CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DataFormats/EgammaCandidates/interface/GsfElectron.h

Go to the documentation of this file.
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 //#include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
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 //#include "DataFormats/Math/interface/LorentzVector.h"
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  * \class reco::GsfElectron
00026  *
00027  * An Electron with a GsfTrack seeded from an ElectronSeed.
00028  * Renamed from PixelMatchGsfElectron.
00029  * Originally adapted from the TRecElectron class in ORCA.
00030  *
00031  * \author Claude Charlot - Laboratoire Leprince-Ringuet - École polytechnique, CNRS/IN2P3
00032  * \author David Chamont  - Laboratoire Leprince-Ringuet - École polytechnique, CNRS/IN2P3
00033  * \author Ursula Berthon - Laboratoire Leprince-Ringuet - École polytechnique, CNRS/IN2P3
00034  *
00035  ****************************************************************************/
00036 
00037 class GsfElectron : public RecoCandidate
00038  {
00039 
00040   //=======================================================
00041   // Constructors
00042   //
00043   // The clone() method with arguments, and the copy
00044   // constructor with edm references is designed for
00045   // someone which want to duplicates all
00046   // collections.
00047   //=======================================================
00048 
00049   public :
00050 
00051     // some nested structures defined later on
00052     struct ChargeInfo ;
00053     struct TrackClusterMatching ;
00054     struct TrackExtrapolations ;
00055     struct ClosestCtfTrack ;
00056     struct FiducialFlags ;
00057     struct ShowerShape ;
00058     struct IsolationVariables ;
00059     struct ConversionRejection ;
00060 
00061     GsfElectron() ;
00062     GsfElectron( const GsfElectronCoreRef & ) ;
00063     GsfElectron
00064      (
00065       const GsfElectron &,
00066       const GsfElectronCoreRef &
00067      ) ;
00068     GsfElectron
00069      (
00070       const GsfElectron & electron,
00071       const GsfElectronCoreRef & core,
00072       const CaloClusterPtr & electronCluster,
00073       const TrackRef & closestCtfTrack,
00074       const TrackBaseRef & conversionPartner,
00075       const GsfTrackRefVector & ambiguousTracks
00076      ) ;
00077     GsfElectron
00078      (
00079       int charge,
00080       const ChargeInfo &,
00081       const GsfElectronCoreRef &,
00082       const TrackClusterMatching &,
00083       const TrackExtrapolations &,
00084       const ClosestCtfTrack &,
00085       const FiducialFlags &,
00086       const ShowerShape &,
00087       const ConversionRejection &,
00088       float fbrem
00089      ) ;
00090     GsfElectron * clone() const ;
00091     GsfElectron * clone
00092      (
00093       const GsfElectronCoreRef & core,
00094       const CaloClusterPtr & electronCluster,
00095       const TrackRef & closestCtfTrack,
00096       const TrackBaseRef & conversionPartner,
00097       const GsfTrackRefVector & ambiguousTracks
00098      ) const ;
00099     virtual ~GsfElectron() {} ;
00100 
00101   private:
00102 
00103     void init() ;
00104 
00105 
00106   //=======================================================
00107   // Candidate methods and complementary information
00108   //
00109   // The gsf electron producer has tried to best evaluate
00110   // the four momentum and charge and given those values to
00111   // the GsfElectron constructor, which forwarded them to
00112   // the Candidate constructor. Those values can be retreived
00113   // with getters inherited from Candidate : p4() and charge().
00114   //=======================================================
00115 
00116   public:
00117 
00118     // Inherited from Candidate
00119     // const LorentzVector & charge() const ;
00120     // const LorentzVector & p4() const ;
00121 
00122     // Complementary struct
00123     struct ChargeInfo
00124      {
00125       int scPixCharge ;
00126       bool isGsfCtfScPixConsistent ;
00127       bool isGsfScPixConsistent ;
00128       bool isGsfCtfConsistent ;
00129       ChargeInfo()
00130         : scPixCharge(0), isGsfCtfScPixConsistent(false),
00131           isGsfScPixConsistent(false), isGsfCtfConsistent(false)
00132         {}
00133      } ;
00134 
00135     // Charge info accessors
00136     // to get gsf track charge: gsfTrack()->charge()
00137     // to get ctf track charge, if closestCtfTrackRef().isNonnull(): closestCtfTrackRef()->charge()
00138     int scPixCharge() const { return chargeInfo_.scPixCharge ; }
00139     bool isGsfCtfScPixChargeConsistent() const { return chargeInfo_.isGsfCtfScPixConsistent ; }
00140     bool isGsfScPixChargeConsistent() const { return chargeInfo_.isGsfScPixConsistent ; }
00141     bool isGsfCtfChargeConsistent() const { return chargeInfo_.isGsfCtfConsistent ; }
00142     const ChargeInfo & chargeInfo() const { return chargeInfo_ ; }
00143 
00144     // Candidate redefined methods
00145     virtual bool isElectron() const { return true ; }
00146     virtual bool overlap( const Candidate & ) const ;
00147 
00148   private:
00149 
00150     // Complementary attributes
00151     ChargeInfo chargeInfo_ ;
00152 
00153 
00154   //=======================================================
00155   // Core Attributes
00156   //
00157   // They all have been computed before, when building the
00158   // collection of GsfElectronCore instances. Each GsfElectron
00159   // has a reference toward a GsfElectronCore.
00160   //=======================================================
00161 
00162   public:
00163 
00164     // accessors
00165     virtual GsfElectronCoreRef core() const ;
00166 
00167     // forward core methods
00168     SuperClusterRef superCluster() const { return core()->superCluster() ; }
00169     GsfTrackRef gsfTrack() const { return core()->gsfTrack() ; }
00170     bool ecalDrivenSeed() const { return core()->ecalDrivenSeed() ; }
00171     bool trackerDrivenSeed() const { return core()->trackerDrivenSeed() ; }
00172     SuperClusterRef pflowSuperCluster() const { return core()->pflowSuperCluster() ; }
00173 
00174   private:
00175 
00176     // attributes
00177     GsfElectronCoreRef core_ ;
00178 
00179 
00180   //=======================================================
00181   // Track-Cluster Matching Attributes
00182   //=======================================================
00183 
00184   public:
00185 
00186     struct TrackClusterMatching
00187      {
00188       CaloClusterPtr electronCluster ;  // basic cluster best matching gsf track
00189       float eSuperClusterOverP ;        // the supercluster energy / track momentum at the PCA to the beam spot
00190       float eSeedClusterOverP ;         // the seed cluster energy / track momentum at the PCA to the beam spot
00191       float eSeedClusterOverPout ;      // the seed cluster energy / track momentum at calo extrapolated from the outermost track state
00192       float eEleClusterOverPout ;       // the electron cluster energy / track momentum at calo extrapolated from the outermost track state
00193       float deltaEtaSuperClusterAtVtx ; // the supercluster eta - track eta position at calo extrapolated from innermost track state
00194       float deltaEtaSeedClusterAtCalo ; // the seed cluster eta - track eta position at calo extrapolated from the outermost track state
00195       float deltaEtaEleClusterAtCalo ;  // the electron cluster eta - track eta position at calo extrapolated from the outermost state
00196       float deltaPhiEleClusterAtCalo ;  // the electron cluster phi - track phi position at calo extrapolated from the outermost track state
00197       float deltaPhiSuperClusterAtVtx ; // the supercluster phi - track phi position at calo extrapolated from the innermost track state
00198       float deltaPhiSeedClusterAtCalo ; // the seed cluster phi - track phi position at calo extrapolated from the outermost track state
00199       TrackClusterMatching()
00200        : eSuperClusterOverP(0.),
00201          eSeedClusterOverP(0.),
00202          eSeedClusterOverPout(0.),
00203          eEleClusterOverPout(0.),
00204          deltaEtaSuperClusterAtVtx(std::numeric_limits<float>::infinity()),
00205          deltaEtaSeedClusterAtCalo(std::numeric_limits<float>::infinity()),
00206          deltaEtaEleClusterAtCalo(std::numeric_limits<float>::infinity()),
00207          deltaPhiEleClusterAtCalo(std::numeric_limits<float>::infinity()),
00208          deltaPhiSuperClusterAtVtx(std::numeric_limits<float>::infinity()),
00209          deltaPhiSeedClusterAtCalo(std::numeric_limits<float>::infinity())
00210         {}
00211      } ;
00212 
00213     // accessors
00214     CaloClusterPtr electronCluster() const { return trackClusterMatching_.electronCluster ; }
00215     float eSuperClusterOverP() const { return trackClusterMatching_.eSuperClusterOverP ; }
00216     float eSeedClusterOverP() const { return trackClusterMatching_.eSeedClusterOverP ; }
00217     float eSeedClusterOverPout() const { return trackClusterMatching_.eSeedClusterOverPout ; }
00218     float eEleClusterOverPout() const { return trackClusterMatching_.eEleClusterOverPout ; }
00219     float deltaEtaSuperClusterTrackAtVtx() const { return trackClusterMatching_.deltaEtaSuperClusterAtVtx ; }
00220     float deltaEtaSeedClusterTrackAtCalo() const { return trackClusterMatching_.deltaEtaSeedClusterAtCalo ; }
00221     float deltaEtaEleClusterTrackAtCalo() const { return trackClusterMatching_.deltaEtaEleClusterAtCalo ; }
00222     float deltaPhiSuperClusterTrackAtVtx() const { return trackClusterMatching_.deltaPhiSuperClusterAtVtx ; }
00223     float deltaPhiSeedClusterTrackAtCalo() const { return trackClusterMatching_.deltaPhiSeedClusterAtCalo ; }
00224     float deltaPhiEleClusterTrackAtCalo() const { return trackClusterMatching_.deltaPhiEleClusterAtCalo ; }
00225     const TrackClusterMatching & trackClusterMatching() const { return trackClusterMatching_ ; }
00226 
00227     // for backward compatibility, usefull ?
00228     void setDeltaEtaSuperClusterAtVtx( float de ) { trackClusterMatching_.deltaEtaSuperClusterAtVtx = de ; }
00229     void setDeltaPhiSuperClusterAtVtx( float dphi ) { trackClusterMatching_.deltaPhiSuperClusterAtVtx = dphi ; }
00230 
00231 
00232   private:
00233 
00234     // attributes
00235     TrackClusterMatching trackClusterMatching_ ;
00236 
00237 
00238   //=======================================================
00239   // Track extrapolations
00240   //=======================================================
00241 
00242   public :
00243 
00244     struct TrackExtrapolations
00245      {
00246       math::XYZPointF  positionAtVtx ;     // the track PCA to the beam spot
00247       math::XYZPointF  positionAtCalo ;    // the track PCA to the supercluster position
00248       math::XYZVectorF momentumAtVtx ;     // the track momentum at the PCA to the beam spot
00249       math::XYZVectorF momentumAtCalo ;    // the track momentum extrapolated at the supercluster position from the innermost track state
00250       math::XYZVectorF momentumOut ;       // the track momentum extrapolated at the seed cluster position from the outermost track state
00251       math::XYZVectorF momentumAtEleClus ; // the track momentum extrapolated at the ele cluster position from the outermost track state
00252       math::XYZVectorF momentumAtVtxWithConstraint ;     // the track momentum at the PCA to the beam spot using bs constraint
00253      } ;
00254 
00255     // accessors
00256     math::XYZPointF trackPositionAtVtx() const { return trackExtrapolations_.positionAtVtx ; }
00257     math::XYZPointF trackPositionAtCalo() const { return trackExtrapolations_.positionAtCalo ; }
00258     math::XYZVectorF trackMomentumAtVtx() const { return trackExtrapolations_.momentumAtVtx ; }
00259     math::XYZVectorF trackMomentumAtCalo() const { return trackExtrapolations_.momentumAtCalo ; }
00260     math::XYZVectorF trackMomentumOut() const { return trackExtrapolations_.momentumOut ; }
00261     math::XYZVectorF trackMomentumAtEleClus() const { return trackExtrapolations_.momentumAtEleClus ; }
00262     math::XYZVectorF trackMomentumAtVtxWithConstraint() const { return trackExtrapolations_.momentumAtVtxWithConstraint ; }
00263     const TrackExtrapolations & trackExtrapolations() const { return trackExtrapolations_ ; }
00264 
00265     // for backward compatibility
00266     math::XYZPointF TrackPositionAtVtx() const { return trackPositionAtVtx() ; }
00267     math::XYZPointF TrackPositionAtCalo() const { return trackPositionAtCalo() ; }
00268 
00269 
00270   private:
00271 
00272     // attributes
00273     TrackExtrapolations trackExtrapolations_ ;
00274 
00275 
00276   //=======================================================
00277   // SuperCluster direct access
00278   //=======================================================
00279 
00280   public :
00281 
00282     // direct accessors
00283     math::XYZPoint superClusterPosition() const { return superCluster()->position() ; } // the super cluster position
00284     int basicClustersSize() const { return superCluster()->clustersSize() ; } // number of basic clusters inside the supercluster
00285     CaloCluster_iterator basicClustersBegin() const { return superCluster()->clustersBegin() ; }
00286     CaloCluster_iterator basicClustersEnd() const { return superCluster()->clustersEnd() ; }
00287 
00288     // for backward compatibility
00289     math::XYZPoint caloPosition() const { return superCluster()->position() ; }
00290 
00291 
00292   //=======================================================
00293   // For backward compatibility
00294   //=======================================================
00295 
00296   public :
00297 
00298     struct ClosestCtfTrack
00299      {
00300       TrackRef ctfTrack ; // best matching ctf track
00301       float shFracInnerHits ; // fraction of common hits between the ctf and gsf tracks
00302       ClosestCtfTrack() : shFracInnerHits(0.) {}
00303       ClosestCtfTrack( TrackRef track, float sh ) : ctfTrack(track), shFracInnerHits(sh) {}
00304      } ;
00305 
00306 
00307     // for backward compatibility
00308     float shFracInnerHits() const { return core()->ctfGsfOverlap() ; } // measure the fraction of common hits between the GSF and CTF tracks
00309     TrackRef closestCtfTrackRef() const { return core()->ctfTrack() ; }
00310     ClosestCtfTrack closestCtfTrack() const { return ClosestCtfTrack(core()->ctfTrack(),core()->ctfGsfOverlap()) ; }
00311 
00312   private :
00313 
00314     //ClosestCtfTrack closestCtfTrack_ ;
00315 
00316 
00317   //=======================================================
00318   // Fiducial Flags
00319   //=======================================================
00320 
00321   public :
00322 
00323     struct FiducialFlags
00324      {
00325       bool isEB ;        // true if particle is in ECAL Barrel
00326       bool isEE ;        // true if particle is in ECAL Endcaps
00327       bool isEBEEGap ;   // true if particle is in the crack between EB and EE
00328       bool isEBEtaGap ;  // true if particle is in EB, and inside the eta gaps between modules
00329       bool isEBPhiGap ;  // true if particle is in EB, and inside the phi gaps between modules
00330       bool isEEDeeGap ;  // true if particle is in EE, and inside the gaps between dees
00331       bool isEERingGap ; // true if particle is in EE, and inside the gaps between rings
00332       FiducialFlags()
00333        : isEB(false), isEE(false), isEBEEGap(false),
00334          isEBEtaGap(false), isEBPhiGap(false),
00335              isEEDeeGap(false), isEERingGap(false)
00336            {}
00337      } ;
00338 
00339     // accessors
00340     bool isEB() const { return fiducialFlags_.isEB ; }
00341     bool isEE() const { return fiducialFlags_.isEE ; }
00342     bool isGap() const { return ((isEBEEGap())||(isEBGap())||(isEEGap())) ; }
00343     bool isEBEEGap() const { return fiducialFlags_.isEBEEGap ; }
00344     bool isEBGap() const { return (isEBEtaGap()||isEBPhiGap()) ; }
00345     bool isEBEtaGap() const { return fiducialFlags_.isEBEtaGap ; }
00346     bool isEBPhiGap() const { return fiducialFlags_.isEBPhiGap ; }
00347     bool isEEGap() const { return (isEEDeeGap()||isEERingGap()) ; }
00348     bool isEEDeeGap() const { return fiducialFlags_.isEEDeeGap ; }
00349     bool isEERingGap() const { return fiducialFlags_.isEERingGap ; }
00350     const FiducialFlags & fiducialFlags() const { return fiducialFlags_ ; }
00351 
00352 
00353   private:
00354 
00355     // attributes
00356     FiducialFlags fiducialFlags_ ;
00357 
00358 
00359   //=======================================================
00360   // Shower Shape Variables
00361   //=======================================================
00362 
00363   public :
00364 
00365     struct ShowerShape
00366      {
00367       float sigmaEtaEta ;        // weighted cluster rms along eta and inside 5x5 (absolute eta)
00368       float sigmaIetaIeta ;      // weighted cluster rms along eta and inside 5x5 (new, Xtal eta)
00369       float e1x5 ;               // energy inside 1x5 in etaxphi around the seed Xtal
00370       float e2x5Max ;            // energy inside 2x5 in etaxphi around the seed Xtal (max bwt the 2 possible sums)
00371       float e5x5 ;               // energy inside 5x5 in etaxphi around the seed Xtal
00372       float hcalDepth1OverEcal ; // hcal over ecal seed cluster energy using first hcal depth (hcal is energy of towers within dR=015)
00373       float hcalDepth2OverEcal ; // hcal over ecal seed cluster energy using 2nd hcal depth (hcal is energy of towers within dR=015)
00374       ShowerShape()
00375        : sigmaEtaEta(std::numeric_limits<float>::infinity()),
00376              sigmaIetaIeta(std::numeric_limits<float>::infinity()),
00377              e1x5(0.), e2x5Max(0.), e5x5(0.),
00378              hcalDepth1OverEcal(0.), hcalDepth2OverEcal(0.)
00379        {}
00380      } ;
00381 
00382     // accessors
00383     float sigmaEtaEta() const { return showerShape_.sigmaEtaEta ; }
00384     float sigmaIetaIeta() const { return showerShape_.sigmaIetaIeta ; }
00385     float e1x5() const { return showerShape_.e1x5 ; }
00386     float e2x5Max() const { return showerShape_.e2x5Max ; }
00387     float e5x5() const { return showerShape_.e5x5 ; }
00388     float hcalDepth1OverEcal() const { return showerShape_.hcalDepth1OverEcal ; }
00389     float hcalDepth2OverEcal() const { return showerShape_.hcalDepth2OverEcal ; }
00390     float hcalOverEcal() const { return hcalDepth1OverEcal() + hcalDepth2OverEcal() ; }
00391     const ShowerShape & showerShape() const { return showerShape_ ; }
00392 
00393     // for backward compatibility
00394     float scSigmaEtaEta() const { return sigmaEtaEta() ; }
00395     float scSigmaIEtaIEta() const { return sigmaIetaIeta() ; }
00396     float scE1x5() const { return e1x5() ; }
00397     float scE2x5Max() const { return e2x5Max() ; }
00398     float scE5x5() const { return e5x5() ; }
00399     float hadronicOverEm() const {return hcalOverEcal();}
00400     float hadronicOverEm1() const {return hcalDepth1OverEcal();}
00401     float hadronicOverEm2() const {return hcalDepth2OverEcal();}
00402 
00403 
00404   private:
00405 
00406     // attributes
00407     ShowerShape showerShape_ ;
00408 
00409 
00410   //=======================================================
00411   // Isolation Variables
00412   //=======================================================
00413 
00414   public :
00415 
00416     struct IsolationVariables
00417      {
00418       float tkSumPt ;                // track iso deposit with electron footprint removed
00419       float ecalRecHitSumEt ;        // ecal iso deposit with electron footprint removed
00420       float hcalDepth1TowerSumEt ;   // hcal depht 1 iso deposit with electron footprint removed
00421       float hcalDepth2TowerSumEt ;   // hcal depht 2 iso deposit with electron footprint removed
00422       IsolationVariables()
00423        : tkSumPt(0.), ecalRecHitSumEt(0.), hcalDepth1TowerSumEt(0.), hcalDepth2TowerSumEt(0.)
00424        {}
00425      } ;
00426 
00427     // 03 accessors
00428     float dr03TkSumPt() const { return dr03_.tkSumPt ; }
00429     float dr03EcalRecHitSumEt() const { return dr03_.ecalRecHitSumEt ; }
00430     float dr03HcalDepth1TowerSumEt() const { return dr03_.hcalDepth1TowerSumEt ; }
00431     float dr03HcalDepth2TowerSumEt() const { return dr03_.hcalDepth2TowerSumEt ; }
00432     float dr03HcalTowerSumEt() const { return dr03HcalDepth1TowerSumEt()+dr03HcalDepth2TowerSumEt() ; }
00433     const IsolationVariables & dr03IsolationVariables() const { return dr03_ ; }
00434 
00435     // 04 accessors
00436     float dr04TkSumPt() const { return dr04_.tkSumPt ; }
00437     float dr04EcalRecHitSumEt() const { return dr04_.ecalRecHitSumEt ; }
00438     float dr04HcalDepth1TowerSumEt() const { return dr04_.hcalDepth1TowerSumEt ; }
00439     float dr04HcalDepth2TowerSumEt() const { return dr04_.hcalDepth2TowerSumEt ; }
00440     float dr04HcalTowerSumEt() const { return dr04HcalDepth1TowerSumEt()+dr04HcalDepth2TowerSumEt() ; }
00441     const IsolationVariables & dr04IsolationVariables() const { return dr04_ ; }
00442 
00443     // setters ?!?
00444     void setDr03Isolation( const IsolationVariables & dr03 ) { dr03_ = dr03 ; }
00445     void setDr04Isolation( const IsolationVariables & dr04 ) { dr04_ = dr04 ; }
00446 
00447     // for backward compatibility
00448     void setIsolation03( const IsolationVariables & dr03 ) { dr03_ = dr03 ; }
00449     void setIsolation04( const IsolationVariables & dr04 ) { dr04_ = dr04 ; }
00450     const IsolationVariables & isolationVariables03() const { return dr03_ ; }
00451     const IsolationVariables & isolationVariables04() const { return dr04_ ; }
00452 
00453   private:
00454 
00455     // attributes
00456     IsolationVariables dr03_ ;
00457     IsolationVariables dr04_ ;
00458 
00459 
00460   //=======================================================
00461   // Conversion Rejection Information
00462   //=======================================================
00463 
00464   public :
00465 
00466     struct ConversionRejection
00467      {
00468       int flags ;  // -infinity:not-computed, other: as computed by Puneeth conversion code
00469       TrackBaseRef partner ; // conversion partner
00470       float dist ; // distance to the conversion partner
00471       float dcot ; // difference of cot(angle) with the conversion partner track
00472       float radius ; // signed conversion radius
00473       ConversionRejection()
00474        : flags(-std::numeric_limits<float>::infinity()),
00475          dist(std::numeric_limits<float>::infinity()),
00476          dcot(std::numeric_limits<float>::infinity()),
00477          radius(std::numeric_limits<float>::infinity())
00478        {}
00479      } ;
00480 
00481     // accessors
00482     int convFlags() const { return conversionRejection_.flags ; }
00483     TrackBaseRef convPartner() const { return conversionRejection_.partner ; }
00484     float convDist() const { return conversionRejection_.dist ; }
00485     float convDcot() const { return conversionRejection_.dcot ; }
00486     float convRadius() const { return conversionRejection_.radius ; }
00487     const ConversionRejection & conversionRejectionVariables() const { return conversionRejection_ ; }
00488 
00489   private:
00490 
00491     // attributes
00492     ConversionRejection conversionRejection_ ;
00493 
00494 
00495   //=======================================================
00496   // Pflow Information
00497   //=======================================================
00498 
00499   public:
00500 
00501     struct PflowIsolationVariables
00502       {
00503        float chargedHadronIso ;
00504        float neutralHadronIso ;
00505        float photonIso ;
00506        PflowIsolationVariables()
00507         : chargedHadronIso(0.), neutralHadronIso(0.), photonIso(0.)
00508         {}
00509       } ;
00510 
00511     struct MvaInput
00512      {
00513       int earlyBrem ; // Early Brem detected (-2=>unknown,-1=>could not be evaluated,0=>wrong,1=>true)
00514       int lateBrem ; // Late Brem detected (-2=>unknown,-1=>could not be evaluated,0=>wrong,1=>true)
00515       float sigmaEtaEta ; // Sigma-eta-eta with the PF cluster
00516       float hadEnergy ; // Associated PF Had Cluster energy
00517       float deltaEta ; // PF-cluster GSF track delta-eta
00518       MvaInput()
00519        : earlyBrem(-2), lateBrem(-2),
00520          sigmaEtaEta(std::numeric_limits<float>::infinity()),
00521          hadEnergy(0.),
00522          deltaEta(std::numeric_limits<float>::infinity())
00523        {}
00524      } ;
00525 
00526     struct MvaOutput
00527      {
00528       int status ; // see PFCandidateElectronExtra::StatusFlag
00529       float mva ;
00530       MvaOutput()
00531        : status(-1), mva(-999999999.)
00532        {}
00533      } ;
00534 
00535     // accessors
00536     const ShowerShape & pfShowerShape() const { return pfShowerShape_ ; }
00537     const PflowIsolationVariables & pfIsolationVariables() const { return pfIso_ ; }
00538     const MvaInput & mvaInput() const { return mvaInput_ ; }
00539     const MvaOutput & mvaOutput() const { return mvaOutput_ ; }
00540 
00541     // setters
00542     void setPfShowerShape( const ShowerShape & shape ) { pfShowerShape_ = shape ; }
00543     void setPfIsolationVariables( const PflowIsolationVariables & iso ) { pfIso_ = iso ; }
00544     void setMvaInput( const MvaInput & mi ) { mvaInput_ = mi ; }
00545     void setMvaOutput( const MvaOutput & mo ) { mvaOutput_ = mo ; }
00546 
00547     // for backward compatibility
00548     float mva() const { return mvaOutput_.mva ; }
00549 
00550   private:
00551 
00552     ShowerShape pfShowerShape_ ;
00553     PflowIsolationVariables pfIso_ ;
00554     MvaInput mvaInput_ ;
00555     MvaOutput mvaOutput_ ;
00556 
00557 
00558   //=======================================================
00559   // Preselection and Ambiguity
00560   //=======================================================
00561 
00562   public :
00563 
00564     // accessors
00565     bool ecalDriven() const ; // return true if ecalDrivenSeed() and passingCutBasedPreselection()
00566     bool passingCutBasedPreselection() const { return passCutBasedPreselection_ ; }
00567     bool passingMvaPreselection() const { return passMvaPreslection_ ; }
00568     bool ambiguous() const { return ambiguous_ ; }
00569     GsfTrackRefVector::size_type ambiguousGsfTracksSize() const { return ambiguousGsfTracks_.size() ; }
00570     GsfTrackRefVector::const_iterator ambiguousGsfTracksBegin() const { return ambiguousGsfTracks_.begin() ; }
00571     GsfTrackRefVector::const_iterator ambiguousGsfTracksEnd() const { return ambiguousGsfTracks_.end() ; }
00572 
00573     // setters
00574     void setPassCutBasedPreselection( bool flag ) { passCutBasedPreselection_ = flag ; }
00575     void setPassMvaPreselection( bool flag ) { passMvaPreslection_ = flag ; }
00576     void setAmbiguous( bool flag ) { ambiguous_ = flag ; }
00577     void clearAmbiguousGsfTracks() { ambiguousGsfTracks_.clear() ; }
00578     void addAmbiguousGsfTrack( const reco::GsfTrackRef & t ) { ambiguousGsfTracks_.push_back(t) ; }
00579 
00580   private:
00581 
00582     // attributes
00583     bool passCutBasedPreselection_ ;
00584     bool passMvaPreslection_ ;
00585     bool ambiguous_ ;
00586     GsfTrackRefVector ambiguousGsfTracks_ ; // ambiguous gsf tracks
00587 
00588 
00589   //=======================================================
00590   // Brem Fraction and Classification
00591   // * fbrem given to the GsfElectron constructor
00592   // * classification computed later
00593   //=======================================================
00594 
00595   public :
00596 
00597     enum Classification { UNKNOWN=-1, GOLDEN=0, BIGBREM=1, OLDNARROW=2, SHOWERING=3, GAP=4 } ;
00598 
00599     // accessors
00600     float fbrem() const { return fbrem_ ; }
00601     int numberOfBrems() const { return basicClustersSize()-1 ; }
00602     Classification classification() const { return class_ ; }
00603 
00604     // setters
00605     void classifyElectron( Classification myclass ) { class_ = myclass ; }
00606 
00607   private:
00608 
00609     // attributes
00610     float fbrem_ ; // the brem fraction from gsf fit: (track momentum in - track momentum out) / track momentum in
00611     Classification class_ ; // fbrem and number of clusters based electron classification
00612 
00613 
00614   //=======================================================
00615   // Corrections
00616   //
00617   // The only methods, with classification, which modify
00618   // the electrons after they have been constructed.
00619   // They change a given characteristic, such as the super-cluster
00620   // energy, and propagate the change consistently
00621   // to all the depending attributes.
00622   // We expect the methods to be called in a given order
00623   // and so to store specific kind of corrections
00624   // 1) classify()
00625   // 2) correctEcalEnergy() : depending on classification and eta
00626   // 3) correctMomemtum() : depending on classification and ecal energy and tracker momentum errors
00627   //
00628   // Beware that correctEcalEnergy() is modifying few attributes which
00629   // were potentially used for preselection, whose value used in
00630   // preselection will not be available any more :
00631   // hcalDepth1OverEcal, hcalDepth2OverEcal, eSuperClusterOverP,
00632   // eSeedClusterOverP, eEleClusterOverPout.
00633   //=======================================================
00634 
00635   public :
00636 
00637     enum P4Kind { P4_UNKNOWN=-1, P4_FROM_SUPER_CLUSTER=0, P4_COMBINATION=1, P4_PFLOW_COMBINATION=2 } ;
00638 
00639     struct Corrections
00640      {
00641       bool isEcalEnergyCorrected ;  // true if ecal energy has been corrected
00642       float ecalEnergy ;            // ecal corrected energy (if !isEcalEnergyCorrected this value is identical to the supercluster energy)
00643       float ecalEnergyError ;       // error on correctedCaloEnergy
00644       //bool isMomentumCorrected ;    // DEPRECATED
00645       float trackMomentumError ;    // track momentum error from gsf fit
00646       //
00647       LorentzVector fromSuperClusterP4 ; // for P4_FROM_SUPER_CLUSTER
00648       float fromSuperClusterP4Error ;    // for P4_FROM_SUPER_CLUSTER
00649       LorentzVector combinedP4 ;    // for P4_COMBINATION
00650       float combinedP4Error ;       // for P4_COMBINATION
00651       LorentzVector pflowP4 ;       // for P4_PFLOW_COMBINATION
00652       float pflowP4Error ;          // for P4_PFLOW_COMBINATION
00653       P4Kind candidateP4Kind ;  // say which momentum has been stored in reco::Candidate
00654       //
00655       Corrections()
00656        : isEcalEnergyCorrected(false), ecalEnergy(0.), ecalEnergyError(999.),
00657              /*isMomentumCorrected(false),*/ trackMomentumError(999.),
00658              fromSuperClusterP4Error(999.), combinedP4Error(999.), pflowP4Error(999.),
00659              candidateP4Kind(P4_UNKNOWN)
00660        {}
00661      } ;
00662 
00663     // setters
00664     void setCorrectedEcalEnergy( float newEnergy, float newEnergyError ) ;
00665     void setTrackMomentumError( float trackMomentumError ) ;
00666     void setP4( P4Kind kind, const LorentzVector & p4, float p4Error, bool setCandidate ) ;
00667     using RecoCandidate::setP4 ;
00668 
00669     // accessors
00670     bool isEcalEnergyCorrected() const { return corrections_.isEcalEnergyCorrected ; }
00671     float ecalEnergy() const { return corrections_.ecalEnergy ; }
00672     float ecalEnergyError() const { return corrections_.ecalEnergyError ; }
00673     float trackMomentumError() const { return corrections_.trackMomentumError ; }
00674     const LorentzVector & p4( P4Kind kind ) const ;
00675     using RecoCandidate::p4 ;
00676     float p4Error( P4Kind kind ) const ;
00677     P4Kind candidateP4Kind() const { return corrections_.candidateP4Kind ; }
00678     const Corrections & corrections() const { return corrections_ ; }
00679 
00680     // for backward compatibility
00681     //bool isMomentumCorrected() const { return corrections_.isMomentumCorrected ; }
00682     float caloEnergy() const
00683      { return ecalEnergy() ; }
00684     bool isEnergyScaleCorrected() const
00685      { return isEcalEnergyCorrected() ; }
00686     void correctEcalEnergy( float newEnergy, float newEnergyError )
00687      { setCorrectedEcalEnergy(newEnergy,newEnergyError) ; }
00688     void correctMomentum( const LorentzVector & p4, float trackMomentumError, float p4Error )
00689      { setTrackMomentumError(trackMomentumError) ; setP4(P4_COMBINATION,p4,p4Error,true) ; }
00690 
00691 
00692   private:
00693 
00694     // attributes
00695     Corrections corrections_ ;
00696 
00697  } ;
00698 
00699  } // namespace reco
00700 
00701 #endif