14 #include <vdt/vdtMath.h> 57 eleCondTokens_{conf.
getParameterSet(
"electron_config"),
"regressionKey",
"uncertaintyKey",
cc},
58 phoCondTokens_{conf.getParameterSet(
"photon_config"),
"regressionKey",
"uncertaintyKey",
cc},
60 rhoToken_(
cc.consumes(conf.getParameter<
edm::InputTag>(
"rhoCollection"))),
61 caloGeometryToken_(
cc.esConsumes()),
62 lowEnergyEcalOnlyThr_(conf.getParameter<
double>(
"lowEnergy_ECALonlyThr")),
63 lowEnergyEcalTrackThr_(conf.getParameter<
double>(
"lowEnergy_ECALTRKThr")),
64 highEnergyEcalTrackThr_(conf.getParameter<
double>(
"highEnergy_ECALTRKThr")),
65 eOverPEcalTrkThr_(conf.getParameter<
double>(
"eOverP_ECALTRKThr")),
66 epDiffSigEcalTrackThr_(conf.getParameter<
double>(
"epDiffSig_ECALTRKThr")),
67 epSigEcalTrackThr_(conf.getParameter<
double>(
"epSig_ECALTRKThr")),
68 forceHighEnergyEcalTrainingIfSaturated_(conf.getParameter<
bool>(
"forceHighEnergyEcalTrainingIfSaturated")) {
69 unsigned int encor = eleCondTokens_.mean.size();
70 eleForestsMean_.reserve(2 * encor);
71 eleForestsSigma_.reserve(2 * encor);
73 unsigned int ncor = phoCondTokens_.mean.size();
74 phoForestsMean_.reserve(ncor);
75 phoForestsSigma_.reserve(ncor);
100 const int numberOfClusters = superClus->clusters().size();
101 const bool missing_clusters = !superClus->clusters()[numberOfClusters - 1].
isAvailable();
102 if (missing_clusters)
112 std::array<float, 32> eval;
113 const double rawEnergy = superClus->rawEnergy();
114 const double raw_es_energy = superClus->preshowerEnergy();
117 float e5x5Inverse = full5x5_ess.
e5x5 != 0. ? vdt::fast_inv(full5x5_ess.e5x5) : 0.;
120 eval[1] = superClus->etaWidth();
121 eval[2] = superClus->phiWidth();
122 eval[3] = superClus->seed()->energy() /
rawEnergy;
126 eval[7] =
seed->eta() - superClus->position().Eta();
128 eval[9] = full5x5_ess.r9;
129 eval[10] = full5x5_ess.sigmaIetaIeta;
130 eval[11] = full5x5_ess.sigmaIetaIphi;
131 eval[12] = full5x5_ess.sigmaIphiIphi;
132 eval[13] = full5x5_ess.eMax * e5x5Inverse;
133 eval[14] = full5x5_ess.e2nd * e5x5Inverse;
134 eval[15] = full5x5_ess.eTop * e5x5Inverse;
135 eval[16] = full5x5_ess.eBottom * e5x5Inverse;
136 eval[17] = full5x5_ess.eLeft * e5x5Inverse;
137 eval[18] = full5x5_ess.eRight * e5x5Inverse;
138 eval[19] = full5x5_ess.e2x5Max * e5x5Inverse;
139 eval[20] = full5x5_ess.e2x5Left * e5x5Inverse;
140 eval[21] = full5x5_ess.e2x5Right * e5x5Inverse;
141 eval[22] = full5x5_ess.e2x5Top * e5x5Inverse;
142 eval[23] = full5x5_ess.e2x5Bottom * e5x5Inverse;
144 eval[25] =
std::max(0, numberOfClusters);
154 int signieta =
ieta > 0 ? +1 : -1;
155 eval[28] = (
ieta - signieta) % 5;
156 eval[29] = (
iphi - 1) % 2;
158 eval[31] = (
iphi - 1) % 20;
172 constexpr
double meanlimlow = -1.0;
173 constexpr
double meanlimhigh = 3.0;
174 constexpr
double meanoffset = meanlimlow + 0.5 * (meanlimhigh - meanlimlow);
175 constexpr
double meanscale = 0.5 * (meanlimhigh - meanlimlow);
177 constexpr
double sigmalimlow = 0.0002;
178 constexpr
double sigmalimhigh = 0.5;
179 constexpr
double sigmaoffset = sigmalimlow + 0.5 * (sigmalimhigh - sigmalimlow);
180 constexpr
double sigmascale = 0.5 * (sigmalimhigh - sigmalimlow);
183 float rawPt =
rawEnergy * superClus->position().rho() / superClus->position().r();
203 double mean = meanoffset + meanscale * vdt::fast_sin(rawmean);
204 double sigma = sigmaoffset + sigmascale * vdt::fast_sin(rawsigma);
213 const double sigmacor = sigma * ecor;
218 double combinedEnergy = ecor;
219 double combinedEnergyError = sigmacor;
222 const float trkMomentum = el_track->pMode();
223 const float trkEta = el_track->etaMode();
224 const float trkPhi = el_track->phiMode();
225 const float trkMomentumError =
std::abs(el_track->qoverpModeError()) * trkMomentum * trkMomentum;
246 eval[1] = sigma /
mean;
247 eval[2] = trkMomentumError / trkMomentum;
250 eval[5] = full5x5_ess.r9;
255 float ecalEnergyVar = (
rawEnergy + raw_es_energy) * sigma;
256 float rawcombNormalization = (trkMomentumError * trkMomentumError + ecalEnergyVar * ecalEnergyVar);
257 float rawcomb = (ecor * trkMomentumError * trkMomentumError + trkMomentum * ecalEnergyVar * ecalEnergyVar) /
258 rawcombNormalization;
261 double rawmean_trk =
eleForestsMean_[coridx]->GetResponse(eval.data());
265 double mean_trk = meanoffset + meanscale * vdt::fast_sin(rawmean_trk);
266 double sigma_trk = sigmaoffset + sigmascale * vdt::fast_sin(rawsigma_trk);
275 combinedEnergy = mean_trk * rawcomb;
276 combinedEnergyError = sigma_trk * rawcomb;
281 oldFourMomentum.y() * combinedEnergy / oldFourMomentum.t(),
282 oldFourMomentum.z() * combinedEnergy / oldFourMomentum.t(),
298 const int numberOfClusters = superClus->clusters().size();
299 const bool missing_clusters = !superClus->clusters()[numberOfClusters - 1].
isAvailable();
300 if (missing_clusters)
305 std::array<float, 32> eval;
306 const double rawEnergy = superClus->rawEnergy();
307 const double raw_es_energy = superClus->preshowerEnergy();
310 float e5x5Inverse = full5x5_pss.
e5x5 != 0. ? vdt::fast_inv(full5x5_pss.e5x5) : 0.;
313 eval[1] = superClus->etaWidth();
314 eval[2] = superClus->phiWidth();
315 eval[3] = superClus->seed()->energy() /
rawEnergy;
319 eval[7] =
seed->eta() - superClus->position().Eta();
322 eval[10] = full5x5_pss.sigmaIetaIeta;
323 eval[11] = full5x5_pss.sigmaIetaIphi;
324 eval[12] = full5x5_pss.sigmaIphiIphi;
325 eval[13] = full5x5_pss.maxEnergyXtal * e5x5Inverse;
326 eval[14] = full5x5_pss.e2nd * e5x5Inverse;
327 eval[15] = full5x5_pss.eTop * e5x5Inverse;
328 eval[16] = full5x5_pss.eBottom * e5x5Inverse;
329 eval[17] = full5x5_pss.eLeft * e5x5Inverse;
330 eval[18] = full5x5_pss.eRight * e5x5Inverse;
331 eval[19] = full5x5_pss.e2x5Max * e5x5Inverse;
332 eval[20] = full5x5_pss.e2x5Left * e5x5Inverse;
333 eval[21] = full5x5_pss.e2x5Right * e5x5Inverse;
334 eval[22] = full5x5_pss.e2x5Top * e5x5Inverse;
335 eval[23] = full5x5_pss.e2x5Bottom * e5x5Inverse;
337 eval[25] =
std::max(0, numberOfClusters);
348 int signieta =
ieta > 0 ? +1 : -1;
349 eval[28] = (
ieta - signieta) % 5;
350 eval[29] = (
iphi - 1) % 2;
352 eval[31] = (
iphi - 1) % 20;
366 constexpr
double meanlimlow = -1.0;
367 constexpr
double meanlimhigh = 3.0;
368 constexpr
double meanoffset = meanlimlow + 0.5 * (meanlimhigh - meanlimlow);
369 constexpr
double meanscale = 0.5 * (meanlimhigh - meanlimlow);
371 constexpr
double sigmalimlow = 0.0002;
372 constexpr
double sigmalimhigh = 0.5;
373 constexpr
double sigmaoffset = sigmalimlow + 0.5 * (sigmalimhigh - sigmalimlow);
374 constexpr
double sigmascale = 0.5 * (sigmalimhigh - sigmalimlow);
377 float rawPt =
rawEnergy * superClus->position().rho() / superClus->position().r();
397 double mean = meanoffset + meanscale * vdt::fast_sin(rawmean);
398 double sigma = sigmaoffset + sigmascale * vdt::fast_sin(rawsigma);
407 const double sigmacor = sigma * ecor;
constexpr double deltaPhi(double phi1, double phi2)
Analysis-level Photon class.
const double lowEnergyEcalOnlyThr_
void setEventContent(const edm::EventSetup &) final
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
std::vector< edm::ESGetToken< GBRForestD, GBRDWrapperRcd > > mean
bool ecalDrivenSeed() const
bool get(ProductID const &oid, Handle< PROD > &result) const
void modifyObject(pat::Photon &pho) const final
void setCorrectedEnergy(P4type type, float E, float dE, bool toCand=true)
const ShowerShape & full5x5_showerShapeVariables() const
const double epSigEcalTrackThr_
uint32_t cc[maxCellsPerHit]
float trackMomentumError() const
void correctMomentum(const LorentzVector &p4, float trackMomentumError, float p4Error)
ParameterSet const & getParameterSet(std::string const &) const
CaloGeometry const * caloGeometry_
void modifyObject(pat::Electron &ele) const final
EGRegressionModifierCondTokens eleCondTokens_
float hcalOverEcalBc(const ShowerShape &ss, int depth) const
void setEvent(const edm::Event &) final
float nSaturatedXtals() const
std::vector< const GBRForestD * > phoForestsSigma_
const edm::EDGetTokenT< double > rhoToken_
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
void setCorrectedEcalEnergyError(float newEnergyError)
const ShowerShape & full5x5_showerShape() const
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometryToken_
reco::SuperClusterRef superCluster() const override
Ref to SuperCluster.
Abs< T >::type abs(const T &t)
const double eOverPEcalTrkThr_
std::vector< const GBRForestD * > phoForestsMean_
const LorentzVector & p4(P4Kind kind) const
const double highEnergyEcalTrackThr_
float hadronicOverEm(int depth=0) const
EGRegressionModifierV2(const edm::ParameterSet &conf, edm::ConsumesCollector &cc)
const bool forceHighEnergyEcalTrainingIfSaturated_
EGRegressionModifierCondTokens phoCondTokens_
const double lowEnergyEcalTrackThr_
Analysis-level electron class.
void modifyObject(reco::GsfElectron &) const final
std::vector< edm::ESGetToken< GBRForestD, GBRDWrapperRcd > > sigma
std::vector< const GBRForestD * > retrieveGBRForests(edm::EventSetup const &evs, std::vector< edm::ESGetToken< GBRForestD, GBRDWrapperRcd >> const &tokens)
void setCorrectedEcalEnergy(float newEnergy)
bool isSaturated(const Digi &digi, const int &maxADCvalue, int ifirst, int n)
const double epDiffSigEcalTrackThr_
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::vector< const GBRForestD * > eleForestsMean_
std::vector< const GBRForestD * > eleForestsSigma_
SuperClusterRef superCluster() const override
reference to a SuperCluster
float nSaturatedXtals() const