CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DataFormats/PatCandidates/interface/Electron.h

Go to the documentation of this file.
00001 //
00002 // $Id: Electron.h,v 1.34 2011/06/08 20:40:18 rwolf Exp $
00003 //
00004 
00005 #ifndef DataFormats_PatCandidates_Electron_h
00006 #define DataFormats_PatCandidates_Electron_h
00007 
00023 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
00024 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
00025 #include "DataFormats/EgammaCandidates/interface/GsfElectronCore.h"
00026 #include "DataFormats/EgammaCandidates/interface/GsfElectronCoreFwd.h"
00027 #include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
00028 #include "DataFormats/PatCandidates/interface/Lepton.h"
00029 
00030 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
00031 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
00032 
00033 // Define typedefs for convenience
00034 namespace pat {
00035   class Electron;
00036   typedef std::vector<Electron>              ElectronCollection;
00037   typedef edm::Ref<ElectronCollection>       ElectronRef;
00038   typedef edm::RefVector<ElectronCollection> ElectronRefVector;
00039 }
00040 
00041 namespace reco {
00043   std::ostream& operator<<(std::ostream& out, const pat::Electron& obj);
00044 }
00045 
00046 // Class definition
00047 namespace pat {
00048 
00049 
00050   class Electron : public Lepton<reco::GsfElectron> {
00051 
00052     public:
00053 
00054       typedef std::pair<std::string,float> IdPair;
00055 
00057       Electron();
00059       Electron(const reco::GsfElectron & anElectron);
00061       Electron(const edm::RefToBase<reco::GsfElectron> & anElectronRef);
00063       Electron(const edm::Ptr<reco::GsfElectron> & anElectronRef);
00065       virtual ~Electron();
00066 
00068       virtual Electron * clone() const { return new Electron(*this); }
00069 
00070       // ---- methods for content embedding ----
00072       virtual reco::GsfElectronCoreRef core() const;
00074       reco::GsfTrackRef gsfTrack() const;
00076       reco::SuperClusterRef superCluster() const;
00078       reco::TrackRef track() const;
00079       using reco::RecoCandidate::track; // avoid hiding the base implementation
00081       void embedGsfElectronCore();
00083       void embedGsfTrack();
00085       void embedSuperCluster();
00087       void embedTrack();
00088 
00089       // ---- methods for electron ID ----
00104       float electronID(const std::string & name) const;
00106       bool isElectronIDAvailable(const std::string & name) const;
00109       const std::vector<IdPair> &  electronIDs() const { return electronIDs_; }
00112       void setElectronIDs(const std::vector<IdPair> & ids) { electronIDs_ = ids; }
00113 
00114       // ---- overload of isolation functions ----
00117       float trackIso() const { return dr04TkSumPt(); }
00121       float ecalIso()  const { return dr04EcalRecHitSumEt(); }
00125       float hcalIso()  const { return dr04HcalTowerSumEt(); }
00128       float caloIso()  const { return ecalIso()+hcalIso(); }
00129 
00130       // ---- PF specific methods ----
00133       reco::PFCandidateRef pfCandidateRef() const;
00135       void setPFCandidateRef(const reco::PFCandidateRef& ref) {
00136         pfCandidateRef_ = ref;
00137       }
00139       void embedPFCandidate();
00140       // get the number of non-null PF candidates
00141       size_t numberOfSourceCandidatePtrs() const {
00142         return pfCandidateRef_.isNonnull() ? 1 : 0;
00143       }
00145       reco::CandidatePtr sourceCandidatePtr( size_type i ) const;
00146 
00147       // ---- embed various impact parameters with errors ----
00148       //
00149       // example:
00150       //
00151       //    // this will return the muon inner track
00152       //    // transverse impact parameter
00153       //    // relative to the primary vertex
00154       //    muon->dB(pat::Muon::PV2D);
00155       //
00156       //    // this will return the uncertainty
00157       //    // on the muon inner track
00158       //    // transverse impact parameter
00159       //    // relative to the primary vertex
00160       //    // or -1.0 if there is no valid PV in the event
00161       //    muon->edB(pat::Muon::PV2D);
00162       //
00163       // IpType defines the type of the impact parameter
00164       // None is default and reverts to old behavior controlled by 
00165       // patMuons.usePV = True/False
00166       typedef enum IPTYPE { None = 0, PV2D = 1, PV3D = 2, BS2D = 3, BS3D = 4 } IpType;       
00167       double dB(IpType type = None) const;
00168       double edB(IpType type = None) const;
00169       void setDB(double dB, double edB, IpType type = None);    
00170       
00171       // ---- Momentum estimate specific methods ----
00172       const LorentzVector & ecalDrivenMomentum() const {return ecalDrivenMomentum_;}
00173       void setEcalDrivenMomentum(const Candidate::LorentzVector& mom) {ecalDrivenMomentum_=mom;}
00174 
00176       friend std::ostream& reco::operator<<(std::ostream& out, const pat::Electron& obj);
00177 
00178     protected:
00179       void initImpactParameters(); // init IP defaults in a constructor
00180 
00181       // ---- for content embedding ----
00182       bool embeddedGsfElectronCore_;
00183       std::vector<reco::GsfElectronCore> gsfElectronCore_;
00184       bool embeddedGsfTrack_;
00185       std::vector<reco::GsfTrack> gsfTrack_;
00186       bool embeddedSuperCluster_;
00187       std::vector<reco::SuperCluster> superCluster_;
00188       bool embeddedTrack_;
00189       std::vector<reco::Track> track_;
00190 
00191       // ---- electron ID's holder ----
00192       std::vector<IdPair> electronIDs_;
00193 
00194       // ---- PF specific members ----
00196       bool embeddedPFCandidate_;
00199       reco::PFCandidateCollection pfCandidate_;
00202       reco::PFCandidateRef pfCandidateRef_;
00203 
00204       // ---- specific members : Momentum estimates ----
00206       LorentzVector ecalDrivenMomentum_;
00207 
00208       // V+Jets group selection variables.
00209       bool    cachedDB_;         // have these values been cached?
00210       double  dB_;               // dB and edB are the impact parameter at the primary vertex,
00211       double  edB_;              // dB and edB are the impact parameter at the primary vertex,
00212 
00213       // ---- cached impact parameters ----
00214       std::vector<bool>    cachedIP_;  // has the IP (former dB) been cached?
00215       std::vector<double>  ip_;        // dB and edB are the impact parameter at the primary vertex,
00216       std::vector<double>  eip_;       // and its uncertainty as recommended by the tracking group
00217       
00218   };
00219 }
00220 
00221 #endif