CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EgammaObjects.cc
Go to the documentation of this file.
2 
5 
14 
16 
18 {
19  particleID = ps.getParameter<int>("particleID");
20  EtCut = ps.getParameter<int>("EtCut");
21 
22  if( particleID == 22 ) particleString = "Photon";
23  else if( particleID == 11 ) particleString = "Electron";
24  else
25  throw(std::runtime_error("\n\nEgammaObjects: Only 11 = Photon and 22 = Electron are acceptable parictleIDs! Exiting...\n\n"));
26 
27  loadCMSSWObjects(ps);
29 
30  rootFile_ = TFile::Open(ps.getParameter<std::string>("outputFile").c_str(),"RECREATE");
31 
34  hist_deltaEtaVsEt_ = 0 ;
35  hist_deltaEtaVsE_ = 0 ;
42 
43  hist_Phi_ = 0 ;
44  hist_PhiOverTruth_ = 0 ;
47  hist_deltaPhiVsEt_ = 0 ;
48  hist_deltaPhiVsE_ = 0 ;
55 
56  hist_All_recoMass_ = 0 ;
60 
65 
70 
75 
80 
85 
86 }
87 
89 {
90  MCTruthCollection_ = ps.getParameter<edm::InputTag>("MCTruthCollection");
91  RecoCollection_ = ps.getParameter<edm::InputTag>("RecoCollection");
92 }
93 
95 {
96  hist_min_Et_ = ps.getParameter<double>("hist_min_Et");
97  hist_max_Et_ = ps.getParameter<double>("hist_max_Et");
98  hist_bins_Et_ = ps.getParameter<int> ("hist_bins_Et");
99 
100  hist_min_E_ = ps.getParameter<double>("hist_min_E");
101  hist_max_E_ = ps.getParameter<double>("hist_max_E");
102  hist_bins_E_ = ps.getParameter<int> ("hist_bins_E");
103 
104  hist_min_Eta_ = ps.getParameter<double>("hist_min_Eta");
105  hist_max_Eta_ = ps.getParameter<double>("hist_max_Eta");
106  hist_bins_Eta_ = ps.getParameter<int> ("hist_bins_Eta");
107 
108  hist_min_Phi_ = ps.getParameter<double>("hist_min_Phi");
109  hist_max_Phi_ = ps.getParameter<double>("hist_max_Phi");
110  hist_bins_Phi_ = ps.getParameter<int> ("hist_bins_Phi");
111 
112  hist_min_EtOverTruth_ = ps.getParameter<double>("hist_min_EtOverTruth");
113  hist_max_EtOverTruth_ = ps.getParameter<double>("hist_max_EtOverTruth");
114  hist_bins_EtOverTruth_ = ps.getParameter<int> ("hist_bins_EtOverTruth");
115 
116  hist_min_EOverTruth_ = ps.getParameter<double>("hist_min_EOverTruth");
117  hist_max_EOverTruth_ = ps.getParameter<double>("hist_max_EOverTruth");
118  hist_bins_EOverTruth_ = ps.getParameter<int> ("hist_bins_EOverTruth");
119 
120  hist_min_EtaOverTruth_ = ps.getParameter<double>("hist_min_EtaOverTruth");
121  hist_max_EtaOverTruth_ = ps.getParameter<double>("hist_max_EtaOverTruth");
122  hist_bins_EtaOverTruth_ = ps.getParameter<int> ("hist_bins_EtaOverTruth");
123 
124  hist_min_PhiOverTruth_ = ps.getParameter<double>("hist_min_PhiOverTruth");
125  hist_max_PhiOverTruth_ = ps.getParameter<double>("hist_max_PhiOverTruth");
126  hist_bins_PhiOverTruth_ = ps.getParameter<int> ("hist_bins_PhiOverTruth");
127 
128  hist_min_deltaEta_ = ps.getParameter<double>("hist_min_deltaEta");
129  hist_max_deltaEta_ = ps.getParameter<double>("hist_max_deltaEta");
130  hist_bins_deltaEta_ = ps.getParameter<int> ("hist_bins_deltaEta");
131 
132  hist_min_deltaPhi_ = ps.getParameter<double>("hist_min_deltaPhi");
133  hist_max_deltaPhi_ = ps.getParameter<double>("hist_max_deltaPhi");
134  hist_bins_deltaPhi_ = ps.getParameter<int> ("hist_bins_deltaPhi");
135 
136  hist_min_recoMass_ = ps.getParameter<double>("hist_min_recoMass");
137  hist_max_recoMass_ = ps.getParameter<double>("hist_max_recoMass");
138  hist_bins_recoMass_ = ps.getParameter<int> ("hist_bins_recoMass");
139 }
140 
142 {
143  delete rootFile_;
144 }
145 
147 {
148  TH1::SetDefaultSumw2(true);
149 
152 }
153 
155 {
156  hist_Et_
157  = new TH1D("hist_Et_",("Et Distribution of "+particleString).c_str(),
160  = new TH1D("hist_EtOverTruth_",("Reco Et over True Et of "+particleString).c_str(),
163  = new TH1D("hist_EtEfficiency_",("# of True "+particleString+" Reconstructed over # of True "+particleString+" VS Et of "+particleString).c_str(),
166  = new TH1D("hist_EtNumRecoOverNumTrue_",("# of Reco "+particleString+" over # of True "+particleString+" VS Et of "+particleString).c_str(),
168 
169  hist_E_
170  = new TH1D("hist_E_",("E Distribution of "+particleString).c_str(),
173  = new TH1D("hist_EOverTruth_",("Reco E over True E of "+particleString).c_str(),
176  = new TH1D("hist_EEfficiency_",("# of True "+particleString+" Reconstructed over # of True "+particleString+" VS E of "+particleString).c_str(),
179  = new TH1D("hist_ENumRecoOverNumTrue_",("# of Reco "+particleString+" over # of True "+particleString+" VS E of "+particleString).c_str(),
181 
182  hist_Eta_
183  = new TH1D("hist_Eta_",("Eta Distribution of "+particleString).c_str(),
186  = new TH1D("hist_EtaOverTruth_",("Reco Eta over True Eta of "+particleString).c_str(),
189  = new TH1D("hist_EtaEfficiency_",("# of True "+particleString+" Reconstructed over # of True "+particleString+" VS Eta of "+particleString).c_str(),
192  = new TH1D("hist_EtaNumRecoOverNumTrue_",("# of Reco "+particleString+" over # of True "+particleString+" VS Eta of "+particleString).c_str(),
194 
195  hist_Phi_
196  = new TH1D("hist_Phi_",("Phi Distribution of "+particleString).c_str(),
199  = new TH1D("hist_PhiOverTruth_",("Reco Phi over True Phi of "+particleString).c_str(),
202  = new TH1D("hist_PhiEfficiency_",("# of True "+particleString+" Reconstructed over # of True "+particleString+" VS Phi of "+particleString).c_str(),
205  = new TH1D("hist_PhiNumRecoOverNumTrue_",("# of Reco "+particleString+" over # of True "+particleString+" VS Phi of "+particleString).c_str(),
207 
208  std::string recoParticleName;
209 
210  if( particleID == 22 ) recoParticleName = "Higgs";
211  else if( particleID == 11 ) recoParticleName = "Z";
212 
214  = new TH1D("hist_All_recoMass_",(recoParticleName+" Mass from "+particleString+" in All Regions").c_str(),
217  = new TH1D("hist_BarrelOnly_recoMass_",(recoParticleName+" Mass from "+particleString+" in Barrel").c_str(),
220  = new TH1D("hist_EndcapOnly_recoMass_",(recoParticleName+" Mass from "+particleString+" in EndCap").c_str(),
223  = new TH1D("hist_Mixed_recoMass_",(recoParticleName+" Mass from "+particleString+" in Split Detectors").c_str(),
225 
227  = new TH1D("hist_recoMass_withBackgroud_NoEtCut_",(recoParticleName+" Mass from "+particleString+" with Background, No Et Cut").c_str(),
230  = new TH1D("hist_recoMass_withBackgroud_5EtCut_",(recoParticleName+" Mass from "+particleString+" with Background, 5 Et Cut").c_str(),
233  = new TH1D("hist_recoMass_withBackgroud_10EtCut_",(recoParticleName+" Mass from "+particleString+" with Background, 10 Et Cut").c_str(),
236  = new TH1D("hist_recoMass_withBackgroud_20EtCut_",(recoParticleName+" Mass from "+particleString+" with Background, 20 Et Cut").c_str(),
238 }
239 
241 {
243  = new TH2D("_TEMP_scatterPlot_EtOverTruthVsEt_","_TEMP_scatterPlot_EtOverTruthVsEt_",
246  = new TH2D("_TEMP_scatterPlot_EtOverTruthVsE_","_TEMP_scatterPlot_EtOverTruthVsE_",
249  = new TH2D("_TEMP_scatterPlot_EtOverTruthVsEta_","_TEMP_scatterPlot_EtOverTruthVsEta_",
252  = new TH2D("_TEMP_scatterPlot_EtOverTruthVsPhi_","_TEMP_scatterPlot_EtOverTruthVsPhi_",
254 
256  = new TH2D("_TEMP_scatterPlot_EOverTruthVsEt_","_TEMP_scatterPlot_EOverTruthVsEt_",
259  = new TH2D("_TEMP_scatterPlot_EOverTruthVsE_","_TEMP_scatterPlot_EOverTruthVsE_",
262  = new TH2D("_TEMP_scatterPlot_EOverTruthVsEta_","_TEMP_scatterPlot_EOverTruthVsEta_",
265  = new TH2D("_TEMP_scatterPlot_EOverTruthVsPhi_","_TEMP_scatterPlot_EOverTruthVsPhi_",
267 
269  = new TH2D("_TEMP_scatterPlot_deltaEtaVsEt_","_TEMP_scatterPlot_deltaEtaVsEt_",
272  = new TH2D("_TEMP_scatterPlot_deltaEtaVsE_","_TEMP_scatterPlot_deltaEtaVsE_",
275  = new TH2D("_TEMP_scatterPlot_deltaEtaVsEta_","_TEMP_scatterPlot_deltaEtaVsEta_",
278  = new TH2D("_TEMP_scatterPlot_deltaEtaVsPhi_","_TEMP_scatterPlot_deltaEtaVsPhi_",
280 
282  = new TH2D("_TEMP_scatterPlot_deltaPhiVsEt_","_TEMP_scatterPlot_deltaPhiVsEt_",
285  = new TH2D("_TEMP_scatterPlot_deltaPhiVsE_","_TEMP_scatterPlot_deltaPhiVsE_",
288  = new TH2D("_TEMP_scatterPlot_deltaPhiVsEta_","_TEMP_scatterPlot_deltaPhiVsEta_",
291  = new TH2D("_TEMP_scatterPlot_deltaPhiVsPhi_","_TEMP_scatterPlot_deltaPhiVsPhi_",
293 }
294 
295 void EgammaObjects::analyze( const edm::Event& evt, const edm::EventSetup& es )
296 {
297  if( particleID == 22 ) analyzePhotons(evt, es);
298  else if( particleID == 11 ) analyzeElectrons(evt, es);
299 }
300 
302 {
304  evt.getByLabel(RecoCollection_, pPhotons);
305  if (!pPhotons.isValid()) {
306  edm::LogError("EgammaObjects") << "Error! can't get collection with label " << RecoCollection_.label();
307  }
308 
309  const reco::PhotonCollection* photons = pPhotons.product();
310  std::vector<reco::Photon> photonsMCMatched;
311 
312  for(reco::PhotonCollection::const_iterator aClus = photons->begin(); aClus != photons->end(); aClus++)
313  {
314  if(aClus->et() >= EtCut)
315  {
316  hist_Et_->Fill(aClus->et());
317  hist_E_->Fill(aClus->energy());
318  hist_Eta_->Fill(aClus->eta());
319  hist_Phi_->Fill(aClus->phi());
320  }
321  }
322 
323  for(int firstPhoton = 0, numPhotons = photons->size(); firstPhoton < numPhotons - 1; firstPhoton++)
324  for(int secondPhoton = firstPhoton + 1; secondPhoton < numPhotons; secondPhoton++)
325  {
326  reco::Photon pOne = (*photons)[firstPhoton];
327  reco::Photon pTwo = (*photons)[secondPhoton];
328 
329  double recoMass = findRecoMass(pOne, pTwo);
330 
331  hist_recoMass_withBackgroud_NoEtCut_->Fill(recoMass);
332 
333  if(pOne.et() >= 5 && pTwo.et() >= 5)
334  hist_recoMass_withBackgroud_5EtCut_->Fill(recoMass);
335 
336  if(pOne.et() >= 10 && pTwo.et() >= 10)
337  hist_recoMass_withBackgroud_10EtCut_->Fill(recoMass);
338 
339  if(pOne.et() >= 20 && pTwo.et() >= 20)
340  hist_recoMass_withBackgroud_20EtCut_->Fill(recoMass);
341  }
342 
344  evt.getByLabel(MCTruthCollection_, pMCTruth);
345  if (!pMCTruth.isValid()) {
346  edm::LogError("EgammaObjects") << "Error! can't get collection with label " << MCTruthCollection_.label();
347  }
348 
349  const HepMC::GenEvent* genEvent = pMCTruth->GetEvent();
350 
351  for(HepMC::GenEvent::particle_const_iterator currentParticle = genEvent->particles_begin();
352  currentParticle != genEvent->particles_end(); currentParticle++ )
353  {
354  if(abs((*currentParticle)->pdg_id())==22 && (*currentParticle)->status()==1
355  && (*currentParticle)->momentum().e()/cosh(ecalEta((*currentParticle)->momentum().eta(), (*currentParticle)->production_vertex()->position().z()/10.,
356  (*currentParticle)->production_vertex()->position().perp()/10.)) >= EtCut)
357  {
358  HepMC::FourVector vtx = (*currentParticle)->production_vertex()->position();
359  double phiTrue = (*currentParticle)->momentum().phi();
360  double etaTrue = ecalEta((*currentParticle)->momentum().eta(), vtx.z()/10., vtx.perp()/10.);
361  double eTrue = (*currentParticle)->momentum().e();
362  double etTrue = (*currentParticle)->momentum().e()/cosh(etaTrue);
363 
364  double etaCurrent, etaFound = -999;
365  double phiCurrent, phiFound = -999;
366  double etCurrent, etFound = -999;
367  double eCurrent, eFound = -999;
368 
369  reco::Photon bestMatchPhoton;
370 
371  double closestParticleDistance = 999;
372 
373  for(reco::PhotonCollection::const_iterator aClus = photons->begin(); aClus != photons->end(); aClus++)
374  {
375  if(aClus->et() > EtCut)
376  {
377  etaCurrent = aClus->eta();
378  phiCurrent = aClus->phi();
379  etCurrent = aClus->et();
380  eCurrent = aClus->energy();
381 
382  double deltaPhi = phiCurrent-phiTrue;
383  if(deltaPhi > Geom::pi()) deltaPhi -= 2.*Geom::pi();
384  if(deltaPhi < -Geom::pi()) deltaPhi += 2.*Geom::pi();
385  double deltaR = std::sqrt(std::pow(etaCurrent-etaTrue,2)+std::pow(deltaPhi,2));
386 
387  if(deltaR < closestParticleDistance)
388  {
389  etFound = etCurrent;
390  eFound = eCurrent;
391  etaFound = etaCurrent;
392  phiFound = phiCurrent;
393  closestParticleDistance = deltaR;
394  bestMatchPhoton = *aClus;
395  }
396  }
397  }
398 
399  if(closestParticleDistance < 0.05 && etFound/etTrue > .5 && etFound/etTrue < 1.5)
400  {
401  hist_EtOverTruth_->Fill(etFound/etTrue);
402  hist_EOverTruth_->Fill(eFound/eTrue);
403  hist_EtaOverTruth_->Fill(etaFound/etaTrue);
404  hist_PhiOverTruth_->Fill(phiFound/phiTrue);
405 
406  hist_EtEfficiency_->Fill(etTrue);
407  hist_EEfficiency_->Fill(eTrue);
408  hist_EtaEfficiency_->Fill(etaTrue);
409  hist_PhiEfficiency_->Fill(phiTrue);
410 
411  double deltaPhi = phiFound-phiTrue;
412  if(deltaPhi > Geom::pi()) deltaPhi -= 2.*Geom::pi();
413  if(deltaPhi < -Geom::pi()) deltaPhi += 2.*Geom::pi();
414 
415  _TEMP_scatterPlot_EtOverTruthVsEt_->Fill(etFound,etFound/etTrue);
416  _TEMP_scatterPlot_EtOverTruthVsE_->Fill(eFound,etFound/etTrue);
417  _TEMP_scatterPlot_EtOverTruthVsEta_->Fill(etaFound,etFound/etTrue);
418  _TEMP_scatterPlot_EtOverTruthVsPhi_->Fill(phiFound,etFound/etTrue);
419 
420  _TEMP_scatterPlot_EOverTruthVsEt_->Fill(etFound,eFound/eTrue);
421  _TEMP_scatterPlot_EOverTruthVsE_->Fill(eFound,eFound/eTrue);
422  _TEMP_scatterPlot_EOverTruthVsEta_->Fill(etaFound,eFound/eTrue);
423  _TEMP_scatterPlot_EOverTruthVsPhi_->Fill(phiFound,eFound/eTrue);
424 
425  _TEMP_scatterPlot_deltaEtaVsEt_->Fill(etFound,etaFound-etaTrue);
426  _TEMP_scatterPlot_deltaEtaVsE_->Fill(eFound,etaFound-etaTrue);
427  _TEMP_scatterPlot_deltaEtaVsEta_->Fill(etaFound,etaFound-etaTrue);
428  _TEMP_scatterPlot_deltaEtaVsPhi_->Fill(phiFound,etaFound-etaTrue);
429 
430  _TEMP_scatterPlot_deltaPhiVsEt_->Fill(etFound,deltaPhi);
431  _TEMP_scatterPlot_deltaPhiVsE_->Fill(eFound,deltaPhi);
432  _TEMP_scatterPlot_deltaPhiVsEta_->Fill(etaFound,deltaPhi);
433  _TEMP_scatterPlot_deltaPhiVsPhi_->Fill(phiFound,deltaPhi);
434 
435  photonsMCMatched.push_back(bestMatchPhoton);
436  }
437 
438  hist_EtNumRecoOverNumTrue_->Fill(etTrue);
439  hist_ENumRecoOverNumTrue_->Fill(eTrue);
440  hist_EtaNumRecoOverNumTrue_->Fill(etaTrue);
441  hist_PhiNumRecoOverNumTrue_->Fill(phiTrue);
442  }
443  }
444 
445  if(photonsMCMatched.size() == 2)
446  {
447  reco::Photon pOne = photonsMCMatched[0];
448  reco::Photon pTwo = photonsMCMatched[1];
449 
450  double recoMass = findRecoMass(pOne, pTwo);
451 
452  hist_All_recoMass_->Fill(recoMass);
453 
454  if(pOne.superCluster()->seed()->algo() == 1 && pTwo.superCluster()->seed()->algo() == 1)
455  hist_BarrelOnly_recoMass_->Fill(recoMass);
456  else if(pOne.superCluster()->seed()->algo() == 0 && pTwo.superCluster()->seed()->algo() == 0)
457  hist_EndcapOnly_recoMass_->Fill(recoMass);
458  else
459  hist_Mixed_recoMass_->Fill(recoMass);
460  }
461 }
462 
464 {
466  evt.getByLabel(RecoCollection_, pElectrons);
467  if (!pElectrons.isValid()) {
468  edm::LogError("DOEPlotsProducerElectrons") << "Error! can't get collection with label " << RecoCollection_.label();
469  }
470 
471  const reco::GsfElectronCollection* electrons = pElectrons.product();
472  std::vector<reco::GsfElectron> electronsMCMatched;
473 
474  for(reco::GsfElectronCollection::const_iterator aClus = electrons->begin(); aClus != electrons->end(); aClus++)
475  {
476  if(aClus->et() >= EtCut)
477  {
478  hist_Et_->Fill(aClus->et());
479  hist_E_->Fill(aClus->energy());
480  hist_Eta_->Fill(aClus->eta());
481  hist_Phi_->Fill(aClus->phi());
482  }
483  }
484 
485  for(int firstElectron = 0, numElectrons = electrons->size(); firstElectron < numElectrons - 1; firstElectron++)
486  for(int secondElectron = firstElectron + 1; secondElectron < numElectrons; secondElectron++)
487  {
488  reco::GsfElectron eOne = (*electrons)[firstElectron];
489  reco::GsfElectron eTwo = (*electrons)[secondElectron];
490 
491  double recoMass = findRecoMass(eOne, eTwo);
492 
493  hist_recoMass_withBackgroud_NoEtCut_->Fill(recoMass);
494 
495  if(eOne.et() >= 5 && eTwo.et() >= 5)
496  hist_recoMass_withBackgroud_5EtCut_->Fill(recoMass);
497 
498  if(eOne.et() >= 10 && eTwo.et() >= 10)
499  hist_recoMass_withBackgroud_10EtCut_->Fill(recoMass);
500 
501  if(eOne.et() >= 20 && eTwo.et() >= 20)
502  hist_recoMass_withBackgroud_20EtCut_->Fill(recoMass);
503  }
504 
506  evt.getByLabel(MCTruthCollection_, pMCTruth);
507  if (!pMCTruth.isValid()) {
508  edm::LogError("DOEPlotsProducerElectrons") << "Error! can't get collection with label " << MCTruthCollection_.label();
509  }
510 
511  const HepMC::GenEvent* genEvent = pMCTruth->GetEvent();
512  for(HepMC::GenEvent::particle_const_iterator currentParticle = genEvent->particles_begin();
513  currentParticle != genEvent->particles_end(); currentParticle++ )
514  {
515  if(abs((*currentParticle)->pdg_id())==11 && (*currentParticle)->status()==1
516  && (*currentParticle)->momentum().e()/cosh((*currentParticle)->momentum().eta()) >= EtCut)
517  {
518  double phiTrue = (*currentParticle)->momentum().phi();
519  double etaTrue = (*currentParticle)->momentum().eta();
520  double eTrue = (*currentParticle)->momentum().e();
521  double etTrue = (*currentParticle)->momentum().e()/cosh(etaTrue);
522 
523  double etaCurrent, etaFound = -999;
524  double phiCurrent, phiFound = -999;
525  double etCurrent, etFound = -999;
526  double eCurrent, eFound = -999;
527 
528  reco::GsfElectron bestMatchElectron;
529 
530  double closestParticleDistance = 999;
531 
532  for(reco::GsfElectronCollection::const_iterator aClus = electrons->begin(); aClus != electrons->end(); aClus++)
533  {
534  if(aClus->et() > EtCut)
535  {
536  etaCurrent = aClus->eta();
537  phiCurrent = aClus->phi();
538  etCurrent = aClus->et();
539  eCurrent = aClus->energy();
540 
541  double deltaPhi = phiCurrent-phiTrue;
542  if(deltaPhi > Geom::pi()) deltaPhi -= 2.*Geom::pi();
543  if(deltaPhi < -Geom::pi()) deltaPhi += 2.*Geom::pi();
544  double deltaR = std::sqrt(std::pow(etaCurrent-etaTrue,2)+std::pow(deltaPhi,2));
545 
546  if(deltaR < closestParticleDistance)
547  {
548  etFound = etCurrent;
549  eFound = eCurrent;
550  etaFound = etaCurrent;
551  phiFound = phiCurrent;
552  closestParticleDistance = deltaR;
553  bestMatchElectron = *aClus;
554  }
555  }
556  }
557 
558  if(closestParticleDistance < 0.05 && etFound/etTrue > .5 && etFound/etTrue < 1.5)
559  {
560  hist_EtOverTruth_->Fill(etFound/etTrue);
561  hist_EOverTruth_->Fill(eFound/eTrue);
562  hist_EtaOverTruth_->Fill(etaFound/etaTrue);
563  hist_PhiOverTruth_->Fill(phiFound/phiTrue);
564 
565  hist_EtEfficiency_->Fill(etTrue);
566  hist_EEfficiency_->Fill(eTrue);
567  hist_EtaEfficiency_->Fill(etaTrue);
568  hist_PhiEfficiency_->Fill(phiTrue);
569 
570  double deltaPhi = phiFound-phiTrue;
571  if(deltaPhi > Geom::pi()) deltaPhi -= 2.*Geom::pi();
572  if(deltaPhi < -Geom::pi()) deltaPhi += 2.*Geom::pi();
573 
574  _TEMP_scatterPlot_EtOverTruthVsEt_->Fill(etFound,etFound/etTrue);
575  _TEMP_scatterPlot_EtOverTruthVsE_->Fill(eFound,etFound/etTrue);
576  _TEMP_scatterPlot_EtOverTruthVsEta_->Fill(etaFound,etFound/etTrue);
577  _TEMP_scatterPlot_EtOverTruthVsPhi_->Fill(phiFound,etFound/etTrue);
578 
579  _TEMP_scatterPlot_EOverTruthVsEt_->Fill(etFound,eFound/eTrue);
580  _TEMP_scatterPlot_EOverTruthVsE_->Fill(eFound,eFound/eTrue);
581  _TEMP_scatterPlot_EOverTruthVsEta_->Fill(etaFound,eFound/eTrue);
582  _TEMP_scatterPlot_EOverTruthVsPhi_->Fill(phiFound,eFound/eTrue);
583 
584  _TEMP_scatterPlot_deltaEtaVsEt_->Fill(etFound,etaFound-etaTrue);
585  _TEMP_scatterPlot_deltaEtaVsE_->Fill(eFound,etaFound-etaTrue);
586  _TEMP_scatterPlot_deltaEtaVsEta_->Fill(etaFound,etaFound-etaTrue);
587  _TEMP_scatterPlot_deltaEtaVsPhi_->Fill(phiFound,etaFound-etaTrue);
588 
589  _TEMP_scatterPlot_deltaPhiVsEt_->Fill(etFound,deltaPhi);
590  _TEMP_scatterPlot_deltaPhiVsE_->Fill(eFound,deltaPhi);
591  _TEMP_scatterPlot_deltaPhiVsEta_->Fill(etaFound,deltaPhi);
592  _TEMP_scatterPlot_deltaPhiVsPhi_->Fill(phiFound,deltaPhi);
593 
594  electronsMCMatched.push_back(bestMatchElectron);
595  }
596 
597  hist_EtNumRecoOverNumTrue_->Fill(etTrue);
598  hist_ENumRecoOverNumTrue_->Fill(eTrue);
599  hist_EtaNumRecoOverNumTrue_->Fill(etaTrue);
600  hist_PhiNumRecoOverNumTrue_->Fill(phiTrue);
601  }
602  }
603 
604  if(electronsMCMatched.size() == 2)
605  {
606  reco::GsfElectron eOne = electronsMCMatched[0];
607  reco::GsfElectron eTwo = electronsMCMatched[1];
608 
609  double recoMass = findRecoMass(eOne, eTwo);
610 
611  hist_All_recoMass_->Fill(recoMass);
612 
613  if(eOne.superCluster()->seed()->algo() == 1 && eTwo.superCluster()->seed()->algo() == 1)
614  hist_BarrelOnly_recoMass_->Fill(recoMass);
615  else if(eOne.superCluster()->seed()->algo() == 0 && eTwo.superCluster()->seed()->algo() == 0)
616  hist_EndcapOnly_recoMass_->Fill(recoMass);
617  else
618  hist_Mixed_recoMass_->Fill(recoMass);
619  }
620 }
621 
623 {
624  double cosTheta
625  = (cos(pOne.superCluster()->phi() - pTwo.superCluster()->phi()) + sinh(pOne.superCluster()->eta()) * sinh(pTwo.superCluster()->eta())) /
626  (cosh(pOne.superCluster()->eta()) * cosh(pTwo.superCluster()->eta()));
627 
628  double recoMass = sqrt(2 * (pOne.superCluster())->energy() * (pTwo.superCluster())->energy() * (1 - cosTheta));
629 
630  return recoMass;
631 }
632 
634 {
635  double cosTheta
636  = (cos(eOne.caloPosition().phi() - eTwo.caloPosition().phi()) + sinh(eOne.caloPosition().eta()) * sinh(eTwo.caloPosition().eta())) /
637  (cosh(eOne.caloPosition().eta()) * cosh(eTwo.caloPosition().eta()));
638 
639  double recoMass = sqrt(2 * eOne.caloEnergy() * eTwo.caloEnergy() * (1 - cosTheta));
640 
641  return recoMass;
642 }
643 
644 float EgammaObjects::ecalEta(float EtaParticle , float Zvertex, float plane_Radius)
645 {
646  const float R_ECAL = 136.5;
647  const float Z_Endcap = 328.0;
648  const float etaBarrelEndcap = 1.479;
649 
650  if(EtaParticle != 0.)
651  {
652  float Theta = 0.0 ;
653  float ZEcal = (R_ECAL-plane_Radius)*sinh(EtaParticle)+Zvertex;
654 
655  if(ZEcal != 0.0) Theta = atan(R_ECAL/ZEcal);
656  if(Theta<0.0) Theta = Theta+Geom::pi() ;
657 
658  float ETA = - log(tan(0.5*Theta));
659 
660  if( std::abs(ETA) > etaBarrelEndcap )
661  {
662  float Zend = Z_Endcap ;
663  if(EtaParticle<0.0 ) Zend = -Zend ;
664  float Zlen = Zend - Zvertex ;
665  float RR = Zlen/sinh(EtaParticle);
666  Theta = atan((RR+plane_Radius)/Zend);
667  if(Theta<0.0) Theta = Theta+Geom::pi() ;
668  ETA = - log(tan(0.5*Theta));
669  }
670 
671  return ETA;
672  }
673  else
674  {
675  edm::LogWarning("") << "[EgammaObjects::ecalEta] Warning: Eta equals to zero, not correcting" ;
676  return EtaParticle;
677  }
678 }
679 
680 
682 {
683  rootFile_->cd();
684  rootFile_->mkdir(particleString.c_str());
685 
688  fitHistos();
689 
690  applyLabels();
691  setDrawOptions();
692  saveHistos();
693  rootFile_->Close();
694 }
695 
697 {
698  _TEMP_scatterPlot_EtOverTruthVsEt_->FitSlicesY(0,1,hist_bins_Et_,10,"QRG3");
699  _TEMP_scatterPlot_EtOverTruthVsE_->FitSlicesY(0,1,hist_bins_E_,10,"QRG3");
700  _TEMP_scatterPlot_EtOverTruthVsEta_->FitSlicesY(0,1,hist_bins_Eta_,10,"QRG2");
701  _TEMP_scatterPlot_EtOverTruthVsPhi_->FitSlicesY(0,1,hist_bins_Phi_,10,"QRG2");
702 
703  _TEMP_scatterPlot_EOverTruthVsEt_->FitSlicesY(0,1,hist_bins_Et_,10,"QRG3");
704  _TEMP_scatterPlot_EOverTruthVsE_->FitSlicesY(0,1,hist_bins_E_,10,"QRG3");
705  _TEMP_scatterPlot_EOverTruthVsEta_->FitSlicesY(0,1,hist_bins_Eta_,10,"QRG2");
706  _TEMP_scatterPlot_EOverTruthVsPhi_->FitSlicesY(0,1,hist_bins_Phi_,10,"QRG2");
707 
708  _TEMP_scatterPlot_deltaEtaVsEt_->FitSlicesY(0,1,hist_bins_Et_,10,"QRG3");
709  _TEMP_scatterPlot_deltaEtaVsE_->FitSlicesY(0,1,hist_bins_E_,10,"QRG3");
710  _TEMP_scatterPlot_deltaEtaVsEta_->FitSlicesY(0,1,hist_bins_Eta_,10,"QRG2");
711  _TEMP_scatterPlot_deltaEtaVsPhi_->FitSlicesY(0,1,hist_bins_Phi_,10,"QRG2");
712 
713  _TEMP_scatterPlot_deltaPhiVsEt_->FitSlicesY(0,1,hist_bins_Et_,10,"QRG3");
714  _TEMP_scatterPlot_deltaPhiVsE_->FitSlicesY(0,1,hist_bins_E_,10,"QRG3");
715  _TEMP_scatterPlot_deltaPhiVsEta_->FitSlicesY(0,1,hist_bins_Eta_,10,"QRG2");
716  _TEMP_scatterPlot_deltaPhiVsPhi_->FitSlicesY(0,1,hist_bins_Phi_,10,"QRG2");
717 
718  hist_EtOverTruthVsEt_ = (TH1D*)gDirectory->Get("_TEMP_scatterPlot_EtOverTruthVsEt__1");
719  hist_EtOverTruthVsE_ = (TH1D*)gDirectory->Get("_TEMP_scatterPlot_EtOverTruthVsE__1");
720  hist_EtOverTruthVsEta_ = (TH1D*)gDirectory->Get("_TEMP_scatterPlot_EtOverTruthVsEta__1");
721  hist_EtOverTruthVsPhi_ = (TH1D*)gDirectory->Get("_TEMP_scatterPlot_EtOverTruthVsPhi__1");
722 
723  hist_EOverTruthVsEt_ = (TH1D*)gDirectory->Get("_TEMP_scatterPlot_EOverTruthVsEt__1");
724  hist_EOverTruthVsE_ = (TH1D*)gDirectory->Get("_TEMP_scatterPlot_EOverTruthVsE__1");
725  hist_EOverTruthVsEta_ = (TH1D*)gDirectory->Get("_TEMP_scatterPlot_EOverTruthVsEta__1");
726  hist_EOverTruthVsPhi_ = (TH1D*)gDirectory->Get("_TEMP_scatterPlot_EOverTruthVsPhi__1");
727 
728  hist_deltaEtaVsEt_ = (TH1D*)gDirectory->Get("_TEMP_scatterPlot_deltaEtaVsEt__1");
729  hist_deltaEtaVsE_ = (TH1D*)gDirectory->Get("_TEMP_scatterPlot_deltaEtaVsE__1");
730  hist_deltaEtaVsEta_ = (TH1D*)gDirectory->Get("_TEMP_scatterPlot_deltaEtaVsEta__1");
731  hist_deltaEtaVsPhi_ = (TH1D*)gDirectory->Get("_TEMP_scatterPlot_deltaEtaVsPhi__1");
732 
733  hist_deltaPhiVsEt_ = (TH1D*)gDirectory->Get("_TEMP_scatterPlot_deltaPhiVsEt__1");
734  hist_deltaPhiVsE_ = (TH1D*)gDirectory->Get("_TEMP_scatterPlot_deltaPhiVsE__1");
735  hist_deltaPhiVsEta_ = (TH1D*)gDirectory->Get("_TEMP_scatterPlot_deltaPhiVsEta__1");
736  hist_deltaPhiVsPhi_ = (TH1D*)gDirectory->Get("_TEMP_scatterPlot_deltaPhiVsPhi__1");
737 
738  hist_EtOverTruthVsEt_->SetNameTitle("hist_EtOverTruthVsEt_",("Reco Et over True Et VS Et of "+particleString).c_str());
739  hist_EtOverTruthVsE_->SetNameTitle("hist_EtOverTruthVsE_",("Reco Et over True Et VS E of "+particleString).c_str());
740  hist_EtOverTruthVsEta_->SetNameTitle("hist_EtOverTruthVsEta_",("Reco Et over True Et VS Eta of "+particleString).c_str());
741  hist_EtOverTruthVsPhi_->SetNameTitle("hist_EtOverTruthVsPhi_",("Reco Et over True Et VS Phi of "+particleString).c_str());
742 
743  hist_EOverTruthVsEt_->SetNameTitle("hist_EOverTruthVsEt_",("Reco E over True E VS Et of "+particleString).c_str());
744  hist_EOverTruthVsE_->SetNameTitle("hist_EOverTruthVsE_",("Reco E over True E VS E of "+particleString).c_str());
745  hist_EOverTruthVsEta_->SetNameTitle("hist_EOverTruthVsEta_",("Reco E over True E VS Eta of "+particleString).c_str());
746  hist_EOverTruthVsPhi_->SetNameTitle("hist_EOverTruthVsPhi_",("Reco E over True E VS Phi of "+particleString).c_str());
747 
748  hist_deltaEtaVsEt_->SetNameTitle("hist_deltaEtaVsEt_",("delta Eta VS Et of "+particleString).c_str());
749  hist_deltaEtaVsE_->SetNameTitle("hist_deltaEtaVsE_",("delta Eta VS E of "+particleString).c_str());
750  hist_deltaEtaVsEta_->SetNameTitle("hist_deltaEtaVsEta_",("delta Eta VS Eta of "+particleString).c_str());
751  hist_deltaEtaVsPhi_->SetNameTitle("hist_deltaEtaVsPhi_",("delta Eta VS Phi of "+particleString).c_str());
752 
753  hist_deltaPhiVsEt_->SetNameTitle("hist_deltaPhiVsEt_",("delta Phi VS Et of "+particleString).c_str());
754  hist_deltaPhiVsE_->SetNameTitle("hist_deltaPhiVsE_",("delta Phi VS E of "+particleString).c_str());
755  hist_deltaPhiVsEta_->SetNameTitle("hist_deltaPhiVsEta_",("delta Phi VS Eta of "+particleString).c_str());
756  hist_deltaPhiVsPhi_->SetNameTitle("hist_deltaPhiVsPhi_",("delta Phi VS Phi of "+particleString).c_str());
757 
758  hist_resolutionEtVsEt_ = (TH1D*)gDirectory->Get("_TEMP_scatterPlot_EtOverTruthVsEt__2");
759  hist_resolutionEtVsE_ = (TH1D*)gDirectory->Get("_TEMP_scatterPlot_EtOverTruthVsE__2");
760  hist_resolutionEtVsEta_ = (TH1D*)gDirectory->Get("_TEMP_scatterPlot_EtOverTruthVsEta__2");
761  hist_resolutionEtVsPhi_ = (TH1D*)gDirectory->Get("_TEMP_scatterPlot_EtOverTruthVsPhi__2");
762 
763  hist_resolutionEVsEt_ = (TH1D*)gDirectory->Get("_TEMP_scatterPlot_EOverTruthVsEt__2");
764  hist_resolutionEVsE_ = (TH1D*)gDirectory->Get("_TEMP_scatterPlot_EOverTruthVsE__2");
765  hist_resolutionEVsEta_ = (TH1D*)gDirectory->Get("_TEMP_scatterPlot_EOverTruthVsEta__2");
766  hist_resolutionEVsPhi_ = (TH1D*)gDirectory->Get("_TEMP_scatterPlot_EOverTruthVsPhi__2");
767 
768  hist_resolutionEtaVsEt_ = (TH1D*)gDirectory->Get("_TEMP_scatterPlot_deltaEtaVsEt__2");
769  hist_resolutionEtaVsE_ = (TH1D*)gDirectory->Get("_TEMP_scatterPlot_deltaEtaVsE__2");
770  hist_resolutionEtaVsEta_ = (TH1D*)gDirectory->Get("_TEMP_scatterPlot_deltaEtaVsEta__2");
771  hist_resolutionEtaVsPhi_ = (TH1D*)gDirectory->Get("_TEMP_scatterPlot_deltaEtaVsPhi__2");
772 
773  hist_resolutionPhiVsEt_ = (TH1D*)gDirectory->Get("_TEMP_scatterPlot_deltaPhiVsEt__2");
774  hist_resolutionPhiVsE_ = (TH1D*)gDirectory->Get("_TEMP_scatterPlot_deltaPhiVsE__2");
775  hist_resolutionPhiVsEta_ = (TH1D*)gDirectory->Get("_TEMP_scatterPlot_deltaPhiVsEta__2");
776  hist_resolutionPhiVsPhi_ = (TH1D*)gDirectory->Get("_TEMP_scatterPlot_deltaPhiVsPhi__2");
777 
778  hist_resolutionEtVsEt_->SetNameTitle("hist_resolutionEtVsEt_",("#sigma of Reco Et over True Et VS Et of "+particleString).c_str());
779  hist_resolutionEtVsE_->SetNameTitle("hist_resolutionEtVsE_",("#sigma of Reco Et over True Et VS E of "+particleString).c_str());
780  hist_resolutionEtVsEta_->SetNameTitle("hist_resolutionEtVsEta_",("#sigma of Reco Et over True Et VS Eta of "+particleString).c_str());
781  hist_resolutionEtVsPhi_->SetNameTitle("hist_resolutionEtVsPhi_",("#sigma of Reco Et over True Et VS Phi of "+particleString).c_str());
782 
783  hist_resolutionEVsEt_->SetNameTitle("hist_resolutionEVsEt_",("#sigma of Reco E over True E VS Et of "+particleString).c_str());
784  hist_resolutionEVsE_->SetNameTitle("hist_resolutionEVsE_",("#sigma of Reco E over True E VS E of "+particleString).c_str());
785  hist_resolutionEVsEta_->SetNameTitle("hist_resolutionEVsEta_",("#sigma of Reco E over True E VS Eta of "+particleString).c_str());
786  hist_resolutionEVsPhi_->SetNameTitle("hist_resolutionEVsPhi_",("#sigma of Reco E over True E VS Phi of "+particleString).c_str());
787 
788  hist_resolutionEtaVsEt_->SetNameTitle("hist_resolutionEtaVsEt_",("#sigma of delta Eta VS Et of "+particleString).c_str());
789  hist_resolutionEtaVsE_->SetNameTitle("hist_resolutionEtaVsE_",("#sigma of delta Eta VS E of "+particleString).c_str());
790  hist_resolutionEtaVsEta_->SetNameTitle("hist_resolutionEtaVsEta_",("#sigma of delta Eta VS Eta of "+particleString).c_str());
791  hist_resolutionEtaVsPhi_->SetNameTitle("hist_resolutionEtaVsPhi_",("#sigma of delta Eta VS Phi of "+particleString).c_str());
792 
793  hist_resolutionPhiVsEt_->SetNameTitle("hist_resolutionPhiVsEt_",("#sigma of delta Phi VS Et of "+particleString).c_str());
794  hist_resolutionPhiVsE_->SetNameTitle("hist_resolutionPhiVsE_",("#sigma of delta Phi VS E of "+particleString).c_str());
795  hist_resolutionPhiVsEta_->SetNameTitle("hist_resolutionPhiVsEta_",("#sigma of delta Phi VS Eta of "+particleString).c_str());
796  hist_resolutionPhiVsPhi_->SetNameTitle("hist_resolutionPhiVsPhi_",("#sigma of delta Phi VS Phi of "+particleString).c_str());
797 }
798 
800 {
805 
810 }
811 
813 {
814  hist_EtOverTruth_->Fit("gaus","QEM");
815 // hist_EtNumRecoOverNumTrue_->Fit("pol1","QEM");
816 
817  hist_EOverTruth_->Fit("gaus","QEM");
818 // hist_ENumRecoOverNumTrue_->Fit("pol1","QEM");
819 
820  hist_EtaOverTruth_->Fit("gaus","QEM");
821 // hist_EtaNumRecoOverNumTrue_->Fit("pol1","QEM");
822 
823  hist_PhiOverTruth_->Fit("gaus","QEM");
824 // hist_PhiNumRecoOverNumTrue_->Fit("pol1","QEM");
825 
826  /*
827  hist_EtOverTruthVsEt_->Fit("pol1","QEM");
828  hist_EtOverTruthVsEta_->Fit("pol1","QEM");
829  hist_EtOverTruthVsPhi_->Fit("pol1","QEM");
830  hist_resolutionEtVsEt_->Fit("pol1","QEM");
831  hist_resolutionEtVsEta_->Fit("pol1","QEM");
832  hist_resolutionEtVsPhi_->Fit("pol1","QEM");
833 
834  hist_EOverTruthVsEt_->Fit("pol1","QEM");
835  hist_EOverTruthVsEta_->Fit("pol1","QEM");
836  hist_EOverTruthVsPhi_->Fit("pol1","QEM");
837  hist_resolutionEVsEt_->Fit("pol1","QEM");
838  hist_resolutionEVsEta_->Fit("pol1","QEM");
839  hist_resolutionEVsPhi_->Fit("pol1","QEM");
840 
841  hist_deltaEtaVsEt_->Fit("pol1","QEM");
842  hist_deltaEtaVsEta_->Fit("pol1","QEM");
843  hist_deltaEtaVsPhi_->Fit("pol1","QEM");
844  hist_resolutionEtaVsEt_->Fit("pol1","QEM");
845  hist_resolutionEtaVsEta_->Fit("pol1","QEM");
846  hist_resolutionEtaVsPhi_->Fit("pol1","QEM");
847 
848  hist_deltaPhiVsEt_->Fit("pol1","QEM");
849  hist_deltaPhiVsEta_->Fit("pol1","QEM");
850  hist_deltaPhiVsPhi_->Fit("pol1","QEM");
851  hist_resolutionPhiVsEt_->Fit("pol1","QEM");
852  hist_resolutionPhiVsEta_->Fit("pol1","QEM");
853  hist_resolutionPhiVsPhi_->Fit("pol1","QEM");
854  */
855 }
856 
858 {
859  hist_Et_->GetXaxis()->SetTitle("Et (GeV)");
860  hist_Et_->GetYaxis()->SetTitle("# per Et Bin");
861  hist_EtOverTruth_->GetXaxis()->SetTitle("Reco Et/True Et");
862  hist_EtOverTruth_->GetYaxis()->SetTitle("# per Ratio Bin");
863  hist_EtEfficiency_->GetXaxis()->SetTitle("Et (GeV)");
864  hist_EtEfficiency_->GetYaxis()->SetTitle("# True Reconstructed/# True per Et Bin");
865  hist_EtNumRecoOverNumTrue_->GetXaxis()->SetTitle("Et (GeV)");
866  hist_EtNumRecoOverNumTrue_->GetYaxis()->SetTitle("# Reco/# True per Et Bin");
867  hist_EtOverTruthVsEt_->GetXaxis()->SetTitle("Et (GeV)");
868  hist_EtOverTruthVsEt_->GetYaxis()->SetTitle("Reco Et/True Et per Et Bin");
869  hist_EtOverTruthVsE_->GetXaxis()->SetTitle("E (GeV)");
870  hist_EtOverTruthVsE_->GetYaxis()->SetTitle("Reco Et/True Et per E Bin");
871  hist_EtOverTruthVsEta_->GetXaxis()->SetTitle("#eta (Radians)");
872  hist_EtOverTruthVsEta_->GetYaxis()->SetTitle("Reco Et/True Et per Eta Bin");
873  hist_EtOverTruthVsPhi_->GetXaxis()->SetTitle("#phi (Radians)");
874  hist_EtOverTruthVsPhi_->GetYaxis()->SetTitle("Reco Et/True Et per Phi Bin");
875  hist_resolutionEtVsEt_->GetXaxis()->SetTitle("Et (GeV)");
876  hist_resolutionEtVsEt_->GetYaxis()->SetTitle("#sigma of Reco Et/True Et per Et Bin");
877  hist_resolutionEtVsE_->GetXaxis()->SetTitle("E (GeV)");
878  hist_resolutionEtVsE_->GetYaxis()->SetTitle("#sigma of Reco Et/True Et per E Bin");
879  hist_resolutionEtVsEta_->GetXaxis()->SetTitle("#eta (Radians)");
880  hist_resolutionEtVsEta_->GetYaxis()->SetTitle("#sigma of Reco Et/True Et per Eta Bin");
881  hist_resolutionEtVsPhi_->GetXaxis()->SetTitle("#phi (Radians)");
882  hist_resolutionEtVsPhi_->GetYaxis()->SetTitle("#sigma of Reco Et/True Et per Phi Bin");
883 
884  hist_E_->GetXaxis()->SetTitle("E (GeV)");
885  hist_E_->GetYaxis()->SetTitle("# per E Bin");
886  hist_EOverTruth_->GetXaxis()->SetTitle("Reco E/True E");
887  hist_EOverTruth_->GetYaxis()->SetTitle("# per Ratio Bin");
888  hist_EEfficiency_->GetXaxis()->SetTitle("E (GeV)");
889  hist_EEfficiency_->GetYaxis()->SetTitle("# True Reconstructed/# True per E Bin");
890  hist_ENumRecoOverNumTrue_->GetXaxis()->SetTitle("E (GeV)");
891  hist_ENumRecoOverNumTrue_->GetYaxis()->SetTitle("# Reco/# True per E Bin");
892  hist_EOverTruthVsEt_->GetXaxis()->SetTitle("Et (GeV)");
893  hist_EOverTruthVsEt_->GetYaxis()->SetTitle("Reco E/True E per Et Bin");
894  hist_EOverTruthVsE_->GetXaxis()->SetTitle("E (GeV)");
895  hist_EOverTruthVsE_->GetYaxis()->SetTitle("Reco E/True E per E Bin");
896  hist_EOverTruthVsEta_->GetXaxis()->SetTitle("#eta (Radians)");
897  hist_EOverTruthVsEta_->GetYaxis()->SetTitle("Reco E/True E per Eta Bin");
898  hist_EOverTruthVsPhi_->GetXaxis()->SetTitle("#phi (Radians)");
899  hist_EOverTruthVsPhi_->GetYaxis()->SetTitle("Reco E/True E per Phi Bin");
900  hist_resolutionEVsEt_->GetXaxis()->SetTitle("Et (GeV)");
901  hist_resolutionEVsEt_->GetYaxis()->SetTitle("#sigma of Reco E/True E per Et Bin");
902  hist_resolutionEVsE_->GetXaxis()->SetTitle("E (GeV)");
903  hist_resolutionEVsE_->GetYaxis()->SetTitle("#sigma of Reco E/True E per E Bin");
904  hist_resolutionEVsEta_->GetXaxis()->SetTitle("#eta (Radians)");
905  hist_resolutionEVsEta_->GetYaxis()->SetTitle("#sigma of Reco E/True E per Eta Bin");
906  hist_resolutionEVsPhi_->GetXaxis()->SetTitle("#phi (Radians)");
907  hist_resolutionEVsPhi_->GetYaxis()->SetTitle("#sigma of Reco E/True E per Phi Bin");
908 
909  hist_Eta_->GetXaxis()->SetTitle("#eta (Radians)");
910  hist_Eta_->GetYaxis()->SetTitle("# per Eta Bin");
911  hist_EtaOverTruth_->GetXaxis()->SetTitle("Reco Eta/True Eta");
912  hist_EtaOverTruth_->GetYaxis()->SetTitle("# per Ratio Bin");
913  hist_EtaEfficiency_->GetXaxis()->SetTitle("#eta (Radians)");
914  hist_EtaEfficiency_->GetYaxis()->SetTitle("# True Reconstructed/# True per Eta Bin");
915  hist_EtaNumRecoOverNumTrue_->GetXaxis()->SetTitle("#eta (Radians)");
916  hist_EtaNumRecoOverNumTrue_->GetYaxis()->SetTitle("# Reco/# True per Eta Bin");
917  hist_deltaEtaVsEt_->GetXaxis()->SetTitle("Et (GeV)");
918  hist_deltaEtaVsEt_->GetYaxis()->SetTitle("Reco Eta - True Eta per Et Bin");
919  hist_deltaEtaVsE_->GetXaxis()->SetTitle("E (GeV)");
920  hist_deltaEtaVsE_->GetYaxis()->SetTitle("Reco Eta - True Eta per E Bin");
921  hist_deltaEtaVsEta_->GetXaxis()->SetTitle("#eta (Radians)");
922  hist_deltaEtaVsEta_->GetYaxis()->SetTitle("Reco Eta - True Eta per Eta Bin");
923  hist_deltaEtaVsPhi_->GetXaxis()->SetTitle("#phi (Radians)");
924  hist_deltaEtaVsPhi_->GetYaxis()->SetTitle("Reco Eta - True Eta per Phi Bin");
925  hist_resolutionEtaVsEt_->GetXaxis()->SetTitle("Et (GeV)");
926  hist_resolutionEtaVsEt_->GetYaxis()->SetTitle("#sigma of Reco Eta - True Eta per Et Bin");
927  hist_resolutionEtaVsE_->GetXaxis()->SetTitle("E (GeV)");
928  hist_resolutionEtaVsE_->GetYaxis()->SetTitle("#sigma of Reco Eta - True Eta per E Bin");
929  hist_resolutionEtaVsEta_->GetXaxis()->SetTitle("#eta (Radians)");
930  hist_resolutionEtaVsEta_->GetYaxis()->SetTitle("#sigma of Reco Eta - True Eta per Eta Bin");
931  hist_resolutionEtaVsPhi_->GetXaxis()->SetTitle("#phi (Radians)");
932  hist_resolutionEtaVsPhi_->GetYaxis()->SetTitle("#sigma of Reco Eta - True Eta per Phi Bin");
933 
934  hist_Phi_->GetXaxis()->SetTitle("#phi (Radians)");
935  hist_Phi_->GetYaxis()->SetTitle("# per Phi Bin");
936  hist_PhiOverTruth_->GetXaxis()->SetTitle("Reco Phi/True Phi");
937  hist_PhiOverTruth_->GetYaxis()->SetTitle("# per Ratio Bin");
938  hist_PhiEfficiency_->GetXaxis()->SetTitle("#phi (Radians)");
939  hist_PhiEfficiency_->GetYaxis()->SetTitle("# True Reconstructed/# True per Phi Bin");
940  hist_PhiNumRecoOverNumTrue_->GetXaxis()->SetTitle("#Phi (Radians)");
941  hist_PhiNumRecoOverNumTrue_->GetYaxis()->SetTitle("# Reco/# True per Phi Bin");
942  hist_deltaPhiVsEt_->GetXaxis()->SetTitle("Et (GeV)");
943  hist_deltaPhiVsEt_->GetYaxis()->SetTitle("Reco Phi - True Phi per Et Bin");
944  hist_deltaPhiVsE_->GetXaxis()->SetTitle("E (GeV)");
945  hist_deltaPhiVsE_->GetYaxis()->SetTitle("Reco Phi - True Phi per E Bin");
946  hist_deltaPhiVsEta_->GetXaxis()->SetTitle("#eta (Radians)");
947  hist_deltaPhiVsEta_->GetYaxis()->SetTitle("Reco Phi - True Phi per Eta Bin");
948  hist_deltaPhiVsPhi_->GetXaxis()->SetTitle("#phi (Radians)");
949  hist_deltaPhiVsPhi_->GetYaxis()->SetTitle("Reco Phi - True Phi per Phi Bin");
950  hist_resolutionPhiVsEt_->GetXaxis()->SetTitle("Et (GeV)");
951  hist_resolutionPhiVsEt_->GetYaxis()->SetTitle("#sigma of Reco Phi - True Phi per Et Bin");
952  hist_resolutionPhiVsE_->GetXaxis()->SetTitle("E (GeV)");
953  hist_resolutionPhiVsE_->GetYaxis()->SetTitle("#sigma of Reco Phi - True Phi per E Bin");
954  hist_resolutionPhiVsEta_->GetXaxis()->SetTitle("#eta (Radians)");
955  hist_resolutionPhiVsEta_->GetYaxis()->SetTitle("#sigma of Reco Phi - True Phi per Eta Bin");
956  hist_resolutionPhiVsPhi_->GetXaxis()->SetTitle("#phi (Radians)");
957  hist_resolutionPhiVsPhi_->GetYaxis()->SetTitle("#sigma of Reco Phi - True Phi per Phi Bin");
958 
959  std::string recoParticleName;
960 
961  if( particleID == 22 ) recoParticleName = "Reco Higgs";
962  else if( particleID == 11 ) recoParticleName = "Reco Z";
963 
964  hist_All_recoMass_->GetXaxis()->SetTitle((recoParticleName+" Mass (GeV)").c_str());
965  hist_All_recoMass_->GetYaxis()->SetTitle("# of Reco Masses per Mass Bin");
966  hist_BarrelOnly_recoMass_->GetXaxis()->SetTitle((recoParticleName+" Mass (GeV)").c_str());
967  hist_BarrelOnly_recoMass_->GetYaxis()->SetTitle("# of Reco Masses per Mass Bin");
968  hist_EndcapOnly_recoMass_->GetXaxis()->SetTitle((recoParticleName+" Mass (GeV)").c_str());
969  hist_EndcapOnly_recoMass_->GetYaxis()->SetTitle("# of Reco Masses per Mass Bin");
970  hist_Mixed_recoMass_->GetXaxis()->SetTitle((recoParticleName+" Mass (GeV)").c_str());
971  hist_Mixed_recoMass_->GetYaxis()->SetTitle("# of Reco Masses per Mass Bin");
972  hist_recoMass_withBackgroud_NoEtCut_->GetXaxis()->SetTitle((recoParticleName+" Mass (GeV)").c_str());
973  hist_recoMass_withBackgroud_NoEtCut_->GetYaxis()->SetTitle("# of Reco Masses per Mass Bin");
974  hist_recoMass_withBackgroud_5EtCut_->GetXaxis()->SetTitle((recoParticleName+" Mass (GeV)").c_str());
975  hist_recoMass_withBackgroud_5EtCut_->GetYaxis()->SetTitle("# of Reco Masses per Mass Bin");
976  hist_recoMass_withBackgroud_10EtCut_->GetXaxis()->SetTitle((recoParticleName+" Mass (GeV)").c_str());
977  hist_recoMass_withBackgroud_10EtCut_->GetYaxis()->SetTitle("# of Reco Masses per Mass Bin");
978  hist_recoMass_withBackgroud_20EtCut_->GetXaxis()->SetTitle((recoParticleName+" Mass (GeV)").c_str());
979  hist_recoMass_withBackgroud_20EtCut_->GetYaxis()->SetTitle("# of Reco Masses per Mass Bin");
980 }
981 
983 {
984  hist_Et_->SetOption("e");
985  hist_EtOverTruth_->SetOption("e");
986  hist_EtEfficiency_->SetOption("e");
987  hist_EtNumRecoOverNumTrue_->SetOption("e");
988  hist_EtOverTruthVsEt_->SetOption("e");
989  hist_EtOverTruthVsE_->SetOption("e");
990  hist_EtOverTruthVsEta_->SetOption("e");
991  hist_EtOverTruthVsPhi_->SetOption("e");
992  hist_resolutionEtVsEt_->SetOption("e");
993  hist_resolutionEtVsE_->SetOption("e");
994  hist_resolutionEtVsEta_->SetOption("e");
995  hist_resolutionEtVsPhi_->SetOption("e");
996 
997  hist_E_->SetOption("e");
998  hist_EOverTruth_->SetOption("e");
999  hist_EEfficiency_->SetOption("e");
1000  hist_ENumRecoOverNumTrue_->SetOption("e");
1001  hist_EOverTruthVsEt_->SetOption("e");
1002  hist_EOverTruthVsE_->SetOption("e");
1003  hist_EOverTruthVsEta_->SetOption("e");
1004  hist_EOverTruthVsPhi_->SetOption("e");
1005  hist_resolutionEVsEt_->SetOption("e");
1006  hist_resolutionEVsE_->SetOption("e");
1007  hist_resolutionEVsEta_->SetOption("e");
1008  hist_resolutionEVsPhi_->SetOption("e");
1009 
1010  hist_Eta_->SetOption("e");
1011  hist_EtaOverTruth_->SetOption("e");
1012  hist_EtaEfficiency_->SetOption("e");
1013  hist_EtaNumRecoOverNumTrue_->SetOption("e");
1014  hist_deltaEtaVsEt_->SetOption("e");
1015  hist_deltaEtaVsE_->SetOption("e");
1016  hist_deltaEtaVsEta_->SetOption("e");
1017  hist_deltaEtaVsPhi_->SetOption("e");
1018  hist_resolutionEtaVsEt_->SetOption("e");
1019  hist_resolutionEtaVsE_->SetOption("e");
1020  hist_resolutionEtaVsEta_->SetOption("e");
1021  hist_resolutionEtaVsPhi_->SetOption("e");
1022 
1023  hist_Phi_->SetOption("e");
1024  hist_PhiOverTruth_->SetOption("e");
1025  hist_PhiEfficiency_->SetOption("e");
1026  hist_PhiNumRecoOverNumTrue_->SetOption("e");
1027  hist_deltaPhiVsEt_->SetOption("e");
1028  hist_deltaPhiVsE_->SetOption("e");
1029  hist_deltaPhiVsEta_->SetOption("e");
1030  hist_deltaPhiVsPhi_->SetOption("e");
1031  hist_resolutionPhiVsEt_->SetOption("e");
1032  hist_resolutionPhiVsE_->SetOption("e");
1033  hist_resolutionPhiVsEta_->SetOption("e");
1034  hist_resolutionPhiVsPhi_->SetOption("e");
1035 
1036  hist_All_recoMass_->SetOption("e");
1037  hist_BarrelOnly_recoMass_->SetOption("e");
1038  hist_EndcapOnly_recoMass_->SetOption("e");
1039  hist_Mixed_recoMass_->SetOption("e");
1040  hist_recoMass_withBackgroud_NoEtCut_->SetOption("e");
1041  hist_recoMass_withBackgroud_5EtCut_->SetOption("e");
1042  hist_recoMass_withBackgroud_10EtCut_->SetOption("e");
1043  hist_recoMass_withBackgroud_20EtCut_->SetOption("e");
1044 }
1045 
1047 {
1048  rootFile_->cd();
1049  rootFile_->GetDirectory(particleString.c_str())->mkdir("ET");
1050  rootFile_->cd(("/"+particleString+"/ET").c_str());
1051 
1052  hist_Et_->Write();
1053  hist_EtOverTruth_->Write();
1054  hist_EtEfficiency_->Write();
1055  hist_EtNumRecoOverNumTrue_->Write();
1056  hist_EtOverTruthVsEt_->Write();
1057  hist_EtOverTruthVsE_->Write();
1058  hist_EtOverTruthVsEta_->Write();
1059  hist_EtOverTruthVsPhi_->Write();
1060  hist_resolutionEtVsEt_->Write();
1061  hist_resolutionEtVsE_->Write();
1062  hist_resolutionEtVsEta_->Write();
1063  hist_resolutionEtVsPhi_->Write();
1064 
1065  rootFile_->cd();
1066  rootFile_->GetDirectory(particleString.c_str())->mkdir("E");
1067  rootFile_->cd(("/"+particleString+"/E").c_str());
1068 
1069  hist_E_->Write();
1070  hist_EOverTruth_->Write();
1071  hist_EEfficiency_->Write();
1072  hist_ENumRecoOverNumTrue_->Write();
1073  hist_EOverTruthVsEt_->Write();
1074  hist_EOverTruthVsE_->Write();
1075  hist_EOverTruthVsEta_->Write();
1076  hist_EOverTruthVsPhi_->Write();
1077  hist_resolutionEVsEt_->Write();
1078  hist_resolutionEVsE_->Write();
1079  hist_resolutionEVsEta_->Write();
1080  hist_resolutionEVsPhi_->Write();
1081 
1082  rootFile_->cd();
1083  rootFile_->GetDirectory(particleString.c_str())->mkdir("Eta");
1084  rootFile_->cd(("/"+particleString+"/Eta").c_str());
1085 
1086  hist_Eta_->Write();
1087  hist_EtaOverTruth_->Write();
1088  hist_EtaEfficiency_->Write();
1089  hist_EtaNumRecoOverNumTrue_->Write();
1090  hist_deltaEtaVsEt_->Write();
1091  hist_deltaEtaVsE_->Write();
1092  hist_deltaEtaVsEta_->Write();
1093  hist_deltaEtaVsPhi_->Write();
1094  hist_resolutionEtaVsEt_->Write();
1095  hist_resolutionEtaVsE_->Write();
1096  hist_resolutionEtaVsEta_->Write();
1097  hist_resolutionEtaVsPhi_->Write();
1098 
1099  rootFile_->cd();
1100  rootFile_->GetDirectory(particleString.c_str())->mkdir("Phi");
1101  rootFile_->cd(("/"+particleString+"/Phi").c_str());
1102 
1103  hist_Phi_->Write();
1104  hist_PhiOverTruth_->Write();
1105  hist_PhiEfficiency_->Write();
1106  hist_PhiNumRecoOverNumTrue_->Write();
1107  hist_deltaPhiVsEt_->Write();
1108  hist_deltaPhiVsE_->Write();
1109  hist_deltaPhiVsEta_->Write();
1110  hist_deltaPhiVsPhi_->Write();
1111  hist_resolutionPhiVsEt_->Write();
1112  hist_resolutionPhiVsE_->Write();
1113  hist_resolutionPhiVsEta_->Write();
1114  hist_resolutionPhiVsPhi_->Write();
1115 
1116  std::string recoParticleName;
1117 
1118  if( particleID == 22 ) recoParticleName = "HiggsRecoMass";
1119  else if( particleID == 11 ) recoParticleName = "ZRecoMass";
1120 
1121  rootFile_->cd();
1122  rootFile_->GetDirectory(particleString.c_str())->mkdir(recoParticleName.c_str());
1123  rootFile_->cd(("/"+particleString+"/"+recoParticleName).c_str());
1124 
1125  hist_All_recoMass_->Write();
1126  hist_BarrelOnly_recoMass_->Write();
1127  hist_EndcapOnly_recoMass_->Write();
1128  hist_Mixed_recoMass_->Write();
1133 
1134  rootFile_->cd();
1135  rootFile_->GetDirectory(particleString.c_str())->mkdir("_TempScatterPlots");
1136  rootFile_->cd(("/"+particleString+"/_TempScatterPlots").c_str());
1137 
1142 
1147 
1152 
1157 
1158  rootFile_->cd();
1159 }
1160 
TH1D * hist_resolutionEVsPhi_
TH2D * _TEMP_scatterPlot_EtOverTruthVsPhi_
double hist_min_deltaEta_
Definition: EgammaObjects.h:73
int hist_bins_deltaEta_
Definition: EgammaObjects.h:75
T getParameter(std::string const &) const
double hist_min_EtaOverTruth_
Definition: EgammaObjects.h:65
TH2D * _TEMP_scatterPlot_deltaEtaVsEta_
TH1D * hist_resolutionEVsE_
int hist_bins_deltaPhi_
Definition: EgammaObjects.h:79
TH2D * _TEMP_scatterPlot_deltaPhiVsPhi_
TH1D * hist_PhiEfficiency_
TH1D * hist_deltaEtaVsEta_
float ecalEta(float EtaParticle, float Zvertex, float plane_Radius)
int hist_bins_recoMass_
Definition: EgammaObjects.h:83
void analyzePhotons(const edm::Event &, const edm::EventSetup &)
TH1D * hist_EOverTruth_
Definition: EgammaObjects.h:99
TH1D * hist_EtOverTruthVsEt_
Definition: EgammaObjects.h:89
TH1D * hist_resolutionEVsEta_
virtual double et() const
transverse energy
TH1D * hist_deltaEtaVsPhi_
TH1D * hist_EEfficiency_
TH1D * hist_EOverTruthVsEt_
TH1D * hist_recoMass_withBackgroud_20EtCut_
TH2D * _TEMP_scatterPlot_EtOverTruthVsE_
double hist_max_Eta_
Definition: EgammaObjects.h:50
TH2D * _TEMP_scatterPlot_deltaPhiVsE_
void getEfficiencyHistosViaDividing()
TH1D * hist_Mixed_recoMass_
double hist_min_PhiOverTruth_
Definition: EgammaObjects.h:69
double hist_max_Phi_
Definition: EgammaObjects.h:54
TH1D * hist_resolutionPhiVsPhi_
TH1D * hist_resolutionEtVsEta_
Definition: EgammaObjects.h:95
#define abs(x)
Definition: mlp_lapack.h:159
reco::SuperClusterRef superCluster() const
Ref to SuperCluster.
Definition: Photon.cc:59
edm::InputTag MCTruthCollection_
Definition: EgammaObjects.h:33
TH2D * _TEMP_scatterPlot_EOverTruthVsEta_
virtual void endJob()
TH2D * _TEMP_scatterPlot_deltaPhiVsEt_
TH1D * hist_ENumRecoOverNumTrue_
TH1D * hist_deltaPhiVsPhi_
double hist_max_EtaOverTruth_
Definition: EgammaObjects.h:66
void loadHistoParameters(const edm::ParameterSet &ps)
double hist_min_Phi_
Definition: EgammaObjects.h:53
TH1D * hist_EOverTruthVsE_
double hist_min_Eta_
Definition: EgammaObjects.h:49
TH1D * hist_EtNumRecoOverNumTrue_
Definition: EgammaObjects.h:88
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
TH1D * hist_resolutionEVsEt_
void createTempHistoObjects()
TH1D * hist_resolutionEtVsPhi_
Definition: EgammaObjects.h:96
std::string particleString
Definition: EgammaObjects.h:37
virtual double eta() const
momentum pseudorapidity
TH1D * hist_EtOverTruth_
Definition: EgammaObjects.h:86
int hist_bins_EOverTruth_
Definition: EgammaObjects.h:63
TH1D * hist_EOverTruthVsPhi_
TH2D * _TEMP_scatterPlot_EtOverTruthVsEta_
TH1D * hist_EtOverTruthVsEta_
Definition: EgammaObjects.h:91
double hist_min_EtOverTruth_
Definition: EgammaObjects.h:57
double findRecoMass(reco::Photon pOne, reco::Photon pTwo)
#define ETA
TH1D * hist_EOverTruthVsEta_
void getDeltaResHistosViaSlicing()
void setDrawOptions()
TH1D * hist_resolutionEtVsE_
Definition: EgammaObjects.h:94
TH2D * _TEMP_scatterPlot_deltaEtaVsE_
double hist_max_recoMass_
Definition: EgammaObjects.h:82
TH1D * hist_PhiNumRecoOverNumTrue_
double hist_max_E_
Definition: EgammaObjects.h:46
TH1D * hist_PhiOverTruth_
double hist_min_deltaPhi_
Definition: EgammaObjects.h:77
TH1D * hist_recoMass_withBackgroud_5EtCut_
TH2D * _TEMP_scatterPlot_deltaEtaVsPhi_
T sqrt(T t)
Definition: SSEVec.h:46
TH1D * hist_resolutionEtVsEt_
Definition: EgammaObjects.h:93
virtual SuperClusterRef superCluster() const
reference to a SuperCluster
Definition: GsfElectron.h:168
TH2D * _TEMP_scatterPlot_EOverTruthVsEt_
double hist_max_deltaEta_
Definition: EgammaObjects.h:74
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
TH1D * hist_EtOverTruthVsE_
Definition: EgammaObjects.h:90
TH1D * hist_resolutionEtaVsE_
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
TH1D * hist_BarrelOnly_recoMass_
tuple genEvent
Definition: MCTruth.py:33
TH1D * hist_EndcapOnly_recoMass_
TH1D * hist_deltaPhiVsEt_
TH1D * hist_EtaOverTruth_
TH1D * hist_deltaPhiVsEta_
bool isValid() const
Definition: HandleBase.h:76
TH1D * hist_deltaEtaVsEt_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
double hist_max_deltaPhi_
Definition: EgammaObjects.h:78
int hist_bins_EtOverTruth_
Definition: EgammaObjects.h:59
TH1D * hist_recoMass_withBackgroud_10EtCut_
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
edm::InputTag RecoCollection_
Definition: EgammaObjects.h:34
TH1D * hist_resolutionPhiVsEt_
double hist_max_PhiOverTruth_
Definition: EgammaObjects.h:70
void analyzeElectrons(const edm::Event &, const edm::EventSetup &)
TH2D * _TEMP_scatterPlot_deltaPhiVsEta_
TH2D * _TEMP_scatterPlot_EOverTruthVsE_
double hist_max_EtOverTruth_
Definition: EgammaObjects.h:58
double hist_min_E_
Definition: EgammaObjects.h:45
EgammaObjects(const edm::ParameterSet &)
TH1D * hist_All_recoMass_
TH2D * _TEMP_scatterPlot_deltaEtaVsEt_
double hist_min_Et_
Definition: EgammaObjects.h:41
math::XYZPoint caloPosition() const
Definition: GsfElectron.h:303
TH2D * _TEMP_scatterPlot_EOverTruthVsPhi_
TH1D * hist_deltaEtaVsE_
std::vector< Photon > PhotonCollection
collectin of Photon objects
Definition: PhotonFwd.h:9
TH1D * hist_resolutionEtaVsPhi_
static const float etaBarrelEndcap
T const * product() const
Definition: Handle.h:74
TH1D * hist_EtOverTruthVsPhi_
Definition: EgammaObjects.h:92
static const float Z_Endcap
std::string const & label() const
Definition: InputTag.h:25
TH1D * hist_deltaPhiVsE_
double hist_min_recoMass_
Definition: EgammaObjects.h:81
TH1D * hist_EtaEfficiency_
TH1D * hist_resolutionPhiVsE_
double pi()
Definition: Pi.h:31
double hist_min_EOverTruth_
Definition: EgammaObjects.h:61
void loadCMSSWObjects(const edm::ParameterSet &ps)
TH1D * hist_recoMass_withBackgroud_NoEtCut_
TH2D * _TEMP_scatterPlot_EtOverTruthVsEt_
int hist_bins_PhiOverTruth_
Definition: EgammaObjects.h:71
static const float R_ECAL
double hist_max_EOverTruth_
Definition: EgammaObjects.h:62
double hist_max_Et_
Definition: EgammaObjects.h:42
virtual void beginJob()
int hist_bins_EtaOverTruth_
Definition: EgammaObjects.h:67
TFile * rootFile_
Definition: EgammaObjects.h:31
void createBookedHistoObjects()
TH1D * hist_resolutionEtaVsEta_
TH1D * hist_resolutionPhiVsEta_
float caloEnergy() const
Definition: GsfElectron.h:727
TH1D * hist_EtEfficiency_
Definition: EgammaObjects.h:87
virtual void analyze(const edm::Event &, const edm::EventSetup &)
TH1D * hist_EtaNumRecoOverNumTrue_
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
TH1D * hist_resolutionEtaVsEt_