CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ZeePlots.cc
Go to the documentation of this file.
1 
3 
21 #include "TFile.h"
22 #include "TH1.h"
23 #include "TH2.h"
24 #include "TF1.h"
25 #include "TRandom.h"
26 
27 
28 #include <iostream>
29 #include <string>
30 #include <stdexcept>
31 #include <vector>
32 
34 
36 {
37 
39  file_ = new TFile(fileName_, "RECREATE");
40 }
41 
42 
44 {
45 
46  file_->Close();
47 
48  delete file_;
49 
50 }
51 
52 //========================================================================
53 
55 
56 
57  file_ -> cd();
58 
59 }
60 //========================================================================
61 
63 
64  file_ -> cd();
65 
66  h1_gen_ZMass_ = new TH1F("gen_ZMass","Generated Z mass",200,0.,150.);
67  h1_gen_ZMass_->SetXTitle("gen_ZMass (GeV)");
68  h1_gen_ZMass_->SetYTitle("events");
69 
70  h1_gen_ZEta_ = new TH1F("gen_ZEta","Eta of gen Z",200,-6.,6.);
71  h1_gen_ZEta_->SetXTitle("#eta");
72  h1_gen_ZEta_->SetYTitle("events");
73 
74  h1_gen_ZPhi_ = new TH1F("gen_ZPhi","Phi of gen Z",200,-4.,4.);
75  h1_gen_ZPhi_->SetXTitle("#phi");
76  h1_gen_ZPhi_->SetYTitle("events");
77 
78  h1_gen_ZRapidity_ = new TH1F("gen_ZRapidity","Rapidity of gen Z",200,-6.,6.);
79  h1_gen_ZRapidity_->SetXTitle("Y");
80  h1_gen_ZRapidity_->SetYTitle("events");
81 
82  h1_gen_ZPt_ = new TH1F("gen_ZPt","Pt of gen Z",200, 0.,100.);
83  h1_gen_ZPt_->SetXTitle("p_{T} (GeV/c)");
84  h1_gen_ZPt_->SetYTitle("events");
85 
86 
87 }
88 
90 
91  file_ -> cd();
92 
93  h1_reco_ZEta_ = new TH1F("reco_ZEta","Eta of reco Z",200,-6.,6.);
94  h1_reco_ZEta_->SetXTitle("#eta");
95  h1_reco_ZEta_->SetYTitle("events");
96 
97  h1_reco_ZTheta_ = new TH1F("reco_ZTheta","Theta of reco Z",200, 0., 4.);
98  h1_reco_ZTheta_->SetXTitle("#theta");
99  h1_reco_ZTheta_->SetYTitle("events");
100 
101  h1_reco_ZRapidity_ = new TH1F("reco_ZRapidity","Rapidity of reco Z",200,-6.,6.);
102  h1_reco_ZRapidity_->SetXTitle("Y");
103  h1_reco_ZRapidity_->SetYTitle("events");
104 
105  h1_reco_ZPhi_ = new TH1F("reco_ZPhi","Phi of reco Z",100,-4.,4.);
106  h1_reco_ZPhi_->SetXTitle("#phi");
107  h1_reco_ZPhi_->SetYTitle("events");
108 
109  h1_reco_ZPt_ = new TH1F("reco_ZPt","Pt of reco Z",200,0.,100.);
110  h1_reco_ZPt_->SetXTitle("p_{T} (GeV/c)");
111  h1_reco_ZPt_->SetYTitle("events");
112 
113 
114 }
115 
116 //========================================================================
117 
118 void ZeePlots::fillZInfo( std::pair<calib::CalibElectron*,calib::CalibElectron*> myZeeCandidate ) {
119 
120  h1_reco_ZEta_->Fill( ZeeKinematicTools::calculateZEta(myZeeCandidate) );
121  h1_reco_ZTheta_->Fill( ZeeKinematicTools::calculateZTheta(myZeeCandidate) );
123  h1_reco_ZPhi_->Fill( ZeeKinematicTools::calculateZPhi(myZeeCandidate) );
124  h1_reco_ZPt_->Fill( ZeeKinematicTools::calculateZPt(myZeeCandidate) );
125 
126 }
127 
128 
129 
130 //========================================================================
131 
133 
134  file_->cd();
135 
136  h1_reco_ZEta_->Write();
137  h1_reco_ZTheta_->Write();
138  h1_reco_ZRapidity_->Write();
139  h1_reco_ZPhi_->Write();
140  h1_reco_ZPt_->Write();
141 
142 }
143 
144 //========================================================================
145 
147 
148  file_->cd();
149 
150  h1_gen_ZRapidity_->Write();
151  h1_gen_ZPt_->Write();
152  h1_gen_ZPhi_->Write();
153 
154 }
155 
156 //========================================================================
157 
158 void ZeePlots::fillZMCInfo( const HepMC::GenEvent* myGenEvent ) {
159 
160  file_->cd();
161 
162  for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin();
163  p != myGenEvent->particles_end(); ++p ) {//loop over MC particles
164 
165  if ( (*p)->pdg_id() == 23 && (*p)->status() == 2 ){
166 
167  h1_gen_ZMass_->Fill( (*p)->momentum().m() );
168  h1_gen_ZEta_->Fill( (*p)->momentum().eta() );
169 
170  float genZ_Y = 0.5 * log ( ( (*p)->momentum().e() + (*p)->momentum().pz() ) / ( (*p)->momentum().e() - (*p)->momentum().pz() ) ) ;
171 
172  h1_gen_ZRapidity_->Fill( genZ_Y );
173  h1_gen_ZPt_->Fill((*p)->momentum().perp());
174  h1_gen_ZPhi_->Fill((*p)->momentum().phi());
175 
176 
177 
178  }
179  }//end loop over MC particles
180 
181  return;
182 }
183 
184 //========================================================================
185 
187 
188  file_->cd();
189 
190  h1_mcEle_Energy_ = new TH1F("mcEleEnergy","mc EleEnergy",300,0.,300.);
191  h1_mcEle_Energy_->SetXTitle("E (GeV)");
192  h1_mcEle_Energy_->SetYTitle("events");
193 
194  h1_mcElePt_ = new TH1F("mcElePt","p_{T} of MC electrons",300,0.,300.);
195  h1_mcElePt_->SetXTitle("p_{T}(GeV/c)");
196  h1_mcElePt_->SetYTitle("events");
197 
198  h1_mcEleEta_ = new TH1F("mcEleEta","Eta of MC electrons",100,-4.,4.);
199  h1_mcEleEta_->SetXTitle("#eta");
200  h1_mcEleEta_->SetYTitle("events");
201 
202  h1_mcElePhi_ = new TH1F("mcElePhi","Phi of MC electrons",100,-4.,4.);
203  h1_mcElePhi_->SetXTitle("#phi");
204  h1_mcElePhi_->SetYTitle("events");
205 
206 }
207 
208 //========================================================================
209 
210 void ZeePlots::fillEleMCInfo( const HepMC::GenEvent* myGenEvent ) {
211 
212  file_->cd();
213 
214  for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin();
215  p != myGenEvent->particles_end(); ++p ) {
216 
217  if ( abs( (*p)->pdg_id() ) == 11 )
218  {
219  h1_mcEle_Energy_->Fill( (*p)->momentum().e() );
220  h1_mcElePt_->Fill( (*p)->momentum().perp() );
221  h1_mcEleEta_->Fill( (*p)->momentum().eta() );
222  h1_mcElePhi_->Fill( (*p)->momentum().phi() );
223 
224  }//matches if ( abs( (*p)->pdg_id() ) == 11 )
225 
226  }//end loop over MC particles
227 
228 }
229 
230 //========================================================================
232 
233  file_->cd();
234 
235  h1_nEleReco_ = new TH1F("h1_nEleReco", "h1_nEleReco", 20, 0, 20 );
236  h1_nEleReco_->SetXTitle("Num. of reco electrons");
237 
238  h1_recoEleEnergy_ = new TH1F("recoEleEnergy","EleEnergy from SC",300,0.,300.);
239  h1_recoEleEnergy_->SetXTitle("eleSCEnergy(GeV)");
240  h1_recoEleEnergy_->SetYTitle("events");
241 
242  h1_recoElePt_ = new TH1F("recoElePt","p_{T} of reco electrons",300,0.,300.);
243  h1_recoElePt_->SetXTitle("p_{T}(GeV/c)");
244  h1_recoElePt_->SetYTitle("events");
245 
246  h1_recoEleEta_ = new TH1F("recoEleEta","Eta of reco electrons",100,-4.,4.);
247  h1_recoEleEta_->SetXTitle("#eta");
248  h1_recoEleEta_->SetYTitle("events");
249 
250 
251  h1_recoElePhi_ = new TH1F("recoElePhi","Phi of reco electrons",100,-4.,4.);
252  h1_recoElePhi_->SetXTitle("#phi");
253  h1_recoElePhi_->SetYTitle("events");
254 
255 
256 
257 }
258 
259 //========================================================================
260 
261 void ZeePlots::fillEleInfo(const reco::GsfElectronCollection* electronCollection) {
262 
263  file_->cd();
264 
265  h1_nEleReco_->Fill(electronCollection->size());
266 
267  for(reco::GsfElectronCollection::const_iterator eleIt = electronCollection->begin(); eleIt != electronCollection->end(); eleIt++)
268  {
269 
270  file_->cd();
271 
272  h1_recoEleEnergy_->Fill( eleIt->superCluster()->energy() );
273  h1_recoElePt_->Fill( eleIt->pt() );
274  h1_recoEleEta_->Fill( eleIt->eta() );
275  h1_recoElePhi_->Fill( eleIt->phi() );
276 
277  }//end loop on electrons
278 
279 }
280 
281 //========================================================================
282 
284 
285  file_->cd();
286 
287  std::cout << "Start with ZeePlots::writeEleHistograms(), done file_->cd(); " << std::endl;
288 
289  h1_recoEleEnergy_->Write();
290  h1_recoElePt_->Write();
291  h1_recoEleEta_->Write();
292  h1_recoElePhi_->Write();
293 
294  std::cout << "Done with ZeePlots::writeEleHistograms() " << std::endl;
295 
296 }
297 
298 //========================================================================
299 
301 
302  file_->cd();
303 
304  std::cout << "Start with ZeePlots::writeMCEleHistograms(), done file_->cd(); " << std::endl;
305 
306  h1_mcEle_Energy_->Write();
307  h1_mcElePt_->Write();
308  h1_mcEleEta_->Write();
309  h1_mcElePhi_->Write();
310 
311  std::cout << "Done with ZeePlots::writeMCEleHistograms() " << std::endl;
312 
313 }
314 
315 //========================================================================
316 
318 
319  file_->cd();
320 
321  h1_FiredTriggers_= new TH1F("h1_FiredTriggers", "h1_FiredTriggers", 5,0,5);
322 
323  h1_HLTVisitedEvents_ = new TH1F("h1_HLTVisitedEvents", "h1_HLTVisitedEvents", 5,0,5);
324 
325  h1_HLT1Electron_FiredEvents_ = new TH1F("h1_HLT1Electron_FiredEvents", "h1_HLT1Electron_FiredEvents", 5,0,5);
326  h1_HLT2Electron_FiredEvents_ = new TH1F("h1_HLT2Electron_FiredEvents", "h1_HLT2Electron_FiredEvents", 5,0,5);
327  h1_HLT2ElectronRelaxed_FiredEvents_ = new TH1F("h1_HLT2ElectronRelaxed_FiredEvents", "h1_HLT2ElectronRelaxed_FiredEvents", 5,0,5);
328 
329  h1_HLT1Electron_HLT2Electron_FiredEvents_ = new TH1F("h1_HLT1Electron_HLT2Electron_FiredEvents", "h1_HLT1Electron_HLT2Electron_FiredEvents", 5,0,5);
330  h1_HLT1Electron_HLT2ElectronRelaxed_FiredEvents_ = new TH1F("h1_HLT1Electron_HLT2ElectronRelaxed_FiredEvents", "h1_HLT1Electron_HLT2ElectronRelaxed_FiredEvents", 5,0,5);
331  h1_HLT2Electron_HLT2ElectronRelaxed_FiredEvents_ = new TH1F("h1_HLT2Electron_HLT2ElectronRelaxed_FiredEvents", "h1_HLT2Electron_HLT2ElectronRelaxed_FiredEvents", 5,0,5);
332 
333  h1_HLT1Electron_HLT2Electron_HLT2ElectronRelaxed_FiredEvents_ = new TH1F("h1_HLT1Electron_HLT2Electron_HLT2ElectronRelaxed_FiredEvents", "h1_HLT1Electron_HLT2Electron_HLT2ElectronRelaxed_FiredEvents", 5,0,5);
334 
335 
336 }
337 
338 
339 //========================================================================
340 
342 
343  file_->cd();
344 
345  int hltCount = hltTriggerResultHandle->size();
346 
347  bool aHLTResults[200] = { false };
348 
349  for(int i = 0 ; i < hltCount ; i++) {
350 
351  aHLTResults[i] = hltTriggerResultHandle->accept(i);
352  if(aHLTResults[i])
353  h1_FiredTriggers_->Fill(i);
354 
355  //HLT bit 32 = HLT1Electron
356  //HLT bit 34 = HLT2Electron
357  //HLT bit 35 = HLT2ElectronRelaxed
358 
359  }
360 
361  h1_HLTVisitedEvents_->Fill(1);
362 
363  if(aHLTResults[32] && !aHLTResults[34] && !aHLTResults[35])
365 
366  if(aHLTResults[34] && !aHLTResults[32] && !aHLTResults[35])
368 
369  if(aHLTResults[35] && !aHLTResults[32] && !aHLTResults[34])
371 
372  if(aHLTResults[32] && aHLTResults[34] && !aHLTResults[35])
374 
375  if(aHLTResults[32] && aHLTResults[35] && !aHLTResults[34])
377 
378  if(aHLTResults[34] && aHLTResults[35] && !aHLTResults[32])
380 
381  if(aHLTResults[32] && aHLTResults[34] && aHLTResults[35])
383 
384 
385 
386 }
387 
388 
390 
391  int myClass = myEle->getRecoElectron()->classification();
392 
393  float myEta = myEle->getRecoElectron()->eta();
394 
395  if(myClass==0 || myClass==100)
396  h1_occupancyVsEtaGold_->Fill(myEta);
397 
398  std::cout<< "[ZeePlots::fillEleClassesPlots]Done gold"<< std::endl;
399 
400  if(myClass==40 || myClass==140)
401  h1_occupancyVsEtaCrack_->Fill(myEta);
402 
403  std::cout<< "[ZeePlots::fillEleClassesPlots]Done crack"<< std::endl;
404 
405  if( (myClass>=30 && myClass<=34) || (myClass>=130 && myClass<=134) )
406  h1_occupancyVsEtaShower_->Fill(myEta);
407 
408  std::cout<< "[ZeePlots::fillEleClassesPlots]Done shower"<< std::endl;
409 
410  if( myClass==10 || myClass==20 || myClass==110 || myClass ==120)
411  h1_occupancyVsEtaSilver_->Fill(myEta);
412 
413  std::cout<< "[ZeePlots::fillEleClassesPlots]Done"<< std::endl;
414 
415 }
416 
417 
419 
420  file_->cd();
421 
422  h1_occupancyVsEtaGold_ = new TH1F("occupancyVsEtaGold","occupancyVsEtaGold", 200, -4.,4.);
423  h1_occupancyVsEtaGold_->SetYTitle("Electron statistics");
424  h1_occupancyVsEtaGold_->SetXTitle("Eta channel");
425 
426  h1_occupancyVsEtaSilver_ = new TH1F("occupancyVsEtaSilver","occupancyVsEtaSilver", 200, -4.,4.);
427  h1_occupancyVsEtaSilver_->SetYTitle("Electron statistics");
428  h1_occupancyVsEtaSilver_->SetXTitle("Eta channel");
429 
430  h1_occupancyVsEtaShower_ = new TH1F("occupancyVsEtaShower","occupancyVsEtaShower", 200, -4.,4.);
431  h1_occupancyVsEtaShower_->SetYTitle("Electron statistics");
432  h1_occupancyVsEtaShower_->SetXTitle("Eta channel");
433 
434  h1_occupancyVsEtaCrack_ = new TH1F("occupancyVsEtaCrack","occupancyVsEtaCrack", 200, -4.,4.);
435  h1_occupancyVsEtaCrack_->SetYTitle("Electron statistics");
436  h1_occupancyVsEtaCrack_->SetXTitle("Eta channel");
437 
438 }
439 
441 
442  file_->cd();
443 
444  h1_occupancyVsEtaGold_->Write();
445  h1_occupancyVsEtaSilver_->Write();
446  h1_occupancyVsEtaShower_->Write();
447  h1_occupancyVsEtaCrack_->Write();
448 
449 }
TH1F * h1_HLTVisitedEvents_
Definition: ZeePlots.h:100
int i
Definition: DBlmapReader.cc:9
void bookEleClassesPlots()
Definition: ZeePlots.cc:418
~ZeePlots()
Definition: ZeePlots.cc:43
TH1F * h1_reco_ZPt_
Definition: ZeePlots.h:118
void fillEleInfo(const reco::GsfElectronCollection *)
Definition: ZeePlots.cc:261
void fillEleMCInfo(const HepMC::GenEvent *)
Definition: ZeePlots.cc:210
TH1F * h1_mcElePhi_
Definition: ZeePlots.h:105
void fillZMCInfo(const HepMC::GenEvent *)
Definition: ZeePlots.cc:158
TH1F * h1_mcEle_Energy_
Definition: ZeePlots.h:102
TH1F * h1_gen_ZPt_
Definition: ZeePlots.h:90
void writeEleClassesPlots()
Definition: ZeePlots.cc:440
TH1F * h1_HLT1Electron_HLT2Electron_FiredEvents_
Definition: ZeePlots.h:96
#define abs(x)
Definition: mlp_lapack.h:159
void writeMCEleHistograms()
Definition: ZeePlots.cc:300
void writeMCZHistograms()
Definition: ZeePlots.cc:146
TH1F * h1_HLT1Electron_HLT2ElectronRelaxed_FiredEvents_
Definition: ZeePlots.h:97
TH1F * h1_gen_ZRapidity_
Definition: ZeePlots.h:87
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
virtual double eta() const
momentum pseudorapidity
TH1F * h1_recoEleEnergy_
Definition: ZeePlots.h:107
TH1F * h1_reco_ZTheta_
Definition: ZeePlots.h:115
static float calculateZEta(const std::pair< calib::CalibElectron *, calib::CalibElectron * > &aZCandidate)
static float calculateZPt(const std::pair< calib::CalibElectron *, calib::CalibElectron * > &aZCandidate)
void bookEleHistograms()
Definition: ZeePlots.cc:231
TH1F * h1_recoElePhi_
Definition: ZeePlots.h:110
TH1F * h1_nEleReco_
Definition: ZeePlots.h:111
TH1F * h1_occupancyVsEtaShower_
Definition: ZeePlots.h:123
TH1F * h1_mcElePt_
Definition: ZeePlots.h:103
TH1F * h1_gen_ZMass_
Definition: ZeePlots.h:86
void openFile()
Definition: ZeePlots.cc:54
TH1F * h1_recoEleEta_
Definition: ZeePlots.h:109
TH1F * h1_reco_ZRapidity_
Definition: ZeePlots.h:116
TH1F * h1_mcEleEta_
Definition: ZeePlots.h:104
TH1F * h1_HLT2Electron_HLT2ElectronRelaxed_FiredEvents_
Definition: ZeePlots.h:98
TFile * file_
Definition: ZeePlots.h:83
void fillHLTInfo(edm::Handle< edm::TriggerResults >)
Definition: ZeePlots.cc:341
static float calculateZRapidity(const std::pair< calib::CalibElectron *, calib::CalibElectron * > &aZCandidate)
TH1F * h1_HLT1Electron_FiredEvents_
Definition: ZeePlots.h:93
void writeZHistograms()
Definition: ZeePlots.cc:132
const char * fileName_
Definition: ZeePlots.h:84
void bookZMCHistograms()
Definition: ZeePlots.cc:62
TH1F * h1_reco_ZEta_
Definition: ZeePlots.h:114
TH1F * h1_HLT1Electron_HLT2Electron_HLT2ElectronRelaxed_FiredEvents_
Definition: ZeePlots.h:99
void writeEleHistograms()
Definition: ZeePlots.cc:283
Classification classification() const
Definition: GsfElectron.h:635
TH1F * h1_HLT2Electron_FiredEvents_
Definition: ZeePlots.h:94
TH1F * h1_gen_ZEta_
Definition: ZeePlots.h:88
ZeePlots(const char *)
Definition: ZeePlots.cc:35
TH1F * h1_occupancyVsEtaGold_
Definition: ZeePlots.h:120
TH1F * h1_recoElePt_
Definition: ZeePlots.h:108
TH1F * h1_gen_ZPhi_
Definition: ZeePlots.h:89
TH1F * h1_reco_ZPhi_
Definition: ZeePlots.h:117
static float calculateZTheta(const std::pair< calib::CalibElectron *, calib::CalibElectron * > &aZCandidate)
TH1F * h1_occupancyVsEtaCrack_
Definition: ZeePlots.h:122
void fillZInfo(std::pair< calib::CalibElectron *, calib::CalibElectron * > myZeeCandidate)
Definition: ZeePlots.cc:118
TH1F * h1_HLT2ElectronRelaxed_FiredEvents_
Definition: ZeePlots.h:95
TH1F * h1_FiredTriggers_
Definition: ZeePlots.h:92
void bookZHistograms()
Definition: ZeePlots.cc:89
const reco::GsfElectron * getRecoElectron()
Definition: CalibElectron.h:32
tuple cout
Definition: gather_cfg.py:121
void bookHLTHistograms()
Definition: ZeePlots.cc:317
void bookEleMCHistograms()
Definition: ZeePlots.cc:186
void fillEleClassesPlots(calib::CalibElectron *)
Definition: ZeePlots.cc:389
static float calculateZPhi(const std::pair< calib::CalibElectron *, calib::CalibElectron * > &aZCandidate)
TH1F * h1_occupancyVsEtaSilver_
Definition: ZeePlots.h:121