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  ~LeafCandidate() override;
68  size_t numberOfDaughters() const override;
70  const Candidate * daughter( size_type ) const override;
72  size_t numberOfMothers() const override;
74  const Candidate * mother( size_type ) const override;
76  Candidate * daughter( size_type ) override;
78  Candidate * daughter(const std::string& s ) override;
80  const Candidate * daughter(const std::string& s ) const override;
83  size_t numberOfSourceCandidatePtrs() const override { return 0;}
87  return CandidatePtr();
88  }
89 
91  int charge() const final { return m_state.charge(); }
93  void setCharge( Charge q ) final { m_state.setCharge(q); }
95  int threeCharge() const final { return m_state.threeCharge(); }
97  void setThreeCharge( Charge qx3 ) final {m_state.setThreeCharge(qx3); }
99  const LorentzVector & p4() const final { return m_state.p4(); }
101  const PolarLorentzVector & polarP4() const final { return m_state.polarP4(); }
103  Vector momentum() const final { return m_state.momentum(); }
106  Vector boostToCM() const final { return m_state.boostToCM(); }
108  double p() const final { return m_state.p(); }
110  double energy() const final { return m_state.energy(); }
112  double et() const final { return m_state.et(); }
114  double et2() const final { return m_state.et2(); }
116  double mass() const final { return m_state.mass(); }
118  double massSqr() const final { return mass() * mass(); }
119 
121  double mt() const final { return m_state.mt(); }
123  double mtSqr() const final { return m_state.mtSqr(); }
125  double px() const final { return m_state.px(); }
127  double py() const final { return m_state.py(); }
129  double pz() const final { return m_state.pz(); }
131  double pt() const final { return m_state.pt();}
133  double phi() const final { return m_state.phi(); }
135  double theta() const final { return m_state.theta(); }
137  double eta() const final { return m_state.eta(); }
139  double rapidity() const final { return m_state.rapidity(); }
141  double y() const final { return rapidity(); }
143  void setP4( const LorentzVector & p4 ) final { m_state.setP4(p4);}
145  void setP4( const PolarLorentzVector & p4 ) final {m_state.setP4(p4); }
147  void setMass( double m ) final {m_state.setMass(m);}
148  void setPz( double pz ) final { m_state.setPz(pz);}
150  const Point & vertex() const override { return m_state.vertex(); }
152  double vx() const override { return m_state.vx(); }
154  double vy() const override { return m_state.vy(); }
156  double vz() const override { return m_state.vz(); }
158  void setVertex( const Point & vertex ) override { m_state.setVertex(vertex); }
159 
161  int pdgId() const final { return m_state.pdgId(); }
162  // set PDG identifier
163  void setPdgId( int pdgId ) final { m_state.setPdgId(pdgId); }
165  int status() const final { return m_state.status(); }
167  void setStatus( int status ) final { m_state.setStatus(status); }
170  void setLongLived() final { m_state.setLongLived(); }
172  bool longLived() const final { return m_state.longLived(); }
177  bool massConstraint() const final { return m_state.massConstraint(); }
178 
180  LeafCandidate * clone() const override {
181  return new LeafCandidate( *this );
182  }
183 
185  double vertexChi2() const override;
192  double vertexNdof() const override;
194  double vertexNormalizedChi2() const override;
196  double vertexCovariance(int i, int j) const override;
200  void fillVertexCovariance(CovarianceMatrix & v) const override;
203  bool hasMasterClone() const override;
206  const CandidateBaseRef & masterClone() const override;
209  bool hasMasterClonePtr() const override;
212  const CandidatePtr & masterClonePtr() const override;
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  bool isElectron() const override;
252  bool isMuon() const override;
253  bool isStandAloneMuon() const override;
254  bool isGlobalMuon() const override;
255  bool isTrackerMuon() const override;
256  bool isCaloMuon() const override;
257  bool isPhoton() const override;
258  bool isConvertedPhoton() const override;
259  bool isJet() const override;
260 
261  private:
263 
264  private:
266  bool overlap( const Candidate & ) const override;
267  template<typename, typename, typename> friend struct component;
268  friend class ::OverlapChecker;
269  friend class ShallowCloneCandidate;
271 
272  };
273 
274 }
275 
276 #endif
double mt() const final
transverse mass
bool isElectron() const override
double rapidity() const
repidity
value_type const * get() const
Definition: RefToBase.h:234
int pdgId() const final
PDG identifier.
int threeCharge() const final
electric charge
Definition: LeafCandidate.h:95
bool isMuon() const override
double px() const
x coordinate of momentum vector
double mtSqr() const final
transverse mass squared
double eta() const final
momentum pseudorapidity
const PolarLorentzVector & polarP4() const final
four-momentum Lorentz vector
LeafCandidate(LeafCandidate &rh)
Definition: LeafCandidate.h:43
LeafCandidate * clone() const override
returns a clone of the Candidate object
int pdgId() const
PDG identifier.
void setMass(double m) final
set particle mass
size_t size_type
Definition: Candidate.h:30
double theta() const final
momentum polar angle
double vy() const override
y coordinate of vertex position
bool isTrackerMuon() const override
double theta() const
momentum polar angle
size_type numberOf() const
number of components
const CandidatePtr & masterClonePtr() const override
size_type numberOf() const
number of components
Vector boostToCM() const final
CandidatePtr sourceCandidatePtr(size_type i) const override
Definition: LeafCandidate.h:86
double pz() const
z coordinate of momentum vector
int threeCharge() const
electric charge
Definition: ParticleState.h:76
bool massConstraint() const final
do mass constraint?
double rapidity() const final
rapidity
double px() const final
x coordinate of momentum vector
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
double vertexNdof() const override
double pt() const final
transverse momentum
const Candidate * mother(size_type) const override
return mother at a given position (throws an exception)
int charge() const final
electric charge
Definition: LeafCandidate.h:91
double y() const final
rapidity
void setMassConstraint()
set mass constraint flag
double energy() const
energy
Definition: ParticleState.h:91
void setPdgId(int pdgId)
void setPz(double pz)
bool isJet() const override
bool isStandAloneMuon() const override
ParticleState m_state
void setVertex(const Point &vertex) override
set vertex
double phi() const
momentum azimuthal angle
bool isCaloMuon() const override
bool massConstraint() const
do mass constraint?
const LorentzVector & p4() const
four-momentum Lorentz vector
Definition: ParticleState.h:80
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
void setCharge(Charge q) final
set electric charge
Definition: LeafCandidate.h:93
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
double vertexNormalizedChi2() const override
chi-squared divided by n.d.o.f.
Vector momentum() const final
spatial momentum vector
double pt() const
transverse momentum
void setP4(const PolarLorentzVector &p4) final
set 4-momentum
void setStatus(int status)
set status word
double mt() const
transverse mass
bool hasMasterClonePtr() const override
double mass() const
mass
Definition: ParticleState.h:97
CovarianceMatrix vertexCovariance() const final
return SMatrix
void setLongLived() final
double et() const final
transverse energy
bool longLived() const
is long lived?
double pz() const final
z coordinate of momentum vector
bool isConvertedPhoton() const override
Ref masterRef() const
cast master clone reference to a concrete type
LeafCandidate(const Candidate &c)
Definition: LeafCandidate.h:36
void setVertex(const Point &vertex)
set vertex
const Point & vertex() const override
vertex position (overwritten by PF...)
double mtSqr() const
transverse mass squared
void setMassConstraint() final
double energy() const final
energy
size_t numberOfSourceCandidatePtrs() const override
Definition: LeafCandidate.h:83
const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
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
bool longLived() const final
is long lived?
size_t numberOfDaughters() const override
number of daughters
size_t numberOfMothers() const override
number of mothers
void setLongLived()
set long lived flag
const PolarLorentzVector & polarP4() const
four-momentum Lorentz vector
Definition: ParticleState.h:82
double vz() const override
z coordinate of vertex position
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float >, ROOT::Math::GlobalCoordinateSystemTag > GlobalVector
vector in glovbal coordinate system
Definition: Vector3D.h:27
double p() const final
magnitude of momentum vector
const Candidate * daughter(size_type) const override
return daughter at a given position (throws an exception)
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
const CandidateBaseRef & masterClone() const override
Definition: LeafCandidate.cc:7
double vz() const
z coordinate of vertex position
int charge() const
electric charge
Definition: ParticleState.h:72
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
void setThreeCharge(Charge qx3) final
set electric charge
Definition: LeafCandidate.h:97
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
int status() const
status word
const Point & vertex() const
vertex position
double py() const final
y coordinate of momentum vector
double massSqr() const final
mass squared
void fillVertexCovariance(CovarianceMatrix &v) const override
fill SMatrix
~LeafCandidate() override
destructor
Definition: LeafCandidate.cc:5
bool isPhoton() const override
fixed size matrix
double vertexChi2() const override
chi-squares
Vector momentum() const
spatial momentum vector
Definition: ParticleState.h:84
bool hasMasterClone() const override
math::XYZVector Vector
point in the space
Definition: LeafCandidate.h:29
int status() const final
status word
void construct(int qx3, float pt, float eta, float phi, float mass, const Point &vtx, int pdgId, int status)
Definition: LeafCandidate.h:61
bool overlap(const Candidate &) const override
check overlap with another Candidate
double eta() const
momentum pseudorapidity
double et2() const final
transverse energy squared (use this for cut!)
void setP4(const LorentzVector &p4)
set 4-momentum
void setStatus(int status) final
set status word
LeafCandidate & operator=(LeafCandidate &&)=default
long double T
void setPz(double pz) final
double phi() const final
momentum azimuthal angle
void setPdgId(int pdgId) final
bool isGlobalMuon() const override
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
void setP4(const LorentzVector &p4) final
set 4-momentum
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
double vx() const override
x coordinate of vertex position
double mass() const final
mass
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