CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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::Photon &p, const reco::VertexCollection &vtxcol, EcalClusterLazyTools &clustertools, const edm::EventSetup &es)
 
std::pair< double, double > CorrectedEnergyWithError (const reco::GsfElectron &e, const reco::VertexCollection &vtxcol, EcalClusterLazyTools &clustertools, const edm::EventSetup &es)
 
 EGEnergyCorrector ()
 
void Initialize (const edm::EventSetup &iSetup, std::string regweights, bool weightsFromDB=false)
 
Bool_t IsInitialized () const
 
 ~EGEnergyCorrector ()
 

Protected Attributes

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

Detailed Description

Definition at line 23 of file EGEnergyCorrector.h.

Constructor & Destructor Documentation

EGEnergyCorrector::EGEnergyCorrector ( )

Definition at line 18 of file EGEnergyCorrector.cc.

18  :
19 fReadereb(0),
21 fReaderee(0),
23 fIsInitialized(kFALSE),
24 fOwnsForests(kFALSE),
25 fVals(0)
26 {
27  // Constructor.
28 }
const GBRForest * fReaderee
const GBRForest * fReadereb
const GBRForest * fReaderebvariance
const GBRForest * fReadereevariance
EGEnergyCorrector::~EGEnergyCorrector ( )

Definition at line 32 of file EGEnergyCorrector.cc.

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

33 {
34 
35  if (fVals) delete [] fVals;
36 
37  if (fOwnsForests) {
38  if (fReadereb) delete fReadereb;
40  if (fReaderee) delete fReaderee;
42  }
43 
44 }
const GBRForest * fReaderee
const GBRForest * fReadereb
const GBRForest * fReaderebvariance
const GBRForest * fReadereevariance

Member Function Documentation

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

Definition at line 92 of file EGEnergyCorrector.cc.

References _ecalLocal, b, reco::deltaPhi(), EcalClusterLazyTools::e2nd(), EcalClusterLazyTools::e3x3(), EcalClusterLazyTools::e5x5(), reco::Photon::e5x5(), EcalClusterLazyTools::eBottom(), EcalBarrel, EcalClusterLazyTools::eLeft(), EcalClusterLazyTools::eMax(), EcalClusterLazyTools::eRight(), EcalClusterLazyTools::eTop(), fReadereb, fReaderebvariance, fReaderee, fReadereevariance, fVals, GBRForest::GetResponse(), reco::Photon::hadronicOverEm(), edm::Ptr< T >::isNonnull(), EcalClusterLocal::localCoordsEB(), EcalClusterLazyTools::localCovariances(), create_public_lumi_plots::log, reco::Photon::r9(), matplotRender::reader, alignCSCRings::s, mathSSE::sqrt(), and reco::Photon::superCluster().

Referenced by EGEnergyAnalyzer::analyze(), and PhotonEnergyCorrector::calculate().

