25 throw(std::runtime_error(
"\n\nEgammaObjects: Only 11 = Photon and 22 = Electron are acceptable parictleIDs! Exiting...\n\n"));
150 TH1::SetDefaultSumw2(
true);
159 =
new TH1D(
"hist_Et_",(
"Et Distribution of "+
particleString).c_str(),
162 =
new TH1D(
"hist_EtOverTruth_",(
"Reco Et over True Et of "+
particleString).c_str(),
172 =
new TH1D(
"hist_E_",(
"E Distribution of "+
particleString).c_str(),
175 =
new TH1D(
"hist_EOverTruth_",(
"Reco E over True E of "+
particleString).c_str(),
185 =
new TH1D(
"hist_Eta_",(
"Eta Distribution of "+
particleString).c_str(),
188 =
new TH1D(
"hist_EtaOverTruth_",(
"Reco Eta over True Eta of "+
particleString).c_str(),
198 =
new TH1D(
"hist_Phi_",(
"Phi Distribution of "+
particleString).c_str(),
201 =
new TH1D(
"hist_PhiOverTruth_",(
"Reco Phi over True Phi of "+
particleString).c_str(),
212 if(
particleID == 22 ) recoParticleName =
"Higgs";
213 else if(
particleID == 11 ) recoParticleName =
"Z";
216 =
new TH1D(
"hist_All_recoMass_",(recoParticleName+
" Mass from "+
particleString+
" in All Regions").c_str(),
219 =
new TH1D(
"hist_BarrelOnly_recoMass_",(recoParticleName+
" Mass from "+
particleString+
" in Barrel").c_str(),
222 =
new TH1D(
"hist_EndcapOnly_recoMass_",(recoParticleName+
" Mass from "+
particleString+
" in EndCap").c_str(),
225 =
new TH1D(
"hist_Mixed_recoMass_",(recoParticleName+
" Mass from "+
particleString+
" in Split Detectors").c_str(),
229 =
new TH1D(
"hist_recoMass_withBackgroud_NoEtCut_",(recoParticleName+
" Mass from "+
particleString+
" with Background, No Et Cut").c_str(),
232 =
new TH1D(
"hist_recoMass_withBackgroud_5EtCut_",(recoParticleName+
" Mass from "+
particleString+
" with Background, 5 Et Cut").c_str(),
235 =
new TH1D(
"hist_recoMass_withBackgroud_10EtCut_",(recoParticleName+
" Mass from "+
particleString+
" with Background, 10 Et Cut").c_str(),
238 =
new TH1D(
"hist_recoMass_withBackgroud_20EtCut_",(recoParticleName+
" Mass from "+
particleString+
" with Background, 20 Et Cut").c_str(),
245 =
new TH2D(
"_TEMP_scatterPlot_EtOverTruthVsEt_",
"_TEMP_scatterPlot_EtOverTruthVsEt_",
248 =
new TH2D(
"_TEMP_scatterPlot_EtOverTruthVsE_",
"_TEMP_scatterPlot_EtOverTruthVsE_",
251 =
new TH2D(
"_TEMP_scatterPlot_EtOverTruthVsEta_",
"_TEMP_scatterPlot_EtOverTruthVsEta_",
254 =
new TH2D(
"_TEMP_scatterPlot_EtOverTruthVsPhi_",
"_TEMP_scatterPlot_EtOverTruthVsPhi_",
258 =
new TH2D(
"_TEMP_scatterPlot_EOverTruthVsEt_",
"_TEMP_scatterPlot_EOverTruthVsEt_",
261 =
new TH2D(
"_TEMP_scatterPlot_EOverTruthVsE_",
"_TEMP_scatterPlot_EOverTruthVsE_",
264 =
new TH2D(
"_TEMP_scatterPlot_EOverTruthVsEta_",
"_TEMP_scatterPlot_EOverTruthVsEta_",
267 =
new TH2D(
"_TEMP_scatterPlot_EOverTruthVsPhi_",
"_TEMP_scatterPlot_EOverTruthVsPhi_",
271 =
new TH2D(
"_TEMP_scatterPlot_deltaEtaVsEt_",
"_TEMP_scatterPlot_deltaEtaVsEt_",
274 =
new TH2D(
"_TEMP_scatterPlot_deltaEtaVsE_",
"_TEMP_scatterPlot_deltaEtaVsE_",
277 =
new TH2D(
"_TEMP_scatterPlot_deltaEtaVsEta_",
"_TEMP_scatterPlot_deltaEtaVsEta_",
280 =
new TH2D(
"_TEMP_scatterPlot_deltaEtaVsPhi_",
"_TEMP_scatterPlot_deltaEtaVsPhi_",
284 =
new TH2D(
"_TEMP_scatterPlot_deltaPhiVsEt_",
"_TEMP_scatterPlot_deltaPhiVsEt_",
287 =
new TH2D(
"_TEMP_scatterPlot_deltaPhiVsE_",
"_TEMP_scatterPlot_deltaPhiVsE_",
290 =
new TH2D(
"_TEMP_scatterPlot_deltaPhiVsEta_",
"_TEMP_scatterPlot_deltaPhiVsEta_",
293 =
new TH2D(
"_TEMP_scatterPlot_deltaPhiVsPhi_",
"_TEMP_scatterPlot_deltaPhiVsPhi_",
311 <<
"Error! can't get collection with label "
316 std::vector<reco::Photon> photonsMCMatched;
318 for(reco::PhotonCollection::const_iterator aClus = photons->begin(); aClus != photons->end(); aClus++)
320 if(aClus->et() >=
EtCut)
323 hist_E_->Fill(aClus->energy());
329 for(
int firstPhoton = 0, numPhotons = photons->size(); firstPhoton < numPhotons - 1; firstPhoton++)
330 for(
int secondPhoton = firstPhoton + 1; secondPhoton < numPhotons; secondPhoton++)
339 if(pOne.
et() >= 5 && pTwo.
et() >= 5)
342 if(pOne.
et() >= 10 && pTwo.
et() >= 10)
345 if(pOne.
et() >= 20 && pTwo.
et() >= 20)
355 <<
"Error! can't get collection with label "
359 const HepMC::GenEvent*
genEvent = pMCTruth->GetEvent();
361 for(HepMC::GenEvent::particle_const_iterator currentParticle = genEvent->particles_begin();
362 currentParticle != genEvent->particles_end(); currentParticle++ )
364 if(
abs((*currentParticle)->pdg_id())==22 && (*currentParticle)->status()==1
365 && (*currentParticle)->momentum().e()/cosh(
ecalEta((*currentParticle)->momentum().eta(), (*currentParticle)->production_vertex()->position().z()/10.,
366 (*currentParticle)->production_vertex()->position().perp()/10.)) >=
EtCut)
368 HepMC::FourVector vtx = (*currentParticle)->production_vertex()->position();
369 double phiTrue = (*currentParticle)->momentum().phi();
370 double etaTrue =
ecalEta((*currentParticle)->momentum().eta(), vtx.z()/10., vtx.perp()/10.);
371 double eTrue = (*currentParticle)->momentum().e();
372 double etTrue = (*currentParticle)->momentum().e()/cosh(etaTrue);
374 double etaCurrent, etaFound = -999;
375 double phiCurrent, phiFound = -999;
376 double etCurrent, etFound = -999;
377 double eCurrent, eFound = -999;
381 double closestParticleDistance = 999;
383 for(reco::PhotonCollection::const_iterator aClus = photons->begin(); aClus != photons->end(); aClus++)
385 if(aClus->et() >
EtCut)
387 etaCurrent = aClus->
eta();
388 phiCurrent = aClus->phi();
389 etCurrent = aClus->et();
390 eCurrent = aClus->energy();
392 double deltaPhi = phiCurrent-phiTrue;
397 if(deltaR < closestParticleDistance)
401 etaFound = etaCurrent;
402 phiFound = phiCurrent;
403 closestParticleDistance =
deltaR;
404 bestMatchPhoton = *aClus;
409 if(closestParticleDistance < 0.05 && etFound/etTrue > .5 && etFound/etTrue < 1.5)
445 photonsMCMatched.push_back(bestMatchPhoton);
455 if(photonsMCMatched.size() == 2)
481 <<
"Error! can't get collection with label "
486 std::vector<reco::GsfElectron> electronsMCMatched;
488 for(reco::GsfElectronCollection::const_iterator aClus = electrons->begin(); aClus != electrons->end(); aClus++)
490 if(aClus->et() >=
EtCut)
493 hist_E_->Fill(aClus->energy());
499 for(
int firstElectron = 0, numElectrons = electrons->size(); firstElectron < numElectrons - 1; firstElectron++)
500 for(
int secondElectron = firstElectron + 1; secondElectron < numElectrons; secondElectron++)
509 if(eOne.
et() >= 5 && eTwo.
et() >= 5)
512 if(eOne.
et() >= 10 && eTwo.
et() >= 10)
515 if(eOne.
et() >= 20 && eTwo.
et() >= 20)
525 <<
"Error! can't get collection with label "
529 const HepMC::GenEvent*
genEvent = pMCTruth->GetEvent();
530 for(HepMC::GenEvent::particle_const_iterator currentParticle = genEvent->particles_begin();
531 currentParticle != genEvent->particles_end(); currentParticle++ )
533 if(
abs((*currentParticle)->pdg_id())==11 && (*currentParticle)->status()==1
534 && (*currentParticle)->momentum().e()/cosh((*currentParticle)->momentum().eta()) >=
EtCut)
536 double phiTrue = (*currentParticle)->momentum().phi();
537 double etaTrue = (*currentParticle)->momentum().eta();
538 double eTrue = (*currentParticle)->momentum().e();
539 double etTrue = (*currentParticle)->momentum().e()/cosh(etaTrue);
541 double etaCurrent, etaFound = -999;
542 double phiCurrent, phiFound = -999;
543 double etCurrent, etFound = -999;
544 double eCurrent, eFound = -999;
548 double closestParticleDistance = 999;
550 for(reco::GsfElectronCollection::const_iterator aClus = electrons->begin(); aClus != electrons->end(); aClus++)
552 if(aClus->et() >
EtCut)
554 etaCurrent = aClus->
eta();
555 phiCurrent = aClus->phi();
556 etCurrent = aClus->et();
557 eCurrent = aClus->energy();
559 double deltaPhi = phiCurrent-phiTrue;
564 if(deltaR < closestParticleDistance)
568 etaFound = etaCurrent;
569 phiFound = phiCurrent;
570 closestParticleDistance =
deltaR;
571 bestMatchElectron = *aClus;
576 if(closestParticleDistance < 0.05 && etFound/etTrue > .5 && etFound/etTrue < 1.5)
612 electronsMCMatched.push_back(bestMatchElectron);
622 if(electronsMCMatched.size() == 2)
664 const float R_ECAL = 136.5;
668 if(EtaParticle != 0.)
671 float ZEcal = (R_ECAL-plane_Radius)*sinh(EtaParticle)+Zvertex;
673 if(ZEcal != 0.0) Theta = atan(R_ECAL/ZEcal);
674 if(Theta<0.0) Theta = Theta+
Geom::pi() ;
678 if(
std::abs(ETA) > etaBarrelEndcap )
681 if(EtaParticle<0.0 ) Zend = -Zend ;
682 float Zlen = Zend - Zvertex ;
683 float RR = Zlen/sinh(EtaParticle);
684 Theta = atan((RR+plane_Radius)/Zend);
685 if(Theta<0.0) Theta = Theta+
Geom::pi() ;
686 ETA = -
log(
tan(0.5*Theta));
693 edm::LogWarning(
"") <<
"[EgammaObjects::ecalEta] Warning: Eta equals to zero, not correcting" ;
877 hist_Et_->GetXaxis()->SetTitle(
"Et (GeV)");
878 hist_Et_->GetYaxis()->SetTitle(
"# per Et Bin");
902 hist_E_->GetXaxis()->SetTitle(
"E (GeV)");
903 hist_E_->GetYaxis()->SetTitle(
"# per E Bin");
907 hist_EEfficiency_->GetYaxis()->SetTitle(
"# True Reconstructed/# True per E Bin");
927 hist_Eta_->GetXaxis()->SetTitle(
"#eta (Radians)");
928 hist_Eta_->GetYaxis()->SetTitle(
"# per Eta Bin");
952 hist_Phi_->GetXaxis()->SetTitle(
"#phi (Radians)");
953 hist_Phi_->GetYaxis()->SetTitle(
"# per Phi Bin");
979 if(
particleID == 22 ) recoParticleName =
"Reco Higgs";
980 else if(
particleID == 11 ) recoParticleName =
"Reco Z";
1136 if(
particleID == 22 ) recoParticleName =
"HiggsRecoMass";
1137 else if(
particleID == 11 ) recoParticleName =
"ZRecoMass";
TH1D * hist_resolutionEVsPhi_
TH2D * _TEMP_scatterPlot_EtOverTruthVsPhi_
double hist_min_deltaEta_
T getParameter(std::string const &) const
double hist_min_EtaOverTruth_
TH2D * _TEMP_scatterPlot_deltaEtaVsEta_
TH1D * hist_resolutionEVsE_
TH2D * _TEMP_scatterPlot_deltaPhiVsPhi_
TH1D * hist_PhiEfficiency_
TH1D * hist_deltaEtaVsEta_
float ecalEta(float EtaParticle, float Zvertex, float plane_Radius)
void analyzePhotons(const edm::Event &, const edm::EventSetup &)
TH1D * hist_EtOverTruthVsEt_
TH1D * hist_resolutionEVsEta_
virtual double et() const
transverse energy
TH1D * hist_deltaEtaVsPhi_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
TH1D * hist_EOverTruthVsEt_
TH1D * hist_recoMass_withBackgroud_20EtCut_
TH2D * _TEMP_scatterPlot_EtOverTruthVsE_
TH2D * _TEMP_scatterPlot_deltaPhiVsE_
void getEfficiencyHistosViaDividing()
TH1D * hist_Mixed_recoMass_
double hist_min_PhiOverTruth_
TH1D * hist_resolutionPhiVsPhi_
TH1D * hist_resolutionEtVsEta_
reco::SuperClusterRef superCluster() const
Ref to SuperCluster.
TH2D * _TEMP_scatterPlot_EOverTruthVsEta_
TH2D * _TEMP_scatterPlot_deltaPhiVsEt_
TH1D * hist_ENumRecoOverNumTrue_
TH1D * hist_deltaPhiVsPhi_
double hist_max_EtaOverTruth_
void loadHistoParameters(const edm::ParameterSet &ps)
TH1D * hist_EOverTruthVsE_
TH1D * hist_EtNumRecoOverNumTrue_
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
TH1D * hist_resolutionEVsEt_
void createTempHistoObjects()
TH1D * hist_resolutionEtVsPhi_
std::string particleString
int hist_bins_EOverTruth_
TH1D * hist_EOverTruthVsPhi_
TH2D * _TEMP_scatterPlot_EtOverTruthVsEta_
TH1D * hist_EtOverTruthVsEta_
double hist_min_EtOverTruth_
TH1D * hist_EOverTruthVsEta_
void getDeltaResHistosViaSlicing()
TH1D * hist_resolutionEtVsE_
TH2D * _TEMP_scatterPlot_deltaEtaVsE_
double hist_max_recoMass_
TH1D * hist_PhiNumRecoOverNumTrue_
TH1D * hist_PhiOverTruth_
double hist_min_deltaPhi_
TH1D * hist_recoMass_withBackgroud_5EtCut_
TH2D * _TEMP_scatterPlot_deltaEtaVsPhi_
virtual float eta() const
momentum pseudorapidity
TH1D * hist_resolutionEtVsEt_
virtual SuperClusterRef superCluster() const
reference to a SuperCluster
TH2D * _TEMP_scatterPlot_EOverTruthVsEt_
double hist_max_deltaEta_
Cos< T >::type cos(const T &t)
TH1D * hist_EtOverTruthVsE_
TH1D * hist_resolutionEtaVsE_
Tan< T >::type tan(const T &t)
Abs< T >::type abs(const T &t)
TH1D * hist_BarrelOnly_recoMass_
TH1D * hist_EndcapOnly_recoMass_
TH1D * hist_deltaPhiVsEt_
TH1D * hist_EtaOverTruth_
TH1D * hist_deltaPhiVsEta_
TH1D * hist_deltaEtaVsEt_
double hist_max_deltaPhi_
int hist_bins_EtOverTruth_
edm::EDGetTokenT< edm::HepMCProduct > MCTruthCollectionT_
TH1D * hist_recoMass_withBackgroud_10EtCut_
double deltaR(double eta1, double eta2, double phi1, double phi2)
edm::EDGetTokenT< reco::GsfElectronCollection > RecoCollectionT_
TH1D * hist_resolutionPhiVsEt_
double hist_max_PhiOverTruth_
void analyzeElectrons(const edm::Event &, const edm::EventSetup &)
TH2D * _TEMP_scatterPlot_deltaPhiVsEta_
TH2D * _TEMP_scatterPlot_EOverTruthVsE_
double hist_max_EtOverTruth_
EgammaObjects(const edm::ParameterSet &)
TH1D * hist_All_recoMass_
TH2D * _TEMP_scatterPlot_deltaEtaVsEt_
math::XYZPoint caloPosition() const
TH2D * _TEMP_scatterPlot_EOverTruthVsPhi_
std::vector< Photon > PhotonCollection
collectin of Photon objects
TH1D * hist_resolutionEtaVsPhi_
static const float etaBarrelEndcap
T const * product() const
TH1D * hist_EtOverTruthVsPhi_
static const float Z_Endcap
void labelsForToken(EDGetToken iToken, Labels &oLabels) const
double hist_min_recoMass_
TH1D * hist_EtaEfficiency_
TH1D * hist_resolutionPhiVsE_
double hist_min_EOverTruth_
void loadCMSSWObjects(const edm::ParameterSet &ps)
TH1D * hist_recoMass_withBackgroud_NoEtCut_
TH2D * _TEMP_scatterPlot_EtOverTruthVsEt_
int hist_bins_PhiOverTruth_
static const float R_ECAL
double findRecoMass(const reco::Photon &pOne, const reco::Photon &pTwo)
double hist_max_EOverTruth_
int hist_bins_EtaOverTruth_
void createBookedHistoObjects()
TH1D * hist_resolutionEtaVsEta_
TH1D * hist_resolutionPhiVsEta_
TH1D * hist_EtEfficiency_
virtual void analyze(const edm::Event &, const edm::EventSetup &)
TH1D * hist_EtaNumRecoOverNumTrue_
Power< A, B >::type pow(const A &a, const B &b)
TH1D * hist_resolutionEtaVsEt_