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  ~LeafRefCandidateT() override {}
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  size_t numberOfDaughters() const final { return 0; }
54  const Candidate * daughter( size_type ) const final { return nullptr; }
56  size_t numberOfMothers() const final { return 0; }
58  const Candidate * mother( size_type ) const final { return nullptr; }
60  Candidate * daughter( size_type ) final { return nullptr; }
62  Candidate * daughter(const std::string& s ) final { return nullptr; }
64  const Candidate * daughter(const std::string& s ) const final { return nullptr; }
67  size_t numberOfSourceCandidatePtrs() const final { return 0;}
71  static const CandidatePtr dummyPtr;
72  return dummyPtr;
73  }
74 
75 
76 
78  bool hasMasterClone() const final { return false; }
81  const CandidateBaseRef & masterClone() const final {
82  static const CandidateBaseRef dummyRef; return dummyRef;
83  }
86  bool hasMasterClonePtr() const final { return false; }
89  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  bool isElectron() const final { return false; }
130  bool isMuon() const final { return false; }
131  bool isStandAloneMuon() const final { return false; }
132  bool isGlobalMuon() const final { return false; }
133  bool isTrackerMuon() const final { return false; }
134  bool isCaloMuon() const final { return false; }
135  bool isPhoton() const final { return false; }
136  bool isConvertedPhoton() const final { return false; }
137  bool isJet() const final { return false; }
138 
140 
141  protected:
142 
144  bool overlap( const Candidate & ) const override;
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
bool isMuon() const final
double eta() const final
momentum pseudorapidity
Ref masterRef() const
cast master clone reference to a concrete type
math::XYZVector Vector
point in the space
bool isConvertedPhoton() const final
~LeafRefCandidateT() override
destructor
size_t size_type
Definition: Candidate.h:30
bool isStandAloneMuon() const final
size_t numberOfMothers() const final
number of mothers
unsigned int index() const
size_t numberOfDaughters() const final
number of daughters
double pt() const final
transverse momentum
bool isElectron() const final
int charge() const final
electric charge
Definition: LeafCandidate.h:91
#define CMS_CLASS_VERSION(_version_)
ProductID id() const
size_type numberOf() const
number of components
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
Candidate * daughter(const std::string &s) final
return daughter with a specified role name
RefCore const & toRefCore() const
bool isPhoton() const final
bool isCaloMuon() const final
bool isTrackerMuon() const final
const CandidatePtr & masterClonePtr() const final
bool isJet() const final
const Point & vertex() const override
vertex position (overwritten by PF...)
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
const Candidate * daughter(size_type) const final
return daughter at a given position (throws an exception)
Candidate * daughter(size_type) final
return daughter at a given position (throws an exception)
bool overlap(const Candidate &) const override
check overlap with another Candidate
size_type numberOf() const
number of components
LeafRefCandidateT()
default constructor
int Charge
electric charge type
LeafRefCandidateT(const REF &c, float m)
const Candidate * mother(size_type) const final
return mother at a given position (throws an exception)
bool isGlobalMuon() const final
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
CandidatePtr sourceCandidatePtr(size_type i) const final
fixed size matrix
HLT enums.
math::XYZPoint Point
point in the space
math::XYZTLorentzVector LorentzVector
Lorentz vector.
bool hasMasterClonePtr() const final
size_t numberOfSourceCandidatePtrs() const final
const CandidateBaseRef & masterClone() const final
double phi() const final
momentum azimuthal angle
edm::RefCoreWithIndex ref_
bool hasMasterClone() const final
This only happens if the concrete Candidate type is ShallowCloneCandidate.
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
const Candidate * daughter(const std::string &s) const final
return daughter with a specified role name