16 #include <vdt/vdtMath.h>
68 autoDetectBunchSpacing_(conf.getParameter<
bool>(
"autoDetectBunchSpacing")),
69 bunchspacing_(autoDetectBunchSpacing_ ? 450 : conf.getParameter<
int>(
"manualBunchSpacing")),
70 rhoToken_(
cc.consumes<double>(conf.getParameter<
edm::
InputTag>(
"rhoCollection"))),
72 applyExtraHighEnergyProtection_(conf.getParameter<
bool>(
"applyExtraHighEnergyProtection")) {
78 .sigma50ns =
electrons.getParameter<std::vector<std::string>>(
"uncertaintyKey_50ns"),
79 .mean25ns =
electrons.getParameter<std::vector<std::string>>(
"regressionKey_25ns"),
80 .sigma25ns =
electrons.getParameter<std::vector<std::string>>(
"uncertaintyKey_25ns")};
86 .sigma50ns =
photons.getParameter<std::vector<std::string>>(
"uncertaintyKey_50ns"),
87 .mean25ns =
photons.getParameter<std::vector<std::string>>(
"regressionKey_25ns"),
88 .sigma25ns =
photons.getParameter<std::vector<std::string>>(
"uncertaintyKey_25ns")};
126 const int numberOfClusters = superClus->clusters().size();
127 const bool missing_clusters = !superClus->clusters()[numberOfClusters - 1].
isAvailable();
129 if (missing_clusters)
132 std::array<float, 33> eval;
133 const double rawEnergy = superClus->rawEnergy();
139 eval[2] = superClus->eta();
140 eval[3] = superClus->phi();
141 eval[4] = superClus->etaWidth();
142 eval[5] = superClus->phiWidth();
144 eval[7] = theseed->
energy() / rawEnergy;
145 eval[8] = ess.eMax / rawEnergy;
146 eval[9] = ess.e2nd / rawEnergy;
147 eval[10] = (ess.eLeft + ess.eRight != 0.f ? (ess.eLeft - ess.eRight) / (ess.eLeft + ess.eRight) : 0.f);
148 eval[11] = (ess.eTop + ess.eBottom != 0.f ? (ess.eTop - ess.eBottom) / (ess.eTop + ess.eBottom) : 0.f);
149 eval[12] = ess.sigmaIetaIeta;
150 eval[13] = ess.sigmaIetaIphi;
151 eval[14] = ess.sigmaIphiIphi;
152 eval[15] =
std::max(0, numberOfClusters - 1);
155 std::vector<float> clusterRawEnergy;
156 clusterRawEnergy.resize(
std::max(3, numberOfClusters), 0);
157 std::vector<float> clusterDEtaToSeed;
158 clusterDEtaToSeed.resize(
std::max(3, numberOfClusters), 0);
159 std::vector<float> clusterDPhiToSeed;
160 clusterDPhiToSeed.resize(
std::max(3, numberOfClusters), 0);
161 float clusterMaxDR = 999.;
162 float clusterMaxDRDPhi = 999.;
163 float clusterMaxDRDEta = 999.;
164 float clusterMaxDRRawEnergy = 0.;
169 for (
auto const& pclus : superClus->clusters()) {
170 if (theseed == pclus)
172 clusterRawEnergy[iclus] = pclus->energy();
174 clusterDEtaToSeed[iclus] = pclus->eta() - theseed->
eta();
178 if (the_dr >
maxDR) {
180 clusterMaxDR =
maxDR;
181 clusterMaxDRDPhi = clusterDPhiToSeed[iclus];
182 clusterMaxDRDEta = clusterDEtaToSeed[iclus];
183 clusterMaxDRRawEnergy = clusterRawEnergy[iclus];
188 eval[16] = clusterMaxDR;
189 eval[17] = clusterMaxDRDPhi;
190 eval[18] = clusterMaxDRDEta;
191 eval[19] = clusterMaxDRRawEnergy / rawEnergy;
192 eval[20] = clusterRawEnergy[0] / rawEnergy;
193 eval[21] = clusterRawEnergy[1] / rawEnergy;
194 eval[22] = clusterRawEnergy[2] / rawEnergy;
195 eval[23] = clusterDPhiToSeed[0];
196 eval[24] = clusterDPhiToSeed[1];
197 eval[25] = clusterDPhiToSeed[2];
198 eval[26] = clusterDEtaToSeed[0];
199 eval[27] = clusterDEtaToSeed[1];
200 eval[28] = clusterDEtaToSeed[2];
203 const bool isEB = ele.
isEB();
220 eval[29] = superClus->preshowerEnergy() / superClus->rawEnergy();
225 constexpr
double meanlimlow = 0.2;
226 constexpr
double meanlimhigh = 2.0;
227 constexpr
double meanoffset = meanlimlow + 0.5 * (meanlimhigh - meanlimlow);
228 constexpr
double meanscale = 0.5 * (meanlimhigh - meanlimlow);
230 constexpr
double sigmalimlow = 0.0002;
231 constexpr
double sigmalimhigh = 0.5;
232 constexpr
double sigmaoffset = sigmalimlow + 0.5 * (sigmalimhigh - sigmalimlow);
233 constexpr
double sigmascale = 0.5 * (sigmalimhigh - sigmalimlow);
235 const int coridx = isEB ? 0 : 1;
242 double mean = meanoffset + meanscale * vdt::fast_sin(rawmean);
243 double sigma = sigmaoffset + sigmascale * vdt::fast_sin(rawsigma);
247 double ecor =
mean * (eval[1]);
249 ecor =
mean * (eval[1] + superClus->preshowerEnergy());
250 const double sigmacor = sigma * ecor;
256 std::array<float, 11> eval_ep;
259 const float tot_energy = superClus->rawEnergy() + superClus->preshowerEnergy();
263 eval_ep[0] = tot_energy *
mean;
264 eval_ep[1] = sigma /
mean;
266 eval_ep[3] = trkMomentumRelError;
267 eval_ep[4] = sigma /
mean / trkMomentumRelError;
268 eval_ep[5] = tot_energy *
mean /
ep;
269 eval_ep[6] = tot_energy *
mean /
ep *
sqrt(sigma /
mean * sigma /
mean + trkMomentumRelError * trkMomentumRelError);
295 oldMomentum.y() * combinedMomentum / oldMomentum.t(),
296 oldMomentum.z() * combinedMomentum / oldMomentum.t(),
305 std::array<float, 35> eval;
309 const int numberOfClusters = superClus->clusters().size();
310 const bool missing_clusters = !superClus->clusters()[numberOfClusters - 1].
isAvailable();
312 if (missing_clusters)
315 const double rawEnergy = superClus->rawEnergy();
321 eval[2] = superClus->etaWidth();
322 eval[3] = superClus->phiWidth();
323 eval[4] =
std::max(0, numberOfClusters - 1);
327 eval[8] = theseed->
eta() - superClus->position().Eta();
329 eval[10] = theseed->
energy() / rawEnergy;
330 eval[11] = ess.e3x3 / ess.e5x5;
331 eval[12] = ess.sigmaIetaIeta;
332 eval[13] = ess.sigmaIphiIphi;
333 eval[14] = ess.sigmaIetaIphi / (ess.sigmaIphiIphi * ess.sigmaIetaIeta);
334 eval[15] = ess.maxEnergyXtal / ess.e5x5;
335 eval[16] = ess.e2nd / ess.e5x5;
336 eval[17] = ess.eTop / ess.e5x5;
337 eval[18] = ess.eBottom / ess.e5x5;
338 eval[19] = ess.eLeft / ess.e5x5;
339 eval[20] = ess.eRight / ess.e5x5;
340 eval[21] = ess.e2x5Max / ess.e5x5;
341 eval[22] = ess.e2x5Left / ess.e5x5;
342 eval[23] = ess.e2x5Right / ess.e5x5;
343 eval[24] = ess.e2x5Top / ess.e5x5;
344 eval[25] = ess.e2x5Bottom / ess.e5x5;
346 const bool isEB = pho.
isEB();
350 int ieta = ebseedid.ieta();
351 int iphi = ebseedid.iphi();
354 int signieta =
ieta > 0 ? +1 : -1;
355 eval[29] = (
ieta - signieta) % 5;
356 eval[30] = (
iphi - 1) % 2;
358 eval[32] = (
iphi - 1) % 20;
363 eval[26] = superClus->preshowerEnergy() / rawEnergy;
364 eval[27] = superClus->preshowerEnergyPlane1() / rawEnergy;
365 eval[28] = superClus->preshowerEnergyPlane2() / rawEnergy;
366 eval[29] = eeseedid.ix();
367 eval[30] = eeseedid.iy();
372 const double meanlimlow = 0.2;
373 const double meanlimhigh = 2.0;
374 const double meanoffset = meanlimlow + 0.5 * (meanlimhigh - meanlimlow);
375 const double meanscale = 0.5 * (meanlimhigh - meanlimlow);
377 const double sigmalimlow = 0.0002;
378 const double sigmalimhigh = 0.5;
379 const double sigmaoffset = sigmalimlow + 0.5 * (sigmalimhigh - sigmalimlow);
380 const double sigmascale = 0.5 * (sigmalimhigh - sigmalimlow);
382 const int coridx = isEB ? 0 : 1;
385 const double rawmean =
phoForestsMean_[coridx]->GetResponse(eval.data());
388 const double mean = meanoffset + meanscale * vdt::fast_sin(rawmean);
389 const double sigma = sigmaoffset + sigmascale * vdt::fast_sin(rawsigma);
393 const double ecor = isEB ?
mean * eval[0] :
mean * (eval[0] + superClus->preshowerEnergy());
395 const double sigmacor = sigma * ecor;