CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
PhotonEnergyCalibratorRun2 Class Reference

#include <PhotonEnergyCalibratorRun2.h>

Public Member Functions

void calibrate (reco::Photon &photon, unsigned int runNumber, edm::StreamID const &id=edm::StreamID::invalidStreamID()) const
 
void calibrate (SimplePhoton &photon, 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() [1/2]

PhotonEnergyCalibratorRun2::PhotonEnergyCalibratorRun2 ( )
inline

Definition at line 14 of file PhotonEnergyCalibratorRun2.h.

14 {}

◆ PhotonEnergyCalibratorRun2() [2/2]

PhotonEnergyCalibratorRun2::PhotonEnergyCalibratorRun2 ( bool  isMC,
bool  synchronization,
std::string  correctionFile 
)

Definition at line 7 of file PhotonEnergyCalibratorRun2.cc.

8  : isMC_(isMC),
10  rng_(nullptr),
11  _correctionRetriever(correctionFile) // here is opening the files and reading thecorrections
12 {
13  if (isMC_) {
16  } else {
19  }
20 }

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

◆ ~PhotonEnergyCalibratorRun2()

PhotonEnergyCalibratorRun2::~PhotonEnergyCalibratorRun2 ( )

Definition at line 22 of file PhotonEnergyCalibratorRun2.cc.

22 {}

Member Function Documentation

◆ calibrate() [1/2]

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 26 of file PhotonEnergyCalibratorRun2.cc.

28  {
30  calibrate(simple, id);
31  simple.writeTo(photon);
32 }

References calibrate(), isMC_, muons2muons_cfi::photon, convertSQLiteXML::runNumber, and SimplePhoton::writeTo().

◆ calibrate() [2/2]

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 34 of file PhotonEnergyCalibratorRun2.cc.

34  {
35  assert(isMC_ == photon.isMC());
36  float smear = 0.0, scale = 1.0;
37  float aeta = std::abs(photon.getEta()); //, r9 = photon.getR9();
38  float et = photon.getNewEnergy() / cosh(aeta);
39 
40  scale = _correctionRetriever.ScaleCorrection(photon.getRunNumber(), photon.isEB(), photon.getR9(), aeta, et);
41  smear = _correctionRetriever.getSmearingSigma(photon.getRunNumber(), photon.isEB(), photon.getR9(), aeta, et, 0., 0.);
42 
43  double newEcalEnergy, newEcalEnergyError;
44  if (isMC_) {
45  double corr = 1.0 + smear * gauss(id);
46  newEcalEnergy = photon.getNewEnergy() * corr;
47  newEcalEnergyError = std::hypot(photon.getNewEnergyError() * corr, smear * newEcalEnergy);
48  } else {
49  newEcalEnergy = photon.getNewEnergy() * scale;
50  newEcalEnergyError = std::hypot(photon.getNewEnergyError() * scale, smear * newEcalEnergy);
51  }
52  photon.setNewEnergy(newEcalEnergy);
53  photon.setNewEnergyError(newEcalEnergyError);
54 }

References _correctionRetriever, funct::abs(), cms::cuda::assert(), alignCSCRings::corr, EgHLTOffHistBins_cfi::et, gauss(), EnergyScaleCorrection_class::getSmearingSigma(), isMC_, muons2muons_cfi::photon, HLT_FULL_cff::scale, and EnergyScaleCorrection_class::ScaleCorrection().

Referenced by calibrate().

◆ gauss()

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 56 of file PhotonEnergyCalibratorRun2.cc.

56  {
57  if (synchronization_)
58  return 1.0;
59  if (rng_) {
60  return rng_->Gaus();
61  } else {
63  if (!rng.isAvailable()) {
64  throw cms::Exception("Configuration")
65  << "XXXXXXX requires the RandomNumberGeneratorService\n"
66  "which is not present in the configuration file. You must add the service\n"
67  "in the configuration file or remove the modules that require it.";
68  }
69  CLHEP::RandGaussQ gaussDistribution(rng->getEngine(id), 0.0, 1.0);
70  return gaussDistribution.fire();
71  }
72 }

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

Referenced by calibrate().

◆ initPrivateRng()

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 24 of file PhotonEnergyCalibratorRun2.cc.

24 { rng_ = rnd; }

References rng_.

Referenced by CalibratedPhotonProducerRun2T< T >::CalibratedPhotonProducerRun2T().

Member Data Documentation

◆ _correctionRetriever

EnergyScaleCorrection_class PhotonEnergyCalibratorRun2::_correctionRetriever
protected

Definition at line 46 of file PhotonEnergyCalibratorRun2.h.

Referenced by calibrate(), and PhotonEnergyCalibratorRun2().

◆ isMC_

bool PhotonEnergyCalibratorRun2::isMC_
protected

Definition at line 37 of file PhotonEnergyCalibratorRun2.h.

Referenced by calibrate(), and PhotonEnergyCalibratorRun2().

◆ rng_

TRandom* PhotonEnergyCalibratorRun2::rng_
protected

Definition at line 38 of file PhotonEnergyCalibratorRun2.h.

Referenced by gauss(), and initPrivateRng().

◆ scales_

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

Definition at line 40 of file PhotonEnergyCalibratorRun2.h.

◆ smearings_

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

Definition at line 39 of file PhotonEnergyCalibratorRun2.h.

◆ synchronization_

bool PhotonEnergyCalibratorRun2::synchronization_
protected

Definition at line 37 of file PhotonEnergyCalibratorRun2.h.

Referenced by gauss().

PhotonEnergyCalibratorRun2::rng_
TRandom * rng_
Definition: PhotonEnergyCalibratorRun2.h:38
muons2muons_cfi.photon
photon
Definition: muons2muons_cfi.py:28
edm::RandomNumberGenerator::getEngine
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
HLT_FULL_cff.scale
scale
Definition: HLT_FULL_cff.py:6637
cms::cuda::assert
assert(be >=bs)
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
convertSQLiteXML.runNumber
runNumber
Definition: convertSQLiteXML.py:91
PhotonEnergyCalibratorRun2::isMC_
bool isMC_
Definition: PhotonEnergyCalibratorRun2.h:37
submitPVValidationJobs.isMC
list isMC
Definition: submitPVValidationJobs.py:658
calibratedElectronsRun2_cfi.correctionFile
correctionFile
Definition: calibratedElectronsRun2_cfi.py:21
PhotonEnergyCalibratorRun2::gauss
double gauss(edm::StreamID const &id) const
Definition: PhotonEnergyCalibratorRun2.cc:56
EnergyScaleCorrection_class::doSmearings
bool doSmearings
Definition: EnergyScaleCorrection_class.h:124
EnergyScaleCorrection_class::getSmearingSigma
float getSmearingSigma(int runNumber, bool isEBEle, float R9Ele, float etaSCEle, float EtEle, paramSmear_t par, float nSigma=0.) const
Definition: EnergyScaleCorrection_class.cc:336
alignCSCRings.corr
dictionary corr
Definition: alignCSCRings.py:124
EnergyScaleCorrection_class::doScale
bool doScale
Definition: EnergyScaleCorrection_class.h:124
calibratedElectrons_cfi.synchronization
synchronization
Definition: calibratedElectrons_cfi.py:33
EnergyScaleCorrection_class::ScaleCorrection
float ScaleCorrection(unsigned int runNumber, bool isEBEle, double R9Ele, double etaSCEle, double EtEle) const
method to get energy scale corrections
Definition: EnergyScaleCorrection_class.cc:44
PhotonEnergyCalibratorRun2::synchronization_
bool synchronization_
Definition: PhotonEnergyCalibratorRun2.h:37
edm::Service< edm::RandomNumberGenerator >
EgHLTOffHistBins_cfi.et
et
Definition: EgHLTOffHistBins_cfi.py:8
Exception
Definition: hltDiff.cc:246
SimplePhoton
Definition: SimplePhoton.h:8
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
PhotonEnergyCalibratorRun2::calibrate
void calibrate(SimplePhoton &photon, edm::StreamID const &id=edm::StreamID::invalidStreamID()) const
Definition: PhotonEnergyCalibratorRun2.cc:34
PhotonEnergyCalibratorRun2::_correctionRetriever
EnergyScaleCorrection_class _correctionRetriever
Definition: PhotonEnergyCalibratorRun2.h:46