CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Attributes
EGEnergyCorrector Class Reference

#include <EGEnergyCorrector.h>

Public Member Functions

std::pair< double, double > CorrectedEnergyWithError (const reco::GsfElectron &e, const reco::VertexCollection &vtxcol, EcalClusterLazyTools &clustertools, const edm::EventSetup &es)
 
std::pair< double, double > CorrectedEnergyWithError (const reco::Photon &p, const reco::VertexCollection &vtxcol, EcalClusterLazyTools &clustertools, const edm::EventSetup &es)
 
std::pair< double, double > CorrectedEnergyWithErrorV3 (const reco::GsfElectron &e, const reco::VertexCollection &vtxcol, double rho, EcalClusterLazyTools &clustertools, const edm::EventSetup &es)
 
std::pair< double, double > CorrectedEnergyWithErrorV3 (const reco::Photon &p, const reco::VertexCollection &vtxcol, double rho, EcalClusterLazyTools &clustertools, const edm::EventSetup &es, bool applyRescale=false)
 
 EGEnergyCorrector ()
 
void Initialize (const edm::EventSetup &iSetup, std::string regweights, bool weightsFromDB=false)
 
Bool_t IsInitialized () const
 
 ~EGEnergyCorrector ()
 

Protected Attributes

Bool_t fIsInitialized
 
Bool_t fOwnsForests
 
const GBRForestfReadereb
 
const GBRForestfReaderebvariance
 
const GBRForestfReaderee
 
const GBRForestfReadereevariance
 
Float_t * fVals
 

Detailed Description

Definition at line 21 of file EGEnergyCorrector.h.

Constructor & Destructor Documentation

◆ EGEnergyCorrector()

EGEnergyCorrector::EGEnergyCorrector ( )

Definition at line 18 of file EGEnergyCorrector.cc.

19  : fReadereb(nullptr),
20  fReaderebvariance(nullptr),
21  fReaderee(nullptr),
22  fReadereevariance(nullptr),
23  fIsInitialized(kFALSE),
24  fOwnsForests(kFALSE),
25  fVals(nullptr) {
26  // Constructor.
27 }

◆ ~EGEnergyCorrector()

EGEnergyCorrector::~EGEnergyCorrector ( )

Definition at line 30 of file EGEnergyCorrector.cc.

30  {
31  if (fVals)
32  delete[] fVals;
33 
34  if (fOwnsForests) {
35  if (fReadereb)
36  delete fReadereb;
38  delete fReaderebvariance;
39  if (fReaderee)
40  delete fReaderee;
42  delete fReadereevariance;
43  }
44 }

References fOwnsForests, fReadereb, fReaderebvariance, fReaderee, fReadereevariance, and fVals.

Member Function Documentation

◆ CorrectedEnergyWithError() [1/2]

std::pair< double, double > EGEnergyCorrector::CorrectedEnergyWithError ( const reco::GsfElectron e,
const reco::VertexCollection vtxcol,
EcalClusterLazyTools clustertools,
const edm::EventSetup es 
)

Definition at line 292 of file EGEnergyCorrector.cc.

