DESY Hbb Analysis Framework
Public Member Functions | Private Attributes | List of all members
analysis::ntuple::EventInfo Class Reference

#include <EventInfo.h>

Public Member Functions

 EventInfo ()
 
 EventInfo (edm::Service< TFileService > &)
 
 EventInfo (TFileDirectory &)
 
void Fill (const edm::Event &)
 
void FixedGridRhoInfo (const edm::InputTag &)
 
void GenEventInfo (const edm::InputTag &)
 
void Init ()
 
void LumiScalersInfo (const edm::InputTag &)
 
void PileupInfo (const edm::InputTag &)
 
void ReadFixedGridRhoInfo (const edm::Event &)
 
void ReadGenEventInfo (const edm::Event &)
 
void ReadLumiScalers (const edm::Event &)
 
void ReadPileupInfo (const edm::Event &)
 
TTree * Tree ()
 
 ~EventInfo ()
 

Private Attributes

int bx_
 
bool do_gen_
 
bool do_lumi_
 
bool do_pu_
 
bool do_rho_
 
int event_
 
edm::InputTag genInfo_
 
double genScale_
 
double genWeight_
 
float instLumi_
 
int lumi_
 
float lumiPU_
 
edm::InputTag lumiScalers_
 
int n_pu_
 
float n_true_pu_
 
int orbit_
 
int pdfid1_
 
int pdfid2_
 
double pdfx1_
 
double pdfx2_
 
edm::InputTag puInfo_
 
double rho_
 
edm::InputTag rho_collection_
 
int run_
 
TTree * tree_
 

Detailed Description

Definition at line 45 of file EventInfo.h.

Constructor & Destructor Documentation

EventInfo::EventInfo ( )

Definition at line 40 of file EventInfo.cc.

41 {
42  // default constructor
43 }
EventInfo::EventInfo ( edm::Service< TFileService > &  fs)

Definition at line 45 of file EventInfo.cc.

References bx_, do_gen_, do_lumi_, do_pu_, do_rho_, event_, lumi_, nano_94X_2017_rereco31Mar18-v1::name, orbit_, run_, and tree_.

46 {
47  std::string name = "EventInfo";
48  tree_ = fs->make<TTree>(name.c_str(),name.c_str());
49 
50  // event output info
51  tree_->Branch("event", &event_, "event/I");
52  tree_->Branch("run" , &run_ , "run/I");
53  tree_->Branch("lumisection" , &lumi_ , "lumisection/I");
54  tree_->Branch("bx" , &bx_ , "bx/I");
55  tree_->Branch("orbit", &orbit_, "orbit/I");
56 
57  do_pu_ = false;
58  do_gen_ = false;
59  do_lumi_ = false;
60  do_rho_ = false;
61 
62 
63 }
EventInfo::EventInfo ( TFileDirectory &  dir)

Definition at line 65 of file EventInfo.cc.

References bx_, do_gen_, do_lumi_, do_pu_, event_, lumi_, nano_94X_2017_rereco31Mar18-v1::name, orbit_, run_, and tree_.

66 {
67  std::string name = "EventInfo";
68  tree_ = dir.make<TTree>(name.c_str(),name.c_str());
69 
70  // event output info
71  tree_->Branch("event", &event_, "event/I");
72  tree_->Branch("run" , &run_ , "run/I");
73  tree_->Branch("lumisection" , &lumi_ , "lumisection/I");
74  tree_->Branch("bx" , &bx_ , "bx/I");
75  tree_->Branch("orbit", &orbit_, "orbit/I");
76 
77  do_pu_ = false;
78  do_gen_ = false;
79  do_lumi_ = false;
80 
81 }
EventInfo::~EventInfo ( )

Definition at line 83 of file EventInfo.cc.

84 {
85  // do anything here that needs to be done at desctruction time
86  // (e.g. close files, deallocate resources etc.)
87 }

Member Function Documentation

void EventInfo::Fill ( const edm::Event &  event)

Definition at line 95 of file EventInfo.cc.

