CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
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_
 
EcalClusterFunctionBaseClassphotonEcalEnergyCorrFunction_
 
EnergyUncertaintyPhotonSpecificphotonUncertaintyCalculator_
 
EGEnergyCorrectorregressionCorrector_
 
EcalClusterFunctionBaseClassscCrackEnergyFunction_
 
EcalClusterFunctionBaseClassscEnergyErrorFunction_
 
EcalClusterFunctionBaseClassscEnergyFunction_
 
edm::ESHandle< CaloGeometrytheCaloGeom_
 
std::string w_db_
 
std::string w_file_
 
bool weightsfromDB_
 

Detailed Description

Id:
PhotonEnergyCorrector.h,v 1.7 2012/03/26 14:38:40 nancy Exp
Date:
2012/03/26 14:38:40
Revision:
1.7
Author
Nancy Marinelli, U. of Notre Dame, US

Definition at line 27 of file PhotonEnergyCorrector.h.

Constructor & Destructor Documentation

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_, AlCaHLTBitMon_QueryRunRegistry::string, w_db_, w_file_, and weightsfromDB_.

13  {
14 
15 
16  minR9Barrel_ = config.getParameter<double>("minR9Barrel");
17  minR9Endcap_ = config.getParameter<double>("minR9Endcap");
18  // get the geometry from the event setup:
19 
20  barrelEcalHits_ = config.getParameter<edm::InputTag>("barrelEcalHits");
21  endcapEcalHits_ = config.getParameter<edm::InputTag>("endcapEcalHits");
22  // candidateP4type_ = config.getParameter<std::string>("candidateP4type") ;
23 
24 
25  // function to extract f(eta) correction
26  scEnergyFunction_ = 0 ;
27  std::string superClusterFunctionName = config.getParameter<std::string>("superClusterEnergyCorrFunction") ;
28  scEnergyFunction_ = EcalClusterFunctionFactory::get()->create(superClusterFunctionName,config) ;
29 
30 
31  // function to extract corrections to cracks
33  std::string superClusterCrackFunctionName = config.getParameter<std::string>("superClusterCrackEnergyCorrFunction") ;
34  scCrackEnergyFunction_ = EcalClusterFunctionFactory::get()->create(superClusterCrackFunctionName,config) ;
35 
36 
37  // function to extract the error on the sc ecal correction
39  std::string superClusterErrorFunctionName = config.getParameter<std::string>("superClusterEnergyErrorFunction") ;
40  scEnergyErrorFunction_ = EcalClusterFunctionFactory::get()->create(superClusterErrorFunctionName,config) ;
41 
42 
43  // function to extract the error on the photon ecal correction
45  std::string photonEnergyFunctionName = config.getParameter<std::string>("photonEcalEnergyCorrFunction") ;
46  photonEcalEnergyCorrFunction_ = EcalClusterFunctionFactory::get()->create(photonEnergyFunctionName, config);
47  //ingredient for photon uncertainty
49 
50 
51 
52  // ingredient for energy regression
53  weightsfromDB_= config.getParameter<bool>("regressionWeightsFromDB");
54  w_file_ = config.getParameter<std::string>("energyRegressionWeightsFileLocation");
55  if (weightsfromDB_) w_db_ = config.getParameter<std::string>("energyRegressionWeightsDBLocation");
56  else w_db_ == "none" ;
58 
59 
60 }
T getParameter(std::string const &) const
EcalClusterFunctionBaseClass * scEnergyFunction_
EcalClusterFunctionBaseClass * photonEcalEnergyCorrFunction_
EGEnergyCorrector * regressionCorrector_
EcalClusterFunctionBaseClass * scEnergyErrorFunction_
EnergyUncertaintyPhotonSpecific * photonUncertaintyCalculator_
EcalClusterFunctionBaseClass * scCrackEnergyFunction_
T get(const Candidate &c)
Definition: component.h:56
PhotonEnergyCorrector::~PhotonEnergyCorrector ( )

Definition at line 63 of file PhotonEnergyCorrector.cc.

References photonUncertaintyCalculator_, and regressionCorrector_.

63  {
64  delete regressionCorrector_;
66 }
EGEnergyCorrector * regressionCorrector_
EnergyUncertaintyPhotonSpecific * photonUncertaintyCalculator_

Member Function Documentation

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().

182  {
183 
184 
185  double crackcor = 1.;
186 
187  for(reco::CaloCluster_iterator cIt = cl.clustersBegin(); cIt != cl.clustersEnd(); ++cIt) {
188 
189  const reco::CaloClusterPtr cc = *cIt;
190  crackcor *= ( (cl.rawEnergy() +
191  cc->energy()*(crackCorrectionFunction->getValue(*cc)-1.)) /
192  cl.rawEnergy() );
193  }// loop on BCs
194 
195 
196  return crackcor;
197 
198 }
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:49
CaloCluster_iterator clustersBegin() const
fist iterator over BasicCluster constituents
Definition: SuperCluster.h:71
CaloCluster_iterator clustersEnd() const
last iterator over BasicCluster constituents
Definition: SuperCluster.h:74
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 GEDPhotonProducer::fillPhotonCollection(), and PhotonProducer::fillPhotonCollection().

