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(0), constraintAtVtx(0), 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  ElectronTkIsolation * tkIsolation03, * tkIsolation04 ;
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 
231  : event(0), beamspot(0),
232  originalCtfTrackCollectionRetreived(false),
233  originalGsfTrackCollectionRetreived(false),
234  tkIsolation03(0), tkIsolation04(0),
235  hadDepth1Isolation03(0), hadDepth1Isolation04(0),
236  hadDepth2Isolation03(0), hadDepth2Isolation04(0),
237  hadDepth1Isolation03Bc(0), hadDepth1Isolation04Bc(0),
238  hadDepth2Isolation03Bc(0), hadDepth2Isolation04Bc(0),
239  ecalBarrelIsol03(0), ecalBarrelIsol04(0),
240  ecalEndcapIsol03(0), ecalEndcapIsol04(0)
241  {
243  }
244 
246  {
247  delete tkIsolation03 ;
248  delete tkIsolation04 ;
249  delete hadDepth1Isolation03 ;
250  delete hadDepth1Isolation04 ;
251  delete hadDepth2Isolation03 ;
252  delete hadDepth2Isolation04 ;
253  delete hadDepth1Isolation03Bc ;
254  delete hadDepth1Isolation04Bc ;
255  delete hadDepth2Isolation03Bc ;
256  delete hadDepth2Isolation04Bc ;
257  delete ecalBarrelIsol03 ;
258  delete ecalBarrelIsol04 ;
259  delete ecalEndcapIsol03 ;
260  delete ecalEndcapIsol04 ;
261 
262  GsfElectronPtrCollection::const_iterator it ;
263  for ( it = electrons->begin() ; it != electrons->end() ; it++ )
264  { delete (*it) ; }
265  delete electrons ;
266  }
267 
269  ( const reco::TrackRef & ctfTrack, const reco::GsfTrackRef & gsfTrack )
270  {
271  if ((!originalCtfTrackCollectionRetreived)&&(ctfTrack.isNonnull()))
272  {
273  event->get(ctfTrack.id(),originalCtfTracks) ;
275  }
276  if ((!originalGsfTrackCollectionRetreived)&&(gsfTrack.isNonnull()))
277  {
278  event->get(gsfTrack.id(),originalGsfTracks) ;
280  }
281  }
282 
283 
284 //===================================================================
285 // GsfElectronAlgo::ElectronData
286 //===================================================================
287 
289  {
290  // Refs to subproducts
297 
298  // constructors
300  ( const reco::GsfElectronCoreRef & core,
301  const reco::BeamSpot & bs ) ;
302  ~ElectronData() ;
303 
304  // utilities
306  void computeCharge( int & charge, reco::GsfElectron::ChargeInfo & info ) ;
307  CaloClusterPtr getEleBasicCluster( const MultiTrajectoryStateTransform * ) ;
308  bool calculateTSOS( const MultiTrajectoryStateTransform *, GsfConstraintAtVertex * ) ;
309  void calculateMode( const MultiTrajectoryStateMode * mtsMode ) ;
310  Candidate::LorentzVector calculateMomentum() ;
311 
312  // TSOS
320 
321  // mode
322  GlobalVector innMom, seedMom, eleMom, sclMom, vtxMom, outMom ;
323  GlobalPoint innPos, seedPos, elePos, sclPos, vtxPos, outPos ;
325  } ;
326 
329  const reco::BeamSpot & bs )
330  : coreRef(core),
331  gsfTrackRef(coreRef->gsfTrack()),
332  superClusterRef(coreRef->superCluster()),
333  ctfTrackRef(coreRef->ctfTrack()), shFracInnerHits(coreRef->ctfGsfOverlap()),
334  beamSpot(bs)
335  {}
336 
338  {}
339 
341 {
342  if (!ctfTrackRef.isNull()) return ;
343 
344  // Code below from Puneeth Kalavase
345 
346  shFracInnerHits = 0 ;
347  const TrackCollection * ctfTrackCollection = currentCtfTracks.product() ;
348 
349  // get the Hit Pattern for the gsfTrack
350  const HitPattern &gsfHitPattern = gsfTrackRef->hitPattern() ;
351 
352  unsigned int counter ;
353  TrackCollection::const_iterator ctfTkIter ;
354  for (ctfTkIter = ctfTrackCollection->begin(), counter = 0;
355  ctfTkIter != ctfTrackCollection->end(); ctfTkIter++, counter++)
356  {
357  double dEta = gsfTrackRef->eta() - ctfTkIter->eta() ;
358  double dPhi = gsfTrackRef->phi() - ctfTkIter->phi() ;
359  double pi = acos(-1.);
360  if(std::abs(dPhi) > pi) dPhi = 2*pi - std::abs(dPhi) ;
361 
362  // dont want to look at every single track in the event!
363  if (sqrt(dEta*dEta + dPhi*dPhi) > 0.3) continue ;
364 
365  unsigned int shared = 0 ;
366  int gsfHitCounter = 0 ;
367  int numGsfInnerHits = 0 ;
368  int numCtfInnerHits = 0 ;
369 
370  // get the CTF Track Hit Pattern
371  const HitPattern &ctfHitPattern = ctfTkIter->hitPattern() ;
372 
373  trackingRecHit_iterator elHitsIt;
374  for (elHitsIt = gsfTrackRef->recHitsBegin();
375  elHitsIt != gsfTrackRef->recHitsEnd();
376  elHitsIt++, gsfHitCounter++)
377  {
378  if (!((**elHitsIt).isValid())) //count only valid Hits
379  { continue ; }
380 
381  // look only in the pixels/TIB/TID
382  uint32_t gsfHit = gsfHitPattern.getHitPattern(HitPattern::TRACK_HITS, gsfHitCounter) ;
383  if (!(HitPattern::pixelHitFilter(gsfHit)
384  || HitPattern::stripTIBHitFilter(gsfHit)
385  || HitPattern::stripTIDHitFilter(gsfHit))){
386  continue;
387  }
388 
389  numGsfInnerHits++ ;
390 
391  int ctfHitsCounter = 0 ;
392  numCtfInnerHits = 0 ;
393  trackingRecHit_iterator ctfHitsIt ;
394  for (ctfHitsIt = ctfTkIter->recHitsBegin();
395  ctfHitsIt != ctfTkIter->recHitsEnd();
396  ctfHitsIt++, ctfHitsCounter++ )
397  {
398  if(!((**ctfHitsIt).isValid())) //count only valid Hits!
399  { continue; }
400 
401  uint32_t ctfHit = ctfHitPattern.getHitPattern(HitPattern::TRACK_HITS, ctfHitsCounter);
402  if(!(HitPattern::pixelHitFilter(ctfHit)
403  || HitPattern::stripTIBHitFilter(ctfHit)
404  || HitPattern::stripTIDHitFilter(ctfHit)))
405  {
406  continue;
407  }
408 
409  numCtfInnerHits++ ;
410 
411  if((**elHitsIt).sharesInput(&(**ctfHitsIt), TrackingRecHit::all))
412  {
413  shared++ ;
414  break ;
415  }
416 
417  } //ctfHits iterator
418 
419  } //gsfHits iterator
420 
421  if ((numGsfInnerHits==0)||(numCtfInnerHits==0))
422  { continue ; }
423 
424  if ( static_cast<float>(shared)/min(numGsfInnerHits,numCtfInnerHits) > shFracInnerHits )
425  {
426  shFracInnerHits = static_cast<float>(shared)/min(numGsfInnerHits, numCtfInnerHits);
427  ctfTrackRef = TrackRef(currentCtfTracks,counter);
428  }
429  } //ctfTrack iterator
430 }
431 
434  {
435  // determine charge from SC
436  GlobalPoint orig, scpos ;
437  ele_convert(beamSpot.position(),orig) ;
438  ele_convert(superClusterRef->position(),scpos) ;
439  GlobalVector scvect(scpos-orig) ;
440  GlobalPoint inntkpos = innTSOS.globalPosition() ;
441  GlobalVector inntkvect = GlobalVector(inntkpos-orig) ;
442  float dPhiInnEle=normalized_phi(scvect.barePhi()-inntkvect.barePhi()) ;
443  if(dPhiInnEle>0) info.scPixCharge = -1 ;
444  else info.scPixCharge = 1 ;
445 
446  // flags
447  int chargeGsf = gsfTrackRef->charge() ;
448  info.isGsfScPixConsistent = ((chargeGsf*info.scPixCharge)>0) ;
449  info.isGsfCtfConsistent = (ctfTrackRef.isNonnull()&&((chargeGsf*ctfTrackRef->charge())>0)) ;
451 
452  // default charge
453  if (info.isGsfScPixConsistent||ctfTrackRef.isNull())
454  { charge = info.scPixCharge ; }
455  else
456  { charge = ctfTrackRef->charge() ; }
457  }
458 
460  ( const MultiTrajectoryStateTransform * mtsTransform )
461  {
462  CaloClusterPtr eleRef ;
463  TrajectoryStateOnSurface tempTSOS ;
464  TrajectoryStateOnSurface outTSOS = mtsTransform->outerStateOnSurface(*gsfTrackRef) ;
465  float dphimin = 1.e30 ;
466  for (CaloCluster_iterator bc=superClusterRef->clustersBegin(); bc!=superClusterRef->clustersEnd(); bc++)
467  {
468  GlobalPoint posclu((*bc)->position().x(),(*bc)->position().y(),(*bc)->position().z()) ;
469  tempTSOS = mtsTransform->extrapolatedState(outTSOS,posclu) ;
470  if (!tempTSOS.isValid()) tempTSOS=outTSOS ;
471  GlobalPoint extrap = tempTSOS.globalPosition() ;
472  float dphi = EleRelPointPair(posclu,extrap,beamSpot.position()).dPhi() ;
473  if (std::abs(dphi)<dphimin)
474  {
475  dphimin = std::abs(dphi) ;
476  eleRef = (*bc);
477  eleTSOS = tempTSOS ;
478  }
479  }
480  return eleRef ;
481  }
482 
484  ( const MultiTrajectoryStateTransform * mtsTransform, GsfConstraintAtVertex * constraintAtVtx )
485  {
486  //at innermost point
487  innTSOS = mtsTransform->innerStateOnSurface(*gsfTrackRef);
488  if (!innTSOS.isValid()) return false;
489 
490  //at vertex
491  // innermost state propagation to the beam spot position
492  GlobalPoint bsPos ;
493  ele_convert(beamSpot.position(),bsPos) ;
494  vtxTSOS = mtsTransform->extrapolatedState(innTSOS,bsPos) ;
495  if (!vtxTSOS.isValid()) vtxTSOS=innTSOS;
496 
497  //at seed
498  outTSOS = mtsTransform->outerStateOnSurface(*gsfTrackRef);
499  if (!outTSOS.isValid()) return false;
500 
501  // TrajectoryStateOnSurface seedTSOS
502  seedTSOS = mtsTransform->extrapolatedState(outTSOS,
503  GlobalPoint(superClusterRef->seed()->position().x(),
504  superClusterRef->seed()->position().y(),
505  superClusterRef->seed()->position().z()));
506  if (!seedTSOS.isValid()) seedTSOS=outTSOS;
507 
508  // at scl
509  sclTSOS = mtsTransform->extrapolatedState(innTSOS,GlobalPoint(superClusterRef->x(),superClusterRef->y(),superClusterRef->z()));
510  if (!sclTSOS.isValid()) sclTSOS=outTSOS;
511 
512  // constrained momentum
513  constrainedVtxTSOS = constraintAtVtx->constrainAtBeamSpot(*gsfTrackRef,beamSpot);
514 
515  return true ;
516  }
517 
519  {
520  mtsMode->momentumFromModeCartesian(innTSOS,innMom) ;
521  mtsMode->positionFromModeCartesian(innTSOS,innPos) ;
522  mtsMode->momentumFromModeCartesian(seedTSOS,seedMom) ;
523  mtsMode->positionFromModeCartesian(seedTSOS,seedPos) ;
524  mtsMode->momentumFromModeCartesian(eleTSOS,eleMom) ;
525  mtsMode->positionFromModeCartesian(eleTSOS,elePos) ;
526  mtsMode->momentumFromModeCartesian(sclTSOS,sclMom) ;
527  mtsMode->positionFromModeCartesian(sclTSOS,sclPos) ;
528  mtsMode->momentumFromModeCartesian(vtxTSOS,vtxMom) ;
529  mtsMode->positionFromModeCartesian(vtxTSOS,vtxPos) ;
530  mtsMode->momentumFromModeCartesian(outTSOS,outMom);
531  mtsMode->positionFromModeCartesian(outTSOS,outPos) ;
532  mtsMode->momentumFromModeCartesian(constrainedVtxTSOS,vtxMomWithConstraint);
533  }
534 
536  {
537  double scale = superClusterRef->energy()/vtxMom.mag() ;
539  ( vtxMom.x()*scale,vtxMom.y()*scale,vtxMom.z()*scale,
540  superClusterRef->energy() ) ;
541  }
542 
545 
546  const reco::CaloCluster & seedCluster = *(theClus->seed()) ;
547  DetId seedXtalId = seedCluster.seed();
548  int detector = seedXtalId.subdetId();
549  const EcalRecHitCollection* ecalRecHits = 0 ;
550  if (detector==EcalBarrel)
551  ecalRecHits = eventData_->barrelRecHits.product() ;
552  else
553  ecalRecHits = eventData_->endcapRecHits.product() ;
554 
555  int nSaturatedXtals = 0;
556  bool isSeedSaturated = false;
557  const auto hitsAndFractions = theClus->hitsAndFractions();
558  for (auto&& hitFractionPair : hitsAndFractions) {
559  auto&& ecalRecHit = ecalRecHits->find(hitFractionPair.first);
560  if (ecalRecHit == ecalRecHits->end()) continue;
561  if (ecalRecHit->checkFlag(EcalRecHit::Flags::kSaturated)) {
562  nSaturatedXtals++;
563  if (seedXtalId == ecalRecHit->detid())
564  isSeedSaturated = true;
565  }
566  }
567  si.nSaturatedXtals = nSaturatedXtals;
568  si.isSeedSaturated = isSeedSaturated;
569 
570 }
571 
573  reco::GsfElectron::ShowerShape & showerShape )
574  {
575  const reco::CaloCluster & seedCluster = *(theClus->seed()) ;
576  // temporary, till CaloCluster->seed() is made available
577  DetId seedXtalId = seedCluster.hitsAndFractions()[0].first ;
578  int detector = seedXtalId.subdetId() ;
579 
582  const EcalRecHitCollection * recHits = 0 ;
583  std::vector<int> recHitFlagsToBeExcluded ;
584  std::vector<int> recHitSeverityToBeExcluded ;
585  if (detector==EcalBarrel)
586  {
587  recHits = eventData_->barrelRecHits.product() ;
588  recHitFlagsToBeExcluded = generalData_->recHitsCfg.recHitFlagsToBeExcludedBarrel ;
589  recHitSeverityToBeExcluded = generalData_->recHitsCfg.recHitSeverityToBeExcludedBarrel ;
590  }
591  else
592  {
593  recHits = eventData_->endcapRecHits.product() ;
594  recHitFlagsToBeExcluded = generalData_->recHitsCfg.recHitFlagsToBeExcludedEndcaps ;
595  recHitSeverityToBeExcluded = generalData_->recHitsCfg.recHitSeverityToBeExcludedEndcaps ;
596  }
597 
598  std::vector<float> covariances = EcalClusterTools::covariances(seedCluster,recHits,topology,geometry) ;
599  std::vector<float> localCovariances = EcalClusterTools::localCovariances(seedCluster,recHits,topology) ;
600  showerShape.sigmaEtaEta = sqrt(covariances[0]) ;
601  showerShape.sigmaIetaIeta = sqrt(localCovariances[0]) ;
602  if (!edm::isNotFinite(localCovariances[2])) showerShape.sigmaIphiIphi = sqrt(localCovariances[2]) ;
603  showerShape.e1x5 = EcalClusterTools::e1x5(seedCluster,recHits,topology) ;
604  showerShape.e2x5Max = EcalClusterTools::e2x5Max(seedCluster,recHits,topology) ;
605  showerShape.e5x5 = EcalClusterTools::e5x5(seedCluster,recHits,topology) ;
606  showerShape.r9 = EcalClusterTools::e3x3(seedCluster,recHits,topology)/theClus->rawEnergy() ;
607 
608  if (pflow)
609  {
610  showerShape.hcalDepth1OverEcal = generalData_->hcalHelperPflow->hcalESumDepth1(*theClus)/theClus->energy() ;
611  showerShape.hcalDepth2OverEcal = generalData_->hcalHelperPflow->hcalESumDepth2(*theClus)/theClus->energy() ;
615  }
616  else
617  {
618  showerShape.hcalDepth1OverEcal = generalData_->hcalHelper->hcalESumDepth1(*theClus)/theClus->energy() ;
619  showerShape.hcalDepth2OverEcal = generalData_->hcalHelper->hcalESumDepth2(*theClus)/theClus->energy() ;
623  }
624 
625  // extra shower shapes
626  const float see_by_spp = showerShape.sigmaIetaIeta*showerShape.sigmaIphiIphi;
627  if( see_by_spp > 0 ) {
628  showerShape.sigmaIetaIphi = localCovariances[1] / see_by_spp;
629  } else if ( localCovariances[1] > 0 ) {
630  showerShape.sigmaIetaIphi = 1.f;
631  } else {
632  showerShape.sigmaIetaIphi = -1.f;
633  }
634  showerShape.eMax = EcalClusterTools::eMax(seedCluster,recHits);
635  showerShape.e2nd = EcalClusterTools::e2nd(seedCluster,recHits);
636  showerShape.eTop = EcalClusterTools::eTop(seedCluster,recHits,topology);
637  showerShape.eLeft = EcalClusterTools::eLeft(seedCluster,recHits,topology);
638  showerShape.eRight = EcalClusterTools::eRight(seedCluster,recHits,topology);
639  showerShape.eBottom = EcalClusterTools::eBottom(seedCluster,recHits,topology);
640 
641  showerShape.e2x5Left = EcalClusterTools::e2x5Left(seedCluster,recHits,topology);
642  showerShape.e2x5Right = EcalClusterTools::e2x5Right(seedCluster,recHits,topology);
643  showerShape.e2x5Top = EcalClusterTools::e2x5Top(seedCluster,recHits,topology);
644  showerShape.e2x5Bottom = EcalClusterTools::e2x5Bottom(seedCluster,recHits,topology);
645  }
646 
648  reco::GsfElectron::ShowerShape & showerShape )
649  {
650  const reco::CaloCluster & seedCluster = *(theClus->seed()) ;
651  // temporary, till CaloCluster->seed() is made available
652  DetId seedXtalId = seedCluster.hitsAndFractions()[0].first ;
653  int detector = seedXtalId.subdetId() ;
654 
657  const EcalRecHitCollection * recHits = 0 ;
658  std::vector<int> recHitFlagsToBeExcluded ;
659  std::vector<int> recHitSeverityToBeExcluded ;
660  if (detector==EcalBarrel)
661  {
662  recHits = eventData_->barrelRecHits.product() ;
663  recHitFlagsToBeExcluded = generalData_->recHitsCfg.recHitFlagsToBeExcludedBarrel ;
664  recHitSeverityToBeExcluded = generalData_->recHitsCfg.recHitSeverityToBeExcludedBarrel ;
665  }
666  else
667  {
668  recHits = eventData_->endcapRecHits.product() ;
669  recHitFlagsToBeExcluded = generalData_->recHitsCfg.recHitFlagsToBeExcludedEndcaps ;
670  recHitSeverityToBeExcluded = generalData_->recHitsCfg.recHitSeverityToBeExcludedEndcaps ;
671  }
672 
673  std::vector<float> covariances = noZS::EcalClusterTools::covariances(seedCluster,recHits,topology,geometry) ;
674  std::vector<float> localCovariances = noZS::EcalClusterTools::localCovariances(seedCluster,recHits,topology) ;
675  showerShape.sigmaEtaEta = sqrt(covariances[0]) ;
676  showerShape.sigmaIetaIeta = sqrt(localCovariances[0]) ;
677  if (!edm::isNotFinite(localCovariances[2])) showerShape.sigmaIphiIphi = sqrt(localCovariances[2]) ;
678  showerShape.e1x5 = noZS::EcalClusterTools::e1x5(seedCluster,recHits,topology) ;
679  showerShape.e2x5Max = noZS::EcalClusterTools::e2x5Max(seedCluster,recHits,topology) ;
680  showerShape.e5x5 = noZS::EcalClusterTools::e5x5(seedCluster,recHits,topology) ;
681  showerShape.r9 = noZS::EcalClusterTools::e3x3(seedCluster,recHits,topology)/theClus->rawEnergy() ;
682 
683  if (pflow)
684  {
685  showerShape.hcalDepth1OverEcal = generalData_->hcalHelperPflow->hcalESumDepth1(*theClus)/theClus->energy() ;
686  showerShape.hcalDepth2OverEcal = generalData_->hcalHelperPflow->hcalESumDepth2(*theClus)/theClus->energy() ;
690  }
691  else
692  {
693  showerShape.hcalDepth1OverEcal = generalData_->hcalHelper->hcalESumDepth1(*theClus)/theClus->energy() ;
694  showerShape.hcalDepth2OverEcal = generalData_->hcalHelper->hcalESumDepth2(*theClus)/theClus->energy() ;
698  }
699 
700  // extra shower shapes
701  const float see_by_spp = showerShape.sigmaIetaIeta*showerShape.sigmaIphiIphi;
702  if( see_by_spp > 0 ) {
703  showerShape.sigmaIetaIphi = localCovariances[1] / see_by_spp;
704  } else if ( localCovariances[1] > 0 ) {
705  showerShape.sigmaIetaIphi = 1.f;
706  } else {
707  showerShape.sigmaIetaIphi = -1.f;
708  }
709  showerShape.eMax = noZS::EcalClusterTools::eMax(seedCluster,recHits);
710  showerShape.e2nd = noZS::EcalClusterTools::e2nd(seedCluster,recHits);
711  showerShape.eTop = noZS::EcalClusterTools::eTop(seedCluster,recHits,topology);
712  showerShape.eLeft = noZS::EcalClusterTools::eLeft(seedCluster,recHits,topology);
713  showerShape.eRight = noZS::EcalClusterTools::eRight(seedCluster,recHits,topology);
714  showerShape.eBottom = noZS::EcalClusterTools::eBottom(seedCluster,recHits,topology);
715 
716  showerShape.e2x5Left = noZS::EcalClusterTools::e2x5Left(seedCluster,recHits,topology);
717  showerShape.e2x5Right = noZS::EcalClusterTools::e2x5Right(seedCluster,recHits,topology);
718  showerShape.e2x5Top = noZS::EcalClusterTools::e2x5Top(seedCluster,recHits,topology);
719  showerShape.e2x5Bottom = noZS::EcalClusterTools::e2x5Bottom(seedCluster,recHits,topology);
720 
721  }
722 
723 
724 //===================================================================
725 // GsfElectronAlgo
726 //===================================================================
727 
729  ( const InputTagsConfiguration & inputCfg,
730  const StrategyConfiguration & strategyCfg,
731  const CutsConfiguration & cutsCfg,
732  const CutsConfiguration & cutsCfgPflow,
733  const ElectronHcalHelper::Configuration & hcalCfg,
734  const ElectronHcalHelper::Configuration & hcalCfgPflow,
735  const IsolationConfiguration & isoCfg,
736  const EcalRecHitsConfiguration & recHitsCfg,
739  const SoftElectronMVAEstimator::Configuration & mva_NIso_Cfg,
740  const ElectronMVAEstimator::Configuration & mva_Iso_Cfg,
741  const RegressionHelper::Configuration & regCfg
742  )
743  : generalData_(new GeneralData(inputCfg,strategyCfg,cutsCfg,cutsCfgPflow,hcalCfg,hcalCfgPflow,isoCfg,recHitsCfg,superClusterErrorFunction,crackCorrectionFunction,mva_NIso_Cfg,mva_Iso_Cfg,regCfg)),
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_!=0)
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 extRadiusSmall=0.3, extRadiusLarge=0.4 ;
859 
860  float egHcalIsoConeSizeOutSmall=0.3, egHcalIsoConeSizeOutLarge=0.4;
861  float egHcalIsoConeSizeIn=generalData_->isoCfg.intRadiusHcal,egHcalIsoPtMin=generalData_->isoCfg.etMinHcal;
862  int egHcalDepth1=1, egHcalDepth2=2;
863  eventData_->hadDepth1Isolation03 = new EgammaTowerIsolation(egHcalIsoConeSizeOutSmall,egHcalIsoConeSizeIn,egHcalIsoPtMin,egHcalDepth1,eventData_->towers.product()) ;
864  eventData_->hadDepth2Isolation03 = new EgammaTowerIsolation(egHcalIsoConeSizeOutSmall,egHcalIsoConeSizeIn,egHcalIsoPtMin,egHcalDepth2,eventData_->towers.product()) ;
865  eventData_->hadDepth1Isolation04 = new EgammaTowerIsolation(egHcalIsoConeSizeOutLarge,egHcalIsoConeSizeIn,egHcalIsoPtMin,egHcalDepth1,eventData_->towers.product()) ;
866  eventData_->hadDepth2Isolation04 = new EgammaTowerIsolation(egHcalIsoConeSizeOutLarge,egHcalIsoConeSizeIn,egHcalIsoPtMin,egHcalDepth2,eventData_->towers.product()) ;
867  eventData_->hadDepth1Isolation03Bc = new EgammaTowerIsolation(egHcalIsoConeSizeOutSmall,0.,egHcalIsoPtMin,egHcalDepth1,eventData_->towers.product()) ;
868  eventData_->hadDepth2Isolation03Bc = new EgammaTowerIsolation(egHcalIsoConeSizeOutSmall,0.,egHcalIsoPtMin,egHcalDepth2,eventData_->towers.product()) ;
869  eventData_->hadDepth1Isolation04Bc = new EgammaTowerIsolation(egHcalIsoConeSizeOutLarge,0.,egHcalIsoPtMin,egHcalDepth1,eventData_->towers.product()) ;
870  eventData_->hadDepth2Isolation04Bc = new EgammaTowerIsolation(egHcalIsoConeSizeOutLarge,0.,egHcalIsoPtMin,egHcalDepth2,eventData_->towers.product()) ;
871 
872  float egIsoConeSizeOutSmall=0.3, egIsoConeSizeOutLarge=0.4, egIsoJurassicWidth=generalData_->isoCfg.jurassicWidth;
873  float egIsoPtMinBarrel=generalData_->isoCfg.etMinBarrel,egIsoEMinBarrel=generalData_->isoCfg.eMinBarrel, egIsoConeSizeInBarrel=generalData_->isoCfg.intRadiusEcalBarrel;
874  float egIsoPtMinEndcap=generalData_->isoCfg.etMinEndcaps,egIsoEMinEndcap=generalData_->isoCfg.eMinEndcaps, egIsoConeSizeInEndcap=generalData_->isoCfg.intRadiusEcalEndcaps;
875  eventData_->ecalBarrelIsol03 = new EgammaRecHitIsolation(egIsoConeSizeOutSmall,egIsoConeSizeInBarrel,egIsoJurassicWidth,egIsoPtMinBarrel,egIsoEMinBarrel,eventSetupData_->caloGeom,*(eventData_->barrelRecHits),eventSetupData_->sevLevel.product(),DetId::Ecal);
876  eventData_->ecalBarrelIsol04 = new EgammaRecHitIsolation(egIsoConeSizeOutLarge,egIsoConeSizeInBarrel,egIsoJurassicWidth,egIsoPtMinBarrel,egIsoEMinBarrel,eventSetupData_->caloGeom,*(eventData_->barrelRecHits),eventSetupData_->sevLevel.product(),DetId::Ecal);
877  eventData_->ecalEndcapIsol03 = new EgammaRecHitIsolation(egIsoConeSizeOutSmall,egIsoConeSizeInEndcap,egIsoJurassicWidth,egIsoPtMinEndcap,egIsoEMinEndcap,eventSetupData_->caloGeom,*(eventData_->endcapRecHits),eventSetupData_->sevLevel.product(),DetId::Ecal);
878  eventData_->ecalEndcapIsol04 = new EgammaRecHitIsolation(egIsoConeSizeOutLarge,egIsoConeSizeInEndcap,egIsoJurassicWidth,egIsoPtMinEndcap,egIsoEMinEndcap,eventSetupData_->caloGeom,*(eventData_->endcapRecHits),eventSetupData_->sevLevel.product(),DetId::Ecal);
895 
896  //Fill in the Isolation Value Maps for PF and EcalDriven electrons
897  std::vector<edm::InputTag> inputTagIsoVals;
899  inputTagIsoVals.push_back(generalData_->inputCfg.pfIsoVals.getParameter<edm::InputTag>("pfSumChargedHadronPt"));
900  inputTagIsoVals.push_back(generalData_->inputCfg.pfIsoVals.getParameter<edm::InputTag>("pfSumPhotonEt"));
901  inputTagIsoVals.push_back(generalData_->inputCfg.pfIsoVals.getParameter<edm::InputTag>("pfSumNeutralHadronEt"));
902 
903  eventData_->pfIsolationValues.resize(inputTagIsoVals.size());
904 
905  for (size_t j = 0; j<inputTagIsoVals.size(); ++j) {
906  event.getByLabel(inputTagIsoVals[j], eventData_->pfIsolationValues[j]);
907  }
908 
909  }
910 
912  inputTagIsoVals.clear();
913  inputTagIsoVals.push_back(generalData_->inputCfg.edIsoVals.getParameter<edm::InputTag>("edSumChargedHadronPt"));
914  inputTagIsoVals.push_back(generalData_->inputCfg.edIsoVals.getParameter<edm::InputTag>("edSumPhotonEt"));
915  inputTagIsoVals.push_back(generalData_->inputCfg.edIsoVals.getParameter<edm::InputTag>("edSumNeutralHadronEt"));
916 
917  eventData_->edIsolationValues.resize(inputTagIsoVals.size());
918 
919  for (size_t j = 0; j<inputTagIsoVals.size(); ++j) {
920  event.getByLabel(inputTagIsoVals[j], eventData_->edIsolationValues[j]);
921  }
922  }
923  }
924 
926  {
927  if (eventData_==0)
928  { throw cms::Exception("GsfElectronAlgo|InternalError")<<"lacking event data" ; }
929  delete eventData_ ;
930  eventData_ = 0 ;
931  }
932 
934  {
935  LogTrace("GsfElectronAlgo") << "========== " << title << " ==========";
936  LogTrace("GsfElectronAlgo") << "Event: " << eventData_->event->id();
937  LogTrace("GsfElectronAlgo") << "Number of electrons: " << eventData_->electrons->size() ;
938  GsfElectronPtrCollection::const_iterator it ;
939  for ( it = eventData_->electrons->begin(); it != eventData_->electrons->end(); it++ )
940  {
941  LogTrace("GsfElectronAlgo") << "Electron with charge, pt, eta, phi: " << (*it)->charge() << " , "
942  << (*it)->pt() << " , " << (*it)->eta() << " , " << (*it)->phi();
943  }
944  LogTrace("GsfElectronAlgo") << "=================================================";
945  }
946 
948  {
949  if (electronData_!=0)
950  { throw cms::Exception("GsfElectronAlgo|InternalError")<<"unexpected electron data" ; }
951 
952  const GsfElectronCoreCollection * coreCollection = eventData_->coreElectrons.product() ;
953  for ( unsigned int i=0 ; i<coreCollection->size() ; ++i )
954  {
955  // check there is no existing electron with this core
957  bool coreFound = false ;
958  GsfElectronPtrCollection::const_iterator itrEle ;
959  for
960  ( itrEle = eventData_->electrons->begin() ;
961  itrEle != eventData_->electrons->end() ;
962  itrEle++ )
963  {
964  if ((*itrEle)->core()==coreRef)
965  {
966  coreFound = true ;
967  break ;
968  }
969  }
970  if (coreFound) continue ;
971 
972  // check there is a super-cluster
973  if (coreRef->superCluster().isNull()) continue ;
974 
975  // prepare internal structure for electron specific data
976  delete electronData_ ;
977  electronData_ = new ElectronData(coreRef,*eventData_->beamspot) ;
978 
979  // calculate and check Trajectory StatesOnSurface....
981 
982  createElectron(hoc) ;
983 
984  } // loop over tracks
985 
986  delete electronData_ ;
987  electronData_ = 0 ;
988  }
989 
991  {
992  const GsfElectronCollection * oldElectrons = eventData_->previousElectrons.product() ;
994  GsfElectronCollection::const_iterator oldElectron ;
995  for
996  ( oldElectron = oldElectrons->begin() ;
997  oldElectron != oldElectrons->end() ;
998  ++oldElectron )
999  {
1000  const GsfElectronCoreRef oldCoreRef = oldElectron->core() ;
1001  const GsfTrackRef oldElectronGsfTrackRef = oldCoreRef->gsfTrack() ;
1002  unsigned int icore ;
1003  for ( icore=0 ; icore<newCores->size() ; ++icore )
1004  {
1005  if (oldElectronGsfTrackRef==(*newCores)[icore].gsfTrack())
1006  {
1008  eventData_->electrons->push_back(new GsfElectron(*oldElectron,coreRef)) ;
1009  break ;
1010  }
1011  }
1012  }
1013  }
1014 
1015 
1016 // now deprecated
1018  {
1019  bool found ;
1020  const GsfElectronCollection * edElectrons = eventData_->previousElectrons.product() ;
1021  const GsfElectronCollection * pfElectrons = eventData_->pflowElectrons.product() ;
1022  GsfElectronCollection::const_iterator pfElectron, edElectron ;
1023  unsigned int edIndex, pfIndex ;
1024 
1025  GsfElectronPtrCollection::iterator el ;
1026  for
1027  ( el = eventData_->electrons->begin() ;
1028  el != eventData_->electrons->end() ;
1029  el++ )
1030  {
1031 
1032  // Retreive info from pflow electrons
1033  found = false ;
1034  for
1035  ( pfIndex = 0, pfElectron = pfElectrons->begin() ; pfElectron != pfElectrons->end() ; pfIndex++, pfElectron++ )
1036  {
1037  if (pfElectron->gsfTrack()==(*el)->gsfTrack())
1038  {
1039  if (found)
1040  {
1041  edm::LogWarning("GsfElectronProducer")<<"associated pfGsfElectron already found" ;
1042  }
1043  else
1044  {
1045  found = true ;
1046 
1047  // Isolation Values
1048  if( (eventData_->pfIsolationValues).size() != 0 )
1049  {
1051  pfElectronRef(eventData_->pflowElectrons, pfIndex);
1053  isoVariables.sumChargedHadronPt =(*(eventData_->pfIsolationValues)[0])[pfElectronRef];
1054  isoVariables.sumPhotonEt =(*(eventData_->pfIsolationValues)[1])[pfElectronRef];
1055  isoVariables.sumNeutralHadronEt =(*(eventData_->pfIsolationValues)[2])[pfElectronRef];
1056  (*el)->setPfIsolationVariables(isoVariables);
1057  }
1058 
1059 // (*el)->setPfIsolationVariables(pfElectron->pfIsolationVariables()) ;
1060  (*el)->setMvaInput(pfElectron->mvaInput()) ;
1061  (*el)->setMvaOutput(pfElectron->mvaOutput()) ;
1062  if ((*el)->ecalDrivenSeed())
1063  { (*el)->setP4(GsfElectron::P4_PFLOW_COMBINATION,pfElectron->p4(GsfElectron::P4_PFLOW_COMBINATION),pfElectron->p4Error(GsfElectron::P4_PFLOW_COMBINATION),false) ; }
1064  else
1065  { (*el)->setP4(GsfElectron::P4_PFLOW_COMBINATION,pfElectron->p4(GsfElectron::P4_PFLOW_COMBINATION),pfElectron->p4Error(GsfElectron::P4_PFLOW_COMBINATION),true) ; }
1066  double noCutMin = -999999999. ;
1067  if ((*el)->mva_e_pi()<noCutMin) { throw cms::Exception("GsfElectronAlgo|UnexpectedMvaValue")<<"unexpected MVA value: "<<(*el)->mva_e_pi() ; }
1068  }
1069  }
1070  }
1071 
1072  // Isolation Values
1073  // Retreive not found info from ed electrons
1074  if( (eventData_->edIsolationValues).size() != 0 )
1075  {
1076  edIndex = 0, edElectron = edElectrons->begin() ;
1077  while ((found == false)&&(edElectron != edElectrons->end()))
1078  {
1079  if (edElectron->gsfTrack()==(*el)->gsfTrack())
1080  {
1081  found = true ;
1082 
1083  // CONSTRUCTION D UNE REF dans le handle eventData_->previousElectrons avec l'indice edIndex,
1084  // puis recuperation dans la ValueMap ED
1085 
1087  edElectronRef(eventData_->previousElectrons, edIndex);
1089  isoVariables.sumChargedHadronPt =(*(eventData_->edIsolationValues)[0])[edElectronRef];
1090  isoVariables.sumPhotonEt =(*(eventData_->edIsolationValues)[1])[edElectronRef];
1091  isoVariables.sumNeutralHadronEt =(*(eventData_->edIsolationValues)[2])[edElectronRef];
1092  (*el)->setPfIsolationVariables(isoVariables);
1093  }
1094 
1095  edIndex++ ;
1096  edElectron++ ;
1097  }
1098  }
1099 
1100  // Preselection
1102 
1103  }
1104  }
1105 
1107  {
1108  bool passCutBased=ele->passingCutBasedPreselection();
1109  bool passPF=ele->passingPflowPreselection(); //it is worth nothing for gedGsfElectrons, this does nothing as its not set till GedGsfElectron finaliser, this is always false
1111  bool passmva=ele->passingMvaPreselection();
1112  if(!ele->ecalDrivenSeed()){
1114  return passmva && passCutBased;
1115  else
1116  return passmva;
1117  }
1118  else{
1119  return passCutBased || passPF || passmva;
1120  }
1121  }
1122  else{
1123  return passCutBased || passPF;
1124  }
1125 
1126  return true;
1127  }
1128 
1130  {
1131  GsfElectronPtrCollection::size_type ei = 1, emax = eventData_->electrons->size() ;
1132  GsfElectronPtrCollection::iterator eitr = eventData_->electrons->begin() ;
1133  while (eitr!=eventData_->electrons->end())
1134  {
1135  LogTrace("GsfElectronAlgo")<<"========== removed not preselected "<<ei<<"/"<<emax<<"==========" ;
1136  if (isPreselected(*eitr))
1137  { ++eitr ; ++ei ; }
1138  else
1139  { delete (*eitr) ; eitr = eventData_->electrons->erase(eitr) ; ++ei ; }
1140  }
1141  }
1142 
1143 
1145  {
1146  // default value
1147  ele->setPassCutBasedPreselection(false) ;
1148 
1149  // kind of seeding
1150  bool eg = ele->core()->ecalDrivenSeed() ;
1151  bool pf = ele->core()->trackerDrivenSeed() && !ele->core()->ecalDrivenSeed() ;
1152  bool gedMode = generalData_->strategyCfg.gedElectronMode;
1153  if (eg&&pf) { throw cms::Exception("GsfElectronAlgo|BothEcalAndPureTrackerDriven")<<"An electron cannot be both egamma and purely pflow" ; }
1154  if ((!eg)&&(!pf)) { throw cms::Exception("GsfElectronAlgo|NeitherEcalNorPureTrackerDriven")<<"An electron cannot be neither egamma nor purely pflow" ; }
1155 
1156  const CutsConfiguration * cfg = ((eg||gedMode)?&generalData_->cutsCfg:&generalData_->cutsCfgPflow);
1157 
1158  // Et cut
1159  double etaValue = EleRelPoint(ele->superCluster()->position(),bs.position()).eta() ;
1160  double etValue = ele->superCluster()->energy()/cosh(etaValue) ;
1161  LogTrace("GsfElectronAlgo") << "Et : " << etValue ;
1162  if (ele->isEB() && (etValue < cfg->minSCEtBarrel)) return ;
1163  if (ele->isEE() && (etValue < cfg->minSCEtEndcaps)) return ;
1164  LogTrace("GsfElectronAlgo") << "Et criteria are satisfied";
1165 
1166  // E/p cut
1167  double eopValue = ele->eSuperClusterOverP() ;
1168  LogTrace("GsfElectronAlgo") << "E/p : " << eopValue ;
1169  if (ele->isEB() && (eopValue > cfg->maxEOverPBarrel)) return ;
1170  if (ele->isEE() && (eopValue > cfg->maxEOverPEndcaps)) return ;
1171  if (ele->isEB() && (eopValue < cfg->minEOverPBarrel)) return ;
1172  if (ele->isEE() && (eopValue < cfg->minEOverPEndcaps)) return ;
1173  LogTrace("GsfElectronAlgo") << "E/p criteria are satisfied";
1174 
1175  // HoE cuts
1176  LogTrace("GsfElectronAlgo") << "HoE1 : " << ele->hcalDepth1OverEcal() << ", HoE2 : " << ele->hcalDepth2OverEcal();
1177  double had = ele->hcalOverEcal()*ele->superCluster()->energy() ;
1178  const reco::CaloCluster & seedCluster = *(ele->superCluster()->seed()) ;
1179  int detector = seedCluster.hitsAndFractions()[0].first.subdetId() ;
1180  bool HoEveto = false ;
1181  if (detector==EcalBarrel && (had<cfg->maxHBarrel || (had/ele->superCluster()->energy())<cfg->maxHOverEBarrel)) HoEveto=true;
1182  else if (detector==EcalEndcap && (had<cfg->maxHEndcaps || (had/ele->superCluster()->energy())<cfg->maxHOverEEndcaps)) HoEveto=true;
1183  if ( !HoEveto ) return ;
1184  LogTrace("GsfElectronAlgo") << "H/E criteria are satisfied";
1185 
1186  // delta eta criteria
1187  double deta = ele->deltaEtaSuperClusterTrackAtVtx() ;
1188  LogTrace("GsfElectronAlgo") << "delta eta : " << deta ;
1189  if (ele->isEB() && (std::abs(deta) > cfg->maxDeltaEtaBarrel)) return ;
1190  if (ele->isEE() && (std::abs(deta) > cfg->maxDeltaEtaEndcaps)) return ;
1191  LogTrace("GsfElectronAlgo") << "Delta eta criteria are satisfied";
1192 
1193  // delta phi criteria
1194  double dphi = ele->deltaPhiSuperClusterTrackAtVtx();
1195  LogTrace("GsfElectronAlgo") << "delta phi : " << dphi;
1196  if (ele->isEB() && (std::abs(dphi) > cfg->maxDeltaPhiBarrel)) return ;
1197  if (ele->isEE() && (std::abs(dphi) > cfg->maxDeltaPhiEndcaps)) return ;
1198  LogTrace("GsfElectronAlgo") << "Delta phi criteria are satisfied";
1199 
1200  // sigma ieta ieta
1201  LogTrace("GsfElectronAlgo") << "sigma ieta ieta : " << ele->sigmaIetaIeta();
1202  if (ele->isEB() && (ele->sigmaIetaIeta() > cfg->maxSigmaIetaIetaBarrel)) return ;
1203  if (ele->isEE() && (ele->sigmaIetaIeta() > cfg->maxSigmaIetaIetaEndcaps)) return ;
1204  LogTrace("GsfElectronAlgo") << "Sigma ieta ieta criteria are satisfied";
1205 
1206  // fiducial
1207  if (!ele->isEB() && cfg->isBarrel) return ;
1208  if (!ele->isEE() && cfg->isEndcaps) return ;
1209  if (cfg->isFiducial && (ele->isEBEEGap()||ele->isEBEtaGap()||ele->isEBPhiGap()||ele->isEERingGap()||ele->isEEDeeGap())) return ;
1210  LogTrace("GsfElectronAlgo") << "Fiducial flags criteria are satisfied";
1211 
1212  // seed in TEC
1213  edm::RefToBase<TrajectorySeed> seed = ele->gsfTrack()->extra()->seedRef() ;
1214  ElectronSeedRef elseed = seed.castTo<ElectronSeedRef>() ;
1215  if (eg && !generalData_->cutsCfg.seedFromTEC)
1216  {
1217  if (elseed.isNull())
1218  { throw cms::Exception("GsfElectronAlgo|NotElectronSeed")<<"The GsfTrack seed is not an ElectronSeed ?!" ; }
1219  else
1220  { if (elseed->subDet2()==6) return ; }
1221  }
1222 
1223  // transverse impact parameter
1224  if (std::abs(ele->gsfTrack()->dxy(bs.position()))>cfg->maxTIP) return ;
1225  LogTrace("GsfElectronAlgo") << "TIP criterion is satisfied" ;
1226 
1227  LogTrace("GsfElectronAlgo") << "All cut based criteria are satisfied" ;
1228  ele->setPassCutBasedPreselection(true) ;
1229  }
1230 
1232  {
1233  ele->setPassMvaPreselection(false) ;
1234 
1235  if (ele->core()->ecalDrivenSeed())
1236  { if (ele->mvaOutput().mva_e_pi>=generalData_->cutsCfg.minMVA) ele->setPassMvaPreselection(true) ; }
1237  else
1239 
1240  if (ele->passingMvaPreselection())
1241  { LogTrace("GsfElectronAlgo") << "Main mva criterion is satisfied" ; }
1242 
1244 
1245  }
1246 
1247 void GsfElectronAlgo::setMVAInputs(const std::map<reco::GsfTrackRef,reco::GsfElectron::MvaInput> & mvaInputs)
1248 {
1249  GsfElectronPtrCollection::iterator el ;
1250  for
1251  ( el = eventData_->electrons->begin() ;
1252  el != eventData_->electrons->end() ;
1253  el++ )
1254  {
1255  std::map<reco::GsfTrackRef,reco::GsfElectron::MvaInput>::const_iterator itcheck=mvaInputs.find((*el)->gsfTrack());
1256  (*el)->setMvaInput(itcheck->second);
1257  }
1258 }
1259 
1261  const std::map<reco::GsfTrackRef,reco::GsfElectron::MvaOutput> & mvaOutputs)
1262 {
1263  GsfElectronPtrCollection::iterator el ;
1264  for
1265  ( el = eventData_->electrons->begin() ;
1266  el != eventData_->electrons->end() ;
1267  el++ )
1268  {
1270  float mva_NIso_Value= hoc->sElectronMVAEstimator->mva( *(*el), *(eventData_->vertices));
1271  float mva_Iso_Value = hoc->iElectronMVAEstimator->mva( *(*el), eventData_->vertices->size() );
1272  GsfElectron::MvaOutput mvaOutput ;
1273  mvaOutput.mva_e_pi = mva_NIso_Value ;
1274  mvaOutput.mva_Isolated = mva_Iso_Value ;
1275  (*el)->setMvaOutput(mvaOutput);
1276  }
1277  else{
1278  std::map<reco::GsfTrackRef,reco::GsfElectron::MvaOutput>::const_iterator itcheck=mvaOutputs.find((*el)->gsfTrack());
1279  (*el)->setMvaOutput(itcheck->second);
1280  }
1281  }
1282 }
1283 
1285  {
1286  // eventually check ctf track
1289 
1290  // charge ID
1291  int eleCharge ;
1292  GsfElectron::ChargeInfo eleChargeInfo ;
1293  electronData_->computeCharge(eleCharge,eleChargeInfo) ;
1294 
1295  // electron basic cluster
1297 
1298  // Seed cluster
1299  const reco::CaloCluster & seedCluster = *(electronData_->superClusterRef->seed()) ;
1300 
1301  // seed Xtal
1302  // temporary, till CaloCluster->seed() is made available
1303  DetId seedXtalId = seedCluster.hitsAndFractions()[0].first ;
1304 
1306 
1307 
1308  //====================================================
1309  // Candidate attributes
1310  //====================================================
1311 
1313 
1314 
1315  //====================================================
1316  // Track-Cluster Matching
1317  //====================================================
1318 
1320  tcMatching.electronCluster = elbcRef ;
1321  tcMatching.eSuperClusterOverP = (electronData_->vtxMom.mag()>0)?(electronData_->superClusterRef->energy()/electronData_->vtxMom.mag()):(-1.) ;
1322  tcMatching.eSeedClusterOverP = (electronData_->vtxMom.mag()>0.)?(seedCluster.energy()/electronData_->vtxMom.mag()):(-1) ;
1323  tcMatching.eSeedClusterOverPout = (electronData_->seedMom.mag()>0.)?(seedCluster.energy()/electronData_->seedMom.mag()):(-1.) ;
1324  tcMatching.eEleClusterOverPout = (electronData_->eleMom.mag()>0.)?(elbcRef->energy()/electronData_->eleMom.mag()):(-1.) ;
1325 
1327  tcMatching.deltaEtaSuperClusterAtVtx = scAtVtx.dEta() ;
1328  tcMatching.deltaPhiSuperClusterAtVtx = scAtVtx.dPhi() ;
1329 
1330  EleRelPointPair seedAtCalo(seedCluster.position(),electronData_->seedPos,eventData_->beamspot->position()) ;
1331  tcMatching.deltaEtaSeedClusterAtCalo = seedAtCalo.dEta() ;
1332  tcMatching.deltaPhiSeedClusterAtCalo = seedAtCalo.dPhi() ;
1333 
1335  tcMatching.deltaEtaEleClusterAtCalo = ecAtCalo.dEta() ;
1336  tcMatching.deltaPhiEleClusterAtCalo = ecAtCalo.dPhi() ;
1337 
1338 
1339  //=======================================================
1340  // Track extrapolations
1341  //=======================================================
1342 
1351 
1352 
1353  //=======================================================
1354  // Closest Ctf Track
1355  //=======================================================
1356 
1358  ctfInfo.ctfTrack = electronData_->ctfTrackRef ;
1360 
1361 
1362  //====================================================
1363  // FiducialFlags, using nextToBoundary definition of gaps
1364  //====================================================
1365 
1366  reco::GsfElectron::FiducialFlags fiducialFlags ;
1367  int region = seedXtalId.det();
1368  int detector = seedXtalId.subdetId() ;
1369  double feta=std::abs(electronData_->superClusterRef->position().eta()) ;
1370  if (detector==EcalBarrel)
1371  {
1372  fiducialFlags.isEB = true ;
1373  EBDetId ebdetid(seedXtalId);
1374  if (EBDetId::isNextToEtaBoundary(ebdetid))
1375  {
1376  if (ebdetid.ietaAbs()==85)
1377  { fiducialFlags.isEBEEGap = true ; }
1378  else
1379  { fiducialFlags.isEBEtaGap = true ; }
1380  }
1381  if (EBDetId::isNextToPhiBoundary(ebdetid))
1382  { fiducialFlags.isEBPhiGap = true ; }
1383  }
1384  else if (detector==EcalEndcap)
1385  {
1386  fiducialFlags.isEE = true ;
1387  EEDetId eedetid(seedXtalId);
1388  if (EEDetId::isNextToRingBoundary(eedetid))
1389  {
1390  if (std::abs(feta)<2.)
1391  { fiducialFlags.isEBEEGap = true ; }
1392  else
1393  { fiducialFlags.isEERingGap = true ; }
1394  }
1395  if (EEDetId::isNextToDBoundary(eedetid))
1396  { fiducialFlags.isEEDeeGap = true ; }
1397  }
1398  else if ( region==DetId::Forward || region == DetId::Hcal )
1399  {
1400  fiducialFlags.isEE = true ;
1401  //HGCalDetId eeDetid(seedXtalId);
1402  // fill in fiducial information when we know how to use it...
1403  }
1404  else
1405  { throw cms::Exception("GsfElectronAlgo|UnknownXtalRegion")<<"createElectron(): do not know if it is a barrel or endcap seed cluster !!!!" ; }
1406 
1407 
1408  //====================================================
1409  // SaturationInfo
1410  //====================================================
1411 
1412  reco::GsfElectron::SaturationInfo saturationInfo;
1414 
1415  //====================================================
1416  // ShowerShape
1417  //====================================================
1418 
1419  reco::GsfElectron::ShowerShape showerShape;
1420  reco::GsfElectron::ShowerShape full5x5_showerShape;
1421  if( !(region==DetId::Forward || region == DetId::Hcal) ) {
1422  calculateShowerShape(electronData_->superClusterRef,!(electronData_->coreRef->ecalDrivenSeed()),showerShape) ;
1423  calculateShowerShape_full5x5(electronData_->superClusterRef,!(electronData_->coreRef->ecalDrivenSeed()),full5x5_showerShape) ;
1424  }
1425 
1426  //====================================================
1427  // ConversionRejection
1428  //====================================================
1429 
1431 
1432  ConversionFinder conversionFinder ;
1433  double BInTesla = eventSetupData_->magField->inTesla(GlobalPoint(0.,0.,0.)).z() ;
1435  if (!ctfTracks.isValid()) { ctfTracks = eventData_->currentCtfTracks ; }
1436 
1437  // values of conversionInfo.flag()
1438  // -9999 : Partner track was not found
1439  // 0 : Partner track found in the CTF collection using
1440  // 1 : Partner track found in the CTF collection using
1441  // 2 : Partner track found in the GSF collection using
1442  // 3 : Partner track found in the GSF collection using the electron's GSF track
1443  ConversionInfo conversionInfo = conversionFinder.getConversionInfo
1444  (*electronData_->coreRef,ctfTracks,eventData_->originalGsfTracks,BInTesla) ;
1445 
1447  conversionVars.flags = conversionInfo.flag() ;
1448  conversionVars.dist = conversionInfo.dist() ;
1449  conversionVars.dcot = conversionInfo.dcot() ;
1450  conversionVars.radius = conversionInfo.radiusOfConversion() ;
1451  if ((conversionVars.flags==0)or(conversionVars.flags==1))
1452  conversionVars.partner = TrackBaseRef(conversionInfo.conversionPartnerCtfTk()) ;
1453  else if ((conversionVars.flags==2)or(conversionVars.flags==3))
1454  conversionVars.partner = TrackBaseRef(conversionInfo.conversionPartnerGsfTk()) ;
1455 
1456 
1457  //====================================================
1458  // Go !
1459  //====================================================
1460 
1461  GsfElectron * ele = new
1462  GsfElectron
1463  ( eleCharge,eleChargeInfo,electronData_->coreRef,
1464  tcMatching, tkExtra, ctfInfo,
1465  fiducialFlags,showerShape, full5x5_showerShape,
1466  conversionVars, saturationInfo ) ;
1467  // Will be overwritten later in the case of the regression
1469  ele->setP4(GsfElectron::P4_FROM_SUPER_CLUSTER,momentum,0,true) ;
1470 
1471  //====================================================
1472  // brems fractions
1473  //====================================================
1474 
1475  if (electronData_->innMom.mag()>0.)
1477 
1478  // the supercluster is the refined one The seed is not necessarily the first cluster
1479  // hence the use of the electronCluster
1480  SuperClusterRef sc = ele->superCluster() ;
1481  if (!(sc.isNull()))
1482  {
1483  CaloClusterPtr cl = ele->electronCluster() ;
1484  if (sc->clustersSize()>1)
1485  {
1486  float pf_fbrem =( sc->energy() - cl->energy() ) / sc->energy();
1487  ele->setSuperClusterFbrem( pf_fbrem ) ;
1488  }
1489  else
1490  {
1491  ele->setSuperClusterFbrem(0) ;
1492  }
1493  }
1494 
1495  //====================================================
1496  // classification and corrections
1497  //====================================================
1498  // classification
1499  ElectronClassification theClassifier ;
1500  theClassifier.classify(*ele) ;
1501  theClassifier.refineWithPflow(*ele) ;
1502  // ecal energy
1505  {
1510  }
1511  else // original implementation
1512  {
1513  if( region!=DetId::Forward && region != DetId::Hcal ) {
1514  if (ele->core()->ecalDrivenSeed())
1515  {
1517  { theEnCorrector.classBasedParameterizationEnergy(*ele,*eventData_->beamspot) ; }
1519  { theEnCorrector.classBasedParameterizationUncertainty(*ele) ; }
1520  }
1521  else
1522  {
1524  { theEnCorrector.simpleParameterizationUncertainty(*ele) ; }
1525  }
1526  }
1527  }
1528 
1529  // momentum
1530  // Keep the default correction running first. The track momentum error is computed in there
1531  if (ele->core()->ecalDrivenSeed())
1532  {
1533  ElectronMomentumCorrector theMomCorrector;
1534  theMomCorrector.correct(*ele,electronData_->vtxTSOS);
1535  }
1537  {
1539  }
1540 
1541  //====================================================
1542  // now isolation variables
1543  //====================================================
1544 
1548  if( !(region==DetId::Forward || region == DetId::Hcal) ) {
1561  }
1562  ele->setIsolation03(dr03);
1563  ele->setIsolation04(dr04);
1564 
1565 
1566  //====================================================
1567  // preselection flag
1568  //====================================================
1569 
1571  //setting mva flag, currently GedGsfElectron and GsfElectron pre-selection flags have desynced
1572  //this is for GedGsfElectrons, GsfElectrons (ie old pre 7X std reco) resets this later on
1573  //in the function "addPfInfo"
1574  //yes this is awful, we'll fix it once we work out how to...
1575  float mvaValue = hoc->sElectronMVAEstimator->mva( *(ele),*(eventData_->vertices));
1577 
1578  //====================================================
1579  // Pixel match variables
1580  //====================================================
1582 
1583  LogTrace("GsfElectronAlgo")<<"Constructed new electron with energy "<< ele->p4().e() ;
1584 
1585  eventData_->electrons->push_back(ele) ;
1586  }
1587 
1588 
1589 //=======================================================================================
1590 // Ambiguity solving
1591 //=======================================================================================
1592 
1593 //bool better_electron( const reco::GsfElectron * e1, const reco::GsfElectron * e2 )
1594 // { return (std::abs(e1->eSuperClusterOverP()-1)<std::abs(e2->eSuperClusterOverP()-1)) ; }
1595 
1596 void GsfElectronAlgo::setAmbiguityData( bool ignoreNotPreselected )
1597  {
1598  GsfElectronPtrCollection::iterator e1, e2 ;
1603  else
1604  { throw cms::Exception("GsfElectronAlgo|UnknownAmbiguitySortingStrategy")<<"value of generalData_->strategyCfg.ambSortingStrategy is : "<<generalData_->strategyCfg.ambSortingStrategy ; }
1605 
1606  // init
1607  for
1608  ( e1 = eventData_->electrons->begin() ;
1609  e1 != eventData_->electrons->end() ;
1610  ++e1 )
1611  {
1612  (*e1)->clearAmbiguousGsfTracks() ;
1613  (*e1)->setAmbiguous(false) ;
1614  }
1615 
1616  // get ambiguous from GsfPfRecTracks
1618  {
1619  for
1620  ( e1 = eventData_->electrons->begin() ;
1621  e1 != eventData_->electrons->end() ;
1622  ++e1 )
1623  {
1624  bool found = false ;
1625  const GsfPFRecTrackCollection * gsfPfRecTrackCollection = eventData_->gsfPfRecTracks.product() ;
1626  GsfPFRecTrackCollection::const_iterator gsfPfRecTrack ;
1627  for ( gsfPfRecTrack=gsfPfRecTrackCollection->begin() ;
1628  gsfPfRecTrack!=gsfPfRecTrackCollection->end() ;
1629  ++gsfPfRecTrack )
1630  {
1631  if (gsfPfRecTrack->gsfTrackRef()==(*e1)->gsfTrack())
1632  {
1633  if (found)
1634  {
1635  edm::LogWarning("GsfElectronAlgo")<<"associated gsfPfRecTrack already found" ;
1636  }
1637  else
1638  {
1639  found = true ;
1640  const std::vector<reco::GsfPFRecTrackRef> & duplicates(gsfPfRecTrack->convBremGsfPFRecTrackRef()) ;
1641  std::vector<reco::GsfPFRecTrackRef>::const_iterator duplicate ;
1642  for ( duplicate = duplicates.begin() ; duplicate != duplicates.end() ; duplicate ++ )
1643  { (*e1)->addAmbiguousGsfTrack((*duplicate)->gsfTrackRef()) ; }
1644  }
1645  }
1646  }
1647  }
1648  }
1649  // or search overlapping clusters
1650  else
1651  {
1652  for
1653  ( e1 = eventData_->electrons->begin() ;
1654  e1 != eventData_->electrons->end() ;
1655  ++e1 )
1656  {
1657  if ((*e1)->ambiguous()) continue ;
1658  if ( ignoreNotPreselected && !isPreselected(*e1) ) continue ;
1659 
1660  SuperClusterRef scRef1 = (*e1)->superCluster();
1661  CaloClusterPtr eleClu1 = (*e1)->electronCluster();
1662  LogDebug("GsfElectronAlgo")
1663  << "Blessing electron with E/P " << (*e1)->eSuperClusterOverP()
1664  << ", cluster " << scRef1.get()
1665  << " & track " << (*e1)->gsfTrack().get() ;
1666 
1667  for
1668  ( e2 = e1, ++e2 ;
1669  e2 != eventData_->electrons->end() ;
1670  ++e2 )
1671  {
1672  if ((*e2)->ambiguous()) continue ;
1673  if ( ignoreNotPreselected && !isPreselected(*e2) ) continue ;
1674 
1675  SuperClusterRef scRef2 = (*e2)->superCluster();
1676  CaloClusterPtr eleClu2 = (*e2)->electronCluster();
1677 
1678  // search if same cluster
1679  bool sameCluster = false ;
1681  { sameCluster = (scRef1==scRef2) ; }
1683  {
1684  float eMin = 1. ;
1685  float threshold = eMin*cosh(EleRelPoint(scRef1->position(),eventData_->beamspot->position()).eta()) ;
1686  sameCluster =
1688  (EgAmbiguityTools::sharedEnergy(&(*scRef1->seed()),&(*eleClu2),eventData_->barrelRecHits,eventData_->endcapRecHits)>=threshold) ||
1690  (EgAmbiguityTools::sharedEnergy(&(*scRef1->seed()),&(*scRef2->seed()),eventData_->barrelRecHits,eventData_->endcapRecHits)>=threshold) ) ;
1691  }
1692  else
1693  { throw cms::Exception("GsfElectronAlgo|UnknownAmbiguityClustersOverlapStrategy")<<"value of generalData_->strategyCfg.ambClustersOverlapStrategy is : "<<generalData_->strategyCfg.ambClustersOverlapStrategy ; }
1694 
1695  // main instructions
1696  if (sameCluster)
1697  {
1698  LogDebug("GsfElectronAlgo")
1699  << "Discarding electron with E/P " << (*e2)->eSuperClusterOverP()
1700  << ", cluster " << scRef2.get()
1701  << " and track " << (*e2)->gsfTrack().get() ;
1702  (*e1)->addAmbiguousGsfTrack((*e2)->gsfTrack()) ;
1703  (*e2)->setAmbiguous(true) ;
1704  }
1705  else if ((*e1)->gsfTrack()==(*e2)->gsfTrack())
1706  {
1707  edm::LogWarning("GsfElectronAlgo")
1708  << "Forgetting electron with E/P " << (*e2)->eSuperClusterOverP()
1709  << ", cluster " << scRef2.get()
1710  << " and track " << (*e2)->gsfTrack().get() ;
1711  (*e2)->setAmbiguous(true) ;
1712  }
1713  }
1714  }
1715  }
1716  }
1717 
1719  {
1720  GsfElectronPtrCollection::size_type ei = 1, emax = eventData_->electrons->size() ;
1721  GsfElectronPtrCollection::iterator eitr = eventData_->electrons->begin() ;
1722  while (eitr!=eventData_->electrons->end())
1723  {
1724  LogTrace("GsfElectronAlgo")<<"========== remove ambiguous "<<ei<<"/"<<emax<<"==========" ;
1725  if ((*eitr)->ambiguous())
1726  { delete (*eitr) ; eitr = eventData_->electrons->erase(eitr) ; ++ei ; }
1727  else
1728  { ++eitr ; ++ei ; }
1729  }
1730  }
1731 
1732 
1733 // Pixel match variables
1735  int sd1 = 0 ;
1736  int sd2 = 0 ;
1737  float dPhi1 = 0 ;
1738  float dPhi2 = 0 ;
1739  float dRz1 = 0 ;
1740  float dRz2 = 0 ;
1741  edm::RefToBase<TrajectorySeed> seed = ele->gsfTrack()->extra()->seedRef();
1742  ElectronSeedRef elseed = seed.castTo<ElectronSeedRef>();
1743  if(seed.isNull()){}
1744  else{
1745  if(elseed.isNull()){}
1746  else{
1747  sd1 = elseed->subDet1() ;
1748  sd2 = elseed->subDet2() ;
1749  dPhi1 = (ele->charge()>0) ? elseed->dPhi1Pos() : elseed->dPhi1() ;
1750  dPhi2 = (ele->charge()>0) ? elseed->dPhi2Pos() : elseed->dPhi2() ;
1751  dRz1 = (ele->charge()>0) ? elseed->dRz1Pos () : elseed->dRz1 () ;
1752  dRz2 = (ele->charge()>0) ? elseed->dRz2Pos () : elseed->dRz2 () ;
1753  }
1754  }
1755  ele->setPixelMatchSubdetectors(sd1,sd2) ;
1756  ele->setPixelMatchDPhi1(dPhi1) ;
1757  ele->setPixelMatchDPhi2(dPhi2) ;
1758  ele->setPixelMatchDRz1 (dRz1 ) ;
1759  ele->setPixelMatchDRz2 (dRz2 ) ;
1760 }
#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
virtual double pt() const final
transverse momentum
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:753
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:706
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
bool positionFromModeCartesian(const TrajectoryStateOnSurface tsos, GlobalPoint &position) const
void setPixelMatchDRz2(float dRz2)
Definition: GsfElectron.h:881
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:878
bool isEBEEGap() const
Definition: GsfElectron.h:355
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
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
std::vector< CaloTowerDetId > hcalTowersBehindClusters(const reco::SuperCluster &sc)
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:195
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:698
bool passingMvaPreselection() const
Definition: GsfElectron.h:714
edm::EDGetTokenT< EcalRecHitCollection > endcapRecHitCollection
void computeCharge(int &charge, reco::GsfElectron::ChargeInfo &info)
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
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:258
bool isEB() const
Definition: GsfElectron.h:352
TrajectoryStateOnSurface outerStateOnSurface(const reco::GsfTrack &tk) const
void setPixelMatchSubdetectors(int sd1, int sd2)
Definition: GsfElectron.h:877
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:754
EgammaRecHitIsolation * ecalBarrelIsol04
TrajectoryStateOnSurface constrainedVtxTSOS
const RegressionHelper::Configuration regCfg
T barePhi() const
Definition: PV3DBase.h:68
EgammaTowerIsolation * hadDepth2Isolation03
EgammaTowerIsolation * hadDepth1Isolation04
virtual int charge() const final
electric charge
Definition: LeafCandidate.h:91
edm::EDGetTokenT< reco::BeamSpot > beamSpotTag
ElectronTkIsolation * tkIsolation03
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
virtual SuperClusterRef superCluster() const
reference to a SuperCluster
Definition: GsfElectron.h:184
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:713
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
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:244
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:37
bool isNull() const
Checks for null.
Definition: Ref.h:249
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:879
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)
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:56
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:672
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
double getPtTracks(const reco::GsfElectron *) const
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
double getTowerEtSum(const reco::Candidate *cand, const std::vector< CaloTowerDetId > *detIdToExclude=0) const
edm::ESHandle< CaloGeometry > caloGeom
EcalClusterFunctionBaseClass * crackCorrectionFunction
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:707
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 &)
ElectronTkIsolation * tkIsolation04
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:35
float sumChargedHadronPt
sum-pt of charged Hadron // old float chargedHadronIso ;
Definition: GsfElectron.h:625
virtual void init(const edm::EventSetup &es)=0
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:880
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)
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
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
virtual GsfTrackRef gsfTrack() const
reference to a GsfTrack
Definition: GsfElectron.h:185
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:699
const reco::BeamSpot beamSpot