References bx_, do_gen_, do_lumi_, do_pu_, do_rho_, event_, genScale_, genWeight_, lumi_, n_pu_, n_true_pu_, orbit_, pdfid1_, pdfid2_, pdfx1_, pdfx2_, ReadFixedGridRhoInfo(), ReadGenEventInfo(), ReadLumiScalers(), ReadPileupInfo(), run_, and tree_.

96 {
97  using namespace edm;
98 
99  const edm::EventAuxiliary evt = event.eventAuxiliary();
100 
101  event_ = evt.event();
102  run_ = evt.run();
103  lumi_ = evt.luminosityBlock();
104  orbit_ = evt.orbitNumber();
105  bx_ = evt.bunchCrossing();
106 
107  if ( do_pu_ )
108  {
109  ReadPileupInfo(event);
110  }
111  else
112  {
113  n_pu_ = -1;
114  n_true_pu_ = -1;
115  }
116 
117  if ( do_gen_ )
118  {
119  ReadGenEventInfo(event);
120  }
121  else
122  {
123  genWeight_ = -1.;
124  genScale_ = -1.;
125  pdfid1_ = 0;
126  pdfid2_ = 0;
127  pdfx1_ = -1.;
128  pdfx2_ = -1.;
129 
130  }
131 
132  if ( do_lumi_ )
133  {
134  ReadLumiScalers(event);
135  }
136 
137  if ( do_rho_ )
138  {
139  ReadFixedGridRhoInfo(event);
140  }
141 
142  tree_ -> Fill();
143 
144 
145 }
void ReadGenEventInfo(const edm::Event &)
Definition: EventInfo.cc:203
void ReadLumiScalers(const edm::Event &)
Definition: EventInfo.cc:235
void ReadFixedGridRhoInfo(const edm::Event &)
Definition: EventInfo.cc:254
void ReadPileupInfo(const edm::Event &)
Definition: EventInfo.cc:169
void Fill(const edm::Event &)
Definition: EventInfo.cc:95
void EventInfo::FixedGridRhoInfo ( const edm::InputTag &  tag)

Definition at line 245 of file EventInfo.cc.

References do_rho_, rho_, rho_collection_, and tree_.

246 {
247  do_rho_ = true;
248  rho_collection_ = tag;
249 
250  tree_->Branch("rho",&rho_,"rho/D");
251 
252 }
edm::InputTag rho_collection_
Definition: EventInfo.h:100
void EventInfo::GenEventInfo ( const edm::InputTag &  tag)

Definition at line 188 of file EventInfo.cc.

References do_gen_, genInfo_, genScale_, genWeight_, pdfid1_, pdfid2_, pdfx1_, pdfx2_, and tree_.

189 {
190  do_gen_ = true;
191 
192  genInfo_ = tag;
193 
194  tree_->Branch("genWeight" , &genWeight_ , "genWeight/D");
195  tree_->Branch("genScale" , &genScale_ , "genScale/D");
196  tree_->Branch("pdfid1" , &pdfid1_ , "pdfid1/I");
197  tree_->Branch("pdfid2" , &pdfid2_ , "pdfid2/I");
198  tree_->Branch("pdfx1" , &pdfx1_ , "pdfx1/D");
199  tree_->Branch("pdfx2" , &pdfx2_ , "pdfx2/D");
200 
201 }
edm::InputTag genInfo_
Definition: EventInfo.h:83
void EventInfo::Init ( )

Definition at line 148 of file EventInfo.cc.

149 {
150 }
void EventInfo::LumiScalersInfo ( const edm::InputTag &  tag)

Definition at line 224 of file EventInfo.cc.

References do_lumi_, instLumi_, lumiPU_, lumiScalers_, and tree_.

225 {
226  do_lumi_ = true;
227 
228  lumiScalers_ = tag;
229 
230  // lumiScalers
231  tree_->Branch("instantLumi", &instLumi_,"instantLumi/F");
232  tree_->Branch("lumiPileup", &lumiPU_,"lumiPileup/F");
233 }
edm::InputTag lumiScalers_
Definition: EventInfo.h:94
void EventInfo::PileupInfo ( const edm::InputTag &  tag)