295  {
296  //apply v2 regression to electrons
297  //mostly duplicated from photon function above //TODO, make common underlying function
298 
299  //protection, this doesn't work properly on non-egamma-seeded electrons
300  if (!e.ecalDrivenSeed())
301  return std::pair<double, double>(0., 0.);
302 
303  const SuperClusterRef s = e.superCluster();
304  const CaloClusterPtr b = s->seed();
305 
307  Double_t ebcmax = -99.;
308  for (reco::CaloCluster_iterator bit = s->clustersBegin(); bit != s->clustersEnd(); ++bit) {
309  const CaloClusterPtr bc = *bit;
310  if (bc->energy() > ebcmax && bc != b) {
311  b2 = bc;
312  ebcmax = bc->energy();
313  }
314  }
315 
316  CaloClusterPtr bclast;
317  Double_t ebcmin = 1e6;
318  for (reco::CaloCluster_iterator bit = s->clustersBegin(); bit != s->clustersEnd(); ++bit) {
319  const CaloClusterPtr bc = *bit;
320  if (bc->energy() < ebcmin && bc != b) {
321  bclast = bc;
322  ebcmin = bc->energy();
323  }
324  }
325 
326  CaloClusterPtr bclast2;
327  ebcmin = 1e6;
328  for (reco::CaloCluster_iterator bit = s->clustersBegin(); bit != s->clustersEnd(); ++bit) {
329  const CaloClusterPtr bc = *bit;
330  if (bc->energy() < ebcmin && bc != b && bc != bclast) {
331  bclast2 = bc;
332  ebcmin = bc->energy();
333  }
334  }
335 
336  Bool_t isbarrel = b->hitsAndFractions().at(0).first.subdetId() == EcalBarrel;
337  Bool_t hasbc2 = b2.isNonnull() && b2->energy() > 0.;
338  Bool_t hasbclast = bclast.isNonnull() && bclast->energy() > 0.;
339  Bool_t hasbclast2 = bclast2.isNonnull() && bclast2->energy() > 0.;
340 
341  if (isbarrel) {
342  fVals[0] = s->rawEnergy();
343  fVals[1] = clustertools.e3x3(*b) / s->rawEnergy(); //r9
344  fVals[2] = s->eta();
345  fVals[3] = s->phi();
346  fVals[4] = clustertools.e5x5(*b) / s->rawEnergy();
347  fVals[5] = e.hcalOverEcal();
348  fVals[6] = s->etaWidth();
349  fVals[7] = s->phiWidth();
350 
351  double bemax = clustertools.eMax(*b);
352  double be2nd = clustertools.e2nd(*b);
353  double betop = clustertools.eTop(*b);
354  double bebottom = clustertools.eBottom(*b);
355  double beleft = clustertools.eLeft(*b);
356  double beright = clustertools.eRight(*b);
357 
358  fVals[8] = b->eta() - s->eta();
359  fVals[9] = reco::deltaPhi(b->phi(), s->phi());
360  fVals[10] = b->energy() / s->rawEnergy();
361  fVals[11] = clustertools.e3x3(*b) / b->energy();
362  fVals[12] = clustertools.e5x5(*b) / b->energy();
363  fVals[13] = sqrt(clustertools.localCovariances(*b)[0]);
364  fVals[14] = sqrt(clustertools.localCovariances(*b)[2]);
365  fVals[15] = clustertools.localCovariances(*b)[1];
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);
374 
375  double bc2emax = hasbc2 ? clustertools.eMax(*b2) : 0.;
376  double bc2e2nd = hasbc2 ? clustertools.e2nd(*b2) : 0.;
377  double bc2etop = hasbc2 ? clustertools.eTop(*b2) : 0.;
378  double bc2ebottom = hasbc2 ? clustertools.eBottom(*b2) : 0.;
379  double bc2eleft = hasbc2 ? clustertools.eLeft(*b2) : 0.;
380  double bc2eright = hasbc2 ? clustertools.eRight(*b2) : 0.;
381 
382  fVals[24] = hasbc2 ? (b2->eta() - s->eta()) : 0.;
383  fVals[25] = hasbc2 ? reco::deltaPhi(b2->phi(), s->phi()) : 0.;
384  fVals[26] = hasbc2 ? b2->energy() / s->rawEnergy() : 0.;
385  fVals[27] = hasbc2 ? clustertools.e3x3(*b2) / b2->energy() : 0.;
386  fVals[28] = hasbc2 ? clustertools.e5x5(*b2) / b2->energy() : 0.;
387  fVals[29] = hasbc2 ? sqrt(clustertools.localCovariances(*b2)[0]) : 0.;
388  fVals[30] = hasbc2 ? sqrt(clustertools.localCovariances(*b2)[2]) : 0.;
389  fVals[31] = hasbc2 ? clustertools.localCovariances(*b)[1] : 0.;
390  fVals[32] = hasbc2 ? bc2emax / b2->energy() : 0.;
391  fVals[33] = hasbc2 ? log(bc2e2nd / bc2emax) : 0.;
392  fVals[34] = hasbc2 ? log(bc2etop / bc2emax) : 0.;
393  fVals[35] = hasbc2 ? log(bc2ebottom / bc2emax) : 0.;
394  fVals[36] = hasbc2 ? log(bc2eleft / bc2emax) : 0.;
395  fVals[37] = hasbc2 ? log(bc2eright / bc2emax) : 0.;
396  fVals[38] = hasbc2 ? (bc2etop - bc2ebottom) / (bc2etop + bc2ebottom) : 0.;
397  fVals[39] = hasbc2 ? (bc2eleft - bc2eright) / (bc2eleft + bc2eright) : 0.;
398 
399  fVals[40] = hasbclast ? (bclast->eta() - s->eta()) : 0.;
400  fVals[41] = hasbclast ? reco::deltaPhi(bclast->phi(), s->phi()) : 0.;
401  fVals[42] = hasbclast ? bclast->energy() / s->rawEnergy() : 0.;
402  fVals[43] = hasbclast ? clustertools.e3x3(*bclast) / bclast->energy() : 0.;
403  fVals[44] = hasbclast ? clustertools.e5x5(*bclast) / bclast->energy() : 0.;
404  fVals[45] = hasbclast ? sqrt(clustertools.localCovariances(*bclast)[0]) : 0.;
405  fVals[46] = hasbclast ? sqrt(clustertools.localCovariances(*bclast)[2]) : 0.;
406  fVals[47] = hasbclast ? clustertools.localCovariances(*bclast)[1] : 0.;
407 
408  fVals[48] = hasbclast2 ? (bclast2->eta() - s->eta()) : 0.;
409  fVals[49] = hasbclast2 ? reco::deltaPhi(bclast2->phi(), s->phi()) : 0.;
410  fVals[50] = hasbclast2 ? bclast2->energy() / s->rawEnergy() : 0.;
411  fVals[51] = hasbclast2 ? clustertools.e3x3(*bclast2) / bclast2->energy() : 0.;
412  fVals[52] = hasbclast2 ? clustertools.e5x5(*bclast2) / bclast2->energy() : 0.;
413  fVals[53] = hasbclast2 ? sqrt(clustertools.localCovariances(*bclast2)[0]) : 0.;
414  fVals[54] = hasbclast2 ? sqrt(clustertools.localCovariances(*bclast2)[2]) : 0.;
415  fVals[55] = hasbclast2 ? clustertools.localCovariances(*bclast2)[1] : 0.;
416 
417  float betacry, bphicry, bthetatilt, bphitilt;
418  int bieta, biphi;
419  edm::ESHandle<CaloGeometry> caloGeometry;
420  es.get<CaloGeometryRecord>().get(caloGeometry);
421  egammaTools::localEcalClusterCoordsEB(*b, *caloGeometry, betacry, bphicry, bieta, biphi, bthetatilt, bphitilt);
422 
423  fVals[56] = bieta;
424  fVals[57] = biphi;
425  fVals[58] = bieta % 5;
426  fVals[59] = biphi % 2;
427  fVals[60] = (TMath::Abs(bieta) <= 25) * (bieta % 25) +
428  (TMath::Abs(bieta) > 25) * ((bieta - 25 * TMath::Abs(bieta) / bieta) % 20);
429  fVals[61] = biphi % 20;
430  fVals[62] = betacry;
431  fVals[63] = bphicry;
432 
433  float bc2etacry, bc2phicry, bc2thetatilt, bc2phitilt;
434  int bc2ieta, bc2iphi;
435  if (hasbc2)
437  *b2, *caloGeometry, bc2etacry, bc2phicry, bc2ieta, bc2iphi, bc2thetatilt, bc2phitilt);
438 
439  fVals[64] = hasbc2 ? bc2ieta : 0.;
440  fVals[65] = hasbc2 ? bc2iphi : 0.;
441  fVals[66] = hasbc2 ? bc2ieta % 5 : 0.;
442  fVals[67] = hasbc2 ? bc2iphi % 2 : 0.;
443  fVals[68] = hasbc2 ? (TMath::Abs(bc2ieta) <= 25) * (bc2ieta % 25) +
444  (TMath::Abs(bc2ieta) > 25) * ((bc2ieta - 25 * TMath::Abs(bc2ieta) / bc2ieta) % 20)
445  : 0.;
446  fVals[69] = hasbc2 ? bc2iphi % 20 : 0.;
447  fVals[70] = hasbc2 ? bc2etacry : 0.;
448  fVals[71] = hasbc2 ? bc2phicry : 0.;
449 
450  fVals[72] = vtxcol.size();
451 
452  } else {
453  fVals[0] = s->rawEnergy();
454  fVals[1] = clustertools.e3x3(*b) / s->rawEnergy(); //r9
455  fVals[2] = s->eta();
456  fVals[3] = s->phi();
457  fVals[4] = clustertools.e5x5(*b) / s->rawEnergy();
458  fVals[5] = s->etaWidth();
459  fVals[6] = s->phiWidth();
460  fVals[7] = vtxcol.size();
461  }
462 
463  const Double_t varscale = 1.253;
464  Double_t den;
465  const GBRForest *reader;
466  const GBRForest *readervar;
467  if (isbarrel) {
468  den = s->rawEnergy();
469  reader = fReadereb;
470  readervar = fReaderebvariance;
471  } else {
472  den = s->rawEnergy() + s->preshowerEnergy();
473  reader = fReaderee;
474  readervar = fReadereevariance;
475  }
476 
477  Double_t ecor = reader->GetResponse(fVals) * den;
478  Double_t ecorerr = readervar->GetResponse(fVals) * den * varscale;
479 
480  //printf("ecor = %5f, ecorerr = %5f\n",ecor,ecorerr);
481 
482  return std::pair<double, double>(ecor, ecorerr);
483 }

