28 throw(std::runtime_error(
29 "\n\nEgammaObjects: Only 11 = Photon and 22 = Electron are acceptable parictleIDs! Exiting...\n\n"));
145 TH1::SetDefaultSumw2(
true);
167 "hist_EtNumRecoOverNumTrue_",
188 "hist_ENumRecoOverNumTrue_",
209 "hist_EtaNumRecoOverNumTrue_",
230 "hist_PhiNumRecoOverNumTrue_",
239 recoParticleName =
"Higgs";
241 recoParticleName =
"Z";
244 (recoParticleName +
" Mass from " +
particleString +
" in All Regions").c_str(),
249 (recoParticleName +
" Mass from " +
particleString +
" in Barrel").c_str(),
254 (recoParticleName +
" Mass from " +
particleString +
" in EndCap").c_str(),
259 (recoParticleName +
" Mass from " +
particleString +
" in Split Detectors").c_str(),
265 new TH1D(
"hist_recoMass_withBackgroud_NoEtCut_",
266 (recoParticleName +
" Mass from " +
particleString +
" with Background, No Et Cut").c_str(),
271 new TH1D(
"hist_recoMass_withBackgroud_5EtCut_",
272 (recoParticleName +
" Mass from " +
particleString +
" with Background, 5 Et Cut").c_str(),
277 new TH1D(
"hist_recoMass_withBackgroud_10EtCut_",
278 (recoParticleName +
" Mass from " +
particleString +
" with Background, 10 Et Cut").c_str(),
283 new TH1D(
"hist_recoMass_withBackgroud_20EtCut_",
284 (recoParticleName +
" Mass from " +
particleString +
" with Background, 20 Et Cut").c_str(),
292 "_TEMP_scatterPlot_EtOverTruthVsEt_",
300 "_TEMP_scatterPlot_EtOverTruthVsE_",
308 "_TEMP_scatterPlot_EtOverTruthVsEta_",
316 "_TEMP_scatterPlot_EtOverTruthVsPhi_",
325 "_TEMP_scatterPlot_EOverTruthVsEt_",
333 "_TEMP_scatterPlot_EOverTruthVsE_",
341 "_TEMP_scatterPlot_EOverTruthVsEta_",
349 "_TEMP_scatterPlot_EOverTruthVsPhi_",
358 "_TEMP_scatterPlot_deltaEtaVsEt_",
366 "_TEMP_scatterPlot_deltaEtaVsE_",
374 "_TEMP_scatterPlot_deltaEtaVsEta_",
382 "_TEMP_scatterPlot_deltaEtaVsPhi_",
391 "_TEMP_scatterPlot_deltaPhiVsEt_",
399 "_TEMP_scatterPlot_deltaPhiVsE_",
407 "_TEMP_scatterPlot_deltaPhiVsEta_",
415 "_TEMP_scatterPlot_deltaPhiVsPhi_",
437 edm::LogError(
"EgammaObjects") <<
"Error! can't get collection with label " <<
l.module;
441 std::vector<reco::Photon> photonsMCMatched;
443 for (reco::PhotonCollection::const_iterator aClus =
photons->begin(); aClus !=
photons->end(); aClus++) {
444 if (aClus->et() >=
EtCut) {
446 hist_E_->Fill(aClus->energy());
452 for (
int firstPhoton = 0, numPhotons =
photons->size(); firstPhoton < numPhotons - 1; firstPhoton++)
453 for (
int secondPhoton = firstPhoton + 1; secondPhoton < numPhotons; secondPhoton++) {
461 if (pOne.
et() >= 5 && pTwo.
et() >= 5)
464 if (pOne.
et() >= 10 && pTwo.
et() >= 10)
467 if (pOne.
et() >= 20 && pTwo.
et() >= 20)
476 edm::LogError(
"EgammaObjects") <<
"Error! can't get collection with label " <<
l.module;
481 for (HepMC::GenEvent::particle_const_iterator currentParticle =
genEvent->particles_begin();
482 currentParticle !=
genEvent->particles_end();
484 if (
abs((*currentParticle)->pdg_id()) == 22 && (*currentParticle)->status() == 1 &&
485 (*currentParticle)->momentum().e() /
486 cosh(
ecalEta((*currentParticle)->momentum().eta(),
487 (*currentParticle)->production_vertex()->position().z() / 10.,
488 (*currentParticle)->production_vertex()->position().perp() / 10.)) >=
490 HepMC::FourVector
vtx = (*currentParticle)->production_vertex()->position();
491 double phiTrue = (*currentParticle)->momentum().phi();
492 double etaTrue =
ecalEta((*currentParticle)->momentum().eta(),
vtx.z() / 10.,
vtx.perp() / 10.);
493 double eTrue = (*currentParticle)->momentum().e();
494 double etTrue = (*currentParticle)->momentum().e() / cosh(etaTrue);
496 double etaCurrent, etaFound = -999;
497 double phiCurrent, phiFound = -999;
498 double etCurrent, etFound = -999;
499 double eCurrent, eFound = -999;
503 double closestParticleDistance = 999;
505 for (reco::PhotonCollection::const_iterator aClus =
photons->begin(); aClus !=
photons->end(); aClus++) {
506 if (aClus->et() >
EtCut) {
507 etaCurrent = aClus->
eta();
508 phiCurrent = aClus->phi();
509 etCurrent = aClus->et();
510 eCurrent = aClus->energy();
512 double deltaPhi = phiCurrent - phiTrue;
519 if (
deltaR < closestParticleDistance) {
522 etaFound = etaCurrent;
523 phiFound = phiCurrent;
524 closestParticleDistance =
deltaR;
525 bestMatchPhoton = *aClus;
530 if (closestParticleDistance < 0.05 && etFound / etTrue > .5 && etFound / etTrue < 1.5) {
541 double deltaPhi = phiFound - phiTrue;
567 photonsMCMatched.push_back(bestMatchPhoton);
577 if (photonsMCMatched.size() == 2) {
600 edm::LogError(
"DOEPlotsProducerElectrons") <<
"Error! can't get collection with label " <<
l.module;
604 std::vector<reco::GsfElectron> electronsMCMatched;
606 for (reco::GsfElectronCollection::const_iterator aClus =
electrons->begin(); aClus !=
electrons->end(); aClus++) {
607 if (aClus->et() >=
EtCut) {
609 hist_E_->Fill(aClus->energy());
615 for (
int firstElectron = 0, numElectrons =
electrons->size(); firstElectron < numElectrons - 1; firstElectron++)
616 for (
int secondElectron = firstElectron + 1; secondElectron < numElectrons; secondElectron++) {
624 if (eOne.
et() >= 5 && eTwo.
et() >= 5)
627 if (eOne.
et() >= 10 && eTwo.
et() >= 10)
630 if (eOne.
et() >= 20 && eTwo.
et() >= 20)
639 edm::LogError(
"DOEPlotsProducerElectrons") <<
"Error! can't get collection with label " <<
l.module;
643 for (HepMC::GenEvent::particle_const_iterator currentParticle =
genEvent->particles_begin();
644 currentParticle !=
genEvent->particles_end();
646 if (
abs((*currentParticle)->pdg_id()) == 11 && (*currentParticle)->status() == 1 &&
647 (*currentParticle)->momentum().e() / cosh((*currentParticle)->momentum().eta()) >=
EtCut) {
648 double phiTrue = (*currentParticle)->momentum().phi();
649 double etaTrue = (*currentParticle)->momentum().eta();
650 double eTrue = (*currentParticle)->momentum().e();
651 double etTrue = (*currentParticle)->momentum().e() / cosh(etaTrue);
653 double etaCurrent, etaFound = -999;
654 double phiCurrent, phiFound = -999;
655 double etCurrent, etFound = -999;
656 double eCurrent, eFound = -999;
660 double closestParticleDistance = 999;
662 for (reco::GsfElectronCollection::const_iterator aClus =
electrons->begin(); aClus !=
electrons->end(); aClus++) {
663 if (aClus->et() >
EtCut) {
664 etaCurrent = aClus->
eta();
665 phiCurrent = aClus->phi();
666 etCurrent = aClus->et();
667 eCurrent = aClus->energy();
669 double deltaPhi = phiCurrent - phiTrue;
676 if (
deltaR < closestParticleDistance) {
679 etaFound = etaCurrent;
680 phiFound = phiCurrent;
681 closestParticleDistance =
deltaR;
682 bestMatchElectron = *aClus;
687 if (closestParticleDistance < 0.05 && etFound / etTrue > .5 && etFound / etTrue < 1.5) {
698 double deltaPhi = phiFound - phiTrue;
724 electronsMCMatched.push_back(bestMatchElectron);
734 if (electronsMCMatched.size() == 2) {
772 const float R_ECAL = 136.5;
776 if (EtaParticle != 0.) {
778 float ZEcal = (
R_ECAL - plane_Radius) * sinh(EtaParticle) + Zvertex;
789 if (EtaParticle < 0.0)
791 float Zlen = Zend - Zvertex;
792 float RR = Zlen / sinh(EtaParticle);
793 Theta = atan((RR + plane_Radius) / Zend);
801 edm::LogWarning(
"") <<
"[EgammaObjects::ecalEta] Warning: Eta equals to zero, not correcting";
908 (
"#sigma of Reco Et over True Et VS Et of " +
particleString).c_str());
910 (
"#sigma of Reco Et over True Et VS E of " +
particleString).c_str());
912 (
"#sigma of Reco Et over True Et VS Eta of " +
particleString).c_str());
914 (
"#sigma of Reco Et over True Et VS Phi of " +
particleString).c_str());
917 (
"#sigma of Reco E over True E VS Et of " +
particleString).c_str());
919 (
"#sigma of Reco E over True E VS E of " +
particleString).c_str());
921 (
"#sigma of Reco E over True E VS Eta of " +
particleString).c_str());
923 (
"#sigma of Reco E over True E VS Phi of " +
particleString).c_str());
958 TF1 gaus(
"mygaus",
"gaus");
1003 hist_Et_->GetXaxis()->SetTitle(
"Et (GeV)");
1004 hist_Et_->GetYaxis()->SetTitle(
"# per Et Bin");
1028 hist_E_->GetXaxis()->SetTitle(
"E (GeV)");
1029 hist_E_->GetYaxis()->SetTitle(
"# per E Bin");
1033 hist_EEfficiency_->GetYaxis()->SetTitle(
"# True Reconstructed/# True per E Bin");
1053 hist_Eta_->GetXaxis()->SetTitle(
"#eta (Radians)");
1054 hist_Eta_->GetYaxis()->SetTitle(
"# per Eta Bin");
1078 hist_Phi_->GetXaxis()->SetTitle(
"#phi (Radians)");
1079 hist_Phi_->GetYaxis()->SetTitle(
"# per Phi Bin");
1106 recoParticleName =
"Reco Higgs";
1108 recoParticleName =
"Reco Z";
1110 hist_All_recoMass_->GetXaxis()->SetTitle((recoParticleName +
" Mass (GeV)").c_str());
1263 recoParticleName =
"HiggsRecoMass";
1265 recoParticleName =
"ZRecoMass";
TH1D * hist_resolutionEVsPhi_
TH2D * _TEMP_scatterPlot_EtOverTruthVsPhi_
double hist_min_deltaEta_
double hist_min_EtaOverTruth_
TH2D * _TEMP_scatterPlot_deltaEtaVsEta_
TH1D * hist_resolutionEVsE_
math::XYZPoint caloPosition() const
T getParameter(std::string const &) const
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_
TH1D * hist_deltaEtaVsPhi_
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_
T const * product() const
TH1D * hist_resolutionPhiVsPhi_
TH1D * hist_resolutionEtVsEta_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
TH2D * _TEMP_scatterPlot_EOverTruthVsEta_
TH2D * _TEMP_scatterPlot_deltaPhiVsEt_
TH1D * hist_ENumRecoOverNumTrue_
TH1D * hist_deltaPhiVsPhi_
double hist_max_EtaOverTruth_
Log< level::Error, false > LogError
void loadHistoParameters(const edm::ParameterSet &ps)
TH1D * hist_EOverTruthVsE_
static constexpr float R_ECAL
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_
reco::SuperClusterRef superCluster() const override
Ref to SuperCluster.
double hist_max_recoMass_
TH1D * hist_PhiNumRecoOverNumTrue_
TH1D * hist_PhiOverTruth_
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)
Abs< T >::type abs(const T &t)
TH1D * hist_BarrelOnly_recoMass_
TH1D * hist_EndcapOnly_recoMass_
TH1D * hist_deltaPhiVsEt_
static constexpr float etaBarrelEndcap
TH1D * hist_EtaOverTruth_
TH1D * hist_deltaPhiVsEta_
TH1D * hist_deltaEtaVsEt_
double hist_max_deltaPhi_
int hist_bins_EtOverTruth_
const HepMC::GenEvent * GetEvent() const
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_
~EgammaObjects() override
EgammaObjects(const edm::ParameterSet &)
TH1D * hist_All_recoMass_
TH2D * _TEMP_scatterPlot_deltaEtaVsEt_
std::vector< Photon > PhotonCollection
collectin of Photon objects
TH2D * _TEMP_scatterPlot_EOverTruthVsPhi_
TH1D * hist_resolutionEtaVsPhi_
TH1D * hist_EtOverTruthVsPhi_
double hist_min_recoMass_
TH1D * hist_EtaEfficiency_
double et() const final
transverse energy
TH1D * hist_resolutionPhiVsE_
double hist_min_EOverTruth_
void loadCMSSWObjects(const edm::ParameterSet &ps)
TH1D * hist_recoMass_withBackgroud_NoEtCut_
static constexpr float ZEcal
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_
Log< level::Warning, false > LogWarning
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)
SuperClusterRef superCluster() const override
reference to a SuperCluster
static constexpr float Z_Endcap
void labelsForToken(EDGetToken iToken, Labels &oLabels) const
TH1D * hist_resolutionEtaVsEt_
double eta() const final
momentum pseudorapidity