CMS 3D CMS Logo

LeafCandidate.h
Go to the documentation of this file.
1 #ifndef Candidate_LeafCandidate_h
2 #define Candidate_LeafCandidate_h
3 
12 #include "ParticleState.h"
13 
14 namespace reco {
15 
16  class LeafCandidate : public Candidate {
17  public:
21  typedef int Charge;
30 
31  typedef unsigned int index;
32 
34 
35  // constructor from candidate
36  explicit LeafCandidate( const Candidate & c) : m_state(c.charge(),c.polarP4(), c.vertex(), c.pdgId(), c.status() ){}
37 
38 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
39  template<typename... Args>
40  explicit LeafCandidate(Args && ...args) :
41  m_state(std::forward<Args>(args)...) {}
42 
44 
45  LeafCandidate(LeafCandidate&&)=default;
46  LeafCandidate(LeafCandidate const&)=default;
48  LeafCandidate& operator=(LeafCandidate const&)=default;
49 #else
50  // for Reflex to parse... (compilation will use the above)
51  LeafCandidate( Charge q, const PtEtaPhiMass & p4, const Point & vtx = Point( 0, 0, 0 ),
52  int pdgId = 0, int status = 0, bool integerCharge = true );
53  LeafCandidate( Charge q, const LorentzVector & p4, const Point & vtx = Point( 0, 0, 0 ),
54  int pdgId = 0, int status = 0, bool integerCharge = true );
55  LeafCandidate( Charge q, const PolarLorentzVector & p4, const Point & vtx = Point( 0, 0, 0 ),
56  int pdgId = 0, int status = 0, bool integerCharge = true );
57  LeafCandidate( Charge q, const GlobalVector & p3, float iEnergy, float imass, const Point & vtx = Point( 0, 0, 0 ),
58  int pdgId = 0, int status = 0, bool integerCharge = true );
59 #endif
60 
61  void construct(int qx3, float pt, float eta, float phi, float mass, const Point & vtx, int pdgId, int status) {
62  m_state = ParticleState(qx3, PolarLorentzVector(pt,eta,phi,mass), vtx, pdgId, status, false);
63  }
64 
66  virtual ~LeafCandidate();
68  virtual size_t numberOfDaughters() const;
70  virtual const Candidate * daughter( size_type ) const;
72  virtual size_t numberOfMothers() const;
74  virtual const Candidate * mother( size_type ) const;
76  virtual Candidate * daughter( size_type );
78  virtual Candidate * daughter(const std::string& s );
80  virtual const Candidate * daughter(const std::string& s ) const;
83  virtual size_t numberOfSourceCandidatePtrs() const { return 0;}
87  return CandidatePtr();
88  }
89 
91  virtual int charge() const final { return m_state.charge(); }
93  virtual void setCharge( Charge q ) final { m_state.setCharge(q); }
95  virtual int threeCharge() const final { return m_state.threeCharge(); }
97  virtual void setThreeCharge( Charge qx3 ) final {m_state.setThreeCharge(qx3); }
99  virtual const LorentzVector & p4() const final { return m_state.p4(); }
101  virtual const PolarLorentzVector & polarP4() const final { return m_state.polarP4(); }
103  virtual Vector momentum() const final { return m_state.momentum(); }
106  virtual Vector boostToCM() const final { return m_state.boostToCM(); }
108  virtual double p() const final { return m_state.p(); }
110  virtual double energy() const final { return m_state.energy(); }
112  virtual double et() const final { return m_state.et(); }
114  virtual double et2() const final { return m_state.et2(); }
116  virtual double mass() const final { return m_state.mass(); }
118  virtual double massSqr() const final { return mass() * mass(); }
119 
121  virtual double mt() const final { return m_state.mt(); }
123  virtual double mtSqr() const final { return m_state.mtSqr(); }
125  virtual double px() const final { return m_state.px(); }
127  virtual double py() const final { return m_state.py(); }
129  virtual double pz() const final { return m_state.pz(); }
131  virtual double pt() const final { return m_state.pt();}
133  virtual double phi() const final { return m_state.phi(); }
135  virtual double theta() const final { return m_state.theta(); }
137  virtual double eta() const final { return m_state.eta(); }
139  virtual double rapidity() const final { return m_state.rapidity(); }
141  virtual double y() const final { return rapidity(); }
143  virtual void setP4( const LorentzVector & p4 ) final { m_state.setP4(p4);}
145  virtual void setP4( const PolarLorentzVector & p4 ) final {m_state.setP4(p4); }
147  virtual void setMass( double m ) final {m_state.setMass(m);}
148  virtual void setPz( double pz ) final { m_state.setPz(pz);}
150  virtual const Point & vertex() const { return m_state.vertex(); }
152  virtual double vx() const { return m_state.vx(); }
154  virtual double vy() const { return m_state.vy(); }
156  virtual double vz() const { return m_state.vz(); }
158  virtual void setVertex( const Point & vertex ) { m_state.setVertex(vertex); }
159 
161  virtual int pdgId() const final { return m_state.pdgId(); }
162  // set PDG identifier
163  virtual void setPdgId( int pdgId ) final { m_state.setPdgId(pdgId); }
165  virtual int status() const final { return m_state.status(); }
167  virtual void setStatus( int status ) final { m_state.setStatus(status); }
170  virtual void setLongLived() final { m_state.setLongLived(); }
172  virtual bool longLived() const final { return m_state.longLived(); }
175  virtual void setMassConstraint() final { m_state.setMassConstraint();}
177  virtual bool massConstraint() const final { return m_state.massConstraint(); }
178 
180  virtual LeafCandidate * clone() const {
181  return new LeafCandidate( *this );
182  }
183 
185  virtual double vertexChi2() const;
192  virtual double vertexNdof() const;
194  virtual double vertexNormalizedChi2() const;
196  virtual double vertexCovariance(int i, int j) const;
200  virtual void fillVertexCovariance(CovarianceMatrix & v) const;
203  virtual bool hasMasterClone() const;
206  virtual const CandidateBaseRef & masterClone() const;
209  virtual bool hasMasterClonePtr() const;
212  virtual const CandidatePtr & masterClonePtr() const;
213 
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 
250 
251  virtual bool isElectron() const;
252  virtual bool isMuon() const;
253  virtual bool isStandAloneMuon() const;
254  virtual bool isGlobalMuon() const;
255  virtual bool isTrackerMuon() const;
256  virtual bool isCaloMuon() const;
257  virtual bool isPhoton() const;
258  virtual bool isConvertedPhoton() const;
259  virtual bool isJet() const;
260 
261  private:
263 
264  private:
266  virtual bool overlap( const Candidate & ) const;
267  template<typename, typename, typename> friend struct component;
268  friend class ::OverlapChecker;
269  friend class ShallowCloneCandidate;
271 
272  };
273 
274 }
275 
276 #endif
double rapidity() const
repidity
value_type const * get() const
Definition: RefToBase.h:234
virtual double pt() const final
transverse momentum
double px() const
x coordinate of momentum vector
LeafCandidate(LeafCandidate &rh)
Definition: LeafCandidate.h:43
virtual double mass() const final
mass
int pdgId() const
PDG identifier.
size_t size_type
Definition: Candidate.h:30
virtual double eta() const final
momentum pseudorapidity
double theta() const
momentum polar angle
size_type numberOf() const
number of components
virtual double vertexChi2() const
chi-squares
virtual const Point & vertex() const
vertex position (overwritten by PF...)
size_type numberOf() const
number of components
virtual double mtSqr() const final
transverse mass squared
virtual bool isConvertedPhoton() const
double pz() const
z coordinate of momentum vector
int threeCharge() const
electric charge
Definition: ParticleState.h:76
virtual void setPdgId(int pdgId) final
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: LeafCandidate.h:25
CandidateCollection daughters
collection of daughter candidates
Definition: LeafCandidate.h:19
LeafCandidate(Args &&...args)
Definition: LeafCandidate.h:40
virtual bool isPhoton() const
virtual bool isStandAloneMuon() const
virtual Vector momentum() const final
spatial momentum vector
virtual int status() const final
status word
void setMassConstraint()
set mass constraint flag
double energy() const
energy
Definition: ParticleState.h:91
void setPdgId(int pdgId)
void setPz(double pz)
virtual double vy() const
y coordinate of vertex position
virtual double et2() const final
transverse energy squared (use this for cut!)
ParticleState m_state
virtual void setMassConstraint() final
virtual bool isMuon() const
virtual Vector boostToCM() const final
double phi() const
momentum azimuthal angle
bool massConstraint() const
do mass constraint?
virtual size_t numberOfDaughters() const
number of daughters
const LorentzVector & p4() const
four-momentum Lorentz vector
Definition: ParticleState.h:80
virtual double mt() const final
transverse mass
virtual double phi() const final
momentum azimuthal angle
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 int charge() const final
electric charge
Definition: LeafCandidate.h:91
virtual void setPz(double pz) final
virtual double et() const final
transverse energy
virtual bool isGlobalMuon() const
virtual double theta() const final
momentum polar angle
double pt() const
transverse momentum
virtual const CandidatePtr & masterClonePtr() const
virtual const Candidate * daughter(size_type) const
return daughter at a given position (throws an exception)
void setStatus(int status)
set status word
double mt() const
transverse mass
double mass() const
mass
Definition: ParticleState.h:97
CovarianceMatrix vertexCovariance() const final
return SMatrix
virtual ~LeafCandidate()
destructor
Definition: LeafCandidate.cc:5
bool longLived() const
is long lived?
virtual void setLongLived() final
virtual bool hasMasterClone() const
Ref masterRef() const
cast master clone reference to a concrete type
virtual double px() const final
x coordinate of momentum vector
LeafCandidate(const Candidate &c)
Definition: LeafCandidate.h:36
virtual bool longLived() const final
is long lived?
void setVertex(const Point &vertex)
set vertex
virtual int pdgId() const final
PDG identifier.
virtual double energy() const final
energy
virtual void setCharge(Charge q) final
set electric charge
Definition: LeafCandidate.h:93
double mtSqr() const
transverse mass squared
virtual CandidatePtr sourceCandidatePtr(size_type i) const
Definition: LeafCandidate.h:86
virtual void setP4(const PolarLorentzVector &p4) final
set 4-momentum
virtual double vertexNormalizedChi2() const
chi-squared divided by n.d.o.f.
virtual double p() const final
magnitude of momentum vector
Vector boostToCM() const
Definition: ParticleState.h:87
void setThreeCharge(Charge qx3)
set electric charge
Definition: ParticleState.h:78
double et2() const
transverse energy squared (use this for cuts)!
Definition: ParticleState.h:95
unsigned int index
Definition: LeafCandidate.h:31
virtual bool overlap(const Candidate &) const
check overlap with another Candidate
virtual double vz() const
z coordinate of vertex position
virtual bool hasMasterClonePtr() const
virtual void setVertex(const Point &vertex)
set vertex
virtual bool isElectron() const
void setLongLived()
set long lived flag
const PolarLorentzVector & polarP4() const
four-momentum Lorentz vector
Definition: ParticleState.h:82
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float >, ROOT::Math::GlobalCoordinateSystemTag > GlobalVector
vector in glovbal coordinate system
Definition: Vector3D.h:27
virtual double pz() const final
z coordinate of momentum vector
virtual bool isCaloMuon() const
virtual double massSqr() const final
mass squared
virtual double y() const final
rapidity
virtual void setStatus(int status) final
set status word
double et() const
transverse energy
Definition: ParticleState.h:93
double vy() const
y coordinate of vertex position
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
Definition: CandidateFwd.h:25
virtual size_t numberOfSourceCandidatePtrs() const
Definition: LeafCandidate.h:83
double vz() const
z coordinate of vertex position
int charge() const
electric charge
Definition: ParticleState.h:72
virtual bool isTrackerMuon() const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
virtual int threeCharge() const final
electric charge
Definition: LeafCandidate.h:95
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
int status() const
status word
const Point & vertex() const
vertex position
virtual void setP4(const LorentzVector &p4) final
set 4-momentum
virtual bool isJet() const
fixed size matrix
virtual size_t numberOfMothers() const
number of mothers
virtual const CandidateBaseRef & masterClone() const
Definition: LeafCandidate.cc:7
Vector momentum() const
spatial momentum vector
Definition: ParticleState.h:84
math::XYZVector Vector
point in the space
Definition: LeafCandidate.h:29
virtual const PolarLorentzVector & polarP4() const final
four-momentum Lorentz vector
virtual double vx() const
x coordinate of vertex position
void construct(int qx3, float pt, float eta, float phi, float mass, const Point &vtx, int pdgId, int status)
Definition: LeafCandidate.h:61
virtual double rapidity() const final
rapidity
virtual void setMass(double m) final
set particle mass
double eta() const
momentum pseudorapidity
virtual LeafCandidate * clone() const
returns a clone of the Candidate object
void setP4(const LorentzVector &p4)
set 4-momentum
virtual void setThreeCharge(Charge qx3) final
set electric charge
Definition: LeafCandidate.h:97
virtual const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
LeafCandidate & operator=(LeafCandidate &&)=default
long double T
double p() const
magnitude of momentum vector
Definition: ParticleState.h:89
double py() const
y coordinate of momentum vector
void setCharge(Charge q)
set electric charge
Definition: ParticleState.h:74
virtual double py() const final
y coordinate of momentum vector
virtual void fillVertexCovariance(CovarianceMatrix &v) const
fill SMatrix
virtual double vertexNdof() const
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: LeafCandidate.h:23
double vx() const
x coordinate of vertex position
int Charge
electric charge type
Definition: LeafCandidate.h:21
virtual const Candidate * mother(size_type) const
return mother at a given position (throws an exception)
virtual bool massConstraint() const final
do mass constraint?
math::XYZPoint Point
point in the space
Definition: LeafCandidate.h:27
double p3[4]
Definition: TauolaWrapper.h:91
void setMass(double m)
set particle mass