Definition at line 158 of file EventInfo.cc.

References do_pu_, n_pu_, n_true_pu_, puInfo_, and tree_.

159 {
160  do_pu_ = true;
161 
162  puInfo_ = tag;
163 
164  tree_->Branch("nPileup" , &n_pu_ , "nPileup/I");
165  tree_->Branch("nTruePileup" , &n_true_pu_, "nTruePileup/F");
166 
167 }
void EventInfo::ReadFixedGridRhoInfo ( const edm::Event &  event)

Definition at line 254 of file EventInfo.cc.

References rho_, and rho_collection_.

Referenced by Fill().

255 {
256  edm::Handle<double> rhoHandler;
257  event.getByLabel(rho_collection_, rhoHandler);
258  rho_ = *(rhoHandler.product());
259 
260 }
edm::InputTag rho_collection_
Definition: EventInfo.h:100
void EventInfo::ReadGenEventInfo ( const edm::Event &  event)

Definition at line 203 of file EventInfo.cc.

References genInfo_, genScale_, genWeight_, pdfid1_, pdfid2_, pdfx1_, and pdfx2_.

Referenced by Fill().

204 {
205  using namespace edm;
206 
207  //
208  edm::Handle<GenEventInfoProduct> hepmc;
209  event.getByLabel(genInfo_, hepmc);
210 
211  if ( hepmc.isValid() )
212  {
213  genWeight_ = hepmc -> weight();
214  genScale_ = hepmc -> qScale();
215  pdfid1_ = hepmc -> pdf() -> id.first;
216  pdfid2_ = hepmc -> pdf() -> id.second;
217  pdfx1_ = hepmc -> pdf() -> x.first;
218  pdfx2_ = hepmc -> pdf() -> x.second;
219  }
220 
221 
222 }
edm::InputTag genInfo_
Definition: EventInfo.h:83
void EventInfo::ReadLumiScalers ( const edm::Event &  event)

Definition at line 235 of file EventInfo.cc.

References instLumi_, lumiPU_, and lumiScalers_.

Referenced by Fill().

236 {
237  edm::Handle<LumiScalersCollection> lumis;
238  event.getByLabel(lumiScalers_, lumis);
239 
240  instLumi_ = lumis -> begin() -> instantLumi();
241  lumiPU_ = lumis -> begin() -> pileup();
242 
243 }
edm::InputTag lumiScalers_
Definition: EventInfo.h:94
void EventInfo::ReadPileupInfo ( const edm::Event &  event)

Definition at line 169 of file EventInfo.cc.

References n_pu_, n_true_pu_, and puInfo_.

Referenced by Fill().

170 {
171  using namespace edm;
172 
173  //
174  edm::Handle<std::vector<PileupSummaryInfo> > handler;
175  event.getByLabel(puInfo_, handler);
176 
177  std::vector<PileupSummaryInfo> pileup_infos = *(handler.product());
178 
179 // Take the first entry - should be enough
180  PileupSummaryInfo pileup_info = pileup_infos.at(0);
181  n_true_pu_ = pileup_info.getTrueNumInteractions();
182  n_pu_ = pileup_info.getPU_NumInteractions();
183 
184 
185 }
TTree * EventInfo::Tree ( )

Definition at line 153 of file EventInfo.cc.

References tree_.

154 {
155  return tree_;
156 }

Member Data Documentation

int analysis::ntuple::EventInfo::bx_
private

Definition at line 70 of file EventInfo.h.

Referenced by EventInfo(), and Fill().

bool analysis::ntuple::EventInfo::do_gen_
private

Definition at line 84 of file EventInfo.h.

Referenced by EventInfo(), Fill(), and GenEventInfo().

bool analysis::ntuple::EventInfo::do_lumi_
private

Definition at line 93 of file EventInfo.h.