References Abs(), b, b2, reco::deltaPhi(), MillePedeFileConverter_cfg::e, EcalBarrel, reco::CaloCluster::energy(), reco::CaloCluster::eta(), fReadereb, fReaderebvariance, fReaderee, fReadereevariance, fVals, edm::EventSetup::get(), get, GBRForest::GetResponse(), edm::Ptr< T >::isNonnull(), egammaTools::localEcalClusterCoordsEB(), dqm-mbProfile::log, reco::CaloCluster::phi(), DQM::reader, alignCSCRings::s, and mathSSE::sqrt().

◆ CorrectedEnergyWithError() [2/2]

std::pair< double, double > EGEnergyCorrector::CorrectedEnergyWithError ( const reco::Photon p,
const reco::VertexCollection vtxcol,
EcalClusterLazyTools clustertools,
const edm::EventSetup es 
)

Definition at line 95 of file EGEnergyCorrector.cc.

98  {
99  const SuperClusterRef s = p.superCluster();
100  const CaloClusterPtr b = s->seed(); //seed basic cluster
101 
102  //highest energy basic cluster excluding seed basic cluster
104  Double_t ebcmax = -99.;
105  for (reco::CaloCluster_iterator bit = s->clustersBegin(); bit != s->clustersEnd(); ++bit) {
106  const CaloClusterPtr bc = *bit;
107  if (bc->energy() > ebcmax && bc != b) {
108  b2 = bc;
109  ebcmax = bc->energy();
110  }
111  }
112 
113  //lowest energy basic cluster excluding seed (for pileup mitigation)
114  CaloClusterPtr bclast;
115  Double_t ebcmin = 1e6;
116  for (reco::CaloCluster_iterator bit = s->clustersBegin(); bit != s->clustersEnd(); ++bit) {
117  const CaloClusterPtr bc = *bit;
118  if (bc->energy() < ebcmin && bc != b) {
119  bclast = bc;
120  ebcmin = bc->energy();
121  }
122  }
123 
124  //2nd lowest energy basic cluster excluding seed (for pileup mitigation)
125  CaloClusterPtr bclast2;
126  ebcmin = 1e6;
127  for (reco::CaloCluster_iterator bit = s->clustersBegin(); bit != s->clustersEnd(); ++bit) {
128  const CaloClusterPtr bc = *bit;
129  if (bc->energy() < ebcmin && bc != b && bc != bclast) {
130  bclast2 = bc;
131  ebcmin = bc->energy();
132  }
133  }
134 
135  Bool_t isbarrel = b->hitsAndFractions().at(0).first.subdetId() == EcalBarrel;
136  Bool_t hasbc2 = b2.isNonnull() && b2->energy() > 0.;
137  Bool_t hasbclast = bclast.isNonnull() && bclast->energy() > 0.;
138  Bool_t hasbclast2 = bclast2.isNonnull() && bclast2->energy() > 0.;
139 
140  if (isbarrel) {
141  //basic supercluster variables
142  fVals[0] = s->rawEnergy();
143  fVals[1] = p.r9();
144  fVals[2] = s->eta();
145  fVals[3] = s->phi();
146  fVals[4] = p.e5x5() / s->rawEnergy();
147  fVals[5] = p.hadronicOverEm();
148  fVals[6] = s->etaWidth();
149  fVals[7] = s->phiWidth();
150 
151  //seed basic cluster variables
152  double bemax = clustertools.eMax(*b);
153  double be2nd = clustertools.e2nd(*b);
154  double betop = clustertools.eTop(*b);
155  double bebottom = clustertools.eBottom(*b);
156  double beleft = clustertools.eLeft(*b);
157  double beright = clustertools.eRight(*b);
158 
159  fVals[8] = b->eta() - s->eta();
160  fVals[9] = reco::deltaPhi(b->phi(), s->phi());
161  fVals[10] = b->energy() / s->rawEnergy();
162  fVals[11] = clustertools.e3x3(*b) / b->energy();
163  fVals[12] = clustertools.e5x5(*b) / b->energy();
164  fVals[13] = sqrt(clustertools.localCovariances(*b)[0]); //sigietaieta
165  fVals[14] = sqrt(clustertools.localCovariances(*b)[2]); //sigiphiiphi
166  fVals[15] = clustertools.localCovariances(*b)[1]; //sigietaiphi
167  fVals[16] = bemax / b->energy(); //crystal energy ratio gap variables
168  fVals[17] = log(be2nd / bemax);
169  fVals[18] = log(betop / bemax);
170  fVals[19] = log(bebottom / bemax);
171  fVals[20] = log(beleft / bemax);
172  fVals[21] = log(beright / bemax);
173  fVals[22] = (betop - bebottom) / (betop + bebottom);
174  fVals[23] = (beleft - beright) / (beleft + beright);
175 
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.;
182 
183  fVals[24] = hasbc2 ? (b2->eta() - s->eta()) : 0.;
184  fVals[25] = hasbc2 ? reco::deltaPhi(b2->phi(), s->phi()) : 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.;
188  fVals[29] = hasbc2 ? sqrt(clustertools.localCovariances(*b2)[0]) : 0.;
189  fVals[30] = hasbc2 ? sqrt(clustertools.localCovariances(*b2)[2]) : 0.;
190  fVals[31] = hasbc2 ? clustertools.localCovariances(*b)[1] : 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.;
199 
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.;
205  fVals[45] = hasbclast ? sqrt(clustertools.localCovariances(*bclast)[0]) : 0.;
206  fVals[46] = hasbclast ? sqrt(clustertools.localCovariances(*bclast)[2]) : 0.;
207  fVals[47] = hasbclast ? clustertools.localCovariances(*bclast)[1] : 0.;
208 
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.;
214  fVals[53] = hasbclast2 ? sqrt(clustertools.localCovariances(*bclast2)[0]) : 0.;
215  fVals[54] = hasbclast2 ? sqrt(clustertools.localCovariances(*bclast2)[2]) : 0.;
216  fVals[55] = hasbclast2 ? clustertools.localCovariances(*bclast2)[1] : 0.;
217 
218  //local coordinates and crystal indices
219 
220  //seed cluster
221  float betacry, bphicry, bthetatilt, bphitilt;
222  int bieta, biphi;
223  edm::ESHandle<CaloGeometry> caloGeometry;
224  es.get<CaloGeometryRecord>().get(caloGeometry);
225  egammaTools::localEcalClusterCoordsEB(*b, *caloGeometry, betacry, bphicry, bieta, biphi, bthetatilt, bphitilt);
226 
227  fVals[56] = bieta; //crystal ieta
228  fVals[57] = biphi; //crystal iphi
229  fVals[58] = bieta % 5; //submodule boundary eta symmetry
230  fVals[59] = biphi % 2; //submodule boundary phi symmetry
231  fVals[60] = (TMath::Abs(bieta) <= 25) * (bieta % 25) +
232  (TMath::Abs(bieta) > 25) *
233  ((bieta - 25 * TMath::Abs(bieta) / bieta) % 20); //module boundary eta approximate symmetry
234  fVals[61] = biphi % 20; //module boundary phi symmetry
235  fVals[62] = betacry; //local coordinates with respect to closest crystal center at nominal shower depth
236  fVals[63] = bphicry;
237 
238  //2nd cluster (meaningful gap corrections for converted photons)
239  float bc2etacry, bc2phicry, bc2thetatilt, bc2phitilt;
240  int bc2ieta, bc2iphi;
241  if (hasbc2)
243  *b2, *caloGeometry, bc2etacry, bc2phicry, bc2ieta, bc2iphi, bc2thetatilt, bc2phitilt);
244 
245  fVals[64] = hasbc2 ? bc2ieta : 0.;
246  fVals[65] = hasbc2 ? bc2iphi : 0.;
247  fVals[66] = hasbc2 ? bc2ieta % 5 : 0.;
248  fVals[67] = hasbc2 ? bc2iphi % 2 : 0.;
249  fVals[68] = hasbc2 ? (TMath::Abs(bc2ieta) <= 25) * (bc2ieta % 25) +
250  (TMath::Abs(bc2ieta) > 25) * ((bc2ieta - 25 * TMath::Abs(bc2ieta) / bc2ieta) % 20)
251  : 0.;
252  fVals[69] = hasbc2 ? bc2iphi % 20 : 0.;
253  fVals[70] = hasbc2 ? bc2etacry : 0.;
254  fVals[71] = hasbc2 ? bc2phicry : 0.;
255 
256  fVals[72] = vtxcol.size();
257 
258  } else {
259  fVals[0] = s->rawEnergy();
260  fVals[1] = p.r9();
261  fVals[2] = s->eta();
262  fVals[3] = s->phi();
263  fVals[4] = p.e5x5() / s->rawEnergy();
264  fVals[5] = s->etaWidth();
265  fVals[6] = s->phiWidth();
266  fVals[7] = vtxcol.size();
267  }
268 
269  const Double_t varscale = 1.253;
270  Double_t den;
271  const GBRForest *reader;
272  const GBRForest *readervar;
273  if (isbarrel) {
274  den = s->rawEnergy();
275  reader = fReadereb;
276  readervar = fReaderebvariance;
277  } else {
278  den = s->rawEnergy() + s->preshowerEnergy();
279  reader = fReaderee;
280  readervar = fReadereevariance;
281  }
282 
283  Double_t ecor = reader->GetResponse(fVals) * den;
284  Double_t ecorerr = readervar->GetResponse(fVals) * den * varscale;
285 
286  //printf("ecor = %5f, ecorerr = %5f\n",ecor,ecorerr);
287 
288  return std::pair<double, double>(ecor, ecorerr);
289 }

