3 #include "../interface/EGEnergyCorrector.h"
21 fIsInitialized(kFALSE),
56 fVals =
new Float_t[73];
79 TFile *fgbr = TFile::Open(regweights.c_str(),
"READ");
97 Double_t ebcmax = -99.;
100 if (bc->energy() > ebcmax && bc !=
b) {
102 ebcmax = bc->energy();
108 Double_t ebcmin = 1e6;
111 if (bc->energy() < ebcmin && bc !=
b) {
113 ebcmin = bc->energy();
122 if (bc->energy() < ebcmin && bc !=b && bc!=bclast) {
124 ebcmin = bc->energy();
128 Bool_t isbarrel = b->hitsAndFractions().at(0).first.subdetId()==
EcalBarrel;
129 Bool_t hasbc2 = b2.
isNonnull() && b2->energy()>0.;
130 Bool_t hasbclast = bclast.
isNonnull() && bclast->energy()>0.;
131 Bool_t hasbclast2 = bclast2.
isNonnull() && bclast2->energy()>0.;
137 fVals[0] = s->rawEnergy();
143 fVals[6] = s->etaWidth();
144 fVals[7] = s->phiWidth();
148 double bemax = clustertools.eMax(*b);
149 double be2nd = clustertools.e2nd(*b);
150 double betop = clustertools.eTop(*b);
151 double bebottom = clustertools.eBottom(*b);
152 double beleft = clustertools.eLeft(*b);
153 double beright = clustertools.eRight(*b);
156 fVals[8] = b->eta()-s->eta();
158 fVals[10] = b->energy()/s->rawEnergy();
159 fVals[11] = clustertools.e3x3(*b)/b->energy();
160 fVals[12] = clustertools.e5x5(*b)/b->energy();
161 fVals[13] =
sqrt(clustertools.localCovariances(*b)[0]);
162 fVals[14] =
sqrt(clustertools.localCovariances(*b)[2]);
163 fVals[15] = clustertools.localCovariances(*b)[1];
164 fVals[16] = bemax/b->energy();
165 fVals[17] =
log(be2nd/bemax);
166 fVals[18] =
log(betop/bemax);
167 fVals[19] =
log(bebottom/bemax);
168 fVals[20] =
log(beleft/bemax);
169 fVals[21] =
log(beright/bemax);
170 fVals[22] = (betop-bebottom)/(betop+bebottom);
171 fVals[23] = (beleft-beright)/(beleft+beright);
174 double bc2emax = hasbc2 ? clustertools.eMax(*b2) : 0.;
175 double bc2e2nd = hasbc2 ? clustertools.e2nd(*b2) : 0.;
176 double bc2etop = hasbc2 ? clustertools.eTop(*b2) : 0.;
177 double bc2ebottom = hasbc2 ? clustertools.eBottom(*b2) : 0.;
178 double bc2eleft = hasbc2 ? clustertools.eLeft(*b2) : 0.;
179 double bc2eright = hasbc2 ? clustertools.eRight(*b2) : 0.;
181 fVals[24] = hasbc2 ? (b2->eta()-s->eta()) : 0.;
183 fVals[26] = hasbc2 ? b2->energy()/s->rawEnergy() : 0.;
184 fVals[27] = hasbc2 ? clustertools.e3x3(*b2)/b2->energy() : 0.;
185 fVals[28] = hasbc2 ? clustertools.e5x5(*b2)/b2->energy() : 0.;
186 fVals[29] = hasbc2 ?
sqrt(clustertools.localCovariances(*b2)[0]) : 0.;
187 fVals[30] = hasbc2 ?
sqrt(clustertools.localCovariances(*b2)[2]) : 0.;
188 fVals[31] = hasbc2 ? clustertools.localCovariances(*b)[1] : 0.;
189 fVals[32] = hasbc2 ? bc2emax/b2->energy() : 0.;
190 fVals[33] = hasbc2 ?
log(bc2e2nd/bc2emax) : 0.;
191 fVals[34] = hasbc2 ?
log(bc2etop/bc2emax) : 0.;
192 fVals[35] = hasbc2 ?
log(bc2ebottom/bc2emax) : 0.;
193 fVals[36] = hasbc2 ?
log(bc2eleft/bc2emax) : 0.;
194 fVals[37] = hasbc2 ?
log(bc2eright/bc2emax) : 0.;
195 fVals[38] = hasbc2 ? (bc2etop-bc2ebottom)/(bc2etop+bc2ebottom) : 0.;
196 fVals[39] = hasbc2 ? (bc2eleft-bc2eright)/(bc2eleft+bc2eright) : 0.;
198 fVals[40] = hasbclast ? (bclast->eta()-s->eta()) : 0.;
199 fVals[41] = hasbclast ?
reco::deltaPhi(bclast->phi(),s->phi()) : 0.;
200 fVals[42] = hasbclast ? bclast->energy()/s->rawEnergy() : 0.;
201 fVals[43] = hasbclast ? clustertools.e3x3(*bclast)/bclast->energy() : 0.;
202 fVals[44] = hasbclast ? clustertools.e5x5(*bclast)/bclast->energy() : 0.;
203 fVals[45] = hasbclast ?
sqrt(clustertools.localCovariances(*bclast)[0]) : 0.;
204 fVals[46] = hasbclast ?
sqrt(clustertools.localCovariances(*bclast)[2]) : 0.;
205 fVals[47] = hasbclast ? clustertools.localCovariances(*bclast)[1] : 0.;
207 fVals[48] = hasbclast2 ? (bclast2->eta()-s->eta()) : 0.;
208 fVals[49] = hasbclast2 ?
reco::deltaPhi(bclast2->phi(),s->phi()) : 0.;
209 fVals[50] = hasbclast2 ? bclast2->energy()/s->rawEnergy() : 0.;
210 fVals[51] = hasbclast2 ? clustertools.e3x3(*bclast2)/bclast2->energy() : 0.;
211 fVals[52] = hasbclast2 ? clustertools.e5x5(*bclast2)/bclast2->energy() : 0.;
212 fVals[53] = hasbclast2 ?
sqrt(clustertools.localCovariances(*bclast2)[0]) : 0.;
213 fVals[54] = hasbclast2 ?
sqrt(clustertools.localCovariances(*bclast2)[2]) : 0.;
214 fVals[55] = hasbclast2 ? clustertools.localCovariances(*bclast2)[1] : 0.;
221 float betacry, bphicry, bthetatilt, bphitilt;
230 fVals[61] = biphi%20;
236 float bc2etacry, bc2phicry, bc2thetatilt, bc2phitilt;
237 int bc2ieta, bc2iphi;
240 fVals[64] = hasbc2 ? bc2ieta : 0.;
241 fVals[65] = hasbc2 ? bc2iphi : 0.;
242 fVals[66] = hasbc2 ? bc2ieta%5 : 0.;
243 fVals[67] = hasbc2 ? bc2iphi%2 : 0.;
245 fVals[69] = hasbc2 ? bc2iphi%20 : 0.;
246 fVals[70] = hasbc2 ? bc2etacry : 0.;
247 fVals[71] = hasbc2 ? bc2phicry : 0.;
249 fVals[72] = vtxcol.size();
253 fVals[0] = s->rawEnergy();
258 fVals[5] = s->etaWidth();
259 fVals[6] = s->phiWidth();
260 fVals[7] = vtxcol.size();
264 const Double_t varscale = 1.253;
269 den = s->rawEnergy();
274 den = s->rawEnergy() + s->preshowerEnergy();
284 return std::pair<double,double>(ecor,ecorerr);
302 Double_t ebcmax = -99.;
305 if (bc->energy() > ebcmax && bc !=
b) {
307 ebcmax = bc->energy();
312 Double_t ebcmin = 1e6;
315 if (bc->energy() < ebcmin && bc !=
b) {
317 ebcmin = bc->energy();
325 if (bc->energy() < ebcmin && bc !=b && bc!=bclast) {
327 ebcmin = bc->energy();
331 Bool_t isbarrel = b->hitsAndFractions().at(0).first.subdetId()==
EcalBarrel;
332 Bool_t hasbc2 = b2.
isNonnull() && b2->energy()>0.;
333 Bool_t hasbclast = bclast.
isNonnull() && bclast->energy()>0.;
334 Bool_t hasbclast2 = bclast2.
isNonnull() && bclast2->energy()>0.;
338 fVals[0] = s->rawEnergy();
339 fVals[1] = clustertools.e3x3(*b)/s->rawEnergy();
342 fVals[4] = clustertools.e5x5(*b)/s->rawEnergy();
344 fVals[6] = s->etaWidth();
345 fVals[7] = s->phiWidth();
348 double bemax = clustertools.eMax(*b);
349 double be2nd = clustertools.e2nd(*b);
350 double betop = clustertools.eTop(*b);
351 double bebottom = clustertools.eBottom(*b);
352 double beleft = clustertools.eLeft(*b);
353 double beright = clustertools.eRight(*b);
356 fVals[8] = b->eta()-s->eta();
358 fVals[10] = b->energy()/s->rawEnergy();
359 fVals[11] = clustertools.e3x3(*b)/b->energy();
360 fVals[12] = clustertools.e5x5(*b)/b->energy();
361 fVals[13] =
sqrt(clustertools.localCovariances(*b)[0]);
362 fVals[14] =
sqrt(clustertools.localCovariances(*b)[2]);
363 fVals[15] = clustertools.localCovariances(*b)[1];
364 fVals[16] = bemax/b->energy();
365 fVals[17] =
log(be2nd/bemax);
366 fVals[18] =
log(betop/bemax);
367 fVals[19] =
log(bebottom/bemax);
368 fVals[20] =
log(beleft/bemax);
369 fVals[21] =
log(beright/bemax);
370 fVals[22] = (betop-bebottom)/(betop+bebottom);
371 fVals[23] = (beleft-beright)/(beleft+beright);
374 double bc2emax = hasbc2 ? clustertools.eMax(*b2) : 0.;
375 double bc2e2nd = hasbc2 ? clustertools.e2nd(*b2) : 0.;
376 double bc2etop = hasbc2 ? clustertools.eTop(*b2) : 0.;
377 double bc2ebottom = hasbc2 ? clustertools.eBottom(*b2) : 0.;
378 double bc2eleft = hasbc2 ? clustertools.eLeft(*b2) : 0.;
379 double bc2eright = hasbc2 ? clustertools.eRight(*b2) : 0.;
381 fVals[24] = hasbc2 ? (b2->eta()-s->eta()) : 0.;
383 fVals[26] = hasbc2 ? b2->energy()/s->rawEnergy() : 0.;
384 fVals[27] = hasbc2 ? clustertools.e3x3(*b2)/b2->energy() : 0.;
385 fVals[28] = hasbc2 ? clustertools.e5x5(*b2)/b2->energy() : 0.;
386 fVals[29] = hasbc2 ?
sqrt(clustertools.localCovariances(*b2)[0]) : 0.;
387 fVals[30] = hasbc2 ?
sqrt(clustertools.localCovariances(*b2)[2]) : 0.;
388 fVals[31] = hasbc2 ? clustertools.localCovariances(*b)[1] : 0.;
389 fVals[32] = hasbc2 ? bc2emax/b2->energy() : 0.;
390 fVals[33] = hasbc2 ?
log(bc2e2nd/bc2emax) : 0.;
391 fVals[34] = hasbc2 ?
log(bc2etop/bc2emax) : 0.;
392 fVals[35] = hasbc2 ?
log(bc2ebottom/bc2emax) : 0.;
393 fVals[36] = hasbc2 ?
log(bc2eleft/bc2emax) : 0.;
394 fVals[37] = hasbc2 ?
log(bc2eright/bc2emax) : 0.;
395 fVals[38] = hasbc2 ? (bc2etop-bc2ebottom)/(bc2etop+bc2ebottom) : 0.;
396 fVals[39] = hasbc2 ? (bc2eleft-bc2eright)/(bc2eleft+bc2eright) : 0.;
398 fVals[40] = hasbclast ? (bclast->eta()-s->eta()) : 0.;
399 fVals[41] = hasbclast ?
reco::deltaPhi(bclast->phi(),s->phi()) : 0.;
400 fVals[42] = hasbclast ? bclast->energy()/s->rawEnergy() : 0.;
401 fVals[43] = hasbclast ? clustertools.e3x3(*bclast)/bclast->energy() : 0.;
402 fVals[44] = hasbclast ? clustertools.e5x5(*bclast)/bclast->energy() : 0.;
403 fVals[45] = hasbclast ?
sqrt(clustertools.localCovariances(*bclast)[0]) : 0.;
404 fVals[46] = hasbclast ?
sqrt(clustertools.localCovariances(*bclast)[2]) : 0.;
405 fVals[47] = hasbclast ? clustertools.localCovariances(*bclast)[1] : 0.;
407 fVals[48] = hasbclast2 ? (bclast2->eta()-s->eta()) : 0.;
408 fVals[49] = hasbclast2 ?
reco::deltaPhi(bclast2->phi(),s->phi()) : 0.;
409 fVals[50] = hasbclast2 ? bclast2->energy()/s->rawEnergy() : 0.;
410 fVals[51] = hasbclast2 ? clustertools.e3x3(*bclast2)/bclast2->energy() : 0.;
411 fVals[52] = hasbclast2 ? clustertools.e5x5(*bclast2)/bclast2->energy() : 0.;
412 fVals[53] = hasbclast2 ?
sqrt(clustertools.localCovariances(*bclast2)[0]) : 0.;
413 fVals[54] = hasbclast2 ?
sqrt(clustertools.localCovariances(*bclast2)[2]) : 0.;
414 fVals[55] = hasbclast2 ? clustertools.localCovariances(*bclast2)[1] : 0.;
417 float betacry, bphicry, bthetatilt, bphitilt;
426 fVals[61] = biphi%20;
430 float bc2etacry, bc2phicry, bc2thetatilt, bc2phitilt;
431 int bc2ieta, bc2iphi;
434 fVals[64] = hasbc2 ? bc2ieta : 0.;
435 fVals[65] = hasbc2 ? bc2iphi : 0.;
436 fVals[66] = hasbc2 ? bc2ieta%5 : 0.;
437 fVals[67] = hasbc2 ? bc2iphi%2 : 0.;
439 fVals[69] = hasbc2 ? bc2iphi%20 : 0.;
440 fVals[70] = hasbc2 ? bc2etacry : 0.;
441 fVals[71] = hasbc2 ? bc2phicry : 0.;
443 fVals[72] = vtxcol.size();
447 fVals[0] = s->rawEnergy();
448 fVals[1] = clustertools.e3x3(*b)/s->rawEnergy();
451 fVals[4] = clustertools.e5x5(*b)/s->rawEnergy();
452 fVals[5] = s->etaWidth();
453 fVals[6] = s->phiWidth();
454 fVals[7] = vtxcol.size();
458 const Double_t varscale = 1.253;
463 den = s->rawEnergy();
468 den = s->rawEnergy() + s->preshowerEnergy();
478 return std::pair<double,double>(ecor,ecorerr);
488 Bool_t isbarrel = b->hitsAndFractions().at(0).first.subdetId()==
EcalBarrel;
491 fVals[0] = s->rawEnergy();
496 fVals[5] = s->etaWidth();
497 fVals[6] = s->phiWidth();
498 fVals[7] = s->clustersSize();
501 fVals[10] = vtxcol.size();
504 double bemax = clustertools.eMax(*b);
505 double be2nd = clustertools.e2nd(*b);
506 double betop = clustertools.eTop(*b);
507 double bebottom = clustertools.eBottom(*b);
508 double beleft = clustertools.eLeft(*b);
509 double beright = clustertools.eRight(*b);
511 double be2x5max = clustertools.e2x5Max(*b);
512 double be2x5top = clustertools.e2x5Top(*b);
513 double be2x5bottom = clustertools.e2x5Bottom(*b);
514 double be2x5left = clustertools.e2x5Left(*b);
515 double be2x5right = clustertools.e2x5Right(*b);
517 fVals[11] = b->eta()-s->eta();
519 fVals[13] = b->energy()/s->rawEnergy();
520 fVals[14] = clustertools.e3x3(*b)/b->energy();
521 fVals[15] = clustertools.e5x5(*b)/b->energy();
522 fVals[16] =
sqrt(clustertools.localCovariances(*b)[0]);
523 fVals[17] =
sqrt(clustertools.localCovariances(*b)[2]);
524 fVals[18] = clustertools.localCovariances(*b)[1];
525 fVals[19] = bemax/b->energy();
526 fVals[20] = be2nd/b->energy();
527 fVals[21] = betop/b->energy();
528 fVals[22] = bebottom/b->energy();
529 fVals[23] = beleft/b->energy();
530 fVals[24] = beright/b->energy();
531 fVals[25] = be2x5max/b->energy();
532 fVals[26] = be2x5top/b->energy();
533 fVals[27] = be2x5bottom/b->energy();
534 fVals[28] = be2x5left/b->energy();
535 fVals[29] = be2x5right/b->energy();
541 float betacry, bphicry, bthetatilt, bphitilt;
550 fVals[35] = biphi%20;
557 fVals[30] = s->preshowerEnergy()/s->rawEnergy();
569 den = s->rawEnergy();
574 den = s->rawEnergy() + s->preshowerEnergy();
585 fVals[3] = 1.0045*p.
r9() +0.001;
586 fVals[5] = 1.04302*s->etaWidth() - 0.000618;
587 fVals[6] = 1.00002*s->phiWidth() - 0.000371;
588 fVals[14] = fVals[3]*s->rawEnergy()/b->energy();
592 fVals[4] = fVals[15]*b->energy()/s->rawEnergy();
594 fVals[16] = 0.891832*
sqrt(clustertools.localCovariances(*b)[0]) + 0.0009133;
595 fVals[17] = 0.993*
sqrt(clustertools.localCovariances(*b)[2]);
597 fVals[19] = 1.012*bemax/b->energy();
598 fVals[20] = 1.0*be2nd/b->energy();
599 fVals[21] = 0.94*betop/b->energy();
600 fVals[22] = 0.94*bebottom/b->energy();
601 fVals[23] = 0.94*beleft/b->energy();
602 fVals[24] = 0.94*beright/b->energy();
603 fVals[25] = 1.006*be2x5max/b->energy();
604 fVals[26] = 1.09*be2x5top/b->energy();
605 fVals[27] = 1.09*be2x5bottom/b->energy();
606 fVals[28] = 1.09*be2x5left/b->energy();
607 fVals[29] = 1.09*be2x5right/b->energy();
611 fVals[3] = 1.0086*p.
r9() -0.0007;
613 fVals[5] = 0.903254*s->etaWidth() +0.001346;
614 fVals[6] = 0.99992*s->phiWidth() + 4.8e-07;
615 fVals[13] =
TMath::Min(1.0,1.0022*b->energy()/s->rawEnergy());
618 fVals[14] = fVals[3]*s->rawEnergy()/b->energy();
620 fVals[16] = 0.9947*
sqrt(clustertools.localCovariances(*b)[0]) + 0.00003;
622 fVals[19] = 1.005*bemax/b->energy();
623 fVals[20] = 1.02*be2nd/b->energy();
624 fVals[21] = 0.96*betop/b->energy();
625 fVals[22] = 0.96*bebottom/b->energy();
626 fVals[23] = 0.96*beleft/b->energy();
627 fVals[24] = 0.96*beright/b->energy();
628 fVals[25] = 1.0075*be2x5max/b->energy();
629 fVals[26] = 1.13*be2x5top/b->energy();
630 fVals[27] = 1.13*be2x5bottom/b->energy();
631 fVals[28] = 1.13*be2x5left/b->energy();
632 fVals[29] = 1.13*be2x5right/b->energy();
637 Double_t ecorerr = readervar->
GetResponse(fVals)*den;
641 return std::pair<double,double>(ecor,ecorerr);
650 Bool_t isbarrel = b->hitsAndFractions().at(0).first.subdetId()==
EcalBarrel;
653 fVals[0] = s->rawEnergy();
656 fVals[3] = clustertools.e3x3(*b)/s->rawEnergy();
657 fVals[4] = clustertools.e5x5(*b)/s->rawEnergy();
658 fVals[5] = s->etaWidth();
659 fVals[6] = s->phiWidth();
660 fVals[7] = s->clustersSize();
663 fVals[10] = vtxcol.size();
666 double bemax = clustertools.eMax(*b);
667 double be2nd = clustertools.e2nd(*b);
668 double betop = clustertools.eTop(*b);
669 double bebottom = clustertools.eBottom(*b);
670 double beleft = clustertools.eLeft(*b);
671 double beright = clustertools.eRight(*b);
673 double be2x5max = clustertools.e2x5Max(*b);
674 double be2x5top = clustertools.e2x5Top(*b);
675 double be2x5bottom = clustertools.e2x5Bottom(*b);
676 double be2x5left = clustertools.e2x5Left(*b);
677 double be2x5right = clustertools.e2x5Right(*b);
679 fVals[11] = b->eta()-s->eta();
681 fVals[13] = b->energy()/s->rawEnergy();
682 fVals[14] = clustertools.e3x3(*b)/b->energy();
683 fVals[15] = clustertools.e5x5(*b)/b->energy();
684 fVals[16] =
sqrt(clustertools.localCovariances(*b)[0]);
685 fVals[17] =
sqrt(clustertools.localCovariances(*b)[2]);
686 fVals[18] = clustertools.localCovariances(*b)[1];
687 fVals[19] = bemax/b->energy();
688 fVals[20] = be2nd/b->energy();
689 fVals[21] = betop/b->energy();
690 fVals[22] = bebottom/b->energy();
691 fVals[23] = beleft/b->energy();
692 fVals[24] = beright/b->energy();
693 fVals[25] = be2x5max/b->energy();
694 fVals[26] = be2x5top/b->energy();
695 fVals[27] = be2x5bottom/b->energy();
696 fVals[28] = be2x5left/b->energy();
697 fVals[29] = be2x5right/b->energy();
703 float betacry, bphicry, bthetatilt, bphitilt;
712 fVals[35] = biphi%20;
719 fVals[30] = s->preshowerEnergy()/s->rawEnergy();
726 den = s->rawEnergy();
731 den = s->rawEnergy() + s->preshowerEnergy();
737 Double_t ecorerr = readervar->
GetResponse(fVals)*den;
741 return std::pair<double,double>(ecor,ecorerr);
double GetResponse(const float *vector) const
void Initialize(const edm::EventSetup &iSetup, std::string regweights, bool weightsFromDB=false)
reco::SuperClusterRef superCluster() const
Ref to SuperCluster.
const GBRForest * fReaderee
const GBRForest * fReadereb
const GBRForest * fReaderebvariance
std::vector< Vertex > VertexCollection
collection of Vertex objects
std::pair< double, double > CorrectedEnergyWithError(const reco::Photon &p, const reco::VertexCollection &vtxcol, EcalClusterLazyTools &clustertools, const edm::EventSetup &es)
virtual SuperClusterRef superCluster() const
reference to a SuperCluster
float hcalOverEcal() const
float hadTowOverEm() const
the ration of hadronic energy in towers behind the BCs in the SC and the SC energy ...
float hadronicOverEm() const
the total hadronic over electromagnetic fraction
float hcalOverEcalBc() const
bool isNonnull() const
Checks for non-null.
double deltaPhi(double phi1, double phi2)
std::pair< double, double > CorrectedEnergyWithErrorV3(const reco::Photon &p, const reco::VertexCollection &vtxcol, double rho, EcalClusterLazyTools &clustertools, const edm::EventSetup &es, bool applyRescale=false)
T const * product() const
void localCoordsEB(const reco::CaloCluster &bclus, const edm::EventSetup &es, float &etacry, float &phicry, int &ieta, int &iphi, float &thetatilt, float &phitilt) const
const GBRForest * fReadereevariance
EcalClusterLocal _ecalLocal
bool ecalDrivenSeed() const