CMS 3D CMS Logo

Functions
lowptgsfeleid Namespace Reference

Functions

std::vector< float > features (edm::Ptr< reco::GsfElectron > const &ele, float rho, float unbiased)
 
std::vector< float > features (edm::Ref< edm::View< reco::GsfElectron > > const &ele, float rho, float unbiased)
 
std::vector< float > features (edm::Ref< std::vector< reco::GsfElectron > > const &ele, float rho, float unbiased)
 

Function Documentation

◆ features() [1/3]

std::vector< float > lowptgsfeleid::features ( edm::Ptr< reco::GsfElectron > const &  ele,
float  rho,
float  unbiased 
)

Definition at line 132 of file LowPtGsfElectronFeatures.cc.

132  {
133  float eid_rho = -999.;
134  float eid_sc_eta = -999.;
135  float eid_shape_full5x5_r9 = -999.;
136  float eid_sc_etaWidth = -999.;
137  float eid_sc_phiWidth = -999.;
138  float eid_shape_full5x5_HoverE = -999.;
139  float eid_trk_nhits = -999.;
140  float eid_trk_chi2red = -999.;
141  float eid_gsf_chi2red = -999.;
142  float eid_brem_frac = -999.;
143  float eid_gsf_nhits = -999.;
144  float eid_match_SC_EoverP = -999.;
145  float eid_match_eclu_EoverP = -999.;
146  float eid_match_SC_dEta = -999.;
147  float eid_match_SC_dPhi = -999.;
148  float eid_match_seed_dEta = -999.;
149  float eid_sc_E = -999.;
150  float eid_trk_p = -999.;
151  float gsf_mode_p = -999.;
152  float core_shFracHits = -999.;
153  float gsf_bdtout1 = -999.;
154  float gsf_dr = -999.;
155  float trk_dr = -999.;
156  float sc_Nclus = -999.;
157  float sc_clus1_nxtal = -999.;
158  float sc_clus1_dphi = -999.;
159  float sc_clus2_dphi = -999.;
160  float sc_clus1_deta = -999.;
161  float sc_clus2_deta = -999.;
162  float sc_clus1_E = -999.;
163  float sc_clus2_E = -999.;
164  float sc_clus1_E_ov_p = -999.;
165  float sc_clus2_E_ov_p = -999.;
166 
167  // KF tracks
168  if (ele->core().isNonnull()) {
169  const auto& trk = ele->closestCtfTrackRef(); // reco::TrackRef
170  if (trk.isNonnull()) {
171  eid_trk_p = (float)trk->p();
172  eid_trk_nhits = (float)trk->found();
173  eid_trk_chi2red = (float)trk->normalizedChi2();
174  TVector3 trkTV3(0, 0, 0);
175  trkTV3.SetPtEtaPhi(trk->pt(), trk->eta(), trk->phi());
176  TVector3 eleTV3(0, 0, 0);
177  eleTV3.SetPtEtaPhi(ele->pt(), ele->eta(), ele->phi());
178  trk_dr = eleTV3.DeltaR(trkTV3);
179  }
180  }
181 
182  // GSF tracks
183  if (ele->core().isNonnull()) {
184  const auto& gsf = ele->core()->gsfTrack(); // reco::GsfTrackRef
185  if (gsf.isNonnull()) {
186  gsf_mode_p = gsf->pMode();
187  eid_gsf_nhits = (float)gsf->found();
188  eid_gsf_chi2red = gsf->normalizedChi2();
189  TVector3 gsfTV3(0, 0, 0);
190  gsfTV3.SetPtEtaPhi(gsf->ptMode(), gsf->etaMode(), gsf->phiMode());
191  TVector3 eleTV3(0, 0, 0);
192  eleTV3.SetPtEtaPhi(ele->pt(), ele->eta(), ele->phi());
193  gsf_dr = eleTV3.DeltaR(gsfTV3);
194  }
195  }
196 
197  // Super clusters
198  if (ele->core().isNonnull()) {
199  const auto& sc = ele->core()->superCluster(); // reco::SuperClusterRef
200  if (sc.isNonnull()) {
201  eid_sc_E = sc->energy();
202  eid_sc_eta = sc->eta();
203  eid_sc_etaWidth = sc->etaWidth();
204  eid_sc_phiWidth = sc->phiWidth();
205  sc_Nclus = (float)sc->clustersSize();
206  }
207  }
208 
209  // Track-cluster matching
210  if (ele.isNonnull()) {
211  eid_match_seed_dEta = ele->deltaEtaSeedClusterTrackAtCalo();
212  eid_match_eclu_EoverP = (1. / ele->ecalEnergy()) - (1. / ele->p());
213  eid_match_SC_EoverP = ele->eSuperClusterOverP();
214  eid_match_SC_dEta = ele->deltaEtaSuperClusterTrackAtVtx();
215  eid_match_SC_dPhi = ele->deltaPhiSuperClusterTrackAtVtx();
216  }
217 
218  // Shower shape vars
219  if (ele.isNonnull()) {
220  eid_shape_full5x5_HoverE = ele->full5x5_hcalOverEcal();
221  eid_shape_full5x5_r9 = ele->full5x5_r9();
222  }
223 
224  // Misc
225  eid_rho = rho;
226 
227  if (ele.isNonnull()) {
228  eid_brem_frac = ele->fbrem();
229  core_shFracHits = (float)ele->shFracInnerHits();
230  }
231 
232  // Unbiased BDT from ElectronSeed
233  gsf_bdtout1 = unbiased;
234 
235  // Clusters
236  if (ele->core().isNonnull()) {
237  const auto& gsf = ele->core()->gsfTrack(); // reco::GsfTrackRef
238  if (gsf.isNonnull()) {
239  const auto& sc = ele->core()->superCluster(); // reco::SuperClusterRef
240  if (sc.isNonnull()) {
241  // Propagate electron track to ECAL surface
242  double mass_ = 0.000511 * 0.000511;
243  float p2 = pow(gsf->p(), 2);
244  float energy = sqrt(mass_ + p2);
245  math::XYZTLorentzVector mom = math::XYZTLorentzVector(gsf->px(), gsf->py(), gsf->pz(), energy);
246  math::XYZTLorentzVector pos = math::XYZTLorentzVector(gsf->vx(), gsf->vy(), gsf->vz(), 0.);
247  float field_z = 3.8;
248  BaseParticlePropagator mypart(RawParticle(mom, pos, gsf->charge()), 0, 0, field_z);
249  mypart.propagateToEcalEntrance(true); // true only first half loop , false more than one loop
250  bool reach_ECAL = mypart.getSuccess(); // 0 does not reach ECAL, 1 yes barrel, 2 yes endcaps
251 
252  // ECAL entry point for track
253  GlobalPoint ecal_pos(
254  mypart.particle().vertex().x(), mypart.particle().vertex().y(), mypart.particle().vertex().z());
255 
256  // Iterate through ECAL clusters and sort in energy
257  int clusNum = 0;
258  float maxEne1 = -1;
259  float maxEne2 = -1;
260  int i1 = -1;
261  int i2 = -1;
262  try {
263  if (sc->clustersSize() > 0 && sc->clustersBegin() != sc->clustersEnd()) {
264  for (const auto& cluster : sc->clusters()) {
265  if (cluster->energy() > maxEne1) {
266  maxEne1 = cluster->energy();
267  i1 = clusNum;
268  }
269  clusNum++;
270  }
271  if (sc->clustersSize() > 1) {
272  clusNum = 0;
273  for (const auto& cluster : sc->clusters()) {
274  if (clusNum != i1) {
275  if (cluster->energy() > maxEne2) {
276  maxEne2 = cluster->energy();
277  i2 = clusNum;
278  }
279  }
280  clusNum++;
281  }
282  }
283  } // loop over clusters
284  } catch (...) {
285  edm::LogError("SuperClusters") << "Problem accessing SC constituent clusters:"
286  << " clusNum=" << clusNum << " clustersSize=" << sc->clustersSize()
287  << " energy=" << sc->energy() << std::endl;
288  }
289 
290  // Initializations
291  sc_clus1_nxtal = -999.;
292  sc_clus1_dphi = -999.;
293  sc_clus2_dphi = -999.;
294  sc_clus1_deta = -999.;
295  sc_clus2_deta = -999.;
296  sc_clus1_E = -999.;
297  sc_clus2_E = -999.;
298  sc_clus1_E_ov_p = -999.;
299  sc_clus2_E_ov_p = -999.;
300 
301  // track-clusters match
302  clusNum = 0;
303  try {
304  if (sc->clustersSize() > 0 && sc->clustersBegin() != sc->clustersEnd()) {
305  for (const auto& cluster : sc->clusters()) {
306  float deta = std::fabs(ecal_pos.eta() - cluster->eta());
307  float dphi = std::fabs(ecal_pos.phi() - cluster->phi());
308  if (dphi > M_PI)
309  dphi -= 2 * M_PI;
310  if (ecal_pos.phi() - cluster->phi() < 0)
311  dphi = -dphi;
312  if (ecal_pos.eta() - cluster->eta() < 0)
313  deta = -deta;
314 
315  if (clusNum == i1) {
316  sc_clus1_E = cluster->energy();
317  if (gsf->pMode() > 0)
318  sc_clus1_E_ov_p = cluster->energy() / gsf->pMode();
319  sc_clus1_nxtal = (float)cluster->size();
320  if (reach_ECAL > 0) {
321  sc_clus1_deta = deta;
322  sc_clus1_dphi = dphi;
323  }
324  } else if (clusNum == i2) {
325  sc_clus2_E = cluster->energy();
326  if (gsf->pMode() > 0)
327  sc_clus2_E_ov_p = cluster->energy() / gsf->pMode();
328  if (reach_ECAL > 0) {
329  sc_clus2_deta = deta;
330  sc_clus2_dphi = dphi;
331  }
332  }
333  clusNum++;
334  }
335  }
336  } catch (...) {
337  edm::LogError("SuperClusters") << "Problem with track-cluster matching" << std::endl;
338  }
339  }
340  }
341  } // clusters
342 
343  // Out-of-range
344  if (eid_rho < 0)
345  eid_rho = 0;
346  if (eid_rho > 100)
347  eid_rho = 100;
348  if (eid_sc_eta < -5)
349  eid_sc_eta = -5;
350  if (eid_sc_eta > 5)
351  eid_sc_eta = 5;
352  if (eid_shape_full5x5_r9 < 0)
353  eid_shape_full5x5_r9 = 0;
354  if (eid_shape_full5x5_r9 > 2)
355  eid_shape_full5x5_r9 = 2;
356  if (eid_sc_etaWidth < 0)
357  eid_sc_etaWidth = 0;
358  if (eid_sc_etaWidth > 3.14)
359  eid_sc_etaWidth = 3.14;
360  if (eid_sc_phiWidth < 0)
361  eid_sc_phiWidth = 0;
362  if (eid_sc_phiWidth > 3.14)
363  eid_sc_phiWidth = 3.14;
364  if (eid_shape_full5x5_HoverE < 0)
365  eid_shape_full5x5_HoverE = 0;
366  if (eid_shape_full5x5_HoverE > 50)
367  eid_shape_full5x5_HoverE = 50;
368  if (eid_trk_nhits < -1)
369  eid_trk_nhits = -1;
370  if (eid_trk_nhits > 50)
371  eid_trk_nhits = 50;
372  if (eid_trk_chi2red < -1)
373  eid_trk_chi2red = -1;
374  if (eid_trk_chi2red > 50)
375  eid_trk_chi2red = 50;
376  if (eid_gsf_chi2red < -1)
377  eid_gsf_chi2red = -1;
378  if (eid_gsf_chi2red > 100)
379  eid_gsf_chi2red = 100;
380  if (eid_brem_frac < 0)
381  eid_brem_frac = -1;
382  if (eid_brem_frac > 1)
383  eid_brem_frac = 1;
384  if (eid_gsf_nhits < -1)
385  eid_gsf_nhits = -1;
386  if (eid_gsf_nhits > 50)
387  eid_gsf_nhits = 50;
388  if (eid_match_SC_EoverP < 0)
389  eid_match_SC_EoverP = 0;
390  if (eid_match_SC_EoverP > 100)
391  eid_match_SC_EoverP = 100;
392  if (eid_match_eclu_EoverP < -1.)
393  eid_match_eclu_EoverP = -1.;
394  if (eid_match_eclu_EoverP > 1.)
395  eid_match_eclu_EoverP = 1.;
396  if (eid_match_SC_dEta < -10)
397  eid_match_SC_dEta = -10;
398  if (eid_match_SC_dEta > 10)
399  eid_match_SC_dEta = 10;
400  if (eid_match_SC_dPhi < -3.14)
401  eid_match_SC_dPhi = -3.14;
402  if (eid_match_SC_dPhi > 3.14)
403  eid_match_SC_dPhi = 3.14;
404  if (eid_match_seed_dEta < -10)
405  eid_match_seed_dEta = -10;
406  if (eid_match_seed_dEta > 10)
407  eid_match_seed_dEta = 10;
408  if (eid_sc_E < 0)
409  eid_sc_E = 0;
410  if (eid_sc_E > 1000)
411  eid_sc_E = 1000;
412  if (eid_trk_p < -1)
413  eid_trk_p = -1;
414  if (eid_trk_p > 1000)
415  eid_trk_p = 1000;
416  if (gsf_mode_p < 0)
417  gsf_mode_p = 0;
418  if (gsf_mode_p > 1000)
419  gsf_mode_p = 1000;
420  if (core_shFracHits < 0)
421  core_shFracHits = 0;
422  if (core_shFracHits > 1)
423  core_shFracHits = 1;
424  if (gsf_bdtout1 < -20)
425  gsf_bdtout1 = -20;
426  if (gsf_bdtout1 > 20)
427  gsf_bdtout1 = 20;
428  if (gsf_dr < 0)
429  gsf_dr = 5;
430  if (gsf_dr > 5)
431  gsf_dr = 5;
432  if (trk_dr < 0)
433  trk_dr = 5;
434  if (trk_dr > 5)
435  trk_dr = 5;
436  if (sc_Nclus < 0)
437  sc_Nclus = 0;
438  if (sc_Nclus > 20)
439  sc_Nclus = 20;
440  if (sc_clus1_nxtal < 0)
441  sc_clus1_nxtal = 0;
442  if (sc_clus1_nxtal > 100)
443  sc_clus1_nxtal = 100;
444  if (sc_clus1_dphi < -3.14)
445  sc_clus1_dphi = -5;
446  if (sc_clus1_dphi > 3.14)
447  sc_clus1_dphi = 5;
448  if (sc_clus2_dphi < -3.14)
449  sc_clus2_dphi = -5;
450  if (sc_clus2_dphi > 3.14)
451  sc_clus2_dphi = 5;
452  if (sc_clus1_deta < -5)
453  sc_clus1_deta = -5;
454  if (sc_clus1_deta > 5)
455  sc_clus1_deta = 5;
456  if (sc_clus2_deta < -5)
457  sc_clus2_deta = -5;
458  if (sc_clus2_deta > 5)
459  sc_clus2_deta = 5;
460  if (sc_clus1_E < 0)
461  sc_clus1_E = 0;
462  if (sc_clus1_E > 1000)
463  sc_clus1_E = 1000;
464  if (sc_clus2_E < 0)
465  sc_clus2_E = 0;
466  if (sc_clus2_E > 1000)
467  sc_clus2_E = 1000;
468  if (sc_clus1_E_ov_p < 0)
469  sc_clus1_E_ov_p = -1;
470  if (sc_clus2_E_ov_p < 0)
471  sc_clus2_E_ov_p = -1;
472 
473  // Set contents of vector
474  std::vector<float> output = {eid_rho,
475  eid_sc_eta,
476  eid_shape_full5x5_r9,
477  eid_sc_etaWidth,
478  eid_sc_phiWidth,
479  eid_shape_full5x5_HoverE,
480  eid_trk_nhits,
481  eid_trk_chi2red,
482  eid_gsf_chi2red,
483  eid_brem_frac,
484  eid_gsf_nhits,
485  eid_match_SC_EoverP,
486  eid_match_eclu_EoverP,
487  eid_match_SC_dEta,
488  eid_match_SC_dPhi,
489  eid_match_seed_dEta,
490  eid_sc_E,
491  eid_trk_p,
492  gsf_mode_p,
493  core_shFracHits,
494  gsf_bdtout1,
495  gsf_dr,
496  trk_dr,
497  sc_Nclus,
498  sc_clus1_nxtal,
499  sc_clus1_dphi,
500  sc_clus2_dphi,
501  sc_clus1_deta,
502  sc_clus2_deta,
503  sc_clus1_E,
504  sc_clus2_E,
505  sc_clus1_E_ov_p,
506  sc_clus2_E_ov_p};
507  return output;
508  }