References Abs(), b, b2, reco::deltaPhi(), EcalBarrel, reco::CaloCluster::energy(), reco::CaloCluster::eta(), fReadereb, fReaderebvariance, fReaderee, fReadereevariance, fVals, edm::EventSetup::get(), get, GBRForest::GetResponse(), edm::Ptr< T >::isNonnull(), egammaTools::localEcalClusterCoordsEB(), dqm-mbProfile::log, AlCaHLTBitMon_ParallelJobs::p, reco::CaloCluster::phi(), DQM::reader, alignCSCRings::s, and mathSSE::sqrt().

Referenced by EGEnergyAnalyzer::analyze().

◆ CorrectedEnergyWithErrorV3() [1/2]

std::pair< double, double > EGEnergyCorrector::CorrectedEnergyWithErrorV3 ( const reco::GsfElectron e,
const reco::VertexCollection vtxcol,
double  rho,
EcalClusterLazyTools clustertools,
const edm::EventSetup es 
)

Definition at line 652 of file EGEnergyCorrector.cc.

656  {
657  const SuperClusterRef s = e.superCluster();
658  const CaloClusterPtr b = s->seed(); //seed basic cluster
659 
660  Bool_t isbarrel = b->hitsAndFractions().at(0).first.subdetId() == EcalBarrel;
661 
662  //basic supercluster variables
663  fVals[0] = s->rawEnergy();
664  fVals[1] = s->eta();
665  fVals[2] = s->phi();
666  fVals[3] = clustertools.e3x3(*b) / s->rawEnergy(); //r9
667  fVals[4] = clustertools.e5x5(*b) / s->rawEnergy();
668  fVals[5] = s->etaWidth();
669  fVals[6] = s->phiWidth();
670  fVals[7] = s->clustersSize();
671  fVals[8] = e.hcalOverEcalBc();
672  fVals[9] = rho;
673  fVals[10] = vtxcol.size();
674 
675  //seed basic cluster variables
676  double bemax = clustertools.eMax(*b);
677  double be2nd = clustertools.e2nd(*b);
678  double betop = clustertools.eTop(*b);
679  double bebottom = clustertools.eBottom(*b);
680  double beleft = clustertools.eLeft(*b);
681  double beright = clustertools.eRight(*b);
682 
683  double be2x5max = clustertools.e2x5Max(*b);
684  double be2x5top = clustertools.e2x5Top(*b);
685  double be2x5bottom = clustertools.e2x5Bottom(*b);
686  double be2x5left = clustertools.e2x5Left(*b);
687  double be2x5right = clustertools.e2x5Right(*b);
688 
689  fVals[11] = b->eta() - s->eta();
690  fVals[12] = reco::deltaPhi(b->phi(), s->phi());
691  fVals[13] = b->energy() / s->rawEnergy();
692  fVals[14] = clustertools.e3x3(*b) / b->energy();
693  fVals[15] = clustertools.e5x5(*b) / b->energy();
694  fVals[16] = sqrt(clustertools.localCovariances(*b)[0]); //sigietaieta
695  fVals[17] = sqrt(clustertools.localCovariances(*b)[2]); //sigiphiiphi
696  fVals[18] = clustertools.localCovariances(*b)[1]; //sigietaiphi
697  fVals[19] = bemax / b->energy(); //crystal energy ratio gap variables
698  fVals[20] = be2nd / b->energy();
699  fVals[21] = betop / b->energy();
700  fVals[22] = bebottom / b->energy();
701  fVals[23] = beleft / b->energy();
702  fVals[24] = beright / b->energy();
703  fVals[25] = be2x5max / b->energy(); //crystal energy ratio gap variables
704  fVals[26] = be2x5top / b->energy();
705  fVals[27] = be2x5bottom / b->energy();
706  fVals[28] = be2x5left / b->energy();
707  fVals[29] = be2x5right / b->energy();
708 
709  if (isbarrel) {
710  //local coordinates and crystal indices (barrel only)
711 
712  //seed cluster
713  float betacry, bphicry, bthetatilt, bphitilt;
714  int bieta, biphi;
715  edm::ESHandle<CaloGeometry> caloGeometry;
716  es.get<CaloGeometryRecord>().get(caloGeometry);
717  egammaTools::localEcalClusterCoordsEB(*b, *caloGeometry, betacry, bphicry, bieta, biphi, bthetatilt, bphitilt);
718 
719  fVals[30] = bieta; //crystal ieta
720  fVals[31] = biphi; //crystal iphi
721  fVals[32] = bieta % 5; //submodule boundary eta symmetry
722  fVals[33] = biphi % 2; //submodule boundary phi symmetry
723  fVals[34] = (TMath::Abs(bieta) <= 25) * (bieta % 25) +
724  (TMath::Abs(bieta) > 25) *
725  ((bieta - 25 * TMath::Abs(bieta) / bieta) % 20); //module boundary eta approximate symmetry
726  fVals[35] = biphi % 20; //module boundary phi symmetry
727  fVals[36] = betacry; //local coordinates with respect to closest crystal center at nominal shower depth
728  fVals[37] = bphicry;
729 
730  } else {
731  //preshower energy ratio (endcap only)
732  fVals[30] = s->preshowerEnergy() / s->rawEnergy();
733  }
734 
735  Double_t den;
736  const GBRForest *reader;
737  const GBRForest *readervar;
738  if (isbarrel) {
739  den = s->rawEnergy();
740  reader = fReadereb;
741  readervar = fReaderebvariance;
742  } else {
743  den = s->rawEnergy() + s->preshowerEnergy();
744  reader = fReaderee;
745  readervar = fReadereevariance;
746  }
747 
748  Double_t ecor = reader->GetResponse(fVals) * den;
749  Double_t ecorerr = readervar->GetResponse(fVals) * den;
750 
751  //printf("ecor = %5f, ecorerr = %5f\n",ecor,ecorerr);
752 
753  return std::pair<double, double>(ecor, ecorerr);
754 }

