CMS 3D CMS Logo

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

#include <ElectronEnergyCalibratorRun2.h>

Public Member Functions

void calibrate (reco::GsfElectron &electron, unsigned int runNumber, edm::StreamID const &id=edm::StreamID::invalidStreamID()) const
 
void calibrate (SimpleElectron &electron, edm::StreamID const &id=edm::StreamID::invalidStreamID()) const
 
 ElectronEnergyCalibratorRun2 ()
 
 ElectronEnergyCalibratorRun2 (EpCombinationTool &combinator, bool isMC, bool synchronization, std::string)
 
void initPrivateRng (TRandom *rnd)
 
 ~ElectronEnergyCalibratorRun2 ()
 

Protected Member Functions

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

Protected Attributes

EnergyScaleCorrection_class _correctionRetriever
 
EpCombinationToolepCombinationTool_
 
bool isMC_
 
TRandom * rng_
 
bool synchronization_
 

Detailed Description

Definition at line 12 of file ElectronEnergyCalibratorRun2.h.

Constructor & Destructor Documentation

◆ ElectronEnergyCalibratorRun2() [1/2]

ElectronEnergyCalibratorRun2::ElectronEnergyCalibratorRun2 ( )
inline

Definition at line 15 of file ElectronEnergyCalibratorRun2.h.

15 {}

◆ ElectronEnergyCalibratorRun2() [2/2]

ElectronEnergyCalibratorRun2::ElectronEnergyCalibratorRun2 ( EpCombinationTool combinator,
bool  isMC,
bool  synchronization,
std::string  correctionFile 
)

Definition at line 7 of file ElectronEnergyCalibratorRun2.cc.

11  : epCombinationTool_(&combinator),
12  isMC_(isMC),
14  rng_(nullptr),
15  _correctionRetriever(correctionFile) // here is opening the files and reading the corrections
16 {
17  if (isMC_) {
20  } else {
23  }
24 }

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

◆ ~ElectronEnergyCalibratorRun2()

ElectronEnergyCalibratorRun2::~ElectronEnergyCalibratorRun2 ( )

Definition at line 26 of file ElectronEnergyCalibratorRun2.cc.

26 {}

Member Function Documentation

◆ calibrate() [1/2]

void ElectronEnergyCalibratorRun2::calibrate ( reco::GsfElectron electron,
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 ElectronEnergyCalibratorRun2.cc.

32  {
34  calibrate(simple, id);
35  simple.writeTo(electron);
36 }

References calibrate(), metsig::electron, isMC_, convertSQLiteXML::runNumber, and SimpleElectron::writeTo().

◆ calibrate() [2/2]

void ElectronEnergyCalibratorRun2::calibrate ( SimpleElectron electron,
edm::StreamID const &  id = edm::StreamID::invalidStreamID() 
) const

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

Definition at line 37 of file ElectronEnergyCalibratorRun2.cc.

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

References _correctionRetriever, funct::abs(), cms::cuda::assert(), EpCombinationTool::combine(), alignCSCRings::corr, metsig::electron, epCombinationTool_, EgHLTOffHistBins_cfi::et, gauss(), EnergyScaleCorrection_class::getSmearingSigma(), isMC_, L1EGammaCrystalsEmulatorProducer_cfi::scale, and EnergyScaleCorrection_class::ScaleCorrection().

Referenced by calibrate().

◆ gauss()

double ElectronEnergyCalibratorRun2::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 61 of file ElectronEnergyCalibratorRun2.cc.

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

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

Referenced by calibrate().

◆ initPrivateRng()

void ElectronEnergyCalibratorRun2::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 28 of file ElectronEnergyCalibratorRun2.cc.

28 { rng_ = rnd; }

References rng_.

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

Member Data Documentation

◆ _correctionRetriever

EnergyScaleCorrection_class ElectronEnergyCalibratorRun2::_correctionRetriever
protected

Definition at line 45 of file ElectronEnergyCalibratorRun2.h.

Referenced by calibrate(), and ElectronEnergyCalibratorRun2().

◆ epCombinationTool_

EpCombinationTool* ElectronEnergyCalibratorRun2::epCombinationTool_
protected

Definition at line 37 of file ElectronEnergyCalibratorRun2.h.

Referenced by calibrate().

◆ isMC_

bool ElectronEnergyCalibratorRun2::isMC_
protected

Definition at line 38 of file ElectronEnergyCalibratorRun2.h.

Referenced by calibrate(), and ElectronEnergyCalibratorRun2().

◆ rng_

TRandom* ElectronEnergyCalibratorRun2::rng_
protected

Definition at line 39 of file ElectronEnergyCalibratorRun2.h.

Referenced by gauss(), and initPrivateRng().

◆ synchronization_

bool ElectronEnergyCalibratorRun2::synchronization_
protected

Definition at line 38 of file ElectronEnergyCalibratorRun2.h.

Referenced by gauss().

edm::RandomNumberGenerator::getEngine
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
ElectronEnergyCalibratorRun2::gauss
double gauss(edm::StreamID const &id) const
Definition: ElectronEnergyCalibratorRun2.cc:61
L1EGammaCrystalsEmulatorProducer_cfi.scale
scale
Definition: L1EGammaCrystalsEmulatorProducer_cfi.py:10
ElectronEnergyCalibratorRun2::_correctionRetriever
EnergyScaleCorrection_class _correctionRetriever
Definition: ElectronEnergyCalibratorRun2.h:45
cms::cuda::assert
assert(be >=bs)
ElectronEnergyCalibratorRun2::synchronization_
bool synchronization_
Definition: ElectronEnergyCalibratorRun2.h:38
EpCombinationTool::combine
void combine(SimpleElectron &mySimpleElectron) const
Definition: EpCombinationTool.cc:58
ElectronEnergyCalibratorRun2::rng_
TRandom * rng_
Definition: ElectronEnergyCalibratorRun2.h:39
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
convertSQLiteXML.runNumber
runNumber
Definition: convertSQLiteXML.py:91
SimpleElectron
Definition: SimpleElectron.h:8
submitPVValidationJobs.isMC
list isMC
Definition: submitPVValidationJobs.py:658
calibratedElectronsRun2_cfi.correctionFile
correctionFile
Definition: calibratedElectronsRun2_cfi.py:21
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
metsig::electron
Definition: SignAlgoResolutions.h:48
EnergyScaleCorrection_class::doScale
bool doScale
Definition: EnergyScaleCorrection_class.h:124
calibratedElectrons_cfi.synchronization
synchronization
Definition: calibratedElectrons_cfi.py:33
ElectronEnergyCalibratorRun2::epCombinationTool_
EpCombinationTool * epCombinationTool_
Definition: ElectronEnergyCalibratorRun2.h:37
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
ElectronEnergyCalibratorRun2::isMC_
bool isMC_
Definition: ElectronEnergyCalibratorRun2.h:38
ElectronEnergyCalibratorRun2::calibrate
void calibrate(SimpleElectron &electron, edm::StreamID const &id=edm::StreamID::invalidStreamID()) const
Definition: ElectronEnergyCalibratorRun2.cc:37
edm::Service< edm::RandomNumberGenerator >
EgHLTOffHistBins_cfi.et
et
Definition: EgHLTOffHistBins_cfi.py:8
Exception
Definition: hltDiff.cc:245
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22