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