References reco::GsfElectron::closestCtfTrackRef(), reco::GsfElectron::core(), reco::GsfElectron::deltaEtaSeedClusterTrackAtCalo(), reco::GsfElectron::deltaEtaSuperClusterTrackAtVtx(), reco::GsfElectron::deltaPhiSuperClusterTrackAtVtx(), reco::GsfElectron::ecalEnergy(), HCALHighEnergyHPDFilter_cfi::energy, reco::GsfElectron::eSuperClusterOverP(), reco::LeafCandidate::eta(), reco::GsfElectron::fbrem(), dqmMemoryStats::float, reco::GsfElectron::full5x5_hcalOverEcal(), reco::GsfElectron::full5x5_r9(), BaseParticlePropagator::getSuccess(), ntupleEnum::gsf, testProducerWithPsetDescEmpty_cfi::i1, testProducerWithPsetDescEmpty_cfi::i2, edm::Ptr< T >::isNonnull(), edm::Ref< C, T, F >::isNonnull(), M_PI, convertSQLitetoXML_cfg::output, reco::LeafCandidate::p(), p2, BaseParticlePropagator::particle(), reco::LeafCandidate::phi(), funct::pow(), BaseParticlePropagator::propagateToEcalEntrance(), reco::LeafCandidate::pt(), reco::GsfElectron::shFracInnerHits(), mathSSE::sqrt(), and RawParticle::vertex().