93  {
94 
95  double phoEcalEnergy = -9999.;
96  double phoEcalEnergyError = -9999.;
97  double phoRegr1Energy = -9999.;
98  double phoRegr1EnergyError = -9999.;
99  theCaloGeom_->getSubdetectorGeometry(DetId::Ecal, subdet);
100 
101  double minR9=0;
102  if (subdet==EcalBarrel) {
103  minR9=minR9Barrel_;
104  } else if (subdet==EcalEndcap) {
105  minR9=minR9Endcap_;
106  }
107 
108 
109 
110  EcalClusterLazyTools lazyTools(evt, iSetup, barrelEcalHits_,endcapEcalHits_);
111 
112 
113 
115  if ( thePhoton.r9() > minR9 ) {
116  // f(eta) correction to e5x5
117  double deltaE = scEnergyFunction_->getValue(*(thePhoton.superCluster()), 1);
118  float e5x5=thePhoton.e5x5();
119  if (subdet==EcalBarrel) e5x5 = e5x5 * (1.0 + deltaE/thePhoton.superCluster()->rawEnergy() );
120  phoEcalEnergy = e5x5 + thePhoton.superCluster()->preshowerEnergy() ;
121  } else {
122  phoEcalEnergy = thePhoton.superCluster()->energy();
123  }
124  // store the value in the Photon.h
125  thePhoton.setCorrectedEnergy( reco::Photon::ecal_standard, phoEcalEnergy, phoEcalEnergyError, false);
126 
128 
129  if ( thePhoton.r9() > minR9 ) {
130 
131 
132 
133  // f(eta) correction to e5x5
134  double deltaE = scEnergyFunction_->getValue(*(thePhoton.superCluster()), 1);
135  float e5x5=thePhoton.e5x5();
136  if (subdet==EcalBarrel) e5x5 = e5x5 * (1.0 + deltaE/thePhoton.superCluster()->rawEnergy() );
137  phoEcalEnergy = e5x5 + thePhoton.superCluster()->preshowerEnergy() ;
138  // add correction for cracks
139  phoEcalEnergy *= scCrackEnergyFunction_->getValue(*(thePhoton.superCluster()));
140  phoEcalEnergyError = photonUncertaintyCalculator_->computePhotonEnergyUncertainty_highR9(thePhoton.superCluster()->eta(), thePhoton.superCluster()->phiWidth()/thePhoton.superCluster()->etaWidth(), phoEcalEnergy);
141  } else {
142 
143 
144  // correction for low r9
145  phoEcalEnergy = photonEcalEnergyCorrFunction_->getValue(*(thePhoton.superCluster()), 1);
146  phoEcalEnergy *= applyCrackCorrection(*(thePhoton.superCluster()), scCrackEnergyFunction_);
147  phoEcalEnergyError = photonUncertaintyCalculator_->computePhotonEnergyUncertainty_lowR9(thePhoton.superCluster()->eta(), thePhoton.superCluster()->phiWidth()/thePhoton.superCluster()->etaWidth(), phoEcalEnergy);
148  }
149 
150 
151  // store the value in the Photon.h
152  thePhoton.setCorrectedEnergy( reco::Photon::ecal_photons, phoEcalEnergy, phoEcalEnergyError, false);
153 
155  //
156  if ( weightsfromDB_ || ( !weightsfromDB_ && !(w_file_ == "none") ) ) {
157  std::pair<double,double> cor = regressionCorrector_->CorrectedEnergyWithError(thePhoton, vtxcol, lazyTools, iSetup);
158  phoRegr1Energy = cor.first;
159  phoRegr1EnergyError = cor.second;
160  // store the value in the Photon.h
161  thePhoton.setCorrectedEnergy( reco::Photon::regression1, phoRegr1Energy, phoRegr1EnergyError, false);
162  }
163 
164 
165 
166  /*
167  std::cout << " ------------------------- " << std::endl;
168  std::cout << " Corrector " << std::endl;
169  std::cout << " P4 Type " << thePhoton.getCandidateP4type() << " candidate p4 " << thePhoton.p4() << std::endl;
170  std::cout << " photon ecalEnergy " << thePhoton.getCorrectedEnergy(reco::Photon::ecal_photons) << " error " << thePhoton.getCorrectedEnergyError(reco::Photon::ecal_photons) << std::endl;
171  std::cout << " ecal p4 from accessor " << thePhoton.p4(reco::Photon::ecal_photons) << std::endl;
172  std::cout << " ------------------------- " << std::endl;
173  std::cout << " reg1 energy " << thePhoton.getCorrectedEnergy(reco::Photon::regression1) << " error " << thePhoton.getCorrectedEnergyError(reco::Photon::regression1) << std::endl;
174  std::cout << " New p4 from regression " << thePhoton.p4(reco::Photon::regression1) << std::endl;
175  std::cout << " ------------------------- " << std::endl;
176  */
177 
178 
179 }
EcalClusterFunctionBaseClass * scEnergyFunction_
edm::ESHandle< CaloGeometry > theCaloGeom_
double computePhotonEnergyUncertainty_highR9(double eta, double brem, double energy)
float e5x5() const
Definition: Photon.h:185
double applyCrackCorrection(const reco::SuperCluster &cl, EcalClusterFunctionBaseClass *crackCorrectionFunction)
reco::SuperClusterRef superCluster() const
Ref to SuperCluster.
Definition: Photon.cc:59
EcalClusterFunctionBaseClass * photonEcalEnergyCorrFunction_
virtual float getValue(const reco::BasicCluster &, const EcalRecHitCollection &) const =0
std::pair< double, double > CorrectedEnergyWithError(const reco::Photon &p, const reco::VertexCollection &vtxcol, EcalClusterLazyTools &clustertools, const edm::EventSetup &es)
EGEnergyCorrector * regressionCorrector_
void setCorrectedEnergy(P4type type, float E, float dE, bool toCand=true)
Definition: Photon.cc:93
double computePhotonEnergyUncertainty_lowR9(double eta, double brem, double energy)
EnergyUncertaintyPhotonSpecific * photonUncertaintyCalculator_
EcalClusterFunctionBaseClass * scCrackEnergyFunction_
float r9() const
Definition: Photon.h:191
void PhotonEnergyCorrector::init ( const edm::EventSetup theEventSetup)

