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 ;
213  EgammaRecHitIsolation * ecalBarrelIsol03, * ecalBarrelIsol04 ;
214  EgammaRecHitIsolation * ecalEndcapIsol03, * ecalEndcapIsol04 ;
215 
216  //Isolation Value Maps for PF and EcalDriven electrons
217  typedef std::vector< edm::Handle< edm::ValueMap<double> > > IsolationValueMaps;
220  } ;
221 
223  : event(0), beamspot(0),
224  originalCtfTrackCollectionRetreived(false),
225  originalGsfTrackCollectionRetreived(false),
226  tkIsolation03(0), tkIsolation04(0),
227  hadDepth1Isolation03(0), hadDepth1Isolation04(0),
228  hadDepth2Isolation03(0), hadDepth2Isolation04(0),
229  ecalBarrelIsol03(0), ecalBarrelIsol04(0),
230  ecalEndcapIsol03(0), ecalEndcapIsol04(0)
231  {
233  }
234 
236  {
237  delete tkIsolation03 ;
238  delete tkIsolation04 ;
239  delete hadDepth1Isolation03 ;
240  delete hadDepth1Isolation04 ;
241  delete hadDepth2Isolation03 ;
242  delete hadDepth2Isolation04 ;
243  delete ecalBarrelIsol03 ;
244  delete ecalBarrelIsol04 ;
245  delete ecalEndcapIsol03 ;
246  delete ecalEndcapIsol04 ;
247 
248  GsfElectronPtrCollection::const_iterator it ;
249  for ( it = electrons->begin() ; it != electrons->end() ; it++ )
250  { delete (*it) ; }
251  delete electrons ;
252  }
253 
255  ( const reco::TrackRef & ctfTrack, const reco::GsfTrackRef & gsfTrack )
256  {
257  if ((!originalCtfTrackCollectionRetreived)&&(ctfTrack.isNonnull()))
258  {
259  event->get(ctfTrack.id(),originalCtfTracks) ;
260  originalCtfTrackCollectionRetreived = true ;
261  }
262  if ((!originalGsfTrackCollectionRetreived)&&(gsfTrack.isNonnull()))
263  {
264  event->get(gsfTrack.id(),originalGsfTracks) ;
265  originalGsfTrackCollectionRetreived = true ;
266  }
267  }
268 
269 
270 //===================================================================
271 // GsfElectronAlgo::ElectronData
272 //===================================================================
273 
275  {
276  // Refs to subproducts
283 
284  // constructors
286  ( const reco::GsfElectronCoreRef & core,
287  const reco::BeamSpot & bs ) ;
288  ~ElectronData() ;
289 
290  // utilities
291  void checkCtfTrack( edm::Handle<reco::TrackCollection> currentCtfTracks ) ;
292  void computeCharge( int & charge, reco::GsfElectron::ChargeInfo & info ) ;
293  CaloClusterPtr getEleBasicCluster( const MultiTrajectoryStateTransform * ) ;
294  bool calculateTSOS( const MultiTrajectoryStateTransform *, GsfConstraintAtVertex * ) ;
295  void calculateMode( const MultiTrajectoryStateMode * mtsMode ) ;
296  Candidate::LorentzVector calculateMomentum() ;
297 
298  // TSOS
306 
307  // mode
308  GlobalVector innMom, seedMom, eleMom, sclMom, vtxMom, outMom ;
309  GlobalPoint innPos, seedPos, elePos, sclPos, vtxPos, outPos ;
311  } ;
312 
314  ( const reco::GsfElectronCoreRef & core,
315  const reco::BeamSpot & bs )
316  : coreRef(core),
317  gsfTrackRef(coreRef->gsfTrack()),
318  superClusterRef(coreRef->superCluster()),
319  ctfTrackRef(coreRef->ctfTrack()), shFracInnerHits(coreRef->ctfGsfOverlap()),
320  beamSpot(bs)
321  {}
322 
324  {}
325 
327  {
328  if (!ctfTrackRef.isNull()) return ;
329 
330  // Code below from Puneeth Kalavase
331 
332  shFracInnerHits = 0 ;
333  const TrackCollection * ctfTrackCollection = currentCtfTracks.product() ;
334 
335  // get the Hit Pattern for the gsfTrack
336  const HitPattern & gsfHitPattern = gsfTrackRef->hitPattern() ;
337 
338  unsigned int counter ;
339  TrackCollection::const_iterator ctfTkIter ;
340  for ( ctfTkIter = ctfTrackCollection->begin() , counter = 0 ;
341  ctfTkIter != ctfTrackCollection->end() ; ctfTkIter++, counter++ )
342  {
343 
344  double dEta = gsfTrackRef->eta() - ctfTkIter->eta() ;
345  double dPhi = gsfTrackRef->phi() - ctfTkIter->phi() ;
346  double pi = acos(-1.);
347  if(std::abs(dPhi) > pi) dPhi = 2*pi - std::abs(dPhi) ;
348 
349  // dont want to look at every single track in the event!
350  if (sqrt(dEta*dEta + dPhi*dPhi) > 0.3) continue ;
351 
352  unsigned int shared = 0 ;
353  int gsfHitCounter = 0 ;
354  int numGsfInnerHits = 0 ;
355  int numCtfInnerHits = 0 ;
356 
357  // get the CTF Track Hit Pattern
358  const HitPattern & ctfHitPattern = ctfTkIter->hitPattern() ;
359 
360  trackingRecHit_iterator elHitsIt ;
361  for ( elHitsIt = gsfTrackRef->recHitsBegin() ;
362  elHitsIt != gsfTrackRef->recHitsEnd() ;
363  elHitsIt++, gsfHitCounter++ )
364  {
365  if (!((**elHitsIt).isValid())) //count only valid Hits
366  { continue ; }
367 
368  // look only in the pixels/TIB/TID
369  uint32_t gsfHit = gsfHitPattern.getHitPattern(gsfHitCounter) ;
370  if (!(gsfHitPattern.pixelHitFilter(gsfHit) ||
371  gsfHitPattern.stripTIBHitFilter(gsfHit) ||
372  gsfHitPattern.stripTIDHitFilter(gsfHit) ) )
373  { continue ; }
374 
375  numGsfInnerHits++ ;
376 
377  int ctfHitsCounter = 0 ;
378  numCtfInnerHits = 0 ;
379  trackingRecHit_iterator ctfHitsIt ;
380  for ( ctfHitsIt = ctfTkIter->recHitsBegin() ;
381  ctfHitsIt != ctfTkIter->recHitsEnd() ;
382  ctfHitsIt++, ctfHitsCounter++ )
383  {
384  if(!((**ctfHitsIt).isValid())) //count only valid Hits!
385  { continue ; }
386 
387  uint32_t ctfHit = ctfHitPattern.getHitPattern(ctfHitsCounter);
388  if( !(ctfHitPattern.pixelHitFilter(ctfHit) ||
389  ctfHitPattern.stripTIBHitFilter(ctfHit) ||
390  ctfHitPattern.stripTIDHitFilter(ctfHit) ) )
391  { continue ; }
392 
393  numCtfInnerHits++ ;
394 
395  if( (**elHitsIt).sharesInput(&(**ctfHitsIt),TrackingRecHit::all) )
396  {
397  shared++ ;
398  break ;
399  }
400 
401  } //ctfHits iterator
402 
403  } //gsfHits iterator
404 
405  if ((numGsfInnerHits==0)||(numCtfInnerHits==0))
406  { continue ; }
407 
408  if ( static_cast<float>(shared)/min(numGsfInnerHits,numCtfInnerHits) > shFracInnerHits )
409  {
410  shFracInnerHits = static_cast<float>(shared)/min(numGsfInnerHits, numCtfInnerHits);
411  ctfTrackRef = TrackRef(currentCtfTracks,counter);
412  }
413  } //ctfTrack iterator
414  }
415 
418  {
419  // determine charge from SC
420  GlobalPoint orig, scpos ;
421  ele_convert(beamSpot.position(),orig) ;
422  ele_convert(superClusterRef->position(),scpos) ;
423  GlobalVector scvect(scpos-orig) ;
424  GlobalPoint inntkpos = innTSOS.globalPosition() ;
425  GlobalVector inntkvect = GlobalVector(inntkpos-orig) ;
426  float dPhiInnEle=normalized_phi(scvect.phi()-inntkvect.phi()) ;
427  if(dPhiInnEle>0) info.scPixCharge = -1 ;
428  else info.scPixCharge = 1 ;
429 
430  // flags
431  int chargeGsf = gsfTrackRef->charge() ;
432  info.isGsfScPixConsistent = ((chargeGsf*info.scPixCharge)>0) ;
433  info.isGsfCtfConsistent = (ctfTrackRef.isNonnull()&&((chargeGsf*ctfTrackRef->charge())>0)) ;
435 
436  // default charge
437  if (info.isGsfScPixConsistent||ctfTrackRef.isNull())
438  { charge = info.scPixCharge ; }
439  else
440  { charge = ctfTrackRef->charge() ; }
441  }
442 
444  ( const MultiTrajectoryStateTransform * mtsTransform )
445  {
446  CaloClusterPtr eleRef ;
447  TrajectoryStateOnSurface tempTSOS ;
448  TrajectoryStateOnSurface outTSOS = mtsTransform->outerStateOnSurface(*gsfTrackRef) ;
449  float dphimin = 1.e30 ;
450  for (CaloCluster_iterator bc=superClusterRef->clustersBegin(); bc!=superClusterRef->clustersEnd(); bc++)
451  {
452  GlobalPoint posclu((*bc)->position().x(),(*bc)->position().y(),(*bc)->position().z()) ;
453  tempTSOS = mtsTransform->extrapolatedState(outTSOS,posclu) ;
454  if (!tempTSOS.isValid()) tempTSOS=outTSOS ;
455  GlobalPoint extrap = tempTSOS.globalPosition() ;
456  float dphi = EleRelPointPair(posclu,extrap,beamSpot.position()).dPhi() ;
457  if (std::abs(dphi)<dphimin)
458  {
459  dphimin = std::abs(dphi) ;
460  eleRef = (*bc);
461  eleTSOS = tempTSOS ;
462  }
463  }
464  return eleRef ;
465  }
466 
468  ( const MultiTrajectoryStateTransform * mtsTransform, GsfConstraintAtVertex * constraintAtVtx )
469  {
470  //at innermost point
471  innTSOS = mtsTransform->innerStateOnSurface(*gsfTrackRef);
472  if (!innTSOS.isValid()) return false;
473 
474  //at vertex
475  // innermost state propagation to the beam spot position
476  GlobalPoint bsPos ;
477  ele_convert(beamSpot.position(),bsPos) ;
478  vtxTSOS = mtsTransform->extrapolatedState(innTSOS,bsPos) ;
479  if (!vtxTSOS.isValid()) vtxTSOS=innTSOS;
480 
481  //at seed
482  outTSOS = mtsTransform->outerStateOnSurface(*gsfTrackRef);
483  if (!outTSOS.isValid()) return false;
484 
485  // TrajectoryStateOnSurface seedTSOS
486  seedTSOS = mtsTransform->extrapolatedState(outTSOS,
487  GlobalPoint(superClusterRef->seed()->position().x(),
488  superClusterRef->seed()->position().y(),
489  superClusterRef->seed()->position().z()));
490  if (!seedTSOS.isValid()) seedTSOS=outTSOS;
491 
492  // at scl
493  sclTSOS = mtsTransform->extrapolatedState(innTSOS,GlobalPoint(superClusterRef->x(),superClusterRef->y(),superClusterRef->z()));
494  if (!sclTSOS.isValid()) sclTSOS=outTSOS;
495 
496  // constrained momentum
497  constrainedVtxTSOS = constraintAtVtx->constrainAtBeamSpot(*gsfTrackRef,beamSpot);
498 
499  return true ;
500  }
501 
503  {
504  mtsMode->momentumFromModeCartesian(innTSOS,innMom) ;
505  mtsMode->positionFromModeCartesian(innTSOS,innPos) ;
506  mtsMode->momentumFromModeCartesian(seedTSOS,seedMom) ;
507  mtsMode->positionFromModeCartesian(seedTSOS,seedPos) ;
508  mtsMode->momentumFromModeCartesian(eleTSOS,eleMom) ;
509  mtsMode->positionFromModeCartesian(eleTSOS,elePos) ;
510  mtsMode->momentumFromModeCartesian(sclTSOS,sclMom) ;
511  mtsMode->positionFromModeCartesian(sclTSOS,sclPos) ;
512  mtsMode->momentumFromModeCartesian(vtxTSOS,vtxMom) ;
513  mtsMode->positionFromModeCartesian(vtxTSOS,vtxPos) ;
514  mtsMode->momentumFromModeCartesian(outTSOS,outMom);
515  mtsMode->positionFromModeCartesian(outTSOS,outPos) ;
516  mtsMode->momentumFromModeCartesian(constrainedVtxTSOS,vtxMomWithConstraint);
517  }
518 
520  {
521  double scale = superClusterRef->energy()/vtxMom.mag() ;
523  ( vtxMom.x()*scale,vtxMom.y()*scale,vtxMom.z()*scale,
524  superClusterRef->energy() ) ;
525  }
526 
528  {
529  const reco::CaloCluster & seedCluster = *(theClus->seed()) ;
530  // temporary, till CaloCluster->seed() is made available
531  DetId seedXtalId = seedCluster.hitsAndFractions()[0].first ;
532  int detector = seedXtalId.subdetId() ;
533 
536  const EcalRecHitCollection * recHits = 0 ;
537  std::vector<int> recHitFlagsToBeExcluded ;
538  std::vector<int> recHitSeverityToBeExcluded ;
539  if (detector==EcalBarrel)
540  {
541  recHits = eventData_->barrelRecHits.product() ;
542  recHitFlagsToBeExcluded = generalData_->recHitsCfg.recHitFlagsToBeExcludedBarrel ;
543  recHitSeverityToBeExcluded = generalData_->recHitsCfg.recHitSeverityToBeExcludedBarrel ;
544  }
545  else
546  {
547  recHits = eventData_->endcapRecHits.product() ;
548  recHitFlagsToBeExcluded = generalData_->recHitsCfg.recHitFlagsToBeExcludedEndcaps ;
549  recHitSeverityToBeExcluded = generalData_->recHitsCfg.recHitSeverityToBeExcludedEndcaps ;
550  }
551 
552  std::vector<float> covariances = EcalClusterTools::covariances(seedCluster,recHits,topology,geometry) ;
553  std::vector<float> localCovariances = EcalClusterTools::localCovariances(seedCluster,recHits,topology) ;
554  showerShape.sigmaEtaEta = sqrt(covariances[0]) ;
555  showerShape.sigmaIetaIeta = sqrt(localCovariances[0]) ;
556  if (!edm::isNotFinite(localCovariances[2])) showerShape.sigmaIphiIphi = sqrt(localCovariances[2]) ;
557  showerShape.e1x5 = EcalClusterTools::e1x5(seedCluster,recHits,topology) ;
558  showerShape.e2x5Max = EcalClusterTools::e2x5Max(seedCluster,recHits,topology) ;
559  showerShape.e5x5 = EcalClusterTools::e5x5(seedCluster,recHits,topology) ;
560  showerShape.r9 = EcalClusterTools::e3x3(seedCluster,recHits,topology)/theClus->rawEnergy() ;
561 
562  if (pflow)
563  {
564  showerShape.hcalDepth1OverEcal = generalData_->hcalHelperPflow->hcalESumDepth1(*theClus)/theClus->energy() ;
565  showerShape.hcalDepth2OverEcal = generalData_->hcalHelperPflow->hcalESumDepth2(*theClus)/theClus->energy() ;
569  }
570  else
571  {
572  showerShape.hcalDepth1OverEcal = generalData_->hcalHelper->hcalESumDepth1(*theClus)/theClus->energy() ;
573  showerShape.hcalDepth2OverEcal = generalData_->hcalHelper->hcalESumDepth2(*theClus)/theClus->energy() ;
577  }
578  }
579 
581  {
582  const reco::CaloCluster & seedCluster = *(theClus->seed()) ;
583  // temporary, till CaloCluster->seed() is made available
584  DetId seedXtalId = seedCluster.hitsAndFractions()[0].first ;
585  int detector = seedXtalId.subdetId() ;
586 
589  const EcalRecHitCollection * recHits = 0 ;
590  std::vector<int> recHitFlagsToBeExcluded ;
591  std::vector<int> recHitSeverityToBeExcluded ;
592  if (detector==EcalBarrel)
593  {
594  recHits = eventData_->barrelRecHits.product() ;
595  recHitFlagsToBeExcluded = generalData_->recHitsCfg.recHitFlagsToBeExcludedBarrel ;
596  recHitSeverityToBeExcluded = generalData_->recHitsCfg.recHitSeverityToBeExcludedBarrel ;
597  }
598  else
599  {
600  recHits = eventData_->endcapRecHits.product() ;
601  recHitFlagsToBeExcluded = generalData_->recHitsCfg.recHitFlagsToBeExcludedEndcaps ;
602  recHitSeverityToBeExcluded = generalData_->recHitsCfg.recHitSeverityToBeExcludedEndcaps ;
603  }
604 
605  std::vector<float> covariances = noZS::EcalClusterTools::covariances(seedCluster,recHits,topology,geometry) ;
606  std::vector<float> localCovariances = noZS::EcalClusterTools::localCovariances(seedCluster,recHits,topology) ;
607  showerShape.sigmaEtaEta = sqrt(covariances[0]) ;
608  showerShape.sigmaIetaIeta = sqrt(localCovariances[0]) ;
609  if (!edm::isNotFinite(localCovariances[2])) showerShape.sigmaIphiIphi = sqrt(localCovariances[2]) ;
610  showerShape.e1x5 = noZS::EcalClusterTools::e1x5(seedCluster,recHits,topology) ;
611  showerShape.e2x5Max = noZS::EcalClusterTools::e2x5Max(seedCluster,recHits,topology) ;
612  showerShape.e5x5 = noZS::EcalClusterTools::e5x5(seedCluster,recHits,topology) ;
613  showerShape.r9 = noZS::EcalClusterTools::e3x3(seedCluster,recHits,topology)/theClus->rawEnergy() ;
614 
615  if (pflow)
616  {
617  showerShape.hcalDepth1OverEcal = generalData_->hcalHelperPflow->hcalESumDepth1(*theClus)/theClus->energy() ;
618  showerShape.hcalDepth2OverEcal = generalData_->hcalHelperPflow->hcalESumDepth2(*theClus)/theClus->energy() ;
622  }
623  else
624  {
625  showerShape.hcalDepth1OverEcal = generalData_->hcalHelper->hcalESumDepth1(*theClus)/theClus->energy() ;
626  showerShape.hcalDepth2OverEcal = generalData_->hcalHelper->hcalESumDepth2(*theClus)/theClus->energy() ;
630  }
631  }
632 
633 
634 //===================================================================
635 // GsfElectronAlgo
636 //===================================================================
637 
639  ( const InputTagsConfiguration & inputCfg,
640  const StrategyConfiguration & strategyCfg,
641  const CutsConfiguration & cutsCfg,
642  const CutsConfiguration & cutsCfgPflow,
643  const ElectronHcalHelper::Configuration & hcalCfg,
644  const ElectronHcalHelper::Configuration & hcalCfgPflow,
645  const IsolationConfiguration & isoCfg,
646  const EcalRecHitsConfiguration & recHitsCfg,
647  EcalClusterFunctionBaseClass * superClusterErrorFunction,
648  EcalClusterFunctionBaseClass * crackCorrectionFunction,
650  const RegressionHelper::Configuration & regCfg
651  )
652  : generalData_(new GeneralData(inputCfg,strategyCfg,cutsCfg,cutsCfgPflow,hcalCfg,hcalCfgPflow,isoCfg,recHitsCfg,superClusterErrorFunction,crackCorrectionFunction,mvaCfg,regCfg)),
655  {}
656 
658  {
659  delete generalData_ ;
660  delete eventSetupData_ ;
661  delete eventData_ ;
662  delete electronData_ ;
663  }
664 
666  {
667  // get EventSetupRecords if needed
668  bool updateField(false);
670  updateField = true;
673  }
674 
675  bool updateGeometry(false);
677  updateGeometry = true;
680  }
681 
682  if ( updateField || updateGeometry ) {
683  delete eventSetupData_->mtsTransform ;
687  }
688 
690  eventSetupData_->cacheIDGeom=es.get<CaloGeometryRecord>().cacheIdentifier();
692  }
693 
695  eventSetupData_->cacheIDTopo=es.get<CaloTopologyRecord>().cacheIdentifier();
697  }
698 
703 
704 
709 
710  //if(eventSetupData_->cacheChStatus!=es.get<EcalChannelStatusRcd>().cacheIdentifier()){
711  // eventSetupData_->cacheChStatus=es.get<EcalChannelStatusRcd>().cacheIdentifier();
712  // es.get<EcalChannelStatusRcd>().get(eventSetupData_->chStatus);
713  //}
714 
716  eventSetupData_->cacheSevLevel = es.get<EcalSeverityLevelAlgoRcd>().cacheIdentifier();
718  }
719  }
720 
721 
723  {
724  GsfElectronPtrCollection::const_iterator it ;
725  for
726  ( it = eventData_->electrons->begin() ;
727  it != eventData_->electrons->end() ;
728  it++ )
729  { outEle.push_back(**it) ; }
730  }
731 
733  {
734  if (eventData_!=0)
735  { throw cms::Exception("GsfElectronAlgo|InternalError")<<"unexpected event data" ; }
736  eventData_ = new EventData ;
737 
738  // init the handles linked to the current event
739  eventData_->event = &event ;
746  event.getByToken(generalData_->inputCfg.hcalTowersTag,eventData_->towers) ;
747  event.getByToken(generalData_->inputCfg.pfMVA,eventData_->pfMva) ;
748  event.getByToken(generalData_->inputCfg.seedsTag,eventData_->seeds) ;
752 
753  // get the beamspot from the Event:
754  edm::Handle<reco::BeamSpot> recoBeamSpotHandle ;
755  event.getByToken(generalData_->inputCfg.beamSpotTag,recoBeamSpotHandle) ;
756  eventData_->beamspot = recoBeamSpotHandle.product() ;
757 
758  // prepare access to hcal data
761 
762  // Isolation algos
763  float extRadiusSmall=0.3, extRadiusLarge=0.4 ;
764  float intRadiusBarrel=generalData_->isoCfg.intRadiusBarrelTk, intRadiusEndcap=generalData_->isoCfg.intRadiusEndcapTk, stripBarrel=generalData_->isoCfg.stripBarrelTk, stripEndcap=generalData_->isoCfg.stripEndcapTk ;
766  eventData_->tkIsolation03 = new ElectronTkIsolation(extRadiusSmall,intRadiusBarrel,intRadiusEndcap,stripBarrel,stripEndcap,ptMin,maxVtxDist,drb,eventData_->currentCtfTracks.product(),eventData_->beamspot->position()) ;
767  eventData_->tkIsolation04 = new ElectronTkIsolation(extRadiusLarge,intRadiusBarrel,intRadiusEndcap,stripBarrel,stripEndcap,ptMin,maxVtxDist,drb,eventData_->currentCtfTracks.product(),eventData_->beamspot->position()) ;
768 
769  float egHcalIsoConeSizeOutSmall=0.3, egHcalIsoConeSizeOutLarge=0.4;
770  float egHcalIsoConeSizeIn=generalData_->isoCfg.intRadiusHcal,egHcalIsoPtMin=generalData_->isoCfg.etMinHcal;
771  int egHcalDepth1=1, egHcalDepth2=2;
772  eventData_->hadDepth1Isolation03 = new EgammaTowerIsolation(egHcalIsoConeSizeOutSmall,egHcalIsoConeSizeIn,egHcalIsoPtMin,egHcalDepth1,eventData_->towers.product()) ;
773  eventData_->hadDepth2Isolation03 = new EgammaTowerIsolation(egHcalIsoConeSizeOutSmall,egHcalIsoConeSizeIn,egHcalIsoPtMin,egHcalDepth2,eventData_->towers.product()) ;
774  eventData_->hadDepth1Isolation04 = new EgammaTowerIsolation(egHcalIsoConeSizeOutLarge,egHcalIsoConeSizeIn,egHcalIsoPtMin,egHcalDepth1,eventData_->towers.product()) ;
775  eventData_->hadDepth2Isolation04 = new EgammaTowerIsolation(egHcalIsoConeSizeOutLarge,egHcalIsoConeSizeIn,egHcalIsoPtMin,egHcalDepth2,eventData_->towers.product()) ;
776  eventData_->hadDepth1Isolation03Bc = new EgammaTowerIsolation(egHcalIsoConeSizeOutSmall,0.,egHcalIsoPtMin,egHcalDepth1,eventData_->towers.product()) ;
777  eventData_->hadDepth2Isolation03Bc = new EgammaTowerIsolation(egHcalIsoConeSizeOutSmall,0.,egHcalIsoPtMin,egHcalDepth2,eventData_->towers.product()) ;
778  eventData_->hadDepth1Isolation04Bc = new EgammaTowerIsolation(egHcalIsoConeSizeOutLarge,0.,egHcalIsoPtMin,egHcalDepth1,eventData_->towers.product()) ;
779  eventData_->hadDepth2Isolation04Bc = new EgammaTowerIsolation(egHcalIsoConeSizeOutLarge,0.,egHcalIsoPtMin,egHcalDepth2,eventData_->towers.product()) ;
780 
781  float egIsoConeSizeOutSmall=0.3, egIsoConeSizeOutLarge=0.4, egIsoJurassicWidth=generalData_->isoCfg.jurassicWidth;
782  float egIsoPtMinBarrel=generalData_->isoCfg.etMinBarrel,egIsoEMinBarrel=generalData_->isoCfg.eMinBarrel, egIsoConeSizeInBarrel=generalData_->isoCfg.intRadiusEcalBarrel;
783  float egIsoPtMinEndcap=generalData_->isoCfg.etMinEndcaps,egIsoEMinEndcap=generalData_->isoCfg.eMinEndcaps, egIsoConeSizeInEndcap=generalData_->isoCfg.intRadiusEcalEndcaps;
784  eventData_->ecalBarrelIsol03 = new EgammaRecHitIsolation(egIsoConeSizeOutSmall,egIsoConeSizeInBarrel,egIsoJurassicWidth,egIsoPtMinBarrel,egIsoEMinBarrel,eventSetupData_->caloGeom,*(eventData_->barrelRecHits),eventSetupData_->sevLevel.product(),DetId::Ecal);
785  eventData_->ecalBarrelIsol04 = new EgammaRecHitIsolation(egIsoConeSizeOutLarge,egIsoConeSizeInBarrel,egIsoJurassicWidth,egIsoPtMinBarrel,egIsoEMinBarrel,eventSetupData_->caloGeom,*(eventData_->barrelRecHits),eventSetupData_->sevLevel.product(),DetId::Ecal);
786  eventData_->ecalEndcapIsol03 = new EgammaRecHitIsolation(egIsoConeSizeOutSmall,egIsoConeSizeInEndcap,egIsoJurassicWidth,egIsoPtMinEndcap,egIsoEMinEndcap,eventSetupData_->caloGeom,*(eventData_->endcapRecHits),eventSetupData_->sevLevel.product(),DetId::Ecal);
787  eventData_->ecalEndcapIsol04 = new EgammaRecHitIsolation(egIsoConeSizeOutLarge,egIsoConeSizeInEndcap,egIsoJurassicWidth,egIsoPtMinEndcap,egIsoEMinEndcap,eventSetupData_->caloGeom,*(eventData_->endcapRecHits),eventSetupData_->sevLevel.product(),DetId::Ecal);
804 
805  //Fill in the Isolation Value Maps for PF and EcalDriven electrons
806  std::vector<edm::InputTag> inputTagIsoVals;
808  inputTagIsoVals.push_back(generalData_->inputCfg.pfIsoVals.getParameter<edm::InputTag>("pfSumChargedHadronPt"));
809  inputTagIsoVals.push_back(generalData_->inputCfg.pfIsoVals.getParameter<edm::InputTag>("pfSumPhotonEt"));
810  inputTagIsoVals.push_back(generalData_->inputCfg.pfIsoVals.getParameter<edm::InputTag>("pfSumNeutralHadronEt"));
811 
812  eventData_->pfIsolationValues.resize(inputTagIsoVals.size());
813 
814  for (size_t j = 0; j<inputTagIsoVals.size(); ++j) {
815  event.getByLabel(inputTagIsoVals[j], eventData_->pfIsolationValues[j]);
816  }
817 
818  }
819 
821  inputTagIsoVals.clear();
822  inputTagIsoVals.push_back(generalData_->inputCfg.edIsoVals.getParameter<edm::InputTag>("edSumChargedHadronPt"));
823  inputTagIsoVals.push_back(generalData_->inputCfg.edIsoVals.getParameter<edm::InputTag>("edSumPhotonEt"));
824  inputTagIsoVals.push_back(generalData_->inputCfg.edIsoVals.getParameter<edm::InputTag>("edSumNeutralHadronEt"));
825 
826  eventData_->edIsolationValues.resize(inputTagIsoVals.size());
827 
828  for (size_t j = 0; j<inputTagIsoVals.size(); ++j) {
829  event.getByLabel(inputTagIsoVals[j], eventData_->edIsolationValues[j]);
830  }
831  }
832  }
833 
835  {
836  if (eventData_==0)
837  { throw cms::Exception("GsfElectronAlgo|InternalError")<<"lacking event data" ; }
838  delete eventData_ ;
839  eventData_ = 0 ;
840  }
841 
843  {
844  LogTrace("GsfElectronAlgo") << "========== " << title << " ==========";
845  LogTrace("GsfElectronAlgo") << "Event: " << eventData_->event->id();
846  LogTrace("GsfElectronAlgo") << "Number of electrons: " << eventData_->electrons->size() ;
847  GsfElectronPtrCollection::const_iterator it ;
848  for ( it = eventData_->electrons->begin(); it != eventData_->electrons->end(); it++ )
849  {
850  LogTrace("GsfElectronAlgo") << "Electron with charge, pt, eta, phi: " << (*it)->charge() << " , "
851  << (*it)->pt() << " , " << (*it)->eta() << " , " << (*it)->phi();
852  }
853  LogTrace("GsfElectronAlgo") << "=================================================";
854  }
855 
857  {
858  if (electronData_!=0)
859  { throw cms::Exception("GsfElectronAlgo|InternalError")<<"unexpected electron data" ; }
860 
861  const GsfElectronCoreCollection * coreCollection = eventData_->coreElectrons.product() ;
862  for ( unsigned int i=0 ; i<coreCollection->size() ; ++i )
863  {
864  // check there is no existing electron with this core
866  bool coreFound = false ;
867  GsfElectronPtrCollection::const_iterator itrEle ;
868  for
869  ( itrEle = eventData_->electrons->begin() ;
870  itrEle != eventData_->electrons->end() ;
871  itrEle++ )
872  {
873  if ((*itrEle)->core()==coreRef)
874  {
875  coreFound = true ;
876  break ;
877  }
878  }
879  if (coreFound) continue ;
880 
881  // check there is a super-cluster
882  if (coreRef->superCluster().isNull()) continue ;
883 
884  // prepare internal structure for electron specific data
885  delete electronData_ ;
886  electronData_ = new ElectronData(coreRef,*eventData_->beamspot) ;
887 
888  // calculate and check Trajectory StatesOnSurface....
890 
891  createElectron() ;
892 
893  } // loop over tracks
894 
895  delete electronData_ ;
896  electronData_ = 0 ;
897  }
898 
900  {
901  const GsfElectronCollection * oldElectrons = eventData_->previousElectrons.product() ;
903  GsfElectronCollection::const_iterator oldElectron ;
904  for
905  ( oldElectron = oldElectrons->begin() ;
906  oldElectron != oldElectrons->end() ;
907  ++oldElectron )
908  {
909  const GsfElectronCoreRef oldCoreRef = oldElectron->core() ;
910  const GsfTrackRef oldElectronGsfTrackRef = oldCoreRef->gsfTrack() ;
911  unsigned int icore ;
912  for ( icore=0 ; icore<newCores->size() ; ++icore )
913  {
914  if (oldElectronGsfTrackRef==(*newCores)[icore].gsfTrack())
915  {
917  eventData_->electrons->push_back(new GsfElectron(*oldElectron,coreRef)) ;
918  break ;
919  }
920  }
921  }
922  }
923 
924 
925 // now deprecated
927  {
928  bool found ;
929  const GsfElectronCollection * edElectrons = eventData_->previousElectrons.product() ;
931  GsfElectronCollection::const_iterator pfElectron, edElectron ;
932  unsigned int edIndex, pfIndex ;
933 
934  GsfElectronPtrCollection::iterator el ;
935  for
936  ( el = eventData_->electrons->begin() ;
937  el != eventData_->electrons->end() ;
938  el++ )
939  {
940 // // MVA
941 // // we check that the value is never inferior to the no-cut value
942 // // we generally use in the configuration file for minMVA.
943 // GsfTrackRef gsfTrackRef = (*el)->gsfTrack() ;
944 // float mva = (*eventData_->pfMva.product())[gsfTrackRef] ;
945 // if (mva<noCutMin) { throw cms::Exception("GsfElectronAlgo|UnexpectedMvaValue")<<"unexpected MVA value: "<<mva ; }
946 //
947 // // Mva Output
948 // GsfElectron::MvaOutput mvaOutput ;
949 // mvaOutput.mva = mva ;
950 // (*el)->setMvaOutput(mvaOutput) ;
951 
952  // Retreive info from pflow electrons
953  found = false ;
954  for
955  ( pfIndex = 0, pfElectron = pfElectrons->begin() ; pfElectron != pfElectrons->end() ; pfIndex++, pfElectron++ )
956  {
957  if (pfElectron->gsfTrack()==(*el)->gsfTrack())
958  {
959  if (found)
960  {
961  edm::LogWarning("GsfElectronProducer")<<"associated pfGsfElectron already found" ;
962  }
963  else
964  {
965  found = true ;
966 
967  // Isolation Values
968  if( (eventData_->pfIsolationValues).size() != 0 )
969  {
971  pfElectronRef(eventData_->pflowElectrons, pfIndex);
973  isoVariables.sumChargedHadronPt =(*(eventData_->pfIsolationValues)[0])[pfElectronRef];
974  isoVariables.sumPhotonEt =(*(eventData_->pfIsolationValues)[1])[pfElectronRef];
975  isoVariables.sumNeutralHadronEt =(*(eventData_->pfIsolationValues)[2])[pfElectronRef];
976  (*el)->setPfIsolationVariables(isoVariables);
977  }
978 
979 // (*el)->setPfIsolationVariables(pfElectron->pfIsolationVariables()) ;
980  (*el)->setMvaInput(pfElectron->mvaInput()) ;
981  (*el)->setMvaOutput(pfElectron->mvaOutput()) ;
982  if ((*el)->ecalDrivenSeed())
983  { (*el)->setP4(GsfElectron::P4_PFLOW_COMBINATION,pfElectron->p4(GsfElectron::P4_PFLOW_COMBINATION),pfElectron->p4Error(GsfElectron::P4_PFLOW_COMBINATION),false) ; }
984  else
985  { (*el)->setP4(GsfElectron::P4_PFLOW_COMBINATION,pfElectron->p4(GsfElectron::P4_PFLOW_COMBINATION),pfElectron->p4Error(GsfElectron::P4_PFLOW_COMBINATION),true) ; }
986  double noCutMin = -999999999. ;
987  if ((*el)->mva()<noCutMin) { throw cms::Exception("GsfElectronAlgo|UnexpectedMvaValue")<<"unexpected MVA value: "<<(*el)->mva() ; }
988  }
989  }
990  }
991 
992  // Isolation Values
993  // Retreive not found info from ed electrons
994  if( (eventData_->edIsolationValues).size() != 0 )
995  {
996  edIndex = 0, edElectron = edElectrons->begin() ;
997  while ((found == false)&&(edElectron != edElectrons->end()))
998  {
999  if (edElectron->gsfTrack()==(*el)->gsfTrack())
1000  {
1001  found = true ;
1002 
1003  // CONSTRUCTION D UNE REF dans le handle eventData_->previousElectrons avec l'indice edIndex,
1004  // puis recuperation dans la ValueMap ED
1005 
1007  edElectronRef(eventData_->previousElectrons, edIndex);
1009  isoVariables.sumChargedHadronPt =(*(eventData_->edIsolationValues)[0])[edElectronRef];
1010  isoVariables.sumPhotonEt =(*(eventData_->edIsolationValues)[1])[edElectronRef];
1011  isoVariables.sumNeutralHadronEt =(*(eventData_->edIsolationValues)[2])[edElectronRef];
1012  (*el)->setPfIsolationVariables(isoVariables);
1013  }
1014 
1015  edIndex++ ;
1016  edElectron++ ;
1017  }
1018  }
1019 
1020  // Preselection
1022 
1023  // Shower Shape of pflow cluster
1024  if (!((*el)->parentSuperCluster().isNull()))
1025  {
1026  reco::GsfElectron::ShowerShape pflowShowerShape ;
1027  calculateShowerShape((*el)->parentSuperCluster(),true,pflowShowerShape) ;
1028  (*el)->setPfShowerShape(pflowShowerShape) ;
1029  }
1030  else if ((*el)->passingPflowPreselection())
1031  { edm::LogError("GsfElectronCoreProducer")<<"Preselected tracker driven GsfTrack with no associated pflow SuperCluster." ; }
1032 
1033  // PfBrem
1034  SuperClusterRef sc = (*el)->parentSuperCluster() ;
1035  if (!(sc.isNull()))
1036  {
1037 
1038  if (sc->clustersSize()>1)
1039  {
1040  CaloCluster_iterator first = sc->clustersBegin() ;
1041  (*el)->setPfSuperClusterFbrem((sc->energy()-(*first)->energy())/sc->energy()) ;
1042  }
1043  else
1044  { (*el)->setPfSuperClusterFbrem(0.) ; }
1045  ElectronClassification theClassifier ;
1046  theClassifier.refineWithPflow(**el) ;
1047  }
1048  }
1049  }
1050 
1052  {
1053  float mvaValue=generalData_->sElectronMVAEstimator->mva( *(ele),*(eventData_->event));
1054  bool passCutBased=ele->passingCutBasedPreselection();
1055  bool passPF=ele->passingPflowPreselection();
1057  bool passmva=mvaValue>generalData_->strategyCfg.PreSelectMVA;
1058  if(!ele->ecalDrivenSeed()){
1060  return passmva && passCutBased;
1061  else
1062  return passmva;
1063  }
1064  else{
1065  return passCutBased || passPF || passmva;
1066  }
1067  }
1068  else{
1069  return passCutBased || passPF;
1070  }
1071 
1072  return true;
1073  }
1074 
1076  {
1077  GsfElectronPtrCollection::size_type ei = 1, emax = eventData_->electrons->size() ;
1078  GsfElectronPtrCollection::iterator eitr = eventData_->electrons->begin() ;
1079  while (eitr!=eventData_->electrons->end())
1080  {
1081  LogTrace("GsfElectronAlgo")<<"========== removed not preselected "<<ei<<"/"<<emax<<"==========" ;
1082  if (isPreselected(*eitr))
1083  { ++eitr ; ++ei ; }
1084  else
1085  { delete (*eitr) ; eitr = eventData_->electrons->erase(eitr) ; ++ei ; }
1086  }
1087  }
1088 
1089 
1091  {
1092  // default value
1093  ele->setPassCutBasedPreselection(false) ;
1094 
1095  // kind of seeding
1096  bool eg = ele->core()->ecalDrivenSeed() ;
1097  bool pf = ele->core()->trackerDrivenSeed() && !ele->core()->ecalDrivenSeed() ;
1098  bool gedMode = generalData_->strategyCfg.gedElectronMode;
1099  if (eg&&pf) { throw cms::Exception("GsfElectronAlgo|BothEcalAndPureTrackerDriven")<<"An electron cannot be both egamma and purely pflow" ; }
1100  if ((!eg)&&(!pf)) { throw cms::Exception("GsfElectronAlgo|NeitherEcalNorPureTrackerDriven")<<"An electron cannot be neither egamma nor purely pflow" ; }
1101 
1102  const CutsConfiguration * cfg = ((eg||gedMode)?&generalData_->cutsCfg:&generalData_->cutsCfgPflow);
1103 
1104  // Et cut
1105  double etaValue = EleRelPoint(ele->superCluster()->position(),bs.position()).eta() ;
1106  double etValue = ele->superCluster()->energy()/cosh(etaValue) ;
1107  LogTrace("GsfElectronAlgo") << "Et : " << etValue ;
1108  if (ele->isEB() && (etValue < cfg->minSCEtBarrel)) return ;
1109  if (ele->isEE() && (etValue < cfg->minSCEtEndcaps)) return ;
1110  LogTrace("GsfElectronAlgo") << "Et criteria are satisfied";
1111 
1112  // E/p cut
1113  double eopValue = ele->eSuperClusterOverP() ;
1114  LogTrace("GsfElectronAlgo") << "E/p : " << eopValue ;
1115  if (ele->isEB() && (eopValue > cfg->maxEOverPBarrel)) return ;
1116  if (ele->isEE() && (eopValue > cfg->maxEOverPEndcaps)) return ;
1117  if (ele->isEB() && (eopValue < cfg->minEOverPBarrel)) return ;
1118  if (ele->isEE() && (eopValue < cfg->minEOverPEndcaps)) return ;
1119  LogTrace("GsfElectronAlgo") << "E/p criteria are satisfied";
1120 
1121  // HoE cuts
1122  LogTrace("GsfElectronAlgo") << "HoE1 : " << ele->hcalDepth1OverEcal() << ", HoE2 : " << ele->hcalDepth2OverEcal();
1123  double had = ele->hcalOverEcal()*ele->superCluster()->energy() ;
1124  const reco::CaloCluster & seedCluster = *(ele->superCluster()->seed()) ;
1125  int detector = seedCluster.hitsAndFractions()[0].first.subdetId() ;
1126  bool HoEveto = false ;
1127  if (detector==EcalBarrel && (had<cfg->maxHBarrel || (had/ele->superCluster()->energy())<cfg->maxHOverEBarrel)) HoEveto=true;
1128  else if (detector==EcalEndcap && (had<cfg->maxHEndcaps || (had/ele->superCluster()->energy())<cfg->maxHOverEEndcaps)) HoEveto=true;
1129  if ( !HoEveto ) return ;
1130  LogTrace("GsfElectronAlgo") << "H/E criteria are satisfied";
1131 
1132  // delta eta criteria
1133  double deta = ele->deltaEtaSuperClusterTrackAtVtx() ;
1134  LogTrace("GsfElectronAlgo") << "delta eta : " << deta ;
1135  if (ele->isEB() && (std::abs(deta) > cfg->maxDeltaEtaBarrel)) return ;
1136  if (ele->isEE() && (std::abs(deta) > cfg->maxDeltaEtaEndcaps)) return ;
1137  LogTrace("GsfElectronAlgo") << "Delta eta criteria are satisfied";
1138 
1139  // delta phi criteria
1140  double dphi = ele->deltaPhiSuperClusterTrackAtVtx();
1141  LogTrace("GsfElectronAlgo") << "delta phi : " << dphi;
1142  if (ele->isEB() && (std::abs(dphi) > cfg->maxDeltaPhiBarrel)) return ;
1143  if (ele->isEE() && (std::abs(dphi) > cfg->maxDeltaPhiEndcaps)) return ;
1144  LogTrace("GsfElectronAlgo") << "Delta phi criteria are satisfied";
1145 
1146  // sigma ieta ieta
1147  LogTrace("GsfElectronAlgo") << "sigma ieta ieta : " << ele->sigmaIetaIeta();
1148  if (ele->isEB() && (ele->sigmaIetaIeta() > cfg->maxSigmaIetaIetaBarrel)) return ;
1149  if (ele->isEE() && (ele->sigmaIetaIeta() > cfg->maxSigmaIetaIetaEndcaps)) return ;
1150  LogTrace("GsfElectronAlgo") << "Sigma ieta ieta criteria are satisfied";
1151 
1152  // fiducial
1153  if (!ele->isEB() && cfg->isBarrel) return ;
1154  if (!ele->isEE() && cfg->isEndcaps) return ;
1155  if (cfg->isFiducial && (ele->isEBEEGap()||ele->isEBEtaGap()||ele->isEBPhiGap()||ele->isEERingGap()||ele->isEEDeeGap())) return ;
1156  LogTrace("GsfElectronAlgo") << "Fiducial flags criteria are satisfied";
1157 
1158  // seed in TEC
1159  edm::RefToBase<TrajectorySeed> seed = ele->gsfTrack()->extra()->seedRef() ;
1160  ElectronSeedRef elseed = seed.castTo<ElectronSeedRef>() ;
1161  if (eg && !generalData_->cutsCfg.seedFromTEC)
1162  {
1163  if (elseed.isNull())
1164  { throw cms::Exception("GsfElectronAlgo|NotElectronSeed")<<"The GsfTrack seed is not an ElectronSeed ?!" ; }
1165  else
1166  { if (elseed->subDet2()==6) return ; }
1167  }
1168 
1169  // transverse impact parameter
1170  if (std::abs(ele->gsfTrack()->dxy(bs.position()))>cfg->maxTIP) return ;
1171  LogTrace("GsfElectronAlgo") << "TIP criterion is satisfied" ;
1172 
1173  LogTrace("GsfElectronAlgo") << "All cut based criteria are satisfied" ;
1174  ele->setPassCutBasedPreselection(true) ;
1175  }
1176 
1178  {
1179  ele->setPassMvaPreselection(false) ;
1180 
1181  if (ele->core()->ecalDrivenSeed())
1182  { if (ele->mvaOutput().mva>=generalData_->cutsCfg.minMVA) ele->setPassMvaPreselection(true) ; }
1183  else
1184  { if (ele->mvaOutput().mva>=generalData_->cutsCfgPflow.minMVA) ele->setPassMvaPreselection(true) ; }
1185 
1186  if (ele->passingMvaPreselection())
1187  { LogTrace("GsfElectronAlgo") << "Main mva criterion is satisfied" ; }
1188 
1190 
1191 // ele->setPassPflowPreselection(false) ;
1192 // if (ele->core()->ecalDrivenSeed())
1193 // {
1194 // if ((ele->mvaOutput().mva>=generalData_->cutsCfg.minMVA) ||
1195 // (ele->mvaOutput().mvaByPassForIsolated>=generalData_->cutsCfg.minMvaByPassForIsolated))
1196 // ele->setPassPflowPreselection(true) ;
1197 // }
1198 // else
1199 // {
1200 // if ((ele->mvaOutput().mva>=generalData_->cutsCfgPflow.minMVA) ||
1201 // (ele->mvaOutput().mvaByPassForIsolated>=generalData_->cutsCfgPflow.minMvaByPassForIsolated))
1202 // ele->setPassPflowPreselection(true) ;
1203 // }
1204 // if (ele->passingPflowPreselection())
1205 // { LogTrace("GsfElectronAlgo") << "Mva criteria are satisfied" ; }
1206  }
1207 
1208 void GsfElectronAlgo::setMVAInputs(const std::map<reco::GsfTrackRef,reco::GsfElectron::MvaInput> & mvaInputs)
1209 {
1210  GsfElectronPtrCollection::iterator el ;
1211  for
1212  ( el = eventData_->electrons->begin() ;
1213  el != eventData_->electrons->end() ;
1214  el++ )
1215  {
1216  std::map<reco::GsfTrackRef,reco::GsfElectron::MvaInput>::const_iterator itcheck=mvaInputs.find((*el)->gsfTrack());
1217  (*el)->setMvaInput(itcheck->second);
1218  }
1219 }
1220 
1221 void GsfElectronAlgo::setMVAOutputs(const std::map<reco::GsfTrackRef,reco::GsfElectron::MvaOutput> & mvaOutputs)
1222 {
1223  GsfElectronPtrCollection::iterator el ;
1224  for
1225  ( el = eventData_->electrons->begin() ;
1226  el != eventData_->electrons->end() ;
1227  el++ )
1228  {
1230  float mvaValue=generalData_->sElectronMVAEstimator->mva( *(*el),*(eventData_->event));
1231  GsfElectron::MvaOutput mvaOutput ;
1232  mvaOutput.mva = mvaValue ;
1233  (*el)->setMvaOutput(mvaOutput);
1234  }
1235  else{
1236  std::map<reco::GsfTrackRef,reco::GsfElectron::MvaOutput>::const_iterator itcheck=mvaOutputs.find((*el)->gsfTrack());
1237  (*el)->setMvaOutput(itcheck->second);
1238  }
1239  }
1240 }
1241 
1243  {
1244  // eventually check ctf track
1247 
1248  // charge ID
1249  int eleCharge ;
1250  GsfElectron::ChargeInfo eleChargeInfo ;
1251  electronData_->computeCharge(eleCharge,eleChargeInfo) ;
1252 
1253  // electron basic cluster
1255 
1256  // Seed cluster
1257  const reco::CaloCluster & seedCluster = *(electronData_->superClusterRef->seed()) ;
1258 
1259  // seed Xtal
1260  // temporary, till CaloCluster->seed() is made available
1261  DetId seedXtalId = seedCluster.hitsAndFractions()[0].first ;
1262 
1264 
1265 
1266  //====================================================
1267  // Candidate attributes
1268  //====================================================
1269 
1271 
1272 
1273  //====================================================
1274  // Track-Cluster Matching
1275  //====================================================
1276 
1278  tcMatching.electronCluster = elbcRef ;
1279  tcMatching.eSuperClusterOverP = (electronData_->vtxMom.mag()>0)?(electronData_->superClusterRef->energy()/electronData_->vtxMom.mag()):(-1.) ;
1280  tcMatching.eSeedClusterOverP = (electronData_->vtxMom.mag()>0.)?(seedCluster.energy()/electronData_->vtxMom.mag()):(-1) ;
1281  tcMatching.eSeedClusterOverPout = (electronData_->seedMom.mag()>0.)?(seedCluster.energy()/electronData_->seedMom.mag()):(-1.) ;
1282  tcMatching.eEleClusterOverPout = (electronData_->eleMom.mag()>0.)?(elbcRef->energy()/electronData_->eleMom.mag()):(-1.) ;
1283 
1285  tcMatching.deltaEtaSuperClusterAtVtx = scAtVtx.dEta() ;
1286  tcMatching.deltaPhiSuperClusterAtVtx = scAtVtx.dPhi() ;
1287 
1288  EleRelPointPair seedAtCalo(seedCluster.position(),electronData_->seedPos,eventData_->beamspot->position()) ;
1289  tcMatching.deltaEtaSeedClusterAtCalo = seedAtCalo.dEta() ;
1290  tcMatching.deltaPhiSeedClusterAtCalo = seedAtCalo.dPhi() ;
1291 
1292  EleRelPointPair ecAtCalo(elbcRef->position(),electronData_->elePos,eventData_->beamspot->position()) ;
1293  tcMatching.deltaEtaEleClusterAtCalo = ecAtCalo.dEta() ;
1294  tcMatching.deltaPhiEleClusterAtCalo = ecAtCalo.dPhi() ;
1295 
1296 
1297  //=======================================================
1298  // Track extrapolations
1299  //=======================================================
1300 
1309 
1310 
1311  //=======================================================
1312  // Closest Ctf Track
1313  //=======================================================
1314 
1316  ctfInfo.ctfTrack = electronData_->ctfTrackRef ;
1318 
1319 
1320  //====================================================
1321  // FiducialFlags, using nextToBoundary definition of gaps
1322  //====================================================
1323 
1324  reco::GsfElectron::FiducialFlags fiducialFlags ;
1325  int detector = seedXtalId.subdetId() ;
1326  double feta=std::abs(electronData_->superClusterRef->position().eta()) ;
1327  if (detector==EcalBarrel)
1328  {
1329  fiducialFlags.isEB = true ;
1330  EBDetId ebdetid(seedXtalId);
1331  if (EBDetId::isNextToEtaBoundary(ebdetid))
1332  {
1333  if (ebdetid.ietaAbs()==85)
1334  { fiducialFlags.isEBEEGap = true ; }
1335  else
1336  { fiducialFlags.isEBEtaGap = true ; }
1337  }
1338  if (EBDetId::isNextToPhiBoundary(ebdetid))
1339  { fiducialFlags.isEBPhiGap = true ; }
1340  }
1341  else if (detector==EcalEndcap)
1342  {
1343  fiducialFlags.isEE = true ;
1344  EEDetId eedetid(seedXtalId);
1345  if (EEDetId::isNextToRingBoundary(eedetid))
1346  {
1347  if (std::abs(feta)<2.)
1348  { fiducialFlags.isEBEEGap = true ; }
1349  else
1350  { fiducialFlags.isEERingGap = true ; }
1351  }
1352  if (EEDetId::isNextToDBoundary(eedetid))
1353  { fiducialFlags.isEEDeeGap = true ; }
1354  }
1355  else
1356  { throw cms::Exception("GsfElectronAlgo|UnknownXtalRegion")<<"createElectron(): do not know if it is a barrel or endcap seed cluster !!!!" ; }
1357 
1358 
1359  //====================================================
1360  // ShowerShape
1361  //====================================================
1362 
1363  reco::GsfElectron::ShowerShape showerShape ;
1364  calculateShowerShape(electronData_->superClusterRef,!(electronData_->coreRef->ecalDrivenSeed()),showerShape) ;
1365 
1366  reco::GsfElectron::ShowerShape full5x5_showerShape ;
1367  calculateShowerShape_full5x5(electronData_->superClusterRef,!(electronData_->coreRef->ecalDrivenSeed()),full5x5_showerShape) ;
1368 
1369  //====================================================
1370  // ConversionRejection
1371  //====================================================
1372 
1374 
1375  ConversionFinder conversionFinder ;
1376  double BInTesla = eventSetupData_->magField->inTesla(GlobalPoint(0.,0.,0.)).z() ;
1378  if (!ctfTracks.isValid()) { ctfTracks = eventData_->currentCtfTracks ; }
1379 
1380  // values of conversionInfo.flag()
1381  // -9999 : Partner track was not found
1382  // 0 : Partner track found in the CTF collection using
1383  // 1 : Partner track found in the CTF collection using
1384  // 2 : Partner track found in the GSF collection using
1385  // 3 : Partner track found in the GSF collection using the electron's GSF track
1386  ConversionInfo conversionInfo = conversionFinder.getConversionInfo
1387  (*electronData_->coreRef,ctfTracks,eventData_->originalGsfTracks,BInTesla) ;
1388 
1390  conversionVars.flags = conversionInfo.flag() ;
1391  conversionVars.dist = conversionInfo.dist() ;
1392  conversionVars.dcot = conversionInfo.dcot() ;
1393  conversionVars.radius = conversionInfo.radiusOfConversion() ;
1394  if ((conversionVars.flags==0)or(conversionVars.flags==1))
1395  conversionVars.partner = TrackBaseRef(conversionInfo.conversionPartnerCtfTk()) ;
1396  else if ((conversionVars.flags==2)or(conversionVars.flags==3))
1397  conversionVars.partner = TrackBaseRef(conversionInfo.conversionPartnerGsfTk()) ;
1398 
1399 
1400  //====================================================
1401  // Go !
1402  //====================================================
1403 
1404  GsfElectron * ele = new
1405  GsfElectron
1406  ( eleCharge,eleChargeInfo,electronData_->coreRef,
1407  tcMatching, tkExtra, ctfInfo,
1408  fiducialFlags,showerShape, full5x5_showerShape,
1409  conversionVars ) ;
1410  // Will be overwritten later in the case of the regression
1412  ele->setP4(GsfElectron::P4_FROM_SUPER_CLUSTER,momentum,0,true) ;
1413 
1414 
1415  //====================================================
1416  // brems fractions
1417  //====================================================
1418 
1419  if (electronData_->innMom.mag()>0.)
1421 
1422  // the supercluster is the refined one The seed is not necessarily the first cluster
1423  // hence the use of the electronCluster
1424  SuperClusterRef sc = ele->superCluster() ;
1425  if (!(sc.isNull()))
1426  {
1427  CaloClusterPtr cl = ele->electronCluster() ;
1428  if (sc->clustersSize()>1)
1429  {
1430  float pf_fbrem =( sc->energy() - cl->energy() ) / sc->energy();
1431  ele->setSuperClusterFbrem( pf_fbrem ) ;
1432  ele->setPfSuperClusterFbrem( pf_fbrem) ;
1433  }
1434  else
1435  {
1436  ele->setSuperClusterFbrem(0) ;
1437  ele->setPfSuperClusterFbrem(0);
1438  }
1439  }
1440 
1441  //====================================================
1442  // classification and corrections
1443  //====================================================
1444  // classification
1445  ElectronClassification theClassifier ;
1446  theClassifier.classify(*ele) ;
1447  theClassifier.refineWithPflow(*ele) ;
1448  // ecal energy
1451  {
1456  }
1457  else // original implementation
1458  {
1459  if (ele->core()->ecalDrivenSeed())
1460  {
1462  { theEnCorrector.classBasedParameterizationEnergy(*ele,*eventData_->beamspot) ; }
1464  { theEnCorrector.classBasedParameterizationUncertainty(*ele) ; }
1465  }
1466  else
1467  {
1469  { theEnCorrector.simpleParameterizationUncertainty(*ele) ; }
1470  }
1471  }
1472 
1473  // momentum
1474  // Keep the default correction running first. The track momentum error is computed in there
1475  if (ele->core()->ecalDrivenSeed())
1476  {
1477  ElectronMomentumCorrector theMomCorrector;
1478  theMomCorrector.correct(*ele,electronData_->vtxTSOS);
1479  }
1481  {
1483  }
1484 
1485  //====================================================
1486  // now isolation variables
1487  //====================================================
1488 
1502  ele->setIsolation03(dr03);
1503  ele->setIsolation04(dr04);
1504 
1505 
1506  //====================================================
1507  // preselection flag
1508  //====================================================
1509 
1511 
1512  LogTrace("GsfElectronAlgo")<<"Constructed new electron with energy "<< ele->p4().e() ;
1513 
1514  eventData_->electrons->push_back(ele) ;
1515  }
1516 
1517 
1518 //=======================================================================================
1519 // Ambiguity solving
1520 //=======================================================================================
1521 
1522 //bool better_electron( const reco::GsfElectron * e1, const reco::GsfElectron * e2 )
1523 // { return (std::abs(e1->eSuperClusterOverP()-1)<std::abs(e2->eSuperClusterOverP()-1)) ; }
1524 
1525 void GsfElectronAlgo::setAmbiguityData( bool ignoreNotPreselected )
1526  {
1527  GsfElectronPtrCollection::iterator e1, e2 ;
1532  else
1533  { throw cms::Exception("GsfElectronAlgo|UnknownAmbiguitySortingStrategy")<<"value of generalData_->strategyCfg.ambSortingStrategy is : "<<generalData_->strategyCfg.ambSortingStrategy ; }
1534 
1535  // init
1536  for
1537  ( e1 = eventData_->electrons->begin() ;
1538  e1 != eventData_->electrons->end() ;
1539  ++e1 )
1540  {
1541  (*e1)->clearAmbiguousGsfTracks() ;
1542  (*e1)->setAmbiguous(false) ;
1543  }
1544 
1545  // get ambiguous from GsfPfRecTracks
1547  {
1548  for
1549  ( e1 = eventData_->electrons->begin() ;
1550  e1 != eventData_->electrons->end() ;
1551  ++e1 )
1552  {
1553  bool found = false ;
1554  const GsfPFRecTrackCollection * gsfPfRecTrackCollection = eventData_->gsfPfRecTracks.product() ;
1555  GsfPFRecTrackCollection::const_iterator gsfPfRecTrack ;
1556  for ( gsfPfRecTrack=gsfPfRecTrackCollection->begin() ;
1557  gsfPfRecTrack!=gsfPfRecTrackCollection->end() ;
1558  ++gsfPfRecTrack )
1559  {
1560  if (gsfPfRecTrack->gsfTrackRef()==(*e1)->gsfTrack())
1561  {
1562  if (found)
1563  {
1564  edm::LogWarning("GsfElectronAlgo")<<"associated gsfPfRecTrack already found" ;
1565  }
1566  else
1567  {
1568  found = true ;
1569  const std::vector<reco::GsfPFRecTrackRef> & duplicates(gsfPfRecTrack->convBremGsfPFRecTrackRef()) ;
1570  std::vector<reco::GsfPFRecTrackRef>::const_iterator duplicate ;
1571  for ( duplicate = duplicates.begin() ; duplicate != duplicates.end() ; duplicate ++ )
1572  { (*e1)->addAmbiguousGsfTrack((*duplicate)->gsfTrackRef()) ; }
1573  }
1574  }
1575  }
1576  }
1577  }
1578  // or search overlapping clusters
1579  else
1580  {
1581  for
1582  ( e1 = eventData_->electrons->begin() ;
1583  e1 != eventData_->electrons->end() ;
1584  ++e1 )
1585  {
1586  if ((*e1)->ambiguous()) continue ;
1587  if ( ignoreNotPreselected && !isPreselected(*e1) ) continue ;
1588 
1589  SuperClusterRef scRef1 = (*e1)->superCluster();
1590  CaloClusterPtr eleClu1 = (*e1)->electronCluster();
1591  LogDebug("GsfElectronAlgo")
1592  << "Blessing electron with E/P " << (*e1)->eSuperClusterOverP()
1593  << ", cluster " << scRef1.get()
1594  << " & track " << (*e1)->gsfTrack().get() ;
1595 
1596  for
1597  ( e2 = e1, ++e2 ;
1598  e2 != eventData_->electrons->end() ;
1599  ++e2 )
1600  {
1601  if ((*e2)->ambiguous()) continue ;
1602  if ( ignoreNotPreselected && !isPreselected(*e2) ) continue ;
1603 
1604  SuperClusterRef scRef2 = (*e2)->superCluster();
1605  CaloClusterPtr eleClu2 = (*e2)->electronCluster();
1606 
1607  // search if same cluster
1608  bool sameCluster = false ;
1610  { sameCluster = (scRef1==scRef2) ; }
1612  {
1613  float eMin = 1. ;
1614  float threshold = eMin*cosh(EleRelPoint(scRef1->position(),eventData_->beamspot->position()).eta()) ;
1615  sameCluster =
1617  (EgAmbiguityTools::sharedEnergy(&(*scRef1->seed()),&(*eleClu2),eventData_->barrelRecHits,eventData_->endcapRecHits)>=threshold) ||
1619  (EgAmbiguityTools::sharedEnergy(&(*scRef1->seed()),&(*scRef2->seed()),eventData_->barrelRecHits,eventData_->endcapRecHits)>=threshold) ) ;
1620  }
1621  else
1622  { throw cms::Exception("GsfElectronAlgo|UnknownAmbiguityClustersOverlapStrategy")<<"value of generalData_->strategyCfg.ambClustersOverlapStrategy is : "<<generalData_->strategyCfg.ambClustersOverlapStrategy ; }
1623 
1624  // main instructions
1625  if (sameCluster)
1626  {
1627  LogDebug("GsfElectronAlgo")
1628  << "Discarding electron with E/P " << (*e2)->eSuperClusterOverP()
1629  << ", cluster " << scRef2.get()
1630  << " and track " << (*e2)->gsfTrack().get() ;
1631  (*e1)->addAmbiguousGsfTrack((*e2)->gsfTrack()) ;
1632  (*e2)->setAmbiguous(true) ;
1633  }
1634  else if ((*e1)->gsfTrack()==(*e2)->gsfTrack())
1635  {
1636  edm::LogWarning("GsfElectronAlgo")
1637  << "Forgetting electron with E/P " << (*e2)->eSuperClusterOverP()
1638  << ", cluster " << scRef2.get()
1639  << " and track " << (*e2)->gsfTrack().get() ;
1640  (*e2)->setAmbiguous(true) ;
1641  }
1642  }
1643  }
1644  }
1645  }
1646 
1648  {
1649  GsfElectronPtrCollection::size_type ei = 1, emax = eventData_->electrons->size() ;
1650  GsfElectronPtrCollection::iterator eitr = eventData_->electrons->begin() ;
1651  while (eitr!=eventData_->electrons->end())
1652  {
1653  LogTrace("GsfElectronAlgo")<<"========== remove ambiguous "<<ei<<"/"<<emax<<"==========" ;
1654  if ((*eitr)->ambiguous())
1655  { delete (*eitr) ; eitr = eventData_->electrons->erase(eitr) ; ++ei ; }
1656  else
1657  { ++eitr ; ++ei ; }
1658  }
1659  }
1660 
1661 
#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:687
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:203
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:638
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)
void clonePreviousElectrons()
const LorentzVector & p4(P4Kind kind) const
Definition: GsfElectron.cc:229
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: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:356
bool passingCutBasedPreselection() const
Definition: GsfElectron.h:630
bool passingMvaPreselection() const
Definition: GsfElectron.h:646
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
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:348
bool isEB() const
Definition: GsfElectron.h:347
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
const Double_t pi
void setSuperClusterFbrem(float fbrem)
Definition: GsfElectron.h:688
static bool stripTIDHitFilter(uint32_t pattern)
Definition: HitPattern.h:458
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:247
void setCorrectedEcalEnergyError(float newEnergyError)
Definition: GsfElectron.cc:183
bool isNull() const
Checks for null.
Definition: Ref.h:247
T mag() const
Definition: PV3DBase.h:67
float sigmaIetaIeta() const
Definition: GsfElectron.h:399
bool isNotFinite(T x)
Definition: isFinite.h:10
void calculateShowerShape_full5x5(const reco::SuperClusterRef &, bool pflow, reco::GsfElectron::ShowerShape &)
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: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 &)
static bool pixelHitFilter(uint32_t pattern)
Definition: HitPattern.h:419
float hcalOverEcal() const
Definition: GsfElectron.h:407
void setPassMvaPreselection(bool flag)
Definition: GsfElectron.h:645
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
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
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
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
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:603
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: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:689
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:639
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
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
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:142
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
static bool stripTIBHitFilter(uint32_t pattern)
Definition: HitPattern.h:451
Candidate::LorentzVector calculateMomentum()
bool passingPflowPreselection() const
Definition: GsfElectron.h:631
const reco::BeamSpot beamSpot