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,
75  ~GeneralData() ;
76 
77  // configurables
84 
85  // additional configuration and helpers
92  } ;
93 
95  ( const InputTagsConfiguration & inputConfig,
96  const StrategyConfiguration & strategyConfig,
97  const CutsConfiguration & cutsConfig,
98  const CutsConfiguration & cutsConfigPflow,
99  const ElectronHcalHelper::Configuration & hcalConfig,
100  const ElectronHcalHelper::Configuration & hcalConfigPflow,
101  const IsolationConfiguration & isoConfig,
102  const EcalRecHitsConfiguration & recHitsConfig,
103  EcalClusterFunctionBaseClass * superClusterErrorFunc,
104  EcalClusterFunctionBaseClass * crackCorrectionFunc,
105  const SoftElectronMVAEstimator::Configuration & mvaConfig,
106  const RegressionHelper::Configuration & regConfig
107  )
108  : inputCfg(inputConfig),
109  strategyCfg(strategyConfig),
110  cutsCfg(cutsConfig),
111  cutsCfgPflow(cutsConfigPflow),
112  isoCfg(isoConfig),
113  recHitsCfg(recHitsConfig),
114  hcalHelper(new ElectronHcalHelper(hcalConfig)),
115  hcalHelperPflow(new ElectronHcalHelper(hcalConfigPflow)),
116  superClusterErrorFunction(superClusterErrorFunc),
117  crackCorrectionFunction(crackCorrectionFunc),
118  sElectronMVAEstimator(new SoftElectronMVAEstimator(mvaConfig)),
119  regCfg(regConfig),
120  regHelper(new RegressionHelper(regConfig))
121  {}
122 
124  {
125  delete hcalHelper ;
126  delete hcalHelperPflow ;
127  delete sElectronMVAEstimator;
128  delete regHelper;
129  }
130 
131 //===================================================================
132 // GsfElectronAlgo::EventSetupData
133 //===================================================================
134 
136  {
137  EventSetupData() ;
138  ~EventSetupData() ;
139 
140  unsigned long long cacheIDGeom ;
141  unsigned long long cacheIDTopo ;
142  unsigned long long cacheIDTDGeom ;
143  unsigned long long cacheIDMagField ;
144  //unsigned long long cacheChStatus ;
145  unsigned long long cacheSevLevel ;
146 
151  //edm::ESHandle<EcalChannelStatus> chStatus ;
153 
157 } ;
158 
160  : cacheIDGeom(0), cacheIDTopo(0), cacheIDTDGeom(0), cacheIDMagField(0),/*cacheChStatus(0),*/
161  cacheSevLevel(0), mtsTransform(0), constraintAtVtx(0), mtsMode(new MultiTrajectoryStateMode)
162  {}
163 
165  {
166  delete mtsMode ;
167  delete constraintAtVtx ;
168  delete mtsTransform ;
169  }
170 
171 
172 //===================================================================
173 // GsfElectronAlgo::EventData
174 //===================================================================
175 
177  {
178  // general
182 
183  EventData() ;
184  ~EventData() ;
185 
186  // utilities
187  void retreiveOriginalTrackCollections
188  ( const reco::TrackRef &, const reco::GsfTrackRef & ) ;
189 
190  // input collections
206 
207  // isolation helpers
208  ElectronTkIsolation * tkIsolation03, * tkIsolation04 ;
209  EgammaTowerIsolation * hadDepth1Isolation03, * hadDepth1Isolation04 ;
210  EgammaTowerIsolation * hadDepth2Isolation03, * hadDepth2Isolation04 ;
211  EgammaTowerIsolation * hadDepth1Isolation03Bc, * hadDepth1Isolation04Bc ;
212  EgammaTowerIsolation * hadDepth2Isolation03Bc, * hadDepth2Isolation04Bc ;
215  EgammaRecHitIsolation * ecalBarrelIsol03, * ecalBarrelIsol04 ;
216  EgammaRecHitIsolation * ecalEndcapIsol03, * ecalEndcapIsol04 ;
217 
218  //Isolation Value Maps for PF and EcalDriven electrons
219  typedef std::vector< edm::Handle< edm::ValueMap<double> > > IsolationValueMaps;
222  } ;
223 
225  : event(0), beamspot(0),
226  originalCtfTrackCollectionRetreived(false),
227  originalGsfTrackCollectionRetreived(false),
228  tkIsolation03(0), tkIsolation04(0),
229  hadDepth1Isolation03(0), hadDepth1Isolation04(0),
230  hadDepth2Isolation03(0), hadDepth2Isolation04(0),
231  ecalBarrelHitsMeta(0), ecalEndcapHitsMeta(0),
232  ecalBarrelIsol03(0), ecalBarrelIsol04(0),
233  ecalEndcapIsol03(0), ecalEndcapIsol04(0)
234  {
236  }
237 
239  {
240  delete tkIsolation03 ;
241  delete tkIsolation04 ;
242  delete hadDepth1Isolation03 ;
243  delete hadDepth1Isolation04 ;
244  delete hadDepth2Isolation03 ;
245  delete hadDepth2Isolation04 ;
246  delete ecalBarrelHitsMeta ;
247  delete ecalEndcapHitsMeta ;
248  delete ecalBarrelIsol03 ;
249  delete ecalBarrelIsol04 ;
250  delete ecalEndcapIsol03 ;
251  delete ecalEndcapIsol04 ;
252 
253  GsfElectronPtrCollection::const_iterator it ;
254  for ( it = electrons->begin() ; it != electrons->end() ; it++ )
255  { delete (*it) ; }
256  delete electrons ;
257  }
258 
260  ( const reco::TrackRef & ctfTrack, const reco::GsfTrackRef & gsfTrack )
261  {
262  if ((!originalCtfTrackCollectionRetreived)&&(ctfTrack.isNonnull()))
263  {
264  event->get(ctfTrack.id(),originalCtfTracks) ;
265  originalCtfTrackCollectionRetreived = true ;
266  }
267  if ((!originalGsfTrackCollectionRetreived)&&(gsfTrack.isNonnull()))
268  {
269  event->get(gsfTrack.id(),originalGsfTracks) ;
270  originalGsfTrackCollectionRetreived = true ;
271  }
272  }
273 
274 
275 //===================================================================
276 // GsfElectronAlgo::ElectronData
277 //===================================================================
278 
280  {
281  // Refs to subproducts
288 
289  // constructors
291  ( const reco::GsfElectronCoreRef & core,
292  const reco::BeamSpot & bs ) ;
293  ~ElectronData() ;
294 
295  // utilities
296  void checkCtfTrack( edm::Handle<reco::TrackCollection> currentCtfTracks ) ;
297  void computeCharge( int & charge, reco::GsfElectron::ChargeInfo & info ) ;
298  CaloClusterPtr getEleBasicCluster( const MultiTrajectoryStateTransform * ) ;
299  bool calculateTSOS( const MultiTrajectoryStateTransform *, GsfConstraintAtVertex * ) ;
300  void calculateMode( const MultiTrajectoryStateMode * mtsMode ) ;
301  Candidate::LorentzVector calculateMomentum() ;
302 
303  // TSOS
311 
312  // mode
313  GlobalVector innMom, seedMom, eleMom, sclMom, vtxMom, outMom ;
314  GlobalPoint innPos, seedPos, elePos, sclPos, vtxPos, outPos ;
316  } ;
317 
319  ( const reco::GsfElectronCoreRef & core,
320  const reco::BeamSpot & bs )
321  : coreRef(core),
322  gsfTrackRef(coreRef->gsfTrack()),
323  superClusterRef(coreRef->superCluster()),
324  ctfTrackRef(coreRef->ctfTrack()), shFracInnerHits(coreRef->ctfGsfOverlap()),
325  beamSpot(bs)
326  {}
327 
329  {}
330 
332  {
333  if (!ctfTrackRef.isNull()) return ;
334 
335  // Code below from Puneeth Kalavase
336 
337  shFracInnerHits = 0 ;
338  const TrackCollection * ctfTrackCollection = currentCtfTracks.product() ;
339 
340  // get the Hit Pattern for the gsfTrack
341  const HitPattern & gsfHitPattern = gsfTrackRef->hitPattern() ;
342 
343  unsigned int counter ;
344  TrackCollection::const_iterator ctfTkIter ;
345  for ( ctfTkIter = ctfTrackCollection->begin() , counter = 0 ;
346  ctfTkIter != ctfTrackCollection->end() ; ctfTkIter++, counter++ )
347  {
348 
349  double dEta = gsfTrackRef->eta() - ctfTkIter->eta() ;
350  double dPhi = gsfTrackRef->phi() - ctfTkIter->phi() ;
351  double pi = acos(-1.);
352  if(std::abs(dPhi) > pi) dPhi = 2*pi - std::abs(dPhi) ;
353 
354  // dont want to look at every single track in the event!
355  if (sqrt(dEta*dEta + dPhi*dPhi) > 0.3) continue ;
356 
357  unsigned int shared = 0 ;
358  int gsfHitCounter = 0 ;
359  int numGsfInnerHits = 0 ;
360  int numCtfInnerHits = 0 ;
361 
362  // get the CTF Track Hit Pattern
363  const HitPattern & ctfHitPattern = ctfTkIter->hitPattern() ;
364 
365  trackingRecHit_iterator elHitsIt ;
366  for ( elHitsIt = gsfTrackRef->recHitsBegin() ;
367  elHitsIt != gsfTrackRef->recHitsEnd() ;
368  elHitsIt++, gsfHitCounter++ )
369  {
370  if (!((**elHitsIt).isValid())) //count only valid Hits
371  { continue ; }
372 
373  // look only in the pixels/TIB/TID
374  uint32_t gsfHit = gsfHitPattern.getHitPattern(gsfHitCounter) ;
375  if (!(gsfHitPattern.pixelHitFilter(gsfHit) ||
376  gsfHitPattern.stripTIBHitFilter(gsfHit) ||
377  gsfHitPattern.stripTIDHitFilter(gsfHit) ) )
378  { continue ; }
379 
380  numGsfInnerHits++ ;
381 
382  int ctfHitsCounter = 0 ;
383  numCtfInnerHits = 0 ;
384  trackingRecHit_iterator ctfHitsIt ;
385  for ( ctfHitsIt = ctfTkIter->recHitsBegin() ;
386  ctfHitsIt != ctfTkIter->recHitsEnd() ;
387  ctfHitsIt++, ctfHitsCounter++ )
388  {
389  if(!((**ctfHitsIt).isValid())) //count only valid Hits!
390  { continue ; }
391 
392  uint32_t ctfHit = ctfHitPattern.getHitPattern(ctfHitsCounter);
393  if( !(ctfHitPattern.pixelHitFilter(ctfHit) ||
394  ctfHitPattern.stripTIBHitFilter(ctfHit) ||
395  ctfHitPattern.stripTIDHitFilter(ctfHit) ) )
396  { continue ; }
397 
398  numCtfInnerHits++ ;
399 
400  if( (**elHitsIt).sharesInput(&(**ctfHitsIt),TrackingRecHit::all) )
401  {
402  shared++ ;
403  break ;
404  }
405 
406  } //ctfHits iterator
407 
408  } //gsfHits iterator
409 
410  if ((numGsfInnerHits==0)||(numCtfInnerHits==0))
411  { continue ; }
412 
413  if ( static_cast<float>(shared)/min(numGsfInnerHits,numCtfInnerHits) > shFracInnerHits )
414  {
415  shFracInnerHits = static_cast<float>(shared)/min(numGsfInnerHits, numCtfInnerHits);
416  ctfTrackRef = TrackRef(currentCtfTracks,counter);
417  }
418  } //ctfTrack iterator
419  }
420 
423  {
424  // determine charge from SC
425  GlobalPoint orig, scpos ;
426  ele_convert(beamSpot.position(),orig) ;
427  ele_convert(superClusterRef->position(),scpos) ;
428  GlobalVector scvect(scpos-orig) ;
429  GlobalPoint inntkpos = innTSOS.globalPosition() ;
430  GlobalVector inntkvect = GlobalVector(inntkpos-orig) ;
431  float dPhiInnEle=normalized_phi(scvect.phi()-inntkvect.phi()) ;
432  if(dPhiInnEle>0) info.scPixCharge = -1 ;
433  else info.scPixCharge = 1 ;
434 
435  // flags
436  int chargeGsf = gsfTrackRef->charge() ;
437  info.isGsfScPixConsistent = ((chargeGsf*info.scPixCharge)>0) ;
438  info.isGsfCtfConsistent = (ctfTrackRef.isNonnull()&&((chargeGsf*ctfTrackRef->charge())>0)) ;
440 
441  // default charge
442  if (info.isGsfScPixConsistent||ctfTrackRef.isNull())
443  { charge = info.scPixCharge ; }
444  else
445  { charge = ctfTrackRef->charge() ; }
446  }
447 
449  ( const MultiTrajectoryStateTransform * mtsTransform )
450  {
451  CaloClusterPtr eleRef ;
452  TrajectoryStateOnSurface tempTSOS ;
453  TrajectoryStateOnSurface outTSOS = mtsTransform->outerStateOnSurface(*gsfTrackRef) ;
454  float dphimin = 1.e30 ;
455  for (CaloCluster_iterator bc=superClusterRef->clustersBegin(); bc!=superClusterRef->clustersEnd(); bc++)
456  {
457  GlobalPoint posclu((*bc)->position().x(),(*bc)->position().y(),(*bc)->position().z()) ;
458  tempTSOS = mtsTransform->extrapolatedState(outTSOS,posclu) ;
459  if (!tempTSOS.isValid()) tempTSOS=outTSOS ;
460  GlobalPoint extrap = tempTSOS.globalPosition() ;
461  float dphi = EleRelPointPair(posclu,extrap,beamSpot.position()).dPhi() ;
462  if (std::abs(dphi)<dphimin)
463  {
464  dphimin = std::abs(dphi) ;
465  eleRef = (*bc);
466  eleTSOS = tempTSOS ;
467  }
468  }
469  return eleRef ;
470  }
471 
473  ( const MultiTrajectoryStateTransform * mtsTransform, GsfConstraintAtVertex * constraintAtVtx )
474  {
475  //at innermost point
476  innTSOS = mtsTransform->innerStateOnSurface(*gsfTrackRef);
477  if (!innTSOS.isValid()) return false;
478 
479  //at vertex
480  // innermost state propagation to the beam spot position
481  GlobalPoint bsPos ;
482  ele_convert(beamSpot.position(),bsPos) ;
483  vtxTSOS = mtsTransform->extrapolatedState(innTSOS,bsPos) ;
484  if (!vtxTSOS.isValid()) vtxTSOS=innTSOS;
485 
486  //at seed
487  outTSOS = mtsTransform->outerStateOnSurface(*gsfTrackRef);
488  if (!outTSOS.isValid()) return false;
489 
490  // TrajectoryStateOnSurface seedTSOS
491  seedTSOS = mtsTransform->extrapolatedState(outTSOS,
492  GlobalPoint(superClusterRef->seed()->position().x(),
493  superClusterRef->seed()->position().y(),
494  superClusterRef->seed()->position().z()));
495  if (!seedTSOS.isValid()) seedTSOS=outTSOS;
496 
497  // at scl
498  sclTSOS = mtsTransform->extrapolatedState(innTSOS,GlobalPoint(superClusterRef->x(),superClusterRef->y(),superClusterRef->z()));
499  if (!sclTSOS.isValid()) sclTSOS=outTSOS;
500 
501  // constrained momentum
502  constrainedVtxTSOS = constraintAtVtx->constrainAtBeamSpot(*gsfTrackRef,beamSpot);
503 
504  return true ;
505  }
506 
508  {
509  mtsMode->momentumFromModeCartesian(innTSOS,innMom) ;
510  mtsMode->positionFromModeCartesian(innTSOS,innPos) ;
511  mtsMode->momentumFromModeCartesian(seedTSOS,seedMom) ;
512  mtsMode->positionFromModeCartesian(seedTSOS,seedPos) ;
513  mtsMode->momentumFromModeCartesian(eleTSOS,eleMom) ;
514  mtsMode->positionFromModeCartesian(eleTSOS,elePos) ;
515  mtsMode->momentumFromModeCartesian(sclTSOS,sclMom) ;
516  mtsMode->positionFromModeCartesian(sclTSOS,sclPos) ;
517  mtsMode->momentumFromModeCartesian(vtxTSOS,vtxMom) ;
518  mtsMode->positionFromModeCartesian(vtxTSOS,vtxPos) ;
519  mtsMode->momentumFromModeCartesian(outTSOS,outMom);
520  mtsMode->positionFromModeCartesian(outTSOS,outPos) ;
521  mtsMode->momentumFromModeCartesian(constrainedVtxTSOS,vtxMomWithConstraint);
522  }
523 
525  {
526  double scale = superClusterRef->energy()/vtxMom.mag() ;
528  ( vtxMom.x()*scale,vtxMom.y()*scale,vtxMom.z()*scale,
529  superClusterRef->energy() ) ;
530  }
531 
533  {
534  const reco::CaloCluster & seedCluster = *(theClus->seed()) ;
535  // temporary, till CaloCluster->seed() is made available
536  DetId seedXtalId = seedCluster.hitsAndFractions()[0].first ;
537  int detector = seedXtalId.subdetId() ;
538 
539  const CaloTopology * topology = eventSetupData_->caloTopo.product() ;
541  const EcalRecHitCollection * recHits = 0 ;
542  std::vector<int> recHitFlagsToBeExcluded ;
543  std::vector<int> recHitSeverityToBeExcluded ;
544  if (detector==EcalBarrel)
545  {
546  recHits = eventData_->barrelRecHits.product() ;
547  recHitFlagsToBeExcluded = generalData_->recHitsCfg.recHitFlagsToBeExcludedBarrel ;
548  recHitSeverityToBeExcluded = generalData_->recHitsCfg.recHitSeverityToBeExcludedBarrel ;
549  }
550  else
551  {
552  recHits = eventData_->endcapRecHits.product() ;
553  recHitFlagsToBeExcluded = generalData_->recHitsCfg.recHitFlagsToBeExcludedEndcaps ;
554  recHitSeverityToBeExcluded = generalData_->recHitsCfg.recHitSeverityToBeExcludedEndcaps ;
555  }
556 
557  std::vector<float> covariances = EcalClusterTools::covariances(seedCluster,recHits,topology,geometry) ;
558  std::vector<float> localCovariances = EcalClusterTools::localCovariances(seedCluster,recHits,topology) ;
559  showerShape.sigmaEtaEta = sqrt(covariances[0]) ;
560  showerShape.sigmaIetaIeta = sqrt(localCovariances[0]) ;
561  if (!edm::isNotFinite(localCovariances[2])) showerShape.sigmaIphiIphi = sqrt(localCovariances[2]) ;
562  showerShape.e1x5 = EcalClusterTools::e1x5(seedCluster,recHits,topology) ;
563  showerShape.e2x5Max = EcalClusterTools::e2x5Max(seedCluster,recHits,topology) ;
564  showerShape.e5x5 = EcalClusterTools::e5x5(seedCluster,recHits,topology) ;
565  showerShape.r9 = EcalClusterTools::e3x3(seedCluster,recHits,topology)/theClus->rawEnergy() ;
566 
567  if (pflow)
568  {
569  showerShape.hcalDepth1OverEcal = generalData_->hcalHelperPflow->hcalESumDepth1(*theClus)/theClus->energy() ;
570  showerShape.hcalDepth2OverEcal = generalData_->hcalHelperPflow->hcalESumDepth2(*theClus)/theClus->energy() ;
574  }
575  else
576  {
577  showerShape.hcalDepth1OverEcal = generalData_->hcalHelper->hcalESumDepth1(*theClus)/theClus->energy() ;
578  showerShape.hcalDepth2OverEcal = generalData_->hcalHelper->hcalESumDepth2(*theClus)/theClus->energy() ;
582  }
583  }
584 
585 
586 //===================================================================
587 // GsfElectronAlgo
588 //===================================================================
589 
591  ( const InputTagsConfiguration & inputCfg,
592  const StrategyConfiguration & strategyCfg,
593  const CutsConfiguration & cutsCfg,
594  const CutsConfiguration & cutsCfgPflow,
595  const ElectronHcalHelper::Configuration & hcalCfg,
596  const ElectronHcalHelper::Configuration & hcalCfgPflow,
597  const IsolationConfiguration & isoCfg,
598  const EcalRecHitsConfiguration & recHitsCfg,
599  EcalClusterFunctionBaseClass * superClusterErrorFunction,
600  EcalClusterFunctionBaseClass * crackCorrectionFunction,
602  const RegressionHelper::Configuration & regCfg
603  )
604  : generalData_(new GeneralData(inputCfg,strategyCfg,cutsCfg,cutsCfgPflow,hcalCfg,hcalCfgPflow,isoCfg,recHitsCfg,superClusterErrorFunction,crackCorrectionFunction,mvaCfg,regCfg)),
607  {}
608 
610  {
611  delete generalData_ ;
612  delete eventSetupData_ ;
613  delete eventData_ ;
614  delete electronData_ ;
615  }
616 
618  {
619  // get EventSetupRecords if needed
620  bool updateField(false);
622  updateField = true;
625  }
626 
627  bool updateGeometry(false);
629  updateGeometry = true;
632  }
633 
634  if ( updateField || updateGeometry ) {
635  delete eventSetupData_->mtsTransform ;
639  }
640 
642  eventSetupData_->cacheIDGeom=es.get<CaloGeometryRecord>().cacheIdentifier();
644  }
645 
647  eventSetupData_->cacheIDTopo=es.get<CaloTopologyRecord>().cacheIdentifier();
649  }
650 
655 
656 
661 
662  //if(eventSetupData_->cacheChStatus!=es.get<EcalChannelStatusRcd>().cacheIdentifier()){
663  // eventSetupData_->cacheChStatus=es.get<EcalChannelStatusRcd>().cacheIdentifier();
664  // es.get<EcalChannelStatusRcd>().get(eventSetupData_->chStatus);
665  //}
666 
668  eventSetupData_->cacheSevLevel = es.get<EcalSeverityLevelAlgoRcd>().cacheIdentifier();
670  }
671  }
672 
673 
675  {
676  GsfElectronPtrCollection::const_iterator it ;
677  for
678  ( it = eventData_->electrons->begin() ;
679  it != eventData_->electrons->end() ;
680  it++ )
681  { outEle.push_back(**it) ; }
682  }
683 
685  {
686  if (eventData_!=0)
687  { throw cms::Exception("GsfElectronAlgo|InternalError")<<"unexpected event data" ; }
688  eventData_ = new EventData ;
689 
690  // init the handles linked to the current event
691  eventData_->event = &event ;
698  event.getByToken(generalData_->inputCfg.hcalTowersTag,eventData_->towers) ;
699  event.getByToken(generalData_->inputCfg.pfMVA,eventData_->pfMva) ;
700  event.getByToken(generalData_->inputCfg.seedsTag,eventData_->seeds) ;
704 
705  // get the beamspot from the Event:
706  edm::Handle<reco::BeamSpot> recoBeamSpotHandle ;
707  event.getByToken(generalData_->inputCfg.beamSpotTag,recoBeamSpotHandle) ;
708  eventData_->beamspot = recoBeamSpotHandle.product() ;
709 
710  // prepare access to hcal data
713 
714  // Isolation algos
715  float extRadiusSmall=0.3, extRadiusLarge=0.4 ;
716  float intRadiusBarrel=generalData_->isoCfg.intRadiusBarrelTk, intRadiusEndcap=generalData_->isoCfg.intRadiusEndcapTk, stripBarrel=generalData_->isoCfg.stripBarrelTk, stripEndcap=generalData_->isoCfg.stripEndcapTk ;
718  eventData_->tkIsolation03 = new ElectronTkIsolation(extRadiusSmall,intRadiusBarrel,intRadiusEndcap,stripBarrel,stripEndcap,ptMin,maxVtxDist,drb,eventData_->currentCtfTracks.product(),eventData_->beamspot->position()) ;
719  eventData_->tkIsolation04 = new ElectronTkIsolation(extRadiusLarge,intRadiusBarrel,intRadiusEndcap,stripBarrel,stripEndcap,ptMin,maxVtxDist,drb,eventData_->currentCtfTracks.product(),eventData_->beamspot->position()) ;
720 
721  float egHcalIsoConeSizeOutSmall=0.3, egHcalIsoConeSizeOutLarge=0.4;
722  float egHcalIsoConeSizeIn=generalData_->isoCfg.intRadiusHcal,egHcalIsoPtMin=generalData_->isoCfg.etMinHcal;
723  int egHcalDepth1=1, egHcalDepth2=2;
724  eventData_->hadDepth1Isolation03 = new EgammaTowerIsolation(egHcalIsoConeSizeOutSmall,egHcalIsoConeSizeIn,egHcalIsoPtMin,egHcalDepth1,eventData_->towers.product()) ;
725  eventData_->hadDepth2Isolation03 = new EgammaTowerIsolation(egHcalIsoConeSizeOutSmall,egHcalIsoConeSizeIn,egHcalIsoPtMin,egHcalDepth2,eventData_->towers.product()) ;
726  eventData_->hadDepth1Isolation04 = new EgammaTowerIsolation(egHcalIsoConeSizeOutLarge,egHcalIsoConeSizeIn,egHcalIsoPtMin,egHcalDepth1,eventData_->towers.product()) ;
727  eventData_->hadDepth2Isolation04 = new EgammaTowerIsolation(egHcalIsoConeSizeOutLarge,egHcalIsoConeSizeIn,egHcalIsoPtMin,egHcalDepth2,eventData_->towers.product()) ;
728  eventData_->hadDepth1Isolation03Bc = new EgammaTowerIsolation(egHcalIsoConeSizeOutSmall,0.,egHcalIsoPtMin,egHcalDepth1,eventData_->towers.product()) ;
729  eventData_->hadDepth2Isolation03Bc = new EgammaTowerIsolation(egHcalIsoConeSizeOutSmall,0.,egHcalIsoPtMin,egHcalDepth2,eventData_->towers.product()) ;
730  eventData_->hadDepth1Isolation04Bc = new EgammaTowerIsolation(egHcalIsoConeSizeOutLarge,0.,egHcalIsoPtMin,egHcalDepth1,eventData_->towers.product()) ;
731  eventData_->hadDepth2Isolation04Bc = new EgammaTowerIsolation(egHcalIsoConeSizeOutLarge,0.,egHcalIsoPtMin,egHcalDepth2,eventData_->towers.product()) ;
732 
733  float egIsoConeSizeOutSmall=0.3, egIsoConeSizeOutLarge=0.4, egIsoJurassicWidth=generalData_->isoCfg.jurassicWidth;
734  float egIsoPtMinBarrel=generalData_->isoCfg.etMinBarrel,egIsoEMinBarrel=generalData_->isoCfg.eMinBarrel, egIsoConeSizeInBarrel=generalData_->isoCfg.intRadiusEcalBarrel;
735  float egIsoPtMinEndcap=generalData_->isoCfg.etMinEndcaps,egIsoEMinEndcap=generalData_->isoCfg.eMinEndcaps, egIsoConeSizeInEndcap=generalData_->isoCfg.intRadiusEcalEndcaps;
738  eventData_->ecalBarrelIsol03 = new EgammaRecHitIsolation(egIsoConeSizeOutSmall,egIsoConeSizeInBarrel,egIsoJurassicWidth,egIsoPtMinBarrel,egIsoEMinBarrel,eventSetupData_->caloGeom,eventData_->ecalBarrelHitsMeta,eventSetupData_->sevLevel.product(),DetId::Ecal);
739  eventData_->ecalBarrelIsol04 = new EgammaRecHitIsolation(egIsoConeSizeOutLarge,egIsoConeSizeInBarrel,egIsoJurassicWidth,egIsoPtMinBarrel,egIsoEMinBarrel,eventSetupData_->caloGeom,eventData_->ecalBarrelHitsMeta,eventSetupData_->sevLevel.product(),DetId::Ecal);
740  eventData_->ecalEndcapIsol03 = new EgammaRecHitIsolation(egIsoConeSizeOutSmall,egIsoConeSizeInEndcap,egIsoJurassicWidth,egIsoPtMinEndcap,egIsoEMinEndcap,eventSetupData_->caloGeom,eventData_->ecalEndcapHitsMeta,eventSetupData_->sevLevel.product(),DetId::Ecal);
741  eventData_->ecalEndcapIsol04 = new EgammaRecHitIsolation(egIsoConeSizeOutLarge,egIsoConeSizeInEndcap,egIsoJurassicWidth,egIsoPtMinEndcap,egIsoEMinEndcap,eventSetupData_->caloGeom,eventData_->ecalEndcapHitsMeta,eventSetupData_->sevLevel.product(),DetId::Ecal);
758 
759  //Fill in the Isolation Value Maps for PF and EcalDriven electrons
760  std::vector<edm::InputTag> inputTagIsoVals;
762  inputTagIsoVals.push_back(generalData_->inputCfg.pfIsoVals.getParameter<edm::InputTag>("pfSumChargedHadronPt"));
763  inputTagIsoVals.push_back(generalData_->inputCfg.pfIsoVals.getParameter<edm::InputTag>("pfSumPhotonEt"));
764  inputTagIsoVals.push_back(generalData_->inputCfg.pfIsoVals.getParameter<edm::InputTag>("pfSumNeutralHadronEt"));
765 
766  eventData_->pfIsolationValues.resize(inputTagIsoVals.size());
767 
768  for (size_t j = 0; j<inputTagIsoVals.size(); ++j) {
769  event.getByLabel(inputTagIsoVals[j], eventData_->pfIsolationValues[j]);
770  }
771 
772  }
773 
775  inputTagIsoVals.clear();
776  inputTagIsoVals.push_back(generalData_->inputCfg.edIsoVals.getParameter<edm::InputTag>("edSumChargedHadronPt"));
777  inputTagIsoVals.push_back(generalData_->inputCfg.edIsoVals.getParameter<edm::InputTag>("edSumPhotonEt"));
778  inputTagIsoVals.push_back(generalData_->inputCfg.edIsoVals.getParameter<edm::InputTag>("edSumNeutralHadronEt"));
779 
780  eventData_->edIsolationValues.resize(inputTagIsoVals.size());
781 
782  for (size_t j = 0; j<inputTagIsoVals.size(); ++j) {
783  event.getByLabel(inputTagIsoVals[j], eventData_->edIsolationValues[j]);
784  }
785  }
786  }
787 
789  {
790  if (eventData_==0)
791  { throw cms::Exception("GsfElectronAlgo|InternalError")<<"lacking event data" ; }
792  delete eventData_ ;
793  eventData_ = 0 ;
794  }
795 
797  {
798  LogTrace("GsfElectronAlgo") << "========== " << title << " ==========";
799  LogTrace("GsfElectronAlgo") << "Event: " << eventData_->event->id();
800  LogTrace("GsfElectronAlgo") << "Number of electrons: " << eventData_->electrons->size() ;
801  GsfElectronPtrCollection::const_iterator it ;
802  for ( it = eventData_->electrons->begin(); it != eventData_->electrons->end(); it++ )
803  {
804  LogTrace("GsfElectronAlgo") << "Electron with charge, pt, eta, phi: " << (*it)->charge() << " , "
805  << (*it)->pt() << " , " << (*it)->eta() << " , " << (*it)->phi();
806  }
807  LogTrace("GsfElectronAlgo") << "=================================================";
808  }
809 
811  {
812  if (electronData_!=0)
813  { throw cms::Exception("GsfElectronAlgo|InternalError")<<"unexpected electron data" ; }
814 
815  const GsfElectronCoreCollection * coreCollection = eventData_->coreElectrons.product() ;
816  for ( unsigned int i=0 ; i<coreCollection->size() ; ++i )
817  {
818  // check there is no existing electron with this core
820  bool coreFound = false ;
821  GsfElectronPtrCollection::const_iterator itrEle ;
822  for
823  ( itrEle = eventData_->electrons->begin() ;
824  itrEle != eventData_->electrons->end() ;
825  itrEle++ )
826  {
827  if ((*itrEle)->core()==coreRef)
828  {
829  coreFound = true ;
830  break ;
831  }
832  }
833  if (coreFound) continue ;
834 
835  // check there is a super-cluster
836  if (coreRef->superCluster().isNull()) continue ;
837 
838  // prepare internal structure for electron specific data
839  delete electronData_ ;
840  electronData_ = new ElectronData(coreRef,*eventData_->beamspot) ;
841 
842  // calculate and check Trajectory StatesOnSurface....
844 
845  createElectron() ;
846 
847  } // loop over tracks
848 
849  delete electronData_ ;
850  electronData_ = 0 ;
851  }
852 
854  {
855  const GsfElectronCollection * oldElectrons = eventData_->previousElectrons.product() ;
857  GsfElectronCollection::const_iterator oldElectron ;
858  for
859  ( oldElectron = oldElectrons->begin() ;
860  oldElectron != oldElectrons->end() ;
861  ++oldElectron )
862  {
863  const GsfElectronCoreRef oldCoreRef = oldElectron->core() ;
864  const GsfTrackRef oldElectronGsfTrackRef = oldCoreRef->gsfTrack() ;
865  unsigned int icore ;
866  for ( icore=0 ; icore<newCores->size() ; ++icore )
867  {
868  if (oldElectronGsfTrackRef==(*newCores)[icore].gsfTrack())
869  {
871  eventData_->electrons->push_back(new GsfElectron(*oldElectron,coreRef)) ;
872  break ;
873  }
874  }
875  }
876  }
877 
879  {
880  bool found ;
881  const GsfElectronCollection * edElectrons = eventData_->previousElectrons.product() ;
883  GsfElectronCollection::const_iterator pfElectron, edElectron ;
884  unsigned int edIndex, pfIndex ;
885 
886  GsfElectronPtrCollection::iterator el ;
887  for
888  ( el = eventData_->electrons->begin() ;
889  el != eventData_->electrons->end() ;
890  el++ )
891  {
892 // // MVA
893 // // we check that the value is never inferior to the no-cut value
894 // // we generally use in the configuration file for minMVA.
895 // GsfTrackRef gsfTrackRef = (*el)->gsfTrack() ;
896 // float mva = (*eventData_->pfMva.product())[gsfTrackRef] ;
897 // if (mva<noCutMin) { throw cms::Exception("GsfElectronAlgo|UnexpectedMvaValue")<<"unexpected MVA value: "<<mva ; }
898 //
899 // // Mva Output
900 // GsfElectron::MvaOutput mvaOutput ;
901 // mvaOutput.mva = mva ;
902 // (*el)->setMvaOutput(mvaOutput) ;
903 
904  // Retreive info from pflow electrons
905  found = false ;
906  for
907  ( pfIndex = 0, pfElectron = pfElectrons->begin() ; pfElectron != pfElectrons->end() ; pfIndex++, pfElectron++ )
908  {
909  if (pfElectron->gsfTrack()==(*el)->gsfTrack())
910  {
911  if (found)
912  {
913  edm::LogWarning("GsfElectronProducer")<<"associated pfGsfElectron already found" ;
914  }
915  else
916  {
917  found = true ;
918 
919  // Isolation Values
920  if( (eventData_->pfIsolationValues).size() != 0 )
921  {
923  pfElectronRef(eventData_->pflowElectrons, pfIndex);
925  isoVariables.sumChargedHadronPt =(*(eventData_->pfIsolationValues)[0])[pfElectronRef];
926  isoVariables.sumPhotonEt =(*(eventData_->pfIsolationValues)[1])[pfElectronRef];
927  isoVariables.sumNeutralHadronEt =(*(eventData_->pfIsolationValues)[2])[pfElectronRef];
928  (*el)->setPfIsolationVariables(isoVariables);
929  }
930 
931 // (*el)->setPfIsolationVariables(pfElectron->pfIsolationVariables()) ;
932  (*el)->setMvaInput(pfElectron->mvaInput()) ;
933  (*el)->setMvaOutput(pfElectron->mvaOutput()) ;
934  if ((*el)->ecalDrivenSeed())
935  { (*el)->setP4(GsfElectron::P4_PFLOW_COMBINATION,pfElectron->p4(GsfElectron::P4_PFLOW_COMBINATION),pfElectron->p4Error(GsfElectron::P4_PFLOW_COMBINATION),false) ; }
936  else
937  { (*el)->setP4(GsfElectron::P4_PFLOW_COMBINATION,pfElectron->p4(GsfElectron::P4_PFLOW_COMBINATION),pfElectron->p4Error(GsfElectron::P4_PFLOW_COMBINATION),true) ; }
938  double noCutMin = -999999999. ;
939  if ((*el)->mva()<noCutMin) { throw cms::Exception("GsfElectronAlgo|UnexpectedMvaValue")<<"unexpected MVA value: "<<(*el)->mva() ; }
940  }
941  }
942  }
943 
944  // Isolation Values
945  // Retreive not found info from ed electrons
946  if( (eventData_->edIsolationValues).size() != 0 )
947  {
948  edIndex = 0, edElectron = edElectrons->begin() ;
949  while ((found == false)&&(edElectron != edElectrons->end()))
950  {
951  if (edElectron->gsfTrack()==(*el)->gsfTrack())
952  {
953  found = true ;
954 
955  // CONSTRUCTION D UNE REF dans le handle eventData_->previousElectrons avec l'indice edIndex,
956  // puis recuperation dans la ValueMap ED
957 
959  edElectronRef(eventData_->previousElectrons, edIndex);
961  isoVariables.sumChargedHadronPt =(*(eventData_->edIsolationValues)[0])[edElectronRef];
962  isoVariables.sumPhotonEt =(*(eventData_->edIsolationValues)[1])[edElectronRef];
963  isoVariables.sumNeutralHadronEt =(*(eventData_->edIsolationValues)[2])[edElectronRef];
964  (*el)->setPfIsolationVariables(isoVariables);
965  }
966 
967  edIndex++ ;
968  edElectron++ ;
969  }
970  }
971 
972  // Preselection
974 
975  // Shower Shape of pflow cluster
976  if (!((*el)->parentSuperCluster().isNull()))
977  {
978  reco::GsfElectron::ShowerShape pflowShowerShape ;
979  calculateShowerShape((*el)->parentSuperCluster(),true,pflowShowerShape) ;
980  (*el)->setPfShowerShape(pflowShowerShape) ;
981  }
982  else if ((*el)->passingPflowPreselection())
983  { edm::LogError("GsfElectronCoreProducer")<<"Preselected tracker driven GsfTrack with no associated pflow SuperCluster." ; }
984 
985  // PfBrem
986  SuperClusterRef sc = (*el)->parentSuperCluster() ;
987  if (!(sc.isNull()))
988  {
989 
990  if (sc->clustersSize()>1)
991  {
992  CaloCluster_iterator first = sc->clustersBegin() ;
993  (*el)->setPfSuperClusterFbrem((sc->energy()-(*first)->energy())/sc->energy()) ;
994  }
995  else
996  { (*el)->setPfSuperClusterFbrem(0.) ; }
997  ElectronClassification theClassifier ;
998  theClassifier.refineWithPflow(**el) ;
999  }
1000  }
1001  }
1002 
1004  {
1005  float mvaValue=generalData_->sElectronMVAEstimator->mva( *(ele),*(eventData_->event));
1006  bool passCutBased=ele->passingCutBasedPreselection();
1007  bool passPF=ele->passingPflowPreselection();
1009  bool passmva=mvaValue>generalData_->strategyCfg.PreSelectMVA;
1010  if(!ele->ecalDrivenSeed()){
1012  return passmva && passCutBased;
1013  else
1014  return passmva;
1015  }
1016  else{
1017  return passCutBased || passPF || passmva;
1018  }
1019  }
1020  else{
1021  return passCutBased || passPF;
1022  }
1023 
1024  return true;
1025  }
1026 
1028  {
1029  GsfElectronPtrCollection::size_type ei = 1, emax = eventData_->electrons->size() ;
1030  GsfElectronPtrCollection::iterator eitr = eventData_->electrons->begin() ;
1031  while (eitr!=eventData_->electrons->end())
1032  {
1033  LogTrace("GsfElectronAlgo")<<"========== removed not preselected "<<ei<<"/"<<emax<<"==========" ;
1034  if (isPreselected(*eitr))
1035  { ++eitr ; ++ei ; }
1036  else
1037  { delete (*eitr) ; eitr = eventData_->electrons->erase(eitr) ; ++ei ; }
1038  }
1039  }
1040 
1041 
1043  {
1044  // default value
1045  ele->setPassCutBasedPreselection(false) ;
1046 
1047  // kind of seeding
1048  bool eg = ele->core()->ecalDrivenSeed() ;
1049  bool pf = ele->core()->trackerDrivenSeed() && !ele->core()->ecalDrivenSeed() ;
1050  bool gedMode = generalData_->strategyCfg.gedElectronMode;
1051  if (eg&&pf) { throw cms::Exception("GsfElectronAlgo|BothEcalAndPureTrackerDriven")<<"An electron cannot be both egamma and purely pflow" ; }
1052  if ((!eg)&&(!pf)) { throw cms::Exception("GsfElectronAlgo|NeitherEcalNorPureTrackerDriven")<<"An electron cannot be neither egamma nor purely pflow" ; }
1053 
1054  const CutsConfiguration * cfg = ((eg||gedMode)?&generalData_->cutsCfg:&generalData_->cutsCfgPflow);
1055 
1056  // Et cut
1057  double etaValue = EleRelPoint(ele->superCluster()->position(),bs.position()).eta() ;
1058  double etValue = ele->superCluster()->energy()/cosh(etaValue) ;
1059  LogTrace("GsfElectronAlgo") << "Et : " << etValue ;
1060  if (ele->isEB() && (etValue < cfg->minSCEtBarrel)) return ;
1061  if (ele->isEE() && (etValue < cfg->minSCEtEndcaps)) return ;
1062  LogTrace("GsfElectronAlgo") << "Et criteria are satisfied";
1063 
1064  // E/p cut
1065  double eopValue = ele->eSuperClusterOverP() ;
1066  LogTrace("GsfElectronAlgo") << "E/p : " << eopValue ;
1067  if (ele->isEB() && (eopValue > cfg->maxEOverPBarrel)) return ;
1068  if (ele->isEE() && (eopValue > cfg->maxEOverPEndcaps)) return ;
1069  if (ele->isEB() && (eopValue < cfg->minEOverPBarrel)) return ;
1070  if (ele->isEE() && (eopValue < cfg->minEOverPEndcaps)) return ;
1071  LogTrace("GsfElectronAlgo") << "E/p criteria are satisfied";
1072 
1073  // HoE cuts
1074  LogTrace("GsfElectronAlgo") << "HoE1 : " << ele->hcalDepth1OverEcal() << ", HoE2 : " << ele->hcalDepth2OverEcal();
1075  double had = ele->hcalOverEcal()*ele->superCluster()->energy() ;
1076  const reco::CaloCluster & seedCluster = *(ele->superCluster()->seed()) ;
1077  int detector = seedCluster.hitsAndFractions()[0].first.subdetId() ;
1078  bool HoEveto = false ;
1079  if (detector==EcalBarrel && (had<cfg->maxHBarrel || (had/ele->superCluster()->energy())<cfg->maxHOverEBarrel)) HoEveto=true;
1080  else if (detector==EcalEndcap && (had<cfg->maxHEndcaps || (had/ele->superCluster()->energy())<cfg->maxHOverEEndcaps)) HoEveto=true;
1081  if ( !HoEveto ) return ;
1082  LogTrace("GsfElectronAlgo") << "H/E criteria are satisfied";
1083 
1084  // delta eta criteria
1085  double deta = ele->deltaEtaSuperClusterTrackAtVtx() ;
1086  LogTrace("GsfElectronAlgo") << "delta eta : " << deta ;
1087  if (ele->isEB() && (std::abs(deta) > cfg->maxDeltaEtaBarrel)) return ;
1088  if (ele->isEE() && (std::abs(deta) > cfg->maxDeltaEtaEndcaps)) return ;
1089  LogTrace("GsfElectronAlgo") << "Delta eta criteria are satisfied";
1090 
1091  // delta phi criteria
1092  double dphi = ele->deltaPhiSuperClusterTrackAtVtx();
1093  LogTrace("GsfElectronAlgo") << "delta phi : " << dphi;
1094  if (ele->isEB() && (std::abs(dphi) > cfg->maxDeltaPhiBarrel)) return ;
1095  if (ele->isEE() && (std::abs(dphi) > cfg->maxDeltaPhiEndcaps)) return ;
1096  LogTrace("GsfElectronAlgo") << "Delta phi criteria are satisfied";
1097 
1098  // sigma ieta ieta
1099  LogTrace("GsfElectronAlgo") << "sigma ieta ieta : " << ele->sigmaIetaIeta();
1100  if (ele->isEB() && (ele->sigmaIetaIeta() > cfg->maxSigmaIetaIetaBarrel)) return ;
1101  if (ele->isEE() && (ele->sigmaIetaIeta() > cfg->maxSigmaIetaIetaEndcaps)) return ;
1102  LogTrace("GsfElectronAlgo") << "Sigma ieta ieta criteria are satisfied";
1103 
1104  // fiducial
1105  if (!ele->isEB() && cfg->isBarrel) return ;
1106  if (!ele->isEE() && cfg->isEndcaps) return ;
1107  if (cfg->isFiducial && (ele->isEBEEGap()||ele->isEBEtaGap()||ele->isEBPhiGap()||ele->isEERingGap()||ele->isEEDeeGap())) return ;
1108  LogTrace("GsfElectronAlgo") << "Fiducial flags criteria are satisfied";
1109 
1110  // seed in TEC
1111  edm::RefToBase<TrajectorySeed> seed = ele->gsfTrack()->extra()->seedRef() ;
1112  ElectronSeedRef elseed = seed.castTo<ElectronSeedRef>() ;
1113  if (eg && !generalData_->cutsCfg.seedFromTEC)
1114  {
1115  if (elseed.isNull())
1116  { throw cms::Exception("GsfElectronAlgo|NotElectronSeed")<<"The GsfTrack seed is not an ElectronSeed ?!" ; }
1117  else
1118  { if (elseed->subDet2()==6) return ; }
1119  }
1120 
1121  // transverse impact parameter
1122  if (std::abs(ele->gsfTrack()->dxy(bs.position()))>cfg->maxTIP) return ;
1123  LogTrace("GsfElectronAlgo") << "TIP criterion is satisfied" ;
1124 
1125  LogTrace("GsfElectronAlgo") << "All cut based criteria are satisfied" ;
1126  ele->setPassCutBasedPreselection(true) ;
1127  }
1128 
1130  {
1131  ele->setPassMvaPreselection(false) ;
1132 
1133  if (ele->core()->ecalDrivenSeed())
1134  { if (ele->mvaOutput().mva>=generalData_->cutsCfg.minMVA) ele->setPassMvaPreselection(true) ; }
1135  else
1136  { if (ele->mvaOutput().mva>=generalData_->cutsCfgPflow.minMVA) ele->setPassMvaPreselection(true) ; }
1137 
1138  if (ele->passingMvaPreselection())
1139  { LogTrace("GsfElectronAlgo") << "Main mva criterion is satisfied" ; }
1140 
1142 
1143 // ele->setPassPflowPreselection(false) ;
1144 // if (ele->core()->ecalDrivenSeed())
1145 // {
1146 // if ((ele->mvaOutput().mva>=generalData_->cutsCfg.minMVA) ||
1147 // (ele->mvaOutput().mvaByPassForIsolated>=generalData_->cutsCfg.minMvaByPassForIsolated))
1148 // ele->setPassPflowPreselection(true) ;
1149 // }
1150 // else
1151 // {
1152 // if ((ele->mvaOutput().mva>=generalData_->cutsCfgPflow.minMVA) ||
1153 // (ele->mvaOutput().mvaByPassForIsolated>=generalData_->cutsCfgPflow.minMvaByPassForIsolated))
1154 // ele->setPassPflowPreselection(true) ;
1155 // }
1156 // if (ele->passingPflowPreselection())
1157 // { LogTrace("GsfElectronAlgo") << "Mva criteria are satisfied" ; }
1158  }
1159 
1160 void GsfElectronAlgo::setMVAInputs(const std::map<reco::GsfTrackRef,reco::GsfElectron::MvaInput> & mvaInputs)
1161 {
1162  GsfElectronPtrCollection::iterator el ;
1163  for
1164  ( el = eventData_->electrons->begin() ;
1165  el != eventData_->electrons->end() ;
1166  el++ )
1167  {
1168  std::map<reco::GsfTrackRef,reco::GsfElectron::MvaInput>::const_iterator itcheck=mvaInputs.find((*el)->gsfTrack());
1169  (*el)->setMvaInput(itcheck->second);
1170  }
1171 }
1172 
1173 void GsfElectronAlgo::setMVAOutputs(const std::map<reco::GsfTrackRef,reco::GsfElectron::MvaOutput> & mvaOutputs)
1174 {
1175  GsfElectronPtrCollection::iterator el ;
1176  for
1177  ( el = eventData_->electrons->begin() ;
1178  el != eventData_->electrons->end() ;
1179  el++ )
1180  {
1182  float mvaValue=generalData_->sElectronMVAEstimator->mva( *(*el),*(eventData_->event));
1183  GsfElectron::MvaOutput mvaOutput ;
1184  mvaOutput.mva = mvaValue ;
1185  (*el)->setMvaOutput(mvaOutput);
1186  }
1187  else{
1188  std::map<reco::GsfTrackRef,reco::GsfElectron::MvaOutput>::const_iterator itcheck=mvaOutputs.find((*el)->gsfTrack());
1189  (*el)->setMvaOutput(itcheck->second);
1190  }
1191  }
1192 }
1193 
1195  {
1196  // eventually check ctf track
1199 
1200  // charge ID
1201  int eleCharge ;
1202  GsfElectron::ChargeInfo eleChargeInfo ;
1203  electronData_->computeCharge(eleCharge,eleChargeInfo) ;
1204 
1205  // electron basic cluster
1207 
1208  // Seed cluster
1209  const reco::CaloCluster & seedCluster = *(electronData_->superClusterRef->seed()) ;
1210 
1211  // seed Xtal
1212  // temporary, till CaloCluster->seed() is made available
1213  DetId seedXtalId = seedCluster.hitsAndFractions()[0].first ;
1214 
1216 
1217 
1218  //====================================================
1219  // Candidate attributes
1220  //====================================================
1221 
1223 
1224 
1225  //====================================================
1226  // Track-Cluster Matching
1227  //====================================================
1228 
1230  tcMatching.electronCluster = elbcRef ;
1231  tcMatching.eSuperClusterOverP = (electronData_->vtxMom.mag()>0)?(electronData_->superClusterRef->energy()/electronData_->vtxMom.mag()):(-1.) ;
1232  tcMatching.eSeedClusterOverP = (electronData_->vtxMom.mag()>0.)?(seedCluster.energy()/electronData_->vtxMom.mag()):(-1) ;
1233  tcMatching.eSeedClusterOverPout = (electronData_->seedMom.mag()>0.)?(seedCluster.energy()/electronData_->seedMom.mag()):(-1.) ;
1234  tcMatching.eEleClusterOverPout = (electronData_->eleMom.mag()>0.)?(elbcRef->energy()/electronData_->eleMom.mag()):(-1.) ;
1235 
1237  tcMatching.deltaEtaSuperClusterAtVtx = scAtVtx.dEta() ;
1238  tcMatching.deltaPhiSuperClusterAtVtx = scAtVtx.dPhi() ;
1239 
1240  EleRelPointPair seedAtCalo(seedCluster.position(),electronData_->seedPos,eventData_->beamspot->position()) ;
1241  tcMatching.deltaEtaSeedClusterAtCalo = seedAtCalo.dEta() ;
1242  tcMatching.deltaPhiSeedClusterAtCalo = seedAtCalo.dPhi() ;
1243 
1244  EleRelPointPair ecAtCalo(elbcRef->position(),electronData_->elePos,eventData_->beamspot->position()) ;
1245  tcMatching.deltaEtaEleClusterAtCalo = ecAtCalo.dEta() ;
1246  tcMatching.deltaPhiEleClusterAtCalo = ecAtCalo.dPhi() ;
1247 
1248 
1249  //=======================================================
1250  // Track extrapolations
1251  //=======================================================
1252 
1261 
1262 
1263  //=======================================================
1264  // Closest Ctf Track
1265  //=======================================================
1266 
1268  ctfInfo.ctfTrack = electronData_->ctfTrackRef ;
1270 
1271 
1272  //====================================================
1273  // FiducialFlags, using nextToBoundary definition of gaps
1274  //====================================================
1275 
1276  reco::GsfElectron::FiducialFlags fiducialFlags ;
1277  int detector = seedXtalId.subdetId() ;
1278  double feta=std::abs(electronData_->superClusterRef->position().eta()) ;
1279  if (detector==EcalBarrel)
1280  {
1281  fiducialFlags.isEB = true ;
1282  EBDetId ebdetid(seedXtalId);
1283  if (EBDetId::isNextToEtaBoundary(ebdetid))
1284  {
1285  if (ebdetid.ietaAbs()==85)
1286  { fiducialFlags.isEBEEGap = true ; }
1287  else
1288  { fiducialFlags.isEBEtaGap = true ; }
1289  }
1290  if (EBDetId::isNextToPhiBoundary(ebdetid))
1291  { fiducialFlags.isEBPhiGap = true ; }
1292  }
1293  else if (detector==EcalEndcap)
1294  {
1295  fiducialFlags.isEE = true ;
1296  EEDetId eedetid(seedXtalId);
1297  if (EEDetId::isNextToRingBoundary(eedetid))
1298  {
1299  if (std::abs(feta)<2.)
1300  { fiducialFlags.isEBEEGap = true ; }
1301  else
1302  { fiducialFlags.isEERingGap = true ; }
1303  }
1304  if (EEDetId::isNextToDBoundary(eedetid))
1305  { fiducialFlags.isEEDeeGap = true ; }
1306  }
1307  else
1308  { throw cms::Exception("GsfElectronAlgo|UnknownXtalRegion")<<"createElectron(): do not know if it is a barrel or endcap seed cluster !!!!" ; }
1309 
1310 
1311  //====================================================
1312  // ShowerShape
1313  //====================================================
1314 
1315  reco::GsfElectron::ShowerShape showerShape ;
1316  calculateShowerShape(electronData_->superClusterRef,!(electronData_->coreRef->ecalDrivenSeed()),showerShape) ;
1317 
1318 
1319  //====================================================
1320  // ConversionRejection
1321  //====================================================
1322 
1324 
1325  ConversionFinder conversionFinder ;
1326  double BInTesla = eventSetupData_->magField->inTesla(GlobalPoint(0.,0.,0.)).z() ;
1328  if (!ctfTracks.isValid()) { ctfTracks = eventData_->currentCtfTracks ; }
1329 
1330  // values of conversionInfo.flag()
1331  // -9999 : Partner track was not found
1332  // 0 : Partner track found in the CTF collection using
1333  // 1 : Partner track found in the CTF collection using
1334  // 2 : Partner track found in the GSF collection using
1335  // 3 : Partner track found in the GSF collection using the electron's GSF track
1336  ConversionInfo conversionInfo = conversionFinder.getConversionInfo
1337  (*electronData_->coreRef,ctfTracks,eventData_->originalGsfTracks,BInTesla) ;
1338 
1340  conversionVars.flags = conversionInfo.flag() ;
1341  conversionVars.dist = conversionInfo.dist() ;
1342  conversionVars.dcot = conversionInfo.dcot() ;
1343  conversionVars.radius = conversionInfo.radiusOfConversion() ;
1344  if ((conversionVars.flags==0)or(conversionVars.flags==1))
1345  conversionVars.partner = TrackBaseRef(conversionInfo.conversionPartnerCtfTk()) ;
1346  else if ((conversionVars.flags==2)or(conversionVars.flags==3))
1347  conversionVars.partner = TrackBaseRef(conversionInfo.conversionPartnerGsfTk()) ;
1348 
1349 
1350  //====================================================
1351  // Go !
1352  //====================================================
1353 
1354  GsfElectron * ele = new
1355  GsfElectron
1356  ( eleCharge,eleChargeInfo,electronData_->coreRef,
1357  tcMatching, tkExtra, ctfInfo,
1358  fiducialFlags,showerShape,
1359  conversionVars ) ;
1360  // Will be overwritten later in the case of the regression
1362  ele->setP4(GsfElectron::P4_FROM_SUPER_CLUSTER,momentum,0,true) ;
1363 
1364 
1365  //====================================================
1366  // brems fractions
1367  //====================================================
1368 
1369  if (electronData_->innMom.mag()>0.)
1371 
1372  SuperClusterRef sc = ele->superCluster() ;
1373  if (!(sc.isNull()))
1374  {
1375  CaloClusterPtr cl = ele->electronCluster() ;
1376  if (sc->clustersSize()>1)
1377  { ele->setSuperClusterFbrem( ( sc->energy() - cl->energy() ) / sc->energy() ) ; }
1378  else
1379  { ele->setSuperClusterFbrem(0) ; }
1380  }
1381 
1382 
1383  //====================================================
1384  // classification and corrections
1385  //====================================================
1386  // classification
1387  ElectronClassification theClassifier ;
1388  theClassifier.classify(*ele) ;
1389 
1390  // ecal energy
1393  {
1398  }
1399  else // original implementation
1400  {
1401  if (ele->core()->ecalDrivenSeed())
1402  {
1404  { theEnCorrector.classBasedParameterizationEnergy(*ele,*eventData_->beamspot) ; }
1406  { theEnCorrector.classBasedParameterizationUncertainty(*ele) ; }
1407  }
1408  else
1409  {
1411  { theEnCorrector.simpleParameterizationUncertainty(*ele) ; }
1412  }
1413  }
1414 
1415  // momentum
1416  // Keep the default correction running first. The track momentum error is computed in there
1417  if (ele->core()->ecalDrivenSeed())
1418  {
1419  ElectronMomentumCorrector theMomCorrector;
1420  theMomCorrector.correct(*ele,electronData_->vtxTSOS);
1421  }
1423  {
1425  }
1426 
1427  //====================================================
1428  // now isolation variables
1429  //====================================================
1430 
1444  ele->setIsolation03(dr03);
1445  ele->setIsolation04(dr04);
1446 
1447 
1448  //====================================================
1449  // preselection flag
1450  //====================================================
1451 
1453 
1454  LogTrace("GsfElectronAlgo")<<"Constructed new electron with energy "<< ele->p4().e() ;
1455 
1456  eventData_->electrons->push_back(ele) ;
1457  }
1458 
1459 
1460 //=======================================================================================
1461 // Ambiguity solving
1462 //=======================================================================================
1463 
1464 //bool better_electron( const reco::GsfElectron * e1, const reco::GsfElectron * e2 )
1465 // { return (std::abs(e1->eSuperClusterOverP()-1)<std::abs(e2->eSuperClusterOverP()-1)) ; }
1466 
1467 void GsfElectronAlgo::setAmbiguityData( bool ignoreNotPreselected )
1468  {
1469  GsfElectronPtrCollection::iterator e1, e2 ;
1474  else
1475  { throw cms::Exception("GsfElectronAlgo|UnknownAmbiguitySortingStrategy")<<"value of generalData_->strategyCfg.ambSortingStrategy is : "<<generalData_->strategyCfg.ambSortingStrategy ; }
1476 
1477  // init
1478  for
1479  ( e1 = eventData_->electrons->begin() ;
1480  e1 != eventData_->electrons->end() ;
1481  ++e1 )
1482  {
1483  (*e1)->clearAmbiguousGsfTracks() ;
1484  (*e1)->setAmbiguous(false) ;
1485  }
1486 
1487  // get ambiguous from GsfPfRecTracks
1489  {
1490  for
1491  ( e1 = eventData_->electrons->begin() ;
1492  e1 != eventData_->electrons->end() ;
1493  ++e1 )
1494  {
1495  bool found = false ;
1496  const GsfPFRecTrackCollection * gsfPfRecTrackCollection = eventData_->gsfPfRecTracks.product() ;
1497  GsfPFRecTrackCollection::const_iterator gsfPfRecTrack ;
1498  for ( gsfPfRecTrack=gsfPfRecTrackCollection->begin() ;
1499  gsfPfRecTrack!=gsfPfRecTrackCollection->end() ;
1500  ++gsfPfRecTrack )
1501  {
1502  if (gsfPfRecTrack->gsfTrackRef()==(*e1)->gsfTrack())
1503  {
1504  if (found)
1505  {
1506  edm::LogWarning("GsfElectronAlgo")<<"associated gsfPfRecTrack already found" ;
1507  }
1508  else
1509  {
1510  found = true ;
1511  const std::vector<reco::GsfPFRecTrackRef> & duplicates(gsfPfRecTrack->convBremGsfPFRecTrackRef()) ;
1512  std::vector<reco::GsfPFRecTrackRef>::const_iterator duplicate ;
1513  for ( duplicate = duplicates.begin() ; duplicate != duplicates.end() ; duplicate ++ )
1514  { (*e1)->addAmbiguousGsfTrack((*duplicate)->gsfTrackRef()) ; }
1515  }
1516  }
1517  }
1518  }
1519  }
1520  // or search overlapping clusters
1521  else
1522  {
1523  for
1524  ( e1 = eventData_->electrons->begin() ;
1525  e1 != eventData_->electrons->end() ;
1526  ++e1 )
1527  {
1528  if ((*e1)->ambiguous()) continue ;
1529  if ( ignoreNotPreselected && !isPreselected(*e1) ) continue ;
1530 
1531  SuperClusterRef scRef1 = (*e1)->superCluster();
1532  CaloClusterPtr eleClu1 = (*e1)->electronCluster();
1533  LogDebug("GsfElectronAlgo")
1534  << "Blessing electron with E/P " << (*e1)->eSuperClusterOverP()
1535  << ", cluster " << scRef1.get()
1536  << " & track " << (*e1)->gsfTrack().get() ;
1537 
1538  for
1539  ( e2 = e1, ++e2 ;
1540  e2 != eventData_->electrons->end() ;
1541  ++e2 )
1542  {
1543  if ((*e2)->ambiguous()) continue ;
1544  if ( ignoreNotPreselected && !isPreselected(*e2) ) continue ;
1545 
1546  SuperClusterRef scRef2 = (*e2)->superCluster();
1547  CaloClusterPtr eleClu2 = (*e2)->electronCluster();
1548 
1549  // search if same cluster
1550  bool sameCluster = false ;
1552  { sameCluster = (scRef1==scRef2) ; }
1554  {
1555  float eMin = 1. ;
1556  float threshold = eMin*cosh(EleRelPoint(scRef1->position(),eventData_->beamspot->position()).eta()) ;
1557  sameCluster =
1559  (EgAmbiguityTools::sharedEnergy(&(*scRef1->seed()),&(*eleClu2),eventData_->barrelRecHits,eventData_->endcapRecHits)>=threshold) ||
1561  (EgAmbiguityTools::sharedEnergy(&(*scRef1->seed()),&(*scRef2->seed()),eventData_->barrelRecHits,eventData_->endcapRecHits)>=threshold) ) ;
1562  }
1563  else
1564  { throw cms::Exception("GsfElectronAlgo|UnknownAmbiguityClustersOverlapStrategy")<<"value of generalData_->strategyCfg.ambClustersOverlapStrategy is : "<<generalData_->strategyCfg.ambClustersOverlapStrategy ; }
1565 
1566  // main instructions
1567  if (sameCluster)
1568  {
1569  LogDebug("GsfElectronAlgo")
1570  << "Discarding electron with E/P " << (*e2)->eSuperClusterOverP()
1571  << ", cluster " << scRef2.get()
1572  << " and track " << (*e2)->gsfTrack().get() ;
1573  (*e1)->addAmbiguousGsfTrack((*e2)->gsfTrack()) ;
1574  (*e2)->setAmbiguous(true) ;
1575  }
1576  else if ((*e1)->gsfTrack()==(*e2)->gsfTrack())
1577  {
1578  edm::LogWarning("GsfElectronAlgo")
1579  << "Forgetting electron with E/P " << (*e2)->eSuperClusterOverP()
1580  << ", cluster " << scRef2.get()
1581  << " and track " << (*e2)->gsfTrack().get() ;
1582  (*e2)->setAmbiguous(true) ;
1583  }
1584  }
1585  }
1586  }
1587  }
1588 
1590  {
1591  GsfElectronPtrCollection::size_type ei = 1, emax = eventData_->electrons->size() ;
1592  GsfElectronPtrCollection::iterator eitr = eventData_->electrons->begin() ;
1593  while (eitr!=eventData_->electrons->end())
1594  {
1595  LogTrace("GsfElectronAlgo")<<"========== remove ambiguous "<<ei<<"/"<<emax<<"==========" ;
1596  if ((*eitr)->ambiguous())
1597  { delete (*eitr) ; eitr = eventData_->electrons->erase(eitr) ; ++ei ; }
1598  else
1599  { ++eitr ; ++ei ; }
1600  }
1601  }
1602 
1603 
#define LogDebug(id)
TrajectoryStateOnSurface constrainAtBeamSpot(const reco::GsfTrack &, const reco::BeamSpot &) const
(multi)TSOS after including the beamspot
CaloClusterPtr electronCluster() const
Definition: GsfElectron.h:228
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:649
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:178
GeneralData * generalData_
const CutsConfiguration cutsCfgPflow
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:600
bool positionFromModeCartesian(const TrajectoryStateOnSurface tsos, GlobalPoint &position) const
edm::EDGetTokenT< reco::GsfElectronCoreCollection > gsfElectronCores
bool isEBEtaGap() const
Definition: GsfElectron.h:335
void readEvent(const edm::Event &)
EgammaTowerIsolation * hadDepth1Isolation03Bc
double radiusOfConversion() const
void clonePreviousElectrons()
const LorentzVector & p4(P4Kind kind) const
Definition: GsfElectron.cc:204
float eSuperClusterOverP() const
Definition: GsfElectron.h:229
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 *)
void retreiveOriginalTrackCollections(const reco::TrackRef &, const reco::GsfTrackRef &)
bool isEBEEGap() const
Definition: GsfElectron.h:333
float hcalDepth2OverEcal() const
Definition: GsfElectron.h:389
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:10
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:339
bool passingCutBasedPreselection() const
Definition: GsfElectron.h:592
bool passingMvaPreselection() const
Definition: GsfElectron.h:608
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:338
double charge(const std::vector< uint8_t > &Ampls)
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:331
bool isEB() const
Definition: GsfElectron.h:330
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 &mvaCfg, const RegressionHelper::Configuration &regCfg)
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
reco::TrackRef conversionPartnerCtfTk() const
static std::vector< float > covariances(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, const CaloGeometry *geometry, float w0=4.7)
void setSuperClusterFbrem(float fbrem)
Definition: GsfElectron.h:650
static bool stripTIDHitFilter(uint32_t pattern)
Definition: HitPattern.h:451
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
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
ElectronTkIsolation * tkIsolation03
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 &mvaCfg, const RegressionHelper::Configuration &)
void setUseNumCrystals(bool b=true)
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:233
void setCorrectedEcalEnergyError(float newEnergyError)
Definition: GsfElectron.cc:158
bool isNull() const
Checks for null.
Definition: Ref.h:247
T mag() const
Definition: PV3DBase.h:67
float sigmaIetaIeta() const
Definition: GsfElectron.h:382
bool isNotFinite(T x)
Definition: isFinite.h:10
static std::vector< float > localCovariances(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, float w0=4.7)
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:22
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:168
GsfConstraintAtVertex * constraintAtVtx
static bool isNextToPhiBoundary(EBDetId id)
Definition: EBDetId.cc:130
float sumPhotonEt
sum pt of PF photons // old float photonIso ;
Definition: GsfElectron.h:520
edm::Handle< EcalRecHitCollection > barrelRecHits
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:236
std::vector< GsfElectronCore > GsfElectronCoreCollection
void correct(reco::GsfElectron &, TrajectoryStateOnSurface &)
static bool pixelHitFilter(uint32_t pattern)
Definition: HitPattern.h:412
float hcalOverEcal() const
Definition: GsfElectron.h:390
static float e3x3(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
void setPassMvaPreselection(bool flag)
Definition: GsfElectron.h:607
IsolationValueMaps pfIsolationValues
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< CaloTowerDetId > hcalTowersBehindClusters
Definition: GsfElectron.h:366
const MultiTrajectoryStateTransform * mtsTransform
int j
Definition: DBlmapReader.cc:9
static bool isNextToRingBoundary(EEDetId id)
Definition: EEDetId.cc:375
std::list< reco::GsfElectron * > GsfElectronPtrCollection
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:519
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:79
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
void setIsolation04(const IsolationVariables &dr04)
Definition: GsfElectron.h:463
#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:388
std::vector< edm::Handle< edm::ValueMap< double > > > IsolationValueMaps
Float e1
Definition: deltaR.h:22
Definition: DetId.h:18
void classBasedParameterizationEnergy(reco::GsfElectron &, const reco::BeamSpot &bs)
edm::Handle< reco::VertexCollection > vertices
EgammaRecHitIsolation * ecalBarrelIsol03
edm::Handle< reco::GsfElectronCollection > pflowElectrons
EcalRecHitMetaCollection * ecalBarrelHitsMeta
int flag() const
EcalClusterFunctionBaseClass * superClusterErrorFunction
const T & get() const
Definition: EventSetup.h:55
REF castTo() const
cast to a concrete type
Definition: RefToBase.h:241
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:14
void setPflowPreselectionFlag(reco::GsfElectron *ele)
const MvaOutput & mvaOutput() const
Definition: GsfElectron.h:565
T const * product() const
Definition: ESHandle.h:62
const reco::GsfTrackRef gsfTrackRef
void ele_convert(const Type1 &obj1, Type2 &obj2)
void setMVAOutputs(const std::map< reco::GsfTrackRef, reco::GsfElectron::MvaOutput > &mvaOutputs)
T const * product() const
Definition: Handle.h:81
bool calculateTSOS(const MultiTrajectoryStateTransform *, GsfConstraintAtVertex *)
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:41
virtual GsfElectronCoreRef core() const
Definition: GsfElectron.cc:8
Float e2
Definition: deltaR.h:23
return(e1-e2)*(e1-e2)+dp *dp
double mva(const reco::GsfElectron &myElectron, const edm::Event &evt)
math::XYZVectorF momentumAtVtxWithConstraint
Definition: GsfElectron.h:266
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:462
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)
SimpleCaloRecHitMetaCollection< EcalRecHitCollection > EcalRecHitMetaCollection
static std::atomic< unsigned int > counter
const reco::GsfElectronCoreRef coreRef
bool isEBPhiGap() const
Definition: GsfElectron.h:336
edm::Handle< reco::TrackCollection > currentCtfTracks
static float e2x5Max(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
double getTowerEtSum(const reco::Candidate *cand, const std::vector< CaloTowerDetId > *detIdToExclude=0) const
edm::ESHandle< CaloGeometry > caloGeom
EcalClusterFunctionBaseClass * crackCorrectionFunction
void removeAmbiguousElectrons()
static float e5x5(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
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:601
EgammaRecHitIsolation * ecalEndcapIsol04
static float e1x5(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_
double dcot() const
TrajectoryStateOnSurface outTSOS
RegressionHelper * regHelper
ElectronData(const reco::GsfElectronCoreRef &core, const reco::BeamSpot &bs)
void copyElectrons(reco::GsfElectronCollection &)
ProductID id() const
Accessor for product ID.
Definition: Ref.h:256
ElectronTkIsolation * tkIsolation04
volatile std::atomic< bool > shutdown_flag false
double pi
ElectronData * electronData_
edm::ESHandle< TrackerGeometry > trackerHandle
void setAmbiguityData(bool ignoreNotPreselected=true)
IsolationValueMaps edIsolationValues
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:242
virtual float pt() const GCC11_FINAL
transverse momentum
uint32_t getHitPattern(int position) const
Definition: HitPattern.cc:144
float sumChargedHadronPt
sum-pt of charged Hadron // old float chargedHadronIso ;
Definition: GsfElectron.h:518
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 &)
void checkSetup(const edm::EventSetup &)
edm::Handle< CaloTowerCollection > towers
void calculateMode(const MultiTrajectoryStateMode *mtsMode)
math::PtEtaPhiELorentzVectorF LorentzVector
EcalRecHitMetaCollection * ecalEndcapHitsMeta
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:169
bool ecalDrivenSeed() const
Definition: GsfElectron.h:172
static bool stripTIBHitFilter(uint32_t pattern)
Definition: HitPattern.h:444
Candidate::LorentzVector calculateMomentum()
bool passingPflowPreselection() const
Definition: GsfElectron.h:593
const reco::BeamSpot beamSpot