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_
 
const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_
 
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 25 of file PhotonEnergyCorrector.h.

Constructor & Destructor Documentation

◆ PhotonEnergyCorrector()

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

Definition at line 13 of file PhotonEnergyCorrector.cc.

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");
21  barrelEcalHitsToken_ = iC.consumes<EcalRecHitCollection>(config.getParameter<edm::InputTag>("barrelEcalHits"));
22  endcapEcalHitsToken_ = iC.consumes<EcalRecHitCollection>(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 }

References eostools::move().

Member Function Documentation

◆ applyCrackCorrection()

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

Definition at line 176 of file PhotonEnergyCorrector.cc.

177  {
178  double crackcor = 1.;
179 
180  for (reco::CaloCluster_iterator cIt = cl.clustersBegin(); cIt != cl.clustersEnd(); ++cIt) {
181  const reco::CaloClusterPtr cc = *cIt;
182  crackcor *= ((cl.rawEnergy() + cc->energy() * (crackCorrectionFunction->getValue(*cc) - 1.)) / cl.rawEnergy());
183  } // loop on BCs
184 
185  return crackcor;
186 }

References GetRecoTauVFromDQM_MC_cff::cl, and EcalClusterFunctionBaseClass::getValue().

Referenced by calculate().

◆ calculate()

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.

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) {
94  } else if (subdet == EcalEndcap) {
96  }
97 
98  EcalClusterLazyTools lazyTools(
100 
102  if (thePhoton.r9() > minR9) {
103  // f(eta) correction to e5x5
104  double deltaE = scEnergyFunction_->getValue(*(thePhoton.superCluster()), 1);
105  float e5x5 = thePhoton.e5x5();
106  if (subdet == EcalBarrel)
107  e5x5 = e5x5 * (1.0 + deltaE / thePhoton.superCluster()->rawEnergy());
108  phoEcalEnergy = e5x5 + thePhoton.superCluster()->preshowerEnergy();
109  } else {
110  phoEcalEnergy = thePhoton.superCluster()->energy();
111  }
112  // store the value in the Photon.h
113  thePhoton.setCorrectedEnergy(reco::Photon::ecal_standard, phoEcalEnergy, phoEcalEnergyError, false);
114 
116 
117  if (thePhoton.r9() > minR9) {
118  // f(eta) correction to e5x5
119  double deltaE = scEnergyFunction_->getValue(*(thePhoton.superCluster()), 1);
120  float e5x5 = thePhoton.e5x5();
121  if (subdet == EcalBarrel)
122  e5x5 = e5x5 * (1.0 + deltaE / thePhoton.superCluster()->rawEnergy());
123  phoEcalEnergy = e5x5 + thePhoton.superCluster()->preshowerEnergy();
124  // add correction for cracks
125  phoEcalEnergy *= scCrackEnergyFunction_->getValue(*(thePhoton.superCluster()));
126  phoEcalEnergyError = photonUncertaintyCalculator_->computePhotonEnergyUncertainty_highR9(
127  thePhoton.superCluster()->eta(),
128  thePhoton.superCluster()->phiWidth() / thePhoton.superCluster()->etaWidth(),
129  phoEcalEnergy);
130  } else {
131  // correction for low r9
132  phoEcalEnergy = photonEcalEnergyCorrFunction_->getValue(*(thePhoton.superCluster()), 1);
133  phoEcalEnergy *= applyCrackCorrection(*(thePhoton.superCluster()), scCrackEnergyFunction_.get());
134  phoEcalEnergyError = photonUncertaintyCalculator_->computePhotonEnergyUncertainty_lowR9(
135  thePhoton.superCluster()->eta(),
136  thePhoton.superCluster()->phiWidth() / thePhoton.superCluster()->etaWidth(),
137  phoEcalEnergy);
138  }
139 
140  // store the value in the Photon.h
141  thePhoton.setCorrectedEnergy(reco::Photon::ecal_photons, phoEcalEnergy, phoEcalEnergyError, false);
142 
144  //
145  if ((weightsfromDB_ && !gedRegression_) || (!weightsfromDB_ && !(w_file_ == "none"))) {
146  std::pair<double, double> cor =
147  regressionCorrector_->CorrectedEnergyWithError(thePhoton, vtxcol, lazyTools, *theCaloGeom_);
148  phoRegr1Energy = cor.first;
149  phoRegr1EnergyError = cor.second;
150  // store the value in the Photon.h
151  thePhoton.setCorrectedEnergy(reco::Photon::regression1, phoRegr1Energy, phoRegr1EnergyError, false);
152  }
153 
154  if (gedRegression_) {
155  gedRegression_->modifyObject(thePhoton); // uses regression2 slot
156  // force regresions1 and 2 to be the same (no reason to be different)
160  false);
161  }
162 
163  /*
164  std::cout << " ------------------------- " << std::endl;
165  std::cout << " Corrector " << std::endl;
166  std::cout << " P4 Type " << thePhoton.getCandidateP4type() << " candidate p4 " << thePhoton.p4() << std::endl;
167  std::cout << " photon ecalEnergy " << thePhoton.getCorrectedEnergy(reco::Photon::ecal_photons) << " error " << thePhoton.getCorrectedEnergyError(reco::Photon::ecal_photons) << std::endl;
168  std::cout << " ecal p4 from accessor " << thePhoton.p4(reco::Photon::ecal_photons) << std::endl;
169  std::cout << " ------------------------- " << std::endl;
170  std::cout << " reg1 energy " << thePhoton.getCorrectedEnergy(reco::Photon::regression1) << " error " << thePhoton.getCorrectedEnergyError(reco::Photon::regression1) << std::endl;
171  std::cout << " New p4 from regression " << thePhoton.p4(reco::Photon::regression1) << std::endl;
172  std::cout << " ------------------------- " << std::endl;
173  */
174 }