92  {
93 
94  const SuperClusterRef s = p.superCluster();
95  const CaloClusterPtr b = s->seed(); //seed basic cluster
96 
97  //highest energy basic cluster excluding seed basic cluster
98  CaloClusterPtr b2;
99  Double_t ebcmax = -99.;
100  for (reco::CaloCluster_iterator bit = s->clustersBegin(); bit!=s->clustersEnd(); ++bit) {
101  const CaloClusterPtr bc = *bit;
102  if (bc->energy() > ebcmax && bc !=b) {
103  b2 = bc;
104  ebcmax = bc->energy();
105  }
106  }
107 
108  //lowest energy basic cluster excluding seed (for pileup mitigation)
109  CaloClusterPtr bclast;
110  Double_t ebcmin = 1e6;
111  for (reco::CaloCluster_iterator bit = s->clustersBegin(); bit!=s->clustersEnd(); ++bit) {
112  const CaloClusterPtr bc = *bit;
113  if (bc->energy() < ebcmin && bc !=b) {
114  bclast = bc;
115  ebcmin = bc->energy();
116  }
117  }
118 
119  //2nd lowest energy basic cluster excluding seed (for pileup mitigation)
120  CaloClusterPtr bclast2;
121  ebcmin = 1e6;
122  for (reco::CaloCluster_iterator bit = s->clustersBegin(); bit!=s->clustersEnd(); ++bit) {
123  const CaloClusterPtr bc = *bit;
124  if (bc->energy() < ebcmin && bc !=b && bc!=bclast) {
125  bclast2 = bc;
126  ebcmin = bc->energy();
127  }
128  }
129 
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.;
134 
135 
136  if (isbarrel) {
137 
138  //basic supercluster variables
139  fVals[0] = s->rawEnergy();
140  fVals[1] = p.r9();
141  fVals[2] = s->eta();
142  fVals[3] = s->phi();
143  fVals[4] = p.e5x5()/s->rawEnergy();
144  fVals[5] = p.hadronicOverEm();
145  fVals[6] = s->etaWidth();
146  fVals[7] = s->phiWidth();
147 
148 
149  //seed basic cluster variables
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);
156 
157 
158  fVals[8] = b->eta()-s->eta();
159  fVals[9] = reco::deltaPhi(b->phi(),s->phi());
160  fVals[10] = b->energy()/s->rawEnergy();
161  fVals[11] = clustertools.e3x3(*b)/b->energy();
162  fVals[12] = clustertools.e5x5(*b)/b->energy();
163  fVals[13] = sqrt(clustertools.localCovariances(*b)[0]); //sigietaieta
164  fVals[14] = sqrt(clustertools.localCovariances(*b)[2]); //sigiphiiphi
165  fVals[15] = clustertools.localCovariances(*b)[1]; //sigietaiphi
166  fVals[16] = bemax/b->energy(); //crystal energy ratio gap variables
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);
174 
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 
219  //local coordinates and crystal indices
220 
221 
222  //seed cluster
223  float betacry, bphicry, bthetatilt, bphitilt;
224  int bieta, biphi;
225  _ecalLocal.localCoordsEB(*b,es,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) + (TMath::Abs(bieta)>25)*((bieta-25*TMath::Abs(bieta)/bieta)%20); //module boundary eta approximate symmetry
232  fVals[61] = biphi%20; //module boundary phi symmetry
233  fVals[62] = betacry; //local coordinates with respect to closest crystal center at nominal shower depth
234  fVals[63] = bphicry;
235 
236 
237  //2nd cluster (meaningful gap corrections for converted photons)
238  float bc2etacry, bc2phicry, bc2thetatilt, bc2phitilt;
239  int bc2ieta, bc2iphi;
240  if (hasbc2) _ecalLocal.localCoordsEB(*b2,es,bc2etacry,bc2phicry,bc2ieta,bc2iphi,bc2thetatilt,bc2phitilt);
241 
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.;
250 
251  fVals[72] = vtxcol.size();
252 
253  }
254  else {
255  fVals[0] = s->rawEnergy();
256  fVals[1] = p.r9();
257  fVals[2] = s->eta();
258  fVals[3] = s->phi();
259  fVals[4] = p.e5x5()/s->rawEnergy();
260  fVals[5] = s->etaWidth();
261  fVals[6] = s->phiWidth();
262  fVals[7] = vtxcol.size();
263  }
264 
265 
266  const Double_t varscale = 1.253;
267  Double_t den;
268  const GBRForest *reader;
269  const GBRForest *readervar;
270  if (isbarrel) {
271  den = s->rawEnergy();
272  reader = fReadereb;
273  readervar = fReaderebvariance;
274  }
275  else {
276  den = s->rawEnergy() + s->preshowerEnergy();
277  reader = fReaderee;
278  readervar = fReadereevariance;
279  }
280 
281  Double_t ecor = reader->GetResponse(fVals)*den;
282  Double_t ecorerr = readervar->GetResponse(fVals)*den*varscale;
283 
284  //printf("ecor = %5f, ecorerr = %5f\n",ecor,ecorerr);
285 
286  return std::pair<double,double>(ecor,ecorerr);
287 }
std::vector< float > localCovariances(const reco::BasicCluster &cluster, float w0=4.7)
double GetResponse(const float *vector) const
Definition: GBRForest.h:51
float eBottom(const reco::BasicCluster &cluster)
float e2nd(const reco::BasicCluster &cluster)
float e5x5() const
Definition: Photon.h:185
const GBRForest * fReaderee
const GBRForest * fReadereb
const GBRForest * fReaderebvariance
float eRight(const reco::BasicCluster &cluster)
float e3x3(const reco::BasicCluster &cluster)
float eMax(const reco::BasicCluster &cluster)
reco::SuperClusterRef superCluster() const
Ref to SuperCluster.
Definition: Photon.cc:59
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:152
T sqrt(T t)
Definition: SSEVec.h:48
float hadronicOverEm() const
the total hadronic over electromagnetic fraction
Definition: Photon.h:167
float eTop(const reco::BasicCluster &cluster)
double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:12
float e5x5(const reco::BasicCluster &cluster)
float eLeft(const reco::BasicCluster &cluster)
double b
Definition: hdecay.h:120
const GBRForest * fReadereevariance
EcalClusterLocal _ecalLocal
float r9() const
Definition: Photon.h:191
void localCoordsEB(const reco::BasicCluster &bclus, const edm::EventSetup &es, float &etacry, float &phicry, int &ieta, int &iphi, float &thetatilt, float &phitilt) const
std::pair< double, double > EGEnergyCorrector::CorrectedEnergyWithError ( const reco::GsfElectron e,
const reco::VertexCollection vtxcol,
EcalClusterLazyTools clustertools,
const edm::EventSetup es 
)

