CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2_patch1/src/DataFormats/Candidate/interface/Candidate.h

Go to the documentation of this file.
00001 #ifndef Candidate_Candidate_h
00002 #define Candidate_Candidate_h
00003 
00011 #include "DataFormats/Candidate/interface/component.h"
00012 #include "DataFormats/Candidate/interface/const_iterator.h"
00013 #include "DataFormats/Candidate/interface/iterator.h"
00014 #include "DataFormats/Candidate/interface/CandidateFwd.h"
00015 #include "DataFormats/Math/interface/Error.h"
00016 #include "boost/iterator/filter_iterator.hpp"
00017 
00018 #include "DataFormats/Math/interface/Point3D.h"
00019 #include "DataFormats/Math/interface/Vector3D.h"
00020 #include "DataFormats/Math/interface/LorentzVector.h"
00021 #include "Rtypes.h"
00022 
00023 #include "DataFormats/Candidate/interface/Particle.h"
00024 
00025 #include "FWCore/Utilities/interface/GCC11Compatibility.h"
00026 
00027 
00028 class OverlapChecker;
00029 
00030 namespace reco {
00031   
00032   class Candidate {
00033   public:
00034     typedef size_t size_type;
00035     typedef candidate::const_iterator const_iterator;
00036     typedef candidate::iterator iterator;
00037  
00039     typedef int Charge;
00041     typedef math::XYZTLorentzVector LorentzVector;
00043     typedef math::PtEtaPhiMLorentzVector PolarLorentzVector;
00045     typedef math::XYZPoint Point;
00047     typedef math::XYZVector Vector;
00048 
00049     enum { dimension = 3 };
00051     typedef math::Error<dimension>::type CovarianceMatrix;
00053     enum { size = dimension * (dimension + 1)/2 };
00055     typedef unsigned int index;
00056 
00058     Candidate() {};
00060     virtual ~Candidate();
00062     virtual int charge() const = 0;
00064     virtual void setCharge( Charge q ) = 0;
00066     virtual int threeCharge() const = 0;
00068     virtual void setThreeCharge( Charge qx3 ) = 0;
00070     virtual const LorentzVector & p4() const = 0;
00072     virtual const PolarLorentzVector & polarP4() const = 0;
00074     virtual Vector momentum() const = 0;
00077     virtual Vector boostToCM() const = 0;
00079     virtual double p() const = 0;
00081     virtual double energy() const = 0;
00083     virtual double et() const = 0;
00085     virtual float mass() const = 0;
00087     virtual float massSqr() const = 0;
00089     virtual double mt() const = 0;
00091     virtual double mtSqr() const = 0;
00093     virtual double px() const = 0;
00095     virtual double py() const = 0;
00097     virtual double pz() const = 0;
00099     virtual float pt() const = 0;
00101     virtual float phi() const = 0;
00103     virtual double theta() const = 0;
00105     virtual float eta() const = 0;
00107     virtual double rapidity() const = 0;
00109     virtual double y() const = 0;
00111     virtual void setP4( const LorentzVector & p4 ) = 0;
00113     virtual void setP4( const PolarLorentzVector & p4 )  = 0;
00115     virtual void setMass( double m )  = 0;
00116     virtual void setPz( double pz )  = 0;
00118     virtual const Point & vertex() const  = 0;
00120     virtual double vx() const  = 0;
00122     virtual double vy() const  = 0;
00124     virtual double vz() const  = 0;
00126     virtual void setVertex( const Point & vertex )  = 0;
00128     virtual int pdgId() const  = 0;
00129     // set PDG identifier
00130     virtual void setPdgId( int pdgId )  = 0;
00132     virtual int status() const  = 0;
00134     virtual void setStatus( int status )  = 0;
00136     virtual void setLongLived()  = 0;
00138     virtual bool longLived() const  = 0;
00140     virtual void setMassConstraint() = 0;
00142     virtual bool massConstraint() const = 0;
00144     virtual Candidate * clone() const = 0;
00146     virtual const_iterator begin() const = 0;
00148     virtual const_iterator end() const = 0;
00150     virtual iterator begin() = 0;
00152     virtual iterator end() = 0;
00154     virtual size_type numberOfDaughters() const = 0;
00156     virtual const Candidate * daughter( size_type i ) const = 0;
00158     virtual Candidate * daughter( size_type i ) = 0;
00160     virtual Candidate * daughter(const std::string& s ) = 0;
00162     virtual const Candidate * daughter(const std::string& s ) const = 0;
00164     virtual size_type numberOfMothers() const = 0;
00166     virtual const Candidate * mother( size_type i = 0 ) const = 0;
00169     virtual size_t numberOfSourceCandidatePtrs() const  = 0;
00172     virtual CandidatePtr sourceCandidatePtr( size_type i ) const {
00173       return CandidatePtr();
00174     }
00184     virtual void setSourceCandidatePtr( const CandidatePtr& ptr ) {};
00185 
00187     virtual double vertexChi2() const = 0;
00194     virtual double vertexNdof() const = 0;
00196     virtual double vertexNormalizedChi2() const = 0;
00198     virtual double vertexCovariance(int i, int j) const = 0;
00200     virtual CovarianceMatrix vertexCovariance() const { CovarianceMatrix m; fillVertexCovariance(m); return m; }  //TODO
00201     virtual void fillVertexCovariance(CovarianceMatrix & v) const = 0;
00204     virtual bool hasMasterClone() const = 0;
00207     virtual const CandidateBaseRef & masterClone() const = 0;
00210     virtual bool hasMasterClonePtr() const = 0;
00213     virtual const CandidatePtr & masterClonePtr() const = 0;
00215     template<typename Ref>
00216     Ref masterRef() const { return masterClone().template castTo<Ref>(); }
00218 
00219     template<typename T> T get() const { 
00220       if ( hasMasterClone() ) return masterClone()->get<T>();
00221       else return reco::get<T>( * this ); 
00222     }
00224     template<typename T, typename Tag> T get() const { 
00225       if ( hasMasterClone() ) return masterClone()->get<T, Tag>();
00226       else return reco::get<T, Tag>( * this ); 
00227     }
00229     template<typename T> T get( size_type i ) const { 
00230       if ( hasMasterClone() ) return masterClone()->get<T>( i );
00231       else return reco::get<T>( * this, i ); 
00232     }
00234     template<typename T, typename Tag> T get( size_type i ) const { 
00235       if ( hasMasterClone() ) return masterClone()->get<T, Tag>( i );
00236       else return reco::get<T, Tag>( * this, i ); 
00237     }
00239     template<typename T> size_type numberOf() const { 
00240       if ( hasMasterClone() ) return masterClone()->numberOf<T>();
00241       else return reco::numberOf<T>( * this ); 
00242     }
00244     template<typename T, typename Tag> size_type numberOf() const { 
00245       if ( hasMasterClone() ) return masterClone()->numberOf<T, Tag>();
00246       else return reco::numberOf<T, Tag>( * this ); 
00247     }
00248 
00249     template<typename S> 
00250       struct daughter_iterator {
00251         typedef boost::filter_iterator<S, const_iterator> type;
00252       };
00253 
00254     template<typename S>
00255       typename daughter_iterator<S>::type beginFilter( const S & s ) const {
00256       return boost::make_filter_iterator(s, begin(), end());
00257     }
00258     template<typename S>
00259       typename daughter_iterator<S>::type endFilter( const S & s ) const {
00260       return boost::make_filter_iterator(s, end(), end());
00261     }
00262 
00263     virtual bool isElectron() const = 0;
00264     virtual bool isMuon() const = 0;
00265     virtual bool isStandAloneMuon() const = 0;
00266     virtual bool isGlobalMuon() const = 0;
00267     virtual bool isTrackerMuon() const = 0;
00268     virtual bool isCaloMuon() const = 0;
00269     virtual bool isPhoton() const = 0;
00270     virtual bool isConvertedPhoton() const = 0;
00271     virtual bool isJet() const = 0;
00272 
00273   protected:
00275     virtual bool overlap( const Candidate & ) const = 0;
00276     template<typename, typename, typename> friend struct component; 
00277     friend class ::OverlapChecker;
00278     friend class ShallowCloneCandidate;
00279     friend class ShallowClonePtrCandidate;
00280 
00281   };
00282 
00283 }
00284 
00285 #endif