References applyCrackCorrection(), barrelEcalHitsToken_, EgHLTOffHistBins_cfi::deltaE, reco::Photon::e5x5(), DetId::Ecal, reco::Photon::ecal_photons, reco::Photon::ecal_standard, EcalBarrel, ecalClusterToolsESGetTokens_, EcalEndcap, endcapEcalHitsToken_, gedRegression_, EcalClusterLazyToolsBase::ESGetTokens::get(), 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().

◆ gedRegression()

std::unique_ptr<ModifyObjectValueBase>& PhotonEnergyCorrector::gedRegression ( )
inline

Definition at line 29 of file PhotonEnergyCorrector.h.

29 { return gedRegression_; }

References gedRegression_.

◆ init()

void PhotonEnergyCorrector::init ( const edm::EventSetup theEventSetup)

Definition at line 60 of file PhotonEnergyCorrector.cc.

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 }

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

Referenced by PhotonProducer::fillPhotonCollection().

Member Data Documentation

◆ barrelEcalHits_

edm::InputTag PhotonEnergyCorrector::barrelEcalHits_
private

Definition at line 50 of file PhotonEnergyCorrector.h.

◆ barrelEcalHitsToken_

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

Definition at line 52 of file PhotonEnergyCorrector.h.

Referenced by calculate().

◆ candidateP4type_

std::string PhotonEnergyCorrector::candidateP4type_
private

Definition at line 40 of file PhotonEnergyCorrector.h.

◆ ecalClusterToolsESGetTokens_

const EcalClusterLazyTools::ESGetTokens PhotonEnergyCorrector::ecalClusterToolsESGetTokens_
private

Definition at line 54 of file PhotonEnergyCorrector.h.

Referenced by calculate().

◆ endcapEcalHits_

edm::InputTag PhotonEnergyCorrector::endcapEcalHits_
private

Definition at line 51 of file PhotonEnergyCorrector.h.

