test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
PhotonEnergyCalibratorRun2 Class Reference

#include <PhotonEnergyCalibratorRun2.h>

Public Member Functions

void calibrate (SimplePhoton &photon, edm::StreamID const &id=edm::StreamID::invalidStreamID()) const
 
void calibrate (reco::Photon &photon, unsigned int runNumber, edm::StreamID const &id=edm::StreamID::invalidStreamID()) const
 
void initPrivateRng (TRandom *rnd)
 
 PhotonEnergyCalibratorRun2 ()
 
 PhotonEnergyCalibratorRun2 (bool isMC, bool synchronization, std::string correctionFile)
 
 ~PhotonEnergyCalibratorRun2 ()
 

Protected Member Functions

double gauss (edm::StreamID const &id) const
 

Protected Attributes

EnergyScaleCorrection_class _correctionRetriever
 
bool isMC_
 
TRandom * rng_
 
std::vector< double > scales_
 
std::vector< double > smearings_
 
bool synchronization_
 

Detailed Description

Definition at line 11 of file PhotonEnergyCalibratorRun2.h.

Constructor & Destructor Documentation

PhotonEnergyCalibratorRun2::PhotonEnergyCalibratorRun2 ( )
inline

Definition at line 14 of file PhotonEnergyCalibratorRun2.h.

14 {}
PhotonEnergyCalibratorRun2::PhotonEnergyCalibratorRun2 ( bool  isMC,
bool  synchronization,
std::string  correctionFile 
)

Definition at line 7 of file PhotonEnergyCalibratorRun2.cc.

References _correctionRetriever, EnergyScaleCorrection_class::doScale, EnergyScaleCorrection_class::doSmearings, and isMC_.

9  :
10  isMC_(isMC), synchronization_(synchronization),
11  rng_(0),
12  _correctionRetriever(correctionFile) // here is opening the files and reading thecorrections
13 {
14  if(isMC_) {
17  } else {
20  }
21 }
EnergyScaleCorrection_class _correctionRetriever
PhotonEnergyCalibratorRun2::~PhotonEnergyCalibratorRun2 ( )

Definition at line 23 of file PhotonEnergyCalibratorRun2.cc.

24 {}

Member Function Documentation

void PhotonEnergyCalibratorRun2::calibrate ( SimplePhoton photon,
edm::StreamID const &  id = edm::StreamID::invalidStreamID() 
) const

Correct this electron. StreamID is needed when used with CMSSW Random Number Generator

Definition at line 36 of file PhotonEnergyCalibratorRun2.cc.

References _correctionRetriever, funct::abs(), assert(), corr, gauss(), SimplePhoton::getEta(), SimplePhoton::getNewEnergy(), SimplePhoton::getNewEnergyError(), SimplePhoton::getR9(), SimplePhoton::getRunNumber(), EnergyScaleCorrection_class::getSmearingSigma(), SimplePhoton::isEB(), SimplePhoton::isMC(), isMC_, pileupReCalc_HLTpaths::scale, EnergyScaleCorrection_class::ScaleCorrection(), SimplePhoton::setNewEnergy(), and SimplePhoton::setNewEnergyError().

Referenced by calibrate().

