4 #include "../interface/EGEnergyCorrector.h"
23 fIsInitialized(kFALSE),
58 fVals =
new Float_t[73];
67 iSetup.
get<
GBRWrapperRcd>().
get(std::string(TString::Format(
"%s_EBCorrection",regweights.c_str())),readereb);
68 iSetup.
get<
GBRWrapperRcd>().
get(std::string(TString::Format(
"%s_EBUncertainty",regweights.c_str())),readerebvar);
69 iSetup.
get<
GBRWrapperRcd>().
get(std::string(TString::Format(
"%s_EECorrection",regweights.c_str())),readeree);
70 iSetup.
get<
GBRWrapperRcd>().
get(std::string(TString::Format(
"%s_EEUncertainty",regweights.c_str())),readereevar);
81 TFile *fgbr = TFile::Open(regweights.c_str(),
"READ");
99 Double_t ebcmax = -99.;
102 if (bc->energy() > ebcmax && bc !=
b) {
104 ebcmax = bc->energy();
110 Double_t ebcmin = 1e6;
113 if (bc->energy() < ebcmin && bc !=
b) {
115 ebcmin = bc->energy();
124 if (bc->energy() < ebcmin && bc !=b && bc!=bclast) {
126 ebcmin = bc->energy();
130 Bool_t isbarrel = b->hitsAndFractions().at(0).first.subdetId()==
EcalBarrel;
131 Bool_t hasbc2 = b2.
isNonnull() && b2->energy()>0.;
132 Bool_t hasbclast = bclast.
isNonnull() && bclast->energy()>0.;
133 Bool_t hasbclast2 = bclast2.
isNonnull() && bclast2->energy()>0.;
139 fVals[0] = s->rawEnergy();
145 fVals[6] = s->etaWidth();
146 fVals[7] = s->phiWidth();
150 double bemax = clustertools.
eMax(*b);
151 double be2nd = clustertools.
e2nd(*b);
152 double betop = clustertools.
eTop(*b);
153 double bebottom = clustertools.
eBottom(*b);
154 double beleft = clustertools.
eLeft(*b);
155 double beright = clustertools.
eRight(*b);
158 fVals[8] = b->eta()-s->eta();
160 fVals[10] = b->energy()/s->rawEnergy();
161 fVals[11] = clustertools.
e3x3(*b)/b->energy();
162 fVals[12] = clustertools.
e5x5(*b)/b->energy();
166 fVals[16] = bemax/b->energy();
167 fVals[17] =
log(be2nd/bemax);
168 fVals[18] =
log(betop/bemax);
169 fVals[19] =
log(bebottom/bemax);
170 fVals[20] =
log(beleft/bemax);
171 fVals[21] =
log(beright/bemax);
172 fVals[22] = (betop-bebottom)/(betop+bebottom);
173 fVals[23] = (beleft-beright)/(beleft+beright);
176 double bc2emax = hasbc2 ? clustertools.
eMax(*b2) : 0.;
177 double bc2e2nd = hasbc2 ? clustertools.
e2nd(*b2) : 0.;
178 double bc2etop = hasbc2 ? clustertools.
eTop(*b2) : 0.;
179 double bc2ebottom = hasbc2 ? clustertools.
eBottom(*b2) : 0.;
180 double bc2eleft = hasbc2 ? clustertools.
eLeft(*b2) : 0.;
181 double bc2eright = hasbc2 ? clustertools.
eRight(*b2) : 0.;
183 fVals[24] = hasbc2 ? (b2->eta()-s->eta()) : 0.;
185 fVals[26] = hasbc2 ? b2->energy()/s->rawEnergy() : 0.;
186 fVals[27] = hasbc2 ? clustertools.
e3x3(*b2)/b2->energy() : 0.;
187 fVals[28] = hasbc2 ? clustertools.
e5x5(*b2)/b2->energy() : 0.;
191 fVals[32] = hasbc2 ? bc2emax/b2->energy() : 0.;
192 fVals[33] = hasbc2 ?
log(bc2e2nd/bc2emax) : 0.;
193 fVals[34] = hasbc2 ?
log(bc2etop/bc2emax) : 0.;
194 fVals[35] = hasbc2 ?
log(bc2ebottom/bc2emax) : 0.;
195 fVals[36] = hasbc2 ?
log(bc2eleft/bc2emax) : 0.;
196 fVals[37] = hasbc2 ?
log(bc2eright/bc2emax) : 0.;
197 fVals[38] = hasbc2 ? (bc2etop-bc2ebottom)/(bc2etop+bc2ebottom) : 0.;
198 fVals[39] = hasbc2 ? (bc2eleft-bc2eright)/(bc2eleft+bc2eright) : 0.;
200 fVals[40] = hasbclast ? (bclast->eta()-s->eta()) : 0.;
201 fVals[41] = hasbclast ?
reco::deltaPhi(bclast->phi(),s->phi()) : 0.;
202 fVals[42] = hasbclast ? bclast->energy()/s->rawEnergy() : 0.;
203 fVals[43] = hasbclast ? clustertools.
e3x3(*bclast)/bclast->energy() : 0.;
204 fVals[44] = hasbclast ? clustertools.
e5x5(*bclast)/bclast->energy() : 0.;
209 fVals[48] = hasbclast2 ? (bclast2->eta()-s->eta()) : 0.;
210 fVals[49] = hasbclast2 ?
reco::deltaPhi(bclast2->phi(),s->phi()) : 0.;
211 fVals[50] = hasbclast2 ? bclast2->energy()/s->rawEnergy() : 0.;
212 fVals[51] = hasbclast2 ? clustertools.
e3x3(*bclast2)/bclast2->energy() : 0.;
213 fVals[52] = hasbclast2 ? clustertools.
e5x5(*bclast2)/bclast2->energy() : 0.;
223 float betacry, bphicry, bthetatilt, bphitilt;
231 fVals[60] = (TMath::Abs(bieta)<=25)*(bieta%25) + (TMath::Abs(bieta)>25)*((bieta-25*TMath::Abs(bieta)/bieta)%20);
232 fVals[61] = biphi%20;
238 float bc2etacry, bc2phicry, bc2thetatilt, bc2phitilt;
239 int bc2ieta, bc2iphi;
242 fVals[64] = hasbc2 ? bc2ieta : 0.;
243 fVals[65] = hasbc2 ? bc2iphi : 0.;
244 fVals[66] = hasbc2 ? bc2ieta%5 : 0.;
245 fVals[67] = hasbc2 ? bc2iphi%2 : 0.;
246 fVals[68] = hasbc2 ? (TMath::Abs(bc2ieta)<=25)*(bc2ieta%25) + (TMath::Abs(bc2ieta)>25)*((bc2ieta-25*TMath::Abs(bc2ieta)/bc2ieta)%20) : 0.;
247 fVals[69] = hasbc2 ? bc2iphi%20 : 0.;
248 fVals[70] = hasbc2 ? bc2etacry : 0.;
249 fVals[71] = hasbc2 ? bc2phicry : 0.;
251 fVals[72] = vtxcol.size();
255 fVals[0] = s->rawEnergy();
260 fVals[5] = s->etaWidth();
261 fVals[6] = s->phiWidth();
262 fVals[7] = vtxcol.size();
266 const Double_t varscale = 1.253;
271 den = s->rawEnergy();
276 den = s->rawEnergy() + s->preshowerEnergy();
286 return std::pair<double,double>(ecor,ecorerr);
304 Double_t ebcmax = -99.;
307 if (bc->energy() > ebcmax && bc !=
b) {
309 ebcmax = bc->energy();
314 Double_t ebcmin = 1e6;
317 if (bc->energy() < ebcmin && bc !=
b) {
319 ebcmin = bc->energy();
327 if (bc->energy() < ebcmin && bc !=b && bc!=bclast) {
329 ebcmin = bc->energy();
333 Bool_t isbarrel = b->hitsAndFractions().at(0).first.subdetId()==
EcalBarrel;
334 Bool_t hasbc2 = b2.
isNonnull() && b2->energy()>0.;
335 Bool_t hasbclast = bclast.
isNonnull() && bclast->energy()>0.;
336 Bool_t hasbclast2 = bclast2.
isNonnull() && bclast2->energy()>0.;
340 fVals[0] = s->rawEnergy();
341 fVals[1] = clustertools.
e3x3(*b)/s->rawEnergy();
344 fVals[4] = clustertools.
e5x5(*b)/s->rawEnergy();
346 fVals[6] = s->etaWidth();
347 fVals[7] = s->phiWidth();
350 double bemax = clustertools.
eMax(*b);
351 double be2nd = clustertools.
e2nd(*b);
352 double betop = clustertools.
eTop(*b);
353 double bebottom = clustertools.
eBottom(*b);
354 double beleft = clustertools.
eLeft(*b);
355 double beright = clustertools.
eRight(*b);
358 fVals[8] = b->eta()-s->eta();
360 fVals[10] = b->energy()/s->rawEnergy();
361 fVals[11] = clustertools.
e3x3(*b)/b->energy();
362 fVals[12] = clustertools.
e5x5(*b)/b->energy();
366 fVals[16] = bemax/b->energy();
367 fVals[17] =
log(be2nd/bemax);
368 fVals[18] =
log(betop/bemax);
369 fVals[19] =
log(bebottom/bemax);
370 fVals[20] =
log(beleft/bemax);
371 fVals[21] =
log(beright/bemax);
372 fVals[22] = (betop-bebottom)/(betop+bebottom);
373 fVals[23] = (beleft-beright)/(beleft+beright);
376 double bc2emax = hasbc2 ? clustertools.
eMax(*b2) : 0.;
377 double bc2e2nd = hasbc2 ? clustertools.
e2nd(*b2) : 0.;
378 double bc2etop = hasbc2 ? clustertools.
eTop(*b2) : 0.;
379 double bc2ebottom = hasbc2 ? clustertools.
eBottom(*b2) : 0.;
380 double bc2eleft = hasbc2 ? clustertools.
eLeft(*b2) : 0.;
381 double bc2eright = hasbc2 ? clustertools.
eRight(*b2) : 0.;
383 fVals[24] = hasbc2 ? (b2->eta()-s->eta()) : 0.;
385 fVals[26] = hasbc2 ? b2->energy()/s->rawEnergy() : 0.;
386 fVals[27] = hasbc2 ? clustertools.
e3x3(*b2)/b2->energy() : 0.;
387 fVals[28] = hasbc2 ? clustertools.
e5x5(*b2)/b2->energy() : 0.;
391 fVals[32] = hasbc2 ? bc2emax/b2->energy() : 0.;
392 fVals[33] = hasbc2 ?
log(bc2e2nd/bc2emax) : 0.;
393 fVals[34] = hasbc2 ?
log(bc2etop/bc2emax) : 0.;
394 fVals[35] = hasbc2 ?
log(bc2ebottom/bc2emax) : 0.;
395 fVals[36] = hasbc2 ?
log(bc2eleft/bc2emax) : 0.;
396 fVals[37] = hasbc2 ?
log(bc2eright/bc2emax) : 0.;
397 fVals[38] = hasbc2 ? (bc2etop-bc2ebottom)/(bc2etop+bc2ebottom) : 0.;
398 fVals[39] = hasbc2 ? (bc2eleft-bc2eright)/(bc2eleft+bc2eright) : 0.;
400 fVals[40] = hasbclast ? (bclast->eta()-s->eta()) : 0.;
401 fVals[41] = hasbclast ?
reco::deltaPhi(bclast->phi(),s->phi()) : 0.;
402 fVals[42] = hasbclast ? bclast->energy()/s->rawEnergy() : 0.;
403 fVals[43] = hasbclast ? clustertools.
e3x3(*bclast)/bclast->energy() : 0.;
404 fVals[44] = hasbclast ? clustertools.
e5x5(*bclast)/bclast->energy() : 0.;
409 fVals[48] = hasbclast2 ? (bclast2->eta()-s->eta()) : 0.;
410 fVals[49] = hasbclast2 ?
reco::deltaPhi(bclast2->phi(),s->phi()) : 0.;
411 fVals[50] = hasbclast2 ? bclast2->energy()/s->rawEnergy() : 0.;
412 fVals[51] = hasbclast2 ? clustertools.
e3x3(*bclast2)/bclast2->energy() : 0.;
413 fVals[52] = hasbclast2 ? clustertools.
e5x5(*bclast2)/bclast2->energy() : 0.;
419 float betacry, bphicry, bthetatilt, bphitilt;
427 fVals[60] = (TMath::Abs(bieta)<=25)*(bieta%25) + (TMath::Abs(bieta)>25)*((bieta-25*TMath::Abs(bieta)/bieta)%20);
428 fVals[61] = biphi%20;
432 float bc2etacry, bc2phicry, bc2thetatilt, bc2phitilt;
433 int bc2ieta, bc2iphi;
436 fVals[64] = hasbc2 ? bc2ieta : 0.;
437 fVals[65] = hasbc2 ? bc2iphi : 0.;
438 fVals[66] = hasbc2 ? bc2ieta%5 : 0.;
439 fVals[67] = hasbc2 ? bc2iphi%2 : 0.;
440 fVals[68] = hasbc2 ? (TMath::Abs(bc2ieta)<=25)*(bc2ieta%25) + (TMath::Abs(bc2ieta)>25)*((bc2ieta-25*TMath::Abs(bc2ieta)/bc2ieta)%20) : 0.;
441 fVals[69] = hasbc2 ? bc2iphi%20 : 0.;
442 fVals[70] = hasbc2 ? bc2etacry : 0.;
443 fVals[71] = hasbc2 ? bc2phicry : 0.;
445 fVals[72] = vtxcol.size();
449 fVals[0] = s->rawEnergy();
450 fVals[1] = clustertools.
e3x3(*b)/s->rawEnergy();
453 fVals[4] = clustertools.
e5x5(*b)/s->rawEnergy();
454 fVals[5] = s->etaWidth();
455 fVals[6] = s->phiWidth();
456 fVals[7] = vtxcol.size();
460 const Double_t varscale = 1.253;
465 den = s->rawEnergy();
470 den = s->rawEnergy() + s->preshowerEnergy();
480 return std::pair<double,double>(ecor,ecorerr);
490 Bool_t isbarrel = b->hitsAndFractions().at(0).first.subdetId()==
EcalBarrel;
493 fVals[0] = s->rawEnergy();
498 fVals[5] = s->etaWidth();
499 fVals[6] = s->phiWidth();
500 fVals[7] = s->clustersSize();
503 fVals[10] = vtxcol.size();
506 double bemax = clustertools.
eMax(*b);
507 double be2nd = clustertools.
e2nd(*b);
508 double betop = clustertools.
eTop(*b);
509 double bebottom = clustertools.
eBottom(*b);
510 double beleft = clustertools.
eLeft(*b);
511 double beright = clustertools.
eRight(*b);
513 double be2x5max = clustertools.
e2x5Max(*b);
514 double be2x5top = clustertools.
e2x5Top(*b);
515 double be2x5bottom = clustertools.
e2x5Bottom(*b);
516 double be2x5left = clustertools.
e2x5Left(*b);
517 double be2x5right = clustertools.
e2x5Right(*b);
519 fVals[11] = b->eta()-s->eta();
521 fVals[13] = b->energy()/s->rawEnergy();
522 fVals[14] = clustertools.
e3x3(*b)/b->energy();
523 fVals[15] = clustertools.
e5x5(*b)/b->energy();
527 fVals[19] = bemax/b->energy();
528 fVals[20] = be2nd/b->energy();
529 fVals[21] = betop/b->energy();
530 fVals[22] = bebottom/b->energy();
531 fVals[23] = beleft/b->energy();
532 fVals[24] = beright/b->energy();
533 fVals[25] = be2x5max/b->energy();
534 fVals[26] = be2x5top/b->energy();
535 fVals[27] = be2x5bottom/b->energy();
536 fVals[28] = be2x5left/b->energy();
537 fVals[29] = be2x5right/b->energy();
543 float betacry, bphicry, bthetatilt, bphitilt;
551 fVals[34] = (TMath::Abs(bieta)<=25)*(bieta%25) + (TMath::Abs(bieta)>25)*((bieta-25*TMath::Abs(bieta)/bieta)%20);
552 fVals[35] = biphi%20;
559 fVals[30] = s->preshowerEnergy()/s->rawEnergy();
571 den = s->rawEnergy();
576 den = s->rawEnergy() + s->preshowerEnergy();
587 fVals[3] = 1.0045*p.
r9() +0.001;
588 fVals[5] = 1.04302*s->etaWidth() - 0.000618;
589 fVals[6] = 1.00002*s->phiWidth() - 0.000371;
590 fVals[14] = fVals[3]*s->rawEnergy()/b->energy();
594 fVals[4] = fVals[15]*b->energy()/s->rawEnergy();
599 fVals[19] = 1.012*bemax/b->energy();
600 fVals[20] = 1.0*be2nd/b->energy();
601 fVals[21] = 0.94*betop/b->energy();
602 fVals[22] = 0.94*bebottom/b->energy();
603 fVals[23] = 0.94*beleft/b->energy();
604 fVals[24] = 0.94*beright/b->energy();
605 fVals[25] = 1.006*be2x5max/b->energy();
606 fVals[26] = 1.09*be2x5top/b->energy();
607 fVals[27] = 1.09*be2x5bottom/b->energy();
608 fVals[28] = 1.09*be2x5left/b->energy();
609 fVals[29] = 1.09*be2x5right/b->energy();
613 fVals[3] = 1.0086*p.
r9() -0.0007;
615 fVals[5] = 0.903254*s->etaWidth() +0.001346;
616 fVals[6] = 0.99992*s->phiWidth() + 4.8e-07;
617 fVals[13] =
TMath::Min(1.0,1.0022*b->energy()/s->rawEnergy());
620 fVals[14] = fVals[3]*s->rawEnergy()/b->energy();
624 fVals[19] = 1.005*bemax/b->energy();
625 fVals[20] = 1.02*be2nd/b->energy();
626 fVals[21] = 0.96*betop/b->energy();
627 fVals[22] = 0.96*bebottom/b->energy();
628 fVals[23] = 0.96*beleft/b->energy();
629 fVals[24] = 0.96*beright/b->energy();
630 fVals[25] = 1.0075*be2x5max/b->energy();
631 fVals[26] = 1.13*be2x5top/b->energy();
632 fVals[27] = 1.13*be2x5bottom/b->energy();
633 fVals[28] = 1.13*be2x5left/b->energy();
634 fVals[29] = 1.13*be2x5right/b->energy();
639 Double_t ecorerr = readervar->
GetResponse(fVals)*den;
643 return std::pair<double,double>(ecor,ecorerr);
652 Bool_t isbarrel = b->hitsAndFractions().at(0).first.subdetId()==
EcalBarrel;
655 fVals[0] = s->rawEnergy();
658 fVals[3] = clustertools.
e3x3(*b)/s->rawEnergy();
659 fVals[4] = clustertools.
e5x5(*b)/s->rawEnergy();
660 fVals[5] = s->etaWidth();
661 fVals[6] = s->phiWidth();
662 fVals[7] = s->clustersSize();
665 fVals[10] = vtxcol.size();
668 double bemax = clustertools.
eMax(*b);
669 double be2nd = clustertools.
e2nd(*b);
670 double betop = clustertools.
eTop(*b);
671 double bebottom = clustertools.
eBottom(*b);
672 double beleft = clustertools.
eLeft(*b);
673 double beright = clustertools.
eRight(*b);
675 double be2x5max = clustertools.
e2x5Max(*b);
676 double be2x5top = clustertools.
e2x5Top(*b);
677 double be2x5bottom = clustertools.
e2x5Bottom(*b);
678 double be2x5left = clustertools.
e2x5Left(*b);
679 double be2x5right = clustertools.
e2x5Right(*b);
681 fVals[11] = b->eta()-s->eta();
683 fVals[13] = b->energy()/s->rawEnergy();
684 fVals[14] = clustertools.
e3x3(*b)/b->energy();
685 fVals[15] = clustertools.
e5x5(*b)/b->energy();
689 fVals[19] = bemax/b->energy();
690 fVals[20] = be2nd/b->energy();
691 fVals[21] = betop/b->energy();
692 fVals[22] = bebottom/b->energy();
693 fVals[23] = beleft/b->energy();
694 fVals[24] = beright/b->energy();
695 fVals[25] = be2x5max/b->energy();
696 fVals[26] = be2x5top/b->energy();
697 fVals[27] = be2x5bottom/b->energy();
698 fVals[28] = be2x5left/b->energy();
699 fVals[29] = be2x5right/b->energy();
705 float betacry, bphicry, bthetatilt, bphitilt;
713 fVals[34] = (TMath::Abs(bieta)<=25)*(bieta%25) + (TMath::Abs(bieta)>25)*((bieta-25*TMath::Abs(bieta)/bieta)%20);
714 fVals[35] = biphi%20;
721 fVals[30] = s->preshowerEnergy()/s->rawEnergy();
728 den = s->rawEnergy();
733 den = s->rawEnergy() + s->preshowerEnergy();
739 Double_t ecorerr = readervar->
GetResponse(fVals)*den;
743 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)
const GBRForest * fReaderee
const GBRForest * fReadereb
const GBRForest * fReaderebvariance
reco::SuperClusterRef superCluster() const
Ref to SuperCluster.
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)
bool isNonnull() const
Checks for non-null.
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
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