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 
13 
15 
17 
18 namespace reco {
19 
20  template < class T >
21  class LeafRefCandidateT : public Candidate {
22  public:
26  typedef int Charge;
35 
36  typedef unsigned int index;
37 
40  mass_(0),
41  cachePolarFixed_( false ) { }
42  // constructor from T
43  explicit LeafRefCandidateT( const T & c, float m) :
44  ref_(c),
45  mass_( m ),
47 
49  virtual ~LeafRefCandidateT() {}
51  virtual const_iterator begin() const;
53  virtual const_iterator end() const;
55  virtual iterator begin();
57  virtual iterator end();
59  virtual size_t numberOfDaughters() const GCC11_FINAL { return 0; }
61  virtual const Candidate * daughter( size_type ) const GCC11_FINAL { return 0; }
63  virtual size_t numberOfMothers() const GCC11_FINAL { return 0; }
65  virtual const Candidate * mother( size_type ) const GCC11_FINAL { return 0; }
67  virtual Candidate * daughter( size_type ) GCC11_FINAL { return 0; }
69  virtual Candidate * daughter(const std::string& s ) GCC11_FINAL { return 0; }
71  virtual const Candidate * daughter(const std::string& s ) const GCC11_FINAL { return 0; }
74  virtual size_t numberOfSourceCandidatePtrs() const GCC11_FINAL { return 0;}
78  static const CandidatePtr dummyPtr;
79  return dummyPtr;
80  }
81 
83  virtual int charge() const GCC11_FINAL { return ref_->charge(); }
85  virtual int pdgId() const GCC11_FINAL { return 0; }
86 
88  virtual const LorentzVector & p4() const GCC11_FINAL { cacheCartesian(); return p4Cartesian_; }
92  virtual Vector momentum() const GCC11_FINAL { cacheCartesian(); return p4Cartesian_.Vect(); }
95  virtual Vector boostToCM() const GCC11_FINAL { cacheCartesian(); return p4Cartesian_.BoostToCM(); }
97  virtual double p() const GCC11_FINAL { cacheCartesian(); return p4Cartesian_.P(); }
99  virtual double energy() const GCC11_FINAL { cacheCartesian(); return p4Cartesian_.E(); }
101  virtual double et() const GCC11_FINAL { cachePolar(); return p4Polar_.Et(); }
103  virtual float mass() const GCC11_FINAL { return mass_; }
105  virtual float massSqr() const GCC11_FINAL { return mass_ * mass_; }
107  virtual double mt() const GCC11_FINAL { cachePolar(); return p4Polar_.Mt(); }
109  virtual double mtSqr() const GCC11_FINAL { cachePolar(); return p4Polar_.Mt2(); }
111  virtual double px() const GCC11_FINAL { cacheCartesian(); return p4Cartesian_.Px(); }
113  virtual double py() const GCC11_FINAL { cacheCartesian(); return p4Cartesian_.Py(); }
115  virtual double pz() const GCC11_FINAL { cacheCartesian(); return p4Cartesian_.Pz(); }
117  virtual float pt() const GCC11_FINAL { return ref_->pt(); }
119  virtual float phi() const GCC11_FINAL { return ref_->phi(); }
121  virtual double theta() const GCC11_FINAL { return ref_->theta(); }
123  virtual float eta() const GCC11_FINAL { return ref_->eta(); }
125  virtual double rapidity() const GCC11_FINAL { cachePolar(); return p4Polar_.Rapidity(); }
127  virtual double y() const GCC11_FINAL { return rapidity(); }
128 
130  virtual void setMass( double m ) GCC11_FINAL {
131  mass_ = m;
132  clearCache();
133  }
134 
136  virtual const Point & vertex() const GCC11_FINAL { return ref_->vertex(); }
138  virtual double vx() const GCC11_FINAL { return ref_->vx(); }
140  virtual double vy() const GCC11_FINAL { return ref_->vy(); }
142  virtual double vz() const GCC11_FINAL { return ref_->vz(); }
143 
144 
147  return new LeafRefCandidateT<T>( *this );
148  }
149 
150 
152  virtual bool hasMasterClone() const GCC11_FINAL { return false; }
156  static const CandidateBaseRef dummyRef; return dummyRef;
157  }
160  virtual bool hasMasterClonePtr() const GCC11_FINAL { return false; }
164  static const CandidatePtr dummyPtr; return dummyPtr;
165  }
166 
168  template<typename Ref>
169  Ref masterRef() const { Ref dummyRef; return dummyRef; }
171 
172  template<typename C> C get() const {
173  if ( hasMasterClone() ) return masterClone()->template get<C>();
174  else return reco::get<C>( * this );
175  }
177  template<typename C, typename Tag> C get() const {
178  if ( hasMasterClone() ) return masterClone()->template get<C, Tag>();
179  else return reco::get<C, Tag>( * this );
180  }
182  template<typename C> C get( size_type i ) const {
183  if ( hasMasterClone() ) return masterClone()->template get<C>( i );
184  else return reco::get<C>( * this, i );
185  }
187  template<typename C, typename Tag> C get( size_type i ) const {
188  if ( hasMasterClone() ) return masterClone()->template get<C, Tag>( i );
189  else return reco::get<C, Tag>( * this, i );
190  }
192  template<typename C> size_type numberOf() const {
193  if ( hasMasterClone() ) return masterClone()->template numberOf<C>();
194  else return reco::numberOf<C>( * this );
195  }
197  template<typename C, typename Tag> size_type numberOf() const {
198  if ( hasMasterClone() ) return masterClone()->template numberOf<C, Tag>();
199  else return reco::numberOf<C, Tag>( * this );
200  }
201 
202  template<typename S>
204  typedef boost::filter_iterator<S, const_iterator> type;
205  };
206 
207  template<typename S>
208  typename daughter_iterator<S>::type beginFilter( const S & s ) const {
209  return boost::make_filter_iterator(s, begin(), end());
210  }
211  template<typename S>
212  typename daughter_iterator<S>::type endFilter( const S & s ) const {
213  return boost::make_filter_iterator(s, end(), end());
214  }
215 
216 
217  virtual bool isElectron() const GCC11_FINAL { return false; }
218  virtual bool isMuon() const GCC11_FINAL { return false; }
219  virtual bool isStandAloneMuon() const GCC11_FINAL { return false; }
220  virtual bool isGlobalMuon() const GCC11_FINAL { return false; }
221  virtual bool isTrackerMuon() const GCC11_FINAL { return false; }
222  virtual bool isCaloMuon() const GCC11_FINAL { return false; }
223  virtual bool isPhoton() const GCC11_FINAL { return false; }
224  virtual bool isConvertedPhoton() const GCC11_FINAL { return false; }
225  virtual bool isJet() const GCC11_FINAL { return false; }
226 
228 
229  protected:
234  float mass_;
242  inline void cachePolar() const {
243  if ( cachePolarFixed_ ) return;
244  p4Polar_ = PolarLorentzVector( ref_->pt(), ref_->eta(), ref_->phi(), mass_ );
245  cachePolarFixed_ = true;
246  }
248  inline void cacheCartesian() const {
249  if ( cacheCartesianFixed_ ) return;
250  cachePolar();
252  cacheCartesianFixed_ = true;
253  }
255  inline void clearCache() const {
256  cachePolarFixed_ = false;
257  cacheCartesianFixed_ = false;
258  }
260  virtual bool overlap( const Candidate & ) const;
261  virtual bool overlap( const LeafRefCandidateT & ) const;
262  template<typename, typename, typename> friend struct component;
263  friend class ::OverlapChecker;
264  friend class ShallowCloneCandidate;
266 
267  private:
268  // const iterator implementation
270  // iterator implementation
272 
273 
277 
278  virtual void setCharge( Charge q ) GCC11_FINAL { return; }
279  virtual int threeCharge() const GCC11_FINAL { return 0; }
280  virtual void setThreeCharge( Charge qx3 ) GCC11_FINAL { return; }
281  virtual void setP4( const LorentzVector & p4 ) GCC11_FINAL {
282  return;
283  }
284  virtual void setP4( const PolarLorentzVector & p4 ) GCC11_FINAL {
285  return;
286  }
287  virtual void setPz( double pz ) GCC11_FINAL {
288  return;
289  }
290  virtual void setVertex( const Point & vertex ) GCC11_FINAL { return; }
291  virtual void setPdgId( int pdgId ) GCC11_FINAL { return; }
292  virtual int status() const GCC11_FINAL { return 0; }
293  virtual void setStatus( int status ) GCC11_FINAL { return; }
294  static const unsigned int longLivedTag;
295  virtual void setLongLived() GCC11_FINAL { return; }
296  virtual bool longLived() const GCC11_FINAL { return false; }
297  static const unsigned int massConstraintTag;
298  virtual void setMassConstraint() GCC11_FINAL { return;}
299  virtual bool massConstraint() const GCC11_FINAL { return false; }
300  virtual double vertexChi2() const GCC11_FINAL { return 0.; }
301  virtual double vertexNdof() const GCC11_FINAL { return 0.; }
302  virtual double vertexNormalizedChi2() const GCC11_FINAL { return 0.; }
303  virtual double vertexCovariance(int i, int j) const GCC11_FINAL { return 0.; }
306 
307  };
308 
309 
310 
311  template<class T>
314  }
315 
316  template<class T>
319  }
320 
321  template<class T>
323  return iterator( new iterator_imp_specific );
324  }
325 
326  template<class T>
328  return iterator( new iterator_imp_specific );
329  }
330 
331 
332  template<class T>
333  bool LeafRefCandidateT<T>::overlap( const Candidate & o ) const {
334  return p4() == o.p4() && vertex() == o.vertex() && charge() == o.charge();
335  }
336 
337 
338  template<class T>
340  return ref_ == o.ref_;
341  }
342 
343 
344 
345 }
346 
347 #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:39
int i
Definition: DBlmapReader.cc:9
virtual int status() const
status word
math::XYZPoint Point
point in the space
CovarianceMatrix vertexCovariance() const
fill SMatrix
#define GCC11_FINAL
math::XYZVector Vector
point in the space
Definition: Candidate.h:47
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:34
virtual void setThreeCharge(Charge qx3)
set electric charge
virtual double pz() const
z coordinate of momentum vector
virtual float phi() const
momentum azimuthal angle
virtual double vertexNormalizedChi2() const
chi-squared divided by n.d.o.f.
candidate::const_iterator const_iterator
Definition: Candidate.h:35
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
virtual float mass() const
mass
size_type numberOf() const
number of components
#define CMS_CLASS_VERSION(_version_)
Definition: classes.h:31
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:25
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
virtual float massSqr() const
mass squared
candidate::iterator_imp_specific< daughters > iterator_imp_specific
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:36
virtual double vertexNdof() const
void cachePolar() const
set internal cache
virtual int threeCharge() const
electric charge
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
math::XYZTLorentzVector LorentzVector
Lorentz vector.
daughter_iterator< S >::type endFilter(const S &s) const
virtual const Point & vertex() const
vertex position
virtual float pt() const
transverse momentum
string const
Definition: compareJSON.py:14
virtual bool isElectron() const
double S(const TLorentzVector &, const TLorentzVector &)
Definition: Particle.cc:99
virtual size_t numberOfSourceCandidatePtrs() const
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:41
virtual const Candidate * daughter(size_type) const
return daughter at a given position (throws an exception)
edm::BoolCache cacheCartesianFixed_
virtual void setPz(double pz)
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:45
virtual void setCharge(Charge q)
virtual bool isMuon() const
#define protected
Definition: FWEveView.cc:34
virtual double vertexChi2() const
chi-squares
volatile std::atomic< bool > shutdown_flag false
virtual double vy() const
y coordinate of vertex position
LeafRefCandidateT(const T &c, float m)
long double T
virtual float eta() const
momentum pseudorapidity
int Charge
electric charge type
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:43