CMS 3D CMS Logo

HcalUHTRTableProducer.cc
Go to the documentation of this file.
1 // system include files
2 #include <memory>
3 
4 // user include files
8 
11 
15 
17 
22 #include <iostream>
23 
25 private:
28  std::vector<int> fedUnpackList_;
29 
30 public:
31  explicit HcalUHTRTableProducer(const edm::ParameterSet& iConfig)
32  : tagRaw_(iConfig.getParameter<edm::InputTag>("InputLabel")),
33  fedUnpackList_(iConfig.getUntrackedParameter<std::vector<int>>("FEDs", std::vector<int>())) {
34  tokenRaw_ = consumes<FEDRawDataCollection>(tagRaw_);
35  produces<nanoaod::FlatTable>("uHTRTable");
36 
37  if (fedUnpackList_.empty()) {
38  // VME range for back-compatibility
40  fedUnpackList_.push_back(i);
41 
42  // uTCA range
44  fedUnpackList_.push_back(i);
45  }
46  }
47 
48  ~HcalUHTRTableProducer() override {}
49 
50  /*
51  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
52  edm::ParameterSetDescription desc;
53  desc.add<edm::InputTag>("tagUHTR")->setComment("Input uMNio digi collection");
54  descriptions.add("HcalUHTRTable", desc);
55  }
56  */
57 
58 private:
59  void produce(edm::Event&, edm::EventSetup const&) override;
60 };
61 
63  std::vector<int> crate;
64  std::vector<int> slot;
65  std::vector<uint32_t> evn;
66  std::vector<uint32_t> bcn;
67  std::vector<uint32_t> orn;
68  std::vector<int> eventType;
69 
71  iEvent.getByToken(tokenRaw_, raw);
72  for (std::vector<int>::const_iterator i = fedUnpackList_.begin(); i != fedUnpackList_.end(); i++) {
73  const FEDRawData& fed = raw->FEDData(*i);
74  hcal::AMC13Header const* hamc13 = (hcal::AMC13Header const*)fed.data();
75  if (!hamc13) {
76  continue;
77  }
78  int namc = hamc13->NAMC();
79  for (int iamc = 0; iamc < namc; iamc++) {
80  HcalUHTRData uhtr(hamc13->AMCPayload(iamc), hamc13->AMCSize(iamc));
81  crate.push_back(uhtr.crateId());
82  slot.push_back(uhtr.slot());
83  evn.push_back(uhtr.l1ANumber());
84  bcn.push_back(uhtr.bunchNumber());
85  orn.push_back(uhtr.orbitNumber());
86  eventType.push_back(uhtr.getEventType());
87  }
88  }
89 
90  auto uHTRNanoTable = std::make_unique<nanoaod::FlatTable>(crate.size(), "uHTR", false, false);
91  uHTRNanoTable->addColumn<int>("crate", crate, "crate");
92  uHTRNanoTable->addColumn<int>("slot", slot, "slot");
93  uHTRNanoTable->addColumn<uint32_t>("evn", evn, "evn");
94  uHTRNanoTable->addColumn<uint32_t>("bcn", bcn, "bcn");
95  uHTRNanoTable->addColumn<uint32_t>("orn", orn, "orn");
96  uHTRNanoTable->addColumn<int>("eventType", eventType, "eventType");
97 
98  iEvent.put(std::move(uHTRNanoTable), "uHTRTable");
99 }
100 
102 //define this as a plug-in
edm::EDGetTokenT< FEDRawDataCollection > tokenRaw_
const uint64_t * AMCPayload(int i) const
Definition: AMC13Header.cc:4
void produce(edm::Event &, edm::EventSetup const &) override
int iEvent
Definition: GenABIO.cc:224
HcalUHTRTableProducer(const edm::ParameterSet &iConfig)
int AMCSize(int i) const
Definition: AMC13Header.h:37
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
int NAMC() const
Definition: AMC13Header.h:25
std::vector< int > fedUnpackList_
HLT enums.
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
def move(src, dest)
Definition: eostools.py:511