CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/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 class OverlapChecker;
00026 
00027 namespace reco {
00028   
00029   class Candidate {
00030   public:
00031     typedef size_t size_type;
00032     typedef candidate::const_iterator const_iterator;
00033     typedef candidate::iterator iterator;
00034  
00036     typedef int Charge;
00038     typedef math::XYZTLorentzVector LorentzVector;
00040     typedef math::PtEtaPhiMLorentzVector PolarLorentzVector;
00042     typedef math::XYZPoint Point;
00044     typedef math::XYZVector Vector;
00045 
00046     enum { dimension = 3 };
00048     typedef math::Error<dimension>::type CovarianceMatrix;
00050     enum { size = dimension * (dimension + 1)/2 };
00052     typedef unsigned int index;
00053 
00055     Candidate() {};
00057     virtual ~Candidate();
00059     virtual int charge() const = 0;
00061     virtual void setCharge( Charge q ) = 0;
00063     virtual int threeCharge() const = 0;
00065     virtual void setThreeCharge( Charge qx3 ) = 0;
00067     virtual const LorentzVector & p4() const = 0;
00069     virtual const PolarLorentzVector & polarP4() const = 0;
00071     virtual Vector momentum() const = 0;
00074     virtual Vector boostToCM() const = 0;
00076     virtual double p() const = 0;
00078     virtual double energy() const = 0;
00080     virtual double et() const = 0;
00082     virtual double mass() const = 0;
00084     virtual double massSqr() const = 0;
00086     virtual double mt() const = 0;
00088     virtual double mtSqr() const = 0;
00090     virtual double px() const = 0;
00092     virtual double py() const = 0;
00094     virtual double pz() const = 0;
00096     virtual double pt() const = 0;
00098     virtual double phi() const = 0;
00100     virtual double theta() const = 0;
00102     virtual double eta() const = 0;
00104     virtual double rapidity() const = 0;
00106     virtual double y() const = 0;
00108     virtual void setP4( const LorentzVector & p4 ) = 0;
00110     virtual void setP4( const PolarLorentzVector & p4 )  = 0;
00112     virtual void setMass( double m )  = 0;
00113     virtual void setPz( double pz )  = 0;
00115     virtual const Point & vertex() const  = 0;
00117     virtual double vx() const  = 0;
00119     virtual double vy() const  = 0;
00121     virtual double vz() const  = 0;
00123     virtual void setVertex( const Point & vertex )  = 0;
00125     virtual int pdgId() const  = 0;
00126     // set PDG identifier
00127     virtual void setPdgId( int pdgId )  = 0;
00129     virtual int status() const  = 0;
00131     virtual void setStatus( int status )  = 0;
00133     virtual void setLongLived()  = 0;
00135     virtual bool longLived() const  = 0;
00137     virtual void setMassConstraint() = 0;
00139     virtual bool massConstraint() const = 0;
00141     virtual Candidate * clone() const = 0;
00143     virtual const_iterator begin() const = 0;
00145     virtual const_iterator end() const = 0;
00147     virtual iterator begin() = 0;
00149     virtual iterator end() = 0;
00151     virtual size_type numberOfDaughters() const = 0;
00153     virtual const Candidate * daughter( size_type i ) const = 0;
00155     virtual Candidate * daughter( size_type i ) = 0;
00157     virtual Candidate * daughter(const std::string& s ) = 0;
00159     virtual const Candidate * daughter(const std::string& s ) const = 0;
00161     virtual size_type numberOfMothers() const = 0;
00163     virtual const Candidate * mother( size_type i = 0 ) const = 0;
00166     virtual size_t numberOfSourceCandidatePtrs() const  = 0;
00169     virtual CandidatePtr sourceCandidatePtr( size_type i ) const {
00170       return CandidatePtr();
00171     }
00181     virtual void setSourceCandidatePtr( const CandidatePtr& ptr ) {};
00182 
00184     virtual double vertexChi2() const = 0;
00191     virtual double vertexNdof() const = 0;
00193     virtual double vertexNormalizedChi2() const = 0;
00195     virtual double vertexCovariance(int i, int j) const = 0;
00197     virtual CovarianceMatrix vertexCovariance() const { CovarianceMatrix m; fillVertexCovariance(m); return m; }  //TODO
00198     virtual void fillVertexCovariance(CovarianceMatrix & v) const = 0;
00201     virtual bool hasMasterClone() const = 0;
00204     virtual const CandidateBaseRef & masterClone() const = 0;
00207     virtual bool hasMasterClonePtr() const = 0;
00210     virtual const CandidatePtr & masterClonePtr() const = 0;
00212     template<typename Ref>
00213     Ref masterRef() const { return masterClone().template castTo<Ref>(); }
00215 
00216     template<typename T> T get() const { 
00217       if ( hasMasterClone() ) return masterClone()->get<T>();
00218       else return reco::get<T>( * this ); 
00219     }
00221     template<typename T, typename Tag> T get() const { 
00222       if ( hasMasterClone() ) return masterClone()->get<T, Tag>();
00223       else return reco::get<T, Tag>( * this ); 
00224     }
00226     template<typename T> T get( size_type i ) const { 
00227       if ( hasMasterClone() ) return masterClone()->get<T>( i );
00228       else return reco::get<T>( * this, i ); 
00229     }
00231     template<typename T, typename Tag> T get( size_type i ) const { 
00232       if ( hasMasterClone() ) return masterClone()->get<T, Tag>( i );
00233       else return reco::get<T, Tag>( * this, i ); 
00234     }
00236     template<typename T> size_type numberOf() const { 
00237       if ( hasMasterClone() ) return masterClone()->numberOf<T>();
00238       else return reco::numberOf<T>( * this ); 
00239     }
00241     template<typename T, typename Tag> size_type numberOf() const { 
00242       if ( hasMasterClone() ) return masterClone()->numberOf<T, Tag>();
00243       else return reco::numberOf<T, Tag>( * this ); 
00244     }
00245 
00246     template<typename S> 
00247       struct daughter_iterator {
00248         typedef boost::filter_iterator<S, const_iterator> type;
00249       };
00250 
00251     template<typename S>
00252       typename daughter_iterator<S>::type beginFilter( const S & s ) const {
00253       return boost::make_filter_iterator(s, begin(), end());
00254     }
00255     template<typename S>
00256       typename daughter_iterator<S>::type endFilter( const S & s ) const {
00257       return boost::make_filter_iterator(s, end(), end());
00258     }
00259 
00260     virtual bool isElectron() const = 0;
00261     virtual bool isMuon() const = 0;
00262     virtual bool isStandAloneMuon() const = 0;
00263     virtual bool isGlobalMuon() const = 0;
00264     virtual bool isTrackerMuon() const = 0;
00265     virtual bool isCaloMuon() const = 0;
00266     virtual bool isPhoton() const = 0;
00267     virtual bool isConvertedPhoton() const = 0;
00268     virtual bool isJet() const = 0;
00269 
00270   protected:
00272     virtual bool overlap( const Candidate & ) const = 0;
00273     template<typename, typename, typename> friend struct component; 
00274     friend class ::OverlapChecker;
00275     friend class ShallowCloneCandidate;
00276     friend class ShallowClonePtrCandidate;
00277 
00278   };
00279 
00280 }
00281 
00282 #endif