Referenced by LowPtGsfElectronIDProducer::eval(), and features().

◆ features() [2/3]

std::vector< float > lowptgsfeleid::features ( edm::Ref< edm::View< reco::GsfElectron > > const &  ele,
float  rho,
float  unbiased 
)

Definition at line 518 of file LowPtGsfElectronFeatures.cc.

518  {
519  return features(edm::refToPtr(ele), rho, unbiased);
520  }

References features(), and edm::refToPtr().

◆ features() [3/3]

std::vector<float> lowptgsfeleid::features ( edm::Ref< std::vector< reco::GsfElectron > > const &  ele,
float  rho,
float  unbiased 
)

Definition at line 512 of file LowPtGsfElectronFeatures.cc.

512  {
513  return features(edm::refToPtr(ele), rho, unbiased);
514  }

References features(), and edm::refToPtr().

reco::GsfElectron::deltaEtaSeedClusterTrackAtCalo
float deltaEtaSeedClusterTrackAtCalo() const
Definition: GsfElectron.h:234
testProducerWithPsetDescEmpty_cfi.i2
i2
Definition: testProducerWithPsetDescEmpty_cfi.py:46
RawParticle
Definition: RawParticle.h:37
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
reco::GsfElectron::deltaPhiSuperClusterTrackAtVtx
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:236
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
postprocess-scan-build.features
features
Definition: postprocess-scan-build.py:8
pos
Definition: PixelAliasList.h:18
ZElectronSkim_cff.rho
rho
Definition: ZElectronSkim_cff.py:38
testProducerWithPsetDescEmpty_cfi.i1
i1
Definition: testProducerWithPsetDescEmpty_cfi.py:45
reco::LeafCandidate::pt
double pt() const final
transverse momentum
Definition: LeafCandidate.h:146
reco::GsfElectron::fbrem
float fbrem() const
Definition: GsfElectron.h:734
BaseParticlePropagator
Definition: BaseParticlePropagator.h:82
reco::GsfElectron::core
virtual GsfElectronCoreRef core() const
Definition: GsfElectron.cc:8
edm::refToPtr
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
Definition: RefToPtr.h:18
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
reco::GsfElectron::full5x5_hcalOverEcal
float full5x5_hcalOverEcal() const
Definition: GsfElectron.h:451
p2
double p2[4]
Definition: TauolaWrapper.h:90
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
Point3DBase< float, GlobalTag >
reco::GsfElectron::full5x5_r9
float full5x5_r9() const
Definition: GsfElectron.h:448
reco::GsfElectron::deltaEtaSuperClusterTrackAtVtx
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:233
reco::LeafCandidate::eta
double eta() const final
momentum pseudorapidity
Definition: LeafCandidate.h:152
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
ntupleEnum.gsf
gsf
Definition: ntupleEnum.py:48
reco::GsfElectron::closestCtfTrackRef
virtual TrackRef closestCtfTrackRef() const
Definition: GsfElectron.h:188
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
reco::LeafCandidate::phi
double phi() const final
momentum azimuthal angle
Definition: LeafCandidate.h:148
math::XYZTLorentzVector
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
reco::LeafCandidate::p
double p() const final
magnitude of momentum vector
Definition: LeafCandidate.h:123
reco::GsfElectron::eSuperClusterOverP
float eSuperClusterOverP() const
Definition: GsfElectron.h:229
edm::Ptr::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:146
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
reco::GsfElectron::shFracInnerHits
float shFracInnerHits() const
Definition: GsfElectron.h:187
reco::GsfElectron::ecalEnergy
float ecalEnergy() const
Definition: GsfElectron.h:820