Definition at line 291 of file EGEnergyCorrector.cc.

References _ecalLocal, b, reco::deltaPhi(), EcalClusterLazyTools::e2nd(), EcalClusterLazyTools::e3x3(), EcalClusterLazyTools::e5x5(), EcalClusterLazyTools::eBottom(), EcalBarrel, reco::GsfElectron::ecalDrivenSeed(), EcalClusterLazyTools::eLeft(), EcalClusterLazyTools::eMax(), EcalClusterLazyTools::eRight(), EcalClusterLazyTools::eTop(), fReadereb, fReaderebvariance, fReaderee, fReadereevariance, fVals, GBRForest::GetResponse(), reco::GsfElectron::hcalOverEcal(), edm::Ptr< T >::isNonnull(), EcalClusterLocal::localCoordsEB(), EcalClusterLazyTools::localCovariances(), create_public_lumi_plots::log, matplotRender::reader, alignCSCRings::s, mathSSE::sqrt(), and reco::GsfElectron::superCluster().

291  {
292 
293  //apply v2 regression to electrons
294  //mostly duplicated from photon function above //TODO, make common underlying function
295 
296  //protection, this doesn't work properly on non-egamma-seeded electrons
297  if (!e.ecalDrivenSeed()) return std::pair<double,double>(0.,0.);
298 
299 
300  const SuperClusterRef s = e.superCluster();
301  const CaloClusterPtr b = s->seed();
302 
303  CaloClusterPtr b2;
304  Double_t ebcmax = -99.;
305  for (reco::CaloCluster_iterator bit = s->clustersBegin(); bit!=s->clustersEnd(); ++bit) {
306  const CaloClusterPtr bc = *bit;
307  if (bc->energy() > ebcmax && bc !=b) {
308  b2 = bc;
309  ebcmax = bc->energy();
310  }
311  }
312 
313  CaloClusterPtr bclast;
314  Double_t ebcmin = 1e6;
315  for (reco::CaloCluster_iterator bit = s->clustersBegin(); bit!=s->clustersEnd(); ++bit) {
316  const CaloClusterPtr bc = *bit;
317  if (bc->energy() < ebcmin && bc !=b) {
318  bclast = bc;
319  ebcmin = bc->energy();
320  }
321  }
322 
323  CaloClusterPtr bclast2;
324  ebcmin = 1e6;
325  for (reco::CaloCluster_iterator bit = s->clustersBegin(); bit!=s->clustersEnd(); ++bit) {
326  const CaloClusterPtr bc = *bit;
327  if (bc->energy() < ebcmin && bc !=b && bc!=bclast) {
328  bclast2 = bc;
329  ebcmin = bc->energy();
330  }
331  }
332 
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.;
337 
338 
339  if (isbarrel) {
340  fVals[0] = s->rawEnergy();
341  fVals[1] = clustertools.e3x3(*b)/s->rawEnergy(); //r9
342  fVals[2] = s->eta();
343  fVals[3] = s->phi();
344  fVals[4] = clustertools.e5x5(*b)/s->rawEnergy();
345  fVals[5] = e.hcalOverEcal();
346  fVals[6] = s->etaWidth();
347  fVals[7] = s->phiWidth();
348 
349 
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);
356 
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 
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.;
382 
383  fVals[24] = hasbc2 ? (b2->eta()-s->eta()) : 0.;
384  fVals[25] = hasbc2 ? reco::deltaPhi(b2->phi(),s->phi()) : 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.;
388  fVals[29] = hasbc2 ? sqrt(clustertools.localCovariances(*b2)[0]) : 0.;
389  fVals[30] = hasbc2 ? sqrt(clustertools.localCovariances(*b2)[2]) : 0.;
390  fVals[31] = hasbc2 ? clustertools.localCovariances(*b)[1] : 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.;
399 
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.;
405  fVals[45] = hasbclast ? sqrt(clustertools.localCovariances(*bclast)[0]) : 0.;
406  fVals[46] = hasbclast ? sqrt(clustertools.localCovariances(*bclast)[2]) : 0.;
407  fVals[47] = hasbclast ? clustertools.localCovariances(*bclast)[1] : 0.;
408 
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.;
414  fVals[53] = hasbclast2 ? sqrt(clustertools.localCovariances(*bclast2)[0]) : 0.;
415  fVals[54] = hasbclast2 ? sqrt(clustertools.localCovariances(*bclast2)[2]) : 0.;
416  fVals[55] = hasbclast2 ? clustertools.localCovariances(*bclast2)[1] : 0.;
417 
418 
419  float betacry, bphicry, bthetatilt, bphitilt;
420  int bieta, biphi;
421  _ecalLocal.localCoordsEB(*b,es,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) + (TMath::Abs(bieta)>25)*((bieta-25*TMath::Abs(bieta)/bieta)%20);
428  fVals[61] = biphi%20;
429  fVals[62] = betacry;
430  fVals[63] = bphicry;
431 
432  float bc2etacry, bc2phicry, bc2thetatilt, bc2phitilt;
433  int bc2ieta, bc2iphi;
434  if (hasbc2) _ecalLocal.localCoordsEB(*b2,es,bc2etacry,bc2phicry,bc2ieta,bc2iphi,bc2thetatilt,bc2phitilt);
435 
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.;
444 
445  fVals[72] = vtxcol.size();
446 
447  }
448  else {
449  fVals[0] = s->rawEnergy();
450  fVals[1] = clustertools.e3x3(*b)/s->rawEnergy(); //r9
451  fVals[2] = s->eta();
452  fVals[3] = s->phi();
453  fVals[4] = clustertools.e5x5(*b)/s->rawEnergy();
454  fVals[5] = s->etaWidth();
455  fVals[6] = s->phiWidth();
456  fVals[7] = vtxcol.size();
457  }
458 
459 
460  const Double_t varscale = 1.253;
461  Double_t den;
462  const GBRForest *reader;
463  const GBRForest *readervar;
464  if (isbarrel) {
465  den = s->rawEnergy();
466  reader = fReadereb;
467  readervar = fReaderebvariance;
468  }
469  else {
470  den = s->rawEnergy() + s->preshowerEnergy();
471  reader = fReaderee;
472  readervar = fReadereevariance;
473  }
474 
475  Double_t ecor = reader->GetResponse(fVals)*den;
476  Double_t ecorerr = readervar->GetResponse(fVals)*den*varscale;
477 
478  //printf("ecor = %5f, ecorerr = %5f\n",ecor,ecorerr);
479 
480  return std::pair<double,double>(ecor,ecorerr);
481 
482 }
std::vector< float > localCovariances(const reco::BasicCluster &cluster, float w0=4.7)
double GetResponse(const float *vector) const
Definition: GBRForest.h:51
float eBottom(const reco::BasicCluster &cluster)
float e2nd(const reco::BasicCluster &cluster)
const GBRForest * fReaderee
const GBRForest * fReadereb
const GBRForest * fReaderebvariance
float eRight(const reco::BasicCluster &cluster)
float e3x3(const reco::BasicCluster &cluster)
float eMax(const reco::BasicCluster &cluster)
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:152
T sqrt(T t)
Definition: SSEVec.h:48
virtual SuperClusterRef superCluster() const
reference to a SuperCluster
Definition: GsfElectron.h:168
float hcalOverEcal() const
Definition: GsfElectron.h:390
float eTop(const reco::BasicCluster &cluster)
double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:12
float e5x5(const reco::BasicCluster &cluster)
float eLeft(const reco::BasicCluster &cluster)
double b
Definition: hdecay.h:120
const GBRForest * fReadereevariance
EcalClusterLocal _ecalLocal
void localCoordsEB(const reco::BasicCluster &bclus, const edm::EventSetup &es, float &etacry, float &phicry, int &ieta, int &iphi, float &thetatilt, float &phitilt) const
bool ecalDrivenSeed() const
Definition: GsfElectron.h:172
void EGEnergyCorrector::Initialize ( const edm::EventSetup iSetup,
std::string  regweights,
bool  weightsFromDB = false 
)

