File indexing completed on 2024-04-06 12:03:48
0001 #ifndef Candidate_LeafRefCandidateT_h
0002 #define Candidate_LeafRefCandidateT_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include "DataFormats/Candidate/interface/LeafCandidate.h"
0013 #include "DataFormats/Common/interface/RefCoreWithIndex.h"
0014
0015 namespace reco {
0016
0017 class LeafRefCandidateT : public LeafCandidate {
0018 public:
0019
0020 typedef CandidateCollection daughters;
0021
0022 typedef int Charge;
0023
0024 typedef math::XYZTLorentzVector LorentzVector;
0025
0026 typedef math::PtEtaPhiMLorentzVector PolarLorentzVector;
0027
0028 typedef math::XYZPoint Point;
0029
0030 typedef math::XYZVector Vector;
0031
0032 typedef unsigned int index;
0033
0034
0035 LeafRefCandidateT() {}
0036
0037 template <class REF>
0038 LeafRefCandidateT(const REF& c, float m)
0039 : LeafCandidate(c->charge(), PolarLorentzVector(c->pt(), c->eta(), c->phi(), m), c->vertex()),
0040 ref_(c.refCore(), c.key()) {}
0041
0042 ~LeafRefCandidateT() override {}
0043
0044 protected:
0045
0046 template <typename REF>
0047 REF getRef() const {
0048 return REF(ref_.toRefCore(), ref_.index());
0049 }
0050
0051 public:
0052
0053 size_t numberOfDaughters() const final { return 0; }
0054
0055 const Candidate* daughter(size_type) const final { return nullptr; }
0056
0057 size_t numberOfMothers() const final { return 0; }
0058
0059 const Candidate* mother(size_type) const final { return nullptr; }
0060
0061 Candidate* daughter(size_type) final { return nullptr; }
0062
0063 Candidate* daughter(const std::string& s) final { return nullptr; }
0064
0065 const Candidate* daughter(const std::string& s) const final { return nullptr; }
0066
0067
0068 size_t numberOfSourceCandidatePtrs() const final { return 0; }
0069
0070
0071 CandidatePtr sourceCandidatePtr(size_type i) const final {
0072 static const CandidatePtr dummyPtr;
0073 return dummyPtr;
0074 }
0075
0076
0077 bool hasMasterClone() const final { return false; }
0078
0079
0080 const CandidateBaseRef& masterClone() const final {
0081 static const CandidateBaseRef dummyRef;
0082 return dummyRef;
0083 }
0084
0085
0086 bool hasMasterClonePtr() const final { return false; }
0087
0088
0089 const CandidatePtr& masterClonePtr() const final {
0090 static const CandidatePtr dummyPtr;
0091 return dummyPtr;
0092 }
0093
0094
0095 template <typename Ref>
0096 Ref masterRef() const {
0097 Ref dummyRef;
0098 return dummyRef;
0099 }
0100
0101
0102 template <typename C>
0103 C get() const {
0104 if (hasMasterClone())
0105 return masterClone()->template get<C>();
0106 else
0107 return reco::get<C>(*this);
0108 }
0109
0110 template <typename C, typename Tag>
0111 C get() const {
0112 if (hasMasterClone())
0113 return masterClone()->template get<C, Tag>();
0114 else
0115 return reco::get<C, Tag>(*this);
0116 }
0117
0118 template <typename C>
0119 C get(size_type i) const {
0120 if (hasMasterClone())
0121 return masterClone()->template get<C>(i);
0122 else
0123 return reco::get<C>(*this, i);
0124 }
0125
0126 template <typename C, typename Tag>
0127 C get(size_type i) const {
0128 if (hasMasterClone())
0129 return masterClone()->template get<C, Tag>(i);
0130 else
0131 return reco::get<C, Tag>(*this, i);
0132 }
0133
0134 template <typename C>
0135 size_type numberOf() const {
0136 if (hasMasterClone())
0137 return masterClone()->template numberOf<C>();
0138 else
0139 return reco::numberOf<C>(*this);
0140 }
0141
0142 template <typename C, typename Tag>
0143 size_type numberOf() const {
0144 if (hasMasterClone())
0145 return masterClone()->template numberOf<C, Tag>();
0146 else
0147 return reco::numberOf<C, Tag>(*this);
0148 }
0149
0150 bool isElectron() const final { return false; }
0151 bool isMuon() const final { return false; }
0152 bool isStandAloneMuon() const final { return false; }
0153 bool isGlobalMuon() const final { return false; }
0154 bool isTrackerMuon() const final { return false; }
0155 bool isCaloMuon() const final { return false; }
0156 bool isPhoton() const final { return false; }
0157 bool isConvertedPhoton() const final { return false; }
0158 bool isJet() const final { return false; }
0159
0160 CMS_CLASS_VERSION(13)
0161
0162 protected:
0163
0164 bool overlap(const Candidate&) const override;
0165 virtual bool overlap(const LeafRefCandidateT&) const;
0166 template <typename, typename, typename>
0167 friend struct component;
0168 friend class ::OverlapChecker;
0169 friend class ShallowCloneCandidate;
0170 friend class ShallowClonePtrCandidate;
0171
0172 protected:
0173 edm::RefCoreWithIndex ref_;
0174
0175 private:
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197 };
0198
0199 inline bool LeafRefCandidateT::overlap(const Candidate& o) const {
0200 return (p4() == o.p4()) && (vertex() == o.vertex()) && (charge() == o.charge());
0201 }
0202
0203 inline bool LeafRefCandidateT::overlap(const LeafRefCandidateT& o) const {
0204 return (ref_.id() == o.ref_.id()) && (ref_.index() == o.ref_.index());
0205 }
0206
0207 }
0208
0209 #endif