00001 #ifndef GsfElectron_h
00002 #define GsfElectron_h
00003
00004 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
00005 #include "DataFormats/EgammaCandidates/interface/GsfElectronCore.h"
00006 #include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
00007 #include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h"
00008
00009 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00010 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00011 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
00012 #include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h"
00013
00014 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00015 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
00016 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00017 #include <vector>
00018 #include <limits>
00019
00020 namespace reco
00021 {
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 class GsfElectron : public RecoCandidate
00040 {
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 public :
00052
00053
00054 struct ChargeInfo ;
00055 struct TrackClusterMatching ;
00056 struct TrackExtrapolations ;
00057 struct ClosestCtfTrack ;
00058 struct FiducialFlags ;
00059 struct ShowerShape ;
00060 struct IsolationVariables ;
00061 struct ConversionRejection ;
00062
00063 GsfElectron() ;
00064 GsfElectron( const GsfElectronCoreRef & ) ;
00065 GsfElectron
00066 (
00067 const GsfElectron &,
00068 const GsfElectronCoreRef &
00069 ) ;
00070 GsfElectron
00071 (
00072 const GsfElectron & electron,
00073 const GsfElectronCoreRef & core,
00074 const CaloClusterPtr & electronCluster,
00075 const TrackRef & closestCtfTrack,
00076 const TrackBaseRef & conversionPartner,
00077 const GsfTrackRefVector & ambiguousTracks
00078 ) ;
00079 GsfElectron
00080 (
00081 const LorentzVector & p4, int charge,
00082 const ChargeInfo &,
00083 const GsfElectronCoreRef &,
00084 const TrackClusterMatching &,
00085 const TrackExtrapolations &,
00086 const ClosestCtfTrack &,
00087 const FiducialFlags &,
00088 const ShowerShape &,
00089 const ConversionRejection &,
00090 float fbrem
00091 ) ;
00092 GsfElectron * clone() const ;
00093 GsfElectron * clone
00094 (
00095 const GsfElectronCoreRef & core,
00096 const CaloClusterPtr & electronCluster,
00097 const TrackRef & closestCtfTrack,
00098 const TrackBaseRef & conversionPartner,
00099 const GsfTrackRefVector & ambiguousTracks
00100 ) const ;
00101 virtual ~GsfElectron() {} ;
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114 public:
00115
00116
00117
00118
00119
00120
00121 struct ChargeInfo
00122 {
00123 int scPixCharge ;
00124 bool isGsfCtfScPixConsistent ;
00125 bool isGsfScPixConsistent ;
00126 bool isGsfCtfConsistent ;
00127 ChargeInfo()
00128 : scPixCharge(0), isGsfCtfScPixConsistent(false),
00129 isGsfScPixConsistent(false), isGsfCtfConsistent(false)
00130 {}
00131 } ;
00132
00133
00134
00135
00136 int scPixCharge() const { return chargeInfo_.scPixCharge ; }
00137 bool isGsfCtfScPixChargeConsistent() const { return chargeInfo_.isGsfCtfScPixConsistent ; }
00138 bool isGsfScPixChargeConsistent() const { return chargeInfo_.isGsfScPixConsistent ; }
00139 bool isGsfCtfChargeConsistent() const { return chargeInfo_.isGsfCtfConsistent ; }
00140 const ChargeInfo & chargeInfo() const { return chargeInfo_ ; }
00141
00142
00143 virtual bool isElectron() const { return true ; }
00144 virtual bool overlap( const Candidate & ) const ;
00145
00146 private:
00147
00148
00149 ChargeInfo chargeInfo_ ;
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160 public:
00161
00162
00163 virtual GsfElectronCoreRef core() const { return core_ ; }
00164
00165
00166 SuperClusterRef superCluster() const { return core()->superCluster() ; }
00167 GsfTrackRef gsfTrack() const { return core()->gsfTrack() ; }
00168 bool ecalDrivenSeed() const { return core()->ecalDrivenSeed() ; }
00169 bool trackerDrivenSeed() const { return core()->trackerDrivenSeed() ; }
00170 SuperClusterRef pflowSuperCluster() const { return core()->pflowSuperCluster() ; }
00171
00172 private:
00173
00174
00175 GsfElectronCoreRef core_ ;
00176
00177
00178
00179
00180
00181
00182 public:
00183
00184 struct TrackClusterMatching
00185 {
00186 CaloClusterPtr electronCluster ;
00187 float eSuperClusterOverP ;
00188 float eSeedClusterOverP ;
00189 float eSeedClusterOverPout ;
00190 float eEleClusterOverPout ;
00191 float deltaEtaSuperClusterAtVtx ;
00192 float deltaEtaSeedClusterAtCalo ;
00193 float deltaEtaEleClusterAtCalo ;
00194 float deltaPhiEleClusterAtCalo ;
00195 float deltaPhiSuperClusterAtVtx ;
00196 float deltaPhiSeedClusterAtCalo ;
00197 } ;
00198
00199
00200 CaloClusterPtr electronCluster() const { return trackClusterMatching_.electronCluster ; }
00201 float eSuperClusterOverP() const { return trackClusterMatching_.eSuperClusterOverP ; }
00202 float eSeedClusterOverP() const { return trackClusterMatching_.eSeedClusterOverP ; }
00203 float eSeedClusterOverPout() const { return trackClusterMatching_.eSeedClusterOverPout ; }
00204 float eEleClusterOverPout() const { return trackClusterMatching_.eEleClusterOverPout ; }
00205 float deltaEtaSuperClusterTrackAtVtx() const { return trackClusterMatching_.deltaEtaSuperClusterAtVtx ; }
00206 float deltaEtaSeedClusterTrackAtCalo() const { return trackClusterMatching_.deltaEtaSeedClusterAtCalo ; }
00207 float deltaEtaEleClusterTrackAtCalo() const { return trackClusterMatching_.deltaEtaEleClusterAtCalo ; }
00208 float deltaPhiSuperClusterTrackAtVtx() const { return trackClusterMatching_.deltaPhiSuperClusterAtVtx ; }
00209 float deltaPhiSeedClusterTrackAtCalo() const { return trackClusterMatching_.deltaPhiSeedClusterAtCalo ; }
00210 float deltaPhiEleClusterTrackAtCalo() const { return trackClusterMatching_.deltaPhiEleClusterAtCalo ; }
00211 const TrackClusterMatching & trackClusterMatching() const { return trackClusterMatching_ ; }
00212
00213
00214 void setDeltaEtaSuperClusterAtVtx( float de ) { trackClusterMatching_.deltaEtaSuperClusterAtVtx = de ; }
00215 void setDeltaPhiSuperClusterAtVtx( float dphi ) { trackClusterMatching_.deltaPhiSuperClusterAtVtx = dphi ; }
00216
00217
00218 private:
00219
00220
00221 TrackClusterMatching trackClusterMatching_ ;
00222
00223
00224
00225
00226
00227
00228 public :
00229
00230 struct TrackExtrapolations
00231 {
00232 math::XYZPoint positionAtVtx ;
00233 math::XYZPoint positionAtCalo ;
00234 math::XYZVector momentumAtVtx ;
00235 math::XYZVector momentumAtCalo ;
00236 math::XYZVector momentumOut ;
00237 math::XYZVector momentumAtEleClus ;
00238 math::XYZVector momentumAtVtxWithConstraint ;
00239 } ;
00240
00241
00242 math::XYZPoint trackPositionAtVtx() const { return trackExtrapolations_.positionAtVtx ; }
00243 math::XYZPoint trackPositionAtCalo() const { return trackExtrapolations_.positionAtCalo ; }
00244 math::XYZVector trackMomentumAtVtx() const { return trackExtrapolations_.momentumAtVtx ; }
00245 math::XYZVector trackMomentumAtCalo() const { return trackExtrapolations_.momentumAtCalo ; }
00246 math::XYZVector trackMomentumOut() const { return trackExtrapolations_.momentumOut ; }
00247 math::XYZVector trackMomentumAtEleClus() const { return trackExtrapolations_.momentumAtEleClus ; }
00248 math::XYZVector trackMomentumAtVtxWithConstraint() const { return trackExtrapolations_.momentumAtVtxWithConstraint ; }
00249 const TrackExtrapolations & trackExtrapolations() const { return trackExtrapolations_ ; }
00250
00251
00252 math::XYZPoint TrackPositionAtVtx() const { return trackPositionAtVtx() ; }
00253 math::XYZPoint TrackPositionAtCalo() const { return trackPositionAtCalo() ; }
00254
00255
00256 private:
00257
00258
00259 TrackExtrapolations trackExtrapolations_ ;
00260
00261
00262
00263
00264
00265
00266 public :
00267
00268
00269 math::XYZPoint superClusterPosition() const { return superCluster()->position() ; }
00270 int basicClustersSize() const { return superCluster()->clustersSize() ; }
00271 CaloCluster_iterator basicClustersBegin() const { return superCluster()->clustersBegin() ; }
00272 CaloCluster_iterator basicClustersEnd() const { return superCluster()->clustersEnd() ; }
00273
00274
00275 math::XYZPoint caloPosition() const { return superCluster()->position() ; }
00276
00277
00278
00279
00280
00281
00282 public :
00283
00284 struct ClosestCtfTrack
00285 {
00286 TrackRef ctfTrack ;
00287 float shFracInnerHits ;
00288 ClosestCtfTrack() : shFracInnerHits(0.) {}
00289 } ;
00290
00291
00292 TrackRef closestCtfTrackRef() const { return closestCtfTrack_.ctfTrack ; }
00293 float shFracInnerHits() const { return closestCtfTrack_.shFracInnerHits ; }
00294 const ClosestCtfTrack & closestCtfTrack() const { return closestCtfTrack_ ; }
00295 GsfTrackRefVector::size_type ambiguousGsfTracksSize() const { return ambiguousGsfTracks_.size() ; }
00296 GsfTrackRefVector::const_iterator ambiguousGsfTracksBegin() const { return ambiguousGsfTracks_.begin() ; }
00297 GsfTrackRefVector::const_iterator ambiguousGsfTracksEnd() const { return ambiguousGsfTracks_.end() ; }
00298
00299
00300 void clearAmbiguousGsfTracks() { ambiguousGsfTracks_.clear() ; }
00301 void addAmbiguousGsfTrack( const reco::GsfTrackRef & t ) { ambiguousGsfTracks_.push_back(t) ; }
00302
00303
00304 private:
00305
00306
00307 ClosestCtfTrack closestCtfTrack_ ;
00308 GsfTrackRefVector ambiguousGsfTracks_ ;
00309
00310
00311
00312
00313
00314
00315 public :
00316
00317 struct FiducialFlags
00318 {
00319 bool isEB ;
00320 bool isEE ;
00321 bool isEBEEGap ;
00322 bool isEBEtaGap ;
00323 bool isEBPhiGap ;
00324 bool isEEDeeGap ;
00325 bool isEERingGap ;
00326 FiducialFlags()
00327 : isEB(false), isEE(false), isEBEEGap(false),
00328 isEBEtaGap(false), isEBPhiGap(false),
00329 isEEDeeGap(false), isEERingGap(false)
00330 {}
00331 } ;
00332
00333
00334 bool isEB() const { return fiducialFlags_.isEB ; }
00335 bool isEE() const { return fiducialFlags_.isEE ; }
00336 bool isGap() const { return ((isEBEEGap())||(isEBGap())||(isEEGap())) ; }
00337 bool isEBEEGap() const { return fiducialFlags_.isEBEEGap ; }
00338 bool isEBGap() const { return (isEBEtaGap()||isEBPhiGap()) ; }
00339 bool isEBEtaGap() const { return fiducialFlags_.isEBEtaGap ; }
00340 bool isEBPhiGap() const { return fiducialFlags_.isEBPhiGap ; }
00341 bool isEEGap() const { return (isEEDeeGap()||isEERingGap()) ; }
00342 bool isEEDeeGap() const { return fiducialFlags_.isEEDeeGap ; }
00343 bool isEERingGap() const { return fiducialFlags_.isEERingGap ; }
00344 const FiducialFlags & fiducialFlags() const { return fiducialFlags_ ; }
00345
00346
00347 private:
00348
00349
00350 FiducialFlags fiducialFlags_ ;
00351
00352
00353
00354
00355
00356
00357 public :
00358
00359 struct ShowerShape
00360 {
00361 float sigmaEtaEta ;
00362 float sigmaIetaIeta ;
00363 float e1x5 ;
00364 float e2x5Max ;
00365 float e5x5 ;
00366 float hcalDepth1OverEcal ;
00367 float hcalDepth2OverEcal ;
00368 ShowerShape()
00369 : sigmaEtaEta(std::numeric_limits<float>::infinity()),
00370 sigmaIetaIeta(std::numeric_limits<float>::infinity()),
00371 e1x5(0.), e2x5Max(0.), e5x5(0.),
00372 hcalDepth1OverEcal(0), hcalDepth2OverEcal(0)
00373 {}
00374 } ;
00375
00376
00377 float sigmaEtaEta() const { return showerShape_.sigmaEtaEta ; }
00378 float sigmaIetaIeta() const { return showerShape_.sigmaIetaIeta ; }
00379 float e1x5() const { return showerShape_.e1x5 ; }
00380 float e2x5Max() const { return showerShape_.e2x5Max ; }
00381 float e5x5() const { return showerShape_.e5x5 ; }
00382 float hcalDepth1OverEcal() const { return showerShape_.hcalDepth1OverEcal ; }
00383 float hcalDepth2OverEcal() const { return showerShape_.hcalDepth2OverEcal ; }
00384 float hcalOverEcal() const { return hcalDepth1OverEcal() + hcalDepth2OverEcal() ; }
00385 const ShowerShape & showerShape() const { return showerShape_ ; }
00386
00387
00388 float scSigmaEtaEta() const { return sigmaEtaEta() ; }
00389 float scSigmaIEtaIEta() const { return sigmaIetaIeta() ; }
00390 float scE1x5() const { return e1x5() ; }
00391 float scE2x5Max() const { return e2x5Max() ; }
00392 float scE5x5() const { return e5x5() ; }
00393 float hadronicOverEm() const {return hcalOverEcal();}
00394 float hadronicOverEm1() const {return hcalDepth1OverEcal();}
00395 float hadronicOverEm2() const {return hcalDepth2OverEcal();}
00396
00397
00398 private:
00399
00400
00401 ShowerShape showerShape_ ;
00402
00403
00404
00405
00406
00407
00408 public :
00409
00410 struct IsolationVariables
00411 {
00412 float tkSumPt ;
00413 float ecalRecHitSumEt ;
00414 float hcalDepth1TowerSumEt ;
00415 float hcalDepth2TowerSumEt ;
00416 IsolationVariables()
00417 : tkSumPt(0.), ecalRecHitSumEt(0.), hcalDepth1TowerSumEt(0.), hcalDepth2TowerSumEt(0.)
00418 {}
00419 } ;
00420
00421
00422 float dr03TkSumPt() const { return dr03_.tkSumPt ; }
00423 float dr03EcalRecHitSumEt() const { return dr03_.ecalRecHitSumEt ; }
00424 float dr03HcalDepth1TowerSumEt() const { return dr03_.hcalDepth1TowerSumEt ; }
00425 float dr03HcalDepth2TowerSumEt() const { return dr03_.hcalDepth2TowerSumEt ; }
00426 float dr03HcalTowerSumEt() const { return dr03HcalDepth1TowerSumEt()+dr03HcalDepth2TowerSumEt() ; }
00427 const IsolationVariables & dr03IsolationVariables() const { return dr03_ ; }
00428
00429
00430 float dr04TkSumPt() const { return dr04_.tkSumPt ; }
00431 float dr04EcalRecHitSumEt() const { return dr04_.ecalRecHitSumEt ; }
00432 float dr04HcalDepth1TowerSumEt() const { return dr04_.hcalDepth1TowerSumEt ; }
00433 float dr04HcalDepth2TowerSumEt() const { return dr04_.hcalDepth2TowerSumEt ; }
00434 float dr04HcalTowerSumEt() const { return dr04HcalDepth1TowerSumEt()+dr04HcalDepth2TowerSumEt() ; }
00435 const IsolationVariables & dr04IsolationVariables() const { return dr04_ ; }
00436
00437
00438 void setDr03Isolation( const IsolationVariables & dr03 ) { dr03_ = dr03 ; }
00439 void setDr04Isolation( const IsolationVariables & dr04 ) { dr04_ = dr04 ; }
00440
00441
00442 void setIsolation03( const IsolationVariables & dr03 ) { dr03_ = dr03 ; }
00443 void setIsolation04( const IsolationVariables & dr04 ) { dr04_ = dr04 ; }
00444 const IsolationVariables & isolationVariables03() const { return dr03_ ; }
00445 const IsolationVariables & isolationVariables04() const { return dr04_ ; }
00446
00447 private:
00448
00449
00450 IsolationVariables dr03_ ;
00451 IsolationVariables dr04_ ;
00452
00453
00454
00455
00456
00457
00458 public :
00459
00460 struct ConversionRejection
00461 {
00462 int flags ;
00463 TrackBaseRef partner ;
00464 float dist ;
00465 float dcot ;
00466 float radius ;
00467 ConversionRejection()
00468 : flags(-std::numeric_limits<float>::infinity()),
00469 dist(std::numeric_limits<float>::infinity()),
00470 dcot(std::numeric_limits<float>::infinity()),
00471 radius(std::numeric_limits<float>::infinity())
00472 {}
00473 } ;
00474
00475
00476 int convFlags() const { return conversionRejection_.flags ; }
00477 TrackBaseRef convPartner() const { return conversionRejection_.partner ; }
00478 float convDist() const { return conversionRejection_.dist ; }
00479 float convDcot() const { return conversionRejection_.dcot ; }
00480 float convRadius() const { return conversionRejection_.radius ; }
00481 const ConversionRejection & conversionRejectionVariables() const { return conversionRejection_ ; }
00482
00483 private:
00484
00485
00486 ConversionRejection conversionRejection_ ;
00487
00488
00489
00490
00491
00492
00493 public :
00494
00495
00496 bool ecalDriven() const ;
00497 bool passingCutBasedPreselection() const { return passCutBasedPreselection_ ; }
00498 bool passingMvaPreselection() const { return passMvaPreslection_ ; }
00499 bool ambiguous() const { return ambiguous_ ; }
00500 float mva() const { return mva_ ; }
00501
00502
00503 void setPassCutBasedPreselection( bool flag ) { passCutBasedPreselection_ = flag ; }
00504 void setPassMvaPreselection( bool flag ) { passMvaPreslection_ = flag ; }
00505 void setAmbiguous( bool flag ) { ambiguous_ = flag ; }
00506 void setMva( float mva ) { mva_ = mva ; }
00507
00508 private:
00509
00510
00511 bool passCutBasedPreselection_ ;
00512 bool passMvaPreslection_ ;
00513 bool ambiguous_ ;
00514 float mva_ ;
00515
00516
00517
00518
00519
00520
00521
00522
00523 public :
00524
00525 enum Classification { UNKNOWN=-1, GOLDEN=0, BIGBREM=1, OLDNARROW=2, SHOWERING=3, GAP=4 } ;
00526
00527
00528 float fbrem() const { return fbrem_ ; }
00529 int numberOfBrems() const { return basicClustersSize()-1 ; }
00530 Classification classification() const { return class_ ; }
00531
00532
00533 void classifyElectron( Classification myclass ) { class_ = myclass ; }
00534
00535 private:
00536
00537
00538 float fbrem_ ;
00539 Classification class_ ;
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563 public :
00564
00565 struct Corrections
00566 {
00567 bool isEcalEnergyCorrected ;
00568 float ecalEnergy ;
00569 float ecalEnergyError ;
00570 bool isMomentumCorrected ;
00571 float trackMomentumError ;
00572 float electronMomentumError ;
00573 Corrections()
00574 : isEcalEnergyCorrected(false), ecalEnergy(0.), ecalEnergyError(999.),
00575 isMomentumCorrected(false), trackMomentumError(999.), electronMomentumError(999.)
00576 {}
00577 } ;
00578
00579
00580 void correctEcalEnergy( float newEnergy, float newEnergyError ) ;
00581 void correctMomentum
00582 ( const LorentzVector & momentum,
00583 float trackMomentumError, float electronMomentumError ) ;
00584
00585
00586 bool isEcalEnergyCorrected() const { return corrections_.isEcalEnergyCorrected ; }
00587 float ecalEnergy() const { return corrections_.ecalEnergy ; }
00588 float ecalEnergyError() const { return corrections_.ecalEnergyError ; }
00589 bool isMomentumCorrected() const { return corrections_.isMomentumCorrected ; }
00590 float trackMomentumError() const { return corrections_.trackMomentumError ; }
00591 float electronMomentumError() const { return corrections_.electronMomentumError ; }
00592 const Corrections & corrections() const { return corrections_ ; }
00593
00594
00595 float caloEnergy() const { return ecalEnergy() ; }
00596
00597
00598
00599
00600
00601
00602 bool isEnergyScaleCorrected() const { return isEcalEnergyCorrected() ; }
00603
00604 private:
00605
00606
00607 Corrections corrections_ ;
00608
00609 } ;
00610
00611
00612
00613 }
00614
00615 #endif