CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
LeafRefCandidateT.h
Go to the documentation of this file.
1 #ifndef Candidate_LeafRefCandidateT_h
2 #define Candidate_LeafRefCandidateT_h
3 
14 
16 
17 namespace reco {
18 
19  template < class T >
20  class LeafRefCandidateT : public Candidate {
21  public:
25  typedef int Charge;
34 
35  typedef unsigned int index;
36 
39  mass_(0),
40  cachePolarFixed_( false ) { }
41  // constructor from T
42  explicit LeafRefCandidateT( const T & c, float m) :
43  ref_(c),
44  mass_( m ),
46 
48  virtual ~LeafRefCandidateT() {}
50  virtual const_iterator begin() const;
52  virtual const_iterator end() const;
54  virtual iterator begin();
56  virtual iterator end();
58  virtual size_t numberOfDaughters() const { return 0; }
60  virtual const Candidate * daughter( size_type ) const { return 0; }
62  virtual size_t numberOfMothers() const { return 0; }
64  virtual const Candidate * mother( size_type ) const { return 0; }
66  virtual Candidate * daughter( size_type ) { return 0; }
68  virtual Candidate * daughter(const std::string& s ) { return 0; }
70  virtual const Candidate * daughter(const std::string& s ) const { return 0; }
73  virtual size_t numberOfSourceCandidatePtrs() const { return 0;}
77  static CandidatePtr dummyPtr;
78  return dummyPtr;
79  }
80 
82  virtual int charge() const { return ref_->charge(); }
84  virtual int pdgId() const { return 0; }
85 
87  virtual const LorentzVector & p4() const { cacheCartesian(); return p4Cartesian_; }
89  virtual const PolarLorentzVector & polarP4() const { cachePolar(); return p4Polar_; }
91  virtual Vector momentum() const { cacheCartesian(); return p4Cartesian_.Vect(); }
94  virtual Vector boostToCM() const { cacheCartesian(); return p4Cartesian_.BoostToCM(); }
96  virtual double p() const { cacheCartesian(); return p4Cartesian_.P(); }
98  virtual double energy() const { cacheCartesian(); return p4Cartesian_.E(); }
100  virtual double et() const { cachePolar(); return p4Polar_.Et(); }
102  virtual double mass() const { return mass_; }
104  virtual double massSqr() const { return mass_ * mass_; }
106  virtual double mt() const { cachePolar(); return p4Polar_.Mt(); }
108  virtual double mtSqr() const { cachePolar(); return p4Polar_.Mt2(); }
110  virtual double px() const { cacheCartesian(); return p4Cartesian_.Px(); }
112  virtual double py() const { cacheCartesian(); return p4Cartesian_.Py(); }
114  virtual double pz() const { cacheCartesian(); return p4Cartesian_.Pz(); }
116  virtual double pt() const { return ref_->pt(); }
118  virtual double phi() const { return ref_->phi(); }
120  virtual double theta() const { return ref_->theta(); }
122  virtual double eta() const { return ref_->eta(); }
124  virtual double rapidity() const { cachePolar(); return p4Polar_.Rapidity(); }
126  virtual double y() const { return rapidity(); }
127 
129  virtual void setMass( double m ) {
130  mass_ = m;
131  clearCache();
132  }
133 
135  virtual const Point & vertex() const { return ref_->vertex(); }
137  virtual double vx() const { return ref_->vx(); }
139  virtual double vy() const { return ref_->vy(); }
141  virtual double vz() const { return ref_->vz(); }
142 
143 
145  virtual LeafRefCandidateT<T> * clone() const {
146  return new LeafRefCandidateT<T>( *this );
147  }
148 
149 
151  virtual bool hasMasterClone() const { return false; }
154  virtual const CandidateBaseRef & masterClone() const {
155  static CandidateBaseRef dummyRef; return dummyRef;
156  }
159  virtual bool hasMasterClonePtr() const { return false; }
162  virtual const CandidatePtr & masterClonePtr() const {
163  static CandidatePtr dummyPtr; return dummyPtr;
164  }
165 
167  template<typename Ref>
168  Ref masterRef() const { Ref dummyRef; return dummyRef; }
170 
171  template<typename C> C get() const {
172  if ( hasMasterClone() ) return masterClone()->get<C>();
173  else return reco::get<C>( * this );
174  }
176  template<typename C, typename Tag> C get() const {
177  if ( hasMasterClone() ) return masterClone()->get<C, Tag>();
178  else return reco::get<C, Tag>( * this );
179  }
181  template<typename C> C get( size_type i ) const {
182  if ( hasMasterClone() ) return masterClone()->get<C>( i );
183  else return reco::get<C>( * this, i );
184  }
186  template<typename C, typename Tag> C get( size_type i ) const {
187  if ( hasMasterClone() ) return masterClone()->get<C, Tag>( i );
188  else return reco::get<C, Tag>( * this, i );
189  }
191  template<typename C> size_type numberOf() const {
192  if ( hasMasterClone() ) return masterClone()->numberOf<C>();
193  else return reco::numberOf<C>( * this );
194  }
196  template<typename C, typename Tag> size_type numberOf() const {
197  if ( hasMasterClone() ) return masterClone()->numberOf<C, Tag>();
198  else return reco::numberOf<C, Tag>( * this );
199  }
200 
201  template<typename S>
203  typedef boost::filter_iterator<S, const_iterator> type;
204  };
205 
206  template<typename S>
207  typename daughter_iterator<S>::type beginFilter( const S & s ) const {
208  return boost::make_filter_iterator(s, begin(), end());
209  }
210  template<typename S>
211  typename daughter_iterator<S>::type endFilter( const S & s ) const {
212  return boost::make_filter_iterator(s, end(), end());
213  }
214 
215 
216  virtual bool isElectron() const { return false; }
217  virtual bool isMuon() const { return false; }
218  virtual bool isStandAloneMuon() const { return false; }
219  virtual bool isGlobalMuon() const { return false; }
220  virtual bool isTrackerMuon() const { return false; }
221  virtual bool isCaloMuon() const { return false; }
222  virtual bool isPhoton() const { return false; }
223  virtual bool isConvertedPhoton() const { return false; }
224  virtual bool isJet() const { return false; }
225 
226  protected:
231  float mass_;
239  inline void cachePolar() const {
240  if ( cachePolarFixed_ ) return;
241  p4Polar_ = PolarLorentzVector( ref_->pt(), ref_->eta(), ref_->phi(), mass_ );
242  cachePolarFixed_ = true;
243  }
245  inline void cacheCartesian() const {
246  if ( cacheCartesianFixed_ ) return;
247  cachePolar();
249  cacheCartesianFixed_ = true;
250  }
252  inline void clearCache() const {
253  cachePolarFixed_ = false;
254  cacheCartesianFixed_ = false;
255  }
257  virtual bool overlap( const Candidate & ) const;
258  virtual bool overlap( const LeafRefCandidateT & ) const;
259  template<typename, typename, typename> friend struct component;
260  friend class ::OverlapChecker;
261  friend class ShallowCloneCandidate;
263 
264  private:
265  // const iterator implementation
267  // iterator implementation
269 
270 
274 
275  virtual void setCharge( Charge q ) { return; }
276  virtual int threeCharge() const { return 0; }
277  virtual void setThreeCharge( Charge qx3 ) { return; }
278  virtual void setP4( const LorentzVector & p4 ) {
279  return;
280  }
281  virtual void setP4( const PolarLorentzVector & p4 ) {
282  return;
283  }
284  virtual void setPz( double pz ) {
285  return;
286  }
287  virtual void setVertex( const Point & vertex ) { return; }
288  virtual void setPdgId( int pdgId ) { return; }
289  virtual int status() const { return 0; }
290  virtual void setStatus( int status ) { return; }
291  static const unsigned int longLivedTag;
292  virtual void setLongLived() { return; }
293  virtual bool longLived() const { return false; }
294  static const unsigned int massConstraintTag;
295  virtual void setMassConstraint() { return;}
296  virtual bool massConstraint() const { return false; }
297  virtual double vertexChi2() const { return 0.; }
298  virtual double vertexNdof() const { return 0.; }
299  virtual double vertexNormalizedChi2() const { return 0.; }
300  virtual double vertexCovariance(int i, int j) const { return 0.; }
302  virtual void fillVertexCovariance(CovarianceMatrix & v) const { return ; }
303 
304  };
305 
306 
307 
308  template<class T>
311  }
312 
313  template<class T>
316  }
317 
318  template<class T>
320  return iterator( new iterator_imp_specific );
321  }
322 
323  template<class T>
325  return iterator( new iterator_imp_specific );
326  }
327 
328 
329  template<class T>
330  bool LeafRefCandidateT<T>::overlap( const Candidate & o ) const {
331  return p4() == o.p4() && vertex() == o.vertex() && charge() == o.charge();
332  }
333 
334 
335  template<class T>
337  return ref_ == o.ref_;
338  }
339 
340 
341 
342 }
343 
344 #endif
virtual Candidate * daughter(size_type)
return daughter at a given position (throws an exception)
virtual bool massConstraint() const
do mass constraint?
virtual const CandidateBaseRef & masterClone() const
virtual double y() const
rapidity
virtual bool isStandAloneMuon() const
int Charge
electric charge type
Definition: Candidate.h:37
int i
Definition: DBlmapReader.cc:9
virtual int status() const
status word
math::XYZPoint Point
point in the space
virtual double massSqr() const
mass squared
CovarianceMatrix vertexCovariance() const
fill SMatrix
math::XYZVector Vector
point in the space
Definition: Candidate.h:45
virtual const Candidate * daughter(const std::string &s) const
return daughter with a specified role name
virtual void setLongLived()
set long lived flag
virtual double p() const
magnitude of momentum vector
size_t size_type
Definition: Candidate.h:32
virtual void setThreeCharge(Charge qx3)
set electric charge
virtual double pz() const
z coordinate of momentum vector
virtual double vertexNormalizedChi2() const
chi-squared divided by n.d.o.f.
candidate::const_iterator const_iterator
Definition: Candidate.h:33
virtual double theta() const
momentum polar angle
virtual bool hasMasterClonePtr() const
virtual void fillVertexCovariance(CovarianceMatrix &v) const
virtual CandidatePtr sourceCandidatePtr(size_type i) const
LorentzVector p4Cartesian_
internal cache for p4
virtual Candidate * daughter(const std::string &s)
return daughter with a specified role name
virtual int charge() const
electric charge
virtual bool isGlobalMuon() const
virtual LeafRefCandidateT< T > * clone() const
returns a clone of the Candidate object
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
virtual const PolarLorentzVector & polarP4() const
four-momentum Lorentz vector
virtual double energy() const
energy
virtual double vx() const
x coordinate of vertex position
size_type numberOf() const
number of components
double charge(const std::vector< uint8_t > &Ampls)
virtual const CandidatePtr & masterClonePtr() const
edm::BoolCache cachePolarFixed_
has cache been set?
size_type numberOf() const
number of components
virtual double vertexCovariance(int i, int j) const
(i, j)-th element of error matrix, i, j = 0, ... 2
return((rh^lh)&mask)
virtual const_iterator begin() const
first daughter const_iterator
CandidateCollection daughters
collection of daughter candidates
virtual double rapidity() const
rapidity
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
candidate::iterator_imp_specific< daughters > iterator_imp_specific
virtual double pt() const
transverse momentum
virtual double et() const
transverse energy
LeafRefCandidateT()
default constructor
virtual double vz() const
z coordinate of vertex position
boost::filter_iterator< S, const_iterator > type
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
void clearCache() const
clear internal cache
virtual double mtSqr() const
transverse mass squared
double p4[4]
Definition: TauolaWrapper.h:92
static const unsigned int massConstraintTag
static const unsigned int longLivedTag
virtual bool overlap(const Candidate &) const
check overlap with another Candidate
virtual int pdgId() const
pdg ID: dummy for now
virtual double px() const
x coordinate of momentum vector
virtual Vector boostToCM() const
virtual Vector momentum() const
spatial momentum vector
virtual bool isPhoton() const
virtual void setVertex(const Point &vertex)
set vertex
int j
Definition: DBlmapReader.cc:9
virtual const Point & vertex() const =0
vertex position
virtual bool isJet() const
virtual bool isCaloMuon() const
virtual int charge() const =0
electric charge
virtual void setP4(const LorentzVector &p4)
set 4-momentum
virtual double py() const
y coordinate of momentum vector
PolarLorentzVector p4Polar_
internal cache for p4
daughter_iterator< S >::type beginFilter(const S &s) const
virtual bool isConvertedPhoton() const
virtual bool longLived() const
is long lived?
virtual void setPdgId(int pdgId)
math::XYZVector Vector
point in the space
virtual void setStatus(int status)
set status word
virtual size_t numberOfMothers() const
number of mothers
virtual double mt() const
transverse mass
virtual size_t numberOfDaughters() const
number of daughters
void cacheCartesian() const
set internal cache
float mass_
mass hypothesis
virtual const Candidate * mother(size_type) const
return mother at a given position (throws an exception)
virtual bool hasMasterClone() const
This only happens if the concrete Candidate type is ShallowCloneCandidate.
candidate::iterator iterator
Definition: Candidate.h:34
virtual double vertexNdof() const
void cachePolar() const
set internal cache
virtual int threeCharge() const
electric charge
virtual double eta() const
momentum pseudorapidity
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
math::XYZTLorentzVector LorentzVector
Lorentz vector.
daughter_iterator< S >::type endFilter(const S &s) const
virtual const Point & vertex() const
vertex position
virtual bool isElectron() const
virtual size_t numberOfSourceCandidatePtrs() const
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:39
virtual const Candidate * daughter(size_type) const
return daughter at a given position (throws an exception)
edm::BoolCache cacheCartesianFixed_
virtual void setPz(double pz)
virtual double phi() const
momentum azimuthal angle
candidate::const_iterator_imp_specific< daughters > const_iterator_imp_specific
virtual bool isTrackerMuon() const
virtual ~LeafRefCandidateT()
destructor
virtual void setP4(const PolarLorentzVector &p4)
set 4-momentum
virtual void setMassConstraint()
set mass constraint flag
math::XYZPoint Point
point in the space
Definition: Candidate.h:43
virtual void setCharge(Charge q)
virtual bool isMuon() const
virtual double mass() const
mass
string s
Definition: asciidump.py:422
virtual double vertexChi2() const
chi-squares
virtual double vy() const
y coordinate of vertex position
LeafRefCandidateT(const T &c, float m)
long double T
value_type const * get() const
Definition: RefToBase.h:212
int Charge
electric charge type
mathSSE::Vec4< T > v
Ref masterRef() const
cast master clone reference to a concrete type
virtual const_iterator end() const
last daughter const_iterator
virtual void setMass(double m)
set particle mass
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:41