CMS 3D CMS Logo

GsfElectronAlgo.cc
Go to the documentation of this file.
1 
9 
13 
26 
30 
33 
34 
36 
39 
42 
43 
46 
47 
48 #include <Math/Point3D.h>
49 #include <sstream>
50 #include <algorithm>
51 
52 
53 using namespace edm ;
54 using namespace std ;
55 using namespace reco ;
56 
57 
58 //===================================================================
59 // GsfElectronAlgo::GeneralData
60 //===================================================================
61 
62 // general data and helpers
64  {
65  // constructors
67  ( const InputTagsConfiguration &,
68  const StrategyConfiguration &,
69  const CutsConfiguration & cutsCfg,
70  const CutsConfiguration & cutsCfgPflow,
71  const ElectronHcalHelper::Configuration & hcalCfg,
72  const ElectronHcalHelper::Configuration & hcalCfgPflow,
73  const IsolationConfiguration &,
77  const SoftElectronMVAEstimator::Configuration & mva_NIso_Cfg ,
78  const ElectronMVAEstimator::Configuration & mva_Iso_Cfg ,
80  ~GeneralData() ;
81 
82  // configurables
89 
90  // additional configuration and helpers
94  //SoftElectronMVAEstimator *sElectronMVAEstimator;
95  //ElectronMVAEstimator *iElectronMVAEstimator;
98  } ;
99 
101  ( const InputTagsConfiguration & inputConfig,
102  const StrategyConfiguration & strategyConfig,
103  const CutsConfiguration & cutsConfig,
104  const CutsConfiguration & cutsConfigPflow,
105  const ElectronHcalHelper::Configuration & hcalConfig,
106  const ElectronHcalHelper::Configuration & hcalConfigPflow,
107  const IsolationConfiguration & isoConfig,
108  const EcalRecHitsConfiguration & recHitsConfig,
109  EcalClusterFunctionBaseClass * superClusterErrorFunc,
110  EcalClusterFunctionBaseClass * crackCorrectionFunc,
111  const SoftElectronMVAEstimator::Configuration & /*mva_NIso_Config*/,
112  const ElectronMVAEstimator::Configuration & /*mva_Iso_Config*/,
113  const RegressionHelper::Configuration & regConfig
114  )
115  : inputCfg(inputConfig),
116  strategyCfg(strategyConfig),
117  cutsCfg(cutsConfig),
118  cutsCfgPflow(cutsConfigPflow),
119  isoCfg(isoConfig),
120  recHitsCfg(recHitsConfig),
121  hcalHelper(new ElectronHcalHelper(hcalConfig)),
122  hcalHelperPflow(new ElectronHcalHelper(hcalConfigPflow)),
123  superClusterErrorFunction(superClusterErrorFunc),
124  crackCorrectionFunction(crackCorrectionFunc),
125  //sElectronMVAEstimator(new SoftElectronMVAEstimator(mva_NIso_Config)),
126  //iElectronMVAEstimator(new ElectronMVAEstimator(mva_Iso_Config)),
127  regCfg(regConfig),
128  regHelper(new RegressionHelper(regConfig))
129  {}
130 
132  {
133  delete hcalHelper ;
134  delete hcalHelperPflow ;
135  //delete sElectronMVAEstimator;
136  //delete iElectronMVAEstimator;
137  delete regHelper;
138  }
139 
140 //===================================================================
141 // GsfElectronAlgo::EventSetupData
142 //===================================================================
143 
145  {
146  EventSetupData() ;
147  ~EventSetupData() ;
148 
149  unsigned long long cacheIDGeom ;
150  unsigned long long cacheIDTopo ;
151  unsigned long long cacheIDTDGeom ;
152  unsigned long long cacheIDMagField ;
153  //unsigned long long cacheChStatus ;
154  unsigned long long cacheSevLevel ;
155 
160  //edm::ESHandle<EcalChannelStatus> chStatus ;
162 
166 } ;
167 
169  : cacheIDGeom(0), cacheIDTopo(0), cacheIDTDGeom(0), cacheIDMagField(0),/*cacheChStatus(0),*/
170  cacheSevLevel(0), mtsTransform(nullptr), constraintAtVtx(nullptr), mtsMode(new MultiTrajectoryStateMode)
171  {}
172 
174  {
175  delete mtsMode ;
176  delete constraintAtVtx ;
177  delete mtsTransform ;
178  }
179 
180 
181 //===================================================================
182 // GsfElectronAlgo::EventData
183 //===================================================================
184 
186  {
187  // general
191 
192  EventData() ;
193  ~EventData() ;
194 
195  // utilities
196  void retreiveOriginalTrackCollections
197  ( const reco::TrackRef &, const reco::GsfTrackRef & ) ;
198 
199  // input collections
215 
216  // isolation helpers
217  EgammaTowerIsolation * hadDepth1Isolation03, * hadDepth1Isolation04 ;
218  EgammaTowerIsolation * hadDepth2Isolation03, * hadDepth2Isolation04 ;
219  EgammaTowerIsolation * hadDepth1Isolation03Bc, * hadDepth1Isolation04Bc ;
220  EgammaTowerIsolation * hadDepth2Isolation03Bc, * hadDepth2Isolation04Bc ;
221  EgammaRecHitIsolation * ecalBarrelIsol03, * ecalBarrelIsol04 ;
222  EgammaRecHitIsolation * ecalEndcapIsol03, * ecalEndcapIsol04 ;
223 
224  //Isolation Value Maps for PF and EcalDriven electrons
225  typedef std::vector< edm::Handle< edm::ValueMap<double> > > IsolationValueMaps;
226  IsolationValueMaps pfIsolationValues;
227  IsolationValueMaps edIsolationValues;
228  } ;
229 
232  originalCtfTrackCollectionRetreived(false),
233  originalGsfTrackCollectionRetreived(false),
234  hadDepth1Isolation03(nullptr), hadDepth1Isolation04(nullptr),
235  hadDepth2Isolation03(nullptr), hadDepth2Isolation04(nullptr),
236  hadDepth1Isolation03Bc(nullptr), hadDepth1Isolation04Bc(nullptr),
237  hadDepth2Isolation03Bc(nullptr), hadDepth2Isolation04Bc(nullptr),
238  ecalBarrelIsol03(nullptr), ecalBarrelIsol04(nullptr),
239  ecalEndcapIsol03(nullptr), ecalEndcapIsol04(nullptr)
240  {
242  }
243 
245  {
246  delete hadDepth1Isolation03 ;
247  delete hadDepth1Isolation04 ;
248  delete hadDepth2Isolation03 ;
249  delete hadDepth2Isolation04 ;
250  delete hadDepth1Isolation03Bc ;
251  delete hadDepth1Isolation04Bc ;
252  delete hadDepth2Isolation03Bc ;
253  delete hadDepth2Isolation04Bc ;
254  delete ecalBarrelIsol03 ;
255  delete ecalBarrelIsol04 ;
256  delete ecalEndcapIsol03 ;
257  delete ecalEndcapIsol04 ;
258 
259  GsfElectronPtrCollection::const_iterator it ;
260  for ( it = electrons->begin() ; it != electrons->end() ; it++ )
261  { delete (*it) ; }
262  delete electrons ;
263  }
264 
266  ( const reco::TrackRef & ctfTrack, const reco::GsfTrackRef & gsfTrack )
267  {
268  if ((!originalCtfTrackCollectionRetreived)&&(ctfTrack.isNonnull()))
269  {
270  event->get(ctfTrack.id(),originalCtfTracks) ;
272  }
273  if ((!originalGsfTrackCollectionRetreived)&&(gsfTrack.isNonnull()))
274  {
275  event->get(gsfTrack.id(),originalGsfTracks) ;
277  }
278  }
279 
280 
281 //===================================================================
282 // GsfElectronAlgo::ElectronData
283 //===================================================================
284 
286  {
287  // Refs to subproducts
294 
295  // constructors
297  ( const reco::GsfElectronCoreRef & core,
298  const reco::BeamSpot & bs ) ;
299  ~ElectronData() ;
300 
301  // utilities
303  void computeCharge( int & charge, reco::GsfElectron::ChargeInfo & info ) ;
304  CaloClusterPtr getEleBasicCluster( const MultiTrajectoryStateTransform * ) ;
305  bool calculateTSOS( const MultiTrajectoryStateTransform *, GsfConstraintAtVertex * ) ;
306  void calculateMode( const MultiTrajectoryStateMode * mtsMode ) ;
307  Candidate::LorentzVector calculateMomentum() ;
308 
309  // TSOS
317 
318  // mode
319  GlobalVector innMom, seedMom, eleMom, sclMom, vtxMom, outMom ;
320  GlobalPoint innPos, seedPos, elePos, sclPos, vtxPos, outPos ;
322  } ;
323 
326  const reco::BeamSpot & bs )
327  : coreRef(core),
328  gsfTrackRef(coreRef->gsfTrack()),
329  superClusterRef(coreRef->superCluster()),
330  ctfTrackRef(coreRef->ctfTrack()), shFracInnerHits(coreRef->ctfGsfOverlap()),
331  beamSpot(bs)
332  {}
333 
335  {}
336 
338 {
339  if (!ctfTrackRef.isNull()) return ;
340 
341  // Code below from Puneeth Kalavase
342 
343  shFracInnerHits = 0 ;
344  const TrackCollection * ctfTrackCollection = currentCtfTracks.product() ;
345 
346  // get the Hit Pattern for the gsfTrack
347  const HitPattern &gsfHitPattern = gsfTrackRef->hitPattern() ;
348 
349  unsigned int counter ;
350  TrackCollection::const_iterator ctfTkIter ;
351  for (ctfTkIter = ctfTrackCollection->begin(), counter = 0;
352  ctfTkIter != ctfTrackCollection->end(); ctfTkIter++, counter++)
353  {
354  double dEta = gsfTrackRef->eta() - ctfTkIter->eta() ;
355  double dPhi = gsfTrackRef->phi() - ctfTkIter->phi() ;
356  double pi = acos(-1.);
357  if(std::abs(dPhi) > pi) dPhi = 2*pi - std::abs(dPhi) ;
358 
359  // dont want to look at every single track in the event!
360  if (sqrt(dEta*dEta + dPhi*dPhi) > 0.3) continue ;
361 
362  unsigned int shared = 0 ;
363  int gsfHitCounter = 0 ;
364  int numGsfInnerHits = 0 ;
365  int numCtfInnerHits = 0 ;
366 
367  // get the CTF Track Hit Pattern
368  const HitPattern &ctfHitPattern = ctfTkIter->hitPattern() ;
369 
370  trackingRecHit_iterator elHitsIt;
371  for (elHitsIt = gsfTrackRef->recHitsBegin();
372  elHitsIt != gsfTrackRef->recHitsEnd();
373  elHitsIt++, gsfHitCounter++)
374  {
375  if (!((**elHitsIt).isValid())) //count only valid Hits
376  { continue ; }
377 
378  // look only in the pixels/TIB/TID
379  uint32_t gsfHit = gsfHitPattern.getHitPattern(HitPattern::TRACK_HITS, gsfHitCounter) ;
380  if (!(HitPattern::pixelHitFilter(gsfHit)
381  || HitPattern::stripTIBHitFilter(gsfHit)
382  || HitPattern::stripTIDHitFilter(gsfHit))){
383  continue;
384  }
385 
386  numGsfInnerHits++ ;
387 
388  int ctfHitsCounter = 0 ;
389  numCtfInnerHits = 0 ;
390  trackingRecHit_iterator ctfHitsIt ;
391  for (ctfHitsIt = ctfTkIter->recHitsBegin();
392  ctfHitsIt != ctfTkIter->recHitsEnd();
393  ctfHitsIt++, ctfHitsCounter++ )
394  {
395  if(!((**ctfHitsIt).isValid())) //count only valid Hits!
396  { continue; }
397 
398  uint32_t ctfHit = ctfHitPattern.getHitPattern(HitPattern::TRACK_HITS, ctfHitsCounter);
399  if(!(HitPattern::pixelHitFilter(ctfHit)
400  || HitPattern::stripTIBHitFilter(ctfHit)
401  || HitPattern::stripTIDHitFilter(ctfHit)))
402  {
403  continue;
404  }
405 
406  numCtfInnerHits++ ;
407 
408  if((**elHitsIt).sharesInput(&(**ctfHitsIt), TrackingRecHit::all))
409  {
410  shared++ ;
411  break ;
412  }
413 
414  } //ctfHits iterator
415 
416  } //gsfHits iterator
417 
418  if ((numGsfInnerHits==0)||(numCtfInnerHits==0))
419  { continue ; }
420 
421  if ( static_cast<float>(shared)/min(numGsfInnerHits,numCtfInnerHits) > shFracInnerHits )
422  {
423  shFracInnerHits = static_cast<float>(shared)/min(numGsfInnerHits, numCtfInnerHits);
424  ctfTrackRef = TrackRef(currentCtfTracks,counter);
425  }
426  } //ctfTrack iterator
427 }
428 
431  {
432  // determine charge from SC
433  GlobalPoint orig, scpos ;
434  ele_convert(beamSpot.position(),orig) ;
435  ele_convert(superClusterRef->position(),scpos) ;
436  GlobalVector scvect(scpos-orig) ;
437  GlobalPoint inntkpos = innTSOS.globalPosition() ;
438  GlobalVector inntkvect = GlobalVector(inntkpos-orig) ;
439  float dPhiInnEle=normalized_phi(scvect.barePhi()-inntkvect.barePhi()) ;
440  if(dPhiInnEle>0) info.scPixCharge = -1 ;
441  else info.scPixCharge = 1 ;
442 
443  // flags
444  int chargeGsf = gsfTrackRef->charge() ;
445  info.isGsfScPixConsistent = ((chargeGsf*info.scPixCharge)>0) ;
446  info.isGsfCtfConsistent = (ctfTrackRef.isNonnull()&&((chargeGsf*ctfTrackRef->charge())>0)) ;
448 
449  // default charge
450  if (info.isGsfScPixConsistent||ctfTrackRef.isNull())
451  { charge = info.scPixCharge ; }
452  else
453  { charge = ctfTrackRef->charge() ; }
454  }
455 
457  ( const MultiTrajectoryStateTransform * mtsTransform )
458  {
459  CaloClusterPtr eleRef ;
460  TrajectoryStateOnSurface tempTSOS ;
461  TrajectoryStateOnSurface outTSOS = mtsTransform->outerStateOnSurface(*gsfTrackRef) ;
462  float dphimin = 1.e30 ;
463  for (CaloCluster_iterator bc=superClusterRef->clustersBegin(); bc!=superClusterRef->clustersEnd(); bc++)
464  {
465  GlobalPoint posclu((*bc)->position().x(),(*bc)->position().y(),(*bc)->position().z()) ;
466  tempTSOS = mtsTransform->extrapolatedState(outTSOS,posclu) ;
467  if (!tempTSOS.isValid()) tempTSOS=outTSOS ;
468  GlobalPoint extrap = tempTSOS.globalPosition() ;
469  float dphi = EleRelPointPair(posclu,extrap,beamSpot.position()).dPhi() ;
470  if (std::abs(dphi)<dphimin)
471  {
472  dphimin = std::abs(dphi) ;
473  eleRef = (*bc);
474  eleTSOS = tempTSOS ;
475  }
476  }
477  return eleRef ;
478  }
479 
481  ( const MultiTrajectoryStateTransform * mtsTransform, GsfConstraintAtVertex * constraintAtVtx )
482  {
483  //at innermost point
484  innTSOS = mtsTransform->innerStateOnSurface(*gsfTrackRef);
485  if (!innTSOS.isValid()) return false;
486 
487  //at vertex
488  // innermost state propagation to the beam spot position
489  GlobalPoint bsPos ;
490  ele_convert(beamSpot.position(),bsPos) ;
491  vtxTSOS = mtsTransform->extrapolatedState(innTSOS,bsPos) ;
492  if (!vtxTSOS.isValid()) vtxTSOS=innTSOS;
493 
494  //at seed
495  outTSOS = mtsTransform->outerStateOnSurface(*gsfTrackRef);
496  if (!outTSOS.isValid()) return false;
497 
498  // TrajectoryStateOnSurface seedTSOS
499  seedTSOS = mtsTransform->extrapolatedState(outTSOS,
500  GlobalPoint(superClusterRef->seed()->position().x(),
501  superClusterRef->seed()->position().y(),
502  superClusterRef->seed()->position().z()));
503  if (!seedTSOS.isValid()) seedTSOS=outTSOS;
504 
505  // at scl
506  sclTSOS = mtsTransform->extrapolatedState(innTSOS,GlobalPoint(superClusterRef->x(),superClusterRef->y(),superClusterRef->z()));
507  if (!sclTSOS.isValid()) sclTSOS=outTSOS;
508 
509  // constrained momentum
510  constrainedVtxTSOS = constraintAtVtx->constrainAtBeamSpot(*gsfTrackRef,beamSpot);
511 
512  return true ;
513  }
514 
516  {
517  mtsMode->momentumFromModeCartesian(innTSOS,innMom) ;
518  mtsMode->positionFromModeCartesian(innTSOS,innPos) ;
519  mtsMode->momentumFromModeCartesian(seedTSOS,seedMom) ;
520  mtsMode->positionFromModeCartesian(seedTSOS,seedPos) ;
521  mtsMode->momentumFromModeCartesian(eleTSOS,eleMom) ;
522  mtsMode->positionFromModeCartesian(eleTSOS,elePos) ;
523  mtsMode->momentumFromModeCartesian(sclTSOS,sclMom) ;
524  mtsMode->positionFromModeCartesian(sclTSOS,sclPos) ;
525  mtsMode->momentumFromModeCartesian(vtxTSOS,vtxMom) ;
526  mtsMode->positionFromModeCartesian(vtxTSOS,vtxPos) ;
527  mtsMode->momentumFromModeCartesian(outTSOS,outMom);
528  mtsMode->positionFromModeCartesian(outTSOS,outPos) ;
529  mtsMode->momentumFromModeCartesian(constrainedVtxTSOS,vtxMomWithConstraint);
530  }
531 
533  {
534  double scale = superClusterRef->energy()/vtxMom.mag() ;
536  ( vtxMom.x()*scale,vtxMom.y()*scale,vtxMom.z()*scale,
537  superClusterRef->energy() ) ;
538  }
539 
542 
543  const reco::CaloCluster & seedCluster = *(theClus->seed()) ;
544  DetId seedXtalId = seedCluster.seed();
545  int detector = seedXtalId.subdetId();
546  const EcalRecHitCollection* ecalRecHits = nullptr ;
547  if (detector==EcalBarrel)
548  ecalRecHits = eventData_->barrelRecHits.product() ;
549  else
550  ecalRecHits = eventData_->endcapRecHits.product() ;
551 
552  int nSaturatedXtals = 0;
553  bool isSeedSaturated = false;
554  const auto hitsAndFractions = theClus->hitsAndFractions();
555  for (auto&& hitFractionPair : hitsAndFractions) {
556  auto&& ecalRecHit = ecalRecHits->find(hitFractionPair.first);
557  if (ecalRecHit == ecalRecHits->end()) continue;
558  if (ecalRecHit->checkFlag(EcalRecHit::Flags::kSaturated)) {
559  nSaturatedXtals++;
560  if (seedXtalId == ecalRecHit->detid())
561  isSeedSaturated = true;
562  }
563  }
564  si.nSaturatedXtals = nSaturatedXtals;
565  si.isSeedSaturated = isSeedSaturated;
566 
567 }
568 
570  reco::GsfElectron::ShowerShape & showerShape )
571  {
572  const reco::CaloCluster & seedCluster = *(theClus->seed()) ;
573  // temporary, till CaloCluster->seed() is made available
574  DetId seedXtalId = seedCluster.hitsAndFractions()[0].first ;
575  int detector = seedXtalId.subdetId() ;
576 
579  const EcalRecHitCollection * recHits = nullptr ;
580  std::vector<int> recHitFlagsToBeExcluded ;
581  std::vector<int> recHitSeverityToBeExcluded ;
582  if (detector==EcalBarrel)
583  {
584  recHits = eventData_->barrelRecHits.product() ;
585  recHitFlagsToBeExcluded = generalData_->recHitsCfg.recHitFlagsToBeExcludedBarrel ;
586  recHitSeverityToBeExcluded = generalData_->recHitsCfg.recHitSeverityToBeExcludedBarrel ;
587  }
588  else
589  {
590  recHits = eventData_->endcapRecHits.product() ;
591  recHitFlagsToBeExcluded = generalData_->recHitsCfg.recHitFlagsToBeExcludedEndcaps ;
592  recHitSeverityToBeExcluded = generalData_->recHitsCfg.recHitSeverityToBeExcludedEndcaps ;
593  }
594 
595  std::vector<float> covariances = EcalClusterTools::covariances(seedCluster,recHits,topology,geometry) ;
596  std::vector<float> localCovariances = EcalClusterTools::localCovariances(seedCluster,recHits,topology) ;
597  showerShape.sigmaEtaEta = sqrt(covariances[0]) ;
598  showerShape.sigmaIetaIeta = sqrt(localCovariances[0]) ;
599  if (!edm::isNotFinite(localCovariances[2])) showerShape.sigmaIphiIphi = sqrt(localCovariances[2]) ;
600  showerShape.e1x5 = EcalClusterTools::e1x5(seedCluster,recHits,topology) ;
601  showerShape.e2x5Max = EcalClusterTools::e2x5Max(seedCluster,recHits,topology) ;
602  showerShape.e5x5 = EcalClusterTools::e5x5(seedCluster,recHits,topology) ;
603  showerShape.r9 = EcalClusterTools::e3x3(seedCluster,recHits,topology)/theClus->rawEnergy() ;
604 
605  if (pflow)
606  {
607  showerShape.hcalDepth1OverEcal = generalData_->hcalHelperPflow->hcalESumDepth1(*theClus)/theClus->energy() ;
608  showerShape.hcalDepth2OverEcal = generalData_->hcalHelperPflow->hcalESumDepth2(*theClus)/theClus->energy() ;
612  showerShape.invalidHcal = (showerShape.hcalDepth1OverEcalBc == 0 &&
613  showerShape.hcalDepth2OverEcalBc == 0 &&
615  }
616  else
617  {
618  showerShape.hcalDepth1OverEcal = generalData_->hcalHelper->hcalESumDepth1(*theClus)/theClus->energy() ;
619  showerShape.hcalDepth2OverEcal = generalData_->hcalHelper->hcalESumDepth2(*theClus)/theClus->energy() ;
623  showerShape.invalidHcal = (showerShape.hcalDepth1OverEcalBc == 0 &&
624  showerShape.hcalDepth2OverEcalBc == 0 &&
625  !generalData_->hcalHelper->hasActiveHcal(*theClus));
626  }
627 
628  // extra shower shapes
629  const float see_by_spp = showerShape.sigmaIetaIeta*showerShape.sigmaIphiIphi;
630  if( see_by_spp > 0 ) {
631  showerShape.sigmaIetaIphi = localCovariances[1] / see_by_spp;
632  } else if ( localCovariances[1] > 0 ) {
633  showerShape.sigmaIetaIphi = 1.f;
634  } else {
635  showerShape.sigmaIetaIphi = -1.f;
636  }
637  showerShape.eMax = EcalClusterTools::eMax(seedCluster,recHits);
638  showerShape.e2nd = EcalClusterTools::e2nd(seedCluster,recHits);
639  showerShape.eTop = EcalClusterTools::eTop(seedCluster,recHits,topology);
640  showerShape.eLeft = EcalClusterTools::eLeft(seedCluster,recHits,topology);
641  showerShape.eRight = EcalClusterTools::eRight(seedCluster,recHits,topology);
642  showerShape.eBottom = EcalClusterTools::eBottom(seedCluster,recHits,topology);
643 
644  showerShape.e2x5Left = EcalClusterTools::e2x5Left(seedCluster,recHits,topology);
645  showerShape.e2x5Right = EcalClusterTools::e2x5Right(seedCluster,recHits,topology);
646  showerShape.e2x5Top = EcalClusterTools::e2x5Top(seedCluster,recHits,topology);
647  showerShape.e2x5Bottom = EcalClusterTools::e2x5Bottom(seedCluster,recHits,topology);
648  }
649 
651  reco::GsfElectron::ShowerShape & showerShape )
652  {
653  const reco::CaloCluster & seedCluster = *(theClus->seed()) ;
654  // temporary, till CaloCluster->seed() is made available
655  DetId seedXtalId = seedCluster.hitsAndFractions()[0].first ;
656  int detector = seedXtalId.subdetId() ;
657 
660  const EcalRecHitCollection * recHits = nullptr ;
661  std::vector<int> recHitFlagsToBeExcluded ;
662  std::vector<int> recHitSeverityToBeExcluded ;
663  if (detector==EcalBarrel)
664  {
665  recHits = eventData_->barrelRecHits.product() ;
666  recHitFlagsToBeExcluded = generalData_->recHitsCfg.recHitFlagsToBeExcludedBarrel ;
667  recHitSeverityToBeExcluded = generalData_->recHitsCfg.recHitSeverityToBeExcludedBarrel ;
668  }
669  else
670  {
671  recHits = eventData_->endcapRecHits.product() ;
672  recHitFlagsToBeExcluded = generalData_->recHitsCfg.recHitFlagsToBeExcludedEndcaps ;
673  recHitSeverityToBeExcluded = generalData_->recHitsCfg.recHitSeverityToBeExcludedEndcaps ;
674  }
675 
676  std::vector<float> covariances = noZS::EcalClusterTools::covariances(seedCluster,recHits,topology,geometry) ;
677  std::vector<float> localCovariances = noZS::EcalClusterTools::localCovariances(seedCluster,recHits,topology) ;
678  showerShape.sigmaEtaEta = sqrt(covariances[0]) ;
679  showerShape.sigmaIetaIeta = sqrt(localCovariances[0]) ;
680  if (!edm::isNotFinite(localCovariances[2])) showerShape.sigmaIphiIphi = sqrt(localCovariances[2]) ;
681  showerShape.e1x5 = noZS::EcalClusterTools::e1x5(seedCluster,recHits,topology) ;
682  showerShape.e2x5Max = noZS::EcalClusterTools::e2x5Max(seedCluster,recHits,topology) ;
683  showerShape.e5x5 = noZS::EcalClusterTools::e5x5(seedCluster,recHits,topology) ;
684  showerShape.r9 = noZS::EcalClusterTools::e3x3(seedCluster,recHits,topology)/theClus->rawEnergy() ;
685 
686  if (pflow)
687  {
688  showerShape.hcalDepth1OverEcal = generalData_->hcalHelperPflow->hcalESumDepth1(*theClus)/theClus->energy() ;
689  showerShape.hcalDepth2OverEcal = generalData_->hcalHelperPflow->hcalESumDepth2(*theClus)/theClus->energy() ;
693  showerShape.invalidHcal = (showerShape.hcalDepth1OverEcalBc == 0 &&
694  showerShape.hcalDepth2OverEcalBc == 0 &&
696  }
697  else
698  {
699  showerShape.hcalDepth1OverEcal = generalData_->hcalHelper->hcalESumDepth1(*theClus)/theClus->energy() ;
700  showerShape.hcalDepth2OverEcal = generalData_->hcalHelper->hcalESumDepth2(*theClus)/theClus->energy() ;
704  showerShape.invalidHcal = (showerShape.hcalDepth1OverEcalBc == 0 &&
705  showerShape.hcalDepth2OverEcalBc == 0 &&
706  !generalData_->hcalHelper->hasActiveHcal(*theClus));
707  }
708 
709  // extra shower shapes
710  const float see_by_spp = showerShape.sigmaIetaIeta*showerShape.sigmaIphiIphi;
711  if( see_by_spp > 0 ) {
712  showerShape.sigmaIetaIphi = localCovariances[1] / see_by_spp;
713  } else if ( localCovariances[1] > 0 ) {
714  showerShape.sigmaIetaIphi = 1.f;
715  } else {
716  showerShape.sigmaIetaIphi = -1.f;
717  }
718  showerShape.eMax = noZS::EcalClusterTools::eMax(seedCluster,recHits);
719  showerShape.e2nd = noZS::EcalClusterTools::e2nd(seedCluster,recHits);
720  showerShape.eTop = noZS::EcalClusterTools::eTop(seedCluster,recHits,topology);
721  showerShape.eLeft = noZS::EcalClusterTools::eLeft(seedCluster,recHits,topology);
722  showerShape.eRight = noZS::EcalClusterTools::eRight(seedCluster,recHits,topology);
723  showerShape.eBottom = noZS::EcalClusterTools::eBottom(seedCluster,recHits,topology);
724 
725  showerShape.e2x5Left = noZS::EcalClusterTools::e2x5Left(seedCluster,recHits,topology);
726  showerShape.e2x5Right = noZS::EcalClusterTools::e2x5Right(seedCluster,recHits,topology);
727  showerShape.e2x5Top = noZS::EcalClusterTools::e2x5Top(seedCluster,recHits,topology);
728  showerShape.e2x5Bottom = noZS::EcalClusterTools::e2x5Bottom(seedCluster,recHits,topology);
729 
730  }
731 
732 
733 //===================================================================
734 // GsfElectronAlgo
735 //===================================================================
736 
738  ( const InputTagsConfiguration & inputCfg,
739  const StrategyConfiguration & strategyCfg,
740  const CutsConfiguration & cutsCfg,
741  const CutsConfiguration & cutsCfgPflow,
742  const ElectronHcalHelper::Configuration & hcalCfg,
743  const ElectronHcalHelper::Configuration & hcalCfgPflow,
744  const IsolationConfiguration & isoCfg,
745  const EcalRecHitsConfiguration & recHitsCfg,
748  const SoftElectronMVAEstimator::Configuration & mva_NIso_Cfg,
749  const ElectronMVAEstimator::Configuration & mva_Iso_Cfg,
750  const RegressionHelper::Configuration & regCfg,
751  const edm::ParameterSet& tkIsol03Cfg,
752  const edm::ParameterSet& tkIsol04Cfg
753 
754  )
755  : generalData_(new GeneralData(inputCfg,strategyCfg,cutsCfg,cutsCfgPflow,hcalCfg,hcalCfgPflow,isoCfg,recHitsCfg,superClusterErrorFunction,crackCorrectionFunction,mva_NIso_Cfg,mva_Iso_Cfg,regCfg)),
757  eventData_(nullptr), electronData_(nullptr),
758  tkIsol03Calc_(tkIsol03Cfg),tkIsol04Calc_(tkIsol04Cfg)
759  {}
760 
762  {
763  delete generalData_ ;
764  delete eventSetupData_ ;
765  delete eventData_ ;
766  delete electronData_ ;
767  }
768 
770  {
771  // get EventSetupRecords if needed
772  bool updateField(false);
774  updateField = true;
777  }
778 
779  bool updateGeometry(false);
781  updateGeometry = true;
784  }
785 
786  if ( updateField || updateGeometry ) {
787  delete eventSetupData_->mtsTransform ;
791  }
792 
794  eventSetupData_->cacheIDGeom=es.get<CaloGeometryRecord>().cacheIdentifier();
796  }
797 
799  eventSetupData_->cacheIDTopo=es.get<CaloTopologyRecord>().cacheIdentifier();
801  }
802 
807 
808 
813 
814  //if(eventSetupData_->cacheChStatus!=es.get<EcalChannelStatusRcd>().cacheIdentifier()){
815  // eventSetupData_->cacheChStatus=es.get<EcalChannelStatusRcd>().cacheIdentifier();
816  // es.get<EcalChannelStatusRcd>().get(eventSetupData_->chStatus);
817  //}
818 
820  eventSetupData_->cacheSevLevel = es.get<EcalSeverityLevelAlgoRcd>().cacheIdentifier();
822  }
823  }
824 
825 
827  {
828  GsfElectronPtrCollection::const_iterator it ;
829  for
830  ( it = eventData_->electrons->begin() ;
831  it != eventData_->electrons->end() ;
832  it++ )
833  { outEle.push_back(**it) ; }
834  }
835 
837  {
838  if (eventData_!=nullptr)
839  { throw cms::Exception("GsfElectronAlgo|InternalError")<<"unexpected event data" ; }
840  eventData_ = new EventData ;
841 
842  // init the handles linked to the current event
843  eventData_->event = &event ;
850  event.getByToken(generalData_->inputCfg.hcalTowersTag,eventData_->towers) ;
851  event.getByToken(generalData_->inputCfg.pfMVA,eventData_->pfMva) ;
852  event.getByToken(generalData_->inputCfg.seedsTag,eventData_->seeds) ;
856 
857  // get the beamspot from the Event:
858  edm::Handle<reco::BeamSpot> recoBeamSpotHandle ;
859  event.getByToken(generalData_->inputCfg.beamSpotTag,recoBeamSpotHandle) ;
860  eventData_->beamspot = recoBeamSpotHandle.product() ;
861 
862  // prepare access to hcal data
865 
866  // Isolation algos
867  float egHcalIsoConeSizeOutSmall=0.3, egHcalIsoConeSizeOutLarge=0.4;
868  float egHcalIsoConeSizeIn=generalData_->isoCfg.intRadiusHcal,egHcalIsoPtMin=generalData_->isoCfg.etMinHcal;
869  int egHcalDepth1=1, egHcalDepth2=2;
870  eventData_->hadDepth1Isolation03 = new EgammaTowerIsolation(egHcalIsoConeSizeOutSmall,egHcalIsoConeSizeIn,egHcalIsoPtMin,egHcalDepth1,eventData_->towers.product()) ;
871  eventData_->hadDepth2Isolation03 = new EgammaTowerIsolation(egHcalIsoConeSizeOutSmall,egHcalIsoConeSizeIn,egHcalIsoPtMin,egHcalDepth2,eventData_->towers.product()) ;
872  eventData_->hadDepth1Isolation04 = new EgammaTowerIsolation(egHcalIsoConeSizeOutLarge,egHcalIsoConeSizeIn,egHcalIsoPtMin,egHcalDepth1,eventData_->towers.product()) ;
873  eventData_->hadDepth2Isolation04 = new EgammaTowerIsolation(egHcalIsoConeSizeOutLarge,egHcalIsoConeSizeIn,egHcalIsoPtMin,egHcalDepth2,eventData_->towers.product()) ;
874  eventData_->hadDepth1Isolation03Bc = new EgammaTowerIsolation(egHcalIsoConeSizeOutSmall,0.,egHcalIsoPtMin,egHcalDepth1,eventData_->towers.product()) ;
875  eventData_->hadDepth2Isolation03Bc = new EgammaTowerIsolation(egHcalIsoConeSizeOutSmall,0.,egHcalIsoPtMin,egHcalDepth2,eventData_->towers.product()) ;
876  eventData_->hadDepth1Isolation04Bc = new EgammaTowerIsolation(egHcalIsoConeSizeOutLarge,0.,egHcalIsoPtMin,egHcalDepth1,eventData_->towers.product()) ;
877  eventData_->hadDepth2Isolation04Bc = new EgammaTowerIsolation(egHcalIsoConeSizeOutLarge,0.,egHcalIsoPtMin,egHcalDepth2,eventData_->towers.product()) ;
878 
879  float egIsoConeSizeOutSmall=0.3, egIsoConeSizeOutLarge=0.4, egIsoJurassicWidth=generalData_->isoCfg.jurassicWidth;
880  float egIsoPtMinBarrel=generalData_->isoCfg.etMinBarrel,egIsoEMinBarrel=generalData_->isoCfg.eMinBarrel, egIsoConeSizeInBarrel=generalData_->isoCfg.intRadiusEcalBarrel;
881  float egIsoPtMinEndcap=generalData_->isoCfg.etMinEndcaps,egIsoEMinEndcap=generalData_->isoCfg.eMinEndcaps, egIsoConeSizeInEndcap=generalData_->isoCfg.intRadiusEcalEndcaps;
882  eventData_->ecalBarrelIsol03 = new EgammaRecHitIsolation(egIsoConeSizeOutSmall,egIsoConeSizeInBarrel,egIsoJurassicWidth,egIsoPtMinBarrel,egIsoEMinBarrel,eventSetupData_->caloGeom,*(eventData_->barrelRecHits),eventSetupData_->sevLevel.product(),DetId::Ecal);
883  eventData_->ecalBarrelIsol04 = new EgammaRecHitIsolation(egIsoConeSizeOutLarge,egIsoConeSizeInBarrel,egIsoJurassicWidth,egIsoPtMinBarrel,egIsoEMinBarrel,eventSetupData_->caloGeom,*(eventData_->barrelRecHits),eventSetupData_->sevLevel.product(),DetId::Ecal);
884  eventData_->ecalEndcapIsol03 = new EgammaRecHitIsolation(egIsoConeSizeOutSmall,egIsoConeSizeInEndcap,egIsoJurassicWidth,egIsoPtMinEndcap,egIsoEMinEndcap,eventSetupData_->caloGeom,*(eventData_->endcapRecHits),eventSetupData_->sevLevel.product(),DetId::Ecal);
885  eventData_->ecalEndcapIsol04 = new EgammaRecHitIsolation(egIsoConeSizeOutLarge,egIsoConeSizeInEndcap,egIsoJurassicWidth,egIsoPtMinEndcap,egIsoEMinEndcap,eventSetupData_->caloGeom,*(eventData_->endcapRecHits),eventSetupData_->sevLevel.product(),DetId::Ecal);
902 
903  //Fill in the Isolation Value Maps for PF and EcalDriven electrons
904  std::vector<edm::InputTag> inputTagIsoVals;
906  inputTagIsoVals.push_back(generalData_->inputCfg.pfIsoVals.getParameter<edm::InputTag>("pfSumChargedHadronPt"));
907  inputTagIsoVals.push_back(generalData_->inputCfg.pfIsoVals.getParameter<edm::InputTag>("pfSumPhotonEt"));
908  inputTagIsoVals.push_back(generalData_->inputCfg.pfIsoVals.getParameter<edm::InputTag>("pfSumNeutralHadronEt"));
909 
910  eventData_->pfIsolationValues.resize(inputTagIsoVals.size());
911 
912  for (size_t j = 0; j<inputTagIsoVals.size(); ++j) {
913  event.getByLabel(inputTagIsoVals[j], eventData_->pfIsolationValues[j]);
914  }
915 
916  }
917 
919  inputTagIsoVals.clear();
920  inputTagIsoVals.push_back(generalData_->inputCfg.edIsoVals.getParameter<edm::InputTag>("edSumChargedHadronPt"));
921  inputTagIsoVals.push_back(generalData_->inputCfg.edIsoVals.getParameter<edm::InputTag>("edSumPhotonEt"));
922  inputTagIsoVals.push_back(generalData_->inputCfg.edIsoVals.getParameter<edm::InputTag>("edSumNeutralHadronEt"));
923 
924  eventData_->edIsolationValues.resize(inputTagIsoVals.size());
925 
926  for (size_t j = 0; j<inputTagIsoVals.size(); ++j) {
927  event.getByLabel(inputTagIsoVals[j], eventData_->edIsolationValues[j]);
928  }
929  }
930  }
931 
933  {
934  if (eventData_==nullptr)
935  { throw cms::Exception("GsfElectronAlgo|InternalError")<<"lacking event data" ; }
936  delete eventData_ ;
937  eventData_ = nullptr ;
938  }
939 
941  {
942  LogTrace("GsfElectronAlgo") << "========== " << title << " ==========";
943  LogTrace("GsfElectronAlgo") << "Event: " << eventData_->event->id();
944  LogTrace("GsfElectronAlgo") << "Number of electrons: " << eventData_->electrons->size() ;
945  GsfElectronPtrCollection::const_iterator it ;
946  for ( it = eventData_->electrons->begin(); it != eventData_->electrons->end(); it++ )
947  {
948  LogTrace("GsfElectronAlgo") << "Electron with charge, pt, eta, phi: " << (*it)->charge() << " , "
949  << (*it)->pt() << " , " << (*it)->eta() << " , " << (*it)->phi();
950  }
951  LogTrace("GsfElectronAlgo") << "=================================================";
952  }
953 
955  {
956  if (electronData_!=nullptr)
957  { throw cms::Exception("GsfElectronAlgo|InternalError")<<"unexpected electron data" ; }
958 
959  const GsfElectronCoreCollection * coreCollection = eventData_->coreElectrons.product() ;
960  for ( unsigned int i=0 ; i<coreCollection->size() ; ++i )
961  {
962  // check there is no existing electron with this core
964  bool coreFound = false ;
965  GsfElectronPtrCollection::const_iterator itrEle ;
966  for
967  ( itrEle = eventData_->electrons->begin() ;
968  itrEle != eventData_->electrons->end() ;
969  itrEle++ )
970  {
971  if ((*itrEle)->core()==coreRef)
972  {
973  coreFound = true ;
974  break ;
975  }
976  }
977  if (coreFound) continue ;
978 
979  // check there is a super-cluster
980  if (coreRef->superCluster().isNull()) continue ;
981 
982  // prepare internal structure for electron specific data
983  delete electronData_ ;
984  electronData_ = new ElectronData(coreRef,*eventData_->beamspot) ;
985 
986  // calculate and check Trajectory StatesOnSurface....
988 
989  createElectron(hoc) ;
990 
991  } // loop over tracks
992 
993  delete electronData_ ;
995  }
996 
998  {
999  const GsfElectronCollection * oldElectrons = eventData_->previousElectrons.product() ;
1001  GsfElectronCollection::const_iterator oldElectron ;
1002  for
1003  ( oldElectron = oldElectrons->begin() ;
1004  oldElectron != oldElectrons->end() ;
1005  ++oldElectron )
1006  {
1007  const GsfElectronCoreRef oldCoreRef = oldElectron->core() ;
1008  const GsfTrackRef oldElectronGsfTrackRef = oldCoreRef->gsfTrack() ;
1009  unsigned int icore ;
1010  for ( icore=0 ; icore<newCores->size() ; ++icore )
1011  {
1012  if (oldElectronGsfTrackRef==(*newCores)[icore].gsfTrack())
1013  {
1015  eventData_->electrons->push_back(new GsfElectron(*oldElectron,coreRef)) ;
1016  break ;
1017  }
1018  }
1019  }
1020  }
1021 
1022 
1023 // now deprecated
1025  {
1026  bool found ;
1027  const GsfElectronCollection * edElectrons = eventData_->previousElectrons.product() ;
1028  const GsfElectronCollection * pfElectrons = eventData_->pflowElectrons.product() ;
1029  GsfElectronCollection::const_iterator pfElectron, edElectron ;
1030  unsigned int edIndex, pfIndex ;
1031 
1032  GsfElectronPtrCollection::iterator el ;
1033  for
1034  ( el = eventData_->electrons->begin() ;
1035  el != eventData_->electrons->end() ;
1036  el++ )
1037  {
1038 
1039  // Retreive info from pflow electrons
1040  found = false ;
1041  for
1042  ( pfIndex = 0, pfElectron = pfElectrons->begin() ; pfElectron != pfElectrons->end() ; pfIndex++, pfElectron++ )
1043  {
1044  if (pfElectron->gsfTrack()==(*el)->gsfTrack())
1045  {
1046  if (found)
1047  {
1048  edm::LogWarning("GsfElectronProducer")<<"associated pfGsfElectron already found" ;
1049  }
1050  else
1051  {
1052  found = true ;
1053 
1054  // Isolation Values
1055  if( !(eventData_->pfIsolationValues).empty() )
1056  {
1058  pfElectronRef(eventData_->pflowElectrons, pfIndex);
1060  isoVariables.sumChargedHadronPt =(*(eventData_->pfIsolationValues)[0])[pfElectronRef];
1061  isoVariables.sumPhotonEt =(*(eventData_->pfIsolationValues)[1])[pfElectronRef];
1062  isoVariables.sumNeutralHadronEt =(*(eventData_->pfIsolationValues)[2])[pfElectronRef];
1063  (*el)->setPfIsolationVariables(isoVariables);
1064  }
1065 
1066 // (*el)->setPfIsolationVariables(pfElectron->pfIsolationVariables()) ;
1067  (*el)->setMvaInput(pfElectron->mvaInput()) ;
1068  (*el)->setMvaOutput(pfElectron->mvaOutput()) ;
1069  if ((*el)->ecalDrivenSeed())
1070  { (*el)->setP4(GsfElectron::P4_PFLOW_COMBINATION,pfElectron->p4(GsfElectron::P4_PFLOW_COMBINATION),pfElectron->p4Error(GsfElectron::P4_PFLOW_COMBINATION),false) ; }
1071  else
1072  { (*el)->setP4(GsfElectron::P4_PFLOW_COMBINATION,pfElectron->p4(GsfElectron::P4_PFLOW_COMBINATION),pfElectron->p4Error(GsfElectron::P4_PFLOW_COMBINATION),true) ; }
1073  double noCutMin = -999999999. ;
1074  if ((*el)->mva_e_pi()<noCutMin) { throw cms::Exception("GsfElectronAlgo|UnexpectedMvaValue")<<"unexpected MVA value: "<<(*el)->mva_e_pi() ; }
1075  }
1076  }
1077  }
1078 
1079  // Isolation Values
1080  // Retreive not found info from ed electrons
1081  if( !(eventData_->edIsolationValues).empty() )
1082  {
1083  edIndex = 0, edElectron = edElectrons->begin() ;
1084  while ((found == false)&&(edElectron != edElectrons->end()))
1085  {
1086  if (edElectron->gsfTrack()==(*el)->gsfTrack())
1087  {
1088  found = true ;
1089 
1090  // CONSTRUCTION D UNE REF dans le handle eventData_->previousElectrons avec l'indice edIndex,
1091  // puis recuperation dans la ValueMap ED
1092 
1094  edElectronRef(eventData_->previousElectrons, edIndex);
1096  isoVariables.sumChargedHadronPt =(*(eventData_->edIsolationValues)[0])[edElectronRef];
1097  isoVariables.sumPhotonEt =(*(eventData_->edIsolationValues)[1])[edElectronRef];
1098  isoVariables.sumNeutralHadronEt =(*(eventData_->edIsolationValues)[2])[edElectronRef];
1099  (*el)->setPfIsolationVariables(isoVariables);
1100  }
1101 
1102  edIndex++ ;
1103  edElectron++ ;
1104  }
1105  }
1106 
1107  // Preselection
1109 
1110  }
1111  }
1112 
1114  {
1115  bool passCutBased=ele->passingCutBasedPreselection();
1116  bool passPF=ele->passingPflowPreselection(); //it is worth nothing for gedGsfElectrons, this does nothing as its not set till GedGsfElectron finaliser, this is always false
1118  bool passmva=ele->passingMvaPreselection();
1119  if(!ele->ecalDrivenSeed()){
1121  return passmva && passCutBased;
1122  else
1123  return passmva;
1124  }
1125  else{
1126  return passCutBased || passPF || passmva;
1127  }
1128  }
1129  else{
1130  return passCutBased || passPF;
1131  }
1132 
1133  return true;
1134  }
1135 
1137  {
1138  GsfElectronPtrCollection::size_type ei = 1, emax = eventData_->electrons->size() ;
1139  GsfElectronPtrCollection::iterator eitr = eventData_->electrons->begin() ;
1140  while (eitr!=eventData_->electrons->end())
1141  {
1142  LogTrace("GsfElectronAlgo")<<"========== removed not preselected "<<ei<<"/"<<emax<<"==========" ;
1143  if (isPreselected(*eitr))
1144  { ++eitr ; ++ei ; }
1145  else
1146  { delete (*eitr) ; eitr = eventData_->electrons->erase(eitr) ; ++ei ; }
1147  }
1148  }
1149 
1150 
1152  {
1153  // default value
1154  ele->setPassCutBasedPreselection(false) ;
1155 
1156  // kind of seeding
1157  bool eg = ele->core()->ecalDrivenSeed() ;
1158  bool pf = ele->core()->trackerDrivenSeed() && !ele->core()->ecalDrivenSeed() ;
1159  bool gedMode = generalData_->strategyCfg.gedElectronMode;
1160  if (eg&&pf) { throw cms::Exception("GsfElectronAlgo|BothEcalAndPureTrackerDriven")<<"An electron cannot be both egamma and purely pflow" ; }
1161  if ((!eg)&&(!pf)) { throw cms::Exception("GsfElectronAlgo|NeitherEcalNorPureTrackerDriven")<<"An electron cannot be neither egamma nor purely pflow" ; }
1162 
1163  const CutsConfiguration * cfg = ((eg||gedMode)?&generalData_->cutsCfg:&generalData_->cutsCfgPflow);
1164 
1165  // Et cut
1166  double etaValue = EleRelPoint(ele->superCluster()->position(),bs.position()).eta() ;
1167  double etValue = ele->superCluster()->energy()/cosh(etaValue) ;
1168  LogTrace("GsfElectronAlgo") << "Et : " << etValue ;
1169  if (ele->isEB() && (etValue < cfg->minSCEtBarrel)) return ;
1170  if (ele->isEE() && (etValue < cfg->minSCEtEndcaps)) return ;
1171  LogTrace("GsfElectronAlgo") << "Et criteria are satisfied";
1172 
1173  // E/p cut
1174  double eopValue = ele->eSuperClusterOverP() ;
1175  LogTrace("GsfElectronAlgo") << "E/p : " << eopValue ;
1176  if (ele->isEB() && (eopValue > cfg->maxEOverPBarrel)) return ;
1177  if (ele->isEE() && (eopValue > cfg->maxEOverPEndcaps)) return ;
1178  if (ele->isEB() && (eopValue < cfg->minEOverPBarrel)) return ;
1179  if (ele->isEE() && (eopValue < cfg->minEOverPEndcaps)) return ;
1180  LogTrace("GsfElectronAlgo") << "E/p criteria are satisfied";
1181 
1182  // HoE cuts
1183  LogTrace("GsfElectronAlgo") << "HoE1 : " << ele->hcalDepth1OverEcal() << ", HoE2 : " << ele->hcalDepth2OverEcal();
1184  double had = ele->hcalOverEcal()*ele->superCluster()->energy() ;
1185  const reco::CaloCluster & seedCluster = *(ele->superCluster()->seed()) ;
1186  int detector = seedCluster.hitsAndFractions()[0].first.subdetId() ;
1187  bool HoEveto = false ;
1188  if (detector==EcalBarrel && (had<cfg->maxHBarrel || (had/ele->superCluster()->energy())<cfg->maxHOverEBarrel)) HoEveto=true;
1189  else if (detector==EcalEndcap && (had<cfg->maxHEndcaps || (had/ele->superCluster()->energy())<cfg->maxHOverEEndcaps)) HoEveto=true;
1190  if ( !HoEveto ) return ;
1191  LogTrace("GsfElectronAlgo") << "H/E criteria are satisfied";
1192 
1193  // delta eta criteria
1194  double deta = ele->deltaEtaSuperClusterTrackAtVtx() ;
1195  LogTrace("GsfElectronAlgo") << "delta eta : " << deta ;
1196  if (ele->isEB() && (std::abs(deta) > cfg->maxDeltaEtaBarrel)) return ;
1197  if (ele->isEE() && (std::abs(deta) > cfg->maxDeltaEtaEndcaps)) return ;
1198  LogTrace("GsfElectronAlgo") << "Delta eta criteria are satisfied";
1199 
1200  // delta phi criteria
1201  double dphi = ele->deltaPhiSuperClusterTrackAtVtx();
1202  LogTrace("GsfElectronAlgo") << "delta phi : " << dphi;
1203  if (ele->isEB() && (std::abs(dphi) > cfg->maxDeltaPhiBarrel)) return ;
1204  if (ele->isEE() && (std::abs(dphi) > cfg->maxDeltaPhiEndcaps)) return ;
1205  LogTrace("GsfElectronAlgo") << "Delta phi criteria are satisfied";
1206 
1207  // sigma ieta ieta
1208  LogTrace("GsfElectronAlgo") << "sigma ieta ieta : " << ele->sigmaIetaIeta();
1209  if (ele->isEB() && (ele->sigmaIetaIeta() > cfg->maxSigmaIetaIetaBarrel)) return ;
1210  if (ele->isEE() && (ele->sigmaIetaIeta() > cfg->maxSigmaIetaIetaEndcaps)) return ;
1211  LogTrace("GsfElectronAlgo") << "Sigma ieta ieta criteria are satisfied";
1212 
1213  // fiducial
1214  if (!ele->isEB() && cfg->isBarrel) return ;
1215  if (!ele->isEE() && cfg->isEndcaps) return ;
1216  if (cfg->isFiducial && (ele->isEBEEGap()||ele->isEBEtaGap()||ele->isEBPhiGap()||ele->isEERingGap()||ele->isEEDeeGap())) return ;
1217  LogTrace("GsfElectronAlgo") << "Fiducial flags criteria are satisfied";
1218 
1219  // seed in TEC
1220  edm::RefToBase<TrajectorySeed> seed = ele->gsfTrack()->extra()->seedRef() ;
1221  ElectronSeedRef elseed = seed.castTo<ElectronSeedRef>() ;
1222  if (eg && !generalData_->cutsCfg.seedFromTEC)
1223  {
1224  if (elseed.isNull())
1225  { throw cms::Exception("GsfElectronAlgo|NotElectronSeed")<<"The GsfTrack seed is not an ElectronSeed ?!" ; }
1226  else
1227  { if (elseed->subDet2()==6) return ; }
1228  }
1229 
1230  // transverse impact parameter
1231  if (std::abs(ele->gsfTrack()->dxy(bs.position()))>cfg->maxTIP) return ;
1232  LogTrace("GsfElectronAlgo") << "TIP criterion is satisfied" ;
1233 
1234  LogTrace("GsfElectronAlgo") << "All cut based criteria are satisfied" ;
1235  ele->setPassCutBasedPreselection(true) ;
1236  }
1237 
1239  {
1240  ele->setPassMvaPreselection(false) ;
1241 
1242  if (ele->core()->ecalDrivenSeed())
1243  { if (ele->mvaOutput().mva_e_pi>=generalData_->cutsCfg.minMVA) ele->setPassMvaPreselection(true) ; }
1244  else
1246 
1247  if (ele->passingMvaPreselection())
1248  { LogTrace("GsfElectronAlgo") << "Main mva criterion is satisfied" ; }
1249 
1251 
1252  }
1253 
1254 void GsfElectronAlgo::setMVAInputs(const std::map<reco::GsfTrackRef,reco::GsfElectron::MvaInput> & mvaInputs)
1255 {
1256  GsfElectronPtrCollection::iterator el ;
1257  for
1258  ( el = eventData_->electrons->begin() ;
1259  el != eventData_->electrons->end() ;
1260  el++ )
1261  {
1262  std::map<reco::GsfTrackRef,reco::GsfElectron::MvaInput>::const_iterator itcheck=mvaInputs.find((*el)->gsfTrack());
1263  (*el)->setMvaInput(itcheck->second);
1264  }
1265 }
1266 
1268  const std::map<reco::GsfTrackRef,reco::GsfElectron::MvaOutput> & mvaOutputs)
1269 {
1270  GsfElectronPtrCollection::iterator el ;
1271  for
1272  ( el = eventData_->electrons->begin() ;
1273  el != eventData_->electrons->end() ;
1274  el++ )
1275  {
1277  float mva_NIso_Value= hoc->sElectronMVAEstimator->mva( *(*el), *(eventData_->vertices));
1278  float mva_Iso_Value = hoc->iElectronMVAEstimator->mva( *(*el), eventData_->vertices->size() );
1279  GsfElectron::MvaOutput mvaOutput ;
1280  mvaOutput.mva_e_pi = mva_NIso_Value ;
1281  mvaOutput.mva_Isolated = mva_Iso_Value ;
1282  (*el)->setMvaOutput(mvaOutput);
1283  }
1284  else{
1285  std::map<reco::GsfTrackRef,reco::GsfElectron::MvaOutput>::const_iterator itcheck=mvaOutputs.find((*el)->gsfTrack());
1286  (*el)->setMvaOutput(itcheck->second);
1287  }
1288  }
1289 }
1290 
1292  {
1293  // eventually check ctf track
1296 
1297  // charge ID
1298  int eleCharge ;
1299  GsfElectron::ChargeInfo eleChargeInfo ;
1300  electronData_->computeCharge(eleCharge,eleChargeInfo) ;
1301 
1302  // electron basic cluster
1304 
1305  // Seed cluster
1306  const reco::CaloCluster & seedCluster = *(electronData_->superClusterRef->seed()) ;
1307 
1308  // seed Xtal
1309  // temporary, till CaloCluster->seed() is made available
1310  DetId seedXtalId = seedCluster.hitsAndFractions()[0].first ;
1311 
1313 
1314 
1315  //====================================================
1316  // Candidate attributes
1317  //====================================================
1318 
1320 
1321 
1322  //====================================================
1323  // Track-Cluster Matching
1324  //====================================================
1325 
1327  tcMatching.electronCluster = elbcRef ;
1328  tcMatching.eSuperClusterOverP = (electronData_->vtxMom.mag()>0)?(electronData_->superClusterRef->energy()/electronData_->vtxMom.mag()):(-1.) ;
1329  tcMatching.eSeedClusterOverP = (electronData_->vtxMom.mag()>0.)?(seedCluster.energy()/electronData_->vtxMom.mag()):(-1) ;
1330  tcMatching.eSeedClusterOverPout = (electronData_->seedMom.mag()>0.)?(seedCluster.energy()/electronData_->seedMom.mag()):(-1.) ;
1331  tcMatching.eEleClusterOverPout = (electronData_->eleMom.mag()>0.)?(elbcRef->energy()/electronData_->eleMom.mag()):(-1.) ;
1332 
1334  tcMatching.deltaEtaSuperClusterAtVtx = scAtVtx.dEta() ;
1335  tcMatching.deltaPhiSuperClusterAtVtx = scAtVtx.dPhi() ;
1336 
1337  EleRelPointPair seedAtCalo(seedCluster.position(),electronData_->seedPos,eventData_->beamspot->position()) ;
1338  tcMatching.deltaEtaSeedClusterAtCalo = seedAtCalo.dEta() ;
1339  tcMatching.deltaPhiSeedClusterAtCalo = seedAtCalo.dPhi() ;
1340 
1342  tcMatching.deltaEtaEleClusterAtCalo = ecAtCalo.dEta() ;
1343  tcMatching.deltaPhiEleClusterAtCalo = ecAtCalo.dPhi() ;
1344 
1345 
1346  //=======================================================
1347  // Track extrapolations
1348  //=======================================================
1349 
1358 
1359 
1360  //=======================================================
1361  // Closest Ctf Track
1362  //=======================================================
1363 
1365  ctfInfo.ctfTrack = electronData_->ctfTrackRef ;
1367 
1368 
1369  //====================================================
1370  // FiducialFlags, using nextToBoundary definition of gaps
1371  //====================================================
1372 
1373  reco::GsfElectron::FiducialFlags fiducialFlags ;
1374  int region = seedXtalId.det();
1375  int detector = seedXtalId.subdetId() ;
1376  double feta=std::abs(electronData_->superClusterRef->position().eta()) ;
1377  if (detector==EcalBarrel)
1378  {
1379  fiducialFlags.isEB = true ;
1380  EBDetId ebdetid(seedXtalId);
1381  if (EBDetId::isNextToEtaBoundary(ebdetid))
1382  {
1383  if (ebdetid.ietaAbs()==85)
1384  { fiducialFlags.isEBEEGap = true ; }
1385  else
1386  { fiducialFlags.isEBEtaGap = true ; }
1387  }
1388  if (EBDetId::isNextToPhiBoundary(ebdetid))
1389  { fiducialFlags.isEBPhiGap = true ; }
1390  }
1391  else if (detector==EcalEndcap)
1392  {
1393  fiducialFlags.isEE = true ;
1394  EEDetId eedetid(seedXtalId);
1395  if (EEDetId::isNextToRingBoundary(eedetid))
1396  {
1397  if (std::abs(feta)<2.)
1398  { fiducialFlags.isEBEEGap = true ; }
1399  else
1400  { fiducialFlags.isEERingGap = true ; }
1401  }
1402  if (EEDetId::isNextToDBoundary(eedetid))
1403  { fiducialFlags.isEEDeeGap = true ; }
1404  }
1405  else if ( EcalTools::isHGCalDet((DetId::Detector)region) )
1406  {
1407  fiducialFlags.isEE = true ;
1408  //HGCalDetId eeDetid(seedXtalId);
1409  // fill in fiducial information when we know how to use it...
1410  }
1411  else
1412  { throw cms::Exception("GsfElectronAlgo|UnknownXtalRegion")<<"createElectron(): do not know if it is a barrel or endcap seed cluster !!!!" ; }
1413 
1414 
1415  //====================================================
1416  // SaturationInfo
1417  //====================================================
1418 
1419  reco::GsfElectron::SaturationInfo saturationInfo;
1421 
1422  //====================================================
1423  // ShowerShape
1424  //====================================================
1425 
1426  reco::GsfElectron::ShowerShape showerShape;
1427  reco::GsfElectron::ShowerShape full5x5_showerShape;
1428  if( !EcalTools::isHGCalDet((DetId::Detector)region) ) {
1429  calculateShowerShape(electronData_->superClusterRef,!(electronData_->coreRef->ecalDrivenSeed()),showerShape) ;
1430  calculateShowerShape_full5x5(electronData_->superClusterRef,!(electronData_->coreRef->ecalDrivenSeed()),full5x5_showerShape) ;
1431  }
1432 
1433  //====================================================
1434  // ConversionRejection
1435  //====================================================
1436 
1438 
1439  ConversionFinder conversionFinder ;
1440  double BInTesla = eventSetupData_->magField->inTesla(GlobalPoint(0.,0.,0.)).z() ;
1442  if (!ctfTracks.isValid()) { ctfTracks = eventData_->currentCtfTracks ; }
1443 
1444  // values of conversionInfo.flag()
1445  // -9999 : Partner track was not found
1446  // 0 : Partner track found in the CTF collection using
1447  // 1 : Partner track found in the CTF collection using
1448  // 2 : Partner track found in the GSF collection using
1449  // 3 : Partner track found in the GSF collection using the electron's GSF track
1450  ConversionInfo conversionInfo = conversionFinder.getConversionInfo
1451  (*electronData_->coreRef,ctfTracks,eventData_->originalGsfTracks,BInTesla) ;
1452 
1454  conversionVars.flags = conversionInfo.flag() ;
1455  conversionVars.dist = conversionInfo.dist() ;
1456  conversionVars.dcot = conversionInfo.dcot() ;
1457  conversionVars.radius = conversionInfo.radiusOfConversion() ;
1458  if ((conversionVars.flags==0)or(conversionVars.flags==1))
1459  conversionVars.partner = TrackBaseRef(conversionInfo.conversionPartnerCtfTk()) ;
1460  else if ((conversionVars.flags==2)or(conversionVars.flags==3))
1461  conversionVars.partner = TrackBaseRef(conversionInfo.conversionPartnerGsfTk()) ;
1462 
1463 
1464  //====================================================
1465  // Go !
1466  //====================================================
1467 
1468  GsfElectron * ele = new
1469  GsfElectron
1470  ( eleCharge,eleChargeInfo,electronData_->coreRef,
1471  tcMatching, tkExtra, ctfInfo,
1472  fiducialFlags,showerShape, full5x5_showerShape,
1473  conversionVars, saturationInfo ) ;
1474  // Will be overwritten later in the case of the regression
1476  ele->setP4(GsfElectron::P4_FROM_SUPER_CLUSTER,momentum,0,true) ;
1477 
1478  //====================================================
1479  // brems fractions
1480  //====================================================
1481 
1482  if (electronData_->innMom.mag()>0.)
1484 
1485  // the supercluster is the refined one The seed is not necessarily the first cluster
1486  // hence the use of the electronCluster
1487  SuperClusterRef sc = ele->superCluster() ;
1488  if (!(sc.isNull()))
1489  {
1490  CaloClusterPtr cl = ele->electronCluster() ;
1491  if (sc->clustersSize()>1)
1492  {
1493  float pf_fbrem =( sc->energy() - cl->energy() ) / sc->energy();
1494  ele->setSuperClusterFbrem( pf_fbrem ) ;
1495  }
1496  else
1497  {
1498  ele->setSuperClusterFbrem(0) ;
1499  }
1500  }
1501 
1502  //====================================================
1503  // classification and corrections
1504  //====================================================
1505  // classification
1506  ElectronClassification theClassifier ;
1507  theClassifier.classify(*ele) ;
1508  theClassifier.refineWithPflow(*ele) ;
1509  // ecal energy
1512  {
1517  }
1518  else // original implementation
1519  {
1520  if( !EcalTools::isHGCalDet((DetId::Detector)region) ) {
1521  if (ele->core()->ecalDrivenSeed())
1522  {
1524  { theEnCorrector.classBasedParameterizationEnergy(*ele,*eventData_->beamspot) ; }
1526  { theEnCorrector.classBasedParameterizationUncertainty(*ele) ; }
1527  }
1528  else
1529  {
1531  { theEnCorrector.simpleParameterizationUncertainty(*ele) ; }
1532  }
1533  }
1534  }
1535 
1536  // momentum
1537  // Keep the default correction running first. The track momentum error is computed in there
1538  if (ele->core()->ecalDrivenSeed())
1539  {
1540  ElectronMomentumCorrector theMomCorrector;
1541  theMomCorrector.correct(*ele,electronData_->vtxTSOS);
1542  }
1544  {
1546  }
1547 
1548  //====================================================
1549  // now isolation variables
1550  //====================================================
1551 
1555 
1556  if( !EcalTools::isHGCalDet((DetId::Detector)region) ) {
1569  }
1570  ele->setIsolation03(dr03);
1571  ele->setIsolation04(dr04);
1572 
1573 
1574  //====================================================
1575  // preselection flag
1576  //====================================================
1577 
1579  //setting mva flag, currently GedGsfElectron and GsfElectron pre-selection flags have desynced
1580  //this is for GedGsfElectrons, GsfElectrons (ie old pre 7X std reco) resets this later on
1581  //in the function "addPfInfo"
1582  //yes this is awful, we'll fix it once we work out how to...
1583  float mvaValue = hoc->sElectronMVAEstimator->mva( *(ele),*(eventData_->vertices));
1585 
1586  //====================================================
1587  // Pixel match variables
1588  //====================================================
1590 
1591  LogTrace("GsfElectronAlgo")<<"Constructed new electron with energy "<< ele->p4().e() ;
1592 
1593  eventData_->electrons->push_back(ele) ;
1594  }
1595 
1596 
1597 //=======================================================================================
1598 // Ambiguity solving
1599 //=======================================================================================
1600 
1601 //bool better_electron( const reco::GsfElectron * e1, const reco::GsfElectron * e2 )
1602 // { return (std::abs(e1->eSuperClusterOverP()-1)<std::abs(e2->eSuperClusterOverP()-1)) ; }
1603 
1604 void GsfElectronAlgo::setAmbiguityData( bool ignoreNotPreselected )
1605  {
1606  GsfElectronPtrCollection::iterator e1, e2 ;
1611  else
1612  { throw cms::Exception("GsfElectronAlgo|UnknownAmbiguitySortingStrategy")<<"value of generalData_->strategyCfg.ambSortingStrategy is : "<<generalData_->strategyCfg.ambSortingStrategy ; }
1613 
1614  // init
1615  for
1616  ( e1 = eventData_->electrons->begin() ;
1617  e1 != eventData_->electrons->end() ;
1618  ++e1 )
1619  {
1620  (*e1)->clearAmbiguousGsfTracks() ;
1621  (*e1)->setAmbiguous(false) ;
1622  }
1623 
1624  // get ambiguous from GsfPfRecTracks
1626  {
1627  for
1628  ( e1 = eventData_->electrons->begin() ;
1629  e1 != eventData_->electrons->end() ;
1630  ++e1 )
1631  {
1632  bool found = false ;
1633  const GsfPFRecTrackCollection * gsfPfRecTrackCollection = eventData_->gsfPfRecTracks.product() ;
1634  GsfPFRecTrackCollection::const_iterator gsfPfRecTrack ;
1635  for ( gsfPfRecTrack=gsfPfRecTrackCollection->begin() ;
1636  gsfPfRecTrack!=gsfPfRecTrackCollection->end() ;
1637  ++gsfPfRecTrack )
1638  {
1639  if (gsfPfRecTrack->gsfTrackRef()==(*e1)->gsfTrack())
1640  {
1641  if (found)
1642  {
1643  edm::LogWarning("GsfElectronAlgo")<<"associated gsfPfRecTrack already found" ;
1644  }
1645  else
1646  {
1647  found = true ;
1648  const std::vector<reco::GsfPFRecTrackRef> & duplicates(gsfPfRecTrack->convBremGsfPFRecTrackRef()) ;
1649  std::vector<reco::GsfPFRecTrackRef>::const_iterator duplicate ;
1650  for ( duplicate = duplicates.begin() ; duplicate != duplicates.end() ; duplicate ++ )
1651  { (*e1)->addAmbiguousGsfTrack((*duplicate)->gsfTrackRef()) ; }
1652  }
1653  }
1654  }
1655  }
1656  }
1657  // or search overlapping clusters
1658  else
1659  {
1660  for
1661  ( e1 = eventData_->electrons->begin() ;
1662  e1 != eventData_->electrons->end() ;
1663  ++e1 )
1664  {
1665  if ((*e1)->ambiguous()) continue ;
1666  if ( ignoreNotPreselected && !isPreselected(*e1) ) continue ;
1667 
1668  SuperClusterRef scRef1 = (*e1)->superCluster();
1669  CaloClusterPtr eleClu1 = (*e1)->electronCluster();
1670  LogDebug("GsfElectronAlgo")
1671  << "Blessing electron with E/P " << (*e1)->eSuperClusterOverP()
1672  << ", cluster " << scRef1.get()
1673  << " & track " << (*e1)->gsfTrack().get() ;
1674 
1675  for
1676  ( e2 = e1, ++e2 ;
1677  e2 != eventData_->electrons->end() ;
1678  ++e2 )
1679  {
1680  if ((*e2)->ambiguous()) continue ;
1681  if ( ignoreNotPreselected && !isPreselected(*e2) ) continue ;
1682 
1683  SuperClusterRef scRef2 = (*e2)->superCluster();
1684  CaloClusterPtr eleClu2 = (*e2)->electronCluster();
1685 
1686  // search if same cluster
1687  bool sameCluster = false ;
1689  { sameCluster = (scRef1==scRef2) ; }
1691  {
1692  float eMin = 1. ;
1693  float threshold = eMin*cosh(EleRelPoint(scRef1->position(),eventData_->beamspot->position()).eta()) ;
1694  sameCluster =
1696  (EgAmbiguityTools::sharedEnergy(&(*scRef1->seed()),&(*eleClu2),eventData_->barrelRecHits,eventData_->endcapRecHits)>=threshold) ||
1698  (EgAmbiguityTools::sharedEnergy(&(*scRef1->seed()),&(*scRef2->seed()),eventData_->barrelRecHits,eventData_->endcapRecHits)>=threshold) ) ;
1699  }
1700  else
1701  { throw cms::Exception("GsfElectronAlgo|UnknownAmbiguityClustersOverlapStrategy")<<"value of generalData_->strategyCfg.ambClustersOverlapStrategy is : "<<generalData_->strategyCfg.ambClustersOverlapStrategy ; }
1702 
1703  // main instructions
1704  if (sameCluster)
1705  {
1706  LogDebug("GsfElectronAlgo")
1707  << "Discarding electron with E/P " << (*e2)->eSuperClusterOverP()
1708  << ", cluster " << scRef2.get()
1709  << " and track " << (*e2)->gsfTrack().get() ;
1710  (*e1)->addAmbiguousGsfTrack((*e2)->gsfTrack()) ;
1711  (*e2)->setAmbiguous(true) ;
1712  }
1713  else if ((*e1)->gsfTrack()==(*e2)->gsfTrack())
1714  {
1715  edm::LogWarning("GsfElectronAlgo")
1716  << "Forgetting electron with E/P " << (*e2)->eSuperClusterOverP()
1717  << ", cluster " << scRef2.get()
1718  << " and track " << (*e2)->gsfTrack().get() ;
1719  (*e2)->setAmbiguous(true) ;
1720  }
1721  }
1722  }
1723  }
1724  }
1725 
1727  {
1728  GsfElectronPtrCollection::size_type ei = 1, emax = eventData_->electrons->size() ;
1729  GsfElectronPtrCollection::iterator eitr = eventData_->electrons->begin() ;
1730  while (eitr!=eventData_->electrons->end())
1731  {
1732  LogTrace("GsfElectronAlgo")<<"========== remove ambiguous "<<ei<<"/"<<emax<<"==========" ;
1733  if ((*eitr)->ambiguous())
1734  { delete (*eitr) ; eitr = eventData_->electrons->erase(eitr) ; ++ei ; }
1735  else
1736  { ++eitr ; ++ei ; }
1737  }
1738  }
1739 
1740 
1741 // Pixel match variables
1743  int sd1 = 0 ;
1744  int sd2 = 0 ;
1745  float dPhi1 = 0 ;
1746  float dPhi2 = 0 ;
1747  float dRz1 = 0 ;
1748  float dRz2 = 0 ;
1749  edm::RefToBase<TrajectorySeed> seed = ele->gsfTrack()->extra()->seedRef();
1750  ElectronSeedRef elseed = seed.castTo<ElectronSeedRef>();
1751  if(seed.isNull()){}
1752  else{
1753  if(elseed.isNull()){}
1754  else{
1755  sd1 = elseed->subDet1() ;
1756  sd2 = elseed->subDet2() ;
1757  dPhi1 = (ele->charge()>0) ? elseed->dPhi1Pos() : elseed->dPhi1() ;
1758  dPhi2 = (ele->charge()>0) ? elseed->dPhi2Pos() : elseed->dPhi2() ;
1759  dRz1 = (ele->charge()>0) ? elseed->dRz1Pos () : elseed->dRz1 () ;
1760  dRz2 = (ele->charge()>0) ? elseed->dRz2Pos () : elseed->dRz2 () ;
1761  }
1762  }
1763  ele->setPixelMatchSubdetectors(sd1,sd2) ;
1764  ele->setPixelMatchDPhi1(dPhi1) ;
1765  ele->setPixelMatchDPhi2(dPhi2) ;
1766  ele->setPixelMatchDRz1 (dRz1 ) ;
1767  ele->setPixelMatchDRz2 (dRz2 ) ;
1768 }
#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:217
const MultiTrajectoryStateMode * mtsMode
bool isPreselected(reco::GsfElectron *ele)
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:131
void applyCombinationRegression(reco::GsfElectron &ele) const
void setMVAOutputs(const gsfAlgoHelpers::HeavyObjectCache *, const std::map< reco::GsfTrackRef, reco::GsfElectron::MvaOutput > &mvaOutputs)
static bool isHGCalDet(DetId::Detector thedet)
identify HGCal cells
Definition: EcalTools.h:54
void setTrackFbrem(float fbrem)
Definition: GsfElectron.h:764
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:717
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:892
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)
bool hasActiveHcal(const reco::SuperCluster &sc)
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:889
bool isEBEEGap() const
Definition: GsfElectron.h:355
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
float hcalDepth2OverEcal() const
Definition: GsfElectron.h:443
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:197
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:709
bool passingMvaPreselection() const
Definition: GsfElectron.h:725
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:888
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
return((rh^lh)&mask)
reco::TrackRef conversionPartnerCtfTk() const
const Double_t pi
void createElectron(const gsfAlgoHelpers::HeavyObjectCache *)
void setSuperClusterFbrem(float fbrem)
Definition: GsfElectron.h:765
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:436
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:473
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:631
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:444
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
void setPassMvaPreselection(bool flag)
Definition: GsfElectron.h:724
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:126
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:630
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
bool isNull() const
Checks for null.
Definition: Ref.h:250
void setIsolation04(const IsolationVariables &dr04)
Definition: GsfElectron.h:574
#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:442
void setPixelMatchDPhi2(float dPhi2)
Definition: GsfElectron.h:890
std::vector< edm::Handle< edm::ValueMap< double > > > IsolationValueMaps
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:207
int flag() const
void calculateSaturationInfo(const reco::SuperClusterRef &, reco::GsfElectron::SaturationInfo &)
T const * product() const
Definition: Handle.h:81
Detector
Definition: DetId.h:26
EcalClusterFunctionBaseClass * superClusterErrorFunction
REF castTo() const
Definition: RefToBase.h:289
bool isNull() const
Checks for null.
Definition: RefToBase.h:331
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:683
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
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:573
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
T get() const
Definition: EventSetup.h:62
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:718
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:516
edm::ESHandle< TrackerGeometry > trackerHandle
void setAmbiguityData(bool ignoreNotPreselected=true)
IsolationValueMaps edIsolationValues
float sumChargedHadronPt
sum-pt of charged Hadron // old float chargedHadronIso ;
Definition: GsfElectron.h:629
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:891
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
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:39
Candidate::LorentzVector calculateMomentum()
bool passingPflowPreselection() const
Definition: GsfElectron.h:710
const reco::BeamSpot beamSpot