CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GsfElectronAlgo.cc
Go to the documentation of this file.
1 
9 
12 
25 
29 
32 
33 
35 
38 
39 
42 
43 
44 #include <Math/Point3D.h>
45 #include <sstream>
46 #include <algorithm>
47 
48 
49 using namespace edm ;
50 using namespace std ;
51 using namespace reco ;
52 
53 
54 //===================================================================
55 // GsfElectronAlgo::GeneralData
56 //===================================================================
57 
58 // general data and helpers
60  {
61  // constructors
63  ( const InputTagsConfiguration &,
64  const StrategyConfiguration &,
65  const CutsConfiguration & cutsCfg,
66  const CutsConfiguration & cutsCfgPflow,
67  const ElectronHcalHelper::Configuration & hcalCfg,
68  const ElectronHcalHelper::Configuration & hcalCfgPflow,
69  const IsolationConfiguration &,
71  EcalClusterFunctionBaseClass * superClusterErrorFunction,
72  EcalClusterFunctionBaseClass * crackCorrectionFunction,
73  const SoftElectronMVAEstimator::Configuration & mva_NIso_Cfg ,
74  const ElectronMVAEstimator::Configuration & mva_Iso_Cfg ,
76  ~GeneralData() ;
77 
78  // configurables
85 
86  // additional configuration and helpers
90  //SoftElectronMVAEstimator *sElectronMVAEstimator;
91  //ElectronMVAEstimator *iElectronMVAEstimator;
94  } ;
95 
97  ( const InputTagsConfiguration & inputConfig,
98  const StrategyConfiguration & strategyConfig,
99  const CutsConfiguration & cutsConfig,
100  const CutsConfiguration & cutsConfigPflow,
101  const ElectronHcalHelper::Configuration & hcalConfig,
102  const ElectronHcalHelper::Configuration & hcalConfigPflow,
103  const IsolationConfiguration & isoConfig,
104  const EcalRecHitsConfiguration & recHitsConfig,
105  EcalClusterFunctionBaseClass * superClusterErrorFunc,
106  EcalClusterFunctionBaseClass * crackCorrectionFunc,
107  const SoftElectronMVAEstimator::Configuration & /*mva_NIso_Config*/,
108  const ElectronMVAEstimator::Configuration & /*mva_Iso_Config*/,
109  const RegressionHelper::Configuration & regConfig
110  )
111  : inputCfg(inputConfig),
112  strategyCfg(strategyConfig),
113  cutsCfg(cutsConfig),
114  cutsCfgPflow(cutsConfigPflow),
115  isoCfg(isoConfig),
116  recHitsCfg(recHitsConfig),
117  hcalHelper(new ElectronHcalHelper(hcalConfig)),
118  hcalHelperPflow(new ElectronHcalHelper(hcalConfigPflow)),
119  superClusterErrorFunction(superClusterErrorFunc),
120  crackCorrectionFunction(crackCorrectionFunc),
121  //sElectronMVAEstimator(new SoftElectronMVAEstimator(mva_NIso_Config)),
122  //iElectronMVAEstimator(new ElectronMVAEstimator(mva_Iso_Config)),
123  regCfg(regConfig),
124  regHelper(new RegressionHelper(regConfig))
125  {}
126 
128  {
129  delete hcalHelper ;
130  delete hcalHelperPflow ;
131  //delete sElectronMVAEstimator;
132  //delete iElectronMVAEstimator;
133  delete regHelper;
134  }
135 
136 //===================================================================
137 // GsfElectronAlgo::EventSetupData
138 //===================================================================
139 
141  {
142  EventSetupData() ;
143  ~EventSetupData() ;
144 
145  unsigned long long cacheIDGeom ;
146  unsigned long long cacheIDTopo ;
147  unsigned long long cacheIDTDGeom ;
148  unsigned long long cacheIDMagField ;
149  //unsigned long long cacheChStatus ;
150  unsigned long long cacheSevLevel ;
151 
156  //edm::ESHandle<EcalChannelStatus> chStatus ;
158 
162 } ;
163 
165  : cacheIDGeom(0), cacheIDTopo(0), cacheIDTDGeom(0), cacheIDMagField(0),/*cacheChStatus(0),*/
166  cacheSevLevel(0), mtsTransform(0), constraintAtVtx(0), mtsMode(new MultiTrajectoryStateMode)
167  {}
168 
170  {
171  delete mtsMode ;
172  delete constraintAtVtx ;
173  delete mtsTransform ;
174  }
175 
176 
177 //===================================================================
178 // GsfElectronAlgo::EventData
179 //===================================================================
180 
182  {
183  // general
187 
188  EventData() ;
189  ~EventData() ;
190 
191  // utilities
192  void retreiveOriginalTrackCollections
193  ( const reco::TrackRef &, const reco::GsfTrackRef & ) ;
194 
195  // input collections
211 
212  // isolation helpers
213  ElectronTkIsolation * tkIsolation03, * tkIsolation04 ;
214  EgammaTowerIsolation * hadDepth1Isolation03, * hadDepth1Isolation04 ;
215  EgammaTowerIsolation * hadDepth2Isolation03, * hadDepth2Isolation04 ;
216  EgammaTowerIsolation * hadDepth1Isolation03Bc, * hadDepth1Isolation04Bc ;
217  EgammaTowerIsolation * hadDepth2Isolation03Bc, * hadDepth2Isolation04Bc ;
218  EgammaRecHitIsolation * ecalBarrelIsol03, * ecalBarrelIsol04 ;
219  EgammaRecHitIsolation * ecalEndcapIsol03, * ecalEndcapIsol04 ;
220 
221  //Isolation Value Maps for PF and EcalDriven electrons
222  typedef std::vector< edm::Handle< edm::ValueMap<double> > > IsolationValueMaps;
225  } ;
226 
228  : event(0), beamspot(0),
229  originalCtfTrackCollectionRetreived(false),
230  originalGsfTrackCollectionRetreived(false),
231  tkIsolation03(0), tkIsolation04(0),
232  hadDepth1Isolation03(0), hadDepth1Isolation04(0),
233  hadDepth2Isolation03(0), hadDepth2Isolation04(0),
234  hadDepth1Isolation03Bc(0), hadDepth1Isolation04Bc(0),
235  hadDepth2Isolation03Bc(0), hadDepth2Isolation04Bc(0),
236  ecalBarrelIsol03(0), ecalBarrelIsol04(0),
237  ecalEndcapIsol03(0), ecalEndcapIsol04(0)
238  {
240  }
241 
243  {
244  delete tkIsolation03 ;
245  delete tkIsolation04 ;
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) ;
271  originalCtfTrackCollectionRetreived = true ;
272  }
273  if ((!originalGsfTrackCollectionRetreived)&&(gsfTrack.isNonnull()))
274  {
275  event->get(gsfTrack.id(),originalGsfTracks) ;
276  originalGsfTrackCollectionRetreived = true ;
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
302  void checkCtfTrack( edm::Handle<reco::TrackCollection> currentCtfTracks ) ;
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 
325  ( const reco::GsfElectronCoreRef & core,
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.phi()-inntkvect.phi()) ;
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 
541  reco::GsfElectron::ShowerShape & showerShape )
542  {
543  const reco::CaloCluster & seedCluster = *(theClus->seed()) ;
544  // temporary, till CaloCluster->seed() is made available
545  DetId seedXtalId = seedCluster.hitsAndFractions()[0].first ;
546  int detector = seedXtalId.subdetId() ;
547 
550  const EcalRecHitCollection * recHits = 0 ;
551  std::vector<int> recHitFlagsToBeExcluded ;
552  std::vector<int> recHitSeverityToBeExcluded ;
553  if (detector==EcalBarrel)
554  {
555  recHits = eventData_->barrelRecHits.product() ;
556  recHitFlagsToBeExcluded = generalData_->recHitsCfg.recHitFlagsToBeExcludedBarrel ;
557  recHitSeverityToBeExcluded = generalData_->recHitsCfg.recHitSeverityToBeExcludedBarrel ;
558  }
559  else
560  {
561  recHits = eventData_->endcapRecHits.product() ;
562  recHitFlagsToBeExcluded = generalData_->recHitsCfg.recHitFlagsToBeExcludedEndcaps ;
563  recHitSeverityToBeExcluded = generalData_->recHitsCfg.recHitSeverityToBeExcludedEndcaps ;
564  }
565 
566  std::vector<float> covariances = EcalClusterTools::covariances(seedCluster,recHits,topology,geometry) ;
567  std::vector<float> localCovariances = EcalClusterTools::localCovariances(seedCluster,recHits,topology) ;
568  showerShape.sigmaEtaEta = sqrt(covariances[0]) ;
569  showerShape.sigmaIetaIeta = sqrt(localCovariances[0]) ;
570  if (!edm::isNotFinite(localCovariances[2])) showerShape.sigmaIphiIphi = sqrt(localCovariances[2]) ;
571  showerShape.e1x5 = EcalClusterTools::e1x5(seedCluster,recHits,topology) ;
572  showerShape.e2x5Max = EcalClusterTools::e2x5Max(seedCluster,recHits,topology) ;
573  showerShape.e5x5 = EcalClusterTools::e5x5(seedCluster,recHits,topology) ;
574  showerShape.r9 = EcalClusterTools::e3x3(seedCluster,recHits,topology)/theClus->rawEnergy() ;
575 
576  if (pflow)
577  {
578  showerShape.hcalDepth1OverEcal = generalData_->hcalHelperPflow->hcalESumDepth1(*theClus)/theClus->energy() ;
579  showerShape.hcalDepth2OverEcal = generalData_->hcalHelperPflow->hcalESumDepth2(*theClus)/theClus->energy() ;
583  }
584  else
585  {
586  showerShape.hcalDepth1OverEcal = generalData_->hcalHelper->hcalESumDepth1(*theClus)/theClus->energy() ;
587  showerShape.hcalDepth2OverEcal = generalData_->hcalHelper->hcalESumDepth2(*theClus)/theClus->energy() ;
591  }
592 
593  // extra shower shapes
594  const float see_by_spp = showerShape.sigmaIetaIeta*showerShape.sigmaIphiIphi;
595  if( see_by_spp > 0 ) {
596  showerShape.sigmaIetaIphi = localCovariances[1] / see_by_spp;
597  } else if ( localCovariances[1] > 0 ) {
598  showerShape.sigmaIetaIphi = 1.f;
599  } else {
600  showerShape.sigmaIetaIphi = -1.f;
601  }
602  showerShape.eMax = EcalClusterTools::eMax(seedCluster,recHits);
603  showerShape.e2nd = EcalClusterTools::e2nd(seedCluster,recHits);
604  showerShape.eTop = EcalClusterTools::eTop(seedCluster,recHits,topology);
605  showerShape.eLeft = EcalClusterTools::eLeft(seedCluster,recHits,topology);
606  showerShape.eRight = EcalClusterTools::eRight(seedCluster,recHits,topology);
607  showerShape.eBottom = EcalClusterTools::eBottom(seedCluster,recHits,topology);
608  }
609 
611  reco::GsfElectron::ShowerShape & showerShape )
612  {
613  const reco::CaloCluster & seedCluster = *(theClus->seed()) ;
614  // temporary, till CaloCluster->seed() is made available
615  DetId seedXtalId = seedCluster.hitsAndFractions()[0].first ;
616  int detector = seedXtalId.subdetId() ;
617 
620  const EcalRecHitCollection * recHits = 0 ;
621  std::vector<int> recHitFlagsToBeExcluded ;
622  std::vector<int> recHitSeverityToBeExcluded ;
623  if (detector==EcalBarrel)
624  {
625  recHits = eventData_->barrelRecHits.product() ;
626  recHitFlagsToBeExcluded = generalData_->recHitsCfg.recHitFlagsToBeExcludedBarrel ;
627  recHitSeverityToBeExcluded = generalData_->recHitsCfg.recHitSeverityToBeExcludedBarrel ;
628  }
629  else
630  {
631  recHits = eventData_->endcapRecHits.product() ;
632  recHitFlagsToBeExcluded = generalData_->recHitsCfg.recHitFlagsToBeExcludedEndcaps ;
633  recHitSeverityToBeExcluded = generalData_->recHitsCfg.recHitSeverityToBeExcludedEndcaps ;
634  }
635 
636  std::vector<float> covariances = noZS::EcalClusterTools::covariances(seedCluster,recHits,topology,geometry) ;
637  std::vector<float> localCovariances = noZS::EcalClusterTools::localCovariances(seedCluster,recHits,topology) ;
638  showerShape.sigmaEtaEta = sqrt(covariances[0]) ;
639  showerShape.sigmaIetaIeta = sqrt(localCovariances[0]) ;
640  if (!edm::isNotFinite(localCovariances[2])) showerShape.sigmaIphiIphi = sqrt(localCovariances[2]) ;
641  showerShape.e1x5 = noZS::EcalClusterTools::e1x5(seedCluster,recHits,topology) ;
642  showerShape.e2x5Max = noZS::EcalClusterTools::e2x5Max(seedCluster,recHits,topology) ;
643  showerShape.e5x5 = noZS::EcalClusterTools::e5x5(seedCluster,recHits,topology) ;
644  showerShape.r9 = noZS::EcalClusterTools::e3x3(seedCluster,recHits,topology)/theClus->rawEnergy() ;
645 
646  if (pflow)
647  {
648  showerShape.hcalDepth1OverEcal = generalData_->hcalHelperPflow->hcalESumDepth1(*theClus)/theClus->energy() ;
649  showerShape.hcalDepth2OverEcal = generalData_->hcalHelperPflow->hcalESumDepth2(*theClus)/theClus->energy() ;
653  }
654  else
655  {
656  showerShape.hcalDepth1OverEcal = generalData_->hcalHelper->hcalESumDepth1(*theClus)/theClus->energy() ;
657  showerShape.hcalDepth2OverEcal = generalData_->hcalHelper->hcalESumDepth2(*theClus)/theClus->energy() ;
661  }
662 
663  // extra shower shapes
664  const float see_by_spp = showerShape.sigmaIetaIeta*showerShape.sigmaIphiIphi;
665  if( see_by_spp > 0 ) {
666  showerShape.sigmaIetaIphi = localCovariances[1] / see_by_spp;
667  } else if ( localCovariances[1] > 0 ) {
668  showerShape.sigmaIetaIphi = 1.f;
669  } else {
670  showerShape.sigmaIetaIphi = -1.f;
671  }
672  showerShape.eMax = noZS::EcalClusterTools::eMax(seedCluster,recHits);
673  showerShape.e2nd = noZS::EcalClusterTools::e2nd(seedCluster,recHits);
674  showerShape.eTop = noZS::EcalClusterTools::eTop(seedCluster,recHits,topology);
675  showerShape.eLeft = noZS::EcalClusterTools::eLeft(seedCluster,recHits,topology);
676  showerShape.eRight = noZS::EcalClusterTools::eRight(seedCluster,recHits,topology);
677  showerShape.eBottom = noZS::EcalClusterTools::eBottom(seedCluster,recHits,topology);
678  }
679 
680 
681 //===================================================================
682 // GsfElectronAlgo
683 //===================================================================
684 
686  ( const InputTagsConfiguration & inputCfg,
687  const StrategyConfiguration & strategyCfg,
688  const CutsConfiguration & cutsCfg,
689  const CutsConfiguration & cutsCfgPflow,
690  const ElectronHcalHelper::Configuration & hcalCfg,
691  const ElectronHcalHelper::Configuration & hcalCfgPflow,
692  const IsolationConfiguration & isoCfg,
693  const EcalRecHitsConfiguration & recHitsCfg,
694  EcalClusterFunctionBaseClass * superClusterErrorFunction,
695  EcalClusterFunctionBaseClass * crackCorrectionFunction,
696  const SoftElectronMVAEstimator::Configuration & mva_NIso_Cfg,
697  const ElectronMVAEstimator::Configuration & mva_Iso_Cfg,
698  const RegressionHelper::Configuration & regCfg
699  )
700  : generalData_(new GeneralData(inputCfg,strategyCfg,cutsCfg,cutsCfgPflow,hcalCfg,hcalCfgPflow,isoCfg,recHitsCfg,superClusterErrorFunction,crackCorrectionFunction,mva_NIso_Cfg,mva_Iso_Cfg,regCfg)),
703  {}
704 
706  {
707  delete generalData_ ;
708  delete eventSetupData_ ;
709  delete eventData_ ;
710  delete electronData_ ;
711  }
712 
714  {
715  // get EventSetupRecords if needed
716  bool updateField(false);
718  updateField = true;
721  }
722 
723  bool updateGeometry(false);
725  updateGeometry = true;
728  }
729 
730  if ( updateField || updateGeometry ) {
731  delete eventSetupData_->mtsTransform ;
735  }
736 
738  eventSetupData_->cacheIDGeom=es.get<CaloGeometryRecord>().cacheIdentifier();
740  }
741 
743  eventSetupData_->cacheIDTopo=es.get<CaloTopologyRecord>().cacheIdentifier();
745  }
746 
751 
752 
757 
758  //if(eventSetupData_->cacheChStatus!=es.get<EcalChannelStatusRcd>().cacheIdentifier()){
759  // eventSetupData_->cacheChStatus=es.get<EcalChannelStatusRcd>().cacheIdentifier();
760  // es.get<EcalChannelStatusRcd>().get(eventSetupData_->chStatus);
761  //}
762 
764  eventSetupData_->cacheSevLevel = es.get<EcalSeverityLevelAlgoRcd>().cacheIdentifier();
766  }
767  }
768 
769 
771  {
772  GsfElectronPtrCollection::const_iterator it ;
773  for
774  ( it = eventData_->electrons->begin() ;
775  it != eventData_->electrons->end() ;
776  it++ )
777  { outEle.push_back(**it) ; }
778  }
779 
781  {
782  if (eventData_!=0)
783  { throw cms::Exception("GsfElectronAlgo|InternalError")<<"unexpected event data" ; }
784  eventData_ = new EventData ;
785 
786  // init the handles linked to the current event
787  eventData_->event = &event ;
794  event.getByToken(generalData_->inputCfg.hcalTowersTag,eventData_->towers) ;
795  event.getByToken(generalData_->inputCfg.pfMVA,eventData_->pfMva) ;
796  event.getByToken(generalData_->inputCfg.seedsTag,eventData_->seeds) ;
800 
801  // get the beamspot from the Event:
802  edm::Handle<reco::BeamSpot> recoBeamSpotHandle ;
803  event.getByToken(generalData_->inputCfg.beamSpotTag,recoBeamSpotHandle) ;
804  eventData_->beamspot = recoBeamSpotHandle.product() ;
805 
806  // prepare access to hcal data
809 
810  // Isolation algos
811  float extRadiusSmall=0.3, extRadiusLarge=0.4 ;
812  float intRadiusBarrel=generalData_->isoCfg.intRadiusBarrelTk, intRadiusEndcap=generalData_->isoCfg.intRadiusEndcapTk, stripBarrel=generalData_->isoCfg.stripBarrelTk, stripEndcap=generalData_->isoCfg.stripEndcapTk ;
814  eventData_->tkIsolation03 = new ElectronTkIsolation(extRadiusSmall,intRadiusBarrel,intRadiusEndcap,stripBarrel,stripEndcap,ptMin,maxVtxDist,drb,eventData_->currentCtfTracks.product(),eventData_->beamspot->position()) ;
815  eventData_->tkIsolation04 = new ElectronTkIsolation(extRadiusLarge,intRadiusBarrel,intRadiusEndcap,stripBarrel,stripEndcap,ptMin,maxVtxDist,drb,eventData_->currentCtfTracks.product(),eventData_->beamspot->position()) ;
816 
817  float egHcalIsoConeSizeOutSmall=0.3, egHcalIsoConeSizeOutLarge=0.4;
818  float egHcalIsoConeSizeIn=generalData_->isoCfg.intRadiusHcal,egHcalIsoPtMin=generalData_->isoCfg.etMinHcal;
819  int egHcalDepth1=1, egHcalDepth2=2;
820  eventData_->hadDepth1Isolation03 = new EgammaTowerIsolation(egHcalIsoConeSizeOutSmall,egHcalIsoConeSizeIn,egHcalIsoPtMin,egHcalDepth1,eventData_->towers.product()) ;
821  eventData_->hadDepth2Isolation03 = new EgammaTowerIsolation(egHcalIsoConeSizeOutSmall,egHcalIsoConeSizeIn,egHcalIsoPtMin,egHcalDepth2,eventData_->towers.product()) ;
822  eventData_->hadDepth1Isolation04 = new EgammaTowerIsolation(egHcalIsoConeSizeOutLarge,egHcalIsoConeSizeIn,egHcalIsoPtMin,egHcalDepth1,eventData_->towers.product()) ;
823  eventData_->hadDepth2Isolation04 = new EgammaTowerIsolation(egHcalIsoConeSizeOutLarge,egHcalIsoConeSizeIn,egHcalIsoPtMin,egHcalDepth2,eventData_->towers.product()) ;
824  eventData_->hadDepth1Isolation03Bc = new EgammaTowerIsolation(egHcalIsoConeSizeOutSmall,0.,egHcalIsoPtMin,egHcalDepth1,eventData_->towers.product()) ;
825  eventData_->hadDepth2Isolation03Bc = new EgammaTowerIsolation(egHcalIsoConeSizeOutSmall,0.,egHcalIsoPtMin,egHcalDepth2,eventData_->towers.product()) ;
826  eventData_->hadDepth1Isolation04Bc = new EgammaTowerIsolation(egHcalIsoConeSizeOutLarge,0.,egHcalIsoPtMin,egHcalDepth1,eventData_->towers.product()) ;
827  eventData_->hadDepth2Isolation04Bc = new EgammaTowerIsolation(egHcalIsoConeSizeOutLarge,0.,egHcalIsoPtMin,egHcalDepth2,eventData_->towers.product()) ;
828 
829  float egIsoConeSizeOutSmall=0.3, egIsoConeSizeOutLarge=0.4, egIsoJurassicWidth=generalData_->isoCfg.jurassicWidth;
830  float egIsoPtMinBarrel=generalData_->isoCfg.etMinBarrel,egIsoEMinBarrel=generalData_->isoCfg.eMinBarrel, egIsoConeSizeInBarrel=generalData_->isoCfg.intRadiusEcalBarrel;
831  float egIsoPtMinEndcap=generalData_->isoCfg.etMinEndcaps,egIsoEMinEndcap=generalData_->isoCfg.eMinEndcaps, egIsoConeSizeInEndcap=generalData_->isoCfg.intRadiusEcalEndcaps;
832  eventData_->ecalBarrelIsol03 = new EgammaRecHitIsolation(egIsoConeSizeOutSmall,egIsoConeSizeInBarrel,egIsoJurassicWidth,egIsoPtMinBarrel,egIsoEMinBarrel,eventSetupData_->caloGeom,*(eventData_->barrelRecHits),eventSetupData_->sevLevel.product(),DetId::Ecal);
833  eventData_->ecalBarrelIsol04 = new EgammaRecHitIsolation(egIsoConeSizeOutLarge,egIsoConeSizeInBarrel,egIsoJurassicWidth,egIsoPtMinBarrel,egIsoEMinBarrel,eventSetupData_->caloGeom,*(eventData_->barrelRecHits),eventSetupData_->sevLevel.product(),DetId::Ecal);
834  eventData_->ecalEndcapIsol03 = new EgammaRecHitIsolation(egIsoConeSizeOutSmall,egIsoConeSizeInEndcap,egIsoJurassicWidth,egIsoPtMinEndcap,egIsoEMinEndcap,eventSetupData_->caloGeom,*(eventData_->endcapRecHits),eventSetupData_->sevLevel.product(),DetId::Ecal);
835  eventData_->ecalEndcapIsol04 = new EgammaRecHitIsolation(egIsoConeSizeOutLarge,egIsoConeSizeInEndcap,egIsoJurassicWidth,egIsoPtMinEndcap,egIsoEMinEndcap,eventSetupData_->caloGeom,*(eventData_->endcapRecHits),eventSetupData_->sevLevel.product(),DetId::Ecal);
852 
853  //Fill in the Isolation Value Maps for PF and EcalDriven electrons
854  std::vector<edm::InputTag> inputTagIsoVals;
856  inputTagIsoVals.push_back(generalData_->inputCfg.pfIsoVals.getParameter<edm::InputTag>("pfSumChargedHadronPt"));
857  inputTagIsoVals.push_back(generalData_->inputCfg.pfIsoVals.getParameter<edm::InputTag>("pfSumPhotonEt"));
858  inputTagIsoVals.push_back(generalData_->inputCfg.pfIsoVals.getParameter<edm::InputTag>("pfSumNeutralHadronEt"));
859 
860  eventData_->pfIsolationValues.resize(inputTagIsoVals.size());
861 
862  for (size_t j = 0; j<inputTagIsoVals.size(); ++j) {
863  event.getByLabel(inputTagIsoVals[j], eventData_->pfIsolationValues[j]);
864  }
865 
866  }
867 
869  inputTagIsoVals.clear();
870  inputTagIsoVals.push_back(generalData_->inputCfg.edIsoVals.getParameter<edm::InputTag>("edSumChargedHadronPt"));
871  inputTagIsoVals.push_back(generalData_->inputCfg.edIsoVals.getParameter<edm::InputTag>("edSumPhotonEt"));
872  inputTagIsoVals.push_back(generalData_->inputCfg.edIsoVals.getParameter<edm::InputTag>("edSumNeutralHadronEt"));
873 
874  eventData_->edIsolationValues.resize(inputTagIsoVals.size());
875 
876  for (size_t j = 0; j<inputTagIsoVals.size(); ++j) {
877  event.getByLabel(inputTagIsoVals[j], eventData_->edIsolationValues[j]);
878  }
879  }
880  }
881 
883  {
884  if (eventData_==0)
885  { throw cms::Exception("GsfElectronAlgo|InternalError")<<"lacking event data" ; }
886  delete eventData_ ;
887  eventData_ = 0 ;
888  }
889 
891  {
892  LogTrace("GsfElectronAlgo") << "========== " << title << " ==========";
893  LogTrace("GsfElectronAlgo") << "Event: " << eventData_->event->id();
894  LogTrace("GsfElectronAlgo") << "Number of electrons: " << eventData_->electrons->size() ;
895  GsfElectronPtrCollection::const_iterator it ;
896  for ( it = eventData_->electrons->begin(); it != eventData_->electrons->end(); it++ )
897  {
898  LogTrace("GsfElectronAlgo") << "Electron with charge, pt, eta, phi: " << (*it)->charge() << " , "
899  << (*it)->pt() << " , " << (*it)->eta() << " , " << (*it)->phi();
900  }
901  LogTrace("GsfElectronAlgo") << "=================================================";
902  }
903 
905  {
906  if (electronData_!=0)
907  { throw cms::Exception("GsfElectronAlgo|InternalError")<<"unexpected electron data" ; }
908 
909  const GsfElectronCoreCollection * coreCollection = eventData_->coreElectrons.product() ;
910  for ( unsigned int i=0 ; i<coreCollection->size() ; ++i )
911  {
912  // check there is no existing electron with this core
914  bool coreFound = false ;
915  GsfElectronPtrCollection::const_iterator itrEle ;
916  for
917  ( itrEle = eventData_->electrons->begin() ;
918  itrEle != eventData_->electrons->end() ;
919  itrEle++ )
920  {
921  if ((*itrEle)->core()==coreRef)
922  {
923  coreFound = true ;
924  break ;
925  }
926  }
927  if (coreFound) continue ;
928 
929  // check there is a super-cluster
930  if (coreRef->superCluster().isNull()) continue ;
931 
932  // prepare internal structure for electron specific data
933  delete electronData_ ;
934  electronData_ = new ElectronData(coreRef,*eventData_->beamspot) ;
935 
936  // calculate and check Trajectory StatesOnSurface....
938 
939  createElectron(hoc) ;
940 
941  } // loop over tracks
942 
943  delete electronData_ ;
944  electronData_ = 0 ;
945  }
946 
948  {
949  const GsfElectronCollection * oldElectrons = eventData_->previousElectrons.product() ;
951  GsfElectronCollection::const_iterator oldElectron ;
952  for
953  ( oldElectron = oldElectrons->begin() ;
954  oldElectron != oldElectrons->end() ;
955  ++oldElectron )
956  {
957  const GsfElectronCoreRef oldCoreRef = oldElectron->core() ;
958  const GsfTrackRef oldElectronGsfTrackRef = oldCoreRef->gsfTrack() ;
959  unsigned int icore ;
960  for ( icore=0 ; icore<newCores->size() ; ++icore )
961  {
962  if (oldElectronGsfTrackRef==(*newCores)[icore].gsfTrack())
963  {
965  eventData_->electrons->push_back(new GsfElectron(*oldElectron,coreRef)) ;
966  break ;
967  }
968  }
969  }
970  }
971 
972 
973 // now deprecated
975  {
976  bool found ;
977  const GsfElectronCollection * edElectrons = eventData_->previousElectrons.product() ;
979  GsfElectronCollection::const_iterator pfElectron, edElectron ;
980  unsigned int edIndex, pfIndex ;
981 
982  GsfElectronPtrCollection::iterator el ;
983  for
984  ( el = eventData_->electrons->begin() ;
985  el != eventData_->electrons->end() ;
986  el++ )
987  {
988 
989  // Retreive info from pflow electrons
990  found = false ;
991  for
992  ( pfIndex = 0, pfElectron = pfElectrons->begin() ; pfElectron != pfElectrons->end() ; pfIndex++, pfElectron++ )
993  {
994  if (pfElectron->gsfTrack()==(*el)->gsfTrack())
995  {
996  if (found)
997  {
998  edm::LogWarning("GsfElectronProducer")<<"associated pfGsfElectron already found" ;
999  }
1000  else
1001  {
1002  found = true ;
1003 
1004  // Isolation Values
1005  if( (eventData_->pfIsolationValues).size() != 0 )
1006  {
1008  pfElectronRef(eventData_->pflowElectrons, pfIndex);
1010  isoVariables.sumChargedHadronPt =(*(eventData_->pfIsolationValues)[0])[pfElectronRef];
1011  isoVariables.sumPhotonEt =(*(eventData_->pfIsolationValues)[1])[pfElectronRef];
1012  isoVariables.sumNeutralHadronEt =(*(eventData_->pfIsolationValues)[2])[pfElectronRef];
1013  (*el)->setPfIsolationVariables(isoVariables);
1014  }
1015 
1016 // (*el)->setPfIsolationVariables(pfElectron->pfIsolationVariables()) ;
1017  (*el)->setMvaInput(pfElectron->mvaInput()) ;
1018  (*el)->setMvaOutput(pfElectron->mvaOutput()) ;
1019  if ((*el)->ecalDrivenSeed())
1020  { (*el)->setP4(GsfElectron::P4_PFLOW_COMBINATION,pfElectron->p4(GsfElectron::P4_PFLOW_COMBINATION),pfElectron->p4Error(GsfElectron::P4_PFLOW_COMBINATION),false) ; }
1021  else
1022  { (*el)->setP4(GsfElectron::P4_PFLOW_COMBINATION,pfElectron->p4(GsfElectron::P4_PFLOW_COMBINATION),pfElectron->p4Error(GsfElectron::P4_PFLOW_COMBINATION),true) ; }
1023  double noCutMin = -999999999. ;
1024  if ((*el)->mva_e_pi()<noCutMin) { throw cms::Exception("GsfElectronAlgo|UnexpectedMvaValue")<<"unexpected MVA value: "<<(*el)->mva_e_pi() ; }
1025  }
1026  }
1027  }
1028 
1029  // Isolation Values
1030  // Retreive not found info from ed electrons
1031  if( (eventData_->edIsolationValues).size() != 0 )
1032  {
1033  edIndex = 0, edElectron = edElectrons->begin() ;
1034  while ((found == false)&&(edElectron != edElectrons->end()))
1035  {
1036  if (edElectron->gsfTrack()==(*el)->gsfTrack())
1037  {
1038  found = true ;
1039 
1040  // CONSTRUCTION D UNE REF dans le handle eventData_->previousElectrons avec l'indice edIndex,
1041  // puis recuperation dans la ValueMap ED
1042 
1044  edElectronRef(eventData_->previousElectrons, edIndex);
1046  isoVariables.sumChargedHadronPt =(*(eventData_->edIsolationValues)[0])[edElectronRef];
1047  isoVariables.sumPhotonEt =(*(eventData_->edIsolationValues)[1])[edElectronRef];
1048  isoVariables.sumNeutralHadronEt =(*(eventData_->edIsolationValues)[2])[edElectronRef];
1049  (*el)->setPfIsolationVariables(isoVariables);
1050  }
1051 
1052  edIndex++ ;
1053  edElectron++ ;
1054  }
1055  }
1056 
1057  // Preselection
1059 
1060  }
1061  }
1062 
1064  {
1065  bool passCutBased=ele->passingCutBasedPreselection();
1066  bool passPF=ele->passingPflowPreselection(); //it is worth nothing for gedGsfElectrons, this does nothing as its not set till GedGsfElectron finaliser, this is always false
1068  bool passmva=ele->passingMvaPreselection();
1069  if(!ele->ecalDrivenSeed()){
1071  return passmva && passCutBased;
1072  else
1073  return passmva;
1074  }
1075  else{
1076  return passCutBased || passPF || passmva;
1077  }
1078  }
1079  else{
1080  return passCutBased || passPF;
1081  }
1082 
1083  return true;
1084  }
1085 
1087  {
1088  GsfElectronPtrCollection::size_type ei = 1, emax = eventData_->electrons->size() ;
1089  GsfElectronPtrCollection::iterator eitr = eventData_->electrons->begin() ;
1090  while (eitr!=eventData_->electrons->end())
1091  {
1092  LogTrace("GsfElectronAlgo")<<"========== removed not preselected "<<ei<<"/"<<emax<<"==========" ;
1093  if (isPreselected(*eitr))
1094  { ++eitr ; ++ei ; }
1095  else
1096  { delete (*eitr) ; eitr = eventData_->electrons->erase(eitr) ; ++ei ; }
1097  }
1098  }
1099 
1100 
1102  {
1103  // default value
1104  ele->setPassCutBasedPreselection(false) ;
1105 
1106  // kind of seeding
1107  bool eg = ele->core()->ecalDrivenSeed() ;
1108  bool pf = ele->core()->trackerDrivenSeed() && !ele->core()->ecalDrivenSeed() ;
1109  bool gedMode = generalData_->strategyCfg.gedElectronMode;
1110  if (eg&&pf) { throw cms::Exception("GsfElectronAlgo|BothEcalAndPureTrackerDriven")<<"An electron cannot be both egamma and purely pflow" ; }
1111  if ((!eg)&&(!pf)) { throw cms::Exception("GsfElectronAlgo|NeitherEcalNorPureTrackerDriven")<<"An electron cannot be neither egamma nor purely pflow" ; }
1112 
1113  const CutsConfiguration * cfg = ((eg||gedMode)?&generalData_->cutsCfg:&generalData_->cutsCfgPflow);
1114 
1115  // Et cut
1116  double etaValue = EleRelPoint(ele->superCluster()->position(),bs.position()).eta() ;
1117  double etValue = ele->superCluster()->energy()/cosh(etaValue) ;
1118  LogTrace("GsfElectronAlgo") << "Et : " << etValue ;
1119  if (ele->isEB() && (etValue < cfg->minSCEtBarrel)) return ;
1120  if (ele->isEE() && (etValue < cfg->minSCEtEndcaps)) return ;
1121  LogTrace("GsfElectronAlgo") << "Et criteria are satisfied";
1122 
1123  // E/p cut
1124  double eopValue = ele->eSuperClusterOverP() ;
1125  LogTrace("GsfElectronAlgo") << "E/p : " << eopValue ;
1126  if (ele->isEB() && (eopValue > cfg->maxEOverPBarrel)) return ;
1127  if (ele->isEE() && (eopValue > cfg->maxEOverPEndcaps)) return ;
1128  if (ele->isEB() && (eopValue < cfg->minEOverPBarrel)) return ;
1129  if (ele->isEE() && (eopValue < cfg->minEOverPEndcaps)) return ;
1130  LogTrace("GsfElectronAlgo") << "E/p criteria are satisfied";
1131 
1132  // HoE cuts
1133  LogTrace("GsfElectronAlgo") << "HoE1 : " << ele->hcalDepth1OverEcal() << ", HoE2 : " << ele->hcalDepth2OverEcal();
1134  double had = ele->hcalOverEcal()*ele->superCluster()->energy() ;
1135  const reco::CaloCluster & seedCluster = *(ele->superCluster()->seed()) ;
1136  int detector = seedCluster.hitsAndFractions()[0].first.subdetId() ;
1137  bool HoEveto = false ;
1138  if (detector==EcalBarrel && (had<cfg->maxHBarrel || (had/ele->superCluster()->energy())<cfg->maxHOverEBarrel)) HoEveto=true;
1139  else if (detector==EcalEndcap && (had<cfg->maxHEndcaps || (had/ele->superCluster()->energy())<cfg->maxHOverEEndcaps)) HoEveto=true;
1140  if ( !HoEveto ) return ;
1141  LogTrace("GsfElectronAlgo") << "H/E criteria are satisfied";
1142 
1143  // delta eta criteria
1144  double deta = ele->deltaEtaSuperClusterTrackAtVtx() ;
1145  LogTrace("GsfElectronAlgo") << "delta eta : " << deta ;
1146  if (ele->isEB() && (std::abs(deta) > cfg->maxDeltaEtaBarrel)) return ;
1147  if (ele->isEE() && (std::abs(deta) > cfg->maxDeltaEtaEndcaps)) return ;
1148  LogTrace("GsfElectronAlgo") << "Delta eta criteria are satisfied";
1149 
1150  // delta phi criteria
1151  double dphi = ele->deltaPhiSuperClusterTrackAtVtx();
1152  LogTrace("GsfElectronAlgo") << "delta phi : " << dphi;
1153  if (ele->isEB() && (std::abs(dphi) > cfg->maxDeltaPhiBarrel)) return ;
1154  if (ele->isEE() && (std::abs(dphi) > cfg->maxDeltaPhiEndcaps)) return ;
1155  LogTrace("GsfElectronAlgo") << "Delta phi criteria are satisfied";
1156 
1157  // sigma ieta ieta
1158  LogTrace("GsfElectronAlgo") << "sigma ieta ieta : " << ele->sigmaIetaIeta();
1159  if (ele->isEB() && (ele->sigmaIetaIeta() > cfg->maxSigmaIetaIetaBarrel)) return ;
1160  if (ele->isEE() && (ele->sigmaIetaIeta() > cfg->maxSigmaIetaIetaEndcaps)) return ;
1161  LogTrace("GsfElectronAlgo") << "Sigma ieta ieta criteria are satisfied";
1162 
1163  // fiducial
1164  if (!ele->isEB() && cfg->isBarrel) return ;
1165  if (!ele->isEE() && cfg->isEndcaps) return ;
1166  if (cfg->isFiducial && (ele->isEBEEGap()||ele->isEBEtaGap()||ele->isEBPhiGap()||ele->isEERingGap()||ele->isEEDeeGap())) return ;
1167  LogTrace("GsfElectronAlgo") << "Fiducial flags criteria are satisfied";
1168 
1169  // seed in TEC
1170  edm::RefToBase<TrajectorySeed> seed = ele->gsfTrack()->extra()->seedRef() ;
1171  ElectronSeedRef elseed = seed.castTo<ElectronSeedRef>() ;
1172  if (eg && !generalData_->cutsCfg.seedFromTEC)
1173  {
1174  if (elseed.isNull())
1175  { throw cms::Exception("GsfElectronAlgo|NotElectronSeed")<<"The GsfTrack seed is not an ElectronSeed ?!" ; }
1176  else
1177  { if (elseed->subDet2()==6) return ; }
1178  }
1179 
1180  // transverse impact parameter
1181  if (std::abs(ele->gsfTrack()->dxy(bs.position()))>cfg->maxTIP) return ;
1182  LogTrace("GsfElectronAlgo") << "TIP criterion is satisfied" ;
1183 
1184  LogTrace("GsfElectronAlgo") << "All cut based criteria are satisfied" ;
1185  ele->setPassCutBasedPreselection(true) ;
1186  }
1187 
1189  {
1190  ele->setPassMvaPreselection(false) ;
1191 
1192  if (ele->core()->ecalDrivenSeed())
1193  { if (ele->mvaOutput().mva_e_pi>=generalData_->cutsCfg.minMVA) ele->setPassMvaPreselection(true) ; }
1194  else
1196 
1197  if (ele->passingMvaPreselection())
1198  { LogTrace("GsfElectronAlgo") << "Main mva criterion is satisfied" ; }
1199 
1201 
1202  }
1203 
1204 void GsfElectronAlgo::setMVAInputs(const std::map<reco::GsfTrackRef,reco::GsfElectron::MvaInput> & mvaInputs)
1205 {
1206  GsfElectronPtrCollection::iterator el ;
1207  for
1208  ( el = eventData_->electrons->begin() ;
1209  el != eventData_->electrons->end() ;
1210  el++ )
1211  {
1212  std::map<reco::GsfTrackRef,reco::GsfElectron::MvaInput>::const_iterator itcheck=mvaInputs.find((*el)->gsfTrack());
1213  (*el)->setMvaInput(itcheck->second);
1214  }
1215 }
1216 
1218  const std::map<reco::GsfTrackRef,reco::GsfElectron::MvaOutput> & mvaOutputs)
1219 {
1220  GsfElectronPtrCollection::iterator el ;
1221  for
1222  ( el = eventData_->electrons->begin() ;
1223  el != eventData_->electrons->end() ;
1224  el++ )
1225  {
1227  float mva_NIso_Value= hoc->sElectronMVAEstimator->mva( *(*el), *(eventData_->vertices));
1228  float mva_Iso_Value = hoc->iElectronMVAEstimator->mva( *(*el), eventData_->vertices->size() );
1229  GsfElectron::MvaOutput mvaOutput ;
1230  mvaOutput.mva_e_pi = mva_NIso_Value ;
1231  mvaOutput.mva_Isolated = mva_Iso_Value ;
1232  (*el)->setMvaOutput(mvaOutput);
1233  }
1234  else{
1235  std::map<reco::GsfTrackRef,reco::GsfElectron::MvaOutput>::const_iterator itcheck=mvaOutputs.find((*el)->gsfTrack());
1236  (*el)->setMvaOutput(itcheck->second);
1237  }
1238  }
1239 }
1240 
1242  {
1243  // eventually check ctf track
1246 
1247  // charge ID
1248  int eleCharge ;
1249  GsfElectron::ChargeInfo eleChargeInfo ;
1250  electronData_->computeCharge(eleCharge,eleChargeInfo) ;
1251 
1252  // electron basic cluster
1254 
1255  // Seed cluster
1256  const reco::CaloCluster & seedCluster = *(electronData_->superClusterRef->seed()) ;
1257 
1258  // seed Xtal
1259  // temporary, till CaloCluster->seed() is made available
1260  DetId seedXtalId = seedCluster.hitsAndFractions()[0].first ;
1261 
1263 
1264 
1265  //====================================================
1266  // Candidate attributes
1267  //====================================================
1268 
1270 
1271 
1272  //====================================================
1273  // Track-Cluster Matching
1274  //====================================================
1275 
1277  tcMatching.electronCluster = elbcRef ;
1278  tcMatching.eSuperClusterOverP = (electronData_->vtxMom.mag()>0)?(electronData_->superClusterRef->energy()/electronData_->vtxMom.mag()):(-1.) ;
1279  tcMatching.eSeedClusterOverP = (electronData_->vtxMom.mag()>0.)?(seedCluster.energy()/electronData_->vtxMom.mag()):(-1) ;
1280  tcMatching.eSeedClusterOverPout = (electronData_->seedMom.mag()>0.)?(seedCluster.energy()/electronData_->seedMom.mag()):(-1.) ;
1281  tcMatching.eEleClusterOverPout = (electronData_->eleMom.mag()>0.)?(elbcRef->energy()/electronData_->eleMom.mag()):(-1.) ;
1282 
1284  tcMatching.deltaEtaSuperClusterAtVtx = scAtVtx.dEta() ;
1285  tcMatching.deltaPhiSuperClusterAtVtx = scAtVtx.dPhi() ;
1286 
1287  EleRelPointPair seedAtCalo(seedCluster.position(),electronData_->seedPos,eventData_->beamspot->position()) ;
1288  tcMatching.deltaEtaSeedClusterAtCalo = seedAtCalo.dEta() ;
1289  tcMatching.deltaPhiSeedClusterAtCalo = seedAtCalo.dPhi() ;
1290 
1291  EleRelPointPair ecAtCalo(elbcRef->position(),electronData_->elePos,eventData_->beamspot->position()) ;
1292  tcMatching.deltaEtaEleClusterAtCalo = ecAtCalo.dEta() ;
1293  tcMatching.deltaPhiEleClusterAtCalo = ecAtCalo.dPhi() ;
1294 
1295 
1296  //=======================================================
1297  // Track extrapolations
1298  //=======================================================
1299 
1308 
1309 
1310  //=======================================================
1311  // Closest Ctf Track
1312  //=======================================================
1313 
1315  ctfInfo.ctfTrack = electronData_->ctfTrackRef ;
1317 
1318 
1319  //====================================================
1320  // FiducialFlags, using nextToBoundary definition of gaps
1321  //====================================================
1322 
1323  reco::GsfElectron::FiducialFlags fiducialFlags ;
1324  int detector = seedXtalId.subdetId() ;
1325  double feta=std::abs(electronData_->superClusterRef->position().eta()) ;
1326  if (detector==EcalBarrel)
1327  {
1328  fiducialFlags.isEB = true ;
1329  EBDetId ebdetid(seedXtalId);
1330  if (EBDetId::isNextToEtaBoundary(ebdetid))
1331  {
1332  if (ebdetid.ietaAbs()==85)
1333  { fiducialFlags.isEBEEGap = true ; }
1334  else
1335  { fiducialFlags.isEBEtaGap = true ; }
1336  }
1337  if (EBDetId::isNextToPhiBoundary(ebdetid))
1338  { fiducialFlags.isEBPhiGap = true ; }
1339  }
1340  else if (detector==EcalEndcap)
1341  {
1342  fiducialFlags.isEE = true ;
1343  EEDetId eedetid(seedXtalId);
1344  if (EEDetId::isNextToRingBoundary(eedetid))
1345  {
1346  if (std::abs(feta)<2.)
1347  { fiducialFlags.isEBEEGap = true ; }
1348  else
1349  { fiducialFlags.isEERingGap = true ; }
1350  }
1351  if (EEDetId::isNextToDBoundary(eedetid))
1352  { fiducialFlags.isEEDeeGap = true ; }
1353  }
1354  else
1355  { throw cms::Exception("GsfElectronAlgo|UnknownXtalRegion")<<"createElectron(): do not know if it is a barrel or endcap seed cluster !!!!" ; }
1356 
1357 
1358  //====================================================
1359  // ShowerShape
1360  //====================================================
1361 
1362  reco::GsfElectron::ShowerShape showerShape ;
1363  calculateShowerShape(electronData_->superClusterRef,!(electronData_->coreRef->ecalDrivenSeed()),showerShape) ;
1364 
1365  reco::GsfElectron::ShowerShape full5x5_showerShape ;
1366  calculateShowerShape_full5x5(electronData_->superClusterRef,!(electronData_->coreRef->ecalDrivenSeed()),full5x5_showerShape) ;
1367 
1368  //====================================================
1369  // ConversionRejection
1370  //====================================================
1371 
1373 
1374  ConversionFinder conversionFinder ;
1375  double BInTesla = eventSetupData_->magField->inTesla(GlobalPoint(0.,0.,0.)).z() ;
1377  if (!ctfTracks.isValid()) { ctfTracks = eventData_->currentCtfTracks ; }
1378 
1379  // values of conversionInfo.flag()
1380  // -9999 : Partner track was not found
1381  // 0 : Partner track found in the CTF collection using
1382  // 1 : Partner track found in the CTF collection using
1383  // 2 : Partner track found in the GSF collection using
1384  // 3 : Partner track found in the GSF collection using the electron's GSF track
1385  ConversionInfo conversionInfo = conversionFinder.getConversionInfo
1386  (*electronData_->coreRef,ctfTracks,eventData_->originalGsfTracks,BInTesla) ;
1387 
1389  conversionVars.flags = conversionInfo.flag() ;
1390  conversionVars.dist = conversionInfo.dist() ;
1391  conversionVars.dcot = conversionInfo.dcot() ;
1392  conversionVars.radius = conversionInfo.radiusOfConversion() ;
1393  if ((conversionVars.flags==0)or(conversionVars.flags==1))
1394  conversionVars.partner = TrackBaseRef(conversionInfo.conversionPartnerCtfTk()) ;
1395  else if ((conversionVars.flags==2)or(conversionVars.flags==3))
1396  conversionVars.partner = TrackBaseRef(conversionInfo.conversionPartnerGsfTk()) ;
1397 
1398 
1399  //====================================================
1400  // Go !
1401  //====================================================
1402 
1403  GsfElectron * ele = new
1404  GsfElectron
1405  ( eleCharge,eleChargeInfo,electronData_->coreRef,
1406  tcMatching, tkExtra, ctfInfo,
1407  fiducialFlags,showerShape, full5x5_showerShape,
1408  conversionVars ) ;
1409  // Will be overwritten later in the case of the regression
1411  ele->setP4(GsfElectron::P4_FROM_SUPER_CLUSTER,momentum,0,true) ;
1412 
1413  //====================================================
1414  // brems fractions
1415  //====================================================
1416 
1417  if (electronData_->innMom.mag()>0.)
1419 
1420  // the supercluster is the refined one The seed is not necessarily the first cluster
1421  // hence the use of the electronCluster
1422  SuperClusterRef sc = ele->superCluster() ;
1423  if (!(sc.isNull()))
1424  {
1425  CaloClusterPtr cl = ele->electronCluster() ;
1426  if (sc->clustersSize()>1)
1427  {
1428  float pf_fbrem =( sc->energy() - cl->energy() ) / sc->energy();
1429  ele->setSuperClusterFbrem( pf_fbrem ) ;
1430  }
1431  else
1432  {
1433  ele->setSuperClusterFbrem(0) ;
1434  }
1435  }
1436 
1437  //====================================================
1438  // classification and corrections
1439  //====================================================
1440  // classification
1441  ElectronClassification theClassifier ;
1442  theClassifier.classify(*ele) ;
1443  theClassifier.refineWithPflow(*ele) ;
1444  // ecal energy
1447  {
1452  }
1453  else // original implementation
1454  {
1455  if (ele->core()->ecalDrivenSeed())
1456  {
1458  { theEnCorrector.classBasedParameterizationEnergy(*ele,*eventData_->beamspot) ; }
1460  { theEnCorrector.classBasedParameterizationUncertainty(*ele) ; }
1461  }
1462  else
1463  {
1465  { theEnCorrector.simpleParameterizationUncertainty(*ele) ; }
1466  }
1467  }
1468 
1469  // momentum
1470  // Keep the default correction running first. The track momentum error is computed in there
1471  if (ele->core()->ecalDrivenSeed())
1472  {
1473  ElectronMomentumCorrector theMomCorrector;
1474  theMomCorrector.correct(*ele,electronData_->vtxTSOS);
1475  }
1477  {
1479  }
1480 
1481  //====================================================
1482  // now isolation variables
1483  //====================================================
1484 
1498  ele->setIsolation03(dr03);
1499  ele->setIsolation04(dr04);
1500 
1501 
1502  //====================================================
1503  // preselection flag
1504  //====================================================
1505 
1507  //setting mva flag, currently GedGsfElectron and GsfElectron pre-selection flags have desynced
1508  //this is for GedGsfElectrons, GsfElectrons (ie old pre 7X std reco) resets this later on
1509  //in the function "addPfInfo"
1510  //yes this is awful, we'll fix it once we work out how to...
1511  float mvaValue = hoc->sElectronMVAEstimator->mva( *(ele),*(eventData_->vertices));
1513 
1514  //====================================================
1515  // Pixel match variables
1516  //====================================================
1518 
1519  LogTrace("GsfElectronAlgo")<<"Constructed new electron with energy "<< ele->p4().e() ;
1520 
1521  eventData_->electrons->push_back(ele) ;
1522  }
1523 
1524 
1525 //=======================================================================================
1526 // Ambiguity solving
1527 //=======================================================================================
1528 
1529 //bool better_electron( const reco::GsfElectron * e1, const reco::GsfElectron * e2 )
1530 // { return (std::abs(e1->eSuperClusterOverP()-1)<std::abs(e2->eSuperClusterOverP()-1)) ; }
1531 
1532 void GsfElectronAlgo::setAmbiguityData( bool ignoreNotPreselected )
1533  {
1534  GsfElectronPtrCollection::iterator e1, e2 ;
1539  else
1540  { throw cms::Exception("GsfElectronAlgo|UnknownAmbiguitySortingStrategy")<<"value of generalData_->strategyCfg.ambSortingStrategy is : "<<generalData_->strategyCfg.ambSortingStrategy ; }
1541 
1542  // init
1543  for
1544  ( e1 = eventData_->electrons->begin() ;
1545  e1 != eventData_->electrons->end() ;
1546  ++e1 )
1547  {
1548  (*e1)->clearAmbiguousGsfTracks() ;
1549  (*e1)->setAmbiguous(false) ;
1550  }
1551 
1552  // get ambiguous from GsfPfRecTracks
1554  {
1555  for
1556  ( e1 = eventData_->electrons->begin() ;
1557  e1 != eventData_->electrons->end() ;
1558  ++e1 )
1559  {
1560  bool found = false ;
1561  const GsfPFRecTrackCollection * gsfPfRecTrackCollection = eventData_->gsfPfRecTracks.product() ;
1562  GsfPFRecTrackCollection::const_iterator gsfPfRecTrack ;
1563  for ( gsfPfRecTrack=gsfPfRecTrackCollection->begin() ;
1564  gsfPfRecTrack!=gsfPfRecTrackCollection->end() ;
1565  ++gsfPfRecTrack )
1566  {
1567  if (gsfPfRecTrack->gsfTrackRef()==(*e1)->gsfTrack())
1568  {
1569  if (found)
1570  {
1571  edm::LogWarning("GsfElectronAlgo")<<"associated gsfPfRecTrack already found" ;
1572  }
1573  else
1574  {
1575  found = true ;
1576  const std::vector<reco::GsfPFRecTrackRef> & duplicates(gsfPfRecTrack->convBremGsfPFRecTrackRef()) ;
1577  std::vector<reco::GsfPFRecTrackRef>::const_iterator duplicate ;
1578  for ( duplicate = duplicates.begin() ; duplicate != duplicates.end() ; duplicate ++ )
1579  { (*e1)->addAmbiguousGsfTrack((*duplicate)->gsfTrackRef()) ; }
1580  }
1581  }
1582  }
1583  }
1584  }
1585  // or search overlapping clusters
1586  else
1587  {
1588  for
1589  ( e1 = eventData_->electrons->begin() ;
1590  e1 != eventData_->electrons->end() ;
1591  ++e1 )
1592  {
1593  if ((*e1)->ambiguous()) continue ;
1594  if ( ignoreNotPreselected && !isPreselected(*e1) ) continue ;
1595 
1596  SuperClusterRef scRef1 = (*e1)->superCluster();
1597  CaloClusterPtr eleClu1 = (*e1)->electronCluster();
1598  LogDebug("GsfElectronAlgo")
1599  << "Blessing electron with E/P " << (*e1)->eSuperClusterOverP()
1600  << ", cluster " << scRef1.get()
1601  << " & track " << (*e1)->gsfTrack().get() ;
1602 
1603  for
1604  ( e2 = e1, ++e2 ;
1605  e2 != eventData_->electrons->end() ;
1606  ++e2 )
1607  {
1608  if ((*e2)->ambiguous()) continue ;
1609  if ( ignoreNotPreselected && !isPreselected(*e2) ) continue ;
1610 
1611  SuperClusterRef scRef2 = (*e2)->superCluster();
1612  CaloClusterPtr eleClu2 = (*e2)->electronCluster();
1613 
1614  // search if same cluster
1615  bool sameCluster = false ;
1617  { sameCluster = (scRef1==scRef2) ; }
1619  {
1620  float eMin = 1. ;
1621  float threshold = eMin*cosh(EleRelPoint(scRef1->position(),eventData_->beamspot->position()).eta()) ;
1622  sameCluster =
1624  (EgAmbiguityTools::sharedEnergy(&(*scRef1->seed()),&(*eleClu2),eventData_->barrelRecHits,eventData_->endcapRecHits)>=threshold) ||
1626  (EgAmbiguityTools::sharedEnergy(&(*scRef1->seed()),&(*scRef2->seed()),eventData_->barrelRecHits,eventData_->endcapRecHits)>=threshold) ) ;
1627  }
1628  else
1629  { throw cms::Exception("GsfElectronAlgo|UnknownAmbiguityClustersOverlapStrategy")<<"value of generalData_->strategyCfg.ambClustersOverlapStrategy is : "<<generalData_->strategyCfg.ambClustersOverlapStrategy ; }
1630 
1631  // main instructions
1632  if (sameCluster)
1633  {
1634  LogDebug("GsfElectronAlgo")
1635  << "Discarding electron with E/P " << (*e2)->eSuperClusterOverP()
1636  << ", cluster " << scRef2.get()
1637  << " and track " << (*e2)->gsfTrack().get() ;
1638  (*e1)->addAmbiguousGsfTrack((*e2)->gsfTrack()) ;
1639  (*e2)->setAmbiguous(true) ;
1640  }
1641  else if ((*e1)->gsfTrack()==(*e2)->gsfTrack())
1642  {
1643  edm::LogWarning("GsfElectronAlgo")
1644  << "Forgetting electron with E/P " << (*e2)->eSuperClusterOverP()
1645  << ", cluster " << scRef2.get()
1646  << " and track " << (*e2)->gsfTrack().get() ;
1647  (*e2)->setAmbiguous(true) ;
1648  }
1649  }
1650  }
1651  }
1652  }
1653 
1655  {
1656  GsfElectronPtrCollection::size_type ei = 1, emax = eventData_->electrons->size() ;
1657  GsfElectronPtrCollection::iterator eitr = eventData_->electrons->begin() ;
1658  while (eitr!=eventData_->electrons->end())
1659  {
1660  LogTrace("GsfElectronAlgo")<<"========== remove ambiguous "<<ei<<"/"<<emax<<"==========" ;
1661  if ((*eitr)->ambiguous())
1662  { delete (*eitr) ; eitr = eventData_->electrons->erase(eitr) ; ++ei ; }
1663  else
1664  { ++eitr ; ++ei ; }
1665  }
1666  }
1667 
1668 
1669 // Pixel match variables
1671  int sd1 = 0 ;
1672  int sd2 = 0 ;
1673  float dPhi1 = 0 ;
1674  float dPhi2 = 0 ;
1675  float dRz1 = 0 ;
1676  float dRz2 = 0 ;
1677  edm::RefToBase<TrajectorySeed> seed = ele->gsfTrack()->extra()->seedRef();
1678  ElectronSeedRef elseed = seed.castTo<ElectronSeedRef>();
1679  if(seed.isNull()){}
1680  else{
1681  if(elseed.isNull()){}
1682  else{
1683  sd1 = elseed->subDet1() ;
1684  sd2 = elseed->subDet2() ;
1685  dPhi1 = (ele->charge()>0) ? elseed->dPhi1Pos() : elseed->dPhi1() ;
1686  dPhi2 = (ele->charge()>0) ? elseed->dPhi2Pos() : elseed->dPhi2() ;
1687  dRz1 = (ele->charge()>0) ? elseed->dRz1Pos () : elseed->dRz1 () ;
1688  dRz2 = (ele->charge()>0) ? elseed->dRz2Pos () : elseed->dRz2 () ;
1689  }
1690  }
1691  ele->setPixelMatchSubdetectors(sd1,sd2) ;
1692  ele->setPixelMatchDPhi1(dPhi1) ;
1693  ele->setPixelMatchDPhi2(dPhi2) ;
1694  ele->setPixelMatchDRz1 (dRz1 ) ;
1695  ele->setPixelMatchDRz2 (dRz2 ) ;
1696 }
#define LogDebug(id)
TrajectoryStateOnSurface constrainAtBeamSpot(const reco::GsfTrack &, const reco::BeamSpot &) const
(multi)TSOS after including the beamspot
CaloClusterPtr electronCluster() const
Definition: GsfElectron.h:242
ElectronHcalHelper * hcalHelperPflow
void setPixelMatchInfomation(reco::GsfElectron *)
edm::Handle< reco::TrackCollection > originalCtfTracks
T getParameter(std::string const &) const
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:126
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:701
int i
Definition: DBlmapReader.cc:9
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:197
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:654
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
bool positionFromModeCartesian(const TrajectoryStateOnSurface tsos, GlobalPoint &position) const
tuple cfg
Definition: looper.py:293
void setPixelMatchDRz2(float dRz2)
Definition: GsfElectron.h:829
edm::EDGetTokenT< reco::GsfElectronCoreCollection > gsfElectronCores
bool isEBEtaGap() const
Definition: GsfElectron.h:355
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:223
float eSuperClusterOverP() const
Definition: GsfElectron.h:243
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::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
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:826
bool isEBEEGap() const
Definition: GsfElectron.h:353
float hcalDepth2OverEcal() const
Definition: GsfElectron.h:423
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 &)
TrajectoryStateOnSurface sclTSOS
const EcalRecHitsConfiguration recHitsCfg
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
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:192
void checkSetup(const edm::EventSetup &)
void setMVAInputs(const std::map< reco::GsfTrackRef, reco::GsfElectron::MvaInput > &mvaInputs)
bool isEERingGap() const
Definition: GsfElectron.h:359
bool passingCutBasedPreselection() const
Definition: GsfElectron.h:646
bool passingMvaPreselection() const
Definition: GsfElectron.h:662
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:358
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
EgammaTowerIsolation * hadDepth1Isolation03
edm::EDGetTokenT< reco::GsfElectronCollection > pflowGsfElectronsTag
const StrategyConfiguration strategyCfg
bool isEE() const
Definition: GsfElectron.h:351
ProductID id() const
Accessor for product ID.
Definition: Ref.h:258
bool isEB() const
Definition: GsfElectron.h:350
TrajectoryStateOnSurface outerStateOnSurface(const reco::GsfTrack &tk) const
void setPixelMatchSubdetectors(int sd1, int sd2)
Definition: GsfElectron.h:825
edm::EDGetTokenT< EcalRecHitCollection > barrelRecHitCollection
edm::ESHandle< CaloTopology > caloTopo
void doFlagChecks(const std::vector< int > &v)
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:702
EgammaRecHitIsolation * ecalBarrelIsol04
TrajectoryStateOnSurface constrainedVtxTSOS
virtual float getValue(const reco::BasicCluster &, const EcalRecHitCollection &) const =0
const RegressionHelper::Configuration regCfg
EgammaTowerIsolation * hadDepth2Isolation03
EgammaTowerIsolation * hadDepth1Isolation04
edm::EDGetTokenT< reco::BeamSpot > beamSpotTag
ElectronTkIsolation * tkIsolation03
void setUseNumCrystals(bool b=true)
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:247
void setCorrectedEcalEnergyError(float newEnergyError)
Definition: GsfElectron.cc:177
T mag() const
Definition: PV3DBase.h:67
float sigmaIetaIeta() const
Definition: GsfElectron.h:416
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 &)
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
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:182
GsfConstraintAtVertex * constraintAtVtx
static bool isNextToPhiBoundary(EBDetId id)
Definition: EBDetId.cc:130
float sumPhotonEt
sum pt of PF photons // old float photonIso ;
Definition: GsfElectron.h:575
edm::Handle< EcalRecHitCollection > barrelRecHits
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:250
std::vector< GsfElectronCore > GsfElectronCoreCollection
void correct(reco::GsfElectron &, TrajectoryStateOnSurface &)
virtual int charge() const final
electric charge
Definition: LeafCandidate.h:91
static float e2nd(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
float hcalOverEcal() const
Definition: GsfElectron.h:424
void setPassMvaPreselection(bool flag)
Definition: GsfElectron.h:661
IsolationValueMaps pfIsolationValues
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< CaloTowerDetId > hcalTowersBehindClusters
Definition: GsfElectron.h:386
const MultiTrajectoryStateTransform * mtsTransform
int j
Definition: DBlmapReader.cc:9
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:121
const CutsConfiguration cutsCfg
ElectronHcalHelper * hcalHelper
float sumNeutralHadronEt
sum pt of neutral hadrons // old float neutralHadronIso ;
Definition: GsfElectron.h:574
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
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
edm::EDGetTokenT< edm::ValueMap< float > > pfMVA
bool isValid() const
Definition: HandleBase.h:75
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:518
#define LogTrace(id)
void doSeverityChecks(const EcalRecHitCollection *const recHits, const std::vector< int > &v)
edm::EDGetTokenT< CaloTowerCollection > hcalTowersTag
void classify(reco::GsfElectron &)
EgammaTowerIsolation * hadDepth2Isolation04Bc
edm::EDGetTokenT< reco::TrackCollection > ctfTracks
edm::Handle< reco::GsfElectronCollection > previousElectrons
float hcalDepth1OverEcal() const
Definition: GsfElectron.h:422
void setPixelMatchDPhi2(float dPhi2)
Definition: GsfElectron.h:827
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
int flag() const
T const * product() const
Definition: Handle.h:81
EcalClusterFunctionBaseClass * superClusterErrorFunction
REF castTo() const
Definition: RefToBase.h:271
bool isNull() const
Checks for null.
Definition: RefToBase.h:313
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:620
T const * product() const
Definition: ESHandle.h:86
const reco::GsfTrackRef gsfTrackRef
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:283
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:517
ESHandle< TrackerGeometry > geometry
edm::EventID id() const
Definition: EventBase.h:59
edm::Handle< reco::GsfTrackCollection > originalGsfTracks
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:356
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:655
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
volatile std::atomic< bool > shutdown_flag false
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
float sumChargedHadronPt
sum-pt of charged Hadron // old float chargedHadronIso ;
Definition: GsfElectron.h:573
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 &)
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:828
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
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:183
virtual double pt() const final
transverse momentum
static float e5x5(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
bool ecalDrivenSeed() const
Definition: GsfElectron.h:186
Candidate::LorentzVector calculateMomentum()
bool passingPflowPreselection() const
Definition: GsfElectron.h:647
const reco::BeamSpot beamSpot