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 
23 
24 class OverlapChecker;
25 
26 namespace reco {
27  class Track;
28  class Candidate {
29  public:
30  typedef size_t size_type;
33 
35  typedef int Charge;
44 
45  enum { dimension = 3 };
49  enum { size = dimension * (dimension + 1) / 2 };
51  typedef unsigned int index;
52 
54  Candidate(){};
56  virtual ~Candidate();
58  virtual int charge() const = 0;
60  virtual void setCharge(Charge q) = 0;
62  virtual int threeCharge() const = 0;
64  virtual void setThreeCharge(Charge qx3) = 0;
66  virtual const LorentzVector& p4() const = 0;
68  virtual const PolarLorentzVector& polarP4() const = 0;
70  virtual Vector momentum() const = 0;
73  virtual Vector boostToCM() const = 0;
75  virtual double p() const = 0;
77  virtual double energy() const = 0;
79  virtual double et() const = 0;
81  virtual double et2() const = 0;
83  virtual double mass() const = 0;
85  virtual double massSqr() const = 0;
87  virtual double mt() const = 0;
89  virtual double mtSqr() const = 0;
91  virtual double px() const = 0;
93  virtual double py() const = 0;
95  virtual double pz() const = 0;
97  virtual double pt() const = 0;
99  virtual double phi() const = 0;
101  virtual double theta() const = 0;
103  virtual double eta() const = 0;
105  virtual double rapidity() const = 0;
107  virtual double y() const = 0;
109  virtual void setP4(const LorentzVector& p4) = 0;
111  virtual void setP4(const PolarLorentzVector& p4) = 0;
113  virtual void setMass(double m) = 0;
114  virtual void setPz(double pz) = 0;
116  virtual const Point& vertex() const = 0;
118  virtual double vx() const = 0;
120  virtual double vy() const = 0;
122  virtual double vz() const = 0;
124  virtual void setVertex(const Point& vertex) = 0;
126  virtual int pdgId() const = 0;
127  // set PDG identifier
128  virtual void setPdgId(int pdgId) = 0;
130  virtual int status() const = 0;
132  virtual void setStatus(int status) = 0;
134  virtual void setLongLived() = 0;
136  virtual bool longLived() const = 0;
138  virtual void setMassConstraint() = 0;
140  virtual bool massConstraint() const = 0;
142  virtual Candidate* clone() const = 0;
144  const_iterator begin() const { return const_iterator(this, 0); }
146  const_iterator end() const { return const_iterator(this, numberOfDaughters()); }
148  iterator begin() { return iterator(this, 0); }
150  iterator end() { return iterator(this, numberOfDaughters()); }
152  virtual size_type numberOfDaughters() const = 0;
154  virtual const Candidate* daughter(size_type i) const = 0;
156  virtual Candidate* daughter(size_type i) = 0;
158  virtual Candidate* daughter(const std::string& s) = 0;
160  virtual const Candidate* daughter(const std::string& s) const = 0;
162  virtual size_type numberOfMothers() const = 0;
164  virtual const Candidate* mother(size_type i = 0) const = 0;
167  virtual size_t numberOfSourceCandidatePtrs() const = 0;
170  virtual CandidatePtr sourceCandidatePtr(size_type i) const { return CandidatePtr(); }
180  virtual void setSourceCandidatePtr(const CandidatePtr& ptr){};
181 
183  virtual double vertexChi2() const = 0;
190  virtual double vertexNdof() const = 0;
192  virtual double vertexNormalizedChi2() const = 0;
194  virtual double vertexCovariance(int i, int j) const = 0;
196  virtual CovarianceMatrix vertexCovariance() const {
197  CovarianceMatrix m;
199  return m;
200  } //TODO
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 {
217  return masterClone().template castTo<Ref>();
218  }
220 
221  template <typename T>
222  T get() const {
223  if (hasMasterClone())
224  return masterClone()->get<T>();
225  else
226  return reco::get<T>(*this);
227  }
229  template <typename T, typename Tag>
230  T get() const {
231  if (hasMasterClone())
232  return masterClone()->get<T, Tag>();
233  else
234  return reco::get<T, Tag>(*this);
235  }
237  template <typename T>
238  T get(size_type i) const {
239  if (hasMasterClone())
240  return masterClone()->get<T>(i);
241  else
242  return reco::get<T>(*this, i);
243  }
245  template <typename T, typename Tag>
246  T get(size_type i) const {
247  if (hasMasterClone())
248  return masterClone()->get<T, Tag>(i);
249  else
250  return reco::get<T, Tag>(*this, i);
251  }
253  template <typename T>
254  size_type numberOf() const {
255  if (hasMasterClone())
256  return masterClone()->numberOf<T>();
257  else
258  return reco::numberOf<T>(*this);
259  }
261  template <typename T, typename Tag>
262  size_type numberOf() const {
263  if (hasMasterClone())
264  return masterClone()->numberOf<T, Tag>();
265  else
266  return reco::numberOf<T, Tag>(*this);
267  }
268 
269  virtual const Track* bestTrack() const { return nullptr; }
270 
272  virtual float dzError() const {
273  return 0;
274  } // { const Track * tr=bestTrack(); if(tr!=nullptr) return tr->dzError(); else return 0; }
276  virtual float dxyError() const {
277  return 0;
278  } // { const Track * tr=bestTrack(); if(tr!=nullptr) return tr->dxyError(); else return 0; }
279 
280  virtual bool isElectron() const = 0;
281  virtual bool isMuon() const = 0;
282  virtual bool isStandAloneMuon() const = 0;
283  virtual bool isGlobalMuon() const = 0;
284  virtual bool isTrackerMuon() const = 0;
285  virtual bool isCaloMuon() const = 0;
286  virtual bool isPhoton() const = 0;
287  virtual bool isConvertedPhoton() const = 0;
288  virtual bool isJet() const = 0;
289 
290  protected:
292  virtual bool overlap(const Candidate&) const = 0;
293  template <typename, typename, typename>
294  friend struct component;
295  friend class ::OverlapChecker;
296  friend class ShallowCloneCandidate;
298  };
299 
300  namespace candidate {
301 
302  const_iterator::reference const_iterator::operator*() const { return *(me->daughter(i)); }
303  iterator::reference iterator::operator*() const { return *(me->daughter(i)); }
304 
305  } // namespace candidate
306 
307 } // namespace reco
308 
309 #endif
int Charge
electric charge type
Definition: Candidate.h:35
virtual double pz() const =0
z coordinate of momentum vector
virtual bool isJet() const =0
math::XYZVector Vector
point in the space
Definition: Candidate.h:43
virtual void setSourceCandidatePtr(const CandidatePtr &ptr)
Set the ptr to the source Candidate.
Definition: Candidate.h:180
virtual double vx() const =0
x coordinate of vertex position
virtual bool hasMasterClonePtr() const =0
size_t size_type
Definition: Candidate.h:30
virtual bool isStandAloneMuon() const =0
virtual void setP4(const LorentzVector &p4)=0
set 4-momentum
virtual const PolarLorentzVector & polarP4() const =0
four-momentum Lorentz vector
virtual const Track * bestTrack() const
Definition: Candidate.h:269
candidate::const_iterator const_iterator
Definition: Candidate.h:31
virtual CandidatePtr sourceCandidatePtr(size_type i) const
Definition: Candidate.h:170
virtual bool isMuon() const =0
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
virtual bool isPhoton() const =0
virtual float dxyError() const
uncertainty on dxy
Definition: Candidate.h:276
virtual void setMassConstraint()=0
set mass constraint flag
virtual double mtSqr() const =0
transverse mass squared
virtual const Candidate * mother(size_type i=0) const =0
return pointer to mother
ErrorD< N >::type type
Definition: Error.h:32
virtual int threeCharge() const =0
electric charge
virtual bool longLived() const =0
is long lived?
virtual double vy() const =0
y coordinate of vertex position
virtual size_t numberOfSourceCandidatePtrs() const =0
virtual bool massConstraint() const =0
do mass constraint?
virtual void setPdgId(int pdgId)=0
reference operator*() const
Definition: Candidate.h:302
virtual void fillVertexCovariance(CovarianceMatrix &v) 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
virtual Vector boostToCM() const =0
virtual bool isTrackerMuon() const =0
virtual int status() const =0
status word
virtual double et() const =0
transverse energy
virtual double energy() const =0
energy
virtual double py() const =0
y coordinate of momentum vector
Ref masterRef() const
cast master clone reference to a concrete type
Definition: Candidate.h:216
virtual bool isConvertedPhoton() const =0
virtual Candidate * clone() const =0
returns a clone of the Candidate object
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
virtual int pdgId() const =0
PDG identifier.
virtual void setVertex(const Point &vertex)=0
set vertex
const_iterator end() const
last daughter const_iterator
Definition: Candidate.h:146
virtual size_type numberOfMothers() const =0
number of mothers (zero or one in most of but not all the cases)
virtual float dzError() const
uncertainty on dz
Definition: Candidate.h:272
virtual double vertexNormalizedChi2() const =0
chi-squared divided by n.d.o.f.
virtual bool isElectron() const =0
virtual void setPz(double pz)=0
size_type numberOf() const
number of components
Definition: Candidate.h:254
virtual double p() const =0
magnitude of momentum vector
virtual bool overlap(const Candidate &) const =0
check overlap with another Candidate
virtual void setStatus(int status)=0
set status word
size_type numberOf() const
number of components
Definition: Candidate.h:262
virtual void setThreeCharge(Charge qx3)=0
set electric charge
iterator end()
last daughter iterator
Definition: Candidate.h:150
virtual void setLongLived()=0
set long lived flag
candidate::iterator iterator
Definition: Candidate.h:32
unsigned int index
index type
Definition: Candidate.h:51
virtual const CandidateBaseRef & masterClone() const =0
virtual bool isGlobalMuon() const =0
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
Definition: CandidateFwd.h:25
virtual double theta() const =0
momentum polar angle
virtual double eta() const =0
momentum pseudorapidity
virtual ~Candidate()
destructor
Definition: Candidate.cc:5
iterator begin()
first daughter iterator
Definition: Candidate.h:148
Candidate()
default constructor
Definition: Candidate.h:54
virtual double pt() const =0
transverse momentum
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 mass() const =0
mass
virtual bool isCaloMuon() const =0
virtual CovarianceMatrix vertexCovariance() const
fill SMatrix
Definition: Candidate.h:196
virtual double massSqr() const =0
mass squared
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
virtual Vector momentum() const =0
spatial momentum vector
virtual double rapidity() const =0
rapidity
virtual int charge() const =0
electric charge
fixed size matrix
virtual double et2() const =0
transverse energy squared (use this for cut!)
T get() const
get a component
Definition: Candidate.h:222
const_iterator begin() const
first daughter const_iterator
Definition: Candidate.h:144
math::XYZPoint Point
point in the space
Definition: Candidate.h:41
virtual const Point & vertex() const =0
vertex position
virtual double vertexChi2() const =0
chi-squares
virtual double vz() const =0
z coordinate of vertex position
virtual double mt() const =0
transverse mass
virtual double vertexNdof() const =0
virtual double px() const =0
x coordinate of momentum vector
math::Error< dimension >::type CovarianceMatrix
covariance error matrix (3x3)
Definition: Candidate.h:47
virtual size_type numberOfDaughters() const =0
number of daughters
long double T
virtual void setCharge(Charge q)=0
set electric charge
virtual double phi() const =0
momentum azimuthal angle
virtual const CandidatePtr & masterClonePtr() const =0
virtual void setMass(double m)=0
set particle mass
reference operator*() const
Definition: Candidate.h:303
virtual bool hasMasterClone() const =0
virtual double y() const =0
rapidity
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:39