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
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 
110  const RegressionHelper::Configuration & regConfig
111  )
112  : inputCfg(inputConfig),
113  strategyCfg(strategyConfig),
114  cutsCfg(cutsConfig),
115  cutsCfgPflow(cutsConfigPflow),
116  isoCfg(isoConfig),
117  recHitsCfg(recHitsConfig),
118  hcalHelper(new ElectronHcalHelper(hcalConfig)),
119  hcalHelperPflow(new ElectronHcalHelper(hcalConfigPflow)),
120  superClusterErrorFunction(superClusterErrorFunc),
121  crackCorrectionFunction(crackCorrectionFunc),
122  sElectronMVAEstimator(new SoftElectronMVAEstimator(mva_NIso_Config)),
123  iElectronMVAEstimator(new ElectronMVAEstimator(mva_Iso_Config)),
124  regCfg(regConfig),
125  regHelper(new RegressionHelper(regConfig))
126  {}
127 
129  {
130  delete hcalHelper ;
131  delete hcalHelperPflow ;
132  delete sElectronMVAEstimator;
133  delete iElectronMVAEstimator;
134  delete regHelper;
135  }
136 
137 //===================================================================
138 // GsfElectronAlgo::EventSetupData
139 //===================================================================
140 
142  {
143  EventSetupData() ;
144  ~EventSetupData() ;
145 
146  unsigned long long cacheIDGeom ;
147  unsigned long long cacheIDTopo ;
148  unsigned long long cacheIDTDGeom ;
149  unsigned long long cacheIDMagField ;
150  //unsigned long long cacheChStatus ;
151  unsigned long long cacheSevLevel ;
152 
157  //edm::ESHandle<EcalChannelStatus> chStatus ;
159 
163 } ;
164 
166  : cacheIDGeom(0), cacheIDTopo(0), cacheIDTDGeom(0), cacheIDMagField(0),/*cacheChStatus(0),*/
167  cacheSevLevel(0), mtsTransform(0), constraintAtVtx(0), mtsMode(new MultiTrajectoryStateMode)
168  {}
169 
171  {
172  delete mtsMode ;
173  delete constraintAtVtx ;
174  delete mtsTransform ;
175  }
176 
177 
178 //===================================================================
179 // GsfElectronAlgo::EventData
180 //===================================================================
181 
183  {
184  // general
188 
189  EventData() ;
190  ~EventData() ;
191 
192  // utilities
193  void retreiveOriginalTrackCollections
194  ( const reco::TrackRef &, const reco::GsfTrackRef & ) ;
195 
196  // input collections
212 
213  // isolation helpers
214  ElectronTkIsolation * tkIsolation03, * tkIsolation04 ;
215  EgammaTowerIsolation * hadDepth1Isolation03, * hadDepth1Isolation04 ;
216  EgammaTowerIsolation * hadDepth2Isolation03, * hadDepth2Isolation04 ;
217  EgammaTowerIsolation * hadDepth1Isolation03Bc, * hadDepth1Isolation04Bc ;
218  EgammaTowerIsolation * hadDepth2Isolation03Bc, * hadDepth2Isolation04Bc ;
219  EgammaRecHitIsolation * ecalBarrelIsol03, * ecalBarrelIsol04 ;
220  EgammaRecHitIsolation * ecalEndcapIsol03, * ecalEndcapIsol04 ;
221 
222  //Isolation Value Maps for PF and EcalDriven electrons
223  typedef std::vector< edm::Handle< edm::ValueMap<double> > > IsolationValueMaps;
226  } ;
227 
229  : event(0), beamspot(0),
230  originalCtfTrackCollectionRetreived(false),
231  originalGsfTrackCollectionRetreived(false),
232  tkIsolation03(0), tkIsolation04(0),
233  hadDepth1Isolation03(0), hadDepth1Isolation04(0),
234  hadDepth2Isolation03(0), hadDepth2Isolation04(0),
235  hadDepth1Isolation03Bc(0), hadDepth1Isolation04Bc(0),
236  hadDepth2Isolation03Bc(0), hadDepth2Isolation04Bc(0),
237  ecalBarrelIsol03(0), ecalBarrelIsol04(0),
238  ecalEndcapIsol03(0), ecalEndcapIsol04(0)
239  {
241  }
242 
244  {
245  delete tkIsolation03 ;
246  delete tkIsolation04 ;
247  delete hadDepth1Isolation03 ;
248  delete hadDepth1Isolation04 ;
249  delete hadDepth2Isolation03 ;
250  delete hadDepth2Isolation04 ;
251  delete hadDepth1Isolation03Bc ;
252  delete hadDepth1Isolation04Bc ;
253  delete hadDepth2Isolation03Bc ;
254  delete hadDepth2Isolation04Bc ;
255  delete ecalBarrelIsol03 ;
256  delete ecalBarrelIsol04 ;
257  delete ecalEndcapIsol03 ;
258  delete ecalEndcapIsol04 ;
259 
260  GsfElectronPtrCollection::const_iterator it ;
261  for ( it = electrons->begin() ; it != electrons->end() ; it++ )
262  { delete (*it) ; }
263  delete electrons ;
264  }
265 
267  ( const reco::TrackRef & ctfTrack, const reco::GsfTrackRef & gsfTrack )
268  {
269  if ((!originalCtfTrackCollectionRetreived)&&(ctfTrack.isNonnull()))
270  {
271  event->get(ctfTrack.id(),originalCtfTracks) ;
272  originalCtfTrackCollectionRetreived = true ;
273  }
274  if ((!originalGsfTrackCollectionRetreived)&&(gsfTrack.isNonnull()))
275  {
276  event->get(gsfTrack.id(),originalGsfTracks) ;
277  originalGsfTrackCollectionRetreived = true ;
278  }
279  }
280 
281 
282 //===================================================================
283 // GsfElectronAlgo::ElectronData
284 //===================================================================
285 
287  {
288  // Refs to subproducts
295 
296  // constructors
298  ( const reco::GsfElectronCoreRef & core,
299  const reco::BeamSpot & bs ) ;
300  ~ElectronData() ;
301 
302  // utilities
303  void checkCtfTrack( edm::Handle<reco::TrackCollection> currentCtfTracks ) ;
304  void computeCharge( int & charge, reco::GsfElectron::ChargeInfo & info ) ;
305  CaloClusterPtr getEleBasicCluster( const MultiTrajectoryStateTransform * ) ;
306  bool calculateTSOS( const MultiTrajectoryStateTransform *, GsfConstraintAtVertex * ) ;
307  void calculateMode( const MultiTrajectoryStateMode * mtsMode ) ;
308  Candidate::LorentzVector calculateMomentum() ;
309 
310  // TSOS
318 
319  // mode
320  GlobalVector innMom, seedMom, eleMom, sclMom, vtxMom, outMom ;
321  GlobalPoint innPos, seedPos, elePos, sclPos, vtxPos, outPos ;
323  } ;
324 
326  ( const reco::GsfElectronCoreRef & core,
327  const reco::BeamSpot & bs )
328  : coreRef(core),
329  gsfTrackRef(coreRef->gsfTrack()),
330  superClusterRef(coreRef->superCluster()),
331  ctfTrackRef(coreRef->ctfTrack()), shFracInnerHits(coreRef->ctfGsfOverlap()),
332  beamSpot(bs)
333  {}
334 
336  {}
337 
339 {
340  if (!ctfTrackRef.isNull()) return ;
341 
342  // Code below from Puneeth Kalavase
343 
344  shFracInnerHits = 0 ;
345  const TrackCollection * ctfTrackCollection = currentCtfTracks.product() ;
346 
347  // get the Hit Pattern for the gsfTrack
348  const HitPattern &gsfHitPattern = gsfTrackRef->hitPattern() ;
349 
350  unsigned int counter ;
351  TrackCollection::const_iterator ctfTkIter ;
352  for (ctfTkIter = ctfTrackCollection->begin(), counter = 0;
353  ctfTkIter != ctfTrackCollection->end(); ctfTkIter++, counter++)
354  {
355  double dEta = gsfTrackRef->eta() - ctfTkIter->eta() ;
356  double dPhi = gsfTrackRef->phi() - ctfTkIter->phi() ;
357  double pi = acos(-1.);
358  if(std::abs(dPhi) > pi) dPhi = 2*pi - std::abs(dPhi) ;
359 
360  // dont want to look at every single track in the event!
361  if (sqrt(dEta*dEta + dPhi*dPhi) > 0.3) continue ;
362 
363  unsigned int shared = 0 ;
364  int gsfHitCounter = 0 ;
365  int numGsfInnerHits = 0 ;
366  int numCtfInnerHits = 0 ;
367 
368  // get the CTF Track Hit Pattern
369  const HitPattern &ctfHitPattern = ctfTkIter->hitPattern() ;
370 
371  trackingRecHit_iterator elHitsIt;
372  for (elHitsIt = gsfTrackRef->recHitsBegin();
373  elHitsIt != gsfTrackRef->recHitsEnd();
374  elHitsIt++, gsfHitCounter++)
375  {
376  if (!((**elHitsIt).isValid())) //count only valid Hits
377  { continue ; }
378 
379  // look only in the pixels/TIB/TID
380  uint32_t gsfHit = gsfHitPattern.getHitPattern(HitPattern::TRACK_HITS, gsfHitCounter) ;
381  if (!(HitPattern::pixelHitFilter(gsfHit)
382  || HitPattern::stripTIBHitFilter(gsfHit)
383  || HitPattern::stripTIDHitFilter(gsfHit))){
384  continue;
385  }
386 
387  numGsfInnerHits++ ;
388 
389  int ctfHitsCounter = 0 ;
390  numCtfInnerHits = 0 ;
391  trackingRecHit_iterator ctfHitsIt ;
392  for (ctfHitsIt = ctfTkIter->recHitsBegin();
393  ctfHitsIt != ctfTkIter->recHitsEnd();
394  ctfHitsIt++, ctfHitsCounter++ )
395  {
396  if(!((**ctfHitsIt).isValid())) //count only valid Hits!
397  { continue; }
398 
399  uint32_t ctfHit = ctfHitPattern.getHitPattern(HitPattern::TRACK_HITS, ctfHitsCounter);
400  if(!(HitPattern::pixelHitFilter(ctfHit)
401  || HitPattern::stripTIBHitFilter(ctfHit)
402  || HitPattern::stripTIDHitFilter(ctfHit)))
403  {
404  continue;
405  }
406 
407  numCtfInnerHits++ ;
408 
409  if((**elHitsIt).sharesInput(&(**ctfHitsIt), TrackingRecHit::all))
410  {
411  shared++ ;
412  break ;
413  }
414 
415  } //ctfHits iterator
416 
417  } //gsfHits iterator
418 
419  if ((numGsfInnerHits==0)||(numCtfInnerHits==0))
420  { continue ; }
421 
422  if ( static_cast<float>(shared)/min(numGsfInnerHits,numCtfInnerHits) > shFracInnerHits )
423  {
424  shFracInnerHits = static_cast<float>(shared)/min(numGsfInnerHits, numCtfInnerHits);
425  ctfTrackRef = TrackRef(currentCtfTracks,counter);
426  }
427  } //ctfTrack iterator
428 }
429 
431  ( int & charge, GsfElectron::ChargeInfo & info )
432  {
433  // determine charge from SC
434  GlobalPoint orig, scpos ;
435  ele_convert(beamSpot.position(),orig) ;
436  ele_convert(superClusterRef->position(),scpos) ;
437  GlobalVector scvect(scpos-orig) ;
438  GlobalPoint inntkpos = innTSOS.globalPosition() ;
439  GlobalVector inntkvect = GlobalVector(inntkpos-orig) ;
440  float dPhiInnEle=normalized_phi(scvect.phi()-inntkvect.phi()) ;
441  if(dPhiInnEle>0) info.scPixCharge = -1 ;
442  else info.scPixCharge = 1 ;
443 
444  // flags
445  int chargeGsf = gsfTrackRef->charge() ;
446  info.isGsfScPixConsistent = ((chargeGsf*info.scPixCharge)>0) ;
447  info.isGsfCtfConsistent = (ctfTrackRef.isNonnull()&&((chargeGsf*ctfTrackRef->charge())>0)) ;
449 
450  // default charge
451  if (info.isGsfScPixConsistent||ctfTrackRef.isNull())
452  { charge = info.scPixCharge ; }
453  else
454  { charge = ctfTrackRef->charge() ; }
455  }
456 
458  ( const MultiTrajectoryStateTransform * mtsTransform )
459  {
460  CaloClusterPtr eleRef ;
461  TrajectoryStateOnSurface tempTSOS ;
462  TrajectoryStateOnSurface outTSOS = mtsTransform->outerStateOnSurface(*gsfTrackRef) ;
463  float dphimin = 1.e30 ;
464  for (CaloCluster_iterator bc=superClusterRef->clustersBegin(); bc!=superClusterRef->clustersEnd(); bc++)
465  {
466  GlobalPoint posclu((*bc)->position().x(),(*bc)->position().y(),(*bc)->position().z()) ;
467  tempTSOS = mtsTransform->extrapolatedState(outTSOS,posclu) ;
468  if (!tempTSOS.isValid()) tempTSOS=outTSOS ;
469  GlobalPoint extrap = tempTSOS.globalPosition() ;
470  float dphi = EleRelPointPair(posclu,extrap,beamSpot.position()).dPhi() ;
471  if (std::abs(dphi)<dphimin)
472  {
473  dphimin = std::abs(dphi) ;
474  eleRef = (*bc);
475  eleTSOS = tempTSOS ;
476  }
477  }
478  return eleRef ;
479  }
480 
482  ( const MultiTrajectoryStateTransform * mtsTransform, GsfConstraintAtVertex * constraintAtVtx )
483  {
484  //at innermost point
485  innTSOS = mtsTransform->innerStateOnSurface(*gsfTrackRef);
486  if (!innTSOS.isValid()) return false;
487 
488  //at vertex
489  // innermost state propagation to the beam spot position
490  GlobalPoint bsPos ;
491  ele_convert(beamSpot.position(),bsPos) ;
492  vtxTSOS = mtsTransform->extrapolatedState(innTSOS,bsPos) ;
493  if (!vtxTSOS.isValid()) vtxTSOS=innTSOS;
494 
495  //at seed
496  outTSOS = mtsTransform->outerStateOnSurface(*gsfTrackRef);
497  if (!outTSOS.isValid()) return false;
498 
499  // TrajectoryStateOnSurface seedTSOS
500  seedTSOS = mtsTransform->extrapolatedState(outTSOS,
501  GlobalPoint(superClusterRef->seed()->position().x(),
502  superClusterRef->seed()->position().y(),
503  superClusterRef->seed()->position().z()));
504  if (!seedTSOS.isValid()) seedTSOS=outTSOS;
505 
506  // at scl
507  sclTSOS = mtsTransform->extrapolatedState(innTSOS,GlobalPoint(superClusterRef->x(),superClusterRef->y(),superClusterRef->z()));
508  if (!sclTSOS.isValid()) sclTSOS=outTSOS;
509 
510  // constrained momentum
511  constrainedVtxTSOS = constraintAtVtx->constrainAtBeamSpot(*gsfTrackRef,beamSpot);
512 
513  return true ;
514  }
515 
517  {
518  mtsMode->momentumFromModeCartesian(innTSOS,innMom) ;
519  mtsMode->positionFromModeCartesian(innTSOS,innPos) ;
520  mtsMode->momentumFromModeCartesian(seedTSOS,seedMom) ;
521  mtsMode->positionFromModeCartesian(seedTSOS,seedPos) ;
522  mtsMode->momentumFromModeCartesian(eleTSOS,eleMom) ;
523  mtsMode->positionFromModeCartesian(eleTSOS,elePos) ;
524  mtsMode->momentumFromModeCartesian(sclTSOS,sclMom) ;
525  mtsMode->positionFromModeCartesian(sclTSOS,sclPos) ;
526  mtsMode->momentumFromModeCartesian(vtxTSOS,vtxMom) ;
527  mtsMode->positionFromModeCartesian(vtxTSOS,vtxPos) ;
528  mtsMode->momentumFromModeCartesian(outTSOS,outMom);
529  mtsMode->positionFromModeCartesian(outTSOS,outPos) ;
530  mtsMode->momentumFromModeCartesian(constrainedVtxTSOS,vtxMomWithConstraint);
531  }
532 
534  {
535  double scale = superClusterRef->energy()/vtxMom.mag() ;
537  ( vtxMom.x()*scale,vtxMom.y()*scale,vtxMom.z()*scale,
538  superClusterRef->energy() ) ;
539  }
540 
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 
595  {
596  const reco::CaloCluster & seedCluster = *(theClus->seed()) ;
597  // temporary, till CaloCluster->seed() is made available
598  DetId seedXtalId = seedCluster.hitsAndFractions()[0].first ;
599  int detector = seedXtalId.subdetId() ;
600 
603  const EcalRecHitCollection * recHits = 0 ;
604  std::vector<int> recHitFlagsToBeExcluded ;
605  std::vector<int> recHitSeverityToBeExcluded ;
606  if (detector==EcalBarrel)
607  {
608  recHits = eventData_->barrelRecHits.product() ;
609  recHitFlagsToBeExcluded = generalData_->recHitsCfg.recHitFlagsToBeExcludedBarrel ;
610  recHitSeverityToBeExcluded = generalData_->recHitsCfg.recHitSeverityToBeExcludedBarrel ;
611  }
612  else
613  {
614  recHits = eventData_->endcapRecHits.product() ;
615  recHitFlagsToBeExcluded = generalData_->recHitsCfg.recHitFlagsToBeExcludedEndcaps ;
616  recHitSeverityToBeExcluded = generalData_->recHitsCfg.recHitSeverityToBeExcludedEndcaps ;
617  }
618 
619  std::vector<float> covariances = noZS::EcalClusterTools::covariances(seedCluster,recHits,topology,geometry) ;
620  std::vector<float> localCovariances = noZS::EcalClusterTools::localCovariances(seedCluster,recHits,topology) ;
621  showerShape.sigmaEtaEta = sqrt(covariances[0]) ;
622  showerShape.sigmaIetaIeta = sqrt(localCovariances[0]) ;
623  if (!edm::isNotFinite(localCovariances[2])) showerShape.sigmaIphiIphi = sqrt(localCovariances[2]) ;
624  showerShape.e1x5 = noZS::EcalClusterTools::e1x5(seedCluster,recHits,topology) ;
625  showerShape.e2x5Max = noZS::EcalClusterTools::e2x5Max(seedCluster,recHits,topology) ;
626  showerShape.e5x5 = noZS::EcalClusterTools::e5x5(seedCluster,recHits,topology) ;
627  showerShape.r9 = noZS::EcalClusterTools::e3x3(seedCluster,recHits,topology)/theClus->rawEnergy() ;
628 
629  if (pflow)
630  {
631  showerShape.hcalDepth1OverEcal = generalData_->hcalHelperPflow->hcalESumDepth1(*theClus)/theClus->energy() ;
632  showerShape.hcalDepth2OverEcal = generalData_->hcalHelperPflow->hcalESumDepth2(*theClus)/theClus->energy() ;
636  }
637  else
638  {
639  showerShape.hcalDepth1OverEcal = generalData_->hcalHelper->hcalESumDepth1(*theClus)/theClus->energy() ;
640  showerShape.hcalDepth2OverEcal = generalData_->hcalHelper->hcalESumDepth2(*theClus)/theClus->energy() ;
644  }
645  }
646 
647 
648 //===================================================================
649 // GsfElectronAlgo
650 //===================================================================
651 
653  ( const InputTagsConfiguration & inputCfg,
654  const StrategyConfiguration & strategyCfg,
655  const CutsConfiguration & cutsCfg,
656  const CutsConfiguration & cutsCfgPflow,
657  const ElectronHcalHelper::Configuration & hcalCfg,
658  const ElectronHcalHelper::Configuration & hcalCfgPflow,
659  const IsolationConfiguration & isoCfg,
660  const EcalRecHitsConfiguration & recHitsCfg,
661  EcalClusterFunctionBaseClass * superClusterErrorFunction,
662  EcalClusterFunctionBaseClass * crackCorrectionFunction,
663  const SoftElectronMVAEstimator::Configuration & mva_NIso_Cfg,
664  const ElectronMVAEstimator::Configuration & mva_Iso_Cfg,
665  const RegressionHelper::Configuration & regCfg
666  )
667  : generalData_(new GeneralData(inputCfg,strategyCfg,cutsCfg,cutsCfgPflow,hcalCfg,hcalCfgPflow,isoCfg,recHitsCfg,superClusterErrorFunction,crackCorrectionFunction,mva_NIso_Cfg,mva_Iso_Cfg,regCfg)),
670  {}
671 
673  {
674  delete generalData_ ;
675  delete eventSetupData_ ;
676  delete eventData_ ;
677  delete electronData_ ;
678  }
679 
681  {
682  // get EventSetupRecords if needed
683  bool updateField(false);
685  updateField = true;
688  }
689 
690  bool updateGeometry(false);
692  updateGeometry = true;
695  }
696 
697  if ( updateField || updateGeometry ) {
698  delete eventSetupData_->mtsTransform ;
702  }
703 
705  eventSetupData_->cacheIDGeom=es.get<CaloGeometryRecord>().cacheIdentifier();
707  }
708 
710  eventSetupData_->cacheIDTopo=es.get<CaloTopologyRecord>().cacheIdentifier();
712  }
713 
718 
719 
724 
725  //if(eventSetupData_->cacheChStatus!=es.get<EcalChannelStatusRcd>().cacheIdentifier()){
726  // eventSetupData_->cacheChStatus=es.get<EcalChannelStatusRcd>().cacheIdentifier();
727  // es.get<EcalChannelStatusRcd>().get(eventSetupData_->chStatus);
728  //}
729 
731  eventSetupData_->cacheSevLevel = es.get<EcalSeverityLevelAlgoRcd>().cacheIdentifier();
733  }
734  }
735 
736 
738  {
739  GsfElectronPtrCollection::const_iterator it ;
740  for
741  ( it = eventData_->electrons->begin() ;
742  it != eventData_->electrons->end() ;
743  it++ )
744  { outEle.push_back(**it) ; }
745  }
746 
748  {
749  if (eventData_!=0)
750  { throw cms::Exception("GsfElectronAlgo|InternalError")<<"unexpected event data" ; }
751  eventData_ = new EventData ;
752 
753  // init the handles linked to the current event
754  eventData_->event = &event ;
761  event.getByToken(generalData_->inputCfg.hcalTowersTag,eventData_->towers) ;
762  event.getByToken(generalData_->inputCfg.pfMVA,eventData_->pfMva) ;
763  event.getByToken(generalData_->inputCfg.seedsTag,eventData_->seeds) ;
767 
768  // get the beamspot from the Event:
769  edm::Handle<reco::BeamSpot> recoBeamSpotHandle ;
770  event.getByToken(generalData_->inputCfg.beamSpotTag,recoBeamSpotHandle) ;
771  eventData_->beamspot = recoBeamSpotHandle.product() ;
772 
773  // prepare access to hcal data
776 
777  // Isolation algos
778  float extRadiusSmall=0.3, extRadiusLarge=0.4 ;
779  float intRadiusBarrel=generalData_->isoCfg.intRadiusBarrelTk, intRadiusEndcap=generalData_->isoCfg.intRadiusEndcapTk, stripBarrel=generalData_->isoCfg.stripBarrelTk, stripEndcap=generalData_->isoCfg.stripEndcapTk ;
781  eventData_->tkIsolation03 = new ElectronTkIsolation(extRadiusSmall,intRadiusBarrel,intRadiusEndcap,stripBarrel,stripEndcap,ptMin,maxVtxDist,drb,eventData_->currentCtfTracks.product(),eventData_->beamspot->position()) ;
782  eventData_->tkIsolation04 = new ElectronTkIsolation(extRadiusLarge,intRadiusBarrel,intRadiusEndcap,stripBarrel,stripEndcap,ptMin,maxVtxDist,drb,eventData_->currentCtfTracks.product(),eventData_->beamspot->position()) ;
783 
784  float egHcalIsoConeSizeOutSmall=0.3, egHcalIsoConeSizeOutLarge=0.4;
785  float egHcalIsoConeSizeIn=generalData_->isoCfg.intRadiusHcal,egHcalIsoPtMin=generalData_->isoCfg.etMinHcal;
786  int egHcalDepth1=1, egHcalDepth2=2;
787  eventData_->hadDepth1Isolation03 = new EgammaTowerIsolation(egHcalIsoConeSizeOutSmall,egHcalIsoConeSizeIn,egHcalIsoPtMin,egHcalDepth1,eventData_->towers.product()) ;
788  eventData_->hadDepth2Isolation03 = new EgammaTowerIsolation(egHcalIsoConeSizeOutSmall,egHcalIsoConeSizeIn,egHcalIsoPtMin,egHcalDepth2,eventData_->towers.product()) ;
789  eventData_->hadDepth1Isolation04 = new EgammaTowerIsolation(egHcalIsoConeSizeOutLarge,egHcalIsoConeSizeIn,egHcalIsoPtMin,egHcalDepth1,eventData_->towers.product()) ;
790  eventData_->hadDepth2Isolation04 = new EgammaTowerIsolation(egHcalIsoConeSizeOutLarge,egHcalIsoConeSizeIn,egHcalIsoPtMin,egHcalDepth2,eventData_->towers.product()) ;
791  eventData_->hadDepth1Isolation03Bc = new EgammaTowerIsolation(egHcalIsoConeSizeOutSmall,0.,egHcalIsoPtMin,egHcalDepth1,eventData_->towers.product()) ;
792  eventData_->hadDepth2Isolation03Bc = new EgammaTowerIsolation(egHcalIsoConeSizeOutSmall,0.,egHcalIsoPtMin,egHcalDepth2,eventData_->towers.product()) ;
793  eventData_->hadDepth1Isolation04Bc = new EgammaTowerIsolation(egHcalIsoConeSizeOutLarge,0.,egHcalIsoPtMin,egHcalDepth1,eventData_->towers.product()) ;
794  eventData_->hadDepth2Isolation04Bc = new EgammaTowerIsolation(egHcalIsoConeSizeOutLarge,0.,egHcalIsoPtMin,egHcalDepth2,eventData_->towers.product()) ;
795 
796  float egIsoConeSizeOutSmall=0.3, egIsoConeSizeOutLarge=0.4, egIsoJurassicWidth=generalData_->isoCfg.jurassicWidth;
797  float egIsoPtMinBarrel=generalData_->isoCfg.etMinBarrel,egIsoEMinBarrel=generalData_->isoCfg.eMinBarrel, egIsoConeSizeInBarrel=generalData_->isoCfg.intRadiusEcalBarrel;
798  float egIsoPtMinEndcap=generalData_->isoCfg.etMinEndcaps,egIsoEMinEndcap=generalData_->isoCfg.eMinEndcaps, egIsoConeSizeInEndcap=generalData_->isoCfg.intRadiusEcalEndcaps;
799  eventData_->ecalBarrelIsol03 = new EgammaRecHitIsolation(egIsoConeSizeOutSmall,egIsoConeSizeInBarrel,egIsoJurassicWidth,egIsoPtMinBarrel,egIsoEMinBarrel,eventSetupData_->caloGeom,*(eventData_->barrelRecHits),eventSetupData_->sevLevel.product(),DetId::Ecal);
800  eventData_->ecalBarrelIsol04 = new EgammaRecHitIsolation(egIsoConeSizeOutLarge,egIsoConeSizeInBarrel,egIsoJurassicWidth,egIsoPtMinBarrel,egIsoEMinBarrel,eventSetupData_->caloGeom,*(eventData_->barrelRecHits),eventSetupData_->sevLevel.product(),DetId::Ecal);
801  eventData_->ecalEndcapIsol03 = new EgammaRecHitIsolation(egIsoConeSizeOutSmall,egIsoConeSizeInEndcap,egIsoJurassicWidth,egIsoPtMinEndcap,egIsoEMinEndcap,eventSetupData_->caloGeom,*(eventData_->endcapRecHits),eventSetupData_->sevLevel.product(),DetId::Ecal);
802  eventData_->ecalEndcapIsol04 = new EgammaRecHitIsolation(egIsoConeSizeOutLarge,egIsoConeSizeInEndcap,egIsoJurassicWidth,egIsoPtMinEndcap,egIsoEMinEndcap,eventSetupData_->caloGeom,*(eventData_->endcapRecHits),eventSetupData_->sevLevel.product(),DetId::Ecal);
819 
820  //Fill in the Isolation Value Maps for PF and EcalDriven electrons
821  std::vector<edm::InputTag> inputTagIsoVals;
823  inputTagIsoVals.push_back(generalData_->inputCfg.pfIsoVals.getParameter<edm::InputTag>("pfSumChargedHadronPt"));
824  inputTagIsoVals.push_back(generalData_->inputCfg.pfIsoVals.getParameter<edm::InputTag>("pfSumPhotonEt"));
825  inputTagIsoVals.push_back(generalData_->inputCfg.pfIsoVals.getParameter<edm::InputTag>("pfSumNeutralHadronEt"));
826 
827  eventData_->pfIsolationValues.resize(inputTagIsoVals.size());
828 
829  for (size_t j = 0; j<inputTagIsoVals.size(); ++j) {
830  event.getByLabel(inputTagIsoVals[j], eventData_->pfIsolationValues[j]);
831  }
832 
833  }
834 
836  inputTagIsoVals.clear();
837  inputTagIsoVals.push_back(generalData_->inputCfg.edIsoVals.getParameter<edm::InputTag>("edSumChargedHadronPt"));
838  inputTagIsoVals.push_back(generalData_->inputCfg.edIsoVals.getParameter<edm::InputTag>("edSumPhotonEt"));
839  inputTagIsoVals.push_back(generalData_->inputCfg.edIsoVals.getParameter<edm::InputTag>("edSumNeutralHadronEt"));
840 
841  eventData_->edIsolationValues.resize(inputTagIsoVals.size());
842 
843  for (size_t j = 0; j<inputTagIsoVals.size(); ++j) {
844  event.getByLabel(inputTagIsoVals[j], eventData_->edIsolationValues[j]);
845  }
846  }
847  }
848 
850  {
851  if (eventData_==0)
852  { throw cms::Exception("GsfElectronAlgo|InternalError")<<"lacking event data" ; }
853  delete eventData_ ;
854  eventData_ = 0 ;
855  }
856 
858  {
859  LogTrace("GsfElectronAlgo") << "========== " << title << " ==========";
860  LogTrace("GsfElectronAlgo") << "Event: " << eventData_->event->id();
861  LogTrace("GsfElectronAlgo") << "Number of electrons: " << eventData_->electrons->size() ;
862  GsfElectronPtrCollection::const_iterator it ;
863  for ( it = eventData_->electrons->begin(); it != eventData_->electrons->end(); it++ )
864  {
865  LogTrace("GsfElectronAlgo") << "Electron with charge, pt, eta, phi: " << (*it)->charge() << " , "
866  << (*it)->pt() << " , " << (*it)->eta() << " , " << (*it)->phi();
867  }
868  LogTrace("GsfElectronAlgo") << "=================================================";
869  }
870 
872  {
873  if (electronData_!=0)
874  { throw cms::Exception("GsfElectronAlgo|InternalError")<<"unexpected electron data" ; }
875 
876  const GsfElectronCoreCollection * coreCollection = eventData_->coreElectrons.product() ;
877  for ( unsigned int i=0 ; i<coreCollection->size() ; ++i )
878  {
879  // check there is no existing electron with this core
881  bool coreFound = false ;
882  GsfElectronPtrCollection::const_iterator itrEle ;
883  for
884  ( itrEle = eventData_->electrons->begin() ;
885  itrEle != eventData_->electrons->end() ;
886  itrEle++ )
887  {
888  if ((*itrEle)->core()==coreRef)
889  {
890  coreFound = true ;
891  break ;
892  }
893  }
894  if (coreFound) continue ;
895 
896  // check there is a super-cluster
897  if (coreRef->superCluster().isNull()) continue ;
898 
899  // prepare internal structure for electron specific data
900  delete electronData_ ;
901  electronData_ = new ElectronData(coreRef,*eventData_->beamspot) ;
902 
903  // calculate and check Trajectory StatesOnSurface....
905 
906  createElectron() ;
907 
908  } // loop over tracks
909 
910  delete electronData_ ;
911  electronData_ = 0 ;
912  }
913 
915  {
916  const GsfElectronCollection * oldElectrons = eventData_->previousElectrons.product() ;
918  GsfElectronCollection::const_iterator oldElectron ;
919  for
920  ( oldElectron = oldElectrons->begin() ;
921  oldElectron != oldElectrons->end() ;
922  ++oldElectron )
923  {
924  const GsfElectronCoreRef oldCoreRef = oldElectron->core() ;
925  const GsfTrackRef oldElectronGsfTrackRef = oldCoreRef->gsfTrack() ;
926  unsigned int icore ;
927  for ( icore=0 ; icore<newCores->size() ; ++icore )
928  {
929  if (oldElectronGsfTrackRef==(*newCores)[icore].gsfTrack())
930  {
932  eventData_->electrons->push_back(new GsfElectron(*oldElectron,coreRef)) ;
933  break ;
934  }
935  }
936  }
937  }
938 
939 
940 // now deprecated
942  {
943  bool found ;
944  const GsfElectronCollection * edElectrons = eventData_->previousElectrons.product() ;
946  GsfElectronCollection::const_iterator pfElectron, edElectron ;
947  unsigned int edIndex, pfIndex ;
948 
949  GsfElectronPtrCollection::iterator el ;
950  for
951  ( el = eventData_->electrons->begin() ;
952  el != eventData_->electrons->end() ;
953  el++ )
954  {
955 // // MVA
956 // // we check that the value is never inferior to the no-cut value
957 // // we generally use in the configuration file for minMVA.
958 // GsfTrackRef gsfTrackRef = (*el)->gsfTrack() ;
959 // float mva = (*eventData_->pfMva.product())[gsfTrackRef] ;
960 // if (mva<noCutMin) { throw cms::Exception("GsfElectronAlgo|UnexpectedMvaValue")<<"unexpected MVA value: "<<mva ; }
961 //
962 // // Mva Output
963 // GsfElectron::MvaOutput mvaOutput ;
964 // mvaOutput.mva = mva ;
965 // (*el)->setMvaOutput(mvaOutput) ;
966 
967  // Retreive info from pflow electrons
968  found = false ;
969  for
970  ( pfIndex = 0, pfElectron = pfElectrons->begin() ; pfElectron != pfElectrons->end() ; pfIndex++, pfElectron++ )
971  {
972  if (pfElectron->gsfTrack()==(*el)->gsfTrack())
973  {
974  if (found)
975  {
976  edm::LogWarning("GsfElectronProducer")<<"associated pfGsfElectron already found" ;
977  }
978  else
979  {
980  found = true ;
981 
982  // Isolation Values
983  if( (eventData_->pfIsolationValues).size() != 0 )
984  {
986  pfElectronRef(eventData_->pflowElectrons, pfIndex);
988  isoVariables.sumChargedHadronPt =(*(eventData_->pfIsolationValues)[0])[pfElectronRef];
989  isoVariables.sumPhotonEt =(*(eventData_->pfIsolationValues)[1])[pfElectronRef];
990  isoVariables.sumNeutralHadronEt =(*(eventData_->pfIsolationValues)[2])[pfElectronRef];
991  (*el)->setPfIsolationVariables(isoVariables);
992  }
993 
994 // (*el)->setPfIsolationVariables(pfElectron->pfIsolationVariables()) ;
995  (*el)->setMvaInput(pfElectron->mvaInput()) ;
996  (*el)->setMvaOutput(pfElectron->mvaOutput()) ;
997  if ((*el)->ecalDrivenSeed())
998  { (*el)->setP4(GsfElectron::P4_PFLOW_COMBINATION,pfElectron->p4(GsfElectron::P4_PFLOW_COMBINATION),pfElectron->p4Error(GsfElectron::P4_PFLOW_COMBINATION),false) ; }
999  else
1000  { (*el)->setP4(GsfElectron::P4_PFLOW_COMBINATION,pfElectron->p4(GsfElectron::P4_PFLOW_COMBINATION),pfElectron->p4Error(GsfElectron::P4_PFLOW_COMBINATION),true) ; }
1001  double noCutMin = -999999999. ;
1002  if ((*el)->mva_e_pi()<noCutMin) { throw cms::Exception("GsfElectronAlgo|UnexpectedMvaValue")<<"unexpected MVA value: "<<(*el)->mva_e_pi() ; }
1003  }
1004  }
1005  }
1006 
1007  // Isolation Values
1008  // Retreive not found info from ed electrons
1009  if( (eventData_->edIsolationValues).size() != 0 )
1010  {
1011  edIndex = 0, edElectron = edElectrons->begin() ;
1012  while ((found == false)&&(edElectron != edElectrons->end()))
1013  {
1014  if (edElectron->gsfTrack()==(*el)->gsfTrack())
1015  {
1016  found = true ;
1017 
1018  // CONSTRUCTION D UNE REF dans le handle eventData_->previousElectrons avec l'indice edIndex,
1019  // puis recuperation dans la ValueMap ED
1020 
1022  edElectronRef(eventData_->previousElectrons, edIndex);
1024  isoVariables.sumChargedHadronPt =(*(eventData_->edIsolationValues)[0])[edElectronRef];
1025  isoVariables.sumPhotonEt =(*(eventData_->edIsolationValues)[1])[edElectronRef];
1026  isoVariables.sumNeutralHadronEt =(*(eventData_->edIsolationValues)[2])[edElectronRef];
1027  (*el)->setPfIsolationVariables(isoVariables);
1028  }
1029 
1030  edIndex++ ;
1031  edElectron++ ;
1032  }
1033  }
1034 
1035  // Preselection
1037 
1038  // Shower Shape of pflow cluster
1039  if (!((*el)->parentSuperCluster().isNull()))
1040  {
1041  reco::GsfElectron::ShowerShape pflowShowerShape ;
1042  calculateShowerShape((*el)->parentSuperCluster(),true,pflowShowerShape) ;
1043  (*el)->setPfShowerShape(pflowShowerShape) ;
1044  }
1045  else if ((*el)->passingPflowPreselection())
1046  { edm::LogError("GsfElectronCoreProducer")<<"Preselected tracker driven GsfTrack with no associated pflow SuperCluster." ; }
1047 
1048  // PfBrem
1049  SuperClusterRef sc = (*el)->parentSuperCluster() ;
1050  if (!(sc.isNull()))
1051  {
1052 
1053  if (sc->clustersSize()>1)
1054  {
1055  CaloCluster_iterator first = sc->clustersBegin() ;
1056  (*el)->setPfSuperClusterFbrem((sc->energy()-(*first)->energy())/sc->energy()) ;
1057  }
1058  else
1059  { (*el)->setPfSuperClusterFbrem(0.) ; }
1060  ElectronClassification theClassifier ;
1061  theClassifier.refineWithPflow(**el) ;
1062  }
1063  }
1064  }
1065 
1067  {
1068  float mvaValue=generalData_->sElectronMVAEstimator->mva( *(ele),*(eventData_->event));
1069  bool passCutBased=ele->passingCutBasedPreselection();
1070  bool passPF=ele->passingPflowPreselection();
1072  bool passmva=mvaValue>generalData_->strategyCfg.PreSelectMVA;
1073  if(!ele->ecalDrivenSeed()){
1075  return passmva && passCutBased;
1076  else
1077  return passmva;
1078  }
1079  else{
1080  return passCutBased || passPF || passmva;
1081  }
1082  }
1083  else{
1084  return passCutBased || passPF;
1085  }
1086 
1087  return true;
1088  }
1089 
1091  {
1092  GsfElectronPtrCollection::size_type ei = 1, emax = eventData_->electrons->size() ;
1093  GsfElectronPtrCollection::iterator eitr = eventData_->electrons->begin() ;
1094  while (eitr!=eventData_->electrons->end())
1095  {
1096  LogTrace("GsfElectronAlgo")<<"========== removed not preselected "<<ei<<"/"<<emax<<"==========" ;
1097  if (isPreselected(*eitr))
1098  { ++eitr ; ++ei ; }
1099  else
1100  { delete (*eitr) ; eitr = eventData_->electrons->erase(eitr) ; ++ei ; }
1101  }
1102  }
1103 
1104 
1106  {
1107  // default value
1108  ele->setPassCutBasedPreselection(false) ;
1109 
1110  // kind of seeding
1111  bool eg = ele->core()->ecalDrivenSeed() ;
1112  bool pf = ele->core()->trackerDrivenSeed() && !ele->core()->ecalDrivenSeed() ;
1113  bool gedMode = generalData_->strategyCfg.gedElectronMode;
1114  if (eg&&pf) { throw cms::Exception("GsfElectronAlgo|BothEcalAndPureTrackerDriven")<<"An electron cannot be both egamma and purely pflow" ; }
1115  if ((!eg)&&(!pf)) { throw cms::Exception("GsfElectronAlgo|NeitherEcalNorPureTrackerDriven")<<"An electron cannot be neither egamma nor purely pflow" ; }
1116 
1117  const CutsConfiguration * cfg = ((eg||gedMode)?&generalData_->cutsCfg:&generalData_->cutsCfgPflow);
1118 
1119  // Et cut
1120  double etaValue = EleRelPoint(ele->superCluster()->position(),bs.position()).eta() ;
1121  double etValue = ele->superCluster()->energy()/cosh(etaValue) ;
1122  LogTrace("GsfElectronAlgo") << "Et : " << etValue ;
1123  if (ele->isEB() && (etValue < cfg->minSCEtBarrel)) return ;
1124  if (ele->isEE() && (etValue < cfg->minSCEtEndcaps)) return ;
1125  LogTrace("GsfElectronAlgo") << "Et criteria are satisfied";
1126 
1127  // E/p cut
1128  double eopValue = ele->eSuperClusterOverP() ;
1129  LogTrace("GsfElectronAlgo") << "E/p : " << eopValue ;
1130  if (ele->isEB() && (eopValue > cfg->maxEOverPBarrel)) return ;
1131  if (ele->isEE() && (eopValue > cfg->maxEOverPEndcaps)) return ;
1132  if (ele->isEB() && (eopValue < cfg->minEOverPBarrel)) return ;
1133  if (ele->isEE() && (eopValue < cfg->minEOverPEndcaps)) return ;
1134  LogTrace("GsfElectronAlgo") << "E/p criteria are satisfied";
1135 
1136  // HoE cuts
1137  LogTrace("GsfElectronAlgo") << "HoE1 : " << ele->hcalDepth1OverEcal() << ", HoE2 : " << ele->hcalDepth2OverEcal();
1138  double had = ele->hcalOverEcal()*ele->superCluster()->energy() ;
1139  const reco::CaloCluster & seedCluster = *(ele->superCluster()->seed()) ;
1140  int detector = seedCluster.hitsAndFractions()[0].first.subdetId() ;
1141  bool HoEveto = false ;
1142  if (detector==EcalBarrel && (had<cfg->maxHBarrel || (had/ele->superCluster()->energy())<cfg->maxHOverEBarrel)) HoEveto=true;
1143  else if (detector==EcalEndcap && (had<cfg->maxHEndcaps || (had/ele->superCluster()->energy())<cfg->maxHOverEEndcaps)) HoEveto=true;
1144  if ( !HoEveto ) return ;
1145  LogTrace("GsfElectronAlgo") << "H/E criteria are satisfied";
1146 
1147  // delta eta criteria
1148  double deta = ele->deltaEtaSuperClusterTrackAtVtx() ;
1149  LogTrace("GsfElectronAlgo") << "delta eta : " << deta ;
1150  if (ele->isEB() && (std::abs(deta) > cfg->maxDeltaEtaBarrel)) return ;
1151  if (ele->isEE() && (std::abs(deta) > cfg->maxDeltaEtaEndcaps)) return ;
1152  LogTrace("GsfElectronAlgo") << "Delta eta criteria are satisfied";
1153 
1154  // delta phi criteria
1155  double dphi = ele->deltaPhiSuperClusterTrackAtVtx();
1156  LogTrace("GsfElectronAlgo") << "delta phi : " << dphi;
1157  if (ele->isEB() && (std::abs(dphi) > cfg->maxDeltaPhiBarrel)) return ;
1158  if (ele->isEE() && (std::abs(dphi) > cfg->maxDeltaPhiEndcaps)) return ;
1159  LogTrace("GsfElectronAlgo") << "Delta phi criteria are satisfied";
1160 
1161  // sigma ieta ieta
1162  LogTrace("GsfElectronAlgo") << "sigma ieta ieta : " << ele->sigmaIetaIeta();
1163  if (ele->isEB() && (ele->sigmaIetaIeta() > cfg->maxSigmaIetaIetaBarrel)) return ;
1164  if (ele->isEE() && (ele->sigmaIetaIeta() > cfg->maxSigmaIetaIetaEndcaps)) return ;
1165  LogTrace("GsfElectronAlgo") << "Sigma ieta ieta criteria are satisfied";
1166 
1167  // fiducial
1168  if (!ele->isEB() && cfg->isBarrel) return ;
1169  if (!ele->isEE() && cfg->isEndcaps) return ;
1170  if (cfg->isFiducial && (ele->isEBEEGap()||ele->isEBEtaGap()||ele->isEBPhiGap()||ele->isEERingGap()||ele->isEEDeeGap())) return ;
1171  LogTrace("GsfElectronAlgo") << "Fiducial flags criteria are satisfied";
1172 
1173  // seed in TEC
1174  edm::RefToBase<TrajectorySeed> seed = ele->gsfTrack()->extra()->seedRef() ;
1175  ElectronSeedRef elseed = seed.castTo<ElectronSeedRef>() ;
1176  if (eg && !generalData_->cutsCfg.seedFromTEC)
1177  {
1178  if (elseed.isNull())
1179  { throw cms::Exception("GsfElectronAlgo|NotElectronSeed")<<"The GsfTrack seed is not an ElectronSeed ?!" ; }
1180  else
1181  { if (elseed->subDet2()==6) return ; }
1182  }
1183 
1184  // transverse impact parameter
1185  if (std::abs(ele->gsfTrack()->dxy(bs.position()))>cfg->maxTIP) return ;
1186  LogTrace("GsfElectronAlgo") << "TIP criterion is satisfied" ;
1187 
1188  LogTrace("GsfElectronAlgo") << "All cut based criteria are satisfied" ;
1189  ele->setPassCutBasedPreselection(true) ;
1190  }
1191 
1193  {
1194  ele->setPassMvaPreselection(false) ;
1195 
1196  if (ele->core()->ecalDrivenSeed())
1197  { if (ele->mvaOutput().mva_e_pi>=generalData_->cutsCfg.minMVA) ele->setPassMvaPreselection(true) ; }
1198  else
1200 
1201  if (ele->passingMvaPreselection())
1202  { LogTrace("GsfElectronAlgo") << "Main mva criterion is satisfied" ; }
1203 
1205 
1206 // ele->setPassPflowPreselection(false) ;
1207 // if (ele->core()->ecalDrivenSeed())
1208 // {
1209 // if ((ele->mvaOutput().mva>=generalData_->cutsCfg.minMVA) ||
1210 // (ele->mvaOutput().mvaByPassForIsolated>=generalData_->cutsCfg.minMvaByPassForIsolated))
1211 // ele->setPassPflowPreselection(true) ;
1212 // }
1213 // else
1214 // {
1215 // if ((ele->mvaOutput().mva>=generalData_->cutsCfgPflow.minMVA) ||
1216 // (ele->mvaOutput().mvaByPassForIsolated>=generalData_->cutsCfgPflow.minMvaByPassForIsolated))
1217 // ele->setPassPflowPreselection(true) ;
1218 // }
1219 // if (ele->passingPflowPreselection())
1220 // { LogTrace("GsfElectronAlgo") << "Mva criteria are satisfied" ; }
1221  }
1222 
1223 void GsfElectronAlgo::setMVAInputs(const std::map<reco::GsfTrackRef,reco::GsfElectron::MvaInput> & mvaInputs)
1224 {
1225  GsfElectronPtrCollection::iterator el ;
1226  for
1227  ( el = eventData_->electrons->begin() ;
1228  el != eventData_->electrons->end() ;
1229  el++ )
1230  {
1231  std::map<reco::GsfTrackRef,reco::GsfElectron::MvaInput>::const_iterator itcheck=mvaInputs.find((*el)->gsfTrack());
1232  (*el)->setMvaInput(itcheck->second);
1233  }
1234 }
1235 
1236 void GsfElectronAlgo::setMVAOutputs(const std::map<reco::GsfTrackRef,reco::GsfElectron::MvaOutput> & mvaOutputs)
1237 {
1238  GsfElectronPtrCollection::iterator el ;
1239  for
1240  ( el = eventData_->electrons->begin() ;
1241  el != eventData_->electrons->end() ;
1242  el++ )
1243  {
1245  float mva_NIso_Value= generalData_->sElectronMVAEstimator->mva( *(*el),*(eventData_->event));
1246  float mva_Iso_Value = generalData_->iElectronMVAEstimator->mva( *(*el), eventData_->vertices->size() );
1247  GsfElectron::MvaOutput mvaOutput ;
1248  mvaOutput.mva_e_pi = mva_NIso_Value ;
1249  mvaOutput.mva_Isolated = mva_Iso_Value ;
1250  (*el)->setMvaOutput(mvaOutput);
1251  }
1252  else{
1253  std::map<reco::GsfTrackRef,reco::GsfElectron::MvaOutput>::const_iterator itcheck=mvaOutputs.find((*el)->gsfTrack());
1254  (*el)->setMvaOutput(itcheck->second);
1255  }
1256  }
1257 }
1258 
1260  {
1261  // eventually check ctf track
1264 
1265  // charge ID
1266  int eleCharge ;
1267  GsfElectron::ChargeInfo eleChargeInfo ;
1268  electronData_->computeCharge(eleCharge,eleChargeInfo) ;
1269 
1270  // electron basic cluster
1272 
1273  // Seed cluster
1274  const reco::CaloCluster & seedCluster = *(electronData_->superClusterRef->seed()) ;
1275 
1276  // seed Xtal
1277  // temporary, till CaloCluster->seed() is made available
1278  DetId seedXtalId = seedCluster.hitsAndFractions()[0].first ;
1279 
1281 
1282 
1283  //====================================================
1284  // Candidate attributes
1285  //====================================================
1286 
1288 
1289 
1290  //====================================================
1291  // Track-Cluster Matching
1292  //====================================================
1293 
1295  tcMatching.electronCluster = elbcRef ;
1296  tcMatching.eSuperClusterOverP = (electronData_->vtxMom.mag()>0)?(electronData_->superClusterRef->energy()/electronData_->vtxMom.mag()):(-1.) ;
1297  tcMatching.eSeedClusterOverP = (electronData_->vtxMom.mag()>0.)?(seedCluster.energy()/electronData_->vtxMom.mag()):(-1) ;
1298  tcMatching.eSeedClusterOverPout = (electronData_->seedMom.mag()>0.)?(seedCluster.energy()/electronData_->seedMom.mag()):(-1.) ;
1299  tcMatching.eEleClusterOverPout = (electronData_->eleMom.mag()>0.)?(elbcRef->energy()/electronData_->eleMom.mag()):(-1.) ;
1300 
1302  tcMatching.deltaEtaSuperClusterAtVtx = scAtVtx.dEta() ;
1303  tcMatching.deltaPhiSuperClusterAtVtx = scAtVtx.dPhi() ;
1304 
1305  EleRelPointPair seedAtCalo(seedCluster.position(),electronData_->seedPos,eventData_->beamspot->position()) ;
1306  tcMatching.deltaEtaSeedClusterAtCalo = seedAtCalo.dEta() ;
1307  tcMatching.deltaPhiSeedClusterAtCalo = seedAtCalo.dPhi() ;
1308 
1309  EleRelPointPair ecAtCalo(elbcRef->position(),electronData_->elePos,eventData_->beamspot->position()) ;
1310  tcMatching.deltaEtaEleClusterAtCalo = ecAtCalo.dEta() ;
1311  tcMatching.deltaPhiEleClusterAtCalo = ecAtCalo.dPhi() ;
1312 
1313 
1314  //=======================================================
1315  // Track extrapolations
1316  //=======================================================
1317 
1326 
1327 
1328  //=======================================================
1329  // Closest Ctf Track
1330  //=======================================================
1331 
1333  ctfInfo.ctfTrack = electronData_->ctfTrackRef ;
1335 
1336 
1337  //====================================================
1338  // FiducialFlags, using nextToBoundary definition of gaps
1339  //====================================================
1340 
1341  reco::GsfElectron::FiducialFlags fiducialFlags ;
1342  int detector = seedXtalId.subdetId() ;
1343  double feta=std::abs(electronData_->superClusterRef->position().eta()) ;
1344  if (detector==EcalBarrel)
1345  {
1346  fiducialFlags.isEB = true ;
1347  EBDetId ebdetid(seedXtalId);
1348  if (EBDetId::isNextToEtaBoundary(ebdetid))
1349  {
1350  if (ebdetid.ietaAbs()==85)
1351  { fiducialFlags.isEBEEGap = true ; }
1352  else
1353  { fiducialFlags.isEBEtaGap = true ; }
1354  }
1355  if (EBDetId::isNextToPhiBoundary(ebdetid))
1356  { fiducialFlags.isEBPhiGap = true ; }
1357  }
1358  else if (detector==EcalEndcap)
1359  {
1360  fiducialFlags.isEE = true ;
1361  EEDetId eedetid(seedXtalId);
1362  if (EEDetId::isNextToRingBoundary(eedetid))
1363  {
1364  if (std::abs(feta)<2.)
1365  { fiducialFlags.isEBEEGap = true ; }
1366  else
1367  { fiducialFlags.isEERingGap = true ; }
1368  }
1369  if (EEDetId::isNextToDBoundary(eedetid))
1370  { fiducialFlags.isEEDeeGap = true ; }
1371  }
1372  else
1373  { throw cms::Exception("GsfElectronAlgo|UnknownXtalRegion")<<"createElectron(): do not know if it is a barrel or endcap seed cluster !!!!" ; }
1374 
1375 
1376  //====================================================
1377  // ShowerShape
1378  //====================================================
1379 
1380  reco::GsfElectron::ShowerShape showerShape ;
1381  calculateShowerShape(electronData_->superClusterRef,!(electronData_->coreRef->ecalDrivenSeed()),showerShape) ;
1382 
1383  reco::GsfElectron::ShowerShape full5x5_showerShape ;
1384  calculateShowerShape_full5x5(electronData_->superClusterRef,!(electronData_->coreRef->ecalDrivenSeed()),full5x5_showerShape) ;
1385 
1386  //====================================================
1387  // ConversionRejection
1388  //====================================================
1389 
1391 
1392  ConversionFinder conversionFinder ;
1393  double BInTesla = eventSetupData_->magField->inTesla(GlobalPoint(0.,0.,0.)).z() ;
1395  if (!ctfTracks.isValid()) { ctfTracks = eventData_->currentCtfTracks ; }
1396 
1397  // values of conversionInfo.flag()
1398  // -9999 : Partner track was not found
1399  // 0 : Partner track found in the CTF collection using
1400  // 1 : Partner track found in the CTF collection using
1401  // 2 : Partner track found in the GSF collection using
1402  // 3 : Partner track found in the GSF collection using the electron's GSF track
1403  ConversionInfo conversionInfo = conversionFinder.getConversionInfo
1404  (*electronData_->coreRef,ctfTracks,eventData_->originalGsfTracks,BInTesla) ;
1405 
1407  conversionVars.flags = conversionInfo.flag() ;
1408  conversionVars.dist = conversionInfo.dist() ;
1409  conversionVars.dcot = conversionInfo.dcot() ;
1410  conversionVars.radius = conversionInfo.radiusOfConversion() ;
1411  if ((conversionVars.flags==0)or(conversionVars.flags==1))
1412  conversionVars.partner = TrackBaseRef(conversionInfo.conversionPartnerCtfTk()) ;
1413  else if ((conversionVars.flags==2)or(conversionVars.flags==3))
1414  conversionVars.partner = TrackBaseRef(conversionInfo.conversionPartnerGsfTk()) ;
1415 
1416 
1417  //====================================================
1418  // Go !
1419  //====================================================
1420 
1421  GsfElectron * ele = new
1422  GsfElectron
1423  ( eleCharge,eleChargeInfo,electronData_->coreRef,
1424  tcMatching, tkExtra, ctfInfo,
1425  fiducialFlags,showerShape, full5x5_showerShape,
1426  conversionVars ) ;
1427  // Will be overwritten later in the case of the regression
1429  ele->setP4(GsfElectron::P4_FROM_SUPER_CLUSTER,momentum,0,true) ;
1430 
1431 
1432  //====================================================
1433  // brems fractions
1434  //====================================================
1435 
1436  if (electronData_->innMom.mag()>0.)
1438 
1439  // the supercluster is the refined one The seed is not necessarily the first cluster
1440  // hence the use of the electronCluster
1441  SuperClusterRef sc = ele->superCluster() ;
1442  if (!(sc.isNull()))
1443  {
1444  CaloClusterPtr cl = ele->electronCluster() ;
1445  if (sc->clustersSize()>1)
1446  {
1447  float pf_fbrem =( sc->energy() - cl->energy() ) / sc->energy();
1448  ele->setSuperClusterFbrem( pf_fbrem ) ;
1449  ele->setPfSuperClusterFbrem( pf_fbrem) ;
1450  }
1451  else
1452  {
1453  ele->setSuperClusterFbrem(0) ;
1454  ele->setPfSuperClusterFbrem(0);
1455  }
1456  }
1457 
1458  //====================================================
1459  // classification and corrections
1460  //====================================================
1461  // classification
1462  ElectronClassification theClassifier ;
1463  theClassifier.classify(*ele) ;
1464  theClassifier.refineWithPflow(*ele) ;
1465  // ecal energy
1468  {
1473  }
1474  else // original implementation
1475  {
1476  if (ele->core()->ecalDrivenSeed())
1477  {
1479  { theEnCorrector.classBasedParameterizationEnergy(*ele,*eventData_->beamspot) ; }
1481  { theEnCorrector.classBasedParameterizationUncertainty(*ele) ; }
1482  }
1483  else
1484  {
1486  { theEnCorrector.simpleParameterizationUncertainty(*ele) ; }
1487  }
1488  }
1489 
1490  // momentum
1491  // Keep the default correction running first. The track momentum error is computed in there
1492  if (ele->core()->ecalDrivenSeed())
1493  {
1494  ElectronMomentumCorrector theMomCorrector;
1495  theMomCorrector.correct(*ele,electronData_->vtxTSOS);
1496  }
1498  {
1500  }
1501 
1502  //====================================================
1503  // now isolation variables
1504  //====================================================
1505 
1519  ele->setIsolation03(dr03);
1520  ele->setIsolation04(dr04);
1521 
1522 
1523  //====================================================
1524  // preselection flag
1525  //====================================================
1526 
1528 
1529  LogTrace("GsfElectronAlgo")<<"Constructed new electron with energy "<< ele->p4().e() ;
1530 
1531  eventData_->electrons->push_back(ele) ;
1532  }
1533 
1534 
1535 //=======================================================================================
1536 // Ambiguity solving
1537 //=======================================================================================
1538 
1539 //bool better_electron( const reco::GsfElectron * e1, const reco::GsfElectron * e2 )
1540 // { return (std::abs(e1->eSuperClusterOverP()-1)<std::abs(e2->eSuperClusterOverP()-1)) ; }
1541 
1542 void GsfElectronAlgo::setAmbiguityData( bool ignoreNotPreselected )
1543  {
1544  GsfElectronPtrCollection::iterator e1, e2 ;
1549  else
1550  { throw cms::Exception("GsfElectronAlgo|UnknownAmbiguitySortingStrategy")<<"value of generalData_->strategyCfg.ambSortingStrategy is : "<<generalData_->strategyCfg.ambSortingStrategy ; }
1551 
1552  // init
1553  for
1554  ( e1 = eventData_->electrons->begin() ;
1555  e1 != eventData_->electrons->end() ;
1556  ++e1 )
1557  {
1558  (*e1)->clearAmbiguousGsfTracks() ;
1559  (*e1)->setAmbiguous(false) ;
1560  }
1561 
1562  // get ambiguous from GsfPfRecTracks
1564  {
1565  for
1566  ( e1 = eventData_->electrons->begin() ;
1567  e1 != eventData_->electrons->end() ;
1568  ++e1 )
1569  {
1570  bool found = false ;
1571  const GsfPFRecTrackCollection * gsfPfRecTrackCollection = eventData_->gsfPfRecTracks.product() ;
1572  GsfPFRecTrackCollection::const_iterator gsfPfRecTrack ;
1573  for ( gsfPfRecTrack=gsfPfRecTrackCollection->begin() ;
1574  gsfPfRecTrack!=gsfPfRecTrackCollection->end() ;
1575  ++gsfPfRecTrack )
1576  {
1577  if (gsfPfRecTrack->gsfTrackRef()==(*e1)->gsfTrack())
1578  {
1579  if (found)
1580  {
1581  edm::LogWarning("GsfElectronAlgo")<<"associated gsfPfRecTrack already found" ;
1582  }
1583  else
1584  {
1585  found = true ;
1586  const std::vector<reco::GsfPFRecTrackRef> & duplicates(gsfPfRecTrack->convBremGsfPFRecTrackRef()) ;
1587  std::vector<reco::GsfPFRecTrackRef>::const_iterator duplicate ;
1588  for ( duplicate = duplicates.begin() ; duplicate != duplicates.end() ; duplicate ++ )
1589  { (*e1)->addAmbiguousGsfTrack((*duplicate)->gsfTrackRef()) ; }
1590  }
1591  }
1592  }
1593  }
1594  }
1595  // or search overlapping clusters
1596  else
1597  {
1598  for
1599  ( e1 = eventData_->electrons->begin() ;
1600  e1 != eventData_->electrons->end() ;
1601  ++e1 )
1602  {
1603  if ((*e1)->ambiguous()) continue ;
1604  if ( ignoreNotPreselected && !isPreselected(*e1) ) continue ;
1605 
1606  SuperClusterRef scRef1 = (*e1)->superCluster();
1607  CaloClusterPtr eleClu1 = (*e1)->electronCluster();
1608  LogDebug("GsfElectronAlgo")
1609  << "Blessing electron with E/P " << (*e1)->eSuperClusterOverP()
1610  << ", cluster " << scRef1.get()
1611  << " & track " << (*e1)->gsfTrack().get() ;
1612 
1613  for
1614  ( e2 = e1, ++e2 ;
1615  e2 != eventData_->electrons->end() ;
1616  ++e2 )
1617  {
1618  if ((*e2)->ambiguous()) continue ;
1619  if ( ignoreNotPreselected && !isPreselected(*e2) ) continue ;
1620 
1621  SuperClusterRef scRef2 = (*e2)->superCluster();
1622  CaloClusterPtr eleClu2 = (*e2)->electronCluster();
1623 
1624  // search if same cluster
1625  bool sameCluster = false ;
1627  { sameCluster = (scRef1==scRef2) ; }
1629  {
1630  float eMin = 1. ;
1631  float threshold = eMin*cosh(EleRelPoint(scRef1->position(),eventData_->beamspot->position()).eta()) ;
1632  sameCluster =
1634  (EgAmbiguityTools::sharedEnergy(&(*scRef1->seed()),&(*eleClu2),eventData_->barrelRecHits,eventData_->endcapRecHits)>=threshold) ||
1636  (EgAmbiguityTools::sharedEnergy(&(*scRef1->seed()),&(*scRef2->seed()),eventData_->barrelRecHits,eventData_->endcapRecHits)>=threshold) ) ;
1637  }
1638  else
1639  { throw cms::Exception("GsfElectronAlgo|UnknownAmbiguityClustersOverlapStrategy")<<"value of generalData_->strategyCfg.ambClustersOverlapStrategy is : "<<generalData_->strategyCfg.ambClustersOverlapStrategy ; }
1640 
1641  // main instructions
1642  if (sameCluster)
1643  {
1644  LogDebug("GsfElectronAlgo")
1645  << "Discarding electron with E/P " << (*e2)->eSuperClusterOverP()
1646  << ", cluster " << scRef2.get()
1647  << " and track " << (*e2)->gsfTrack().get() ;
1648  (*e1)->addAmbiguousGsfTrack((*e2)->gsfTrack()) ;
1649  (*e2)->setAmbiguous(true) ;
1650  }
1651  else if ((*e1)->gsfTrack()==(*e2)->gsfTrack())
1652  {
1653  edm::LogWarning("GsfElectronAlgo")
1654  << "Forgetting electron with E/P " << (*e2)->eSuperClusterOverP()
1655  << ", cluster " << scRef2.get()
1656  << " and track " << (*e2)->gsfTrack().get() ;
1657  (*e2)->setAmbiguous(true) ;
1658  }
1659  }
1660  }
1661  }
1662  }
1663 
1665  {
1666  GsfElectronPtrCollection::size_type ei = 1, emax = eventData_->electrons->size() ;
1667  GsfElectronPtrCollection::iterator eitr = eventData_->electrons->begin() ;
1668  while (eitr!=eventData_->electrons->end())
1669  {
1670  LogTrace("GsfElectronAlgo")<<"========== remove ambiguous "<<ei<<"/"<<emax<<"==========" ;
1671  if ((*eitr)->ambiguous())
1672  { delete (*eitr) ; eitr = eventData_->electrons->erase(eitr) ; ++ei ; }
1673  else
1674  { ++eitr ; ++ei ; }
1675  }
1676  }
1677 
1678 
#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
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:216
const MultiTrajectoryStateMode * mtsMode
bool isPreselected(reco::GsfElectron *ele)
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:124
void applyCombinationRegression(reco::GsfElectron &ele) const
void setTrackFbrem(float fbrem)
Definition: GsfElectron.h:689
int i
Definition: DBlmapReader.cc:9
edm::Handle< edm::ValueMap< float > > pfMva
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:640
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
bool positionFromModeCartesian(const TrajectoryStateOnSurface tsos, GlobalPoint &position) const
edm::EDGetTokenT< reco::GsfElectronCoreCollection > gsfElectronCores
bool isEBEtaGap() const
Definition: GsfElectron.h:352
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)
virtual float pt() const
transverse momentum
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 &)
bool isEBEEGap() const
Definition: GsfElectron.h:350
float hcalDepth2OverEcal() const
Definition: GsfElectron.h:406
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:13
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:190
void checkSetup(const edm::EventSetup &)
void setMVAInputs(const std::map< reco::GsfTrackRef, reco::GsfElectron::MvaInput > &mvaInputs)
bool isEERingGap() const
Definition: GsfElectron.h:356
bool passingCutBasedPreselection() const
Definition: GsfElectron.h:632
bool passingMvaPreselection() const
Definition: GsfElectron.h:648
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)
T eta() const
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:355
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
EgammaTowerIsolation * hadDepth1Isolation03
edm::EDGetTokenT< reco::GsfElectronCollection > pflowGsfElectronsTag
const StrategyConfiguration strategyCfg
SoftElectronMVAEstimator * sElectronMVAEstimator
bool isEE() const
Definition: GsfElectron.h:348
ProductID id() const
Accessor for product ID.
Definition: Ref.h:256
bool isEB() const
Definition: GsfElectron.h:347
TrajectoryStateOnSurface outerStateOnSurface(const reco::GsfTrack &tk) const
edm::EDGetTokenT< EcalRecHitCollection > barrelRecHitCollection
edm::ESHandle< CaloTopology > caloTopo
void doFlagChecks(const std::vector< int > &v)
edm::EDGetTokenT< reco::GsfPFRecTrackCollection > gsfPfRecTracksTag
return((rh^lh)&mask)
reco::TrackRef conversionPartnerCtfTk() const
const Double_t pi
void setSuperClusterFbrem(float fbrem)
Definition: GsfElectron.h:690
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:399
bool isNotFinite(T x)
Definition: isFinite.h:10
static const boost::regex duplicate("duplicateIOV[[:print:]]+?[S|s]ince[=| ]([[:alnum:]]+?);.*")
void calculateShowerShape_full5x5(const reco::SuperClusterRef &, bool pflow, reco::GsfElectron::ShowerShape &)
uint16_t hitPattern[ARRAY_LENGTH]
Definition: HitPattern.h:410
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:31
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:48
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:558
edm::Handle< EcalRecHitCollection > barrelRecHits
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:250
std::vector< GsfElectronCore > GsfElectronCoreCollection
void correct(reco::GsfElectron &, TrajectoryStateOnSurface &)
float hcalOverEcal() const
Definition: GsfElectron.h:407
void setPassMvaPreselection(bool flag)
Definition: GsfElectron.h:647
IsolationValueMaps pfIsolationValues
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< CaloTowerDetId > hcalTowersBehindClusters
Definition: GsfElectron.h:383
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)
double energy() const
cluster energy
Definition: CaloCluster.h:120
const CutsConfiguration cutsCfg
ElectronHcalHelper * hcalHelper
float sumNeutralHadronEt
sum pt of neutral hadrons // old float neutralHadronIso ;
Definition: GsfElectron.h:557
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:242
edm::EDGetTokenT< reco::ElectronSeedCollection > seedsTag
const reco::BeamSpot * beamspot
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 first
Definition: L1TdeRCT.cc:75
bool isValid() const
Definition: HandleBase.h:76
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:247
void setIsolation04(const IsolationVariables &dr04)
Definition: GsfElectron.h:501
#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:405
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
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
cast to a concrete type
Definition: RefToBase.h:242
const T & get() const
Definition: EventSetup.h:55
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:19
void setPflowPreselectionFlag(reco::GsfElectron *ele)
const MvaOutput & mvaOutput() const
Definition: GsfElectron.h:604
T const * product() const
Definition: ESHandle.h:86
const reco::GsfTrackRef gsfTrackRef
void ele_convert(const Type1 &obj1, Type2 &obj2)
void setMVAOutputs(const std::map< reco::GsfTrackRef, reco::GsfElectron::MvaOutput > &mvaOutputs)
bool calculateTSOS(const MultiTrajectoryStateTransform *, GsfConstraintAtVertex *)
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:41
virtual GsfElectronCoreRef core() const
Definition: GsfElectron.cc:8
double mva(const reco::GsfElectron &myElectron, const edm::Event &evt)
double mva(const reco::GsfElectron &myElectron, int nvertices=0)
math::XYZVectorF momentumAtVtxWithConstraint
Definition: GsfElectron.h:280
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:500
ESHandle< TrackerGeometry > geometry
edm::EventID id() const
Definition: EventBase.h:56
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)
void setPfSuperClusterFbrem(float fbrem)
Definition: GsfElectron.h:691
static std::atomic< unsigned int > counter
const reco::GsfElectronCoreRef coreRef
bool isEBPhiGap() const
Definition: GsfElectron.h:353
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:641
EgammaRecHitIsolation * ecalEndcapIsol04
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
ElectronMVAEstimator * iElectronMVAEstimator
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:448
edm::ESHandle< TrackerGeometry > trackerHandle
void setAmbiguityData(bool ignoreNotPreselected=true)
IsolationValueMaps edIsolationValues
float sumChargedHadronPt
sum-pt of charged Hadron // old float chargedHadronIso ;
Definition: GsfElectron.h:556
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 std::vector< float > localCovariances(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, float w0=4.7)
void checkSetup(const edm::EventSetup &)
static float e1x5(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
edm::Handle< CaloTowerCollection > towers
void calculateMode(const MultiTrajectoryStateMode *mtsMode)
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
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:633
const reco::BeamSpot beamSpot