References Abs(), b, reco::deltaPhi(), MillePedeFileConverter_cfg::e, EcalBarrel, fReadereb, fReaderebvariance, fReaderee, fReadereevariance, fVals, edm::EventSetup::get(), get, GBRForest::GetResponse(), egammaTools::localEcalClusterCoordsEB(), DQM::reader, rho, alignCSCRings::s, and mathSSE::sqrt().

◆ CorrectedEnergyWithErrorV3() [2/2]

std::pair< double, double > EGEnergyCorrector::CorrectedEnergyWithErrorV3 ( const reco::Photon p,
const reco::VertexCollection vtxcol,
double  rho,
EcalClusterLazyTools clustertools,
const edm::EventSetup es,
bool  applyRescale = false 
)

Definition at line 486 of file EGEnergyCorrector.cc.

491  {
492  const SuperClusterRef s = p.superCluster();
493  const CaloClusterPtr b = s->seed(); //seed basic cluster
494 
495  Bool_t isbarrel = b->hitsAndFractions().at(0).first.subdetId() == EcalBarrel;
496 
497  //basic supercluster variables
498  fVals[0] = s->rawEnergy();
499  fVals[1] = s->eta();
500  fVals[2] = s->phi();
501  fVals[3] = p.r9();
502  fVals[4] = p.e5x5() / s->rawEnergy();
503  fVals[5] = s->etaWidth();
504  fVals[6] = s->phiWidth();
505  fVals[7] = s->clustersSize();
506  fVals[8] = p.hadTowOverEm();
507  fVals[9] = rho;
508  fVals[10] = vtxcol.size();
509 
510  //seed basic cluster variables
511  double bemax = clustertools.eMax(*b);
512  double be2nd = clustertools.e2nd(*b);
513  double betop = clustertools.eTop(*b);
514  double bebottom = clustertools.eBottom(*b);
515  double beleft = clustertools.eLeft(*b);
516  double beright = clustertools.eRight(*b);
517 
518  double be2x5max = clustertools.e2x5Max(*b);
519  double be2x5top = clustertools.e2x5Top(*b);
520  double be2x5bottom = clustertools.e2x5Bottom(*b);
521  double be2x5left = clustertools.e2x5Left(*b);
522  double be2x5right = clustertools.e2x5Right(*b);
523 
524  fVals[11] = b->eta() - s->eta();
525  fVals[12] = reco::deltaPhi(b->phi(), s->phi());
526  fVals[13] = b->energy() / s->rawEnergy();
527  fVals[14] = clustertools.e3x3(*b) / b->energy();
528  fVals[15] = clustertools.e5x5(*b) / b->energy();
529  fVals[16] = sqrt(clustertools.localCovariances(*b)[0]); //sigietaieta
530  fVals[17] = sqrt(clustertools.localCovariances(*b)[2]); //sigiphiiphi
531  fVals[18] = clustertools.localCovariances(*b)[1]; //sigietaiphi
532  fVals[19] = bemax / b->energy(); //crystal energy ratio gap variables
533  fVals[20] = be2nd / b->energy();
534  fVals[21] = betop / b->energy();
535  fVals[22] = bebottom / b->energy();
536  fVals[23] = beleft / b->energy();
537  fVals[24] = beright / b->energy();
538  fVals[25] = be2x5max / b->energy(); //crystal energy ratio gap variables
539  fVals[26] = be2x5top / b->energy();
540  fVals[27] = be2x5bottom / b->energy();
541  fVals[28] = be2x5left / b->energy();
542  fVals[29] = be2x5right / b->energy();
543 
544  if (isbarrel) {
545  //local coordinates and crystal indices (barrel only)
546 
547  //seed cluster
548  float betacry, bphicry, bthetatilt, bphitilt;
549  int bieta, biphi;
550  edm::ESHandle<CaloGeometry> caloGeometry;
551  es.get<CaloGeometryRecord>().get(caloGeometry);
552  egammaTools::localEcalClusterCoordsEB(*b, *caloGeometry, betacry, bphicry, bieta, biphi, bthetatilt, bphitilt);
553 
554  fVals[30] = bieta; //crystal ieta
555  fVals[31] = biphi; //crystal iphi
556  fVals[32] = bieta % 5; //submodule boundary eta symmetry
557  fVals[33] = biphi % 2; //submodule boundary phi symmetry
558  fVals[34] = (TMath::Abs(bieta) <= 25) * (bieta % 25) +
559  (TMath::Abs(bieta) > 25) *
560  ((bieta - 25 * TMath::Abs(bieta) / bieta) % 20); //module boundary eta approximate symmetry
561  fVals[35] = biphi % 20; //module boundary phi symmetry
562  fVals[36] = betacry; //local coordinates with respect to closest crystal center at nominal shower depth
563  fVals[37] = bphicry;
564 
565  } else {
566  //preshower energy ratio (endcap only)
567  fVals[30] = s->preshowerEnergy() / s->rawEnergy();
568  }
569 
570  // if (isbarrel) {
571  // for (int i=0; i<38; ++i) printf("%i: %5f\n",i,fVals[i]);
572  // }
573  // else for (int i=0; i<31; ++i) printf("%i: %5f\n",i,fVals[i]);
574 
575  Double_t den;
576  const GBRForest *reader;
577  const GBRForest *readervar;
578  if (isbarrel) {
579  den = s->rawEnergy();
580  reader = fReadereb;
581  readervar = fReaderebvariance;
582  } else {
583  den = s->rawEnergy() + s->preshowerEnergy();
584  reader = fReaderee;
585  readervar = fReadereevariance;
586  }
587 
588  Double_t ecor = reader->GetResponse(fVals) * den;
589 
590  //apply shower shape rescaling - for Monte Carlo only, and only for calculation of energy uncertainty
591  if (applyRescale) {
592  if (isbarrel) {
593  fVals[3] = 1.0045 * p.r9() + 0.001; //r9
594  fVals[5] = 1.04302 * s->etaWidth() - 0.000618; //etawidth
595  fVals[6] = 1.00002 * s->phiWidth() - 0.000371; //phiwidth
596  fVals[14] = fVals[3] * s->rawEnergy() / b->energy(); //compute consistent e3x3/eseed after r9 rescaling
597  if (fVals[15] <= 1.0) // rescale e5x5/eseed only if value is <=1.0, don't allow scaled values to exceed 1.0
598  fVals[15] = TMath::Min(1.0, 1.0022 * p.e5x5() / b->energy());
599 
600  fVals[4] =
601  fVals[15] * b->energy() / s->rawEnergy(); // compute consistent e5x5()/rawEnergy() after e5x5/eseed resacling
602 
603  fVals[16] = 0.891832 * sqrt(clustertools.localCovariances(*b)[0]) + 0.0009133; //sigietaieta
604  fVals[17] = 0.993 * sqrt(clustertools.localCovariances(*b)[2]); //sigiphiiphi
605 
606  fVals[19] = 1.012 * bemax / b->energy(); //crystal energy ratio gap variables
607  fVals[20] = 1.0 * be2nd / b->energy();
608  fVals[21] = 0.94 * betop / b->energy();
609  fVals[22] = 0.94 * bebottom / b->energy();
610  fVals[23] = 0.94 * beleft / b->energy();
611  fVals[24] = 0.94 * beright / b->energy();
612  fVals[25] = 1.006 * be2x5max / b->energy(); //crystal energy ratio gap variables
613  fVals[26] = 1.09 * be2x5top / b->energy();
614  fVals[27] = 1.09 * be2x5bottom / b->energy();
615  fVals[28] = 1.09 * be2x5left / b->energy();
616  fVals[29] = 1.09 * be2x5right / b->energy();
617 
618  } else {
619  fVals[3] = 1.0086 * p.r9() - 0.0007; //r9
620  fVals[4] = TMath::Min(1.0, 1.0022 * p.e5x5() / s->rawEnergy()); //e5x5/rawenergy
621  fVals[5] = 0.903254 * s->etaWidth() + 0.001346; //etawidth
622  fVals[6] = 0.99992 * s->phiWidth() + 4.8e-07; //phiwidth
623  fVals[13] =
624  TMath::Min(1.0, 1.0022 * b->energy() / s->rawEnergy()); //eseed/rawenergy (practically equivalent to e5x5)
625 
626  fVals[14] = fVals[3] * s->rawEnergy() / b->energy(); //compute consistent e3x3/eseed after r9 rescaling
627 
628  fVals[16] = 0.9947 * sqrt(clustertools.localCovariances(*b)[0]) + 0.00003; //sigietaieta
629 
630  fVals[19] = 1.005 * bemax / b->energy(); //crystal energy ratio gap variables
631  fVals[20] = 1.02 * be2nd / b->energy();
632  fVals[21] = 0.96 * betop / b->energy();
633  fVals[22] = 0.96 * bebottom / b->energy();
634  fVals[23] = 0.96 * beleft / b->energy();
635  fVals[24] = 0.96 * beright / b->energy();
636  fVals[25] = 1.0075 * be2x5max / b->energy(); //crystal energy ratio gap variables
637  fVals[26] = 1.13 * be2x5top / b->energy();
638  fVals[27] = 1.13 * be2x5bottom / b->energy();
639  fVals[28] = 1.13 * be2x5left / b->energy();
640  fVals[29] = 1.13 * be2x5right / b->energy();
641  }
642  }
643 
644  Double_t ecorerr = readervar->GetResponse(fVals) * den;
645 
646  //printf("ecor = %5f, ecorerr = %5f\n",ecor,ecorerr);
647 
648  return std::pair<double, double>(ecor, ecorerr);
649 }