36  {
37  assert(isMC_ == photon.isMC());
38  float smear = 0.0, scale = 1.0;
39  float aeta = std::abs(photon.getEta()); //, r9 = photon.getR9();
40  float et = photon.getNewEnergy()/cosh(aeta);
41 
42  scale = _correctionRetriever.ScaleCorrection(photon.getRunNumber(), photon.isEB(), photon.getR9(), aeta, et);
43  smear = _correctionRetriever.getSmearingSigma(photon.getRunNumber(), photon.isEB(), photon.getR9(), aeta, et, 0., 0.);
44 
45  double newEcalEnergy, newEcalEnergyError;
46  if (isMC_) {
47  double corr = 1.0 + smear * gauss(id);
48  newEcalEnergy = photon.getNewEnergy() * corr;
49  newEcalEnergyError = std::hypot(photon.getNewEnergyError() * corr, smear * newEcalEnergy);
50  } else {
51  newEcalEnergy = photon.getNewEnergy() * scale;
52  newEcalEnergyError = std::hypot(photon.getNewEnergyError() * scale, smear * newEcalEnergy);
53  }
54  photon.setNewEnergy(newEcalEnergy);
55  photon.setNewEnergyError(newEcalEnergyError);
56 
57 }
float getR9() const
Definition: SimplePhoton.h:53
float getSmearingSigma(int runNumber, bool isEBEle, float R9Ele, float etaSCEle, float EtEle, paramSmear_t par, float nSigma=0.) const
double getNewEnergy() const
Definition: SimplePhoton.h:44
int getRunNumber() const
Definition: SimplePhoton.h:55
assert(m_qm.get())
void setNewEnergyError(double newEnergyError)
Definition: SimplePhoton.h:61
float ScaleCorrection(unsigned int runNumber, bool isEBEle, double R9Ele, double etaSCEle, double EtEle) const
method to get energy scale corrections
double getEta() const
Definition: SimplePhoton.h:52
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double getNewEnergyError() const
Definition: SimplePhoton.h:45
double gauss(edm::StreamID const &id) const
JetCorrectorParameters corr
Definition: classes.h:5
void setNewEnergy(double newEnergy)
Definition: SimplePhoton.h:60
bool isEB() const
Definition: SimplePhoton.h:56
bool isMC() const
Definition: SimplePhoton.h:57
EnergyScaleCorrection_class _correctionRetriever
void PhotonEnergyCalibratorRun2::calibrate ( reco::Photon photon,
unsigned int  runNumber,
edm::StreamID const &  id = edm::StreamID::invalidStreamID() 
) const

Correct this electron. StreamID is needed when used with CMSSW Random Number Generator

Definition at line 30 of file PhotonEnergyCalibratorRun2.cc.

References calibrate(), isMC_, PileupJetIDParams_cfi::simple, and SimplePhoton::writeTo().

30  {
32  calibrate(simple, id);
33  simple.writeTo(photon);
34 }
void calibrate(SimplePhoton &photon, edm::StreamID const &id=edm::StreamID::invalidStreamID()) const
double PhotonEnergyCalibratorRun2::gauss ( edm::StreamID const &  id) const
protected

Return a number distributed as a unit gaussian, drawn from the private RNG if initPrivateRng was called, or from the CMSSW RandomNumberGenerator service If synchronization is set to true, it returns a fixed number (1.0)

Definition at line 59 of file PhotonEnergyCalibratorRun2.cc.

References Exception, edm::RandomNumberGenerator::getEngine(), edm::Service< T >::isAvailable(), rng_, and synchronization_.

Referenced by calibrate().

59  {
60  if (synchronization_) return 1.0;
61  if (rng_) {
62  return rng_->Gaus();
63  } else {
65  if ( !rng.isAvailable() ) {
66  throw cms::Exception("Configuration")
67  << "XXXXXXX requires the RandomNumberGeneratorService\n"
68  "which is not present in the configuration file. You must add the service\n"
69  "in the configuration file or remove the modules that require it.";
70  }
71  CLHEP::RandGaussQ gaussDistribution(rng->getEngine(id), 0.0, 1.0);
72  return gaussDistribution.fire();
73  }
74 }
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
bool isAvailable() const
Definition: Service.h:46
void PhotonEnergyCalibratorRun2::initPrivateRng ( TRandom *  rnd)

Initialize with a random number generator (if not done, it will use the CMSSW service) Caller code owns the TRandom.

Definition at line 26 of file PhotonEnergyCalibratorRun2.cc.

References rng_.

26  {
27  rng_ = rnd;
28 }

Member Data Documentation

EnergyScaleCorrection_class PhotonEnergyCalibratorRun2::_correctionRetriever
protected

Definition at line 44 of file PhotonEnergyCalibratorRun2.h.

Referenced by calibrate(), and PhotonEnergyCalibratorRun2().

bool PhotonEnergyCalibratorRun2::isMC_
protected

Definition at line 35 of file PhotonEnergyCalibratorRun2.h.

Referenced by calibrate(), and PhotonEnergyCalibratorRun2().

TRandom* PhotonEnergyCalibratorRun2::rng_
protected

Definition at line 36 of file PhotonEnergyCalibratorRun2.h.

Referenced by gauss(), and initPrivateRng().

std::vector<double> PhotonEnergyCalibratorRun2::scales_
protected

Definition at line 38 of file PhotonEnergyCalibratorRun2.h.

std::vector<double> PhotonEnergyCalibratorRun2::smearings_
protected

Definition at line 37 of file PhotonEnergyCalibratorRun2.h.

bool PhotonEnergyCalibratorRun2::synchronization_
protected

Definition at line 35 of file PhotonEnergyCalibratorRun2.h.

Referenced by gauss().