Definition at line 47 of file EGEnergyCorrector.cc.

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

Referenced by EGEnergyAnalyzer::analyze(), and PhotonEnergyCorrector::init().

47  {
48  fIsInitialized = kTRUE;
49 
50  if (fVals) delete [] fVals;
51  if (fOwnsForests) {
52  if (fReadereb) delete fReadereb;
54  if (fReaderee) delete fReaderee;
56  }
57 
58  fVals = new Float_t[73];
59 
60  if (weightsFromDB) { //weights from event setup
61 
62  edm::ESHandle<GBRForest> readereb;
63  edm::ESHandle<GBRForest> readerebvar;
64  edm::ESHandle<GBRForest> readeree;
65  edm::ESHandle<GBRForest> readereevar;
66 
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);
71 
72  fReadereb = readereb.product();
73  fReaderebvariance = readerebvar.product();
74  fReaderee = readeree.product();
75  fReadereevariance = readereevar.product();
76 
77  }
78  else { //weights from root file
79  fOwnsForests = kTRUE;
80 
81  TFile *fgbr = new TFile(regweights.c_str(),"READ");
82  fReadereb = (GBRForest*)fgbr->Get("EBCorrection");
83  fReaderebvariance = (GBRForest*)fgbr->Get("EBUncertainty");
84  fReaderee = (GBRForest*)fgbr->Get("EECorrection");
85  fReadereevariance = (GBRForest*)fgbr->Get("EEUncertainty");
86  fgbr->Close();
87  }
88 
89 }
const GBRForest * fReaderee
const GBRForest * fReadereb
const GBRForest * fReaderebvariance
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
const GBRForest * fReadereevariance
Bool_t EGEnergyCorrector::IsInitialized ( ) const
inline

