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 beginRun(edm::Run const&, edm::EventSetup const&) override;
60  void produce(edm::Event&, edm::EventSetup const&) override;
61 };
62 
63 void HcalUHTRTableProducer::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {}
64 
66  std::vector<int> crate;
67  std::vector<int> slot;
68  std::vector<uint32_t> evn;
69  std::vector<uint32_t> bcn;
70  std::vector<uint32_t> orn;
71  std::vector<int> eventType;
72 
74  iEvent.getByToken(tokenRaw_, raw);
75  for (std::vector<int>::const_iterator i = fedUnpackList_.begin(); i != fedUnpackList_.end(); i++) {
76  const FEDRawData& fed = raw->FEDData(*i);
77  hcal::AMC13Header const* hamc13 = (hcal::AMC13Header const*)fed.data();
78  if (!hamc13) {
79  continue;
80  }
81  int namc = hamc13->NAMC();
82  for (int iamc = 0; iamc < namc; iamc++) {
83  HcalUHTRData uhtr(hamc13->AMCPayload(iamc), hamc13->AMCSize(iamc));
84  crate.push_back(uhtr.crateId());
85  slot.push_back(uhtr.slot());
86  evn.push_back(uhtr.l1ANumber());
87  bcn.push_back(uhtr.bunchNumber());
88  orn.push_back(uhtr.orbitNumber());
89  eventType.push_back(uhtr.getEventType());
90  }
91  }
92 
93  auto uHTRNanoTable = std::make_unique<nanoaod::FlatTable>(crate.size(), "uHTR", false, false);
94  uHTRNanoTable->addColumn<int>("crate", crate, "crate");
95  uHTRNanoTable->addColumn<int>("slot", slot, "slot");
96  uHTRNanoTable->addColumn<uint32_t>("evn", evn, "evn");
97  uHTRNanoTable->addColumn<uint32_t>("bcn", bcn, "bcn");
98  uHTRNanoTable->addColumn<uint32_t>("orn", orn, "orn");
99  uHTRNanoTable->addColumn<int>("eventType", eventType, "eventType");
100 
101  iEvent.put(std::move(uHTRNanoTable), "uHTRTable");
102 }
103 
105 //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
void beginRun(edm::Run const &, edm::EventSetup const &) override
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
Definition: Run.h:45