CMS 3D CMS Logo

CMSSW_4_4_3_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 "DataFormats/Common/interface/BoolCache.h"
00022 #include "Rtypes.h"
00023 
00024 #include "DataFormats/Candidate/interface/Particle.h"
00025 
00026 class OverlapChecker;
00027 
00028 namespace reco {
00029   
00030   class Candidate {
00031   public:
00032     typedef size_t size_type;
00033     typedef candidate::const_iterator const_iterator;
00034     typedef candidate::iterator iterator;
00035  
00037     typedef int Charge;
00039     typedef math::XYZTLorentzVector LorentzVector;
00041     typedef math::PtEtaPhiMLorentzVector PolarLorentzVector;
00043     typedef math::XYZPoint Point;
00045     typedef math::XYZVector Vector;
00046 
00047     enum { dimension = 3 };
00049     typedef math::Error<dimension>::type CovarianceMatrix;
00051     enum { size = dimension * (dimension + 1)/2 };
00053     typedef unsigned int index;
00054 
00056     Candidate() {};
00058     virtual ~Candidate();
00060     virtual int charge() const = 0;
00062     virtual void setCharge( Charge q ) = 0;
00064     virtual int threeCharge() const = 0;
00066     virtual void setThreeCharge( Charge qx3 ) = 0;
00068     virtual const LorentzVector & p4() const = 0;
00070     virtual const PolarLorentzVector & polarP4() const = 0;
00072     virtual Vector momentum() const = 0;
00075     virtual Vector boostToCM() const = 0;
00077     virtual double p() const = 0;
00079     virtual double energy() const = 0;
00081     virtual double et() const = 0;
00083     virtual double mass() const = 0;
00085     virtual double massSqr() const = 0;
00087     virtual double mt() const = 0;
00089     virtual double mtSqr() const = 0;
00091     virtual double px() const = 0;
00093     virtual double py() const = 0;
00095     virtual double pz() const = 0;
00097     virtual double pt() const = 0;
00099     virtual double phi() const = 0;
00101     virtual double theta() const = 0;
00103     virtual double eta() const = 0;
00105     virtual double rapidity() const = 0;
00107     virtual double y() const = 0;
00109     virtual void setP4( const LorentzVector & p4 ) = 0;
00111     virtual void setP4( const PolarLorentzVector & p4 )  = 0;
00113     virtual void setMass( double m )  = 0;
00114     virtual void setPz( double pz )  = 0;
00116     virtual const Point & vertex() const  = 0;
00118     virtual double vx() const  = 0;
00120     virtual double vy() const  = 0;
00122     virtual double vz() const  = 0;
00124     virtual void setVertex( const Point & vertex )  = 0;
00126     virtual int pdgId() const  = 0;
00127     // set PDG identifier
00128     virtual void setPdgId( int pdgId )  = 0;
00130     virtual int status() const  = 0;
00132     virtual void setStatus( int status )  = 0;
00134     virtual void setLongLived()  = 0;
00136     virtual bool longLived() const  = 0;
00138     virtual void setMassConstraint() = 0;
00140     virtual bool massConstraint() const = 0;
00142     virtual Candidate * clone() const = 0;
00144     virtual const_iterator begin() const = 0;
00146     virtual const_iterator end() const = 0;
00148     virtual iterator begin() = 0;
00150     virtual iterator end() = 0;
00152     virtual size_type numberOfDaughters() const = 0;
00154     virtual const Candidate * daughter( size_type i ) const = 0;
00156     virtual Candidate * daughter( size_type i ) = 0;
00158     virtual Candidate * daughter(const std::string& s ) = 0;
00160     virtual const Candidate * daughter(const std::string& s ) const = 0;
00162     virtual size_type numberOfMothers() const = 0;
00164     virtual const Candidate * mother( size_type i = 0 ) const = 0;
00167     virtual size_t numberOfSourceCandidatePtrs() const  = 0;
00170     virtual CandidatePtr sourceCandidatePtr( size_type i ) const {
00171       return CandidatePtr();
00172     }
00182     virtual void setSourceCandidatePtr( const CandidatePtr& ptr ) {};
00183 
00185     virtual double vertexChi2() const = 0;
00192     virtual double vertexNdof() const = 0;
00194     virtual double vertexNormalizedChi2() const = 0;
00196     virtual double vertexCovariance(int i, int j) const = 0;
00198     virtual CovarianceMatrix vertexCovariance() const { CovarianceMatrix m; fillVertexCovariance(m); return m; }  //TODO
00199     virtual void fillVertexCovariance(CovarianceMatrix & v) const = 0;
00202     virtual bool hasMasterClone() const = 0;
00205     virtual const CandidateBaseRef & masterClone() const = 0;
00208     virtual bool hasMasterClonePtr() const = 0;
00211     virtual const CandidatePtr & masterClonePtr() const = 0;
00213     template<typename Ref>
00214     Ref masterRef() const { return masterClone().template castTo<Ref>(); }
00216 
00217     template<typename T> T get() const { 
00218       if ( hasMasterClone() ) return masterClone()->get<T>();
00219       else return reco::get<T>( * this ); 
00220     }
00222     template<typename T, typename Tag> T get() const { 
00223       if ( hasMasterClone() ) return masterClone()->get<T, Tag>();
00224       else return reco::get<T, Tag>( * this ); 
00225     }
00227     template<typename T> T get( size_type i ) const { 
00228       if ( hasMasterClone() ) return masterClone()->get<T>( i );
00229       else return reco::get<T>( * this, i ); 
00230     }
00232     template<typename T, typename Tag> T get( size_type i ) const { 
00233       if ( hasMasterClone() ) return masterClone()->get<T, Tag>( i );
00234       else return reco::get<T, Tag>( * this, i ); 
00235     }
00237     template<typename T> size_type numberOf() const { 
00238       if ( hasMasterClone() ) return masterClone()->numberOf<T>();
00239       else return reco::numberOf<T>( * this ); 
00240     }
00242     template<typename T, typename Tag> size_type numberOf() const { 
00243       if ( hasMasterClone() ) return masterClone()->numberOf<T, Tag>();
00244       else return reco::numberOf<T, Tag>( * this ); 
00245     }
00246 
00247     template<typename S> 
00248       struct daughter_iterator {
00249         typedef boost::filter_iterator<S, const_iterator> type;
00250       };
00251 
00252     template<typename S>
00253       typename daughter_iterator<S>::type beginFilter( const S & s ) const {
00254       return boost::make_filter_iterator(s, begin(), end());
00255     }
00256     template<typename S>
00257       typename daughter_iterator<S>::type endFilter( const S & s ) const {
00258       return boost::make_filter_iterator(s, end(), end());
00259     }
00260 
00261     virtual bool isElectron() const = 0;
00262     virtual bool isMuon() const = 0;
00263     virtual bool isStandAloneMuon() const = 0;
00264     virtual bool isGlobalMuon() const = 0;
00265     virtual bool isTrackerMuon() const = 0;
00266     virtual bool isCaloMuon() const = 0;
00267     virtual bool isPhoton() const = 0;
00268     virtual bool isConvertedPhoton() const = 0;
00269     virtual bool isJet() const = 0;
00270 
00271   protected:
00273     virtual bool overlap( const Candidate & ) const = 0;
00274     template<typename, typename, typename> friend struct component; 
00275     friend class ::OverlapChecker;
00276     friend class ShallowCloneCandidate;
00277     friend class ShallowClonePtrCandidate;
00278 
00279   };
00280 
00281 }
00282 
00283 #endif