CMS 3D CMS Logo

SiPixelPhase1RawData.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiPixelPhase1RawData
4 // Class: SiPixelPhase1RawData
5 //
6 
7 // Original Author: Marcel Schneider
8 
13 
16 
17 namespace {
18 
19  class SiPixelPhase1RawData final : public SiPixelPhase1Base {
20  enum { NERRORS, FIFOFULL, TBMMESSAGE, TBMTYPE, TYPE_NERRORS };
21 
22  public:
23  explicit SiPixelPhase1RawData(const edm::ParameterSet& conf);
24  void analyze(const edm::Event&, const edm::EventSetup&) override;
25 
26  private:
28  };
29 
30  SiPixelPhase1RawData::SiPixelPhase1RawData(const edm::ParameterSet& iConfig) : SiPixelPhase1Base(iConfig) {
31  srcToken_ = consumes<edm::DetSetVector<SiPixelRawDataError>>(iConfig.getParameter<edm::InputTag>("src"));
32  }
33 
35  if (!checktrigger(iEvent, iSetup, DCS))
36  return;
37 
39  iEvent.getByToken(srcToken_, input);
40  if (!input.isValid())
41  return;
42 
43  for (auto it = input->begin(); it != input->end(); ++it) {
44  for (auto& siPixelRawDataError : *it) {
45  int fed = siPixelRawDataError.getFedId();
46  int type = siPixelRawDataError.getType();
47  DetId id = it->detId();
48 
49  // encoding of the channel number within the FED error word
50  const uint32_t LINK_bits = 6;
51  const uint32_t LINK_shift = 26;
52  const uint64_t LINK_mask = (1 << LINK_bits) - 1;
53 
54  uint64_t errorWord = 0;
55  // use 64bit word for some error types
56  // invalid header, invalid trailer, size mismatch
57  if (type == 32 || type == 33 || type == 34) {
58  errorWord = siPixelRawDataError.getWord64();
59  } else {
60  errorWord = siPixelRawDataError.getWord32();
61  }
62 
63  int32_t chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
64  // timeout
65  if (type == 29)
66  chanNmbr = -1; // TODO: different formula needed.
67 
68  uint32_t error_data = errorWord & 0xFF;
69 
70  if (type == 28) { // overflow.
71  for (uint32_t i = 0; i < 8; i++) {
72  if (error_data & (1 << i))
73  histo[FIFOFULL].fill(i, id, &iEvent, fed, chanNmbr);
74  }
75  }
76 
77  if (type == 30) { // TBM stuff.
78  uint32_t statemachine_state = errorWord >> 8 & 0xF; // next 4 bits after data
79  const uint32_t tbm_types[16] = {0, 1, 2, 4, 2, 4, 2, 4, 3, 1, 4, 4, 4, 4, 4, 4};
80 
81  histo[TBMTYPE].fill(tbm_types[statemachine_state], id, &iEvent, fed, chanNmbr);
82 
83  for (uint32_t i = 0; i < 8; i++) {
84  if (error_data & (1 << i))
85  histo[TBMMESSAGE].fill(i, id, &iEvent, fed, chanNmbr);
86  }
87  continue; // we don't really consider these as errors.
88  }
89 
90  // note that a DetId of 0xFFFFFFFF can mean 'no DetId'.
91  // We hijack column and row for FED and chan in this case,
92  // the GeometryInterface does understand that.
93 
94  histo[NERRORS].fill(id, &iEvent, fed, chanNmbr);
95  histo[TYPE_NERRORS].fill(type, id, &iEvent, fed, chanNmbr);
96  }
97  }
98 
99  histo[NERRORS].executePerEventHarvesting(&iEvent);
100  }
101 
102 } //namespace
103 
104 DEFINE_FWK_MODULE(SiPixelPhase1RawData);
mps_fire.i
i
Definition: mps_fire.py:355
input
static const std::string input
Definition: EdmProvDump.cc:48
ESHandle.h
edm::EDGetTokenT
Definition: EDGetToken.h:33
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:279
edm::Handle
Definition: AssociativeIterator.h:50
SiPixelPhase1Base
Definition: SiPixelPhase1Base.h:46
DetId
Definition: DetId.h:17
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ntuplemaker.fill
fill
Definition: ntuplemaker.py:304
edm::ParameterSet
Definition: ParameterSet.h:36
CertificationClient_cfi.DCS
DCS
Definition: CertificationClient_cfi.py:9
iEvent
int iEvent
Definition: GenABIO.cc:224
analyze
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
edm::EventSetup
Definition: EventSetup.h:57
DetSetVector.h
SiPixelPhase1Base::analyze
void analyze(edm::Event const &e, edm::EventSetup const &) override=0
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
SiPixelPhase1Base.h
type
type
Definition: HCALResponse.h:21
LocalPoint.h
SiPixelRawDataError.h
cond::uint64_t
unsigned long long uint64_t
Definition: Time.h:13
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15