References Abs(), b, reco::deltaPhi(), EcalBarrel, fReadereb, fReaderebvariance, fReaderee, fReadereevariance, fVals, edm::EventSetup::get(), get, GBRForest::GetResponse(), egammaTools::localEcalClusterCoordsEB(), Min(), AlCaHLTBitMon_ParallelJobs::p, DQM::reader, rho, alignCSCRings::s, and mathSSE::sqrt().

◆ Initialize()

void EGEnergyCorrector::Initialize ( const edm::EventSetup iSetup,
std::string  regweights,
bool  weightsFromDB = false 
)

Definition at line 47 of file EGEnergyCorrector.cc.

47  {
48  fIsInitialized = kTRUE;
49 
50  if (fVals)
51  delete[] fVals;
52  if (fOwnsForests) {
53  if (fReadereb)
54  delete fReadereb;
56  delete fReaderebvariance;
57  if (fReaderee)
58  delete fReaderee;
60  delete fReadereevariance;
61  }
62 
63  fVals = new Float_t[73];
64 
65  if (weightsFromDB) { //weights from event setup
66 
67  edm::ESHandle<GBRForest> readereb;
68  edm::ESHandle<GBRForest> readerebvar;
69  edm::ESHandle<GBRForest> readeree;
70  edm::ESHandle<GBRForest> readereevar;
71 
72  iSetup.get<GBRWrapperRcd>().get(regweights + "_EBCorrection", readereb);
73  iSetup.get<GBRWrapperRcd>().get(regweights + "_EBUncertainty", readerebvar);
74  iSetup.get<GBRWrapperRcd>().get(regweights + "_EECorrection", readeree);
75  iSetup.get<GBRWrapperRcd>().get(regweights + "_EEUncertainty", readereevar);
76 
77  fReadereb = readereb.product();
78  fReaderebvariance = readerebvar.product();
79  fReaderee = readeree.product();
80  fReadereevariance = readereevar.product();
81 
82  } else { //weights from root file
83  fOwnsForests = kTRUE;
84 
85  TFile *fgbr = TFile::Open(regweights.c_str(), "READ");
86  fReadereb = (GBRForest *)fgbr->Get("EBCorrection");
87  fReaderebvariance = (GBRForest *)fgbr->Get("EBUncertainty");
88  fReaderee = (GBRForest *)fgbr->Get("EECorrection");
89  fReadereevariance = (GBRForest *)fgbr->Get("EEUncertainty");
90  fgbr->Close();
91  }
92 }

