CMS 3D CMS Logo

GsfElectronAlgo.cc
Go to the documentation of this file.
1 
9 
12 
25 
29 
32 
33 
35 
38 
41 
42 
45 
46 
47 #include <Math/Point3D.h>
48 #include <sstream>
49 #include <algorithm>
50 
51 
52 using namespace edm ;
53 using namespace std ;
54 using namespace reco ;
55 
56 
57 //===================================================================
58 // GsfElectronAlgo::GeneralData
59 //===================================================================
60 
61 // general data and helpers
63  {
64  // constructors
66  ( const InputTagsConfiguration &,
67  const StrategyConfiguration &,
68  const CutsConfiguration & cutsCfg,
69  const CutsConfiguration & cutsCfgPflow,
70  const ElectronHcalHelper::Configuration & hcalCfg,
71  const ElectronHcalHelper::Configuration & hcalCfgPflow,
72  const IsolationConfiguration &,
76  const SoftElectronMVAEstimator::Configuration & mva_NIso_Cfg ,
77  const ElectronMVAEstimator::Configuration & mva_Iso_Cfg ,
79  ~GeneralData() ;
80 
81  // configurables
88 
89  // additional configuration and helpers
93  //SoftElectronMVAEstimator *sElectronMVAEstimator;
94  //ElectronMVAEstimator *iElectronMVAEstimator;
97  } ;
98 
100  ( const InputTagsConfiguration & inputConfig,
101  const StrategyConfiguration & strategyConfig,
102  const CutsConfiguration & cutsConfig,
103  const CutsConfiguration & cutsConfigPflow,
104  const ElectronHcalHelper::Configuration & hcalConfig,
105  const ElectronHcalHelper::Configuration & hcalConfigPflow,
106  const IsolationConfiguration & isoConfig,
107  const EcalRecHitsConfiguration & recHitsConfig,
108  EcalClusterFunctionBaseClass * superClusterErrorFunc,
109  EcalClusterFunctionBaseClass * crackCorrectionFunc,
110  const SoftElectronMVAEstimator::Configuration & /*mva_NIso_Config*/,
111  const ElectronMVAEstimator::Configuration & /*mva_Iso_Config*/,
112  const RegressionHelper::Configuration & regConfig
113  )
114  : inputCfg(inputConfig),
115  strategyCfg(strategyConfig),
116  cutsCfg(cutsConfig),
117  cutsCfgPflow(cutsConfigPflow),
118  isoCfg(isoConfig),
119  recHitsCfg(recHitsConfig),
120  hcalHelper(new ElectronHcalHelper(hcalConfig)),
121  hcalHelperPflow(new ElectronHcalHelper(hcalConfigPflow)),
122  superClusterErrorFunction(superClusterErrorFunc),
123  crackCorrectionFunction(crackCorrectionFunc),
124  //sElectronMVAEstimator(new SoftElectronMVAEstimator(mva_NIso_Config)),
125  //iElectronMVAEstimator(new ElectronMVAEstimator(mva_Iso_Config)),
126  regCfg(regConfig),
127  regHelper(new RegressionHelper(regConfig))
128  {}
129 
131  {
132  delete hcalHelper ;
133  delete hcalHelperPflow ;
134  //delete sElectronMVAEstimator;
135  //delete iElectronMVAEstimator;
136  delete regHelper;
137  }
138 
139 //===================================================================
140 // GsfElectronAlgo::EventSetupData
141 //===================================================================
142 
144  {
145  EventSetupData() ;
146  ~EventSetupData() ;
147 
148  unsigned long long cacheIDGeom ;
149  unsigned long long cacheIDTopo ;
150  unsigned long long cacheIDTDGeom ;
151  unsigned long long cacheIDMagField ;
152  //unsigned long long cacheChStatus ;
153  unsigned long long cacheSevLevel ;
154 
159  //edm::ESHandle<EcalChannelStatus> chStatus ;
161 
165 } ;
166 
168  : cacheIDGeom(0), cacheIDTopo(0), cacheIDTDGeom(0), cacheIDMagField(0),/*cacheChStatus(0),*/
169  cacheSevLevel(0), mtsTransform(nullptr), constraintAtVtx(nullptr), mtsMode(new MultiTrajectoryStateMode)
170  {}
171 
173  {
174  delete mtsMode ;
175  delete constraintAtVtx ;
176  delete mtsTransform ;
177  }
178 
179 
180 //===================================================================
181 // GsfElectronAlgo::EventData
182 //===================================================================
183 
185  {
186  // general
190 
191  EventData() ;
192  ~EventData() ;
193 
194  // utilities
195  void retreiveOriginalTrackCollections
196  ( const reco::TrackRef &, const reco::GsfTrackRef & ) ;
197 
198  // input collections
214 
215  // isolation helpers
216  EgammaTowerIsolation * hadDepth1Isolation03, * hadDepth1Isolation04 ;
217  EgammaTowerIsolation * hadDepth2Isolation03, * hadDepth2Isolation04 ;
218  EgammaTowerIsolation * hadDepth1Isolation03Bc, * hadDepth1Isolation04Bc ;
219  EgammaTowerIsolation * hadDepth2Isolation03Bc, * hadDepth2Isolation04Bc ;
220  EgammaRecHitIsolation * ecalBarrelIsol03, * ecalBarrelIsol04 ;
221  EgammaRecHitIsolation * ecalEndcapIsol03, * ecalEndcapIsol04 ;
222 
223  //Isolation Value Maps for PF and EcalDriven electrons
224  typedef std::vector< edm::Handle< edm::ValueMap<double> > > IsolationValueMaps;
225  IsolationValueMaps pfIsolationValues;
226  IsolationValueMaps edIsolationValues;
227  } ;
228 
231  originalCtfTrackCollectionRetreived(false),
232  originalGsfTrackCollectionRetreived(false),
233  hadDepth1Isolation03(nullptr), hadDepth1Isolation04(nullptr),
234  hadDepth2Isolation03(nullptr), hadDepth2Isolation04(nullptr),
235  hadDepth1Isolation03Bc(nullptr), hadDepth1Isolation04Bc(nullptr),
236  hadDepth2Isolation03Bc(nullptr), hadDepth2Isolation04Bc(nullptr),
237  ecalBarrelIsol03(nullptr), ecalBarrelIsol04(nullptr),
238  ecalEndcapIsol03(nullptr), ecalEndcapIsol04(nullptr)
239  {
241  }
242 
244  {
245  delete hadDepth1Isolation03 ;
246  delete hadDepth1Isolation04 ;
247  delete hadDepth2Isolation03 ;
248  delete hadDepth2Isolation04 ;
249  delete hadDepth1Isolation03Bc ;
250  delete hadDepth1Isolation04Bc ;
251  delete hadDepth2Isolation03Bc ;
252  delete hadDepth2Isolation04Bc ;
253  delete ecalBarrelIsol03 ;
254  delete ecalBarrelIsol04 ;
255  delete ecalEndcapIsol03 ;
256  delete ecalEndcapIsol04 ;
257 
258  GsfElectronPtrCollection::const_iterator it ;
259  for ( it = electrons->begin() ; it != electrons->end() ; it++ )
260  { delete (*it) ; }
261  delete electrons ;
262  }
263 
265  ( const reco::TrackRef & ctfTrack, const reco::GsfTrackRef & gsfTrack )
266  {
267  if ((!originalCtfTrackCollectionRetreived)&&(ctfTrack.isNonnull()))
268  {
269  event->get(ctfTrack.id(),originalCtfTracks) ;
271  }
272  if ((!originalGsfTrackCollectionRetreived)&&(gsfTrack.isNonnull()))
273  {
274  event->get(gsfTrack.id(),originalGsfTracks) ;
276  }
277  }
278 
279 
280 //===================================================================
281 // GsfElectronAlgo::ElectronData
282 //===================================================================
283 
285  {
286  // Refs to subproducts
293 
294  // constructors
296  ( const reco::GsfElectronCoreRef & core,
297  const reco::BeamSpot & bs ) ;
298  ~ElectronData() ;
299 
300  // utilities
302  void computeCharge( int & charge, reco::GsfElectron::ChargeInfo & info ) ;
303  CaloClusterPtr getEleBasicCluster( const MultiTrajectoryStateTransform * ) ;
304  bool calculateTSOS( const MultiTrajectoryStateTransform *, GsfConstraintAtVertex * ) ;
305  void calculateMode( const MultiTrajectoryStateMode * mtsMode ) ;
306  Candidate::LorentzVector calculateMomentum() ;
307 
308  // TSOS
316 
317  // mode
318  GlobalVector innMom, seedMom, eleMom, sclMom, vtxMom, outMom ;
319  GlobalPoint innPos, seedPos, elePos, sclPos, vtxPos, outPos ;
321  } ;
322 
325  const reco::BeamSpot & bs )
326  : coreRef(core),
327  gsfTrackRef(coreRef->gsfTrack()),
328  superClusterRef(coreRef->superCluster()),
329  ctfTrackRef(coreRef->ctfTrack()), shFracInnerHits(coreRef->ctfGsfOverlap()),
330  beamSpot(bs)
331  {}
332 
334  {}
335 
337 {
338  if (!ctfTrackRef.isNull()) return ;
339 
340  // Code below from Puneeth Kalavase
341 
342  shFracInnerHits = 0 ;
343  const TrackCollection * ctfTrackCollection = currentCtfTracks.product() ;
344 
345  // get the Hit Pattern for the gsfTrack
346  const HitPattern &gsfHitPattern = gsfTrackRef->hitPattern() ;
347 
348  unsigned int counter ;
349  TrackCollection::const_iterator ctfTkIter ;
350  for (ctfTkIter = ctfTrackCollection->begin(), counter = 0;
351  ctfTkIter != ctfTrackCollection->end(); ctfTkIter++, counter++)
352  {
353  double dEta = gsfTrackRef->eta() - ctfTkIter->eta() ;
354  double dPhi = gsfTrackRef->phi() - ctfTkIter->phi() ;
355  double pi = acos(-1.);
356  if(std::abs(dPhi) > pi) dPhi = 2*pi - std::abs(dPhi) ;
357 
358  // dont want to look at every single track in the event!
359  if (sqrt(dEta*dEta + dPhi*dPhi) > 0.3) continue ;
360 
361  unsigned int shared = 0 ;
362  int gsfHitCounter = 0 ;
363  int numGsfInnerHits = 0 ;
364  int numCtfInnerHits = 0 ;
365 
366  // get the CTF Track Hit Pattern
367  const HitPattern &ctfHitPattern = ctfTkIter->hitPattern() ;
368 
369  trackingRecHit_iterator elHitsIt;
370  for (elHitsIt = gsfTrackRef->recHitsBegin();
371  elHitsIt != gsfTrackRef->recHitsEnd();
372  elHitsIt++, gsfHitCounter++)
373  {
374  if (!((**elHitsIt).isValid())) //count only valid Hits
375  { continue ; }
376 
377  // look only in the pixels/TIB/TID
378  uint32_t gsfHit = gsfHitPattern.getHitPattern(HitPattern::TRACK_HITS, gsfHitCounter) ;
379  if (!(HitPattern::pixelHitFilter(gsfHit)
380  || HitPattern::stripTIBHitFilter(gsfHit)
381  || HitPattern::stripTIDHitFilter(gsfHit))){
382  continue;
383  }
384 
385  numGsfInnerHits++ ;
386 
387  int ctfHitsCounter = 0 ;
388  numCtfInnerHits = 0 ;
389  trackingRecHit_iterator ctfHitsIt ;
390  for (ctfHitsIt = ctfTkIter->recHitsBegin();
391  ctfHitsIt != ctfTkIter->recHitsEnd();
392  ctfHitsIt++, ctfHitsCounter++ )
393  {
394  if(!((**ctfHitsIt).isValid())) //count only valid Hits!
395  { continue; }
396 
397  uint32_t ctfHit = ctfHitPattern.getHitPattern(HitPattern::TRACK_HITS, ctfHitsCounter);
398  if(!(HitPattern::pixelHitFilter(ctfHit)
399  || HitPattern::stripTIBHitFilter(ctfHit)
400  || HitPattern::stripTIDHitFilter(ctfHit)))
401  {
402  continue;
403  }
404 
405  numCtfInnerHits++ ;
406 
407  if((**elHitsIt).sharesInput(&(**ctfHitsIt), TrackingRecHit::all))
408  {
409  shared++ ;
410  break ;
411  }
412 
413  } //ctfHits iterator
414 
415  } //gsfHits iterator
416 
417  if ((numGsfInnerHits==0)||(numCtfInnerHits==0))
418  { continue ; }
419 
420  if ( static_cast<float>(shared)/min(numGsfInnerHits,numCtfInnerHits) > shFracInnerHits )
421  {
422  shFracInnerHits = static_cast<float>(shared)/min(numGsfInnerHits, numCtfInnerHits);
423  ctfTrackRef = TrackRef(currentCtfTracks,counter);
424  }
425  } //ctfTrack iterator
426 }
427 
430  {
431  // determine charge from SC
432  GlobalPoint orig, scpos ;
433  ele_convert(beamSpot.position(),orig) ;
434  ele_convert(superClusterRef->position(),scpos) ;
435  GlobalVector scvect(scpos-orig) ;
436  GlobalPoint inntkpos = innTSOS.globalPosition() ;
437  GlobalVector inntkvect = GlobalVector(inntkpos-orig) ;
438  float dPhiInnEle=normalized_phi(scvect.barePhi()-inntkvect.barePhi()) ;
439  if(dPhiInnEle>0) info.scPixCharge = -1 ;
440  else info.scPixCharge = 1 ;
441 
442  // flags
443  int chargeGsf = gsfTrackRef->charge() ;
444  info.isGsfScPixConsistent = ((chargeGsf*info.scPixCharge)>0) ;
445  info.isGsfCtfConsistent = (ctfTrackRef.isNonnull()&&((chargeGsf*ctfTrackRef->charge())>0)) ;
447 
448  // default charge
449  if (info.isGsfScPixConsistent||ctfTrackRef.isNull())
450  { charge = info.scPixCharge ; }
451  else
452  { charge = ctfTrackRef->charge() ; }
453  }
454 
456  ( const MultiTrajectoryStateTransform * mtsTransform )
457  {
458  CaloClusterPtr eleRef ;
459  TrajectoryStateOnSurface tempTSOS ;
460  TrajectoryStateOnSurface outTSOS = mtsTransform->outerStateOnSurface(*gsfTrackRef) ;
461  float dphimin = 1.e30 ;
462  for (CaloCluster_iterator bc=superClusterRef->clustersBegin(); bc!=superClusterRef->clustersEnd(); bc++)
463  {
464  GlobalPoint posclu((*bc)->position().x(),(*bc)->position().y(),(*bc)->position().z()) ;
465  tempTSOS = mtsTransform->extrapolatedState(outTSOS,posclu) ;
466  if (!tempTSOS.isValid()) tempTSOS=outTSOS ;
467  GlobalPoint extrap = tempTSOS.globalPosition() ;
468  float dphi = EleRelPointPair(posclu,extrap,beamSpot.position()).dPhi() ;
469  if (std::abs(dphi)<dphimin)
470  {
471  dphimin = std::abs(dphi) ;
472  eleRef = (*bc);
473  eleTSOS = tempTSOS ;
474  }
475  }
476  return eleRef ;
477  }
478 
480  ( const MultiTrajectoryStateTransform * mtsTransform, GsfConstraintAtVertex * constraintAtVtx )
481  {
482  //at innermost point
483  innTSOS = mtsTransform->innerStateOnSurface(*gsfTrackRef);
484  if (!innTSOS.isValid()) return false;
485 
486  //at vertex
487  // innermost state propagation to the beam spot position
488  GlobalPoint bsPos ;
489  ele_convert(beamSpot.position(),bsPos) ;
490  vtxTSOS = mtsTransform->extrapolatedState(innTSOS,bsPos) ;
491  if (!vtxTSOS.isValid()) vtxTSOS=innTSOS;
492 
493  //at seed
494  outTSOS = mtsTransform->outerStateOnSurface(*gsfTrackRef);
495  if (!outTSOS.isValid()) return false;
496 
497  // TrajectoryStateOnSurface seedTSOS
498  seedTSOS = mtsTransform->extrapolatedState(outTSOS,
499  GlobalPoint(superClusterRef->seed()->position().x(),
500  superClusterRef->seed()->position().y(),
501  superClusterRef->seed()->position().z()));
502  if (!seedTSOS.isValid()) seedTSOS=outTSOS;
503 
504  // at scl
505  sclTSOS = mtsTransform->extrapolatedState(innTSOS,GlobalPoint(superClusterRef->x(),superClusterRef->y(),superClusterRef->z()));
506  if (!sclTSOS.isValid()) sclTSOS=outTSOS;
507 
508  // constrained momentum
509  constrainedVtxTSOS = constraintAtVtx->constrainAtBeamSpot(*gsfTrackRef,beamSpot);
510 
511  return true ;
512  }
513 
515  {
516  mtsMode->momentumFromModeCartesian(innTSOS,innMom) ;
517  mtsMode->positionFromModeCartesian(innTSOS,innPos) ;
518  mtsMode->momentumFromModeCartesian(seedTSOS,seedMom) ;
519  mtsMode->positionFromModeCartesian(seedTSOS,seedPos) ;
520  mtsMode->momentumFromModeCartesian(eleTSOS,eleMom) ;
521  mtsMode->positionFromModeCartesian(eleTSOS,elePos) ;
522  mtsMode->momentumFromModeCartesian(sclTSOS,sclMom) ;
523  mtsMode->positionFromModeCartesian(sclTSOS,sclPos) ;
524  mtsMode->momentumFromModeCartesian(vtxTSOS,vtxMom) ;
525  mtsMode->positionFromModeCartesian(vtxTSOS,vtxPos) ;
526  mtsMode->momentumFromModeCartesian(outTSOS,outMom);
527  mtsMode->positionFromModeCartesian(outTSOS,outPos) ;
528  mtsMode->momentumFromModeCartesian(constrainedVtxTSOS,vtxMomWithConstraint);
529  }
530 
532  {
533  double scale = superClusterRef->energy()/vtxMom.mag() ;
535  ( vtxMom.x()*scale,vtxMom.y()*scale,vtxMom.z()*scale,
536  superClusterRef->energy() ) ;
537  }
538 
541 
542  const reco::CaloCluster & seedCluster = *(theClus->seed()) ;
543  DetId seedXtalId = seedCluster.seed();
544  int detector = seedXtalId.subdetId();
545  const EcalRecHitCollection* ecalRecHits = nullptr ;
546  if (detector==EcalBarrel)
547  ecalRecHits = eventData_->barrelRecHits.product() ;
548  else
549  ecalRecHits = eventData_->endcapRecHits.product() ;
550 
551  int nSaturatedXtals = 0;
552  bool isSeedSaturated = false;
553  const auto hitsAndFractions = theClus->hitsAndFractions();
554  for (auto&& hitFractionPair : hitsAndFractions) {
555  auto&& ecalRecHit = ecalRecHits->find(hitFractionPair.first);
556  if (ecalRecHit == ecalRecHits->end()) continue;
557  if (ecalRecHit->checkFlag(EcalRecHit::Flags::kSaturated)) {
558  nSaturatedXtals++;
559  if (seedXtalId == ecalRecHit->detid())
560  isSeedSaturated = true;
561  }
562  }
563  si.nSaturatedXtals = nSaturatedXtals;
564  si.isSeedSaturated = isSeedSaturated;
565 
566 }
567 
569  reco::GsfElectron::ShowerShape & showerShape )
570  {
571  const reco::CaloCluster & seedCluster = *(theClus->seed()) ;
572  // temporary, till CaloCluster->seed() is made available
573  DetId seedXtalId = seedCluster.hitsAndFractions()[0].first ;
574  int detector = seedXtalId.subdetId() ;
575 
578  const EcalRecHitCollection * recHits = nullptr ;
579  std::vector<int> recHitFlagsToBeExcluded ;
580  std::vector<int> recHitSeverityToBeExcluded ;
581  if (detector==EcalBarrel)
582  {
583  recHits = eventData_->barrelRecHits.product() ;
584  recHitFlagsToBeExcluded = generalData_->recHitsCfg.recHitFlagsToBeExcludedBarrel ;
585  recHitSeverityToBeExcluded = generalData_->recHitsCfg.recHitSeverityToBeExcludedBarrel ;
586  }
587  else
588  {
589  recHits = eventData_->endcapRecHits.product() ;
590  recHitFlagsToBeExcluded = generalData_->recHitsCfg.recHitFlagsToBeExcludedEndcaps ;
591  recHitSeverityToBeExcluded = generalData_->recHitsCfg.recHitSeverityToBeExcludedEndcaps ;
592  }
593 
594  std::vector<float> covariances = EcalClusterTools::covariances(seedCluster,recHits,topology,geometry) ;
595  std::vector<float> localCovariances = EcalClusterTools::localCovariances(seedCluster,recHits,topology) ;
596  showerShape.sigmaEtaEta = sqrt(covariances[0]) ;
597  showerShape.sigmaIetaIeta = sqrt(localCovariances[0]) ;
598  if (!edm::isNotFinite(localCovariances[2])) showerShape.sigmaIphiIphi = sqrt(localCovariances[2]) ;
599  showerShape.e1x5 = EcalClusterTools::e1x5(seedCluster,recHits,topology) ;
600  showerShape.e2x5Max = EcalClusterTools::e2x5Max(seedCluster,recHits,topology) ;
601  showerShape.e5x5 = EcalClusterTools::e5x5(seedCluster,recHits,topology) ;
602  showerShape.r9 = EcalClusterTools::e3x3(seedCluster,recHits,topology)/theClus->rawEnergy() ;
603 
604  if (pflow)
605  {
606  showerShape.hcalDepth1OverEcal = generalData_->hcalHelperPflow->hcalESumDepth1(*theClus)/theClus->energy() ;
607  showerShape.hcalDepth2OverEcal = generalData_->hcalHelperPflow->hcalESumDepth2(*theClus)/theClus->energy() ;
611  }
612  else
613  {
614  showerShape.hcalDepth1OverEcal = generalData_->hcalHelper->hcalESumDepth1(*theClus)/theClus->energy() ;
615  showerShape.hcalDepth2OverEcal = generalData_->hcalHelper->hcalESumDepth2(*theClus)/theClus->energy() ;
619  }
620 
621  // extra shower shapes
622  const float see_by_spp = showerShape.sigmaIetaIeta*showerShape.sigmaIphiIphi;
623  if( see_by_spp > 0 ) {
624  showerShape.sigmaIetaIphi = localCovariances[1] / see_by_spp;
625  } else if ( localCovariances[1] > 0 ) {
626  showerShape.sigmaIetaIphi = 1.f;
627  } else {
628  showerShape.sigmaIetaIphi = -1.f;
629  }
630  showerShape.eMax = EcalClusterTools::eMax(seedCluster,recHits);
631  showerShape.e2nd = EcalClusterTools::e2nd(seedCluster,recHits);
632  showerShape.eTop = EcalClusterTools::eTop(seedCluster,recHits,topology);
633  showerShape.eLeft = EcalClusterTools::eLeft(seedCluster,recHits,topology);
634  showerShape.eRight = EcalClusterTools::eRight(seedCluster,recHits,topology);
635  showerShape.eBottom = EcalClusterTools::eBottom(seedCluster,recHits,topology);
636 
637  showerShape.e2x5Left = EcalClusterTools::e2x5Left(seedCluster,recHits,topology);
638  showerShape.e2x5Right = EcalClusterTools::e2x5Right(seedCluster,recHits,topology);
639  showerShape.e2x5Top = EcalClusterTools::e2x5Top(seedCluster,recHits,topology);
640  showerShape.e2x5Bottom = EcalClusterTools::e2x5Bottom(seedCluster,recHits,topology);
641  }
642 
644  reco::GsfElectron::ShowerShape & showerShape )
645  {
646  const reco::CaloCluster & seedCluster = *(theClus->seed()) ;
647  // temporary, till CaloCluster->seed() is made available
648  DetId seedXtalId = seedCluster.hitsAndFractions()[0].first ;
649  int detector = seedXtalId.subdetId() ;
650 
653  const EcalRecHitCollection * recHits = nullptr ;
654  std::vector<int> recHitFlagsToBeExcluded ;
655  std::vector<int> recHitSeverityToBeExcluded ;
656  if (detector==EcalBarrel)
657  {
658  recHits = eventData_->barrelRecHits.product() ;
659  recHitFlagsToBeExcluded = generalData_->recHitsCfg.recHitFlagsToBeExcludedBarrel ;
660  recHitSeverityToBeExcluded = generalData_->recHitsCfg.recHitSeverityToBeExcludedBarrel ;
661  }
662  else
663  {
664  recHits = eventData_->endcapRecHits.product() ;
665  recHitFlagsToBeExcluded = generalData_->recHitsCfg.recHitFlagsToBeExcludedEndcaps ;
666  recHitSeverityToBeExcluded = generalData_->recHitsCfg.recHitSeverityToBeExcludedEndcaps ;
667  }
668 
669  std::vector<float> covariances = noZS::EcalClusterTools::covariances(seedCluster,recHits,topology,geometry) ;
670  std::vector<float> localCovariances = noZS::EcalClusterTools::localCovariances(seedCluster,recHits,topology) ;
671  showerShape.sigmaEtaEta = sqrt(covariances[0]) ;
672  showerShape.sigmaIetaIeta = sqrt(localCovariances[0]) ;
673  if (!edm::isNotFinite(localCovariances[2])) showerShape.sigmaIphiIphi = sqrt(localCovariances[2]) ;
674  showerShape.e1x5 = noZS::EcalClusterTools::e1x5(seedCluster,recHits,topology) ;
675  showerShape.e2x5Max = noZS::EcalClusterTools::e2x5Max(seedCluster,recHits,topology) ;
676  showerShape.e5x5 = noZS::EcalClusterTools::e5x5(seedCluster,recHits,topology) ;
677  showerShape.r9 = noZS::EcalClusterTools::e3x3(seedCluster,recHits,topology)/theClus->rawEnergy() ;
678 
679  if (pflow)
680  {
681  showerShape.hcalDepth1OverEcal = generalData_->hcalHelperPflow->hcalESumDepth1(*theClus)/theClus->energy() ;
682  showerShape.hcalDepth2OverEcal = generalData_->hcalHelperPflow->hcalESumDepth2(*theClus)/theClus->energy() ;
686  }
687  else
688  {
689  showerShape.hcalDepth1OverEcal = generalData_->hcalHelper->hcalESumDepth1(*theClus)/theClus->energy() ;
690  showerShape.hcalDepth2OverEcal = generalData_->hcalHelper->hcalESumDepth2(*theClus)/theClus->energy() ;
694  }
695 
696  // extra shower shapes
697  const float see_by_spp = showerShape.sigmaIetaIeta*showerShape.sigmaIphiIphi;
698  if( see_by_spp > 0 ) {
699  showerShape.sigmaIetaIphi = localCovariances[1] / see_by_spp;
700  } else if ( localCovariances[1] > 0 ) {
701  showerShape.sigmaIetaIphi = 1.f;
702  } else {
703  showerShape.sigmaIetaIphi = -1.f;
704  }
705  showerShape.eMax = noZS::EcalClusterTools::eMax(seedCluster,recHits);
706  showerShape.e2nd = noZS::EcalClusterTools::e2nd(seedCluster,recHits);
707  showerShape.eTop = noZS::EcalClusterTools::eTop(seedCluster,recHits,topology);
708  showerShape.eLeft = noZS::EcalClusterTools::eLeft(seedCluster,recHits,topology);
709  showerShape.eRight = noZS::EcalClusterTools::eRight(seedCluster,recHits,topology);
710  showerShape.eBottom = noZS::EcalClusterTools::eBottom(seedCluster,recHits,topology);
711 
712  showerShape.e2x5Left = noZS::EcalClusterTools::e2x5Left(seedCluster,recHits,topology);
713  showerShape.e2x5Right = noZS::EcalClusterTools::e2x5Right(seedCluster,recHits,topology);
714  showerShape.e2x5Top = noZS::EcalClusterTools::e2x5Top(seedCluster,recHits,topology);
715  showerShape.e2x5Bottom = noZS::EcalClusterTools::e2x5Bottom(seedCluster,recHits,topology);
716 
717  }
718 
719 
720 //===================================================================
721 // GsfElectronAlgo
722 //===================================================================
723 
725  ( const InputTagsConfiguration & inputCfg,
726  const StrategyConfiguration & strategyCfg,
727  const CutsConfiguration & cutsCfg,
728  const CutsConfiguration & cutsCfgPflow,
729  const ElectronHcalHelper::Configuration & hcalCfg,
730  const ElectronHcalHelper::Configuration & hcalCfgPflow,
731  const IsolationConfiguration & isoCfg,
732  const EcalRecHitsConfiguration & recHitsCfg,
735  const SoftElectronMVAEstimator::Configuration & mva_NIso_Cfg,
736  const ElectronMVAEstimator::Configuration & mva_Iso_Cfg,
737  const RegressionHelper::Configuration & regCfg,
738  const edm::ParameterSet& tkIsol03Cfg,
739  const edm::ParameterSet& tkIsol04Cfg
740 
741  )
742  : generalData_(new GeneralData(inputCfg,strategyCfg,cutsCfg,cutsCfgPflow,hcalCfg,hcalCfgPflow,isoCfg,recHitsCfg,superClusterErrorFunction,crackCorrectionFunction,mva_NIso_Cfg,mva_Iso_Cfg,regCfg)),
744  eventData_(nullptr), electronData_(nullptr),
745  tkIsol03Calc_(tkIsol03Cfg),tkIsol04Calc_(tkIsol04Cfg)
746  {}
747 
749  {
750  delete generalData_ ;
751  delete eventSetupData_ ;
752  delete eventData_ ;
753  delete electronData_ ;
754  }
755 
757  {
758  // get EventSetupRecords if needed
759  bool updateField(false);
761  updateField = true;
764  }
765 
766  bool updateGeometry(false);
768  updateGeometry = true;
771  }
772 
773  if ( updateField || updateGeometry ) {
774  delete eventSetupData_->mtsTransform ;
778  }
779 
781  eventSetupData_->cacheIDGeom=es.get<CaloGeometryRecord>().cacheIdentifier();
783  }
784 
786  eventSetupData_->cacheIDTopo=es.get<CaloTopologyRecord>().cacheIdentifier();
788  }
789 
794 
795 
800 
801  //if(eventSetupData_->cacheChStatus!=es.get<EcalChannelStatusRcd>().cacheIdentifier()){
802  // eventSetupData_->cacheChStatus=es.get<EcalChannelStatusRcd>().cacheIdentifier();
803  // es.get<EcalChannelStatusRcd>().get(eventSetupData_->chStatus);
804  //}
805 
807  eventSetupData_->cacheSevLevel = es.get<EcalSeverityLevelAlgoRcd>().cacheIdentifier();
809  }
810  }
811 
812 
814  {
815  GsfElectronPtrCollection::const_iterator it ;
816  for
817  ( it = eventData_->electrons->begin() ;
818  it != eventData_->electrons->end() ;
819  it++ )
820  { outEle.push_back(**it) ; }
821  }
822 
824  {
825  if (eventData_!=nullptr)
826  { throw cms::Exception("GsfElectronAlgo|InternalError")<<"unexpected event data" ; }
827  eventData_ = new EventData ;
828 
829  // init the handles linked to the current event
830  eventData_->event = &event ;
837  event.getByToken(generalData_->inputCfg.hcalTowersTag,eventData_->towers) ;
838  event.getByToken(generalData_->inputCfg.pfMVA,eventData_->pfMva) ;
839  event.getByToken(generalData_->inputCfg.seedsTag,eventData_->seeds) ;
843 
844  // get the beamspot from the Event:
845  edm::Handle<reco::BeamSpot> recoBeamSpotHandle ;
846  event.getByToken(generalData_->inputCfg.beamSpotTag,recoBeamSpotHandle) ;
847  eventData_->beamspot = recoBeamSpotHandle.product() ;
848 
849  // prepare access to hcal data
852 
853  // Isolation algos
854  float egHcalIsoConeSizeOutSmall=0.3, egHcalIsoConeSizeOutLarge=0.4;
855  float egHcalIsoConeSizeIn=generalData_->isoCfg.intRadiusHcal,egHcalIsoPtMin=generalData_->isoCfg.etMinHcal;
856  int egHcalDepth1=1, egHcalDepth2=2;
857  eventData_->hadDepth1Isolation03 = new EgammaTowerIsolation(egHcalIsoConeSizeOutSmall,egHcalIsoConeSizeIn,egHcalIsoPtMin,egHcalDepth1,eventData_->towers.product()) ;
858  eventData_->hadDepth2Isolation03 = new EgammaTowerIsolation(egHcalIsoConeSizeOutSmall,egHcalIsoConeSizeIn,egHcalIsoPtMin,egHcalDepth2,eventData_->towers.product()) ;
859  eventData_->hadDepth1Isolation04 = new EgammaTowerIsolation(egHcalIsoConeSizeOutLarge,egHcalIsoConeSizeIn,egHcalIsoPtMin,egHcalDepth1,eventData_->towers.product()) ;
860  eventData_->hadDepth2Isolation04 = new EgammaTowerIsolation(egHcalIsoConeSizeOutLarge,egHcalIsoConeSizeIn,egHcalIsoPtMin,egHcalDepth2,eventData_->towers.product()) ;
861  eventData_->hadDepth1Isolation03Bc = new EgammaTowerIsolation(egHcalIsoConeSizeOutSmall,0.,egHcalIsoPtMin,egHcalDepth1,eventData_->towers.product()) ;
862  eventData_->hadDepth2Isolation03Bc = new EgammaTowerIsolation(egHcalIsoConeSizeOutSmall,0.,egHcalIsoPtMin,egHcalDepth2,eventData_->towers.product()) ;
863  eventData_->hadDepth1Isolation04Bc = new EgammaTowerIsolation(egHcalIsoConeSizeOutLarge,0.,egHcalIsoPtMin,egHcalDepth1,eventData_->towers.product()) ;
864  eventData_->hadDepth2Isolation04Bc = new EgammaTowerIsolation(egHcalIsoConeSizeOutLarge,0.,egHcalIsoPtMin,egHcalDepth2,eventData_->towers.product()) ;
865 
866  float egIsoConeSizeOutSmall=0.3, egIsoConeSizeOutLarge=0.4, egIsoJurassicWidth=generalData_->isoCfg.jurassicWidth;
867  float egIsoPtMinBarrel=generalData_->isoCfg.etMinBarrel,egIsoEMinBarrel=generalData_->isoCfg.eMinBarrel, egIsoConeSizeInBarrel=generalData_->isoCfg.intRadiusEcalBarrel;
868  float egIsoPtMinEndcap=generalData_->isoCfg.etMinEndcaps,egIsoEMinEndcap=generalData_->isoCfg.eMinEndcaps, egIsoConeSizeInEndcap=generalData_->isoCfg.intRadiusEcalEndcaps;
869  eventData_->ecalBarrelIsol03 = new EgammaRecHitIsolation(egIsoConeSizeOutSmall,egIsoConeSizeInBarrel,egIsoJurassicWidth,egIsoPtMinBarrel,egIsoEMinBarrel,eventSetupData_->caloGeom,*(eventData_->barrelRecHits),eventSetupData_->sevLevel.product(),DetId::Ecal);
870  eventData_->ecalBarrelIsol04 = new EgammaRecHitIsolation(egIsoConeSizeOutLarge,egIsoConeSizeInBarrel,egIsoJurassicWidth,egIsoPtMinBarrel,egIsoEMinBarrel,eventSetupData_->caloGeom,*(eventData_->barrelRecHits),eventSetupData_->sevLevel.product(),DetId::Ecal);
871  eventData_->ecalEndcapIsol03 = new EgammaRecHitIsolation(egIsoConeSizeOutSmall,egIsoConeSizeInEndcap,egIsoJurassicWidth,egIsoPtMinEndcap,egIsoEMinEndcap,eventSetupData_->caloGeom,*(eventData_->endcapRecHits),eventSetupData_->sevLevel.product(),DetId::Ecal);
872  eventData_->ecalEndcapIsol04 = new EgammaRecHitIsolation(egIsoConeSizeOutLarge,egIsoConeSizeInEndcap,egIsoJurassicWidth,egIsoPtMinEndcap,egIsoEMinEndcap,eventSetupData_->caloGeom,*(eventData_->endcapRecHits),eventSetupData_->sevLevel.product(),DetId::Ecal);
889 
890  //Fill in the Isolation Value Maps for PF and EcalDriven electrons
891  std::vector<edm::InputTag> inputTagIsoVals;
893  inputTagIsoVals.push_back(generalData_->inputCfg.pfIsoVals.getParameter<edm::InputTag>("pfSumChargedHadronPt"));
894  inputTagIsoVals.push_back(generalData_->inputCfg.pfIsoVals.getParameter<edm::InputTag>("pfSumPhotonEt"));
895  inputTagIsoVals.push_back(generalData_->inputCfg.pfIsoVals.getParameter<edm::InputTag>("pfSumNeutralHadronEt"));
896 
897  eventData_->pfIsolationValues.resize(inputTagIsoVals.size());
898 
899  for (size_t j = 0; j<inputTagIsoVals.size(); ++j) {
900  event.getByLabel(inputTagIsoVals[j], eventData_->pfIsolationValues[j]);
901  }
902 
903  }
904 
906  inputTagIsoVals.clear();
907  inputTagIsoVals.push_back(generalData_->inputCfg.edIsoVals.getParameter<edm::InputTag>("edSumChargedHadronPt"));
908  inputTagIsoVals.push_back(generalData_->inputCfg.edIsoVals.getParameter<edm::InputTag>("edSumPhotonEt"));
909  inputTagIsoVals.push_back(generalData_->inputCfg.edIsoVals.getParameter<edm::InputTag>("edSumNeutralHadronEt"));
910 
911  eventData_->edIsolationValues.resize(inputTagIsoVals.size());
912 
913  for (size_t j = 0; j<inputTagIsoVals.size(); ++j) {
914  event.getByLabel(inputTagIsoVals[j], eventData_->edIsolationValues[j]);
915  }
916  }
917  }
918 
920  {
921  if (eventData_==nullptr)
922  { throw cms::Exception("GsfElectronAlgo|InternalError")<<"lacking event data" ; }
923  delete eventData_ ;
924  eventData_ = nullptr ;
925  }
926 
928  {
929  LogTrace("GsfElectronAlgo") << "========== " << title << " ==========";
930  LogTrace("GsfElectronAlgo") << "Event: " << eventData_->event->id();
931  LogTrace("GsfElectronAlgo") << "Number of electrons: " << eventData_->electrons->size() ;
932  GsfElectronPtrCollection::const_iterator it ;
933  for ( it = eventData_->electrons->begin(); it != eventData_->electrons->end(); it++ )
934  {
935  LogTrace("GsfElectronAlgo") << "Electron with charge, pt, eta, phi: " << (*it)->charge() << " , "
936  << (*it)->pt() << " , " << (*it)->eta() << " , " << (*it)->phi();
937  }
938  LogTrace("GsfElectronAlgo") << "=================================================";
939  }
940 
942  {
943  if (electronData_!=nullptr)
944  { throw cms::Exception("GsfElectronAlgo|InternalError")<<"unexpected electron data" ; }
945 
946  const GsfElectronCoreCollection * coreCollection = eventData_->coreElectrons.product() ;
947  for ( unsigned int i=0 ; i<coreCollection->size() ; ++i )
948  {
949  // check there is no existing electron with this core
951  bool coreFound = false ;
952  GsfElectronPtrCollection::const_iterator itrEle ;
953  for
954  ( itrEle = eventData_->electrons->begin() ;
955  itrEle != eventData_->electrons->end() ;
956  itrEle++ )
957  {
958  if ((*itrEle)->core()==coreRef)
959  {
960  coreFound = true ;
961  break ;
962  }
963  }
964  if (coreFound) continue ;
965 
966  // check there is a super-cluster
967  if (coreRef->superCluster().isNull()) continue ;
968 
969  // prepare internal structure for electron specific data
970  delete electronData_ ;
971  electronData_ = new ElectronData(coreRef,*eventData_->beamspot) ;
972 
973  // calculate and check Trajectory StatesOnSurface....
975 
976  createElectron(hoc) ;
977 
978  } // loop over tracks
979 
980  delete electronData_ ;
982  }
983 
985  {
986  const GsfElectronCollection * oldElectrons = eventData_->previousElectrons.product() ;
988  GsfElectronCollection::const_iterator oldElectron ;
989  for
990  ( oldElectron = oldElectrons->begin() ;
991  oldElectron != oldElectrons->end() ;
992  ++oldElectron )
993  {
994  const GsfElectronCoreRef oldCoreRef = oldElectron->core() ;
995  const GsfTrackRef oldElectronGsfTrackRef = oldCoreRef->gsfTrack() ;
996  unsigned int icore ;
997  for ( icore=0 ; icore<newCores->size() ; ++icore )
998  {
999  if (oldElectronGsfTrackRef==(*newCores)[icore].gsfTrack())
1000  {
1002  eventData_->electrons->push_back(new GsfElectron(*oldElectron,coreRef)) ;
1003  break ;
1004  }
1005  }
1006  }
1007  }
1008 
1009 
1010 // now deprecated
1012  {
1013  bool found ;
1014  const GsfElectronCollection * edElectrons = eventData_->previousElectrons.product() ;
1015  const GsfElectronCollection * pfElectrons = eventData_->pflowElectrons.product() ;
1016  GsfElectronCollection::const_iterator pfElectron, edElectron ;
1017  unsigned int edIndex, pfIndex ;
1018 
1019  GsfElectronPtrCollection::iterator el ;
1020  for
1021  ( el = eventData_->electrons->begin() ;
1022  el != eventData_->electrons->end() ;
1023  el++ )
1024  {
1025 
1026  // Retreive info from pflow electrons
1027  found = false ;
1028  for
1029  ( pfIndex = 0, pfElectron = pfElectrons->begin() ; pfElectron != pfElectrons->end() ; pfIndex++, pfElectron++ )
1030  {
1031  if (pfElectron->gsfTrack()==(*el)->gsfTrack())
1032  {
1033  if (found)
1034  {
1035  edm::LogWarning("GsfElectronProducer")<<"associated pfGsfElectron already found" ;
1036  }
1037  else
1038  {
1039  found = true ;
1040 
1041  // Isolation Values
1042  if( !(eventData_->pfIsolationValues).empty() )
1043  {
1045  pfElectronRef(eventData_->pflowElectrons, pfIndex);
1047  isoVariables.sumChargedHadronPt =(*(eventData_->pfIsolationValues)[0])[pfElectronRef];
1048  isoVariables.sumPhotonEt =(*(eventData_->pfIsolationValues)[1])[pfElectronRef];
1049  isoVariables.sumNeutralHadronEt =(*(eventData_->pfIsolationValues)[2])[pfElectronRef];
1050  (*el)->setPfIsolationVariables(isoVariables);
1051  }
1052 
1053 // (*el)->setPfIsolationVariables(pfElectron->pfIsolationVariables()) ;
1054  (*el)->setMvaInput(pfElectron->mvaInput()) ;
1055  (*el)->setMvaOutput(pfElectron->mvaOutput()) ;
1056  if ((*el)->ecalDrivenSeed())
1057  { (*el)->setP4(GsfElectron::P4_PFLOW_COMBINATION,pfElectron->p4(GsfElectron::P4_PFLOW_COMBINATION),pfElectron->p4Error(GsfElectron::P4_PFLOW_COMBINATION),false) ; }
1058  else
1059  { (*el)->setP4(GsfElectron::P4_PFLOW_COMBINATION,pfElectron->p4(GsfElectron::P4_PFLOW_COMBINATION),pfElectron->p4Error(GsfElectron::P4_PFLOW_COMBINATION),true) ; }
1060  double noCutMin = -999999999. ;
1061  if ((*el)->mva_e_pi()<noCutMin) { throw cms::Exception("GsfElectronAlgo|UnexpectedMvaValue")<<"unexpected MVA value: "<<(*el)->mva_e_pi() ; }
1062  }
1063  }
1064  }
1065 
1066  // Isolation Values
1067  // Retreive not found info from ed electrons
1068  if( !(eventData_->edIsolationValues).empty() )
1069  {
1070  edIndex = 0, edElectron = edElectrons->begin() ;
1071  while ((found == false)&&(edElectron != edElectrons->end()))
1072  {
1073  if (edElectron->gsfTrack()==(*el)->gsfTrack())
1074  {
1075  found = true ;
1076 
1077  // CONSTRUCTION D UNE REF dans le handle eventData_->previousElectrons avec l'indice edIndex,
1078  // puis recuperation dans la ValueMap ED
1079 
1081  edElectronRef(eventData_->previousElectrons, edIndex);
1083  isoVariables.sumChargedHadronPt =(*(eventData_->edIsolationValues)[0])[edElectronRef];
1084  isoVariables.sumPhotonEt =(*(eventData_->edIsolationValues)[1])[edElectronRef];
1085  isoVariables.sumNeutralHadronEt =(*(eventData_->edIsolationValues)[2])[edElectronRef];
1086  (*el)->setPfIsolationVariables(isoVariables);
1087  }
1088 
1089  edIndex++ ;
1090  edElectron++ ;
1091  }
1092  }
1093 
1094  // Preselection
1096 
1097  }
1098  }
1099 
1101  {
1102  bool passCutBased=ele->passingCutBasedPreselection();
1103  bool passPF=ele->passingPflowPreselection(); //it is worth nothing for gedGsfElectrons, this does nothing as its not set till GedGsfElectron finaliser, this is always false
1105  bool passmva=ele->passingMvaPreselection();
1106  if(!ele->ecalDrivenSeed()){
1108  return passmva && passCutBased;
1109  else
1110  return passmva;
1111  }
1112  else{
1113  return passCutBased || passPF || passmva;
1114  }
1115  }
1116  else{
1117  return passCutBased || passPF;
1118  }
1119 
1120  return true;
1121  }
1122 
1124  {
1125  GsfElectronPtrCollection::size_type ei = 1, emax = eventData_->electrons->size() ;
1126  GsfElectronPtrCollection::iterator eitr = eventData_->electrons->begin() ;
1127  while (eitr!=eventData_->electrons->end())
1128  {
1129  LogTrace("GsfElectronAlgo")<<"========== removed not preselected "<<ei<<"/"<<emax<<"==========" ;
1130  if (isPreselected(*eitr))
1131  { ++eitr ; ++ei ; }
1132  else
1133  { delete (*eitr) ; eitr = eventData_->electrons->erase(eitr) ; ++ei ; }
1134  }
1135  }
1136 
1137 
1139  {
1140  // default value
1141  ele->setPassCutBasedPreselection(false) ;
1142 
1143  // kind of seeding
1144  bool eg = ele->core()->ecalDrivenSeed() ;
1145  bool pf = ele->core()->trackerDrivenSeed() && !ele->core()->ecalDrivenSeed() ;
1146  bool gedMode = generalData_->strategyCfg.gedElectronMode;
1147  if (eg&&pf) { throw cms::Exception("GsfElectronAlgo|BothEcalAndPureTrackerDriven")<<"An electron cannot be both egamma and purely pflow" ; }
1148  if ((!eg)&&(!pf)) { throw cms::Exception("GsfElectronAlgo|NeitherEcalNorPureTrackerDriven")<<"An electron cannot be neither egamma nor purely pflow" ; }
1149 
1150  const CutsConfiguration * cfg = ((eg||gedMode)?&generalData_->cutsCfg:&generalData_->cutsCfgPflow);
1151 
1152  // Et cut
1153  double etaValue = EleRelPoint(ele->superCluster()->position(),bs.position()).eta() ;
1154  double etValue = ele->superCluster()->energy()/cosh(etaValue) ;
1155  LogTrace("GsfElectronAlgo") << "Et : " << etValue ;
1156  if (ele->isEB() && (etValue < cfg->minSCEtBarrel)) return ;
1157  if (ele->isEE() && (etValue < cfg->minSCEtEndcaps)) return ;
1158  LogTrace("GsfElectronAlgo") << "Et criteria are satisfied";
1159 
1160  // E/p cut
1161  double eopValue = ele->eSuperClusterOverP() ;
1162  LogTrace("GsfElectronAlgo") << "E/p : " << eopValue ;
1163  if (ele->isEB() && (eopValue > cfg->maxEOverPBarrel)) return ;
1164  if (ele->isEE() && (eopValue > cfg->maxEOverPEndcaps)) return ;
1165  if (ele->isEB() && (eopValue < cfg->minEOverPBarrel)) return ;
1166  if (ele->isEE() && (eopValue < cfg->minEOverPEndcaps)) return ;
1167  LogTrace("GsfElectronAlgo") << "E/p criteria are satisfied";
1168 
1169  // HoE cuts
1170  LogTrace("GsfElectronAlgo") << "HoE1 : " << ele->hcalDepth1OverEcal() << ", HoE2 : " << ele->hcalDepth2OverEcal();
1171  double had = ele->hcalOverEcal()*ele->superCluster()->energy() ;
1172  const reco::CaloCluster & seedCluster = *(ele->superCluster()->seed()) ;
1173  int detector = seedCluster.hitsAndFractions()[0].first.subdetId() ;
1174  bool HoEveto = false ;
1175  if (detector==EcalBarrel && (had<cfg->maxHBarrel || (had/ele->superCluster()->energy())<cfg->maxHOverEBarrel)) HoEveto=true;
1176  else if (detector==EcalEndcap && (had<cfg->maxHEndcaps || (had/ele->superCluster()->energy())<cfg->maxHOverEEndcaps)) HoEveto=true;
1177  if ( !HoEveto ) return ;
1178  LogTrace("GsfElectronAlgo") << "H/E criteria are satisfied";
1179 
1180  // delta eta criteria
1181  double deta = ele->deltaEtaSuperClusterTrackAtVtx() ;
1182  LogTrace("GsfElectronAlgo") << "delta eta : " << deta ;
1183  if (ele->isEB() && (std::abs(deta) > cfg->maxDeltaEtaBarrel)) return ;
1184  if (ele->isEE() && (std::abs(deta) > cfg->maxDeltaEtaEndcaps)) return ;
1185  LogTrace("GsfElectronAlgo") << "Delta eta criteria are satisfied";
1186 
1187  // delta phi criteria
1188  double dphi = ele->deltaPhiSuperClusterTrackAtVtx();
1189  LogTrace("GsfElectronAlgo") << "delta phi : " << dphi;
1190  if (ele->isEB() && (std::abs(dphi) > cfg->maxDeltaPhiBarrel)) return ;
1191  if (ele->isEE() && (std::abs(dphi) > cfg->maxDeltaPhiEndcaps)) return ;
1192  LogTrace("GsfElectronAlgo") << "Delta phi criteria are satisfied";
1193 
1194  // sigma ieta ieta
1195  LogTrace("GsfElectronAlgo") << "sigma ieta ieta : " << ele->sigmaIetaIeta();
1196  if (ele->isEB() && (ele->sigmaIetaIeta() > cfg->maxSigmaIetaIetaBarrel)) return ;
1197  if (ele->isEE() && (ele->sigmaIetaIeta() > cfg->maxSigmaIetaIetaEndcaps)) return ;
1198  LogTrace("GsfElectronAlgo") << "Sigma ieta ieta criteria are satisfied";
1199 
1200  // fiducial
1201  if (!ele->isEB() && cfg->isBarrel) return ;
1202  if (!ele->isEE() && cfg->isEndcaps) return ;
1203  if (cfg->isFiducial && (ele->isEBEEGap()||ele->isEBEtaGap()||ele->isEBPhiGap()||ele->isEERingGap()||ele->isEEDeeGap())) return ;
1204  LogTrace("GsfElectronAlgo") << "Fiducial flags criteria are satisfied";
1205 
1206  // seed in TEC
1207  edm::RefToBase<TrajectorySeed> seed = ele->gsfTrack()->extra()->seedRef() ;
1208  ElectronSeedRef elseed = seed.castTo<ElectronSeedRef>() ;
1209  if (eg && !generalData_->cutsCfg.seedFromTEC)
1210  {
1211  if (elseed.isNull())
1212  { throw cms::Exception("GsfElectronAlgo|NotElectronSeed")<<"The GsfTrack seed is not an ElectronSeed ?!" ; }
1213  else
1214  { if (elseed->subDet2()==6) return ; }
1215  }
1216 
1217  // transverse impact parameter
1218  if (std::abs(ele->gsfTrack()->dxy(bs.position()))>cfg->maxTIP) return ;
1219  LogTrace("GsfElectronAlgo") << "TIP criterion is satisfied" ;
1220 
1221  LogTrace("GsfElectronAlgo") << "All cut based criteria are satisfied" ;
1222  ele->setPassCutBasedPreselection(true) ;
1223  }
1224 
1226  {
1227  ele->setPassMvaPreselection(false) ;
1228 
1229  if (ele->core()->ecalDrivenSeed())
1230  { if (ele->mvaOutput().mva_e_pi>=generalData_->cutsCfg.minMVA) ele->setPassMvaPreselection(true) ; }
1231  else
1233 
1234  if (ele->passingMvaPreselection())
1235  { LogTrace("GsfElectronAlgo") << "Main mva criterion is satisfied" ; }
1236 
1238 
1239  }
1240 
1241 void GsfElectronAlgo::setMVAInputs(const std::map<reco::GsfTrackRef,reco::GsfElectron::MvaInput> & mvaInputs)
1242 {
1243  GsfElectronPtrCollection::iterator el ;
1244  for
1245  ( el = eventData_->electrons->begin() ;
1246  el != eventData_->electrons->end() ;
1247  el++ )
1248  {
1249  std::map<reco::GsfTrackRef,reco::GsfElectron::MvaInput>::const_iterator itcheck=mvaInputs.find((*el)->gsfTrack());
1250  (*el)->setMvaInput(itcheck->second);
1251  }
1252 }
1253 
1255  const std::map<reco::GsfTrackRef,reco::GsfElectron::MvaOutput> & mvaOutputs)
1256 {
1257  GsfElectronPtrCollection::iterator el ;
1258  for
1259  ( el = eventData_->electrons->begin() ;
1260  el != eventData_->electrons->end() ;
1261  el++ )
1262  {
1264  float mva_NIso_Value= hoc->sElectronMVAEstimator->mva( *(*el), *(eventData_->vertices));
1265  float mva_Iso_Value = hoc->iElectronMVAEstimator->mva( *(*el), eventData_->vertices->size() );
1266  GsfElectron::MvaOutput mvaOutput ;
1267  mvaOutput.mva_e_pi = mva_NIso_Value ;
1268  mvaOutput.mva_Isolated = mva_Iso_Value ;
1269  (*el)->setMvaOutput(mvaOutput);
1270  }
1271  else{
1272  std::map<reco::GsfTrackRef,reco::GsfElectron::MvaOutput>::const_iterator itcheck=mvaOutputs.find((*el)->gsfTrack());
1273  (*el)->setMvaOutput(itcheck->second);
1274  }
1275  }
1276 }
1277 
1279  {
1280  // eventually check ctf track
1283 
1284  // charge ID
1285  int eleCharge ;
1286  GsfElectron::ChargeInfo eleChargeInfo ;
1287  electronData_->computeCharge(eleCharge,eleChargeInfo) ;
1288 
1289  // electron basic cluster
1291 
1292  // Seed cluster
1293  const reco::CaloCluster & seedCluster = *(electronData_->superClusterRef->seed()) ;
1294 
1295  // seed Xtal
1296  // temporary, till CaloCluster->seed() is made available
1297  DetId seedXtalId = seedCluster.hitsAndFractions()[0].first ;
1298 
1300 
1301 
1302  //====================================================
1303  // Candidate attributes
1304  //====================================================
1305 
1307 
1308 
1309  //====================================================
1310  // Track-Cluster Matching
1311  //====================================================
1312 
1314  tcMatching.electronCluster = elbcRef ;
1315  tcMatching.eSuperClusterOverP = (electronData_->vtxMom.mag()>0)?(electronData_->superClusterRef->energy()/electronData_->vtxMom.mag()):(-1.) ;
1316  tcMatching.eSeedClusterOverP = (electronData_->vtxMom.mag()>0.)?(seedCluster.energy()/electronData_->vtxMom.mag()):(-1) ;
1317  tcMatching.eSeedClusterOverPout = (electronData_->seedMom.mag()>0.)?(seedCluster.energy()/electronData_->seedMom.mag()):(-1.) ;
1318  tcMatching.eEleClusterOverPout = (electronData_->eleMom.mag()>0.)?(elbcRef->energy()/electronData_->eleMom.mag()):(-1.) ;
1319 
1321  tcMatching.deltaEtaSuperClusterAtVtx = scAtVtx.dEta() ;
1322  tcMatching.deltaPhiSuperClusterAtVtx = scAtVtx.dPhi() ;
1323 
1324  EleRelPointPair seedAtCalo(seedCluster.position(),electronData_->seedPos,eventData_->beamspot->position()) ;
1325  tcMatching.deltaEtaSeedClusterAtCalo = seedAtCalo.dEta() ;
1326  tcMatching.deltaPhiSeedClusterAtCalo = seedAtCalo.dPhi() ;
1327 
1329  tcMatching.deltaEtaEleClusterAtCalo = ecAtCalo.dEta() ;
1330  tcMatching.deltaPhiEleClusterAtCalo = ecAtCalo.dPhi() ;
1331 
1332 
1333  //=======================================================
1334  // Track extrapolations
1335  //=======================================================
1336 
1345 
1346 
1347  //=======================================================
1348  // Closest Ctf Track
1349  //=======================================================
1350 
1352  ctfInfo.ctfTrack = electronData_->ctfTrackRef ;
1354 
1355 
1356  //====================================================
1357  // FiducialFlags, using nextToBoundary definition of gaps
1358  //====================================================
1359 
1360  reco::GsfElectron::FiducialFlags fiducialFlags ;
1361  int region = seedXtalId.det();
1362  int detector = seedXtalId.subdetId() ;
1363  double feta=std::abs(electronData_->superClusterRef->position().eta()) ;
1364  if (detector==EcalBarrel)
1365  {
1366  fiducialFlags.isEB = true ;
1367  EBDetId ebdetid(seedXtalId);
1368  if (EBDetId::isNextToEtaBoundary(ebdetid))
1369  {
1370  if (ebdetid.ietaAbs()==85)
1371  { fiducialFlags.isEBEEGap = true ; }
1372  else
1373  { fiducialFlags.isEBEtaGap = true ; }
1374  }
1375  if (EBDetId::isNextToPhiBoundary(ebdetid))
1376  { fiducialFlags.isEBPhiGap = true ; }
1377  }
1378  else if (detector==EcalEndcap)
1379  {
1380  fiducialFlags.isEE = true ;
1381  EEDetId eedetid(seedXtalId);
1382  if (EEDetId::isNextToRingBoundary(eedetid))
1383  {
1384  if (std::abs(feta)<2.)
1385  { fiducialFlags.isEBEEGap = true ; }
1386  else
1387  { fiducialFlags.isEERingGap = true ; }
1388  }
1389  if (EEDetId::isNextToDBoundary(eedetid))
1390  { fiducialFlags.isEEDeeGap = true ; }
1391  }
1392  else if ( region==DetId::Forward || region == DetId::Hcal )
1393  {
1394  fiducialFlags.isEE = true ;
1395  //HGCalDetId eeDetid(seedXtalId);
1396  // fill in fiducial information when we know how to use it...
1397  }
1398  else
1399  { throw cms::Exception("GsfElectronAlgo|UnknownXtalRegion")<<"createElectron(): do not know if it is a barrel or endcap seed cluster !!!!" ; }
1400 
1401 
1402  //====================================================
1403  // SaturationInfo
1404  //====================================================
1405 
1406  reco::GsfElectron::SaturationInfo saturationInfo;
1408 
1409  //====================================================
1410  // ShowerShape
1411  //====================================================
1412 
1413  reco::GsfElectron::ShowerShape showerShape;
1414  reco::GsfElectron::ShowerShape full5x5_showerShape;
1415  if( !(region==DetId::Forward || region == DetId::Hcal) ) {
1416  calculateShowerShape(electronData_->superClusterRef,!(electronData_->coreRef->ecalDrivenSeed()),showerShape) ;
1417  calculateShowerShape_full5x5(electronData_->superClusterRef,!(electronData_->coreRef->ecalDrivenSeed()),full5x5_showerShape) ;
1418  }
1419 
1420  //====================================================
1421  // ConversionRejection
1422  //====================================================
1423 
1425 
1426  ConversionFinder conversionFinder ;
1427  double BInTesla = eventSetupData_->magField->inTesla(GlobalPoint(0.,0.,0.)).z() ;
1429  if (!ctfTracks.isValid()) { ctfTracks = eventData_->currentCtfTracks ; }
1430 
1431  // values of conversionInfo.flag()
1432  // -9999 : Partner track was not found
1433  // 0 : Partner track found in the CTF collection using
1434  // 1 : Partner track found in the CTF collection using
1435  // 2 : Partner track found in the GSF collection using
1436  // 3 : Partner track found in the GSF collection using the electron's GSF track
1437  ConversionInfo conversionInfo = conversionFinder.getConversionInfo
1438  (*electronData_->coreRef,ctfTracks,eventData_->originalGsfTracks,BInTesla) ;
1439 
1441  conversionVars.flags = conversionInfo.flag() ;
1442  conversionVars.dist = conversionInfo.dist() ;
1443  conversionVars.dcot = conversionInfo.dcot() ;
1444  conversionVars.radius = conversionInfo.radiusOfConversion() ;
1445  if ((conversionVars.flags==0)or(conversionVars.flags==1))
1446  conversionVars.partner = TrackBaseRef(conversionInfo.conversionPartnerCtfTk()) ;
1447  else if ((conversionVars.flags==2)or(conversionVars.flags==3))
1448  conversionVars.partner = TrackBaseRef(conversionInfo.conversionPartnerGsfTk()) ;
1449 
1450 
1451  //====================================================
1452  // Go !
1453  //====================================================
1454 
1455  GsfElectron * ele = new
1456  GsfElectron
1457  ( eleCharge,eleChargeInfo,electronData_->coreRef,
1458  tcMatching, tkExtra, ctfInfo,
1459  fiducialFlags,showerShape, full5x5_showerShape,
1460  conversionVars, saturationInfo ) ;
1461  // Will be overwritten later in the case of the regression
1463  ele->setP4(GsfElectron::P4_FROM_SUPER_CLUSTER,momentum,0,true) ;
1464 
1465  //====================================================
1466  // brems fractions
1467  //====================================================
1468 
1469  if (electronData_->innMom.mag()>0.)
1471 
1472  // the supercluster is the refined one The seed is not necessarily the first cluster
1473  // hence the use of the electronCluster
1474  SuperClusterRef sc = ele->superCluster() ;
1475  if (!(sc.isNull()))
1476  {
1477  CaloClusterPtr cl = ele->electronCluster() ;
1478  if (sc->clustersSize()>1)
1479  {
1480  float pf_fbrem =( sc->energy() - cl->energy() ) / sc->energy();
1481  ele->setSuperClusterFbrem( pf_fbrem ) ;
1482  }
1483  else
1484  {
1485  ele->setSuperClusterFbrem(0) ;
1486  }
1487  }
1488 
1489  //====================================================
1490  // classification and corrections
1491  //====================================================
1492  // classification
1493  ElectronClassification theClassifier ;
1494  theClassifier.classify(*ele) ;
1495  theClassifier.refineWithPflow(*ele) ;
1496  // ecal energy
1499  {
1504  }
1505  else // original implementation
1506  {
1507  if( region!=DetId::Forward && region != DetId::Hcal ) {
1508  if (ele->core()->ecalDrivenSeed())
1509  {
1511  { theEnCorrector.classBasedParameterizationEnergy(*ele,*eventData_->beamspot) ; }
1513  { theEnCorrector.classBasedParameterizationUncertainty(*ele) ; }
1514  }
1515  else
1516  {
1518  { theEnCorrector.simpleParameterizationUncertainty(*ele) ; }
1519  }
1520  }
1521  }
1522 
1523  // momentum
1524  // Keep the default correction running first. The track momentum error is computed in there
1525  if (ele->core()->ecalDrivenSeed())
1526  {
1527  ElectronMomentumCorrector theMomCorrector;
1528  theMomCorrector.correct(*ele,electronData_->vtxTSOS);
1529  }
1531  {
1533  }
1534 
1535  //====================================================
1536  // now isolation variables
1537  //====================================================
1538 
1542 
1543  if( !(region==DetId::Forward || region == DetId::Hcal) ) {
1556  }
1557  ele->setIsolation03(dr03);
1558  ele->setIsolation04(dr04);
1559 
1560 
1561  //====================================================
1562  // preselection flag
1563  //====================================================
1564 
1566  //setting mva flag, currently GedGsfElectron and GsfElectron pre-selection flags have desynced
1567  //this is for GedGsfElectrons, GsfElectrons (ie old pre 7X std reco) resets this later on
1568  //in the function "addPfInfo"
1569  //yes this is awful, we'll fix it once we work out how to...
1570  float mvaValue = hoc->sElectronMVAEstimator->mva( *(ele),*(eventData_->vertices));
1572 
1573  //====================================================
1574  // Pixel match variables
1575  //====================================================
1577 
1578  LogTrace("GsfElectronAlgo")<<"Constructed new electron with energy "<< ele->p4().e() ;
1579 
1580  eventData_->electrons->push_back(ele) ;
1581  }
1582 
1583 
1584 //=======================================================================================
1585 // Ambiguity solving
1586 //=======================================================================================
1587 
1588 //bool better_electron( const reco::GsfElectron * e1, const reco::GsfElectron * e2 )
1589 // { return (std::abs(e1->eSuperClusterOverP()-1)<std::abs(e2->eSuperClusterOverP()-1)) ; }
1590 
1591 void GsfElectronAlgo::setAmbiguityData( bool ignoreNotPreselected )
1592  {
1593  GsfElectronPtrCollection::iterator e1, e2 ;
1598  else
1599  { throw cms::Exception("GsfElectronAlgo|UnknownAmbiguitySortingStrategy")<<"value of generalData_->strategyCfg.ambSortingStrategy is : "<<generalData_->strategyCfg.ambSortingStrategy ; }
1600 
1601  // init
1602  for
1603  ( e1 = eventData_->electrons->begin() ;
1604  e1 != eventData_->electrons->end() ;
1605  ++e1 )
1606  {
1607  (*e1)->clearAmbiguousGsfTracks() ;
1608  (*e1)->setAmbiguous(false) ;
1609  }
1610 
1611  // get ambiguous from GsfPfRecTracks
1613  {
1614  for
1615  ( e1 = eventData_->electrons->begin() ;
1616  e1 != eventData_->electrons->end() ;
1617  ++e1 )
1618  {
1619  bool found = false ;
1620  const GsfPFRecTrackCollection * gsfPfRecTrackCollection = eventData_->gsfPfRecTracks.product() ;
1621  GsfPFRecTrackCollection::const_iterator gsfPfRecTrack ;
1622  for ( gsfPfRecTrack=gsfPfRecTrackCollection->begin() ;
1623  gsfPfRecTrack!=gsfPfRecTrackCollection->end() ;
1624  ++gsfPfRecTrack )
1625  {
1626  if (gsfPfRecTrack->gsfTrackRef()==(*e1)->gsfTrack())
1627  {
1628  if (found)
1629  {
1630  edm::LogWarning("GsfElectronAlgo")<<"associated gsfPfRecTrack already found" ;
1631  }
1632  else
1633  {
1634  found = true ;
1635  const std::vector<reco::GsfPFRecTrackRef> & duplicates(gsfPfRecTrack->convBremGsfPFRecTrackRef()) ;
1636  std::vector<reco::GsfPFRecTrackRef>::const_iterator duplicate ;
1637  for ( duplicate = duplicates.begin() ; duplicate != duplicates.end() ; duplicate ++ )
1638  { (*e1)->addAmbiguousGsfTrack((*duplicate)->gsfTrackRef()) ; }
1639  }
1640  }
1641  }
1642  }
1643  }
1644  // or search overlapping clusters
1645  else
1646  {
1647  for
1648  ( e1 = eventData_->electrons->begin() ;
1649  e1 != eventData_->electrons->end() ;
1650  ++e1 )
1651  {
1652  if ((*e1)->ambiguous()) continue ;
1653  if ( ignoreNotPreselected && !isPreselected(*e1) ) continue ;
1654 
1655  SuperClusterRef scRef1 = (*e1)->superCluster();
1656  CaloClusterPtr eleClu1 = (*e1)->electronCluster();
1657  LogDebug("GsfElectronAlgo")
1658  << "Blessing electron with E/P " << (*e1)->eSuperClusterOverP()
1659  << ", cluster " << scRef1.get()
1660  << " & track " << (*e1)->gsfTrack().get() ;
1661 
1662  for
1663  ( e2 = e1, ++e2 ;
1664  e2 != eventData_->electrons->end() ;
1665  ++e2 )
1666  {
1667  if ((*e2)->ambiguous()) continue ;
1668  if ( ignoreNotPreselected && !isPreselected(*e2) ) continue ;
1669 
1670  SuperClusterRef scRef2 = (*e2)->superCluster();
1671  CaloClusterPtr eleClu2 = (*e2)->electronCluster();
1672 
1673  // search if same cluster
1674  bool sameCluster = false ;
1676  { sameCluster = (scRef1==scRef2) ; }
1678  {
1679  float eMin = 1. ;
1680  float threshold = eMin*cosh(EleRelPoint(scRef1->position(),eventData_->beamspot->position()).eta()) ;
1681  sameCluster =
1683  (EgAmbiguityTools::sharedEnergy(&(*scRef1->seed()),&(*eleClu2),eventData_->barrelRecHits,eventData_->endcapRecHits)>=threshold) ||
1685  (EgAmbiguityTools::sharedEnergy(&(*scRef1->seed()),&(*scRef2->seed()),eventData_->barrelRecHits,eventData_->endcapRecHits)>=threshold) ) ;
1686  }
1687  else
1688  { throw cms::Exception("GsfElectronAlgo|UnknownAmbiguityClustersOverlapStrategy")<<"value of generalData_->strategyCfg.ambClustersOverlapStrategy is : "<<generalData_->strategyCfg.ambClustersOverlapStrategy ; }
1689 
1690  // main instructions
1691  if (sameCluster)
1692  {
1693  LogDebug("GsfElectronAlgo")
1694  << "Discarding electron with E/P " << (*e2)->eSuperClusterOverP()
1695  << ", cluster " << scRef2.get()
1696  << " and track " << (*e2)->gsfTrack().get() ;
1697  (*e1)->addAmbiguousGsfTrack((*e2)->gsfTrack()) ;
1698  (*e2)->setAmbiguous(true) ;
1699  }
1700  else if ((*e1)->gsfTrack()==(*e2)->gsfTrack())
1701  {
1702  edm::LogWarning("GsfElectronAlgo")
1703  << "Forgetting electron with E/P " << (*e2)->eSuperClusterOverP()
1704  << ", cluster " << scRef2.get()
1705  << " and track " << (*e2)->gsfTrack().get() ;
1706  (*e2)->setAmbiguous(true) ;
1707  }
1708  }
1709  }
1710  }
1711  }
1712 
1714  {
1715  GsfElectronPtrCollection::size_type ei = 1, emax = eventData_->electrons->size() ;
1716  GsfElectronPtrCollection::iterator eitr = eventData_->electrons->begin() ;
1717  while (eitr!=eventData_->electrons->end())
1718  {
1719  LogTrace("GsfElectronAlgo")<<"========== remove ambiguous "<<ei<<"/"<<emax<<"==========" ;
1720  if ((*eitr)->ambiguous())
1721  { delete (*eitr) ; eitr = eventData_->electrons->erase(eitr) ; ++ei ; }
1722  else
1723  { ++eitr ; ++ei ; }
1724  }
1725  }
1726 
1727 
1728 // Pixel match variables
1730  int sd1 = 0 ;
1731  int sd2 = 0 ;
1732  float dPhi1 = 0 ;
1733  float dPhi2 = 0 ;
1734  float dRz1 = 0 ;
1735  float dRz2 = 0 ;
1736  edm::RefToBase<TrajectorySeed> seed = ele->gsfTrack()->extra()->seedRef();
1737  ElectronSeedRef elseed = seed.castTo<ElectronSeedRef>();
1738  if(seed.isNull()){}
1739  else{
1740  if(elseed.isNull()){}
1741  else{
1742  sd1 = elseed->subDet1() ;
1743  sd2 = elseed->subDet2() ;
1744  dPhi1 = (ele->charge()>0) ? elseed->dPhi1Pos() : elseed->dPhi1() ;
1745  dPhi2 = (ele->charge()>0) ? elseed->dPhi2Pos() : elseed->dPhi2() ;
1746  dRz1 = (ele->charge()>0) ? elseed->dRz1Pos () : elseed->dRz1 () ;
1747  dRz2 = (ele->charge()>0) ? elseed->dRz2Pos () : elseed->dRz2 () ;
1748  }
1749  }
1750  ele->setPixelMatchSubdetectors(sd1,sd2) ;
1751  ele->setPixelMatchDPhi1(dPhi1) ;
1752  ele->setPixelMatchDPhi2(dPhi2) ;
1753  ele->setPixelMatchDRz1 (dRz1 ) ;
1754  ele->setPixelMatchDRz2 (dRz2 ) ;
1755 }
#define LogDebug(id)
TrajectoryStateOnSurface constrainAtBeamSpot(const reco::GsfTrack &, const reco::BeamSpot &) const
(multi)TSOS after including the beamspot
CaloClusterPtr electronCluster() const
Definition: GsfElectron.h:244
ElectronHcalHelper * hcalHelperPflow
void setPixelMatchInfomation(reco::GsfElectron *)
edm::Handle< reco::TrackCollection > originalCtfTracks
T getParameter(std::string const &) const
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:185
unsigned long long cacheIdentifier() const
edm::Handle< reco::ElectronSeedCollection > seeds
bool empty() const
Definition: ParameterSet.h:218
const MultiTrajectoryStateMode * mtsMode
bool isPreselected(reco::GsfElectron *ele)
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:129
void applyCombinationRegression(reco::GsfElectron &ele) const
void setMVAOutputs(const gsfAlgoHelpers::HeavyObjectCache *, const std::map< reco::GsfTrackRef, reco::GsfElectron::MvaOutput > &mvaOutputs)
void setTrackFbrem(float fbrem)
Definition: GsfElectron.h:760
edm::Handle< edm::ValueMap< float > > pfMva
std::unique_ptr< const SoftElectronMVAEstimator > sElectronMVAEstimator
void setP4(P4Kind kind, const LorentzVector &p4, float p4Error, bool setCandidate)
Definition: GsfElectron.cc:199
GeneralData * generalData_
const CutsConfiguration cutsCfgPflow
GeneralData(const InputTagsConfiguration &, const StrategyConfiguration &, const CutsConfiguration &cutsCfg, const CutsConfiguration &cutsCfgPflow, const ElectronHcalHelper::Configuration &hcalCfg, const ElectronHcalHelper::Configuration &hcalCfgPflow, const IsolationConfiguration &, const EcalRecHitsConfiguration &, EcalClusterFunctionBaseClass *superClusterErrorFunction, EcalClusterFunctionBaseClass *crackCorrectionFunction, const SoftElectronMVAEstimator::Configuration &mva_NIso_Cfg, const ElectronMVAEstimator::Configuration &mva_Iso_Cfg, const RegressionHelper::Configuration &)
static bool isNextToEtaBoundary(EBDetId id)
Definition: EBDetId.cc:125
EgammaTowerIsolation * hadDepth1Isolation04Bc
reco::GsfTrackRef conversionPartnerGsfTk() const
static const TGPicture * info(bool iBackgroundIsBlack)
void setPassCutBasedPreselection(bool flag)
Definition: GsfElectron.h:713
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:253
bool positionFromModeCartesian(const TrajectoryStateOnSurface tsos, GlobalPoint &position) const
void setPixelMatchDRz2(float dRz2)
Definition: GsfElectron.h:888
static float e2x5Bottom(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
edm::EDGetTokenT< reco::GsfElectronCoreCollection > gsfElectronCores
bool isEBEtaGap() const
Definition: GsfElectron.h:357
void readEvent(const edm::Event &)
EgammaTowerIsolation * hadDepth1Isolation03Bc
double radiusOfConversion() const
static std::vector< float > covariances(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, const CaloGeometry *geometry, float w0=4.7)
void clonePreviousElectrons()
const LorentzVector & p4(P4Kind kind) const
Definition: GsfElectron.cc:225
float eSuperClusterOverP() const
Definition: GsfElectron.h:245
bool isBetter(const reco::GsfElectron *, const reco::GsfElectron *)
CaloTopology const * topology(0)
void retreiveOriginalTrackCollections(const reco::TrackRef &, const reco::GsfTrackRef &)
void setPixelMatchDPhi1(float dPhi1)
Definition: GsfElectron.h:885
bool isEBEEGap() const
Definition: GsfElectron.h:355
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
float hcalDepth2OverEcal() const
Definition: GsfElectron.h:441
static float eMax(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
edm::EDGetTokenT< reco::GsfElectronCollection > previousGsfElectrons
double getEtSum(const reco::Candidate *emObject) const
const IsolationConfiguration isoCfg
edm::EDGetTokenT< reco::VertexCollection > vtxCollectionTag
void calculateShowerShape(const reco::SuperClusterRef &, bool pflow, reco::GsfElectron::ShowerShape &)
void beginEvent(edm::Event &)
Definition: __init__.py:1
TrajectoryStateOnSurface sclTSOS
const EcalRecHitsConfiguration recHitsCfg
EventSetupData * eventSetupData_
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
edm::Handle< EcalRecHitCollection > endcapRecHits
double hcalESumDepth2BehindClusters(const std::vector< CaloTowerDetId > &towers)
double dist() const
double pt() const final
transverse momentum
std::vector< CaloTowerDetId > hcalTowersBehindClusters(const reco::SuperCluster &sc)
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:195
int charge() const final
electric charge
Definition: LeafCandidate.h:91
void checkSetup(const edm::EventSetup &)
void setMVAInputs(const std::map< reco::GsfTrackRef, reco::GsfElectron::MvaInput > &mvaInputs)
bool isEERingGap() const
Definition: GsfElectron.h:361
bool passingCutBasedPreselection() const
Definition: GsfElectron.h:705
bool passingMvaPreselection() const
Definition: GsfElectron.h:721
edm::EDGetTokenT< EcalRecHitCollection > endcapRecHitCollection
void computeCharge(int &charge, reco::GsfElectron::ChargeInfo &info)
GsfElectronAlgo(const InputTagsConfiguration &, const StrategyConfiguration &, const CutsConfiguration &cutsCfg, const CutsConfiguration &cutsCfgPflow, const ElectronHcalHelper::Configuration &hcalCfg, const ElectronHcalHelper::Configuration &hcalCfgPflow, const IsolationConfiguration &, const EcalRecHitsConfiguration &, EcalClusterFunctionBaseClass *superClusterErrorFunction, EcalClusterFunctionBaseClass *crackCorrectionFunction, const SoftElectronMVAEstimator::Configuration &mva_NIso_Cfg, const ElectronMVAEstimator::Configuration &mva_Iso_Cfg, const RegressionHelper::Configuration &regCfg, const edm::ParameterSet &tkIsol03Cfg, const edm::ParameterSet &tkIsol04Cfg)
bool momentumFromModeCartesian(const TrajectoryStateOnSurface tsos, GlobalVector &momentum) const
void checkCtfTrack(edm::Handle< reco::TrackCollection > currentCtfTracks)
void completeElectrons(const gsfAlgoHelpers::HeavyObjectCache *)
double hcalESumDepth1BehindClusters(const std::vector< CaloTowerDetId > &towers)
const InputTagsConfiguration inputCfg
#define nullptr
edm::ESHandle< EcalSeverityLevelAlgo > sevLevel
TrajectoryStateOnSurface innTSOS
uint16_t size_type
bool isEEDeeGap() const
Definition: GsfElectron.h:360
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
EgammaTowerIsolation * hadDepth1Isolation03
edm::EDGetTokenT< reco::GsfElectronCollection > pflowGsfElectronsTag
const StrategyConfiguration strategyCfg
bool isEE() const
Definition: GsfElectron.h:353
ProductID id() const
Accessor for product ID.
Definition: Ref.h:259
bool isEB() const
Definition: GsfElectron.h:352
TrajectoryStateOnSurface outerStateOnSurface(const reco::GsfTrack &tk) const
void setPixelMatchSubdetectors(int sd1, int sd2)
Definition: GsfElectron.h:884
edm::EDGetTokenT< EcalRecHitCollection > barrelRecHitCollection
edm::ESHandle< CaloTopology > caloTopo
void doFlagChecks(const std::vector< int > &v)
static float e2x5Top(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
edm::EDGetTokenT< reco::GsfPFRecTrackCollection > gsfPfRecTracksTag
reco::TrackRef conversionPartnerCtfTk() const
const Double_t pi
void createElectron(const gsfAlgoHelpers::HeavyObjectCache *)
void setSuperClusterFbrem(float fbrem)
Definition: GsfElectron.h:761
EgammaRecHitIsolation * ecalBarrelIsol04
TrajectoryStateOnSurface constrainedVtxTSOS
const RegressionHelper::Configuration regCfg
T barePhi() const
Definition: PV3DBase.h:68
EgammaTowerIsolation * hadDepth2Isolation03
EgammaTowerIsolation * hadDepth1Isolation04
edm::EDGetTokenT< reco::BeamSpot > beamSpotTag
virtual float getValue(const reco::BasicCluster &, const EcalRecHitCollection &) const =0
void setUseNumCrystals(bool b=true)
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:249
void setCorrectedEcalEnergyError(float newEnergyError)
Definition: GsfElectron.cc:179
T mag() const
Definition: PV3DBase.h:67
float sigmaIetaIeta() const
Definition: GsfElectron.h:434
bool isNotFinite(T x)
Definition: isFinite.h:10
void calculateShowerShape_full5x5(const reco::SuperClusterRef &, bool pflow, reco::GsfElectron::ShowerShape &)
uint16_t hitPattern[ARRAY_LENGTH]
Definition: HitPattern.h:472
void simpleParameterizationUncertainty(reco::GsfElectron &)
TrajectoryStateOnSurface extrapolatedState(const TrajectoryStateOnSurface tsos, const GlobalPoint &point) const
void setCutBasedPreselectionFlag(reco::GsfElectron *ele, const reco::BeamSpot &)
std::vector< GsfPFRecTrack > GsfPFRecTrackCollection
collection of GsfPFRecTrack objects
edm::RefToBase< reco::Track > TrackBaseRef
persistent reference to a Track, using views
Definition: TrackFwd.h:32
EgammaRecHitIsolation * ecalEndcapIsol03
float sharedEnergy(const reco::CaloCluster *, const reco::CaloCluster *, edm::Handle< EcalRecHitCollection > &barrelRecHits, edm::Handle< EcalRecHitCollection > &endcapRecHits)
EgammaTowerIsolation * hadDepth2Isolation03Bc
RealType normalized_phi(RealType phi)
T sqrt(T t)
Definition: SSEVec.h:18
GsfConstraintAtVertex * constraintAtVtx
static bool isNextToPhiBoundary(EBDetId id)
Definition: EBDetId.cc:130
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
float sumPhotonEt
sum pt of PF photons // old float photonIso ;
Definition: GsfElectron.h:627
edm::Handle< EcalRecHitCollection > barrelRecHits
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:252
T z() const
Definition: PV3DBase.h:64
std::vector< GsfElectronCore > GsfElectronCoreCollection
void correct(reco::GsfElectron &, TrajectoryStateOnSurface &)
static float e2nd(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
float hcalOverEcal() const
Definition: GsfElectron.h:442
void setPassMvaPreselection(bool flag)
Definition: GsfElectron.h:720
IsolationValueMaps pfIsolationValues
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< CaloTowerDetId > hcalTowersBehindClusters
Definition: GsfElectron.h:396
const MultiTrajectoryStateTransform * mtsTransform
static bool isNextToRingBoundary(EEDetId id)
Definition: EEDetId.cc:375
std::list< reco::GsfElectron * > GsfElectronPtrCollection
static float e2x5Max(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
double hcalESumDepth2(const reco::SuperCluster &, const std::vector< CaloTowerDetId > *excludeTowers=0)
static float eBottom(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
double energy() const
cluster energy
Definition: CaloCluster.h:124
const CutsConfiguration cutsCfg
static float e2x5Right(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
ElectronHcalHelper * hcalHelper
float sumNeutralHadronEt
sum pt of neutral hadrons // old float neutralHadronIso ;
Definition: GsfElectron.h:626
double calIsolPt(Args &&...args) const
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:245
edm::EDGetTokenT< reco::ElectronSeedCollection > seedsTag
const reco::BeamSpot * beamspot
T min(T a, T b)
Definition: MathUtil.h:58
edm::ESHandle< MagneticField > magField
GsfElectronPtrCollection * electrons
CaloClusterPtr getEleBasicCluster(const MultiTrajectoryStateTransform *)
static bool isNextToDBoundary(EEDetId id)
Definition: EEDetId.cc:367
edm::EDGetTokenT< edm::ValueMap< float > > pfMVA
bool isValid() const
Definition: HandleBase.h:74
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:38
bool isNull() const
Checks for null.
Definition: Ref.h:250
void setIsolation04(const IsolationVariables &dr04)
Definition: GsfElectron.h:570
#define LogTrace(id)
void doSeverityChecks(const EcalRecHitCollection *const recHits, const std::vector< int > &v)
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
edm::EDGetTokenT< CaloTowerCollection > hcalTowersTag
void classify(reco::GsfElectron &)
EgammaTowerIsolation * hadDepth2Isolation04Bc
const_iterator end() const
edm::EDGetTokenT< reco::TrackCollection > ctfTracks
edm::Handle< reco::GsfElectronCollection > previousElectrons
float hcalDepth1OverEcal() const
Definition: GsfElectron.h:440
void setPixelMatchDPhi2(float dPhi2)
Definition: GsfElectron.h:886
std::vector< edm::Handle< edm::ValueMap< double > > > IsolationValueMaps
Float e1
Definition: deltaR.h:20
static float eTop(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
Definition: DetId.h:18
void classBasedParameterizationEnergy(reco::GsfElectron &, const reco::BeamSpot &bs)
edm::Handle< reco::VertexCollection > vertices
EgammaRecHitIsolation * ecalBarrelIsol03
edm::Handle< reco::GsfElectronCollection > pflowElectrons
DetId seed() const
return DetId of seed
Definition: CaloCluster.h:205
int flag() const
void calculateSaturationInfo(const reco::SuperClusterRef &, reco::GsfElectron::SaturationInfo &)
T const * product() const
Definition: Handle.h:81
EcalClusterFunctionBaseClass * superClusterErrorFunction
REF castTo() const
Definition: RefToBase.h:286
bool isNull() const
Checks for null.
Definition: RefToBase.h:328
const T & get() const
Definition: EventSetup.h:59
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
void setPflowPreselectionFlag(reco::GsfElectron *ele)
const MvaOutput & mvaOutput() const
Definition: GsfElectron.h:679
const reco::GsfTrackRef gsfTrackRef
static float e2x5Left(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
void ele_convert(const Type1 &obj1, Type2 &obj2)
bool calculateTSOS(const MultiTrajectoryStateTransform *, GsfConstraintAtVertex *)
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
virtual GsfElectronCoreRef core() const
Definition: GsfElectron.cc:8
Float e2
Definition: deltaR.h:21
return(e1-e2)*(e1-e2)+dp *dp
math::XYZVectorF momentumAtVtxWithConstraint
Definition: GsfElectron.h:285
TrajectoryStateOnSurface innerStateOnSurface(const reco::GsfTrack &tk) const
TrajectoryStateOnSurface seedTSOS
void refineWithPflow(reco::GsfElectron &)
void setIsolation03(const IsolationVariables &dr03)
Definition: GsfElectron.h:569
edm::EventID id() const
Definition: EventBase.h:60
iterator find(key_type k)
fixed size matrix
edm::Handle< reco::GsfTrackCollection > originalGsfTracks
HLT enums.
void applyEcalRegression(reco::GsfElectron &electron, const edm::Handle< reco::VertexCollection > &vertices, const edm::Handle< EcalRecHitCollection > &rechitsEB, const edm::Handle< EcalRecHitCollection > &rechitsEE) const
EgammaTowerIsolation * hadDepth2Isolation04
void setVetoClustered(bool b=true)
static std::atomic< unsigned int > counter
const reco::GsfElectronCoreRef coreRef
bool isEBPhiGap() const
Definition: GsfElectron.h:358
edm::Handle< reco::TrackCollection > currentCtfTracks
EleTkIsolFromCands tkIsol04Calc_
double getTowerEtSum(const reco::Candidate *cand, const std::vector< CaloTowerDetId > *detIdToExclude=0) const
edm::ESHandle< CaloGeometry > caloGeom
EcalClusterFunctionBaseClass * crackCorrectionFunction
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:184
void removeAmbiguousElectrons()
double hcalESumDepth1(const reco::SuperCluster &, const std::vector< CaloTowerDetId > *excludeTowers=0)
void displayInternalElectrons(const std::string &title) const
void setPassPflowPreselection(bool flag)
Definition: GsfElectron.h:714
EgammaRecHitIsolation * ecalEndcapIsol04
static float eRight(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
void removeNotPreselectedElectrons()
const reco::SuperClusterRef superClusterRef
TrajectoryStateOnSurface eleTSOS
const Point & position() const
position
Definition: BeamSpot.h:62
EventData * eventData_
static float e3x3(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
double dcot() const
TrajectoryStateOnSurface outTSOS
RegressionHelper * regHelper
ElectronData(const reco::GsfElectronCoreRef &core, const reco::BeamSpot &bs)
void copyElectrons(reco::GsfElectronCollection &)
ElectronData * electronData_
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:515
edm::ESHandle< TrackerGeometry > trackerHandle
void setAmbiguityData(bool ignoreNotPreselected=true)
IsolationValueMaps edIsolationValues
Detector det() const
get the detector field from this detid
Definition: DetId.h:36
float sumChargedHadronPt
sum-pt of charged Hadron // old float chargedHadronIso ;
Definition: GsfElectron.h:625
virtual void init(const edm::EventSetup &es)=0
EleTkIsolFromCands tkIsol03Calc_
edm::Handle< reco::GsfElectronCoreCollection > coreElectrons
int ietaAbs() const
get the absolute value of the crystal ieta
Definition: EBDetId.h:49
void classBasedParameterizationUncertainty(reco::GsfElectron &)
T const * product() const
Definition: ESHandle.h:86
static float eLeft(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
static std::vector< float > localCovariances(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, float w0=4.7)
void checkSetup(const edm::EventSetup &)
void setPixelMatchDRz1(float dRz1)
Definition: GsfElectron.h:887
static float e1x5(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
edm::Handle< CaloTowerCollection > towers
std::unique_ptr< const ElectronMVAEstimator > iElectronMVAEstimator
void calculateMode(const MultiTrajectoryStateMode *mtsMode)
Definition: event.py:1
math::PtEtaPhiELorentzVectorF LorentzVector
Global3DVector GlobalVector
Definition: GlobalVector.h:10
void checkSetup(const edm::EventSetup &)
edm::Handle< reco::GsfPFRecTrackCollection > gsfPfRecTracks
TrajectoryStateOnSurface vtxTSOS
static float e5x5(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
bool ecalDrivenSeed() const
Definition: GsfElectron.h:188
Candidate::LorentzVector calculateMomentum()
bool passingPflowPreselection() const
Definition: GsfElectron.h:706
const reco::BeamSpot beamSpot