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 
11 
14 
15 
17  SiPixelPhase1Base(iConfig)
18 {
19  srcToken_ = consumes<DetSetVector<SiPixelRawDataError>>(iConfig.getParameter<edm::InputTag>("src"));
20 }
21 
22 
24  if( !checktrigger(iEvent,iSetup,DCS) ) return;
25 
27  iEvent.getByToken(srcToken_, input);
28  if (!input.isValid()) return;
29 
30  for (auto it = input->begin(); it != input->end(); ++it) {
31  for (auto& siPixelRawDataError : *it) {
32  int fed = siPixelRawDataError.getFedId();
33  int type = siPixelRawDataError.getType();
34  DetId id = it->detId();
35 
36  // encoding of the channel number within the FED error word
37  const uint32_t LINK_bits = 6;
38  const uint32_t LINK_shift = 26;
39  const uint64_t LINK_mask = (1 << LINK_bits) - 1;
40 
41  uint64_t errorWord = 0;
42  // use 64bit word for some error types
43  // invalid header, invalid trailer, size mismatch
44  if (type == 32 || type == 33 || type == 34) {
45  errorWord = siPixelRawDataError.getWord64();
46  } else {
47  errorWord = siPixelRawDataError.getWord32();
48  }
49 
50  int32_t chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
51  // timeout
52  if (type == 29) chanNmbr = -1; // TODO: different formula needed.
53 
54  uint32_t error_data = errorWord & 0xFF;
55 
56  if (type == 28) { // overflow.
57  for (uint32_t i = 0; i < 8; i++) {
58  if (error_data & (1 << i)) histo[FIFOFULL].fill(i, id, &iEvent, fed, chanNmbr);
59  }
60  }
61 
62  if (type == 30) { // TBM stuff.
63  uint32_t statemachine_state = errorWord >> 8 & 0xF; // next 4 bits after data
64  const uint32_t tbm_types[16] = {
65  0, 1, 2, 4,
66  2, 4, 2, 4,
67  3, 1, 4, 4,
68  4, 4, 4, 4
69  };
70 
71  histo[TBMTYPE].fill(tbm_types[statemachine_state], id, &iEvent, fed, chanNmbr);
72 
73  for (uint32_t i = 0; i < 8; i++) {
74  if (error_data & (1 << i)) histo[TBMMESSAGE].fill(i, id, &iEvent, fed, chanNmbr);
75  }
76  continue; // we don't really consider these as errors.
77  }
78 
79  // note that a DetId of 0xFFFFFFFF can mean 'no DetId'.
80  // We hijack column and row for FED and chan in this case,
81  // the GeometryInterface does understand that.
82 
83  histo[NERRORS].fill(id, &iEvent, fed, chanNmbr);
84  histo[TYPE_NERRORS].fill(type, id, &iEvent, fed, chanNmbr);
85  }
86  }
87 
88  histo[NERRORS].executePerEventHarvesting(&iEvent);
89 }
90 
92 
edm::EDGetTokenT< DetSetVector< SiPixelRawDataError > > srcToken_
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
static std::string const input
Definition: EdmProvDump.cc:44
bool checktrigger(const edm::Event &iEvent, const edm::EventSetup &iSetup, const unsigned trgidx) const
void analyze(const edm::Event &, const edm::EventSetup &) override
int iEvent
Definition: GenABIO.cc:230
SiPixelPhase1RawData(const edm::ParameterSet &conf)
bool isValid() const
Definition: HandleBase.h:74
Definition: DetId.h:18
unsigned long long uint64_t
Definition: Time.h:15
std::vector< HistogramManager > histo