CMS 3D CMS Logo

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