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