7 #include <CLHEP/Random/RandGaussQ.h> 13 : correctionRetriever_(correctionFile), rng_(
nullptr), minEt_(1.0) {}
23 return calibrate(photon, runNumber, recHits,
gauss(
id), eventType);
30 const float smearNrSigma,
36 std::array<float, EGEnergySysIndex::kNrSysErrs> retVal;
53 unsigned int gainSeedSC = 12;
54 if (seedRecHit != recHits->
end()) {
65 if (scaleCorr ==
nullptr)
67 if (smearCorr ==
nullptr)
70 std::array<float, EGEnergySysIndex::kNrSysErrs> uncertainties{};
91 const float smearNrSigma,
96 std::array<float, EGEnergySysIndex::kNrSysErrs>& energyData)
const {
97 const float smear = smearCorr.
sigma(et);
98 const float smearRhoUp = smearCorr.
sigma(et, 1, 0);
99 const float smearRhoDn = smearCorr.
sigma(et, -1, 0);
100 const float smearPhiUp = smearCorr.
sigma(et, 0, 1);
101 const float smearPhiDn = smearCorr.
sigma(et, 0, -1);
103 const float corr = scale + smear * smearNrSigma;
104 const float corrRhoUp = scale + smearRhoUp * smearNrSigma;
105 const float corrRhoDn = scale + smearRhoDn * smearNrSigma;
106 const float corrPhiUp = scale + smearPhiUp * smearNrSigma;
107 const float corrPhiDn = scale + smearPhiDn * smearNrSigma;
108 const float corrUp = corrRhoUp;
109 const float corrDn = corrRhoDn;
111 const double oldEcalEnergy = photon.
getCorrectedEnergy(reco::Photon::P4type::regression2);
117 const double newEcalEnergy = oldEcalEnergy *
corr;
118 const double newEcalEnergyError = std::hypot(oldEcalEnergyError * corr, smear * newEcalEnergy);
119 photon.
setCorrectedEnergy(reco::Photon::P4type::regression2, newEcalEnergy, newEcalEnergyError,
true);
151 <<
"XXXXXXX requires the RandomNumberGeneratorService\n" 152 "which is not present in the configuration file. You must add the service\n" 153 "in the configuration file or remove the modules that require it.";
155 CLHEP::RandGaussQ gaussDistribution(rng->
getEngine(
id), 0.0, 1.0);
156 return gaussDistribution.fire();
EnergyScaleCorrection correctionRetriever_
void initPrivateRng(TRandom *rnd)
void setCorrectedEnergy(P4type type, float E, float dE, bool toCand=true)
constexpr bool isNotFinite(T x)
std::vector< EcalRecHit >::const_iterator const_iterator
reco::SuperClusterRef superCluster() const override
Ref to SuperCluster.
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
float scaleErrGain() const
const ScaleCorrection * getScaleCorr(unsigned int runnr, double et, double eta, double r9, unsigned int gainSeed) const
Abs< T >::type abs(const T &t)
const SmearCorrection * getSmearCorr(unsigned int runnr, double et, double eta, double r9, unsigned int gainSeed) const
static const EnergyScaleCorrection::ScaleCorrection defaultScaleCorr_
static const EnergyScaleCorrection::SmearCorrection defaultSmearCorr_
float getCorrectedEnergyError(P4type type) const
float scaleErr(const std::bitset< kErrNrBits > &uncBitMask) const
float sigma(const float et, const float nrSigmaRho=0., const float nrSigmaPhi=0.) const
const_iterator end() const
float getCorrectedEnergy(P4type type) const
double gauss(edm::StreamID const &id) const
iterator find(key_type k)
float scaleErrSyst() const
void setEnergyAndSystVarations(const float scale, const float smearNrSigma, const float et, const EnergyScaleCorrection::ScaleCorrection &scaleCorr, const EnergyScaleCorrection::SmearCorrection &smearCorr, reco::Photon &photon, std::array< float, EGEnergySysIndex::kNrSysErrs > &energyData) const
float scaleErrStat() const
std::array< float, EGEnergySysIndex::kNrSysErrs > calibrate(reco::Photon &photon, const unsigned int runNumber, const EcalRecHitCollection *recHits, edm::StreamID const &id, const EventType eventType) const