CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 //
00002 // $Id: Muon.h,v 1.36 2011/06/08 20:40:18 rwolf Exp $
00003 //
00004 
00005 #ifndef DataFormats_PatCandidates_Muon_h
00006 #define DataFormats_PatCandidates_Muon_h
00007 
00023 #include "DataFormats/MuonReco/interface/Muon.h"
00024 #include "DataFormats/MuonReco/interface/MuonFwd.h"
00025 #include "DataFormats/MuonReco/interface/MuonSelectors.h"
00026 #include "DataFormats/MuonReco/interface/MuonMETCorrectionData.h"
00027 
00028 #include "DataFormats/TrackReco/interface/Track.h"
00029 #include "DataFormats/PatCandidates/interface/Lepton.h"
00030 #include "DataFormats/ParticleFlowCandidate/interface/IsolatedPFCandidateFwd.h"
00031 #include "DataFormats/ParticleFlowCandidate/interface/IsolatedPFCandidate.h"
00032 
00033 
00034 // Define typedefs for convenience
00035 namespace pat {
00036   class Muon;
00037   typedef std::vector<Muon>              MuonCollection; 
00038   typedef edm::Ref<MuonCollection>       MuonRef; 
00039   typedef edm::RefVector<MuonCollection> MuonRefVector; 
00040 }
00041 
00042 namespace reco {
00044   std::ostream& operator<<(std::ostream& out, const pat::Muon& obj);
00045 }
00046 
00047 // Class definition
00048 namespace pat {
00049 
00050 
00051   class Muon : public Lepton<reco::Muon> {
00052 
00053     public:
00054 
00056       Muon();
00058       Muon(const reco::Muon & aMuon);
00060       Muon(const edm::RefToBase<reco::Muon> & aMuonRef);
00062       Muon(const edm::Ptr<reco::Muon> & aMuonRef);
00064       virtual ~Muon();
00065 
00067       virtual Muon * clone() const { return new Muon(*this); }
00068 
00069       // ---- methods for content embedding ----
00071       reco::TrackRef track() const;
00072       using reco::RecoCandidate::track; // avoid hiding the base implementation
00074       reco::TrackRef innerTrack() const { return track(); }
00076       reco::TrackRef standAloneMuon() const;
00078       reco::TrackRef outerTrack() const { return standAloneMuon(); }
00080       reco::TrackRef combinedMuon() const;
00082       reco::TrackRef globalTrack() const { return combinedMuon(); }
00084       void embedTrack();
00086       void embedStandAloneMuon();
00088       void embedCombinedMuon();
00089 
00090       // ---- methods for MuonMETCorrectionData ----
00092       reco::MuonMETCorrectionData caloMETMuonCorrs() const { return (embeddedCaloMETMuonCorrs_ ? caloMETMuonCorrs_.front() : reco::MuonMETCorrectionData());};
00093       void embedCaloMETMuonCorrs(const reco::MuonMETCorrectionData& t);
00095       reco::MuonMETCorrectionData tcMETMuonCorrs() const {return (embeddedTCMETMuonCorrs_ ? tcMETMuonCorrs_.front() : reco::MuonMETCorrectionData());};
00096       void embedTcMETMuonCorrs(const reco::MuonMETCorrectionData& t);
00097 
00098       // ---- methods for TeV refit tracks ----
00100       reco::TrackRef pickyMuon() const;
00101       void setPickyMuon(const reco::TrackRef& t) { pickyMuonRef_ = t; }
00103       reco::TrackRef tpfmsMuon() const;
00104       void setTpfmsMuon(const reco::TrackRef& t) { tpfmsMuonRef_ = t; }
00106       void embedPickyMuon();
00108       void embedTpfmsMuon();
00109 
00110       // ---- PF specific methods ----
00113       reco::PFCandidateRef pfCandidateRef() const;
00115       void setPFCandidateRef(const reco::PFCandidateRef& ref) {
00116         pfCandidateRef_ = ref;
00117       } 
00119       void embedPFCandidate();
00121       size_t numberOfSourceCandidatePtrs() const { 
00122         return pfCandidateRef_.isNonnull() ? 1 : 0;
00123       }
00125       reco::CandidatePtr sourceCandidatePtr( size_type i ) const;
00126 
00127       // ---- methods for accessing muon identification ----
00131       bool muonID (const std::string& name) const;
00134       bool isGood (const std::string& name) const { return muonID(name); }
00137       //bool isMuonIDAvailable(const std::string& name) const;
00138 
00139       // ---- overload of isolation functions ----
00142       float trackIso() const { return isolationR03().sumPt; }
00146       float ecalIso()  const { return isolationR03().emEt; }
00150       float hcalIso()  const { return isolationR03().hadEt; }
00153       float caloIso()  const { return ecalIso()+hcalIso(); }
00154 
00160       //  as external input. 
00161         
00162         // ---- embed various impact parameters with errors ----
00163         //
00164         // example:
00165         //
00166         //    // this will return the muon inner track
00167         //    // transverse impact parameter
00168         //    // relative to the primary vertex
00169         //    muon->dB(pat::Muon::PV2D);
00170         //
00171         //    // this will return the uncertainty
00172         //    // on the muon inner track
00173         //    // transverse impact parameter
00174         //    // relative to the primary vertex
00175         //    // or -1.0 if there is no valid PV in the event
00176         //    muon->edB(pat::Muon::PV2D);
00177         //
00178         // IpType defines the type of the impact parameter
00179         // None is default and reverts to old behavior controlled by 
00180         // patMuons.usePV = True/False
00181         typedef enum IPTYPE 
00182           {
00183             None = 0, PV2D = 1, PV3D = 2, BS2D = 3, BS3D = 4
00184           } IpType; 
00185         void initImpactParameters(void); // init IP defaults in a constructor
00186         double dB(IpType type = None) const;
00187         double edB(IpType type = None) const;
00188         void   setDB ( double dB, double edB, IpType type = None ) { 
00189           if (type == None) {
00190             dB_ = dB; edB_ = edB; 
00191             cachedDB_ = true;
00192           }
00193           ip_[type] = dB; eip_[type] = edB; cachedIP_[type] = true;
00194         }
00195 
00197       unsigned int numberOfValidHits() const;
00198       void setNumberOfValidHits(unsigned int numberOfValidHits ) 
00199       { numberOfValidHits_ = numberOfValidHits; cachedNumberOfValidHits_ = true; }
00200 
00202       double normChi2() const;
00203       void setNormChi2 (double normChi2 ) 
00204       { normChi2_ = normChi2; cachedNormChi2_ = true; }
00205 
00207       double segmentCompatibility(reco::Muon::ArbitrationType arbitrationType = reco::Muon::SegmentAndTrackArbitration) const ;
00208 
00210       friend std::ostream& reco::operator<<(std::ostream& out, const Muon& obj);
00211 
00212     protected:
00213 
00214       // ---- for content embedding ----
00216       bool embeddedTrack_;
00217       std::vector<reco::Track> track_;
00219       bool embeddedStandAloneMuon_;
00220       std::vector<reco::Track> standAloneMuon_;
00222       bool embeddedCombinedMuon_;
00223       std::vector<reco::Track> combinedMuon_;
00224 
00226       bool embeddedTCMETMuonCorrs_;
00227       std::vector<reco::MuonMETCorrectionData> tcMETMuonCorrs_;
00229       bool embeddedCaloMETMuonCorrs_;
00230       std::vector<reco::MuonMETCorrectionData> caloMETMuonCorrs_;
00231 
00232       // TeV refit tracks, which are not currently stored in the
00233       // reco::Muon like the above tracks are. Also provide capability
00234       // to embed them.
00235       bool embeddedPickyMuon_;
00236       bool embeddedTpfmsMuon_;
00237       reco::TrackRef pickyMuonRef_;
00238       reco::TrackRef tpfmsMuonRef_;
00239       std::vector<reco::Track> pickyMuon_;
00240       std::vector<reco::Track> tpfmsMuon_;
00241 
00242       // ---- PF specific members ----
00244       bool embeddedPFCandidate_;      
00247       reco::PFCandidateCollection pfCandidate_;
00250       reco::PFCandidateRef pfCandidateRef_;
00251 
00252       // V+Jets group selection variables. 
00253       bool    cachedNormChi2_;         
00254       bool    cachedDB_;               
00255 
00256       bool    cachedNumberOfValidHits_;
00257       double  normChi2_;               
00258       double  dB_;                     
00259       double  edB_;                    // and its uncertainty as recommended by the tracking group
00260 
00261       // ---- cached impact parameters ----
00262       std::vector<bool>    cachedIP_;  // has the IP (former dB) been cached?
00263       std::vector<double>  ip_;        // dB and edB are the impact parameter at the primary vertex,
00264       std::vector<double>  eip_;       // and its uncertainty as recommended by the tracking group
00265 
00266       unsigned int  numberOfValidHits_;
00267 
00268   };
00269 
00270 
00271 }
00272 
00273 #endif