CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Candidate.h
Go to the documentation of this file.
1 #ifndef Candidate_Candidate_h
2 #define Candidate_Candidate_h
3 
16 #include "boost/iterator/filter_iterator.hpp"
17 
21 #include "Rtypes.h"
22 
24 
26 
27 
28 class OverlapChecker;
29 
30 namespace reco {
31 
32  class Candidate {
33  public:
34  typedef size_t size_type;
37 
39  typedef int Charge;
48 
49  enum { dimension = 3 };
53  enum { size = dimension * (dimension + 1)/2 };
55  typedef unsigned int index;
56 
58  Candidate() {};
60  virtual ~Candidate();
62  virtual int charge() const = 0;
64  virtual void setCharge( Charge q ) = 0;
66  virtual int threeCharge() const = 0;
68  virtual void setThreeCharge( Charge qx3 ) = 0;
70  virtual const LorentzVector & p4() const = 0;
72  virtual const PolarLorentzVector & polarP4() const = 0;
74  virtual Vector momentum() const = 0;
77  virtual Vector boostToCM() const = 0;
79  virtual double p() const = 0;
81  virtual double energy() const = 0;
83  virtual double et() const = 0;
85  virtual float mass() const = 0;
87  virtual float massSqr() const = 0;
89  virtual double mt() const = 0;
91  virtual double mtSqr() const = 0;
93  virtual double px() const = 0;
95  virtual double py() const = 0;
97  virtual double pz() const = 0;
99  virtual float pt() const = 0;
101  virtual float phi() const = 0;
103  virtual double theta() const = 0;
105  virtual float eta() const = 0;
107  virtual double rapidity() const = 0;
109  virtual double y() const = 0;
111  virtual void setP4( const LorentzVector & p4 ) = 0;
113  virtual void setP4( const PolarLorentzVector & p4 ) = 0;
115  virtual void setMass( double m ) = 0;
116  virtual void setPz( double pz ) = 0;
118  virtual const Point & vertex() const = 0;
120  virtual double vx() const = 0;
122  virtual double vy() const = 0;
124  virtual double vz() const = 0;
126  virtual void setVertex( const Point & vertex ) = 0;
128  virtual int pdgId() const = 0;
129  // set PDG identifier
130  virtual void setPdgId( int pdgId ) = 0;
132  virtual int status() const = 0;
134  virtual void setStatus( int status ) = 0;
136  virtual void setLongLived() = 0;
138  virtual bool longLived() const = 0;
140  virtual void setMassConstraint() = 0;
142  virtual bool massConstraint() const = 0;
144  virtual Candidate * clone() const = 0;
146  virtual const_iterator begin() const = 0;
148  virtual const_iterator end() const = 0;
150  virtual iterator begin() = 0;
152  virtual iterator end() = 0;
154  virtual size_type numberOfDaughters() const = 0;
156  virtual const Candidate * daughter( size_type i ) const = 0;
158  virtual Candidate * daughter( size_type i ) = 0;
160  virtual Candidate * daughter(const std::string& s ) = 0;
162  virtual const Candidate * daughter(const std::string& s ) const = 0;
164  virtual size_type numberOfMothers() const = 0;
166  virtual const Candidate * mother( size_type i = 0 ) const = 0;
169  virtual size_t numberOfSourceCandidatePtrs() const = 0;
173  return CandidatePtr();
174  }
184  virtual void setSourceCandidatePtr( const CandidatePtr& ptr ) {};
185 
187  virtual double vertexChi2() const = 0;
194  virtual double vertexNdof() const = 0;
196  virtual double vertexNormalizedChi2() const = 0;
198  virtual double vertexCovariance(int i, int j) const = 0;
201  virtual void fillVertexCovariance(CovarianceMatrix & v) const = 0;
204  virtual bool hasMasterClone() const = 0;
207  virtual const CandidateBaseRef & masterClone() const = 0;
210  virtual bool hasMasterClonePtr() const = 0;
213  virtual const CandidatePtr & masterClonePtr() const = 0;
215  template<typename Ref>
216  Ref masterRef() const { return masterClone().template castTo<Ref>(); }
218 
219  template<typename T> T get() const {
220  if ( hasMasterClone() ) return masterClone()->get<T>();
221  else return reco::get<T>( * this );
222  }
224  template<typename T, typename Tag> T get() const {
225  if ( hasMasterClone() ) return masterClone()->get<T, Tag>();
226  else return reco::get<T, Tag>( * this );
227  }
229  template<typename T> T get( size_type i ) const {
230  if ( hasMasterClone() ) return masterClone()->get<T>( i );
231  else return reco::get<T>( * this, i );
232  }
234  template<typename T, typename Tag> T get( size_type i ) const {
235  if ( hasMasterClone() ) return masterClone()->get<T, Tag>( i );
236  else return reco::get<T, Tag>( * this, i );
237  }
239  template<typename T> size_type numberOf() const {
240  if ( hasMasterClone() ) return masterClone()->numberOf<T>();
241  else return reco::numberOf<T>( * this );
242  }
244  template<typename T, typename Tag> size_type numberOf() const {
245  if ( hasMasterClone() ) return masterClone()->numberOf<T, Tag>();
246  else return reco::numberOf<T, Tag>( * this );
247  }
248 
249  template<typename S>
251  typedef boost::filter_iterator<S, const_iterator> type;
252  };
253 
254  template<typename S>
255  typename daughter_iterator<S>::type beginFilter( const S & s ) const {
256  return boost::make_filter_iterator(s, begin(), end());
257  }
258  template<typename S>
259  typename daughter_iterator<S>::type endFilter( const S & s ) const {
260  return boost::make_filter_iterator(s, end(), end());
261  }
262 
263  virtual bool isElectron() const = 0;
264  virtual bool isMuon() const = 0;
265  virtual bool isStandAloneMuon() const = 0;
266  virtual bool isGlobalMuon() const = 0;
267  virtual bool isTrackerMuon() const = 0;
268  virtual bool isCaloMuon() const = 0;
269  virtual bool isPhoton() const = 0;
270  virtual bool isConvertedPhoton() const = 0;
271  virtual bool isJet() const = 0;
272 
273  protected:
275  virtual bool overlap( const Candidate & ) const = 0;
276  template<typename, typename, typename> friend struct component;
277  friend class ::OverlapChecker;
278  friend class ShallowCloneCandidate;
280 
281  };
282 
283 }
284 
285 #endif
int Charge
electric charge type
Definition: Candidate.h:39
daughter_iterator< S >::type endFilter(const S &s) const
Definition: Candidate.h:259
int i
Definition: DBlmapReader.cc:9
virtual double energy() const =0
energy
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
virtual bool isJet() const =0
virtual float mass() const =0
mass
math::XYZVector Vector
point in the space
Definition: Candidate.h:47
virtual void setSourceCandidatePtr(const CandidatePtr &ptr)
Set the ptr to the source Candidate.
Definition: Candidate.h:184
virtual void fillVertexCovariance(CovarianceMatrix &v) const =0
virtual const Candidate * mother(size_type i=0) const =0
return pointer to mother
size_t size_type
Definition: Candidate.h:34
virtual bool isConvertedPhoton() const =0
virtual void setP4(const LorentzVector &p4)=0
set 4-momentum
virtual double et() const =0
transverse energy
candidate::const_iterator const_iterator
Definition: Candidate.h:35
virtual float eta() const =0
momentum pseudorapidity
virtual CandidatePtr sourceCandidatePtr(size_type i) const
Definition: Candidate.h:172
virtual int threeCharge() const =0
electric charge
virtual int status() const =0
status word
virtual size_type numberOfMothers() const =0
number of mothers (zero or one in most of but not all the cases)
virtual double pz() const =0
z coordinate of momentum vector
math::XYZTLorentzVector LorentzVector
virtual void setMassConstraint()=0
set mass constraint flag
virtual bool massConstraint() const =0
do mass constraint?
virtual double vx() const =0
x coordinate of vertex position
virtual const CandidatePtr & masterClonePtr() const =0
virtual float phi() const =0
momentum azimuthal angle
virtual double y() const =0
rapidity
virtual double rapidity() const =0
rapidity
ErrorD< N >::type type
Definition: Error.h:30
virtual const PolarLorentzVector & polarP4() const =0
four-momentum Lorentz vector
virtual void setPdgId(int pdgId)=0
virtual double vy() const =0
y coordinate of vertex position
virtual bool isPhoton() const =0
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:26
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
virtual size_type numberOfDaughters() const =0
number of daughters
virtual double p() const =0
magnitude of momentum vector
virtual bool hasMasterClone() const =0
virtual bool isCaloMuon() const =0
virtual Vector momentum() const =0
spatial momentum vector
virtual float pt() const =0
transverse momentum
Ref masterRef() const
cast master clone reference to a concrete type
Definition: Candidate.h:216
virtual double mt() const =0
transverse mass
fixed size vector
Definition: Vector.h:23
virtual const_iterator end() const =0
last daughter const_iterator
virtual double theta() const =0
momentum polar angle
virtual double vertexChi2() const =0
chi-squares
virtual bool isStandAloneMuon() const =0
virtual void setVertex(const Point &vertex)=0
set vertex
math::XYZPoint Point
int j
Definition: DBlmapReader.cc:9
virtual const Point & vertex() const =0
vertex position
virtual int charge() const =0
electric charge
virtual void setPz(double pz)=0
size_type numberOf() const
number of components
Definition: Candidate.h:239
virtual double py() const =0
y coordinate of momentum vector
virtual void setStatus(int status)=0
set status word
size_type numberOf() const
number of components
Definition: Candidate.h:244
virtual double vertexNormalizedChi2() const =0
chi-squared divided by n.d.o.f.
virtual void setThreeCharge(Charge qx3)=0
set electric charge
virtual void setLongLived()=0
set long lived flag
virtual double px() const =0
x coordinate of momentum vector
boost::filter_iterator< S, const_iterator > type
Definition: Candidate.h:251
virtual bool hasMasterClonePtr() const =0
virtual int pdgId() const =0
PDG identifier.
virtual Candidate * clone() const =0
returns a clone of the Candidate object
candidate::iterator iterator
Definition: Candidate.h:36
unsigned int index
index type
Definition: Candidate.h:55
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
Definition: CandidateFwd.h:25
virtual bool isMuon() const =0
virtual ~Candidate()
destructor
Definition: Candidate.cc:5
Candidate()
default constructor
Definition: Candidate.h:58
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
virtual CovarianceMatrix vertexCovariance() const
fill SMatrix
Definition: Candidate.h:200
virtual double mtSqr() const =0
transverse mass squared
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:41
virtual float massSqr() const =0
mass squared
virtual double vz() const =0
z coordinate of vertex position
virtual const_iterator begin() const =0
first daughter const_iterator
math::XYZPoint Point
point in the space
Definition: Candidate.h:45
virtual bool longLived() const =0
is long lived?
virtual bool overlap(const Candidate &) const =0
check overlap with another Candidate
virtual bool isElectron() const =0
virtual bool isTrackerMuon() const =0
math::Error< dimension >::type CovarianceMatrix
covariance error matrix (3x3)
Definition: Candidate.h:51
long double T
virtual void setCharge(Charge q)=0
set electric charge
virtual size_t numberOfSourceCandidatePtrs() const =0
virtual Vector boostToCM() const =0
value_type const * get() const
Definition: RefToBase.h:212
virtual void setMass(double m)=0
set particle mass
daughter_iterator< S >::type beginFilter(const S &s) const
Definition: Candidate.h:255
virtual double vertexNdof() const =0
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
virtual bool isGlobalMuon() const =0
virtual const CandidateBaseRef & masterClone() const =0
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:43