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 
227  protected:
232  float mass_;
240  inline void cachePolar() const {
241  if ( cachePolarFixed_ ) return;
242  p4Polar_ = PolarLorentzVector( ref_->pt(), ref_->eta(), ref_->phi(), mass_ );
243  cachePolarFixed_ = true;
244  }
246  inline void cacheCartesian() const {
247  if ( cacheCartesianFixed_ ) return;
248  cachePolar();
250  cacheCartesianFixed_ = true;
251  }
253  inline void clearCache() const {
254  cachePolarFixed_ = false;
255  cacheCartesianFixed_ = false;
256  }
258  virtual bool overlap( const Candidate & ) const;
259  virtual bool overlap( const LeafRefCandidateT & ) const;
260  template<typename, typename, typename> friend struct component;
261  friend class ::OverlapChecker;
262  friend class ShallowCloneCandidate;
264 
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 bool isStandAloneMuon() const GCC11_FINAL
virtual void setMass(double m) GCC11_FINAL
set particle mass
int Charge
electric charge type
Definition: Candidate.h:39
int i
Definition: DBlmapReader.cc:9
virtual void setPdgId(int pdgId) GCC11_FINAL
virtual float pt() const GCC11_FINAL
transverse momentum
math::XYZPoint Point
point in the space
virtual const Candidate * daughter(const std::string &s) const GCC11_FINAL
return daughter with a specified role name
virtual double vz() const GCC11_FINAL
z coordinate of vertex position
virtual double rapidity() const GCC11_FINAL
rapidity
virtual size_t numberOfDaughters() const GCC11_FINAL
number of daughters
math::XYZVector Vector
point in the space
Definition: Candidate.h:47
virtual const CandidateBaseRef & masterClone() const GCC11_FINAL
size_t size_type
Definition: Candidate.h:34
virtual const LorentzVector & p4() const GCC11_FINAL
four-momentum Lorentz vector
candidate::const_iterator const_iterator
Definition: Candidate.h:35
virtual void setPz(double pz) GCC11_FINAL
virtual bool hasMasterClonePtr() const GCC11_FINAL
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
LorentzVector p4Cartesian_
internal cache for p4
virtual int status() const GCC11_FINAL
status word
virtual void setP4(const PolarLorentzVector &p4) GCC11_FINAL
set 4-momentum
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
virtual const Candidate * daughter(size_type) const GCC11_FINAL
return daughter at a given position (throws an exception)
virtual int charge() const GCC11_FINAL
electric charge
virtual bool isJet() const GCC11_FINAL
virtual bool isPhoton() const GCC11_FINAL
size_type numberOf() const
number of components
#define CMS_CLASS_VERSION(_version_)
virtual Candidate * daughter(const std::string &s) GCC11_FINAL
return daughter with a specified role name
virtual void setLongLived() GCC11_FINAL
set long lived flag
double charge(const std::vector< uint8_t > &Ampls)
edm::BoolCache cachePolarFixed_
has cache been set?
size_type numberOf() const
number of components
virtual const_iterator begin() const
first daughter const_iterator
virtual Vector momentum() const GCC11_FINAL
spatial momentum vector
CandidateCollection daughters
collection of daughter candidates
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 int threeCharge() const GCC11_FINAL
electric charge
virtual bool massConstraint() const GCC11_FINAL
do mass constraint?
virtual double p() const GCC11_FINAL
magnitude of momentum vector
boost::filter_iterator< S, const_iterator > type
virtual double y() const GCC11_FINAL
rapidity
virtual void setMassConstraint() GCC11_FINAL
set mass constraint flag
CovarianceMatrix vertexCovariance() const GCC11_FINAL
fill SMatrix
virtual int pdgId() const GCC11_FINAL
pdg ID: dummy for now
LeafRefCandidateT()
default constructor
virtual void setThreeCharge(Charge qx3) GCC11_FINAL
set electric charge
void clearCache() const
clear internal cache
double p4[4]
Definition: TauolaWrapper.h:92
static const unsigned int massConstraintTag
virtual double mtSqr() const GCC11_FINAL
transverse mass squared
static const unsigned int longLivedTag
virtual bool overlap(const Candidate &) const
check overlap with another Candidate
virtual LeafRefCandidateT< T > * clone() const GCC11_FINAL
returns a clone of the Candidate object
virtual bool isConvertedPhoton() const GCC11_FINAL
int j
Definition: DBlmapReader.cc:9
virtual void setP4(const LorentzVector &p4) GCC11_FINAL
set 4-momentum
virtual const Point & vertex() const =0
vertex position
virtual bool isGlobalMuon() const GCC11_FINAL
virtual int charge() const =0
electric charge
PolarLorentzVector p4Polar_
internal cache for p4
daughter_iterator< S >::type beginFilter(const S &s) const
virtual double vertexChi2() const GCC11_FINAL
chi-squares
math::XYZVector Vector
point in the space
virtual const PolarLorentzVector & polarP4() const GCC11_FINAL
four-momentum Lorentz vector
virtual const CandidatePtr & masterClonePtr() const GCC11_FINAL
virtual double theta() const GCC11_FINAL
momentum polar angle
virtual double py() const GCC11_FINAL
y coordinate of momentum vector
virtual double mt() const GCC11_FINAL
transverse mass
virtual bool isCaloMuon() const GCC11_FINAL
void cacheCartesian() const
set internal cache
float mass_
mass hypothesis
virtual Candidate * daughter(size_type) GCC11_FINAL
return daughter at a given position (throws an exception)
candidate::iterator iterator
Definition: Candidate.h:36
virtual bool isTrackerMuon() const GCC11_FINAL
void cachePolar() const
set internal cache
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
virtual double et() const GCC11_FINAL
transverse energy
math::XYZTLorentzVector LorentzVector
Lorentz vector.
virtual size_t numberOfMothers() const GCC11_FINAL
number of mothers
daughter_iterator< S >::type endFilter(const S &s) const
virtual void setVertex(const Point &vertex) GCC11_FINAL
set vertex
virtual double vertexNormalizedChi2() const GCC11_FINAL
chi-squared divided by n.d.o.f.
string const
Definition: compareJSON.py:14
virtual double vy() const GCC11_FINAL
y coordinate of vertex position
virtual const Point & vertex() const GCC11_FINAL
vertex position
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:41
virtual float mass() const GCC11_FINAL
mass
return(e1-e2)*(e1-e2)+dp *dp
virtual Vector boostToCM() const GCC11_FINAL
virtual float massSqr() const GCC11_FINAL
mass squared
virtual double pz() const GCC11_FINAL
z coordinate of momentum vector
#define private
Definition: FWFileEntry.h:17
edm::BoolCache cacheCartesianFixed_
virtual void setStatus(int status) GCC11_FINAL
set status word
virtual double vertexNdof() const GCC11_FINAL
virtual double energy() const GCC11_FINAL
energy
virtual bool isMuon() const GCC11_FINAL
virtual const Candidate * mother(size_type) const GCC11_FINAL
return mother at a given position (throws an exception)
virtual bool longLived() const GCC11_FINAL
is long lived?
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
virtual ~LeafRefCandidateT()
destructor
math::XYZPoint Point
point in the space
Definition: Candidate.h:45
virtual bool isElectron() const GCC11_FINAL
virtual double vx() const GCC11_FINAL
x coordinate of vertex position
virtual void setCharge(Charge q) GCC11_FINAL
volatile std::atomic< bool > shutdown_flag false
virtual double vertexCovariance(int i, int j) const GCC11_FINAL
(i, j)-th element of error matrix, i, j = 0, ... 2
virtual bool hasMasterClone() const GCC11_FINAL
This only happens if the concrete Candidate type is ShallowCloneCandidate.
virtual CandidatePtr sourceCandidatePtr(size_type i) const GCC11_FINAL
virtual size_t numberOfSourceCandidatePtrs() const GCC11_FINAL
virtual double px() const GCC11_FINAL
x coordinate of momentum vector
LeafRefCandidateT(const T &c, float m)
long double T
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 fillVertexCovariance(CovarianceMatrix &v) const GCC11_FINAL
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:43