16 #include <vdt/vdtMath.h>
63 eleCond50nsTokens_{conf.
getParameterSet(
"electron_config"),
"regressionKey_50ns",
"uncertaintyKey_50ns",
cc},
64 phoCond50nsTokens_{conf.getParameterSet(
"photon_config"),
"regressionKey_50ns",
"uncertaintyKey_50ns",
cc},
65 eleCond25nsTokens_{conf.getParameterSet(
"electron_config"),
"regressionKey_25ns",
"uncertaintyKey_25ns",
cc},
66 phoCond25nsTokens_{conf.getParameterSet(
"photon_config"),
"regressionKey_25ns",
"uncertaintyKey_25ns",
cc},
67 autoDetectBunchSpacing_(conf.getParameter<
bool>(
"autoDetectBunchSpacing")),
68 bunchspacing_(autoDetectBunchSpacing_ ? 450 : conf.getParameter<
int>(
"manualBunchSpacing")),
69 rhoToken_(
cc.consumes(conf.getParameter<
edm::InputTag>(
"rhoCollection"))),
70 vtxToken_(
cc.consumes(conf.getParameter<
edm::InputTag>(
"vertexCollection"))),
71 caloGeomToken_{
cc.esConsumes()},
72 applyExtraHighEnergyProtection_(conf.getParameter<
bool>(
"applyExtraHighEnergyProtection")) {
73 if (autoDetectBunchSpacing_)
74 bunchSpacingToken_ =
cc.consumes(conf.getParameter<
edm::InputTag>(
"bunchSpacingTag"));
76 auto const&
electrons = conf.getParameterSet(
"electron_config");
108 const int numberOfClusters = superClus->clusters().size();
109 const bool missing_clusters = !superClus->clusters()[numberOfClusters - 1].
isAvailable();
111 if (missing_clusters)
114 std::array<float, 33> eval;
115 const double rawEnergy = superClus->rawEnergy();
121 eval[2] = superClus->eta();
122 eval[3] = superClus->phi();
123 eval[4] = superClus->etaWidth();
124 eval[5] = superClus->phiWidth();
126 eval[7] = theseed->
energy() / rawEnergy;
127 eval[8] = ess.eMax / rawEnergy;
128 eval[9] = ess.e2nd / rawEnergy;
129 eval[10] = (ess.eLeft + ess.eRight != 0.f ? (ess.eLeft - ess.eRight) / (ess.eLeft + ess.eRight) : 0.f);
130 eval[11] = (ess.eTop + ess.eBottom != 0.f ? (ess.eTop - ess.eBottom) / (ess.eTop + ess.eBottom) : 0.f);
131 eval[12] = ess.sigmaIetaIeta;
132 eval[13] = ess.sigmaIetaIphi;
133 eval[14] = ess.sigmaIphiIphi;
134 eval[15] =
std::max(0, numberOfClusters - 1);
137 std::vector<float> clusterRawEnergy;
138 clusterRawEnergy.resize(
std::max(3, numberOfClusters), 0);
139 std::vector<float> clusterDEtaToSeed;
140 clusterDEtaToSeed.resize(
std::max(3, numberOfClusters), 0);
141 std::vector<float> clusterDPhiToSeed;
142 clusterDPhiToSeed.resize(
std::max(3, numberOfClusters), 0);
143 float clusterMaxDR = 999.;
144 float clusterMaxDRDPhi = 999.;
145 float clusterMaxDRDEta = 999.;
146 float clusterMaxDRRawEnergy = 0.;
151 for (
auto const& pclus : superClus->clusters()) {
152 if (theseed == pclus)
154 clusterRawEnergy[iclus] = pclus->energy();
156 clusterDEtaToSeed[iclus] = pclus->eta() - theseed->
eta();
160 if (the_dr >
maxDR) {
162 clusterMaxDR =
maxDR;
163 clusterMaxDRDPhi = clusterDPhiToSeed[iclus];
164 clusterMaxDRDEta = clusterDEtaToSeed[iclus];
165 clusterMaxDRRawEnergy = clusterRawEnergy[iclus];
170 eval[16] = clusterMaxDR;
171 eval[17] = clusterMaxDRDPhi;
172 eval[18] = clusterMaxDRDEta;
173 eval[19] = clusterMaxDRRawEnergy / rawEnergy;
174 eval[20] = clusterRawEnergy[0] / rawEnergy;
175 eval[21] = clusterRawEnergy[1] / rawEnergy;
176 eval[22] = clusterRawEnergy[2] / rawEnergy;
177 eval[23] = clusterDPhiToSeed[0];
178 eval[24] = clusterDPhiToSeed[1];
179 eval[25] = clusterDPhiToSeed[2];
180 eval[26] = clusterDEtaToSeed[0];
181 eval[27] = clusterDEtaToSeed[1];
182 eval[28] = clusterDEtaToSeed[2];
185 const bool isEB = ele.
isEB();
202 eval[29] = superClus->preshowerEnergy() / superClus->rawEnergy();
207 constexpr
double meanlimlow = 0.2;
208 constexpr
double meanlimhigh = 2.0;
209 constexpr
double meanoffset = meanlimlow + 0.5 * (meanlimhigh - meanlimlow);
210 constexpr
double meanscale = 0.5 * (meanlimhigh - meanlimlow);
212 constexpr
double sigmalimlow = 0.0002;
213 constexpr
double sigmalimhigh = 0.5;
214 constexpr
double sigmaoffset = sigmalimlow + 0.5 * (sigmalimhigh - sigmalimlow);
215 constexpr
double sigmascale = 0.5 * (sigmalimhigh - sigmalimlow);
217 const int coridx = isEB ? 0 : 1;
224 double mean = meanoffset + meanscale * vdt::fast_sin(rawmean);
225 double sigma = sigmaoffset + sigmascale * vdt::fast_sin(rawsigma);
229 double ecor =
mean * (eval[1]);
231 ecor =
mean * (eval[1] + superClus->preshowerEnergy());
232 const double sigmacor = sigma * ecor;
238 std::array<float, 11> eval_ep;
241 const float tot_energy = superClus->rawEnergy() + superClus->preshowerEnergy();
245 eval_ep[0] = tot_energy *
mean;
246 eval_ep[1] = sigma /
mean;
248 eval_ep[3] = trkMomentumRelError;
249 eval_ep[4] = sigma /
mean / trkMomentumRelError;
250 eval_ep[5] = tot_energy *
mean /
ep;
251 eval_ep[6] = tot_energy *
mean /
ep *
sqrt(sigma /
mean * sigma /
mean + trkMomentumRelError * trkMomentumRelError);
277 oldMomentum.y() * combinedMomentum / oldMomentum.t(),
278 oldMomentum.z() * combinedMomentum / oldMomentum.t(),
287 std::array<float, 35> eval;
291 const int numberOfClusters = superClus->clusters().size();
292 const bool missing_clusters = !superClus->clusters()[numberOfClusters - 1].
isAvailable();
294 if (missing_clusters)
297 const double rawEnergy = superClus->rawEnergy();
303 eval[2] = superClus->etaWidth();
304 eval[3] = superClus->phiWidth();
305 eval[4] =
std::max(0, numberOfClusters - 1);
309 eval[8] = theseed->
eta() - superClus->position().Eta();
311 eval[10] = theseed->
energy() / rawEnergy;
312 eval[11] = ess.e3x3 / ess.e5x5;
313 eval[12] = ess.sigmaIetaIeta;
314 eval[13] = ess.sigmaIphiIphi;
315 eval[14] = ess.sigmaIetaIphi / (ess.sigmaIphiIphi * ess.sigmaIetaIeta);
316 eval[15] = ess.maxEnergyXtal / ess.e5x5;
317 eval[16] = ess.e2nd / ess.e5x5;
318 eval[17] = ess.eTop / ess.e5x5;
319 eval[18] = ess.eBottom / ess.e5x5;
320 eval[19] = ess.eLeft / ess.e5x5;
321 eval[20] = ess.eRight / ess.e5x5;
322 eval[21] = ess.e2x5Max / ess.e5x5;
323 eval[22] = ess.e2x5Left / ess.e5x5;
324 eval[23] = ess.e2x5Right / ess.e5x5;
325 eval[24] = ess.e2x5Top / ess.e5x5;
326 eval[25] = ess.e2x5Bottom / ess.e5x5;
328 const bool isEB = pho.
isEB();
332 int ieta = ebseedid.ieta();
333 int iphi = ebseedid.iphi();
336 int signieta =
ieta > 0 ? +1 : -1;
337 eval[29] = (
ieta - signieta) % 5;
338 eval[30] = (
iphi - 1) % 2;
340 eval[32] = (
iphi - 1) % 20;
345 eval[26] = superClus->preshowerEnergy() / rawEnergy;
346 eval[27] = superClus->preshowerEnergyPlane1() / rawEnergy;
347 eval[28] = superClus->preshowerEnergyPlane2() / rawEnergy;
348 eval[29] = eeseedid.ix();
349 eval[30] = eeseedid.iy();
354 const double meanlimlow = 0.2;
355 const double meanlimhigh = 2.0;
356 const double meanoffset = meanlimlow + 0.5 * (meanlimhigh - meanlimlow);
357 const double meanscale = 0.5 * (meanlimhigh - meanlimlow);
359 const double sigmalimlow = 0.0002;
360 const double sigmalimhigh = 0.5;
361 const double sigmaoffset = sigmalimlow + 0.5 * (sigmalimhigh - sigmalimlow);
362 const double sigmascale = 0.5 * (sigmalimhigh - sigmalimlow);
364 const int coridx = isEB ? 0 : 1;
367 const double rawmean =
phoForestsMean_[coridx]->GetResponse(eval.data());
370 const double mean = meanoffset + meanscale * vdt::fast_sin(rawmean);
371 const double sigma = sigmaoffset + sigmascale * vdt::fast_sin(rawsigma);
375 const double ecor = isEB ?
mean * eval[0] :
mean * (eval[0] + superClus->preshowerEnergy());
377 const double sigmacor = sigma * ecor;