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 (SimpleElectron &electron, edm::StreamID const &id=edm::StreamID::invalidStreamID()) const
 
void calibrate (reco::GsfElectron &electron, unsigned int runNumber, 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 13 of file ElectronEnergyCalibratorRun2.h.

Constructor & Destructor Documentation

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

Definition at line 26 of file ElectronEnergyCalibratorRun2.cc.

Referenced by ElectronEnergyCalibratorRun2().

27 {}

Member Function Documentation

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 40 of file ElectronEnergyCalibratorRun2.cc.

References _correctionRetriever, funct::abs(), EpCombinationTool::combine(), corr, epCombinationTool_, stringResolutionProvider_cfi::et, gauss(), SimpleElectron::getEta(), SimpleElectron::getNewEnergy(), SimpleElectron::getNewEnergyError(), SimpleElectron::getR9(), SimpleElectron::getRunNumber(), EnergyScaleCorrection_class::getSmearingSigma(), SimpleElectron::isEB(), SimpleElectron::isMC(), isMC_, Scenarios_cff::scale, EnergyScaleCorrection_class::ScaleCorrection(), SimpleElectron::setNewEnergy(), and SimpleElectron::setNewEnergyError().

Referenced by calibrate(), ElectronEnergyCalibratorRun2(), and CalibratedElectronProducerRun2T< T >::produce().

41 {
42  assert(isMC_ == electron.isMC());
43  float smear = 0.0, scale = 1.0;
44  float aeta = std::abs(electron.getEta()); //, r9 = electron.getR9();
45  float et = electron.getNewEnergy()/cosh(aeta);
46 
47  scale = _correctionRetriever.ScaleCorrection(electron.getRunNumber(), electron.isEB(), electron.getR9(), aeta, et);
48  smear = _correctionRetriever.getSmearingSigma(electron.getRunNumber(), electron.isEB(), electron.getR9(), aeta, et, 0., 0.);
49 
50  double newEcalEnergy, newEcalEnergyError;
51  if (isMC_) {
52  double corr = 1.0 + smear * gauss(id);
53  newEcalEnergy = electron.getNewEnergy() * corr;
54  newEcalEnergyError = std::hypot(electron.getNewEnergyError() * corr, smear * newEcalEnergy);
55  } else {
56  newEcalEnergy = electron.getNewEnergy() * scale;
57  newEcalEnergyError = std::hypot(electron.getNewEnergyError() * scale, smear * newEcalEnergy);
58  }
59  electron.setNewEnergy(newEcalEnergy);
60  electron.setNewEnergyError(newEcalEnergyError);
61  epCombinationTool_->combine(electron);
62 }
float getSmearingSigma(int runNumber, bool isEBEle, float R9Ele, float etaSCEle, float EtEle, paramSmear_t par, float nSigma=0.) const
void setNewEnergyError(double newEnergyError)
void setNewEnergy(double newEnergy)
void combine(SimpleElectron &mySimpleElectron) const
double gauss(edm::StreamID const &id) const
float ScaleCorrection(unsigned int runNumber, bool isEBEle, double R9Ele, double etaSCEle, double EtEle) const
method to get energy scale corrections
double getNewEnergy() const
bool isMC() const
unsigned int getRunNumber() const
double getNewEnergyError() const
EnergyScaleCorrection_class _correctionRetriever
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double getEta() const
float getR9() const
JetCorrectorParameters corr
Definition: classes.h:5
et
define resolution functions of each parameter
bool isEB() const
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 34 of file ElectronEnergyCalibratorRun2.cc.

References calibrate(), isMC_, and SimpleElectron::writeTo().

35 {
36  SimpleElectron simple(electron, runNumber, isMC_);
37  calibrate(simple, id);
38  simple.writeTo(electron);
39 }
void calibrate(SimpleElectron &electron, edm::StreamID const &id=edm::StreamID::invalidStreamID()) const
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 64 of file ElectronEnergyCalibratorRun2.cc.

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

Referenced by calibrate().

65 {
66  if (synchronization_) return 1.0;
67  if (rng_) {
68  return rng_->Gaus();
69  } else {
71  if ( !rng.isAvailable() ) {
72  throw cms::Exception("Configuration")
73  << "XXXXXXX requires the RandomNumberGeneratorService\n"
74  "which is not present in the configuration file. You must add the service\n"
75  "in the configuration file or remove the modules that require it.";
76  }
77  CLHEP::RandGaussQ gaussDistribution(rng->getEngine(id), 0.0, 1.0);
78  return gaussDistribution.fire();
79  }
80 }
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
bool isAvailable() const
Definition: Service.h:46
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 29 of file ElectronEnergyCalibratorRun2.cc.

References rng_.

Referenced by CalibratedElectronProducerRun2T< T >::CalibratedElectronProducerRun2T(), and ElectronEnergyCalibratorRun2().

30 {
31  rng_ = rnd;
32 }

Member Data Documentation

EnergyScaleCorrection_class ElectronEnergyCalibratorRun2::_correctionRetriever
protected

Definition at line 44 of file ElectronEnergyCalibratorRun2.h.

Referenced by calibrate(), and ElectronEnergyCalibratorRun2().

EpCombinationTool* ElectronEnergyCalibratorRun2::epCombinationTool_
protected

Definition at line 36 of file ElectronEnergyCalibratorRun2.h.

Referenced by calibrate().

bool ElectronEnergyCalibratorRun2::isMC_
protected

Definition at line 37 of file ElectronEnergyCalibratorRun2.h.

Referenced by calibrate(), and ElectronEnergyCalibratorRun2().

TRandom* ElectronEnergyCalibratorRun2::rng_
protected

Definition at line 38 of file ElectronEnergyCalibratorRun2.h.

Referenced by gauss(), and initPrivateRng().

bool ElectronEnergyCalibratorRun2::synchronization_
protected

Definition at line 37 of file ElectronEnergyCalibratorRun2.h.

Referenced by gauss().