References fIsInitialized, fOwnsForests, fReadereb, fReaderebvariance, fReaderee, fReadereevariance, fVals, edm::EventSetup::get(), get, and edm::ESHandle< T >::product().

Referenced by EGEnergyAnalyzer::analyze().

◆ IsInitialized()

Bool_t EGEnergyCorrector::IsInitialized ( ) const
inline

Definition at line 27 of file EGEnergyCorrector.h.

27 { return fIsInitialized; }

References fIsInitialized.

Referenced by EGEnergyAnalyzer::analyze().

Member Data Documentation

◆ fIsInitialized

Bool_t EGEnergyCorrector::fIsInitialized
protected

Definition at line 56 of file EGEnergyCorrector.h.

Referenced by Initialize(), and IsInitialized().

◆ fOwnsForests

Bool_t EGEnergyCorrector::fOwnsForests
protected

Definition at line 57 of file EGEnergyCorrector.h.

Referenced by Initialize(), and ~EGEnergyCorrector().

◆ fReadereb

const GBRForest* EGEnergyCorrector::fReadereb
protected

◆ fReaderebvariance

const GBRForest* EGEnergyCorrector::fReaderebvariance
protected

◆ fReaderee

const GBRForest* EGEnergyCorrector::fReaderee
protected

◆ fReadereevariance

