CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
LeafCandidate.h
Go to the documentation of this file.
1 #ifndef Candidate_LeafCandidate_h
2 #define Candidate_LeafCandidate_h
3 
12 
14 
16 
17 namespace reco {
18 
19  class LeafCandidate : public Candidate {
20  public:
24  typedef int Charge;
33 
34  typedef unsigned int index;
35 
38  qx3_(0), pt_(0), eta_(0), phi_(0), mass_(0),
39  vertex_(0, 0, 0), pdgId_(0), status_(0),
41  // constructor from candidate
42  explicit LeafCandidate( const Candidate & c) :
43  qx3_( c.charge()*3 ), pt_( c.p4().pt() ), eta_( c.p4().eta() ), phi_( c.p4().phi() )
44  , mass_( c.p4().mass() ),
45  vertex_( c.vertex() ), pdgId_( c.pdgId() ), status_( c.status() ),
47 
49  template<typename P4>
50  LeafCandidate( Charge q, const P4 & p4, const Point & vtx = Point( 0, 0, 0 ),
51  int pdgId = 0, int status = 0, bool integerCharge = true ) :
52  qx3_(integerCharge ? 3*q : q ), pt_( p4.pt() ), eta_( p4.eta() ), phi_( p4.phi() ), mass_( p4.mass() ),
53  vertex_( vtx ), pdgId_( pdgId ), status_( status ),
55 
56 
58  LeafCandidate( Charge q, const PtEtaPhiMass & p4, const Point & vtx = Point( 0, 0, 0 ),
59  int pdgId = 0, int status = 0, bool integerCharge = true ) :
60  qx3_(integerCharge ? 3*q : q ), pt_( p4.pt() ), eta_( p4.eta() ), phi_( p4.phi() ), mass_( p4.mass() ),
61  vertex_( vtx ), pdgId_( pdgId ), status_( status ),
63 
65  LeafCandidate( Charge q, const LorentzVector & p4, const Point & vtx = Point( 0, 0, 0 ),
66  int pdgId = 0, int status = 0, bool integerCharge = true ) :
67  qx3_( q ), pt_( p4.pt() ), eta_( p4.eta() ), phi_( p4.phi() ), mass_( p4.mass() ),
68  vertex_( vtx ), pdgId_( pdgId ), status_( status ),
70  if ( integerCharge ) qx3_ *= 3;
71  }
73  LeafCandidate( Charge q, const PolarLorentzVector & p4, const Point & vtx = Point( 0, 0, 0 ),
74  int pdgId = 0, int status = 0, bool integerCharge = true ) :
75  qx3_( q ), pt_( p4.pt() ), eta_( p4.eta() ), phi_( p4.phi() ), mass_( p4.mass() ),
76  vertex_( vtx ), pdgId_( pdgId ), status_( status ),
78  if ( integerCharge ) qx3_ *= 3;
79  }
80 
82  virtual ~LeafCandidate();
84  virtual const_iterator begin() const;
86  virtual const_iterator end() const;
88  virtual iterator begin();
90  virtual iterator end();
92  virtual size_t numberOfDaughters() const;
94  virtual const Candidate * daughter( size_type ) const;
96  virtual size_t numberOfMothers() const;
98  virtual const Candidate * mother( size_type ) const;
100  virtual Candidate * daughter( size_type );
102  virtual Candidate * daughter(const std::string& s );
104  virtual const Candidate * daughter(const std::string& s ) const;
107  virtual size_t numberOfSourceCandidatePtrs() const { return 0;}
111  return CandidatePtr();
112  }
113 
115  virtual int charge() const GCC11_FINAL { return qx3_ / 3; }
117  virtual void setCharge( Charge q ) GCC11_FINAL { qx3_ = q * 3; }
119  virtual int threeCharge() const GCC11_FINAL { return qx3_; }
121  virtual void setThreeCharge( Charge qx3 ) GCC11_FINAL { qx3_ = qx3; }
123  virtual const LorentzVector & p4() const GCC11_FINAL { cacheCartesian(); return p4Cartesian_; }
127  virtual Vector momentum() const GCC11_FINAL { cacheCartesian(); return p4Cartesian_.Vect(); }
130  virtual Vector boostToCM() const GCC11_FINAL { cacheCartesian(); return p4Cartesian_.BoostToCM(); }
132  virtual double p() const GCC11_FINAL { cacheCartesian(); return p4Cartesian_.P(); }
134  virtual double energy() const GCC11_FINAL { cacheCartesian(); return p4Cartesian_.E(); }
136  virtual double et() const GCC11_FINAL { cachePolar(); return p4Polar_.Et(); }
138  virtual float mass() const GCC11_FINAL { return mass_; }
140  virtual float massSqr() const GCC11_FINAL { return mass_ * mass_; }
141 
143  virtual double mt() const GCC11_FINAL { cachePolar(); return p4Polar_.Mt(); }
145  virtual double mtSqr() const GCC11_FINAL { cachePolar(); return p4Polar_.Mt2(); }
147  virtual double px() const GCC11_FINAL { cacheCartesian(); return p4Cartesian_.Px(); }
149  virtual double py() const GCC11_FINAL { cacheCartesian(); return p4Cartesian_.Py(); }
151  virtual double pz() const GCC11_FINAL { cacheCartesian(); return p4Cartesian_.Pz(); }
153  virtual float pt() const GCC11_FINAL { return pt_;}
155  virtual float phi() const GCC11_FINAL { return phi_; }
157  virtual double theta() const GCC11_FINAL { cacheCartesian(); return p4Cartesian_.Theta(); }
159  virtual float eta() const GCC11_FINAL { return eta_; }
161  virtual double rapidity() const GCC11_FINAL { cachePolar(); return p4Polar_.Rapidity(); }
163  virtual double y() const GCC11_FINAL { return rapidity(); }
165  virtual void setP4( const LorentzVector & p4 ) GCC11_FINAL {
166  p4Cartesian_ = p4;
167  p4Polar_ = p4;
168  pt_ = p4Polar_.pt();
169  eta_ = p4Polar_.eta();
170  phi_ = p4Polar_.phi();
171  mass_ = p4Polar_.mass();
172  cachePolarFixed_ = true;
173  cacheCartesianFixed_ = true;
174  }
176  virtual void setP4( const PolarLorentzVector & p4 ) GCC11_FINAL {
177  p4Polar_ = p4;
178  pt_ = p4Polar_.pt();
179  eta_ = p4Polar_.eta();
180  phi_ = p4Polar_.phi();
181  mass_ = p4Polar_.mass();
182  cachePolarFixed_ = true;
183  cacheCartesianFixed_ = false;
184  }
186  virtual void setMass( double m ) GCC11_FINAL {
187  mass_ = m;
188  clearCache();
189  }
190  virtual void setPz( double pz ) GCC11_FINAL {
191  cacheCartesian();
192  p4Cartesian_.SetPz(pz);
194  pt_ = p4Polar_.pt();
195  eta_ = p4Polar_.eta();
196  phi_ = p4Polar_.phi();
197  mass_ = p4Polar_.mass();
198  }
200  virtual const Point & vertex() const { return vertex_; }
202  virtual double vx() const { return vertex_.X(); }
204  virtual double vy() const { return vertex_.Y(); }
206  virtual double vz() const { return vertex_.Z(); }
208  virtual void setVertex( const Point & vertex ) { vertex_ = vertex; }
209 
211  virtual int pdgId() const GCC11_FINAL { return pdgId_; }
212  // set PDG identifier
213  virtual void setPdgId( int pdgId ) GCC11_FINAL { pdgId_ = pdgId; }
215  virtual int status() const GCC11_FINAL { return status_; }
217  virtual void setStatus( int status ) GCC11_FINAL { status_ = status; }
219  static const unsigned int longLivedTag;
223  virtual bool longLived() const GCC11_FINAL { return status_ & longLivedTag; }
225  static const unsigned int massConstraintTag;
230 
232  virtual LeafCandidate * clone() const {
233  return new LeafCandidate( *this );
234  }
235 
237  virtual double vertexChi2() const;
244  virtual double vertexNdof() const;
246  virtual double vertexNormalizedChi2() const;
248  virtual double vertexCovariance(int i, int j) const;
252  virtual void fillVertexCovariance(CovarianceMatrix & v) const;
255  virtual bool hasMasterClone() const;
258  virtual const CandidateBaseRef & masterClone() const;
261  virtual bool hasMasterClonePtr() const;
264  virtual const CandidatePtr & masterClonePtr() const;
265 
267  template<typename Ref>
268  Ref masterRef() const { return masterClone().template castTo<Ref>(); }
270 
271  template<typename T> T get() const {
272  if ( hasMasterClone() ) return masterClone()->get<T>();
273  else return reco::get<T>( * this );
274  }
276  template<typename T, typename Tag> T get() const {
277  if ( hasMasterClone() ) return masterClone()->get<T, Tag>();
278  else return reco::get<T, Tag>( * this );
279  }
281  template<typename T> T get( size_type i ) const {
282  if ( hasMasterClone() ) return masterClone()->get<T>( i );
283  else return reco::get<T>( * this, i );
284  }
286  template<typename T, typename Tag> T get( size_type i ) const {
287  if ( hasMasterClone() ) return masterClone()->get<T, Tag>( i );
288  else return reco::get<T, Tag>( * this, i );
289  }
291  template<typename T> size_type numberOf() const {
292  if ( hasMasterClone() ) return masterClone()->numberOf<T>();
293  else return reco::numberOf<T>( * this );
294  }
296  template<typename T, typename Tag> size_type numberOf() const {
297  if ( hasMasterClone() ) return masterClone()->numberOf<T, Tag>();
298  else return reco::numberOf<T, Tag>( * this );
299  }
300 
301  template<typename S>
303  typedef boost::filter_iterator<S, const_iterator> type;
304  };
305 
306  template<typename S>
307  typename daughter_iterator<S>::type beginFilter( const S & s ) const {
308  return boost::make_filter_iterator(s, begin(), end());
309  }
310  template<typename S>
311  typename daughter_iterator<S>::type endFilter( const S & s ) const {
312  return boost::make_filter_iterator(s, end(), end());
313  }
314 
315 
316  virtual bool isElectron() const;
317  virtual bool isMuon() const;
318  virtual bool isStandAloneMuon() const;
319  virtual bool isGlobalMuon() const;
320  virtual bool isTrackerMuon() const;
321  virtual bool isCaloMuon() const;
322  virtual bool isPhoton() const;
323  virtual bool isConvertedPhoton() const;
324  virtual bool isJet() const;
325 
326  protected:
330  float pt_, eta_, phi_, mass_;
334  int pdgId_;
336  int status_;
344  inline void cachePolar() const {
345  if ( cachePolarFixed_ ) return;
347  cachePolarFixed_ = true;
348  }
350  inline void cacheCartesian() const {
351  if ( cacheCartesianFixed_ ) return;
352  cachePolar();
354  cacheCartesianFixed_ = true;
355  }
357  inline void clearCache() const {
358  cachePolarFixed_ = false;
359  cacheCartesianFixed_ = false;
360  }
362  virtual bool overlap( const Candidate & ) const;
363  template<typename, typename, typename> friend struct component;
364  friend class ::OverlapChecker;
365  friend class ShallowCloneCandidate;
367 
368  private:
369  // const iterator implementation
371  // iterator implementation
373  };
374 
375 }
376 
377 #endif
virtual void setLongLived() GCC11_FINAL
set long lived flag
virtual double energy() const GCC11_FINAL
energy
int Charge
electric charge type
Definition: Candidate.h:39
virtual double et() const GCC11_FINAL
transverse energy
int i
Definition: DBlmapReader.cc:9
static const unsigned int longLivedTag
long lived flag
virtual void setCharge(Charge q) GCC11_FINAL
set electric charge
LorentzVector p4Cartesian_
internal cache for p4
virtual bool longLived() const GCC11_FINAL
is long lived?
void clearCache() const
clear internal cache
daughter_iterator< S >::type endFilter(const S &s) const
math::XYZVector Vector
point in the space
Definition: Candidate.h:47
size_t size_type
Definition: Candidate.h:34
virtual double p() const GCC11_FINAL
magnitude of momentum vector
virtual const LorentzVector & p4() const GCC11_FINAL
four-momentum Lorentz vector
candidate::const_iterator const_iterator
Definition: Candidate.h:35
size_type numberOf() const
number of components
virtual double vertexChi2() const
chi-squares
int pdgId_
PDG identifier.
virtual const Point & vertex() const
vertex position (overwritten by PF...)
size_type numberOf() const
number of components
virtual int pdgId() const GCC11_FINAL
PDG identifier.
virtual bool isConvertedPhoton() const
candidate::const_iterator_imp_specific< daughters > const_iterator_imp_specific
daughter_iterator< S >::type beginFilter(const S &s) const
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: LeafCandidate.h:28
CandidateCollection daughters
collection of daughter candidates
Definition: LeafCandidate.h:22
float pt_
four-momentum Lorentz vector
virtual bool isPhoton() const
virtual bool isStandAloneMuon() const
PolarLorentzVector p4Polar_
internal cache for p4
void cachePolar() const
set internal cache
virtual double theta() const GCC11_FINAL
momentum polar angle
virtual void setMass(double m) GCC11_FINAL
set particle mass
candidate::iterator_imp_specific< daughters > iterator_imp_specific
Point vertex_
vertex position
virtual double vy() const
y coordinate of vertex position
virtual double pz() const GCC11_FINAL
z coordinate of momentum vector
virtual double py() const GCC11_FINAL
y coordinate of momentum vector
virtual bool isMuon() const
static const unsigned int massConstraintTag
do mass constraint flag
virtual size_t numberOfDaughters() const
number of daughters
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:26
virtual bool massConstraint() const GCC11_FINAL
do mass constraint?
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
virtual bool isGlobalMuon() const
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
virtual const CandidatePtr & masterClonePtr() const
virtual const Candidate * daughter(size_type) const
return daughter at a given position (throws an exception)
virtual double rapidity() const GCC11_FINAL
rapidity
virtual ~LeafCandidate()
destructor
Definition: LeafCandidate.cc:6
virtual void setStatus(int status) GCC11_FINAL
set status word
virtual int status() const GCC11_FINAL
status word
virtual bool hasMasterClone() const
Ref masterRef() const
cast master clone reference to a concrete type
LeafCandidate(const Candidate &c)
Definition: LeafCandidate.h:42
virtual void setMassConstraint() GCC11_FINAL
set mass constraint flag
int status_
status word
virtual CandidatePtr sourceCandidatePtr(size_type i) const
virtual double px() const GCC11_FINAL
x coordinate of momentum vector
int j
Definition: DBlmapReader.cc:9
virtual double vertexNormalizedChi2() const
chi-squared divided by n.d.o.f.
LeafCandidate(Charge q, const PolarLorentzVector &p4, const Point &vtx=Point(0, 0, 0), int pdgId=0, int status=0, bool integerCharge=true)
constructor from values
Definition: LeafCandidate.h:73
virtual double mt() const GCC11_FINAL
transverse mass
LeafCandidate(Charge q, const PtEtaPhiMass &p4, const Point &vtx=Point(0, 0, 0), int pdgId=0, int status=0, bool integerCharge=true)
constructor from values
Definition: LeafCandidate.h:58
unsigned int index
Definition: LeafCandidate.h:34
virtual bool overlap(const Candidate &) const
check overlap with another Candidate
virtual double vz() const
z coordinate of vertex position
virtual Vector boostToCM() const GCC11_FINAL
virtual bool hasMasterClonePtr() const
virtual const_iterator begin() const
first daughter const_iterator
Definition: LeafCandidate.cc:8
virtual void setVertex(const Point &vertex)
set vertex
virtual bool isElectron() const
virtual double y() const GCC11_FINAL
rapidity
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
virtual bool isCaloMuon() const
virtual void setThreeCharge(Charge qx3) GCC11_FINAL
set electric charge
virtual float mass() const GCC11_FINAL
mass
candidate::iterator iterator
Definition: Candidate.h:36
LeafCandidate(Charge q, const LorentzVector &p4, const Point &vtx=Point(0, 0, 0), int pdgId=0, int status=0, bool integerCharge=true)
constructor from values
Definition: LeafCandidate.h:65
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
Definition: CandidateFwd.h:25
virtual size_t numberOfSourceCandidatePtrs() const
virtual bool isTrackerMuon() const
virtual const PolarLorentzVector & polarP4() const GCC11_FINAL
four-momentum Lorentz vector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
virtual int charge() const GCC11_FINAL
electric charge
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
void cacheCartesian() const
set internal cache
CovarianceMatrix vertexCovariance() const GCC11_FINAL
return SMatrix
virtual Vector momentum() const GCC11_FINAL
spatial momentum vector
virtual void setP4(const PolarLorentzVector &p4) GCC11_FINAL
set 4-momentum
string const
Definition: compareJSON.py:14
virtual bool isJet() const
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:41
LeafCandidate()
default constructor
Definition: LeafCandidate.h:37
virtual double mtSqr() const GCC11_FINAL
transverse mass squared
LeafCandidate(Charge q, const P4 &p4, const Point &vtx=Point(0, 0, 0), int pdgId=0, int status=0, bool integerCharge=true)
constructor from Any values
Definition: LeafCandidate.h:50
virtual float massSqr() const GCC11_FINAL
mass squared
virtual size_t numberOfMothers() const
number of mothers
virtual const CandidateBaseRef & masterClone() const
virtual void setP4(const LorentzVector &p4) GCC11_FINAL
set 4-momentum
math::XYZVector Vector
point in the space
Definition: LeafCandidate.h:32
virtual int threeCharge() const GCC11_FINAL
electric charge
virtual double vx() const
x coordinate of vertex position
math::XYZPoint Point
point in the space
Definition: Candidate.h:45
bool cachePolarFixed_
has cache been set?
virtual LeafCandidate * clone() const
returns a clone of the Candidate object
virtual void setPz(double pz) GCC11_FINAL
virtual float pt() const GCC11_FINAL
transverse momentum
virtual void setPdgId(int pdgId) GCC11_FINAL
long double T
value_type const * get() const
Definition: RefToBase.h:212
virtual const_iterator end() const
last daughter const_iterator
virtual void fillVertexCovariance(CovarianceMatrix &v) const
fill SMatrix
virtual double vertexNdof() const
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: LeafCandidate.h:26
int Charge
electric charge type
Definition: LeafCandidate.h:24
Charge qx3_
electric charge
virtual const Candidate * mother(size_type) const
return mother at a given position (throws an exception)
boost::filter_iterator< S, const_iterator > type
math::XYZPoint Point
point in the space
Definition: LeafCandidate.h:30
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:43