CMS 3D CMS Logo

Candidate.h
Go to the documentation of this file.
1 #ifndef Candidate_Candidate_h
2 #define Candidate_Candidate_h
3 
14 
18 
20 
22 
23 class OverlapChecker;
24 
25 namespace reco {
26  class Track;
27  class Candidate {
28  public:
29  typedef size_t size_type;
32 
34  typedef int Charge;
43 
44  enum { dimension = 3 };
48  enum { size = dimension * (dimension + 1) / 2 };
50  typedef unsigned int index;
51 
53  Candidate(){};
55  virtual ~Candidate();
57  virtual int charge() const = 0;
59  virtual void setCharge(Charge q) = 0;
61  virtual int threeCharge() const = 0;
63  virtual void setThreeCharge(Charge qx3) = 0;
65  virtual const LorentzVector& p4() const = 0;
67  virtual const PolarLorentzVector& polarP4() const = 0;
69  virtual Vector momentum() const = 0;
72  virtual Vector boostToCM() const = 0;
74  virtual double p() const = 0;
76  virtual double energy() const = 0;
78  virtual double et() const = 0;
80  virtual double et2() const = 0;
82  virtual double mass() const = 0;
84  virtual double massSqr() const = 0;
86  virtual double mt() const = 0;
88  virtual double mtSqr() const = 0;
90  virtual double px() const = 0;
92  virtual double py() const = 0;
94  virtual double pz() const = 0;
96  virtual double pt() const = 0;
98  virtual double phi() const = 0;
100  virtual double theta() const = 0;
102  virtual double eta() const = 0;
104  virtual double rapidity() const = 0;
106  virtual double y() const = 0;
108  virtual void setP4(const LorentzVector& p4) = 0;
110  virtual void setP4(const PolarLorentzVector& p4) = 0;
112  virtual void setMass(double m) = 0;
113  virtual void setPz(double pz) = 0;
115  virtual const Point& vertex() const = 0;
117  virtual double vx() const = 0;
119  virtual double vy() const = 0;
121  virtual double vz() const = 0;
123  virtual void setVertex(const Point& vertex) = 0;
125  virtual int pdgId() const = 0;
126  // set PDG identifier
127  virtual void setPdgId(int pdgId) = 0;
129  virtual int status() const = 0;
131  virtual void setStatus(int status) = 0;
133  virtual void setLongLived() = 0;
135  virtual bool longLived() const = 0;
137  virtual void setMassConstraint() = 0;
139  virtual bool massConstraint() const = 0;
141  virtual Candidate* clone() const = 0;
143  const_iterator begin() const { return const_iterator(this, 0); }
145  const_iterator end() const { return const_iterator(this, numberOfDaughters()); }
147  iterator begin() { return iterator(this, 0); }
149  iterator end() { return iterator(this, numberOfDaughters()); }
151  virtual size_type numberOfDaughters() const = 0;
153  virtual const Candidate* daughter(size_type i) const = 0;
155  virtual Candidate* daughter(size_type i) = 0;
157  virtual Candidate* daughter(const std::string& s) = 0;
159  virtual const Candidate* daughter(const std::string& s) const = 0;
161  virtual size_type numberOfMothers() const = 0;
163  virtual const Candidate* mother(size_type i = 0) const = 0;
166  virtual size_t numberOfSourceCandidatePtrs() const = 0;
179  virtual void setSourceCandidatePtr(const CandidatePtr& ptr){};
180 
182  virtual double vertexChi2() const = 0;
189  virtual double vertexNdof() const = 0;
191  virtual double vertexNormalizedChi2() const = 0;
193  virtual double vertexCovariance(int i, int j) const = 0;
198  return m;
199  } //TODO
200  virtual void fillVertexCovariance(CovarianceMatrix& v) const = 0;
203  virtual bool hasMasterClone() const = 0;
206  virtual const CandidateBaseRef& masterClone() const = 0;
209  virtual bool hasMasterClonePtr() const = 0;
212  virtual const CandidatePtr& masterClonePtr() const = 0;
214  template <typename Ref>
215  Ref masterRef() const {
216  return masterClone().template castTo<Ref>();
217  }
219 
220  template <typename T>
221  T get() const {
222  if (hasMasterClone())
223  return masterClone()->get<T>();
224  else
225  return reco::get<T>(*this);
226  }
228  template <typename T, typename Tag>
229  T get() const {
230  if (hasMasterClone())
231  return masterClone()->get<T, Tag>();
232  else
233  return reco::get<T, Tag>(*this);
234  }
236  template <typename T>
237  T get(size_type i) const {
238  if (hasMasterClone())
239  return masterClone()->get<T>(i);
240  else
241  return reco::get<T>(*this, i);
242  }
244  template <typename T, typename Tag>
245  T get(size_type i) const {
246  if (hasMasterClone())
247  return masterClone()->get<T, Tag>(i);
248  else
249  return reco::get<T, Tag>(*this, i);
250  }
252  template <typename T>
253  size_type numberOf() const {
254  if (hasMasterClone())
255  return masterClone()->numberOf<T>();
256  else
257  return reco::numberOf<T>(*this);
258  }
260  template <typename T, typename Tag>
261  size_type numberOf() const {
262  if (hasMasterClone())
263  return masterClone()->numberOf<T, Tag>();
264  else
265  return reco::numberOf<T, Tag>(*this);
266  }
267 
268  virtual const Track* bestTrack() const { return nullptr; }
269 
271  virtual float dzError() const {
272  return 0;
273  } // { const Track * tr=bestTrack(); if(tr!=nullptr) return tr->dzError(); else return 0; }
275  virtual float dxyError() const {
276  return 0;
277  } // { const Track * tr=bestTrack(); if(tr!=nullptr) return tr->dxyError(); else return 0; }
278 
279  virtual bool isElectron() const = 0;
280  virtual bool isMuon() const = 0;
281  virtual bool isStandAloneMuon() const = 0;
282  virtual bool isGlobalMuon() const = 0;
283  virtual bool isTrackerMuon() const = 0;
284  virtual bool isCaloMuon() const = 0;
285  virtual bool isPhoton() const = 0;
286  virtual bool isConvertedPhoton() const = 0;
287  virtual bool isJet() const = 0;
288 
289  protected:
291  virtual bool overlap(const Candidate&) const = 0;
292  template <typename, typename, typename>
293  friend struct component;
294  friend class ::OverlapChecker;
295  friend class ShallowCloneCandidate;
297  };
298 
299  namespace candidate {
300 
303 
304  } // namespace candidate
305 
306 } // namespace reco
307 
308 #endif
virtual double massSqr() const =0
mass squared
int Charge
electric charge type
Definition: Candidate.h:34
reference operator*() const
Definition: Candidate.h:301
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 float dzError() const
uncertainty on dz
Definition: Candidate.h:271
virtual bool isJet() const =0
math::XYZVector Vector
point in the space
Definition: Candidate.h:42
virtual void setSourceCandidatePtr(const CandidatePtr &ptr)
Set the ptr to the source Candidate.
Definition: Candidate.h:179
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:29
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:30
virtual double pt() const =0
transverse momentum
virtual int threeCharge() const =0
electric charge
virtual double mass() const =0
mass
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
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 double y() const =0
rapidity
virtual double rapidity() const =0
rapidity
ErrorD< N >::type type
Definition: Error.h:32
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:25
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
size_type numberOf() const
number of components
Definition: Candidate.h:253
difference_type i
Definition: iterator.h:68
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 double mt() const =0
transverse mass
fixed size vector
Definition: Vector.h:24
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
size_type numberOf() const
number of components
Definition: Candidate.h:261
const_iterator end() const
last daughter const_iterator
Definition: Candidate.h:145
math::XYZTLorentzVector LorentzVector
virtual const Point & vertex() const =0
vertex position
virtual int charge() const =0
electric charge
virtual void setPz(double pz)=0
virtual double py() const =0
y coordinate of momentum vector
Ref masterRef() const
cast master clone reference to a concrete type
Definition: Candidate.h:215
virtual void setStatus(int status)=0
set status word
virtual double vertexNormalizedChi2() const =0
chi-squared divided by n.d.o.f.
virtual void setThreeCharge(Charge qx3)=0
set electric charge
iterator end()
last daughter iterator
Definition: Candidate.h:149
virtual void setLongLived()=0
set long lived flag
virtual double px() const =0
x coordinate of momentum vector
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:31
unsigned int index
index type
Definition: Candidate.h:50
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
iterator begin()
first daughter iterator
Definition: Candidate.h:147
Candidate()
default constructor
Definition: Candidate.h:53
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
virtual double mtSqr() const =0
transverse mass squared
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
virtual double vz() const =0
z coordinate of vertex position
fixed size matrix
virtual float dxyError() const
uncertainty on dxy
Definition: Candidate.h:275
Structure Point Contains parameters of Gaussian fits to DMRs.
virtual const Track * bestTrack() const
Definition: Candidate.h:268
virtual CovarianceMatrix vertexCovariance() const
fill SMatrix
Definition: Candidate.h:195
math::XYZPoint Point
point in the space
Definition: Candidate.h:40
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
virtual CandidatePtr sourceCandidatePtr(size_type i) const
Definition: Candidate.h:169
math::Error< dimension >::type CovarianceMatrix
covariance error matrix (3x3)
Definition: Candidate.h:46
reference operator*() const
Definition: Candidate.h:302
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:216
virtual void setMass(double m)=0
set particle mass
virtual double et2() const =0
transverse energy squared (use this for cut!)
virtual double phi() const =0
momentum azimuthal angle
virtual double eta() const =0
momentum pseudorapidity
virtual double vertexNdof() const =0
const_iterator begin() const
first daughter const_iterator
Definition: Candidate.h:143
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:38