◆ endcapEcalHitsToken_

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

Definition at line 53 of file PhotonEnergyCorrector.h.

Referenced by calculate().

◆ gedRegression_

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

Definition at line 46 of file PhotonEnergyCorrector.h.

Referenced by calculate(), and gedRegression().

◆ minR9Barrel_

double PhotonEnergyCorrector::minR9Barrel_
private

Definition at line 47 of file PhotonEnergyCorrector.h.

Referenced by calculate().

◆ minR9Endcap_

double PhotonEnergyCorrector::minR9Endcap_
private

Definition at line 48 of file PhotonEnergyCorrector.h.

Referenced by calculate().

◆ photonEcalEnergyCorrFunction_

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

Definition at line 45 of file PhotonEnergyCorrector.h.

Referenced by calculate(), and init().

◆ photonUncertaintyCalculator_

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

Definition at line 56 of file PhotonEnergyCorrector.h.

Referenced by calculate(), and init().

◆ regressionCorrector_

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

Definition at line 41 of file PhotonEnergyCorrector.h.

Referenced by calculate(), and init().

◆ scCrackEnergyFunction_

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

Definition at line 43 of file PhotonEnergyCorrector.h.

Referenced by calculate(), and init().

◆ scEnergyErrorFunction_

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

Definition at line 44 of file PhotonEnergyCorrector.h.

Referenced by init().

◆ scEnergyFunction_

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

Definition at line 42 of file PhotonEnergyCorrector.h.

Referenced by calculate(), and init().

◆ theCaloGeom_

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

Definition at line 49 of file PhotonEnergyCorrector.h.

Referenced by calculate(), and init().

◆ w_db_

std::string PhotonEnergyCorrector::w_db_
private

Definition at line 39 of file PhotonEnergyCorrector.h.

Referenced by init().

◆ w_file_

std::string PhotonEnergyCorrector::w_file_
private

Definition at line 38 of file PhotonEnergyCorrector.h.

Referenced by calculate(), and init().

◆ weightsfromDB_

bool PhotonEnergyCorrector::weightsfromDB_
private

Definition at line 37 of file PhotonEnergyCorrector.h.

Referenced by calculate(), and init().