Definition at line 29 of file EGEnergyCorrector.h.

References fIsInitialized.

Referenced by EGEnergyAnalyzer::analyze(), and PhotonEnergyCorrector::init().

29 { return fIsInitialized; }

Member Data Documentation

EcalClusterLocal EGEnergyCorrector::_ecalLocal
protected

Definition at line 45 of file EGEnergyCorrector.h.

Referenced by CorrectedEnergyWithError().

Bool_t EGEnergyCorrector::fIsInitialized
protected

Definition at line 41 of file EGEnergyCorrector.h.

Referenced by Initialize(), and IsInitialized().

Bool_t EGEnergyCorrector::fOwnsForests
protected

Definition at line 42 of file EGEnergyCorrector.h.

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

const GBRForest* EGEnergyCorrector::fReadereb
protected

Definition at line 36 of file EGEnergyCorrector.h.

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

const GBRForest* EGEnergyCorrector::fReaderebvariance
protected

Definition at line 37 of file EGEnergyCorrector.h.

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

const GBRForest* EGEnergyCorrector::fReaderee
protected

Definition at line 38 of file EGEnergyCorrector.h.

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

const GBRForest* EGEnergyCorrector::fReadereevariance
protected

Definition at line 39 of file EGEnergyCorrector.h.

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

Float_t* EGEnergyCorrector::fVals
protected

Definition at line 43 of file EGEnergyCorrector.h.

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