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