CMS 3D CMS Logo

ShallowEventDataProducer.cc
Go to the documentation of this file.
5 
6 // #include <bitset>
7 
9  produces<unsigned int>("run");
10  produces<unsigned int>("event");
11  produces<unsigned int>("bx");
12  produces<unsigned int>("lumi");
13  produces<float>("instLumi");
14  produces<float>("PU");
15 #ifdef ExtendedCALIBTree
16  produces<std::vector<bool>>("TrigTech");
17  produces<std::vector<bool>>("TrigPh");
18 #endif
19 
20  trig_token_ = consumes<L1GlobalTriggerReadoutRecord>(iConfig.getParameter<edm::InputTag>("trigRecord"));
21  scalerToken_ = consumes<LumiScalersCollection>(iConfig.getParameter<edm::InputTag>("lumiScalers"));
22 }
23 
25  auto run = std::make_unique<unsigned int>(iEvent.id().run());
26  auto event = std::make_unique<unsigned int>(iEvent.id().event());
27  auto bx = std::make_unique<unsigned int>(iEvent.bunchCrossing());
28  auto lumi = std::make_unique<unsigned int>(iEvent.luminosityBlock());
29 
31  iEvent.getByToken(trig_token_, gtRecord);
32 
33 #ifdef ExtendedCALIBTree
34  std::vector<bool> TrigTech_(64, false);
35  std::vector<bool> TrigPh_(128, false);
36 #endif
37 
38 #ifdef ExtendedCALIBTree
39  // Get dWord after masking disabled bits
40  DecisionWord dWord = gtRecord->decisionWord();
41  if (!dWord.empty()) { // if board not there this is zero
42  // loop over dec. bit to get total rate (no overlap)
43  for (int i = 0; i < 64; ++i) {
44  TrigPh_[i] = dWord[i];
45  }
46  }
47 
48  TechnicalTriggerWord tw = gtRecord->technicalTriggerWord();
49  if (!tw.empty()) {
50  // loop over dec. bit to get total rate (no overlap)
51  for (int i = 0; i < 64; ++i) {
52  TrigTech_[i] = tw[i];
53  }
54  }
55 
56  auto TrigTech = std::make_unique<std::vector<bool>>(TrigTech_);
57  auto TrigPh = std::make_unique<std::vector<bool>>(TrigPh_);
58 #endif
59 
60  // Luminosity informations
62  float instLumi_ = 0;
63  float PU_ = 0;
64  iEvent.getByToken(scalerToken_, lumiScalers);
65  if (lumiScalers.isValid()) {
66  if (lumiScalers->begin() != lumiScalers->end()) {
67  instLumi_ = lumiScalers->begin()->instantLumi();
68  PU_ = lumiScalers->begin()->pileup();
69  }
70  } else {
71  edm::LogInfo("ShallowEventDataProducer")
72  << "LumiScalers collection not found in the event; will write dummy values";
73  }
74 
75  auto instLumi = std::make_unique<float>(instLumi_);
76  auto PU = std::make_unique<float>(PU_);
77 
78  iEvent.put(std::move(run), "run");
79  iEvent.put(std::move(event), "event");
80  iEvent.put(std::move(bx), "bx");
81  iEvent.put(std::move(lumi), "lumi");
82 #ifdef ExtendedCALIBTree
83  iEvent.put(std::move(TrigTech), "TrigTech");
84  iEvent.put(std::move(TrigPh), "TrigPh");
85 #endif
86  iEvent.put(std::move(instLumi), "instLumi");
87  iEvent.put(std::move(PU), "PU");
88 }
RunNumber_t run() const
Definition: EventID.h:38
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:40
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
int bunchCrossing() const
Definition: EventBase.h:64
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:61
int iEvent
Definition: GenABIO.cc:224
std::vector< bool > DecisionWord
typedefs
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > trig_token_
std::vector< bool > TechnicalTriggerWord
technical trigger bits (64 bits)
edm::EDGetTokenT< LumiScalersCollection > scalerToken_
void produce(edm::Event &, const edm::EventSetup &) override
edm::EventID id() const
Definition: EventBase.h:59
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1
ShallowEventDataProducer(const edm::ParameterSet &)