7 #include <CLHEP/Random/RandGaussQ.h> 13 : correctionRetriever_(
correctionFile), rng_(nullptr), minEt_(1.0) {}
30 const float smearNrSigma,
33 const float et =
photon.getCorrectedEnergy(reco::Photon::P4type::regression2) / cosh(scEtaAbs);
36 std::array<float, EGEnergySysIndex::kNrSysErrs> retVal;
37 retVal.fill(
photon.getCorrectedEnergy(reco::Photon::P4type::regression2));
51 const DetId seedDetId =
photon.superCluster()->seed()->seed();
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);
112 const double oldEcalEnergyError =
photon.getCorrectedEnergyError(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();
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
EnergyScaleCorrection correctionRetriever_
MPlex< T, D1, D2, N > hypot(const MPlex< T, D1, D2, N > &a, const MPlex< T, D1, D2, N > &b)
float scaleErrSyst() const
void initPrivateRng(TRandom *rnd)
constexpr bool isNotFinite(T x)
std::vector< EcalRecHit >::const_iterator const_iterator
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
float scaleErrGain() const
float scaleErrStat() const
float scaleErr(const std::bitset< kErrNrBits > &uncBitMask) const
Abs< T >::type abs(const T &t)
static const EnergyScaleCorrection::ScaleCorrection defaultScaleCorr_
static const EnergyScaleCorrection::SmearCorrection defaultSmearCorr_
float sigma(const float et, const float nrSigmaRho=0., const float nrSigmaPhi=0.) const
const SmearCorrection * getSmearCorr(unsigned int runnr, double et, double eta, double r9, unsigned int gainSeed) const
const ScaleCorrection * getScaleCorr(unsigned int runnr, double et, double eta, double r9, unsigned int gainSeed) 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
double gauss(edm::StreamID const &id) const