27 throw(std::runtime_error(
"\n\nEgammaObjects: Only 11 = Photon and 22 = Electron are acceptable parictleIDs! Exiting...\n\n"));
152 TH1::SetDefaultSumw2(
true);
161 =
new TH1D(
"hist_Et_",(
"Et Distribution of "+
particleString).c_str(),
164 =
new TH1D(
"hist_EtOverTruth_",(
"Reco Et over True Et of "+
particleString).c_str(),
174 =
new TH1D(
"hist_E_",(
"E Distribution of "+
particleString).c_str(),
177 =
new TH1D(
"hist_EOverTruth_",(
"Reco E over True E of "+
particleString).c_str(),
187 =
new TH1D(
"hist_Eta_",(
"Eta Distribution of "+
particleString).c_str(),
190 =
new TH1D(
"hist_EtaOverTruth_",(
"Reco Eta over True Eta of "+
particleString).c_str(),
200 =
new TH1D(
"hist_Phi_",(
"Phi Distribution of "+
particleString).c_str(),
203 =
new TH1D(
"hist_PhiOverTruth_",(
"Reco Phi over True Phi of "+
particleString).c_str(),
214 if(
particleID == 22 ) recoParticleName =
"Higgs";
215 else if(
particleID == 11 ) recoParticleName =
"Z";
218 =
new TH1D(
"hist_All_recoMass_",(recoParticleName+
" Mass from "+
particleString+
" in All Regions").c_str(),
221 =
new TH1D(
"hist_BarrelOnly_recoMass_",(recoParticleName+
" Mass from "+
particleString+
" in Barrel").c_str(),
224 =
new TH1D(
"hist_EndcapOnly_recoMass_",(recoParticleName+
" Mass from "+
particleString+
" in EndCap").c_str(),
227 =
new TH1D(
"hist_Mixed_recoMass_",(recoParticleName+
" Mass from "+
particleString+
" in Split Detectors").c_str(),
231 =
new TH1D(
"hist_recoMass_withBackgroud_NoEtCut_",(recoParticleName+
" Mass from "+
particleString+
" with Background, No Et Cut").c_str(),
234 =
new TH1D(
"hist_recoMass_withBackgroud_5EtCut_",(recoParticleName+
" Mass from "+
particleString+
" with Background, 5 Et Cut").c_str(),
237 =
new TH1D(
"hist_recoMass_withBackgroud_10EtCut_",(recoParticleName+
" Mass from "+
particleString+
" with Background, 10 Et Cut").c_str(),
240 =
new TH1D(
"hist_recoMass_withBackgroud_20EtCut_",(recoParticleName+
" Mass from "+
particleString+
" with Background, 20 Et Cut").c_str(),
247 =
new TH2D(
"_TEMP_scatterPlot_EtOverTruthVsEt_",
"_TEMP_scatterPlot_EtOverTruthVsEt_",
250 =
new TH2D(
"_TEMP_scatterPlot_EtOverTruthVsE_",
"_TEMP_scatterPlot_EtOverTruthVsE_",
253 =
new TH2D(
"_TEMP_scatterPlot_EtOverTruthVsEta_",
"_TEMP_scatterPlot_EtOverTruthVsEta_",
256 =
new TH2D(
"_TEMP_scatterPlot_EtOverTruthVsPhi_",
"_TEMP_scatterPlot_EtOverTruthVsPhi_",
260 =
new TH2D(
"_TEMP_scatterPlot_EOverTruthVsEt_",
"_TEMP_scatterPlot_EOverTruthVsEt_",
263 =
new TH2D(
"_TEMP_scatterPlot_EOverTruthVsE_",
"_TEMP_scatterPlot_EOverTruthVsE_",
266 =
new TH2D(
"_TEMP_scatterPlot_EOverTruthVsEta_",
"_TEMP_scatterPlot_EOverTruthVsEta_",
269 =
new TH2D(
"_TEMP_scatterPlot_EOverTruthVsPhi_",
"_TEMP_scatterPlot_EOverTruthVsPhi_",
273 =
new TH2D(
"_TEMP_scatterPlot_deltaEtaVsEt_",
"_TEMP_scatterPlot_deltaEtaVsEt_",
276 =
new TH2D(
"_TEMP_scatterPlot_deltaEtaVsE_",
"_TEMP_scatterPlot_deltaEtaVsE_",
279 =
new TH2D(
"_TEMP_scatterPlot_deltaEtaVsEta_",
"_TEMP_scatterPlot_deltaEtaVsEta_",
282 =
new TH2D(
"_TEMP_scatterPlot_deltaEtaVsPhi_",
"_TEMP_scatterPlot_deltaEtaVsPhi_",
286 =
new TH2D(
"_TEMP_scatterPlot_deltaPhiVsEt_",
"_TEMP_scatterPlot_deltaPhiVsEt_",
289 =
new TH2D(
"_TEMP_scatterPlot_deltaPhiVsE_",
"_TEMP_scatterPlot_deltaPhiVsE_",
292 =
new TH2D(
"_TEMP_scatterPlot_deltaPhiVsEta_",
"_TEMP_scatterPlot_deltaPhiVsEta_",
295 =
new TH2D(
"_TEMP_scatterPlot_deltaPhiVsPhi_",
"_TEMP_scatterPlot_deltaPhiVsPhi_",
313 <<
"Error! can't get collection with label " 318 std::vector<reco::Photon> photonsMCMatched;
320 for(reco::PhotonCollection::const_iterator aClus = photons->begin(); aClus != photons->end(); aClus++)
322 if(aClus->et() >=
EtCut)
325 hist_E_->Fill(aClus->energy());
331 for(
int firstPhoton = 0, numPhotons = photons->size(); firstPhoton < numPhotons - 1; firstPhoton++)
332 for(
int secondPhoton = firstPhoton + 1; secondPhoton < numPhotons; secondPhoton++)
341 if(pOne.
et() >= 5 && pTwo.
et() >= 5)
344 if(pOne.
et() >= 10 && pTwo.
et() >= 10)
347 if(pOne.
et() >= 20 && pTwo.
et() >= 20)
357 <<
"Error! can't get collection with label " 363 for(HepMC::GenEvent::particle_const_iterator currentParticle = genEvent->particles_begin();
364 currentParticle != genEvent->particles_end(); currentParticle++ )
366 if(
abs((*currentParticle)->pdg_id())==22 && (*currentParticle)->status()==1
367 && (*currentParticle)->momentum().e()/cosh(
ecalEta((*currentParticle)->momentum().eta(), (*currentParticle)->production_vertex()->position().z()/10.,
368 (*currentParticle)->production_vertex()->position().perp()/10.)) >=
EtCut)
370 HepMC::FourVector
vtx = (*currentParticle)->production_vertex()->position();
371 double phiTrue = (*currentParticle)->momentum().phi();
372 double etaTrue =
ecalEta((*currentParticle)->momentum().eta(), vtx.z()/10., vtx.perp()/10.);
373 double eTrue = (*currentParticle)->momentum().e();
374 double etTrue = (*currentParticle)->momentum().e()/cosh(etaTrue);
376 double etaCurrent, etaFound = -999;
377 double phiCurrent, phiFound = -999;
378 double etCurrent, etFound = -999;
379 double eCurrent, eFound = -999;
383 double closestParticleDistance = 999;
385 for(reco::PhotonCollection::const_iterator aClus = photons->begin(); aClus != photons->end(); aClus++)
387 if(aClus->et() >
EtCut)
389 etaCurrent = aClus->
eta();
390 phiCurrent = aClus->phi();
391 etCurrent = aClus->et();
392 eCurrent = aClus->energy();
394 double deltaPhi = phiCurrent-phiTrue;
399 if(deltaR < closestParticleDistance)
403 etaFound = etaCurrent;
404 phiFound = phiCurrent;
405 closestParticleDistance =
deltaR;
406 bestMatchPhoton = *aClus;
411 if(closestParticleDistance < 0.05 && etFound/etTrue > .5 && etFound/etTrue < 1.5)
447 photonsMCMatched.push_back(bestMatchPhoton);
457 if(photonsMCMatched.size() == 2)
483 <<
"Error! can't get collection with label " 488 std::vector<reco::GsfElectron> electronsMCMatched;
490 for(reco::GsfElectronCollection::const_iterator aClus = electrons->begin(); aClus != electrons->end(); aClus++)
492 if(aClus->et() >=
EtCut)
495 hist_E_->Fill(aClus->energy());
501 for(
int firstElectron = 0, numElectrons = electrons->size(); firstElectron < numElectrons - 1; firstElectron++)
502 for(
int secondElectron = firstElectron + 1; secondElectron < numElectrons; secondElectron++)
511 if(eOne.
et() >= 5 && eTwo.
et() >= 5)
514 if(eOne.
et() >= 10 && eTwo.
et() >= 10)
517 if(eOne.
et() >= 20 && eTwo.
et() >= 20)
527 <<
"Error! can't get collection with label " 532 for(HepMC::GenEvent::particle_const_iterator currentParticle = genEvent->particles_begin();
533 currentParticle != genEvent->particles_end(); currentParticle++ )
535 if(
abs((*currentParticle)->pdg_id())==11 && (*currentParticle)->status()==1
536 && (*currentParticle)->momentum().e()/cosh((*currentParticle)->momentum().eta()) >=
EtCut)
538 double phiTrue = (*currentParticle)->momentum().phi();
539 double etaTrue = (*currentParticle)->momentum().eta();
540 double eTrue = (*currentParticle)->momentum().e();
541 double etTrue = (*currentParticle)->momentum().e()/cosh(etaTrue);
543 double etaCurrent, etaFound = -999;
544 double phiCurrent, phiFound = -999;
545 double etCurrent, etFound = -999;
546 double eCurrent, eFound = -999;
550 double closestParticleDistance = 999;
552 for(reco::GsfElectronCollection::const_iterator aClus = electrons->begin(); aClus != electrons->end(); aClus++)
554 if(aClus->et() >
EtCut)
556 etaCurrent = aClus->
eta();
557 phiCurrent = aClus->phi();
558 etCurrent = aClus->et();
559 eCurrent = aClus->energy();
561 double deltaPhi = phiCurrent-phiTrue;
566 if(deltaR < closestParticleDistance)
570 etaFound = etaCurrent;
571 phiFound = phiCurrent;
572 closestParticleDistance =
deltaR;
573 bestMatchElectron = *aClus;
578 if(closestParticleDistance < 0.05 && etFound/etTrue > .5 && etFound/etTrue < 1.5)
614 electronsMCMatched.push_back(bestMatchElectron);
624 if(electronsMCMatched.size() == 2)
666 const float R_ECAL = 136.5;
670 if(EtaParticle != 0.)
673 float ZEcal = (R_ECAL-plane_Radius)*sinh(EtaParticle)+Zvertex;
675 if(ZEcal != 0.0) Theta = atan(R_ECAL/ZEcal);
676 if(Theta<0.0) Theta = Theta+
Geom::pi() ;
680 if(
std::abs(ETA) > etaBarrelEndcap )
683 if(EtaParticle<0.0 ) Zend = -Zend ;
684 float Zlen = Zend - Zvertex ;
685 float RR = Zlen/sinh(EtaParticle);
686 Theta = atan((RR+plane_Radius)/Zend);
687 if(Theta<0.0) Theta = Theta+
Geom::pi() ;
688 ETA = -
log(
tan(0.5*Theta));
695 edm::LogWarning(
"") <<
"[EgammaObjects::ecalEta] Warning: Eta equals to zero, not correcting" ;
835 TF1 gaus(
"mygaus",
"gaus");
881 hist_Et_->GetXaxis()->SetTitle(
"Et (GeV)");
882 hist_Et_->GetYaxis()->SetTitle(
"# per Et Bin");
906 hist_E_->GetXaxis()->SetTitle(
"E (GeV)");
907 hist_E_->GetYaxis()->SetTitle(
"# per E Bin");
911 hist_EEfficiency_->GetYaxis()->SetTitle(
"# True Reconstructed/# True per E Bin");
931 hist_Eta_->GetXaxis()->SetTitle(
"#eta (Radians)");
932 hist_Eta_->GetYaxis()->SetTitle(
"# per Eta Bin");
956 hist_Phi_->GetXaxis()->SetTitle(
"#phi (Radians)");
957 hist_Phi_->GetYaxis()->SetTitle(
"# per Phi Bin");
983 if(
particleID == 22 ) recoParticleName =
"Reco Higgs";
984 else if(
particleID == 11 ) recoParticleName =
"Reco Z";
1140 if(
particleID == 22 ) recoParticleName =
"HiggsRecoMass";
1141 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_
double eta() const final
momentum pseudorapidity
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_
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_
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_
reco::SuperClusterRef superCluster() const override
Ref to SuperCluster.
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_
void analyze(const edm::Event &, const edm::EventSetup &) override
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 et() const final
transverse energy
double hist_min_deltaPhi_
TH1D * hist_recoMass_withBackgroud_5EtCut_
TH2D * _TEMP_scatterPlot_deltaEtaVsPhi_
TH1D * hist_resolutionEtVsEt_
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)
static float etaBarrelEndcap
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_
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_
const HepMC::GenEvent * GetEvent() const
~EgammaObjects() override
T const * product() const
EgammaObjects(const edm::ParameterSet &)
TH1D * hist_All_recoMass_
TH2D * _TEMP_scatterPlot_deltaEtaVsEt_
std::vector< Photon > PhotonCollection
collectin of Photon objects
math::XYZPoint caloPosition() const
TH2D * _TEMP_scatterPlot_EOverTruthVsPhi_
TH1D * hist_resolutionEtaVsPhi_
TH1D * hist_EtOverTruthVsPhi_
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_
SuperClusterRef superCluster() const override
reference to a SuperCluster
TH2D * _TEMP_scatterPlot_EtOverTruthVsEt_
int hist_bins_PhiOverTruth_
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_
TH1D * hist_EtaNumRecoOverNumTrue_
Power< A, B >::type pow(const A &a, const B &b)
TH1D * hist_resolutionEtaVsEt_