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 
13 
15 
16 namespace reco {
17 
18  class LeafCandidate : public Candidate {
19  public:
23  typedef int Charge;
32 
33  typedef unsigned int index;
34 
37  qx3_(0), pt_(0), eta_(0), phi_(0), mass_(0),
38  vertex_(0, 0, 0), pdgId_(0), status_(0),
40  // constructor from candidate
41  explicit LeafCandidate( const Candidate & c) :
42  qx3_( c.charge()*3 ), pt_( c.p4().pt() ), eta_( c.p4().eta() ), phi_( c.p4().phi() )\
43  , mass_( c.p4().mass() ),
44  vertex_( c.vertex() ), pdgId_( c.pdgId() ), status_( c.status() ),
46 
48  LeafCandidate( Charge q, const LorentzVector & p4, const Point & vtx = Point( 0, \
49  0, 0 ),
50  int pdgId = 0, int status = 0, bool integerCharge = true ) :
51  qx3_( q ), pt_( p4.pt() ), eta_( p4.eta() ), phi_( p4.phi() ), mass_( p4.mass() ),
52  vertex_( vtx ), pdgId_( pdgId ), status_( status ),
54  if ( integerCharge ) qx3_ *= 3;
55  }
57  LeafCandidate( Charge q, const PolarLorentzVector & p4, const Point & vtx = Point\
58  ( 0, 0, 0 ),
59  int pdgId = 0, int status = 0, bool integerCharge = true ) :
60  qx3_( q ), pt_( p4.pt() ), eta_( p4.eta() ), phi_( p4.phi() ), mass_( p4.mass() ),
61  vertex_( vtx ), pdgId_( pdgId ), status_( status ),
63  if ( integerCharge ) qx3_ *= 3;
64  }
65 
67  virtual ~LeafCandidate();
69  virtual const_iterator begin() const;
71  virtual const_iterator end() const;
73  virtual iterator begin();
75  virtual iterator end();
77  virtual size_t numberOfDaughters() const;
79  virtual const Candidate * daughter( size_type ) const;
81  virtual size_t numberOfMothers() const;
83  virtual const Candidate * mother( size_type ) const;
85  virtual Candidate * daughter( size_type );
87  virtual Candidate * daughter(const std::string& s );
89  virtual const Candidate * daughter(const std::string& s ) const;
92  virtual size_t numberOfSourceCandidatePtrs() const { return 0;}
96  return CandidatePtr();
97  }
98 
100  virtual int charge() const { return qx3_ / 3; }
102  virtual void setCharge( Charge q ) { qx3_ = q * 3; }
104  virtual int threeCharge() const { return qx3_; }
106  virtual void setThreeCharge( Charge qx3 ) { qx3_ = qx3; }
108  virtual const LorentzVector & p4() const { cacheCartesian(); return p4Cartesian_; }
110  virtual const PolarLorentzVector & polarP4() const { cachePolar(); return p4Polar_; }
112  virtual Vector momentum() const { cacheCartesian(); return p4Cartesian_.Vect(); }
115  virtual Vector boostToCM() const { cacheCartesian(); return p4Cartesian_.BoostToCM(); }
117  virtual double p() const { cacheCartesian(); return p4Cartesian_.P(); }
119  virtual double energy() const { cacheCartesian(); return p4Cartesian_.E(); }
121  virtual double et() const { cachePolar(); return p4Polar_.Et(); }
123  virtual double mass() const { return mass_; }
125  virtual double massSqr() const { return mass_ * mass_; }
127  virtual double mt() const { cachePolar(); return p4Polar_.Mt(); }
129  virtual double mtSqr() const { cachePolar(); return p4Polar_.Mt2(); }
131  virtual double px() const { cacheCartesian(); return p4Cartesian_.Px(); }
133  virtual double py() const { cacheCartesian(); return p4Cartesian_.Py(); }
135  virtual double pz() const { cacheCartesian(); return p4Cartesian_.Pz(); }
137  virtual double pt() const;
139  virtual double phi() const { return phi_; }
141  virtual double theta() const { cacheCartesian(); return p4Cartesian_.Theta(); }
143  virtual double eta() const { return eta_; }
145  virtual double rapidity() const { cachePolar(); return p4Polar_.Rapidity(); }
147  virtual double y() const { return rapidity(); }
149  virtual void setP4( const LorentzVector & p4 ) {
150  p4Cartesian_ = p4;
151  p4Polar_ = p4;
152  pt_ = p4Polar_.pt();
153  eta_ = p4Polar_.eta();
154  phi_ = p4Polar_.phi();
155  mass_ = p4Polar_.mass();
156  cachePolarFixed_ = true;
157  cacheCartesianFixed_ = true;
158  }
160  virtual void setP4( const PolarLorentzVector & p4 ) {
161  p4Polar_ = p4;
162  pt_ = p4Polar_.pt();
163  eta_ = p4Polar_.eta();
164  phi_ = p4Polar_.phi();
165  mass_ = p4Polar_.mass();
166  cachePolarFixed_ = true;
167  cacheCartesianFixed_ = false;
168  }
170  virtual void setMass( double m ) {
171  mass_ = m;
172  clearCache();
173  }
174  virtual void setPz( double pz ) {
175  cacheCartesian();
176  p4Cartesian_.SetPz(pz);
178  pt_ = p4Polar_.pt();
179  eta_ = p4Polar_.eta();
180  phi_ = p4Polar_.phi();
181  mass_ = p4Polar_.mass();
182  }
184  virtual const Point & vertex() const { return vertex_; }
186  virtual double vx() const { return vertex_.X(); }
188  virtual double vy() const { return vertex_.Y(); }
190  virtual double vz() const { return vertex_.Z(); }
192  virtual void setVertex( const Point & vertex ) { vertex_ = vertex; }
194  virtual int pdgId() const { return pdgId_; }
195  // set PDG identifier
196  virtual void setPdgId( int pdgId ) { pdgId_ = pdgId; }
198  virtual int status() const { return status_; }
200  virtual void setStatus( int status ) { status_ = status; }
202  static const unsigned int longLivedTag;
204  virtual void setLongLived() { status_ |= longLivedTag; }
206  virtual bool longLived() const { return status_ & longLivedTag; }
208  static const unsigned int massConstraintTag;
212  virtual bool massConstraint() const { return status_ & massConstraintTag; }
214  virtual LeafCandidate * clone() const {
215  return new LeafCandidate( *this );
216  }
217 
219  virtual double vertexChi2() const;
226  virtual double vertexNdof() const;
228  virtual double vertexNormalizedChi2() const;
230  virtual double vertexCovariance(int i, int j) const;
234  virtual void fillVertexCovariance(CovarianceMatrix & v) const;
237  virtual bool hasMasterClone() const;
240  virtual const CandidateBaseRef & masterClone() const;
243  virtual bool hasMasterClonePtr() const;
246  virtual const CandidatePtr & masterClonePtr() const;
247 
249  template<typename Ref>
250  Ref masterRef() const { return masterClone().template castTo<Ref>(); }
252 
253  template<typename T> T get() const {
254  if ( hasMasterClone() ) return masterClone()->get<T>();
255  else return reco::get<T>( * this );
256  }
258  template<typename T, typename Tag> T get() const {
259  if ( hasMasterClone() ) return masterClone()->get<T, Tag>();
260  else return reco::get<T, Tag>( * this );
261  }
263  template<typename T> T get( size_type i ) const {
264  if ( hasMasterClone() ) return masterClone()->get<T>( i );
265  else return reco::get<T>( * this, i );
266  }
268  template<typename T, typename Tag> T get( size_type i ) const {
269  if ( hasMasterClone() ) return masterClone()->get<T, Tag>( i );
270  else return reco::get<T, Tag>( * this, i );
271  }
273  template<typename T> size_type numberOf() const {
274  if ( hasMasterClone() ) return masterClone()->numberOf<T>();
275  else return reco::numberOf<T>( * this );
276  }
278  template<typename T, typename Tag> size_type numberOf() const {
279  if ( hasMasterClone() ) return masterClone()->numberOf<T, Tag>();
280  else return reco::numberOf<T, Tag>( * this );
281  }
282 
283  template<typename S>
285  typedef boost::filter_iterator<S, const_iterator> type;
286  };
287 
288  template<typename S>
289  typename daughter_iterator<S>::type beginFilter( const S & s ) const {
290  return boost::make_filter_iterator(s, begin(), end());
291  }
292  template<typename S>
293  typename daughter_iterator<S>::type endFilter( const S & s ) const {
294  return boost::make_filter_iterator(s, end(), end());
295  }
296 
297 
298  virtual bool isElectron() const;
299  virtual bool isMuon() const;
300  virtual bool isStandAloneMuon() const;
301  virtual bool isGlobalMuon() const;
302  virtual bool isTrackerMuon() const;
303  virtual bool isCaloMuon() const;
304  virtual bool isPhoton() const;
305  virtual bool isConvertedPhoton() const;
306  virtual bool isJet() const;
307 
308  protected:
312  float pt_, eta_, phi_, mass_;
316  int pdgId_;
318  int status_;
326  inline void cachePolar() const {
327  if ( cachePolarFixed_ ) return;
329  cachePolarFixed_ = true;
330  }
332  inline void cacheCartesian() const {
333  if ( cacheCartesianFixed_ ) return;
334  cachePolar();
336  cacheCartesianFixed_ = true;
337  }
339  inline void clearCache() const {
340  cachePolarFixed_ = false;
341  cacheCartesianFixed_ = false;
342  }
344  virtual bool overlap( const Candidate & ) const;
345  template<typename, typename, typename> friend struct component;
346  friend class ::OverlapChecker;
347  friend class ShallowCloneCandidate;
349 
350  private:
351  // const iterator implementation
353  // iterator implementation
355  };
356 
357 }
358 
359 #endif
int Charge
electric charge type
Definition: Candidate.h:37
int i
Definition: DBlmapReader.cc:9
virtual int pdgId() const
PDG identifier.
virtual double p() const
magnitude of momentum vector
static const unsigned int longLivedTag
long lived flag
virtual void setMassConstraint()
set mass constraint flag
LorentzVector p4Cartesian_
internal cache for p4
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:45
size_t size_type
Definition: Candidate.h:32
virtual double et() const
transverse energy
candidate::const_iterator const_iterator
Definition: Candidate.h:33
virtual void setCharge(Charge q)
set electric charge
size_type numberOf() const
number of components
virtual double vertexChi2() const
chi-squares
int pdgId_
PDG identifier.
virtual void setStatus(int status)
set status word
virtual const Point & vertex() const
vertex position
size_type numberOf() const
number of components
virtual double massSqr() const
mass squared
virtual int status() const
status word
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:27
CandidateCollection daughters
collection of daughter candidates
Definition: LeafCandidate.h:21
float pt_
four-momentum Lorentz vector
virtual Vector momentum() const
spatial momentum vector
virtual bool isPhoton() const
virtual double y() const
rapidity
virtual bool isStandAloneMuon() const
virtual void setP4(const LorentzVector &p4)
set 4-momentum
PolarLorentzVector p4Polar_
internal cache for p4
void cachePolar() const
set internal cache
candidate::iterator_imp_specific< daughters > iterator_imp_specific
Point vertex_
vertex position
virtual double vy() const
y coordinate of vertex position
virtual double eta() const
momentum pseudorapidity
virtual bool longLived() const
is long lived?
virtual bool isMuon() const
virtual void setP4(const PolarLorentzVector &p4)
set 4-momentum
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
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
virtual bool isGlobalMuon() const
edm::BoolCache cachePolarFixed_
has cache been set?
virtual double mass() const
mass
virtual double energy() const
energy
virtual const CandidatePtr & masterClonePtr() const
virtual const Candidate * daughter(size_type) const
return daughter at a given position (throws an exception)
CovarianceMatrix vertexCovariance() const
return SMatrix
virtual ~LeafCandidate()
destructor
Definition: LeafCandidate.cc:6
virtual void setThreeCharge(Charge qx3)
set electric charge
virtual bool hasMasterClone() const
Ref masterRef() const
cast master clone reference to a concrete type
LeafCandidate(const Candidate &c)
Definition: LeafCandidate.h:41
int status_
status word
virtual int charge() const
electric charge
virtual CandidatePtr sourceCandidatePtr(size_type i) const
Definition: LeafCandidate.h:95
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:57
virtual int threeCharge() const
electric charge
unsigned int index
Definition: LeafCandidate.h:33
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 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 theta() const
momentum polar angle
boost::filter_iterator< S, const_iterator > type
virtual bool isCaloMuon() const
virtual void setPz(double pz)
candidate::iterator iterator
Definition: Candidate.h:34
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:48
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:92
virtual double px() const
x coordinate of momentum vector
virtual void setLongLived()
set long lived flag
virtual bool isTrackerMuon() const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
virtual double pt() const
transverse momentum
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
virtual double mt() const
transverse mass
void cacheCartesian() const
set internal cache
virtual bool isJet() const
virtual double pz() const
z coordinate of momentum vector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:39
LeafCandidate()
default constructor
Definition: LeafCandidate.h:36
virtual double rapidity() const
rapidity
virtual Vector boostToCM() const
virtual const PolarLorentzVector & polarP4() const
four-momentum Lorentz vector
virtual size_t numberOfMothers() const
number of mothers
virtual const CandidateBaseRef & masterClone() const
virtual void setPdgId(int pdgId)
math::XYZVector Vector
point in the space
Definition: LeafCandidate.h:31
virtual double mtSqr() const
transverse mass squared
virtual double vx() const
x coordinate of vertex position
math::XYZPoint Point
point in the space
Definition: Candidate.h:43
edm::BoolCache cacheCartesianFixed_
string s
Definition: asciidump.py:422
virtual LeafCandidate * clone() const
returns a clone of the Candidate object
virtual void setMass(double m)
set particle mass
long double T
virtual double phi() const
momentum azimuthal angle
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
virtual bool massConstraint() const
do mass constraint?
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
mathSSE::Vec4< T > v
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: LeafCandidate.h:25
virtual double py() const
y coordinate of momentum vector
int Charge
electric charge type
Definition: LeafCandidate.h:23
Charge qx3_
electric charge
virtual const Candidate * mother(size_type) const
return mother at a given position (throws an exception)
math::XYZPoint Point
point in the space
Definition: LeafCandidate.h:29
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:41