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 namespace reco {
16 
18  public:
22  typedef int Charge;
31 
32  typedef unsigned int index;
33 
36  // constructor from T
37  template <class REF>
38  LeafRefCandidateT(const REF& c, float m)
39  : LeafCandidate(c->charge(), PolarLorentzVector(c->pt(), c->eta(), c->phi(), m), c->vertex()),
40  ref_(c.refCore(), c.key()) {}
42  ~LeafRefCandidateT() override {}
43 
44  protected:
45  // get the ref (better be the correct ref!)
46  template <typename REF>
47  REF getRef() const {
48  return REF(ref_.toRefCore(), ref_.index());
49  }
50 
51  public:
53  size_t numberOfDaughters() const final { return 0; }
55  const Candidate* daughter(size_type) const final { return nullptr; }
57  size_t numberOfMothers() const final { return 0; }
59  const Candidate* mother(size_type) const final { return nullptr; }
61  Candidate* daughter(size_type) final { return nullptr; }
63  Candidate* daughter(const std::string& s) final { return nullptr; }
65  const Candidate* daughter(const std::string& s) const final { return nullptr; }
68  size_t numberOfSourceCandidatePtrs() const final { return 0; }
72  static const CandidatePtr dummyPtr;
73  return dummyPtr;
74  }
75 
77  bool hasMasterClone() const final { return false; }
81  static const CandidateBaseRef dummyRef;
82  return dummyRef;
83  }
86  bool hasMasterClonePtr() const final { return false; }
90  static const CandidatePtr dummyPtr;
91  return dummyPtr;
92  }
93 
95  template <typename Ref>
96  Ref masterRef() const {
97  Ref dummyRef;
98  return dummyRef;
99  }
101 
102  template <typename C>
103  C get() const {
104  if (hasMasterClone())
105  return masterClone()->template get<C>();
106  else
107  return reco::get<C>(*this);
108  }
110  template <typename C, typename Tag>
111  C get() const {
112  if (hasMasterClone())
113  return masterClone()->template get<C, Tag>();
114  else
115  return reco::get<C, Tag>(*this);
116  }
118  template <typename C>
119  C get(size_type i) const {
120  if (hasMasterClone())
121  return masterClone()->template get<C>(i);
122  else
123  return reco::get<C>(*this, i);
124  }
126  template <typename C, typename Tag>
127  C get(size_type i) const {
128  if (hasMasterClone())
129  return masterClone()->template get<C, Tag>(i);
130  else
131  return reco::get<C, Tag>(*this, i);
132  }
134  template <typename C>
135  size_type numberOf() const {
136  if (hasMasterClone())
137  return masterClone()->template numberOf<C>();
138  else
139  return reco::numberOf<C>(*this);
140  }
142  template <typename C, typename Tag>
143  size_type numberOf() const {
144  if (hasMasterClone())
145  return masterClone()->template numberOf<C, Tag>();
146  else
147  return reco::numberOf<C, Tag>(*this);
148  }
149 
150  bool isElectron() const final { return false; }
151  bool isMuon() const final { return false; }
152  bool isStandAloneMuon() const final { return false; }
153  bool isGlobalMuon() const final { return false; }
154  bool isTrackerMuon() const final { return false; }
155  bool isCaloMuon() const final { return false; }
156  bool isPhoton() const final { return false; }
157  bool isConvertedPhoton() const final { return false; }
158  bool isJet() const final { return false; }
159 
161 
162  protected:
164  bool overlap(const Candidate&) const override;
165  virtual bool overlap(const LeafRefCandidateT&) const;
166  template <typename, typename, typename>
167  friend struct component;
168  friend class ::OverlapChecker;
169  friend class ShallowCloneCandidate;
171 
172  protected:
173  edm::RefCoreWithIndex ref_;
174 
175  private:
179  /*
180  virtual void setCharge( Charge q ) final {}
181  virtual void setThreeCharge( Charge qx3 ) final {}
182  virtual void setP4( const LorentzVector & p4 ) final {}
183  virtual void setP4( const PolarLorentzVector & p4 ) final {}
184  virtual void setPz( double pz ) final {}
185  virtual void setVertex( const Point & vertex ) final {}
186  virtual void setPdgId( int pdgId ) final {}
187  virtual void setStatus( int status ) final {}
188  virtual void setLongLived() final {}
189  virtual void setMassConstraint() final {}
190 
191  virtual double vertexChi2() const final { return 0.; }
192  virtual double vertexNdof() const final { return 0.; }
193  virtual double vertexNormalizedChi2() const final { return 0.; }
194  virtual double vertexCovariance(int i, int j) const final { return 0.; }
195  virtual void fillVertexCovariance(CovarianceMatrix & v) const final {}
196  */
197  };
198 
199  inline bool LeafRefCandidateT::overlap(const Candidate& o) const {
200  return p4() == o.p4() && vertex() == o.vertex() && charge() == o.charge();
201  }
202 
203  inline bool LeafRefCandidateT::overlap(const LeafRefCandidateT& o) const {
204  return (ref_.id() == o.ref_.id()) & (ref_.index() == o.ref_.index());
205  }
206 
207 } // namespace reco
208 
209 #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
#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
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:31
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