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)
110 const bool isEB = ele.
isEB();
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;
123 eval[4] = full5x5_ess.e5x5 / 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;
167 eval[28] = raw_es_energy / rawEnergy;
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);
212 const double ecor =
mean * (rawEnergy + raw_es_energy);
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;
227 const float eOverP = (rawEnergy + raw_es_energy) *
mean / trkMomentum;
228 const float fbrem = ele.
fbrem();
235 rawPt = ecor / cosh(trkEta);
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)
303 const bool isEB = pho.
isEB();
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;
316 eval[4] = full5x5_pss.e5x5 / 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;
361 eval[28] = raw_es_energy / rawEnergy;
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);
406 const double ecor =
mean * (rawEnergy + raw_es_energy);
407 const double sigmacor = sigma * ecor;