Referenced by EventInfo(), Fill(), and LumiScalersInfo().

bool analysis::ntuple::EventInfo::do_pu_
private

Definition at line 78 of file EventInfo.h.

Referenced by EventInfo(), Fill(), and PileupInfo().

bool analysis::ntuple::EventInfo::do_rho_
private

Definition at line 99 of file EventInfo.h.

Referenced by EventInfo(), Fill(), and FixedGridRhoInfo().

int analysis::ntuple::EventInfo::event_
private

Definition at line 67 of file EventInfo.h.

Referenced by EventInfo(), and Fill().

edm::InputTag analysis::ntuple::EventInfo::genInfo_
private

Definition at line 83 of file EventInfo.h.

Referenced by GenEventInfo(), and ReadGenEventInfo().

double analysis::ntuple::EventInfo::genScale_
private

Definition at line 86 of file EventInfo.h.

Referenced by Fill(), GenEventInfo(), and ReadGenEventInfo().

double analysis::ntuple::EventInfo::genWeight_
private

Definition at line 85 of file EventInfo.h.

Referenced by Fill(), GenEventInfo(), and ReadGenEventInfo().

float analysis::ntuple::EventInfo::instLumi_
private

Definition at line 95 of file EventInfo.h.

Referenced by LumiScalersInfo(), and ReadLumiScalers().

int analysis::ntuple::EventInfo::lumi_
private

Definition at line 69 of file EventInfo.h.

Referenced by EventInfo(), and Fill().

float analysis::ntuple::EventInfo::lumiPU_
private

Definition at line 96 of file EventInfo.h.

Referenced by LumiScalersInfo(), and ReadLumiScalers().

edm::InputTag analysis::ntuple::EventInfo::lumiScalers_
private

Definition at line 94 of file EventInfo.h.

Referenced by LumiScalersInfo(), and ReadLumiScalers().

int analysis::ntuple::EventInfo::n_pu_
private

Definition at line 79 of file EventInfo.h.

Referenced by Fill(), PileupInfo(), and ReadPileupInfo().

float analysis::ntuple::EventInfo::n_true_pu_
private

Definition at line 80 of file EventInfo.h.

Referenced by Fill(), PileupInfo(), and ReadPileupInfo().

int analysis::ntuple::EventInfo::orbit_
private

Definition at line 71 of file EventInfo.h.

Referenced by EventInfo(), and Fill().

int analysis::ntuple::EventInfo::pdfid1_
private

Definition at line 87 of file EventInfo.h.

Referenced by Fill(), GenEventInfo(), and ReadGenEventInfo().

int analysis::ntuple::EventInfo::pdfid2_
private

Definition at line 88 of file EventInfo.h.

Referenced by Fill(), GenEventInfo(), and ReadGenEventInfo().

double analysis::ntuple::EventInfo::pdfx1_
private

Definition at line 89 of file EventInfo.h.

Referenced by Fill(), GenEventInfo(), and ReadGenEventInfo().

double analysis::ntuple::EventInfo::pdfx2_
private

Definition at line 90 of file EventInfo.h.

Referenced by Fill(), GenEventInfo(), and ReadGenEventInfo().

edm::InputTag analysis::ntuple::EventInfo::puInfo_
private

Definition at line 77 of file EventInfo.h.

Referenced by PileupInfo(), and ReadPileupInfo().

double analysis::ntuple::EventInfo::rho_
private

Definition at line 101 of file EventInfo.h.

Referenced by FixedGridRhoInfo(), and ReadFixedGridRhoInfo().

edm::InputTag analysis::ntuple::EventInfo::rho_collection_
private

Definition at line 100 of file EventInfo.h.

Referenced by FixedGridRhoInfo(), and ReadFixedGridRhoInfo().

int analysis::ntuple::EventInfo::run_
private

Definition at line 68 of file EventInfo.h.

Referenced by EventInfo(), and Fill().

TTree* analysis::ntuple::EventInfo::tree_
private

The documentation for this class was generated from the following files: