CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
PhotonEnergyCorrector Class Reference

#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)
 
std::unique_ptr< ModifyObjectValueBase > & gedRegression ()
 
void init (const edm::EventSetup &theEventSetup)
 
 PhotonEnergyCorrector (const edm::ParameterSet &config, edm::ConsumesCollector &&iC)
 

Private Attributes

edm::InputTag barrelEcalHits_
 
edm::EDGetTokenT< EcalRecHitCollectionbarrelEcalHitsToken_
 
std::string candidateP4type_
 
edm::InputTag endcapEcalHits_
 
edm::EDGetTokenT< EcalRecHitCollectionendcapEcalHitsToken_
 
std::unique_ptr< ModifyObjectValueBasegedRegression_
 
double minR9Barrel_
 
double minR9Endcap_
 
std::unique_ptr< EcalClusterFunctionBaseClassphotonEcalEnergyCorrFunction_
 
std::unique_ptr< EnergyUncertaintyPhotonSpecificphotonUncertaintyCalculator_
 
std::unique_ptr< EGEnergyCorrectorregressionCorrector_
 
std::unique_ptr< EcalClusterFunctionBaseClassscCrackEnergyFunction_
 
std::unique_ptr< EcalClusterFunctionBaseClassscEnergyErrorFunction_
 
std::unique_ptr< EcalClusterFunctionBaseClassscEnergyFunction_
 
edm::ESHandle< CaloGeometrytheCaloGeom_
 
std::string w_db_
 
std::string w_file_
 
bool weightsfromDB_
 

Detailed Description

Author
Nancy Marinelli, U. of Notre Dame, US

Definition at line 26 of file PhotonEnergyCorrector.h.

Constructor & Destructor Documentation

PhotonEnergyCorrector::PhotonEnergyCorrector ( const edm::ParameterSet config,
edm::ConsumesCollector &&  iC 
)

Definition at line 14 of file PhotonEnergyCorrector.cc.

References barrelEcalHits_, barrelEcalHitsToken_, looper::config, endcapEcalHits_, endcapEcalHitsToken_, edm::ParameterSet::existsAs(), gedRegression_, timingPdfMaker::get, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterSet(), minR9Barrel_, minR9Endcap_, photonEcalEnergyCorrFunction_, photonUncertaintyCalculator_, regressionCorrector_, scCrackEnergyFunction_, scEnergyErrorFunction_, scEnergyFunction_, AlCaHLTBitMon_QueryRunRegistry::string, w_db_, w_file_, and weightsfromDB_.

14  {
15  minR9Barrel_ = config.getParameter<double>("minR9Barrel");
16  minR9Endcap_ = config.getParameter<double>("minR9Endcap");
17  // get the geometry from the event setup:
18 
19  barrelEcalHits_ = config.getParameter<edm::InputTag>("barrelEcalHits");
20  endcapEcalHits_ = config.getParameter<edm::InputTag>("endcapEcalHits");
23 
24  // candidateP4type_ = config.getParameter<std::string>("candidateP4type") ;
25 
26  // function to extract f(eta) correction
27  std::string superClusterFunctionName = config.getParameter<std::string>("superClusterEnergyCorrFunction");
28  scEnergyFunction_ = EcalClusterFunctionFactory::get()->create(superClusterFunctionName, config);
29 
30  // function to extract corrections to cracks
31  std::string superClusterCrackFunctionName = config.getParameter<std::string>("superClusterCrackEnergyCorrFunction");
32  scCrackEnergyFunction_ = EcalClusterFunctionFactory::get()->create(superClusterCrackFunctionName, config);
33 
34  // function to extract the error on the sc ecal correction
35  std::string superClusterErrorFunctionName = config.getParameter<std::string>("superClusterEnergyErrorFunction");
36  scEnergyErrorFunction_ = EcalClusterFunctionFactory::get()->create(superClusterErrorFunctionName, config);
37 
38  // function to extract the error on the photon ecal correction
39  std::string photonEnergyFunctionName = config.getParameter<std::string>("photonEcalEnergyCorrFunction");
40  photonEcalEnergyCorrFunction_ = EcalClusterFunctionFactory::get()->create(photonEnergyFunctionName, config);
41  //ingredient for photon uncertainty
42  photonUncertaintyCalculator_ = std::make_unique<EnergyUncertaintyPhotonSpecific>(config);
43 
44  if (config.existsAs<edm::ParameterSet>("regressionConfig")) {
45  const edm::ParameterSet& regr_conf = config.getParameterSet("regressionConfig");
46  const std::string& mname = regr_conf.getParameter<std::string>("modifierName");
47  gedRegression_ = ModifyObjectValueFactory::get()->create(mname, regr_conf, iC);
48  }
49 
50  // ingredient for energy regression
51  weightsfromDB_ = config.getParameter<bool>("regressionWeightsFromDB");
52  w_file_ = config.getParameter<std::string>("energyRegressionWeightsFileLocation");
53  if (weightsfromDB_)
54  w_db_ = config.getParameter<std::string>("energyRegressionWeightsDBLocation");
55  else
56  w_db_ = "none";
57  regressionCorrector_ = std::make_unique<EGEnergyCorrector>();
58 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:160
std::unique_ptr< EcalClusterFunctionBaseClass > scCrackEnergyFunction_
edm::EDGetTokenT< EcalRecHitCollection > endcapEcalHitsToken_
std::unique_ptr< EnergyUncertaintyPhotonSpecific > photonUncertaintyCalculator_
config
Definition: looper.py:291
std::unique_ptr< EcalClusterFunctionBaseClass > scEnergyFunction_
edm::EDGetTokenT< EcalRecHitCollection > barrelEcalHitsToken_
std::unique_ptr< EcalClusterFunctionBaseClass > photonEcalEnergyCorrFunction_
ParameterSet const & getParameterSet(std::string const &) const
std::unique_ptr< EcalClusterFunctionBaseClass > scEnergyErrorFunction_
std::unique_ptr< ModifyObjectValueBase > gedRegression_
std::unique_ptr< EGEnergyCorrector > regressionCorrector_

Member Function Documentation

double PhotonEnergyCorrector::applyCrackCorrection ( const reco::SuperCluster cl,
EcalClusterFunctionBaseClass crackCorrectionFunction 
)

Definition at line 175 of file PhotonEnergyCorrector.cc.

References reco::SuperCluster::clustersBegin(), reco::SuperCluster::clustersEnd(), EcalClusterFunctionBaseClass::getValue(), and reco::SuperCluster::rawEnergy().

Referenced by calculate(), and gedRegression().

176  {
177  double crackcor = 1.;
178 
179  for (reco::CaloCluster_iterator cIt = cl.clustersBegin(); cIt != cl.clustersEnd(); ++cIt) {
180  const reco::CaloClusterPtr cc = *cIt;
181  crackcor *= ((cl.rawEnergy() + cc->energy() * (crackCorrectionFunction->getValue(*cc) - 1.)) / cl.rawEnergy());
182  } // loop on BCs
183 
184  return crackcor;
185 }
virtual float getValue(const reco::BasicCluster &, const EcalRecHitCollection &) const =0
double rawEnergy() const
raw uncorrected energy (sum of energies of component BasicClusters)
Definition: SuperCluster.h:58
CaloCluster_iterator clustersBegin() const
fist iterator over BasicCluster constituents
Definition: SuperCluster.h:86
CaloCluster_iterator clustersEnd() const
last iterator over BasicCluster constituents
Definition: SuperCluster.h:89
void PhotonEnergyCorrector::calculate ( edm::Event evt,
reco::Photon thePhoton,
int  subdet,
const reco::VertexCollection vtxcol,
const edm::EventSetup iSetup 
)

Definition at line 80 of file PhotonEnergyCorrector.cc.

References applyCrackCorrection(), barrelEcalHitsToken_, EgHLTOffHistBins_cfi::deltaE, reco::Photon::e5x5(), DetId::Ecal, reco::Photon::ecal_photons, reco::Photon::ecal_standard, EcalBarrel, EcalEndcap, endcapEcalHitsToken_, gedRegression_, reco::Photon::getCorrectedEnergy(), reco::Photon::getCorrectedEnergyError(), CaloGeometry::getSubdetectorGeometry(), EgHLTOffEleSelection_cfi::minR9, minR9Barrel_, minR9Endcap_, photonEcalEnergyCorrFunction_, photonUncertaintyCalculator_, reco::Photon::r9(), reco::Photon::regression1, reco::Photon::regression2, regressionCorrector_, scCrackEnergyFunction_, scEnergyFunction_, reco::Photon::setCorrectedEnergy(), reco::Photon::superCluster(), theCaloGeom_, w_file_, and weightsfromDB_.

Referenced by PhotonProducer::fillPhotonCollection(), GEDPhotonProducer::fillPhotonCollection(), and gedRegression().

84  {
85  double phoEcalEnergy = -9999.;
86  double phoEcalEnergyError = -9999.;
87  double phoRegr1Energy = -9999.;
88  double phoRegr1EnergyError = -9999.;
90 
91  double minR9 = 0;
92  if (subdet == EcalBarrel) {
93  minR9 = minR9Barrel_;
94  } else if (subdet == EcalEndcap) {
95  minR9 = minR9Endcap_;
96  }
97 
99 
101  if (thePhoton.r9() > minR9) {
102  // f(eta) correction to e5x5
103  double deltaE = scEnergyFunction_->getValue(*(thePhoton.superCluster()), 1);
104  float e5x5 = thePhoton.e5x5();
105  if (subdet == EcalBarrel)
106  e5x5 = e5x5 * (1.0 + deltaE / thePhoton.superCluster()->rawEnergy());
107  phoEcalEnergy = e5x5 + thePhoton.superCluster()->preshowerEnergy();
108  } else {
109  phoEcalEnergy = thePhoton.superCluster()->energy();
110  }
111  // store the value in the Photon.h
112  thePhoton.setCorrectedEnergy(reco::Photon::ecal_standard, phoEcalEnergy, phoEcalEnergyError, false);
113 
115 
116  if (thePhoton.r9() > minR9) {
117  // f(eta) correction to e5x5
118  double deltaE = scEnergyFunction_->getValue(*(thePhoton.superCluster()), 1);
119  float e5x5 = thePhoton.e5x5();
120  if (subdet == EcalBarrel)
121  e5x5 = e5x5 * (1.0 + deltaE / thePhoton.superCluster()->rawEnergy());
122  phoEcalEnergy = e5x5 + thePhoton.superCluster()->preshowerEnergy();
123  // add correction for cracks
124  phoEcalEnergy *= scCrackEnergyFunction_->getValue(*(thePhoton.superCluster()));
125  phoEcalEnergyError = photonUncertaintyCalculator_->computePhotonEnergyUncertainty_highR9(
126  thePhoton.superCluster()->eta(),
127  thePhoton.superCluster()->phiWidth() / thePhoton.superCluster()->etaWidth(),
128  phoEcalEnergy);
129  } else {
130  // correction for low r9
131  phoEcalEnergy = photonEcalEnergyCorrFunction_->getValue(*(thePhoton.superCluster()), 1);
132  phoEcalEnergy *= applyCrackCorrection(*(thePhoton.superCluster()), scCrackEnergyFunction_.get());
133  phoEcalEnergyError = photonUncertaintyCalculator_->computePhotonEnergyUncertainty_lowR9(
134  thePhoton.superCluster()->eta(),
135  thePhoton.superCluster()->phiWidth() / thePhoton.superCluster()->etaWidth(),
136  phoEcalEnergy);
137  }
138 
139  // store the value in the Photon.h
140  thePhoton.setCorrectedEnergy(reco::Photon::ecal_photons, phoEcalEnergy, phoEcalEnergyError, false);
141 
143  //
144  if ((weightsfromDB_ && !gedRegression_) || (!weightsfromDB_ && !(w_file_ == "none"))) {
145  std::pair<double, double> cor =
146  regressionCorrector_->CorrectedEnergyWithError(thePhoton, vtxcol, lazyTools, iSetup);
147  phoRegr1Energy = cor.first;
148  phoRegr1EnergyError = cor.second;
149  // store the value in the Photon.h
150  thePhoton.setCorrectedEnergy(reco::Photon::regression1, phoRegr1Energy, phoRegr1EnergyError, false);
151  }
152 
153  if (gedRegression_) {
154  gedRegression_->modifyObject(thePhoton); // uses regression2 slot
155  // force regresions1 and 2 to be the same (no reason to be different)
159  false);
160  }
161 
162  /*
163  std::cout << " ------------------------- " << std::endl;
164  std::cout << " Corrector " << std::endl;
165  std::cout << " P4 Type " << thePhoton.getCandidateP4type() << " candidate p4 " << thePhoton.p4() << std::endl;
166  std::cout << " photon ecalEnergy " << thePhoton.getCorrectedEnergy(reco::Photon::ecal_photons) << " error " << thePhoton.getCorrectedEnergyError(reco::Photon::ecal_photons) << std::endl;
167  std::cout << " ecal p4 from accessor " << thePhoton.p4(reco::Photon::ecal_photons) << std::endl;
168  std::cout << " ------------------------- " << std::endl;
169  std::cout << " reg1 energy " << thePhoton.getCorrectedEnergy(reco::Photon::regression1) << " error " << thePhoton.getCorrectedEnergyError(reco::Photon::regression1) << std::endl;
170  std::cout << " New p4 from regression " << thePhoton.p4(reco::Photon::regression1) << std::endl;
171  std::cout << " ------------------------- " << std::endl;
172  */
173 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
edm::ESHandle< CaloGeometry > theCaloGeom_
std::unique_ptr< EcalClusterFunctionBaseClass > scCrackEnergyFunction_
void setCorrectedEnergy(P4type type, float E, float dE, bool toCand=true)
float e5x5() const
Definition: Photon.h:234
double applyCrackCorrection(const reco::SuperCluster &cl, EcalClusterFunctionBaseClass *crackCorrectionFunction)
edm::EDGetTokenT< EcalRecHitCollection > endcapEcalHitsToken_
reco::SuperClusterRef superCluster() const override
Ref to SuperCluster.
std::unique_ptr< EnergyUncertaintyPhotonSpecific > photonUncertaintyCalculator_
std::unique_ptr< EcalClusterFunctionBaseClass > scEnergyFunction_
edm::EDGetTokenT< EcalRecHitCollection > barrelEcalHitsToken_
float getCorrectedEnergyError(P4type type) const
std::unique_ptr< EcalClusterFunctionBaseClass > photonEcalEnergyCorrFunction_
float getCorrectedEnergy(P4type type) const
std::unique_ptr< ModifyObjectValueBase > gedRegression_
float r9() const
Definition: Photon.h:240
std::unique_ptr< EGEnergyCorrector > regressionCorrector_
std::unique_ptr<ModifyObjectValueBase>& PhotonEnergyCorrector::gedRegression ( )
inline

Definition at line 30 of file PhotonEnergyCorrector.h.

References applyCrackCorrection(), calculate(), GetRecoTauVFromDQM_MC_cff::cl, gedRegression_, and init().

Referenced by GEDPhotonProducer::produce().

30 { return gedRegression_; }
std::unique_ptr< ModifyObjectValueBase > gedRegression_
void PhotonEnergyCorrector::init ( const edm::EventSetup theEventSetup)

Definition at line 60 of file PhotonEnergyCorrector.cc.

References edm::EventSetup::get(), photonEcalEnergyCorrFunction_, photonUncertaintyCalculator_, regressionCorrector_, scCrackEnergyFunction_, scEnergyErrorFunction_, scEnergyFunction_, theCaloGeom_, w_db_, w_file_, and weightsfromDB_.

Referenced by GEDPhotonProducer::beginRun(), PhotonProducer::fillPhotonCollection(), gedRegression(), and GEDPhotonProducer::produce().

60  {
61  theEventSetup.get<CaloGeometryRecord>().get(theCaloGeom_);
62 
63  scEnergyFunction_->init(theEventSetup);
64  scCrackEnergyFunction_->init(theEventSetup);
65  scEnergyErrorFunction_->init(theEventSetup);
66  photonEcalEnergyCorrFunction_->init(theEventSetup);
67 
68  if (weightsfromDB_) {
69  if (!regressionCorrector_->IsInitialized())
70  regressionCorrector_->Initialize(theEventSetup, w_db_, weightsfromDB_);
71  }
72  if (!weightsfromDB_ && !(w_file_ == "none")) {
73  if (!regressionCorrector_->IsInitialized())
74  regressionCorrector_->Initialize(theEventSetup, w_file_, weightsfromDB_);
75  }
76 
77  photonUncertaintyCalculator_->init(theEventSetup);
78 }
edm::ESHandle< CaloGeometry > theCaloGeom_
std::unique_ptr< EcalClusterFunctionBaseClass > scCrackEnergyFunction_
std::unique_ptr< EnergyUncertaintyPhotonSpecific > photonUncertaintyCalculator_
std::unique_ptr< EcalClusterFunctionBaseClass > scEnergyFunction_
std::unique_ptr< EcalClusterFunctionBaseClass > photonEcalEnergyCorrFunction_
std::unique_ptr< EcalClusterFunctionBaseClass > scEnergyErrorFunction_
T get() const
Definition: EventSetup.h:73
std::unique_ptr< EGEnergyCorrector > regressionCorrector_

Member Data Documentation

edm::InputTag PhotonEnergyCorrector::barrelEcalHits_
private

Definition at line 51 of file PhotonEnergyCorrector.h.

Referenced by PhotonEnergyCorrector().

edm::EDGetTokenT<EcalRecHitCollection> PhotonEnergyCorrector::barrelEcalHitsToken_
private

Definition at line 53 of file PhotonEnergyCorrector.h.

Referenced by calculate(), and PhotonEnergyCorrector().

std::string PhotonEnergyCorrector::candidateP4type_
private

Definition at line 41 of file PhotonEnergyCorrector.h.

edm::InputTag PhotonEnergyCorrector::endcapEcalHits_
private

Definition at line 52 of file PhotonEnergyCorrector.h.

Referenced by PhotonEnergyCorrector().

edm::EDGetTokenT<EcalRecHitCollection> PhotonEnergyCorrector::endcapEcalHitsToken_
private

Definition at line 54 of file PhotonEnergyCorrector.h.

Referenced by calculate(), and PhotonEnergyCorrector().

std::unique_ptr<ModifyObjectValueBase> PhotonEnergyCorrector::gedRegression_
private

Definition at line 47 of file PhotonEnergyCorrector.h.

Referenced by calculate(), gedRegression(), and PhotonEnergyCorrector().

double PhotonEnergyCorrector::minR9Barrel_
private

Definition at line 48 of file PhotonEnergyCorrector.h.

Referenced by calculate(), and PhotonEnergyCorrector().

double PhotonEnergyCorrector::minR9Endcap_
private

Definition at line 49 of file PhotonEnergyCorrector.h.

Referenced by calculate(), and PhotonEnergyCorrector().

std::unique_ptr<EcalClusterFunctionBaseClass> PhotonEnergyCorrector::photonEcalEnergyCorrFunction_
private

Definition at line 46 of file PhotonEnergyCorrector.h.

Referenced by calculate(), init(), and PhotonEnergyCorrector().

std::unique_ptr<EnergyUncertaintyPhotonSpecific> PhotonEnergyCorrector::photonUncertaintyCalculator_
private

Definition at line 56 of file PhotonEnergyCorrector.h.

Referenced by calculate(), init(), and PhotonEnergyCorrector().

std::unique_ptr<EGEnergyCorrector> PhotonEnergyCorrector::regressionCorrector_
private

Definition at line 42 of file PhotonEnergyCorrector.h.

Referenced by calculate(), init(), and PhotonEnergyCorrector().

std::unique_ptr<EcalClusterFunctionBaseClass> PhotonEnergyCorrector::scCrackEnergyFunction_
private

Definition at line 44 of file PhotonEnergyCorrector.h.

Referenced by calculate(), init(), and PhotonEnergyCorrector().

std::unique_ptr<EcalClusterFunctionBaseClass> PhotonEnergyCorrector::scEnergyErrorFunction_
private

Definition at line 45 of file PhotonEnergyCorrector.h.

Referenced by init(), and PhotonEnergyCorrector().

std::unique_ptr<EcalClusterFunctionBaseClass> PhotonEnergyCorrector::scEnergyFunction_
private

Definition at line 43 of file PhotonEnergyCorrector.h.

Referenced by calculate(), init(), and PhotonEnergyCorrector().

edm::ESHandle<CaloGeometry> PhotonEnergyCorrector::theCaloGeom_
private

Definition at line 50 of file PhotonEnergyCorrector.h.

Referenced by calculate(), and init().

std::string PhotonEnergyCorrector::w_db_
private

Definition at line 40 of file PhotonEnergyCorrector.h.

Referenced by init(), and PhotonEnergyCorrector().

std::string PhotonEnergyCorrector::w_file_
private

Definition at line 39 of file PhotonEnergyCorrector.h.

Referenced by calculate(), init(), and PhotonEnergyCorrector().

bool PhotonEnergyCorrector::weightsfromDB_
private

Definition at line 38 of file PhotonEnergyCorrector.h.

Referenced by calculate(), init(), and PhotonEnergyCorrector().