#include <PhotonEnergyCorrector.h>
Public Member Functions | |
double | applyCrackCorrection (const reco::SuperCluster &cl, EcalClusterFunctionBaseClass *crackCorrectionFunction) |
void | calculate (edm::Event &evt, reco::Photon &, int subdet, const reco::VertexCollection &vtxcol, const edm::EventSetup &iSetup) |
void | init (const edm::EventSetup &theEventSetup) |
PhotonEnergyCorrector (const edm::ParameterSet &config) | |
~PhotonEnergyCorrector () | |
Private Attributes | |
edm::InputTag | barrelEcalHits_ |
std::string | candidateP4type_ |
edm::InputTag | endcapEcalHits_ |
double | minR9Barrel_ |
double | minR9Endcap_ |
EcalClusterFunctionBaseClass * | photonEcalEnergyCorrFunction_ |
EnergyUncertaintyPhotonSpecific * | photonUncertaintyCalculator_ |
EGEnergyCorrector * | regressionCorrector_ |
EcalClusterFunctionBaseClass * | scCrackEnergyFunction_ |
EcalClusterFunctionBaseClass * | scEnergyErrorFunction_ |
EcalClusterFunctionBaseClass * | scEnergyFunction_ |
edm::ESHandle< CaloGeometry > | theCaloGeom_ |
std::string | w_db_ |
std::string | w_file_ |
bool | weightsfromDB_ |
Definition at line 27 of file PhotonEnergyCorrector.h.
PhotonEnergyCorrector::PhotonEnergyCorrector | ( | const edm::ParameterSet & | config | ) |
Definition at line 13 of file PhotonEnergyCorrector.cc.
References barrelEcalHits_, endcapEcalHits_, reco::get(), edm::ParameterSet::getParameter(), minR9Barrel_, minR9Endcap_, photonEcalEnergyCorrFunction_, photonUncertaintyCalculator_, regressionCorrector_, scCrackEnergyFunction_, scEnergyErrorFunction_, scEnergyFunction_, w_db_, w_file_, and weightsfromDB_.
{ minR9Barrel_ = config.getParameter<double>("minR9Barrel"); minR9Endcap_ = config.getParameter<double>("minR9Endcap"); // get the geometry from the event setup: barrelEcalHits_ = config.getParameter<edm::InputTag>("barrelEcalHits"); endcapEcalHits_ = config.getParameter<edm::InputTag>("endcapEcalHits"); // candidateP4type_ = config.getParameter<std::string>("candidateP4type") ; // function to extract f(eta) correction scEnergyFunction_ = 0 ; std::string superClusterFunctionName = config.getParameter<std::string>("superClusterEnergyCorrFunction") ; scEnergyFunction_ = EcalClusterFunctionFactory::get()->create(superClusterFunctionName,config) ; // function to extract corrections to cracks scCrackEnergyFunction_ = 0 ; std::string superClusterCrackFunctionName = config.getParameter<std::string>("superClusterCrackEnergyCorrFunction") ; scCrackEnergyFunction_ = EcalClusterFunctionFactory::get()->create(superClusterCrackFunctionName,config) ; // function to extract the error on the sc ecal correction scEnergyErrorFunction_ = 0 ; std::string superClusterErrorFunctionName = config.getParameter<std::string>("superClusterEnergyErrorFunction") ; scEnergyErrorFunction_ = EcalClusterFunctionFactory::get()->create(superClusterErrorFunctionName,config) ; // function to extract the error on the photon ecal correction photonEcalEnergyCorrFunction_=0; std::string photonEnergyFunctionName = config.getParameter<std::string>("photonEcalEnergyCorrFunction") ; photonEcalEnergyCorrFunction_ = EcalClusterFunctionFactory::get()->create(photonEnergyFunctionName, config); //ingredient for photon uncertainty photonUncertaintyCalculator_ = new EnergyUncertaintyPhotonSpecific(config); // ingredient for energy regression weightsfromDB_= config.getParameter<bool>("regressionWeightsFromDB"); w_file_ = config.getParameter<std::string>("energyRegressionWeightsFileLocation"); if (weightsfromDB_) w_db_ = config.getParameter<std::string>("energyRegressionWeightsDBLocation"); else w_db_ == "none" ; regressionCorrector_ = new EGEnergyCorrector(); }
PhotonEnergyCorrector::~PhotonEnergyCorrector | ( | ) |
Definition at line 63 of file PhotonEnergyCorrector.cc.
References photonUncertaintyCalculator_, and regressionCorrector_.
{ delete regressionCorrector_; delete photonUncertaintyCalculator_; }
double PhotonEnergyCorrector::applyCrackCorrection | ( | const reco::SuperCluster & | cl, |
EcalClusterFunctionBaseClass * | crackCorrectionFunction | ||
) |
Definition at line 181 of file PhotonEnergyCorrector.cc.
References reco::SuperCluster::clustersBegin(), reco::SuperCluster::clustersEnd(), EcalClusterFunctionBaseClass::getValue(), and reco::SuperCluster::rawEnergy().
Referenced by calculate().
{ double crackcor = 1.; for(reco::CaloCluster_iterator cIt = cl.clustersBegin(); cIt != cl.clustersEnd(); ++cIt) { const reco::CaloClusterPtr cc = *cIt; crackcor *= ( (cl.rawEnergy() + cc->energy()*(crackCorrectionFunction->getValue(*cc)-1.)) / cl.rawEnergy() ); }// loop on BCs return crackcor; }
void PhotonEnergyCorrector::calculate | ( | edm::Event & | evt, |
reco::Photon & | thePhoton, | ||
int | subdet, | ||
const reco::VertexCollection & | vtxcol, | ||
const edm::EventSetup & | iSetup | ||
) |
Definition at line 93 of file PhotonEnergyCorrector.cc.
References applyCrackCorrection(), barrelEcalHits_, EnergyUncertaintyPhotonSpecific::computePhotonEnergyUncertainty_highR9(), EnergyUncertaintyPhotonSpecific::computePhotonEnergyUncertainty_lowR9(), EGEnergyCorrector::CorrectedEnergyWithError(), reco::Photon::e5x5(), DetId::Ecal, reco::Photon::ecal_photons, reco::Photon::ecal_standard, EcalBarrel, EcalEndcap, endcapEcalHits_, EcalClusterFunctionBaseClass::getValue(), minR9Barrel_, minR9Endcap_, photonEcalEnergyCorrFunction_, photonUncertaintyCalculator_, reco::Photon::r9(), reco::Photon::regression1, regressionCorrector_, scCrackEnergyFunction_, scEnergyFunction_, reco::Photon::setCorrectedEnergy(), reco::Photon::superCluster(), theCaloGeom_, w_file_, and weightsfromDB_.
Referenced by PhotonProducer::fillPhotonCollection().
{ double phoEcalEnergy = -9999.; double phoEcalEnergyError = -9999.; double phoRegr1Energy = -9999.; double phoRegr1EnergyError = -9999.; theCaloGeom_->getSubdetectorGeometry(DetId::Ecal, subdet); double minR9=0; if (subdet==EcalBarrel) { minR9=minR9Barrel_; } else if (subdet==EcalEndcap) { minR9=minR9Endcap_; } EcalClusterLazyTools lazyTools(evt, iSetup, barrelEcalHits_,endcapEcalHits_); if ( thePhoton.r9() > minR9 ) { // f(eta) correction to e5x5 double deltaE = scEnergyFunction_->getValue(*(thePhoton.superCluster()), 1); float e5x5=thePhoton.e5x5(); if (subdet==EcalBarrel) e5x5 = e5x5 * (1.0 + deltaE/thePhoton.superCluster()->rawEnergy() ); phoEcalEnergy = e5x5 + thePhoton.superCluster()->preshowerEnergy() ; } else { phoEcalEnergy = thePhoton.superCluster()->energy(); } // store the value in the Photon.h thePhoton.setCorrectedEnergy( reco::Photon::ecal_standard, phoEcalEnergy, phoEcalEnergyError, false); if ( thePhoton.r9() > minR9 ) { // f(eta) correction to e5x5 double deltaE = scEnergyFunction_->getValue(*(thePhoton.superCluster()), 1); float e5x5=thePhoton.e5x5(); if (subdet==EcalBarrel) e5x5 = e5x5 * (1.0 + deltaE/thePhoton.superCluster()->rawEnergy() ); phoEcalEnergy = e5x5 + thePhoton.superCluster()->preshowerEnergy() ; // add correction for cracks phoEcalEnergy *= scCrackEnergyFunction_->getValue(*(thePhoton.superCluster())); phoEcalEnergyError = photonUncertaintyCalculator_->computePhotonEnergyUncertainty_highR9(thePhoton.superCluster()->eta(), thePhoton.superCluster()->phiWidth()/thePhoton.superCluster()->etaWidth(), phoEcalEnergy); } else { // correction for low r9 phoEcalEnergy = photonEcalEnergyCorrFunction_->getValue(*(thePhoton.superCluster()), 1); phoEcalEnergy *= applyCrackCorrection(*(thePhoton.superCluster()), scCrackEnergyFunction_); phoEcalEnergyError = photonUncertaintyCalculator_->computePhotonEnergyUncertainty_lowR9(thePhoton.superCluster()->eta(), thePhoton.superCluster()->phiWidth()/thePhoton.superCluster()->etaWidth(), phoEcalEnergy); } // store the value in the Photon.h thePhoton.setCorrectedEnergy( reco::Photon::ecal_photons, phoEcalEnergy, phoEcalEnergyError, false); // if ( weightsfromDB_ || ( !weightsfromDB_ && !(w_file_ == "none") ) ) { std::pair<double,double> cor = regressionCorrector_->CorrectedEnergyWithError(thePhoton, vtxcol, lazyTools, iSetup); phoRegr1Energy = cor.first; phoRegr1EnergyError = cor.second; // store the value in the Photon.h thePhoton.setCorrectedEnergy( reco::Photon::regression1, phoRegr1Energy, phoRegr1EnergyError, false); } /* std::cout << " ------------------------- " << std::endl; std::cout << " Corrector " << std::endl; std::cout << " P4 Type " << thePhoton.getCandidateP4type() << " candidate p4 " << thePhoton.p4() << std::endl; std::cout << " photon ecalEnergy " << thePhoton.getCorrectedEnergy(reco::Photon::ecal_photons) << " error " << thePhoton.getCorrectedEnergyError(reco::Photon::ecal_photons) << std::endl; std::cout << " ecal p4 from accessor " << thePhoton.p4(reco::Photon::ecal_photons) << std::endl; std::cout << " ------------------------- " << std::endl; std::cout << " reg1 energy " << thePhoton.getCorrectedEnergy(reco::Photon::regression1) << " error " << thePhoton.getCorrectedEnergyError(reco::Photon::regression1) << std::endl; std::cout << " New p4 from regression " << thePhoton.p4(reco::Photon::regression1) << std::endl; std::cout << " ------------------------- " << std::endl; */ }
void PhotonEnergyCorrector::init | ( | const edm::EventSetup & | theEventSetup | ) |
Definition at line 70 of file PhotonEnergyCorrector.cc.
References edm::EventSetup::get(), EcalClusterFunctionBaseClass::init(), EnergyUncertaintyPhotonSpecific::init(), EGEnergyCorrector::Initialize(), EGEnergyCorrector::IsInitialized(), photonEcalEnergyCorrFunction_, photonUncertaintyCalculator_, regressionCorrector_, scCrackEnergyFunction_, scEnergyErrorFunction_, scEnergyFunction_, theCaloGeom_, w_db_, w_file_, and weightsfromDB_.
{ theEventSetup.get<CaloGeometryRecord>().get(theCaloGeom_); scEnergyFunction_->init(theEventSetup); scCrackEnergyFunction_->init(theEventSetup); scEnergyErrorFunction_->init(theEventSetup); photonEcalEnergyCorrFunction_->init(theEventSetup); if ( weightsfromDB_ ) { if (!regressionCorrector_->IsInitialized()) regressionCorrector_->Initialize(theEventSetup,w_db_,weightsfromDB_); } if ( !weightsfromDB_ && !(w_file_ == "none") ) { if (!regressionCorrector_->IsInitialized()) regressionCorrector_->Initialize(theEventSetup,w_file_,weightsfromDB_); } photonUncertaintyCalculator_->init(theEventSetup); }
Definition at line 52 of file PhotonEnergyCorrector.h.
Referenced by calculate(), and PhotonEnergyCorrector().
std::string PhotonEnergyCorrector::candidateP4type_ [private] |
Definition at line 43 of file PhotonEnergyCorrector.h.
Definition at line 53 of file PhotonEnergyCorrector.h.
Referenced by calculate(), and PhotonEnergyCorrector().
double PhotonEnergyCorrector::minR9Barrel_ [private] |
Definition at line 49 of file PhotonEnergyCorrector.h.
Referenced by calculate(), and PhotonEnergyCorrector().
double PhotonEnergyCorrector::minR9Endcap_ [private] |
Definition at line 50 of file PhotonEnergyCorrector.h.
Referenced by calculate(), and PhotonEnergyCorrector().
Definition at line 48 of file PhotonEnergyCorrector.h.
Referenced by calculate(), init(), and PhotonEnergyCorrector().
Definition at line 55 of file PhotonEnergyCorrector.h.
Referenced by calculate(), init(), PhotonEnergyCorrector(), and ~PhotonEnergyCorrector().
Definition at line 44 of file PhotonEnergyCorrector.h.
Referenced by calculate(), init(), PhotonEnergyCorrector(), and ~PhotonEnergyCorrector().
Definition at line 46 of file PhotonEnergyCorrector.h.
Referenced by calculate(), init(), and PhotonEnergyCorrector().
Definition at line 47 of file PhotonEnergyCorrector.h.
Referenced by init(), and PhotonEnergyCorrector().
Definition at line 45 of file PhotonEnergyCorrector.h.
Referenced by calculate(), init(), and PhotonEnergyCorrector().
Definition at line 51 of file PhotonEnergyCorrector.h.
Referenced by calculate(), and init().
std::string PhotonEnergyCorrector::w_db_ [private] |
Definition at line 42 of file PhotonEnergyCorrector.h.
Referenced by init(), and PhotonEnergyCorrector().
std::string PhotonEnergyCorrector::w_file_ [private] |
Definition at line 41 of file PhotonEnergyCorrector.h.
Referenced by calculate(), init(), and PhotonEnergyCorrector().
bool PhotonEnergyCorrector::weightsfromDB_ [private] |
Definition at line 40 of file PhotonEnergyCorrector.h.
Referenced by calculate(), init(), and PhotonEnergyCorrector().