CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EventHeader.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <sstream>
3 #include <istream>
4 #include <fstream>
5 #include <iomanip>
6 #include <stdlib.h>
7 #include <string.h>
8 
10 
12  fEvent( 0 ),
13  fLumiBlock( -1 ),
14  fRun( -1 ),
15  fBx( -1 ),
16  fOrbit( -1 ),
17  fAvgInstDelLumi( -999. ),
18  _Debug( false )
19 { }
20 
22 
23 }
24 
25 /* Setup the analysis to put the branch-variables into the tree. */
26 void EventHeader::setup(edm::ConsumesCollector && iC, TTree* HltTree) {
27 
28  fEvent = 0;
29  fLumiBlock=-1;
30  fRun = -1;
31  fBx = -1;
32  fOrbit = -1;
33  fAvgInstDelLumi = -999.;
34 
35  HltTree->Branch("Event", &fEvent, "Event/l");
36  HltTree->Branch("LumiBlock", &fLumiBlock, "LumiBlock/I");
37  HltTree->Branch("Run", &fRun, "Run/I");
38  HltTree->Branch("Bx", &fBx, "Bx/I");
39  HltTree->Branch("Orbit", &fOrbit, "Orbit/I");
40  HltTree->Branch("AvgInstDelLumi", &fAvgInstDelLumi, "AvgInstDelLumi/D");
41 
42  lumi_Token = iC.consumes<LumiSummary,edm::InLumi>(edm::InputTag("lumiProducer"));
43 }
44 
45 /* **Analyze the event** */
46 void EventHeader::analyze(edm::Event const& iEvent, TTree* HltTree) {
47 
48  fEvent = iEvent.id().event();
49  fLumiBlock = iEvent.luminosityBlock();
50  fRun = iEvent.id().run();
51  fBx = iEvent.bunchCrossing();
52  fOrbit = iEvent.orbitNumber();
53 
54 
55  bool lumiException = false;
56  const edm::LuminosityBlock& iLumi = iEvent.getLuminosityBlock();
58  try{
59  iLumi.getByToken(lumi_Token, lumiSummary);
60  lumiSummary->isValid();
61  }
62  catch(cms::Exception&){
63  lumiException = true;
64  }
65  if(!lumiException)
66  fAvgInstDelLumi = lumiSummary->avgInsDelLumi();
67  else
68  fAvgInstDelLumi = -999.;
69 
70 
71  if (_Debug) {
72  std::cout << "EventHeader -- event = " << fEvent << std::endl;
73  std::cout << "EventHeader -- lumisection = " << fLumiBlock << std::endl;
74  std::cout << "EventHeader -- run = " << fRun << std::endl;
75  std::cout << "EventHeader -- bunch crossing = " << fBx << std::endl;
76  std::cout << "EventHeader -- orbit number = " << fOrbit << std::endl;
77  }
78 
79 }
RunNumber_t run() const
Definition: EventID.h:39
EventNumber_t event() const
Definition: EventID.h:41
void analyze(edm::Event const &iEvent, TTree *tree)
Definition: EventHeader.cc:46
void setup(edm::ConsumesCollector &&iC, TTree *tree)
Definition: EventHeader.cc:26
bool getByToken(EDGetToken token, Handle< PROD > &result) const
int bunchCrossing() const
Definition: EventBase.h:65
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:62
tuple lumiSummary
Definition: runregparse.py:290
int iEvent
Definition: GenABIO.cc:230
int fLumiBlock
Definition: EventHeader.h:32
edm::EDGetTokenT< LumiSummary > lumi_Token
Definition: EventHeader.h:40
LuminosityBlock const & getLuminosityBlock() const
Definition: Event.h:85
int orbitNumber() const
Definition: EventBase.h:66
bool isValid() const
Definition: HandleBase.h:75
double fAvgInstDelLumi
Definition: EventHeader.h:36
unsigned long long fEvent
Definition: EventHeader.h:31
edm::EventID id() const
Definition: EventBase.h:59
tuple cout
Definition: gather_cfg.py:145
volatile std::atomic< bool > shutdown_flag false