PhotonEnergyCorrector::gedRegression_
std::unique_ptr< ModifyObjectValueBase > gedRegression_
Definition: PhotonEnergyCorrector.h:46
reco::Photon::superCluster
reco::SuperClusterRef superCluster() const override
Ref to SuperCluster.
PhotonEnergyCorrector::scEnergyFunction_
std::unique_ptr< EcalClusterFunctionBaseClass > scEnergyFunction_
Definition: PhotonEnergyCorrector.h:42
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
PhotonEnergyCorrector::minR9Endcap_
double minR9Endcap_
Definition: PhotonEnergyCorrector.h:48
PhotonEnergyCorrector::barrelEcalHitsToken_
edm::EDGetTokenT< EcalRecHitCollection > barrelEcalHitsToken_
Definition: PhotonEnergyCorrector.h:52
CaloGeometry::getSubdetectorGeometry
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
edm::PtrVectorItr
Definition: PtrVector.h:51
edm::SortedCollection< EcalRecHit >
PhotonEnergyCorrector::w_db_
std::string w_db_
Definition: PhotonEnergyCorrector.h:39
PhotonEnergyCorrector::photonEcalEnergyCorrFunction_
std::unique_ptr< EcalClusterFunctionBaseClass > photonEcalEnergyCorrFunction_
Definition: PhotonEnergyCorrector.h:45
EcalBarrel
Definition: EcalSubdetector.h:10
PhotonEnergyCorrector::ecalClusterToolsESGetTokens_
const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_
Definition: PhotonEnergyCorrector.h:54
PhotonEnergyCorrector::minR9Barrel_
double minR9Barrel_
Definition: PhotonEnergyCorrector.h:47
GetRecoTauVFromDQM_MC_cff.cl
cl
Definition: GetRecoTauVFromDQM_MC_cff.py:38
config
Definition: config.py:1
reco::Photon::ecal_photons
Definition: Photon.h:314
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
PhotonEnergyCorrector::endcapEcalHits_
edm::InputTag endcapEcalHits_
Definition: PhotonEnergyCorrector.h:51
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:55
EcalClusterLazyTools
PhotonEnergyCorrector::theCaloGeom_
edm::ESHandle< CaloGeometry > theCaloGeom_
Definition: PhotonEnergyCorrector.h:49
EcalEndcap
Definition: EcalSubdetector.h:10
PhotonEnergyCorrector::scEnergyErrorFunction_
std::unique_ptr< EcalClusterFunctionBaseClass > scEnergyErrorFunction_
Definition: PhotonEnergyCorrector.h:44
edm::ParameterSet
Definition: ParameterSet.h:47
reco::Photon::r9
float r9() const
Definition: Photon.h:273
reco::Photon::getCorrectedEnergyError
float getCorrectedEnergyError(P4type type) const
EgHLTOffHistBins_cfi.deltaE
deltaE
Definition: EgHLTOffHistBins_cfi.py:28
EgHLTOffEleSelection_cfi.minR9
minR9
Definition: EgHLTOffEleSelection_cfi.py:22
PhotonEnergyCorrector::weightsfromDB_
bool weightsfromDB_
Definition: PhotonEnergyCorrector.h:37
DetId::Ecal
Definition: DetId.h:27
reco::Photon::setCorrectedEnergy
void setCorrectedEnergy(P4type type, float E, float dE, bool toCand=true)
get
#define get
cc
reco::Photon::e5x5
float e5x5() const
Definition: Photon.h:267
PhotonEnergyCorrector::w_file_
std::string w_file_
Definition: PhotonEnergyCorrector.h:38
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalClusterLazyToolsBase::ESGetTokens::get
ESData get(edm::EventSetup const &eventSetup) const
Definition: EcalClusterLazyTools.h:64
edm::Ptr< CaloCluster >
EcalClusterFunctionBaseClass::getValue
virtual float getValue(const reco::BasicCluster &, const EcalRecHitCollection &) const =0
PhotonEnergyCorrector::regressionCorrector_
std::unique_ptr< EGEnergyCorrector > regressionCorrector_
Definition: PhotonEnergyCorrector.h:41
eostools.move
def move(src, dest)
Definition: eostools.py:511
reco::Photon::getCorrectedEnergy
float getCorrectedEnergy(P4type type) const
PhotonEnergyCorrector::applyCrackCorrection
double applyCrackCorrection(const reco::SuperCluster &cl, EcalClusterFunctionBaseClass *crackCorrectionFunction)
Definition: PhotonEnergyCorrector.cc:176
reco::Photon::regression1
Definition: Photon.h:314
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
PhotonEnergyCorrector::endcapEcalHitsToken_
edm::EDGetTokenT< EcalRecHitCollection > endcapEcalHitsToken_
Definition: PhotonEnergyCorrector.h:53
PhotonEnergyCorrector::barrelEcalHits_
edm::InputTag barrelEcalHits_
Definition: PhotonEnergyCorrector.h:50
reco::Photon::regression2
Definition: Photon.h:314
PhotonEnergyCorrector::scCrackEnergyFunction_
std::unique_ptr< EcalClusterFunctionBaseClass > scCrackEnergyFunction_
Definition: PhotonEnergyCorrector.h:43
PhotonEnergyCorrector::photonUncertaintyCalculator_
std::unique_ptr< EnergyUncertaintyPhotonSpecific > photonUncertaintyCalculator_
Definition: PhotonEnergyCorrector.h:56
edm::InputTag
Definition: InputTag.h:15
reco::Photon::ecal_standard
Definition: Photon.h:314