CMS 3D CMS Logo

LeafRefCandidateT.h
Go to the documentation of this file.
1 #ifndef Candidate_LeafRefCandidateT_h
2 #define Candidate_LeafRefCandidateT_h
3 
14 
15 
16 namespace reco {
17 
19  public:
23  typedef int Charge;
32 
33  typedef unsigned int index;
34 
37  // constructor from T
38  template < class REF >
39  LeafRefCandidateT( const REF & c, float m) :
40  LeafCandidate(c->charge(),PolarLorentzVector(c->pt(), c->eta(), c->phi(), m ),c->vertex()),
41  ref_(c.refCore(), c.key()){}
43  virtual ~LeafRefCandidateT() {}
44 
45 protected:
46  // get the ref (better be the correct ref!)
47  template<typename REF>
48  REF getRef() const { return REF(ref_.toRefCore(),ref_.index()); }
49 
50 public:
52  virtual size_t numberOfDaughters() const final { return 0; }
54  virtual const Candidate * daughter( size_type ) const final { return 0; }
56  virtual size_t numberOfMothers() const final { return 0; }
58  virtual const Candidate * mother( size_type ) const final { return 0; }
60  virtual Candidate * daughter( size_type ) final { return 0; }
62  virtual Candidate * daughter(const std::string& s ) final { return 0; }
64  virtual const Candidate * daughter(const std::string& s ) const final { return 0; }
67  virtual size_t numberOfSourceCandidatePtrs() const final { return 0;}
70  virtual CandidatePtr sourceCandidatePtr( size_type i ) const final {
71  static const CandidatePtr dummyPtr;
72  return dummyPtr;
73  }
74 
75 
76 
78  virtual bool hasMasterClone() const final { return false; }
81  virtual const CandidateBaseRef & masterClone() const final {
82  static const CandidateBaseRef dummyRef; return dummyRef;
83  }
86  virtual bool hasMasterClonePtr() const final { return false; }
89  virtual const CandidatePtr & masterClonePtr() const final {
90  static const CandidatePtr dummyPtr; return dummyPtr;
91  }
92 
94  template<typename Ref>
95  Ref masterRef() const { Ref dummyRef; return dummyRef; }
97 
98  template<typename C> C get() const {
99  if ( hasMasterClone() ) return masterClone()->template get<C>();
100  else return reco::get<C>( * this );
101  }
103  template<typename C, typename Tag> C get() const {
104  if ( hasMasterClone() ) return masterClone()->template get<C, Tag>();
105  else return reco::get<C, Tag>( * this );
106  }
108  template<typename C> C get( size_type i ) const {
109  if ( hasMasterClone() ) return masterClone()->template get<C>( i );
110  else return reco::get<C>( * this, i );
111  }
113  template<typename C, typename Tag> C get( size_type i ) const {
114  if ( hasMasterClone() ) return masterClone()->template get<C, Tag>( i );
115  else return reco::get<C, Tag>( * this, i );
116  }
118  template<typename C> size_type numberOf() const {
119  if ( hasMasterClone() ) return masterClone()->template numberOf<C>();
120  else return reco::numberOf<C>( * this );
121  }
123  template<typename C, typename Tag> size_type numberOf() const {
124  if ( hasMasterClone() ) return masterClone()->template numberOf<C, Tag>();
125  else return reco::numberOf<C, Tag>( * this );
126  }
127 
128 
129  virtual bool isElectron() const final { return false; }
130  virtual bool isMuon() const final { return false; }
131  virtual bool isStandAloneMuon() const final { return false; }
132  virtual bool isGlobalMuon() const final { return false; }
133  virtual bool isTrackerMuon() const final { return false; }
134  virtual bool isCaloMuon() const final { return false; }
135  virtual bool isPhoton() const final { return false; }
136  virtual bool isConvertedPhoton() const final { return false; }
137  virtual bool isJet() const final { return false; }
138 
140 
141  protected:
142 
144  virtual bool overlap( const Candidate & ) const;
145  virtual bool overlap( const LeafRefCandidateT & ) const;
146  template<typename, typename, typename> friend struct component;
147  friend class ::OverlapChecker;
148  friend class ShallowCloneCandidate;
150 
151  protected:
152  edm::RefCoreWithIndex ref_;
153  private:
154 
158  /*
159  virtual void setCharge( Charge q ) final {}
160  virtual void setThreeCharge( Charge qx3 ) final {}
161  virtual void setP4( const LorentzVector & p4 ) final {}
162  virtual void setP4( const PolarLorentzVector & p4 ) final {}
163  virtual void setPz( double pz ) final {}
164  virtual void setVertex( const Point & vertex ) final {}
165  virtual void setPdgId( int pdgId ) final {}
166  virtual void setStatus( int status ) final {}
167  virtual void setLongLived() final {}
168  virtual void setMassConstraint() final {}
169 
170  virtual double vertexChi2() const final { return 0.; }
171  virtual double vertexNdof() const final { return 0.; }
172  virtual double vertexNormalizedChi2() const final { return 0.; }
173  virtual double vertexCovariance(int i, int j) const final { return 0.; }
174  virtual void fillVertexCovariance(CovarianceMatrix & v) const final {}
175  */
176  };
177 
178 
179 
180  inline
181  bool LeafRefCandidateT::overlap( const Candidate & o ) const {
182  return p4() == o.p4() && vertex() == o.vertex() && charge() == o.charge();
183  }
184 
185  inline
187  return (ref_.id() == o.ref_.id()) & (ref_.index() == o.ref_.index());
188  }
189 
190 
191 
192 }
193 
194 #endif
virtual double pt() const final
transverse momentum
int i
Definition: DBlmapReader.cc:9
virtual bool overlap(const Candidate &) const
check overlap with another Candidate
Ref masterRef() const
cast master clone reference to a concrete type
virtual size_t numberOfDaughters() const final
number of daughters
math::XYZVector Vector
point in the space
size_t size_type
Definition: Candidate.h:30
virtual bool isMuon() const final
virtual double eta() const final
momentum pseudorapidity
virtual bool hasMasterClone() const final
This only happens if the concrete Candidate type is ShallowCloneCandidate.
virtual const Point & vertex() const
vertex position (overwritten by PF...)
virtual const Candidate * daughter(size_type) const final
return daughter at a given position (throws an exception)
unsigned int index() const
#define CMS_CLASS_VERSION(_version_)
Definition: classes.h:31
ProductID id() const
virtual bool isPhoton() const final
size_type numberOf() const
number of components
virtual bool isConvertedPhoton() const final
virtual double phi() const final
momentum azimuthal angle
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 charge() const final
electric charge
Definition: LeafCandidate.h:91
RefCore const & toRefCore() const
virtual bool isJet() const final
virtual const CandidateBaseRef & masterClone() const final
virtual Candidate * daughter(size_type) final
return daughter at a given position (throws an exception)
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:520
virtual size_t numberOfMothers() const final
number of mothers
size_type numberOf() const
number of components
virtual bool isGlobalMuon() const final
virtual const Candidate * mother(size_type) const final
return mother at a given position (throws an exception)
virtual bool isTrackerMuon() const final
LeafRefCandidateT()
default constructor
int Charge
electric charge type
virtual ~LeafRefCandidateT()
destructor
virtual Candidate * daughter(const std::string &s) final
return daughter with a specified role name
LeafRefCandidateT(const REF &c, float m)
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
CandidateCollection daughters
collection of daughter candidates
virtual size_t numberOfSourceCandidatePtrs() const final
virtual const Candidate * daughter(const std::string &s) const final
return daughter with a specified role name
virtual CandidatePtr sourceCandidatePtr(size_type i) const final
fixed size matrix
HLT enums.
math::XYZPoint Point
point in the space
math::XYZTLorentzVector LorentzVector
Lorentz vector.
virtual const CandidatePtr & masterClonePtr() const final
virtual const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
virtual bool isCaloMuon() const final
edm::RefCoreWithIndex ref_
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
virtual bool isStandAloneMuon() const final
virtual bool hasMasterClonePtr() const final
virtual bool isElectron() const final