CMS 3D CMS Logo

Candidate.h

Go to the documentation of this file.
00001 #ifndef Candidate_Candidate_h
00002 #define Candidate_Candidate_h
00003 
00012 #include "DataFormats/Candidate/interface/Particle.h"
00013 #include "DataFormats/Candidate/interface/component.h"
00014 #include "DataFormats/Candidate/interface/const_iterator.h"
00015 #include "DataFormats/Candidate/interface/iterator.h"
00016 #include "DataFormats/Candidate/interface/CandidateFwd.h"
00017 #include "DataFormats/Math/interface/Error.h"
00018 #include "boost/iterator/filter_iterator.hpp"
00019 
00020 class OverlapChecker;
00021 
00022 namespace reco {
00023   
00024   class Candidate : public Particle {
00025   public:
00027     typedef size_t size_type;
00028     typedef candidate::const_iterator const_iterator;
00029     typedef candidate::iterator iterator;
00031     enum { dimension = 3 };
00033     typedef math::Error<dimension>::type CovarianceMatrix;
00035     enum { size = dimension * (dimension + 1)/2 };
00037     typedef unsigned int index;
00039     Candidate() : Particle() { }
00041     explicit Candidate( const Particle & p ) : Particle( p ) { }
00043     Candidate( Charge q, const LorentzVector & p4, const Point & vtx = Point( 0, 0, 0 ),
00044                int pdgId = 0, int status = 0, bool integerCharge = true ) : 
00045       Particle( q, p4, vtx, pdgId, status, integerCharge ) { }
00047     Candidate( Charge q, const PolarLorentzVector & p4, const Point & vtx = Point( 0, 0, 0 ),
00048                int pdgId = 0, int status = 0, bool integerCharge = true ) : 
00049       Particle( q, p4, vtx, pdgId, status, integerCharge ) { }
00051     virtual ~Candidate();
00053     virtual Candidate * clone() const = 0;
00055     virtual const_iterator begin() const = 0;
00057     virtual const_iterator end() const = 0;
00059     virtual iterator begin() = 0;
00061     virtual iterator end() = 0;
00063     virtual size_type numberOfDaughters() const = 0;
00065     virtual const Candidate * daughter( size_type i ) const = 0;
00067     virtual Candidate * daughter( size_type i ) = 0;
00069     virtual Candidate * daughter(const std::string& s );
00071     virtual const Candidate * daughter(const std::string& s ) const;
00073     virtual size_type numberOfMothers() const = 0;
00075     virtual const Candidate * mother( size_type i = 0 ) const = 0;
00078     virtual size_t numberOfSourceCandidatePtrs() const { return 0;}
00081     virtual CandidatePtr sourceCandidatePtr( size_type i ) const {
00082       return CandidatePtr();
00083     }
00085     virtual double vertexChi2() const;
00092     virtual double vertexNdof() const;
00094     virtual double vertexNormalizedChi2() const;
00096     virtual double vertexCovariance(int i, int j) const;
00098     CovarianceMatrix vertexCovariance() const { CovarianceMatrix m; fillVertexCovariance(m); return m; }
00100     virtual void fillVertexCovariance(CovarianceMatrix & v) const;
00103     virtual bool hasMasterClone() const;
00106     virtual const CandidateBaseRef & masterClone() const;
00109     virtual bool hasMasterClonePtr() const;
00112     virtual const CandidatePtr & masterClonePtr() const;
00114     template<typename Ref>
00115     Ref masterRef() const { return masterClone().template castTo<Ref>(); }
00117     template<typename T> T get() const { 
00118       if ( hasMasterClone() ) return masterClone()->get<T>();
00119       else return reco::get<T>( * this ); 
00120     }
00122     template<typename T, typename Tag> T get() const { 
00123       if ( hasMasterClone() ) return masterClone()->get<T, Tag>();
00124       else return reco::get<T, Tag>( * this ); 
00125     }
00127     template<typename T> T get( size_type i ) const { 
00128       if ( hasMasterClone() ) return masterClone()->get<T>( i );
00129       else return reco::get<T>( * this, i ); 
00130     }
00132     template<typename T, typename Tag> T get( size_type i ) const { 
00133       if ( hasMasterClone() ) return masterClone()->get<T, Tag>( i );
00134       else return reco::get<T, Tag>( * this, i ); 
00135     }
00137     template<typename T> size_type numberOf() const { 
00138       if ( hasMasterClone() ) return masterClone()->numberOf<T>();
00139       else return reco::numberOf<T>( * this ); 
00140     }
00142     template<typename T, typename Tag> size_type numberOf() const { 
00143       if ( hasMasterClone() ) return masterClone()->numberOf<T, Tag>();
00144       else return reco::numberOf<T, Tag>( * this ); 
00145     }
00146 
00147     template<typename S> 
00148     struct daughter_iterator {
00149       typedef boost::filter_iterator<S, const_iterator> type;
00150     };
00151 
00152     template<typename S>
00153     typename daughter_iterator<S>::type beginFilter( const S & s ) const {
00154       return boost::make_filter_iterator(s, begin(), end());
00155     }
00156     template<typename S>
00157     typename daughter_iterator<S>::type endFilter( const S & s ) const {
00158       return boost::make_filter_iterator(s, end(), end());
00159     }
00160 
00161     virtual bool isElectron() const;
00162     virtual bool isMuon() const;
00163     virtual bool isStandAloneMuon() const;
00164     virtual bool isGlobalMuon() const;
00165     virtual bool isTrackerMuon() const;
00166     virtual bool isCaloMuon() const;
00167     virtual bool isPhoton() const;
00168     virtual bool isConvertedPhoton() const;
00169     virtual bool isJet() const;
00170 
00171   private:
00173     virtual bool overlap( const Candidate & ) const = 0;
00174     template<typename, typename, typename> friend struct component; 
00175     friend class ::OverlapChecker;
00176     friend class ShallowCloneCandidate;
00177     friend class ShallowClonePtrCandidate;
00178   };
00179 
00180 }
00181 
00182 #endif

Generated on Tue Jun 9 17:27:15 2009 for CMSSW by  doxygen 1.5.4