Definition at line 70 of file PhotonEnergyCorrector.cc.

References edm::EventSetup::get(), EnergyUncertaintyPhotonSpecific::init(), EcalClusterFunctionBaseClass::init(), EGEnergyCorrector::Initialize(), EGEnergyCorrector::IsInitialized(), photonEcalEnergyCorrFunction_, photonUncertaintyCalculator_, regressionCorrector_, scCrackEnergyFunction_, scEnergyErrorFunction_, scEnergyFunction_, theCaloGeom_, w_db_, w_file_, and weightsfromDB_.

70  {
71  theEventSetup.get<CaloGeometryRecord>().get(theCaloGeom_);
72 
73 
74  scEnergyFunction_->init(theEventSetup);
75  scCrackEnergyFunction_->init(theEventSetup);
76  scEnergyErrorFunction_->init(theEventSetup);
77  photonEcalEnergyCorrFunction_->init(theEventSetup);
78 
79  if ( weightsfromDB_ ) {
81  }
82  if ( !weightsfromDB_ && !(w_file_ == "none") ) {
84  }
85 
86 
87  photonUncertaintyCalculator_->init(theEventSetup);
88 
89 
90 }
void Initialize(const edm::EventSetup &iSetup, std::string regweights, bool weightsFromDB=false)
EcalClusterFunctionBaseClass * scEnergyFunction_
edm::ESHandle< CaloGeometry > theCaloGeom_
EcalClusterFunctionBaseClass * photonEcalEnergyCorrFunction_
EGEnergyCorrector * regressionCorrector_
EcalClusterFunctionBaseClass * scEnergyErrorFunction_
EnergyUncertaintyPhotonSpecific * photonUncertaintyCalculator_
EcalClusterFunctionBaseClass * scCrackEnergyFunction_
const T & get() const
Definition: EventSetup.h:55
Bool_t IsInitialized() const
virtual void init(const edm::EventSetup &es)=0
void init(const edm::EventSetup &theEventSetup)

Member Data Documentation

edm::InputTag PhotonEnergyCorrector::barrelEcalHits_
private

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.

edm::InputTag PhotonEnergyCorrector::endcapEcalHits_
private

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().

EcalClusterFunctionBaseClass* PhotonEnergyCorrector::photonEcalEnergyCorrFunction_
private

Definition at line 48 of file PhotonEnergyCorrector.h.

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

EnergyUncertaintyPhotonSpecific* PhotonEnergyCorrector::photonUncertaintyCalculator_
private
EGEnergyCorrector* PhotonEnergyCorrector::regressionCorrector_
private
EcalClusterFunctionBaseClass* PhotonEnergyCorrector::scCrackEnergyFunction_
private

Definition at line 46 of file PhotonEnergyCorrector.h.

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

EcalClusterFunctionBaseClass* PhotonEnergyCorrector::scEnergyErrorFunction_
private

Definition at line 47 of file PhotonEnergyCorrector.h.

Referenced by init(), and PhotonEnergyCorrector().

EcalClusterFunctionBaseClass* PhotonEnergyCorrector::scEnergyFunction_
private

Definition at line 45 of file PhotonEnergyCorrector.h.

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

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

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().