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 
301  const_iterator::reference const_iterator::operator*() const { return *(me->daughter(i)); }
303 
304  } // namespace candidate
305 
306 } // namespace reco
307 
308 #endif
reco::Candidate::size
Definition: Candidate.h:48
reco::Candidate::energy
virtual double energy() const =0
energy
reco::Candidate::daughter
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode)
const_iterator.h
reco::Candidate::dzError
virtual float dzError() const
uncertainty on dz
Definition: Candidate.h:271
OverlapChecker
Definition: OverlapChecker.h:17
reco::Candidate::vertexNdof
virtual double vertexNdof() const =0
reco::candidate::iterator::me
pointer me
Definition: iterator.h:67
reco::Candidate::Vector
math::XYZVector Vector
point in the space
Definition: Candidate.h:42
reco::Candidate::overlap
virtual bool overlap(const Candidate &) const =0
check overlap with another Candidate
mps_fire.i
i
Definition: mps_fire.py:428
reco::Candidate::masterClonePtr
virtual const CandidatePtr & masterClonePtr() const =0
reco::Candidate::fillVertexCovariance
virtual void fillVertexCovariance(CovarianceMatrix &v) const =0
reco::Candidate::boostToCM
virtual Vector boostToCM() const =0
reco::Candidate::setP4
virtual void setP4(const LorentzVector &p4)=0
set 4-momentum
reco::Candidate::setMass
virtual void setMass(double m)=0
set particle mass
reco::Candidate::threeCharge
virtual int threeCharge() const =0
electric charge
reco::Candidate::mass
virtual double mass() const =0
mass
reco::Candidate::eta
virtual double eta() const =0
momentum pseudorapidity
reco::candidate::const_iterator::me
pointer me
Definition: const_iterator.h:72
component.h
reco::Candidate::PolarLorentzVector
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:38
reco::candidate::const_iterator
Definition: const_iterator.h:14
reco::Candidate::Charge
int Charge
electric charge type
Definition: Candidate.h:34
reco::Candidate::const_iterator
candidate::const_iterator const_iterator
Definition: Candidate.h:30
reco::Candidate::get
T get(size_type i) const
get a component
Definition: Candidate.h:237
reco::Candidate::pt
virtual double pt() const =0
transverse momentum
reco::Candidate::isPhoton
virtual bool isPhoton() const =0
reco::Candidate::get
T get() const
get a component
Definition: Candidate.h:221
reco::candidate::iterator::i
difference_type i
Definition: iterator.h:68
CovarianceMatrix
Definition: CovarianceMatrix.h:28
reco::Candidate::status
virtual int status() const =0
status word
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
findQualityFiles.v
v
Definition: findQualityFiles.py:179
reco::Candidate::setSourceCandidatePtr
virtual void setSourceCandidatePtr(const CandidatePtr &ptr)
Set the ptr to the source Candidate.
Definition: Candidate.h:179
reco::Candidate::setPdgId
virtual void setPdgId(int pdgId)=0
reco::Candidate::mother
virtual const Candidate * mother(size_type i=0) const =0
return pointer to mother
reco::Candidate::isConvertedPhoton
virtual bool isConvertedPhoton() const =0
reco::Candidate::rapidity
virtual double rapidity() const =0
rapidity
reco::Candidate::theta
virtual double theta() const =0
momentum polar angle
reco::Candidate::vertexChi2
virtual double vertexChi2() const =0
chi-squares
reco::candidate::iterator::operator*
reference operator*() const
Definition: Candidate.h:302
alignCSCRings.s
s
Definition: alignCSCRings.py:92
reco::Candidate::pz
virtual double pz() const =0
z coordinate of momentum vector
reco::Candidate::numberOfMothers
virtual size_type numberOfMothers() const =0
number of mothers (zero or one in most of but not all the cases)
reco::Candidate::setMassConstraint
virtual void setMassConstraint()=0
set mass constraint flag
reco::Candidate::massConstraint
virtual bool massConstraint() const =0
do mass constraint?
reco::Candidate::vx
virtual double vx() const =0
x coordinate of vertex position
reco::Candidate::vy
virtual double vy() const =0
y coordinate of vertex position
reco::Candidate::y
virtual double y() const =0
rapidity
reco::Candidate::charge
virtual int charge() const =0
electric charge
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
reco::Candidate::isStandAloneMuon
virtual bool isStandAloneMuon() const =0
reco::Candidate::numberOf
size_type numberOf() const
number of components
Definition: Candidate.h:253
reco::Candidate::masterRef
Ref masterRef() const
cast master clone reference to a concrete type
Definition: Candidate.h:215
reco::Track
Definition: Track.h:27
Particle.h
reco::Candidate::numberOfDaughters
virtual size_type numberOfDaughters() const =0
number of daughters
reco::Candidate::vertexNormalizedChi2
virtual double vertexNormalizedChi2() const =0
chi-squared divided by n.d.o.f.
reco::Candidate::p
virtual double p() const =0
magnitude of momentum vector
reco::Candidate::hasMasterClone
virtual bool hasMasterClone() const =0
reco::Candidate::isCaloMuon
virtual bool isCaloMuon() const =0
reco::Candidate::setThreeCharge
virtual void setThreeCharge(Charge qx3)=0
set electric charge
reco::Candidate::polarP4
virtual const PolarLorentzVector & polarP4() const =0
four-momentum Lorentz vector
reco::Candidate::end
iterator end()
last daughter iterator
Definition: Candidate.h:149
edm::RefToBase::get
value_type const * get() const
Definition: RefToBase.h:209
reco::candidate::const_iterator::reference
const typedef Candidate & reference
Definition: const_iterator.h:17
reco::Candidate::iterator
candidate::iterator iterator
Definition: Candidate.h:31
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
reco::Candidate::py
virtual double py() const =0
y coordinate of momentum vector
reco::Candidate::isMuon
virtual bool isMuon() const =0
Error.h
Point
Structure Point Contains parameters of Gaussian fits to DMRs.
Definition: DMRtrends.cc:57
reco::Candidate::setStatus
virtual void setStatus(int status)=0
set status word
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
reco::Candidate::get
T get() const
get a component
Definition: Candidate.h:229
reco::Candidate::end
const_iterator end() const
last daughter const_iterator
Definition: Candidate.h:145
reco::Candidate::momentum
virtual Vector momentum() const =0
spatial momentum vector
reco::Candidate::mt
virtual double mt() const =0
transverse mass
reco::Candidate::vertex
virtual const Point & vertex() const =0
vertex position
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
reco::Candidate::clone
virtual Candidate * clone() const =0
returns a clone of the Candidate object
math::Vector
fixed size vector
Definition: Vector.h:24
LorentzVector.h
reco::Candidate::setVertex
virtual void setVertex(const Point &vertex)=0
set vertex
reco::Candidate::begin
iterator begin()
first daughter iterator
Definition: Candidate.h:147
reco::candidate::const_iterator::i
difference_type i
Definition: const_iterator.h:73
reco::candidate::iterator
Definition: iterator.h:14
reco::Candidate::numberOf
size_type numberOf() const
number of components
Definition: Candidate.h:261
submitPVResolutionJobs.q
q
Definition: submitPVResolutionJobs.py:84
reco::Candidate::setLongLived
virtual void setLongLived()=0
set long lived flag
reco::Candidate::pdgId
virtual int pdgId() const =0
PDG identifier.
reco::Candidate::mtSqr
virtual double mtSqr() const =0
transverse mass squared
reco::Candidate::setPz
virtual void setPz(double pz)=0
edm::Ptr< Candidate >
reco::Candidate
Definition: Candidate.h:27
reco::Candidate::isElectron
virtual bool isElectron() const =0
reco::Candidate::CovarianceMatrix
math::Error< dimension >::type CovarianceMatrix
covariance error matrix (3x3)
Definition: Candidate.h:46
reco::Candidate::get
T get(size_type i) const
get a component
Definition: Candidate.h:245
reco::Candidate::sourceCandidatePtr
virtual CandidatePtr sourceCandidatePtr(size_type i) const
Definition: Candidate.h:169
CMS_CLASS_VERSION.h
reco::Candidate::setCharge
virtual void setCharge(Charge q)=0
set electric charge
reco::Candidate::px
virtual double px() const =0
x coordinate of momentum vector
reco::Candidate::bestTrack
virtual const Track * bestTrack() const
Definition: Candidate.h:268
reco::Candidate::hasMasterClonePtr
virtual bool hasMasterClonePtr() const =0
T
long double T
Definition: Basic3DVectorLD.h:48
math::XYZTLorentzVector
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
LorentzVector
math::XYZTLorentzVector LorentzVector
Definition: HLTMuonMatchAndPlot.h:49
reco::JetExtendedAssociation::Ref
edm::Ref< Container > Ref
Definition: JetExtendedAssociation.h:32
math::Error::type
ErrorD< N >::type type
Definition: Error.h:32
reco::Candidate::index
unsigned int index
index type
Definition: Candidate.h:50
reco::Candidate::dimension
Definition: Candidate.h:44
reco::Candidate::longLived
virtual bool longLived() const =0
is long lived?
reco::Candidate::et2
virtual double et2() const =0
transverse energy squared (use this for cut!)
Point3D.h
reco::Candidate::vz
virtual double vz() const =0
z coordinate of vertex position
reco::candidate::const_iterator::operator*
reference operator*() const
Definition: Candidate.h:301
edm::RefToBase< Candidate >
reco::Candidate::~Candidate
virtual ~Candidate()
destructor
Definition: Candidate.cc:5
reco::Candidate::masterClone
virtual const CandidateBaseRef & masterClone() const =0
reco::Candidate::p4
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
reco::Candidate::Candidate
Candidate()
default constructor
Definition: Candidate.h:53
reco::Candidate::isTrackerMuon
virtual bool isTrackerMuon() const =0
reco::Candidate::numberOfSourceCandidatePtrs
virtual size_t numberOfSourceCandidatePtrs() const =0
reco::ShallowCloneCandidate
Definition: ShallowCloneCandidate.h:15
math::PtEtaPhiMLorentzVector
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
reco::CandidatePtr
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
Definition: CandidateFwd.h:25
reco::Candidate::vertexCovariance
virtual CovarianceMatrix vertexCovariance() const
fill SMatrix
Definition: Candidate.h:195
reco::ShallowClonePtrCandidate
Definition: ShallowClonePtrCandidate.h:15
reco::Candidate::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
reco::Candidate::Point
math::XYZPoint Point
point in the space
Definition: Candidate.h:40
Vector3D.h
reco::Candidate::isJet
virtual bool isJet() const =0
reco::Candidate::phi
virtual double phi() const =0
momentum azimuthal angle
reco::Candidate::begin
const_iterator begin() const
first daughter const_iterator
Definition: Candidate.h:143
reco::component
Definition: component.h:57
reco::Candidate::isGlobalMuon
virtual bool isGlobalMuon() const =0
reco::Candidate::dxyError
virtual float dxyError() const
uncertainty on dxy
Definition: Candidate.h:275
reco::Candidate::massSqr
virtual double massSqr() const =0
mass squared
reco::Candidate::size_type
size_t size_type
Definition: Candidate.h:29
reco::Candidate::et
virtual double et() const =0
transverse energy