const GBRForest* EGEnergyCorrector::fReadereevariance
protected

◆ fVals

Float_t* EGEnergyCorrector::fVals
protected
reco::CaloCluster::phi
double phi() const
azimuthal angle of cluster centroid
Definition: CaloCluster.h:184
EGEnergyCorrector::fReadereb
const GBRForest * fReadereb
Definition: EGEnergyCorrector.h:51
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
reco::deltaPhi
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
GBRForest
Definition: GBRForest.h:25
edm::PtrVectorItr
Definition: PtrVector.h:51
EGEnergyCorrector::fReaderebvariance
const GBRForest * fReaderebvariance
Definition: EGEnergyCorrector.h:52
b2
static constexpr float b2
Definition: L1EGammaCrystalsEmulatorProducer.cc:83
EcalBarrel
Definition: EcalSubdetector.h:10
edm::Ref< SuperClusterCollection >
GBRForest::GetResponse
double GetResponse(const float *vector) const
Definition: GBRForest.h:49
alignCSCRings.s
s
Definition: alignCSCRings.py:92
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
Abs
T Abs(T a)
Definition: MathUtil.h:49
DQM.reader
reader
Definition: DQM.py:105
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
edm::ESHandle< CaloGeometry >
b
double b
Definition: hdecay.h:118
DDAxes::rho
egammaTools::localEcalClusterCoordsEB
void localEcalClusterCoordsEB(const reco::CaloCluster &bclus, const CaloGeometry &geom, float &etacry, float &phicry, int &ieta, int &iphi, float &thetatilt, float &phitilt)
Definition: EcalClusterLocal.cc:14
reco::CaloCluster::eta
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:181
EGEnergyCorrector::fVals
Float_t * fVals
Definition: EGEnergyCorrector.h:58
EGEnergyCorrector::fOwnsForests
Bool_t fOwnsForests
Definition: EGEnergyCorrector.h:57
EGEnergyCorrector::fIsInitialized
Bool_t fIsInitialized
Definition: EGEnergyCorrector.h:56
get
#define get
edm::Ptr< CaloCluster >
GBRWrapperRcd
Definition: GBRWrapperRcd.h:24
edm::Ptr::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:146
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
EGEnergyCorrector::fReadereevariance
const GBRForest * fReadereevariance
Definition: EGEnergyCorrector.h:54
Min
T Min(T a, T b)
Definition: MathUtil.h:39
reco::CaloCluster::energy
double energy() const
cluster energy
Definition: CaloCluster.h:149
EGEnergyCorrector::fReaderee
const GBRForest * fReaderee
Definition: EGEnergyCorrector.h:53
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37