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 
18 
19 namespace reco {
20 
21  template < class T >
22  class LeafRefCandidateT : public Candidate {
23  public:
27  typedef int Charge;
36 
37  typedef unsigned int index;
38 
41  mass_(0),
42  cachePolarFixed_( false ) { }
43  // constructor from T
44  explicit LeafRefCandidateT( const T & c, float m) :
45  ref_(c),
46  mass_( m ),
48 
50  virtual ~LeafRefCandidateT() {}
52  virtual const_iterator begin() const;
54  virtual const_iterator end() const;
56  virtual iterator begin();
58  virtual iterator end();
60  virtual size_t numberOfDaughters() const { return 0; }
62  virtual const Candidate * daughter( size_type ) const { return 0; }
64  virtual size_t numberOfMothers() const { return 0; }
66  virtual const Candidate * mother( size_type ) const { return 0; }
68  virtual Candidate * daughter( size_type ) { return 0; }
70  virtual Candidate * daughter(const std::string& s ) { return 0; }
72  virtual const Candidate * daughter(const std::string& s ) const { return 0; }
75  virtual size_t numberOfSourceCandidatePtrs() const { return 0;}
79  static CandidatePtr dummyPtr;
80  return dummyPtr;
81  }
82 
84  virtual int charge() const { return ref_->charge(); }
86  virtual int pdgId() const { return 0; }
87 
89  virtual const LorentzVector & p4() const { cacheCartesian(); return p4Cartesian_; }
91  virtual const PolarLorentzVector & polarP4() const { cachePolar(); return p4Polar_; }
93  virtual Vector momentum() const { cacheCartesian(); return p4Cartesian_.Vect(); }
96  virtual Vector boostToCM() const { cacheCartesian(); return p4Cartesian_.BoostToCM(); }
98  virtual double p() const { cacheCartesian(); return p4Cartesian_.P(); }
100  virtual double energy() const { cacheCartesian(); return p4Cartesian_.E(); }
102  virtual double et() const { cachePolar(); return p4Polar_.Et(); }
104  virtual double mass() const { return mass_; }
106  virtual double massSqr() const { return mass_ * mass_; }
108  virtual double mt() const { cachePolar(); return p4Polar_.Mt(); }
110  virtual double mtSqr() const { cachePolar(); return p4Polar_.Mt2(); }
112  virtual double px() const { cacheCartesian(); return p4Cartesian_.Px(); }
114  virtual double py() const { cacheCartesian(); return p4Cartesian_.Py(); }
116  virtual double pz() const { cacheCartesian(); return p4Cartesian_.Pz(); }
118  virtual double pt() const { return ref_->pt(); }
120  virtual double phi() const { return ref_->phi(); }
122  virtual double theta() const { return ref_->theta(); }
124  virtual double eta() const { return ref_->eta(); }
126  virtual double rapidity() const { cachePolar(); return p4Polar_.Rapidity(); }
128  virtual double y() const { return rapidity(); }
129 
131  virtual void setMass( double m ) {
132  mass_ = m;
133  clearCache();
134  }
135 
137  virtual const Point & vertex() const { return ref_->vertex(); }
139  virtual double vx() const { return ref_->vx(); }
141  virtual double vy() const { return ref_->vy(); }
143  virtual double vz() const { return ref_->vz(); }
144 
145 
147  virtual LeafRefCandidateT<T> * clone() const {
148  return new LeafRefCandidateT<T>( *this );
149  }
150 
151 
153  virtual bool hasMasterClone() const { return false; }
156  virtual const CandidateBaseRef & masterClone() const {
157  static CandidateBaseRef dummyRef; return dummyRef;
158  }
161  virtual bool hasMasterClonePtr() const { return false; }
164  virtual const CandidatePtr & masterClonePtr() const {
165  static CandidatePtr dummyPtr; return dummyPtr;
166  }
167 
169  template<typename Ref>
170  Ref masterRef() const { Ref dummyRef; return dummyRef; }
172 
173  template<typename C> C get() const {
174  if ( hasMasterClone() ) return masterClone()->get<C>();
175  else return reco::get<C>( * this );
176  }
178  template<typename C, typename Tag> C get() const {
179  if ( hasMasterClone() ) return masterClone()->get<C, Tag>();
180  else return reco::get<C, Tag>( * this );
181  }
183  template<typename C> C get( size_type i ) const {
184  if ( hasMasterClone() ) return masterClone()->get<C>( i );
185  else return reco::get<C>( * this, i );
186  }
188  template<typename C, typename Tag> C get( size_type i ) const {
189  if ( hasMasterClone() ) return masterClone()->get<C, Tag>( i );
190  else return reco::get<C, Tag>( * this, i );
191  }
193  template<typename C> size_type numberOf() const {
194  if ( hasMasterClone() ) return masterClone()->numberOf<C>();
195  else return reco::numberOf<C>( * this );
196  }
198  template<typename C, typename Tag> size_type numberOf() const {
199  if ( hasMasterClone() ) return masterClone()->numberOf<C, Tag>();
200  else return reco::numberOf<C, Tag>( * this );
201  }
202 
203  template<typename S>
205  typedef boost::filter_iterator<S, const_iterator> type;
206  };
207 
208  template<typename S>
209  typename daughter_iterator<S>::type beginFilter( const S & s ) const {
210  return boost::make_filter_iterator(s, begin(), end());
211  }
212  template<typename S>
213  typename daughter_iterator<S>::type endFilter( const S & s ) const {
214  return boost::make_filter_iterator(s, end(), end());
215  }
216 
217 
218  virtual bool isElectron() const { return false; }
219  virtual bool isMuon() const { return false; }
220  virtual bool isStandAloneMuon() const { return false; }
221  virtual bool isGlobalMuon() const { return false; }
222  virtual bool isTrackerMuon() const { return false; }
223  virtual bool isCaloMuon() const { return false; }
224  virtual bool isPhoton() const { return false; }
225  virtual bool isConvertedPhoton() const { return false; }
226  virtual bool isJet() const { return false; }
227 
228  protected:
233  float mass_;
241  inline void cachePolar() const {
242  if ( cachePolarFixed_ ) return;
243  p4Polar_ = PolarLorentzVector( ref_->pt(), ref_->eta(), ref_->phi(), mass_ );
244  cachePolarFixed_ = true;
245  }
247  inline void cacheCartesian() const {
248  if ( cacheCartesianFixed_ ) return;
249  cachePolar();
251  cacheCartesianFixed_ = true;
252  }
254  inline void clearCache() const {
255  cachePolarFixed_ = false;
256  cacheCartesianFixed_ = false;
257  }
259  virtual bool overlap( const Candidate & ) const;
260  virtual bool overlap( const LeafRefCandidateT & ) const;
261  template<typename, typename, typename> friend struct component;
262  friend class ::OverlapChecker;
263  friend class ShallowCloneCandidate;
265 
266  private:
267  // const iterator implementation
269  // iterator implementation
271 
272 
276 
277  virtual void setCharge( Charge q ) { return; }
278  virtual int threeCharge() const { return 0; }
279  virtual void setThreeCharge( Charge qx3 ) { return; }
280  virtual void setP4( const LorentzVector & p4 ) {
281  return;
282  }
283  virtual void setP4( const PolarLorentzVector & p4 ) {
284  return;
285  }
286  virtual void setPz( double pz ) {
287  return;
288  }
289  virtual void setVertex( const Point & vertex ) { return; }
290  virtual void setPdgId( int pdgId ) { return; }
291  virtual int status() const { return 0; }
292  virtual void setStatus( int status ) { return; }
293  static const unsigned int longLivedTag;
294  virtual void setLongLived() { return; }
295  virtual bool longLived() const { return false; }
296  static const unsigned int massConstraintTag;
297  virtual void setMassConstraint() { return;}
298  virtual bool massConstraint() const { return false; }
299  virtual double vertexChi2() const { return 0.; }
300  virtual double vertexNdof() const { return 0.; }
301  virtual double vertexNormalizedChi2() const { return 0.; }
302  virtual double vertexCovariance(int i, int j) const { return 0.; }
304  virtual void fillVertexCovariance(CovarianceMatrix & v) const { return ; }
305 
306  };
307 
308 
309 
310  template<class T>
313  }
314 
315  template<class T>
318  }
319 
320  template<class T>
322  return iterator( new iterator_imp_specific );
323  }
324 
325  template<class T>
327  return iterator( new iterator_imp_specific );
328  }
329 
330 
331  template<class T>
332  bool LeafRefCandidateT<T>::overlap( const Candidate & o ) const {
333  return p4() == o.p4() && vertex() == o.vertex() && charge() == o.charge();
334  }
335 
336 
337  template<class T>
339  return ref_ == o.ref_;
340  }
341 
342 
343 
344 }
345 
346 #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:36
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:44
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:31
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:32
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
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:33
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:38
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:42
virtual void setCharge(Charge q)
virtual bool isMuon() const
virtual double mass() const
mass
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:40