File indexing completed on 2024-09-07 04:35:50
0001 #ifndef Candidate_Candidate_h
0002 #define Candidate_Candidate_h
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include "DataFormats/Candidate/interface/component.h"
0012 #include "DataFormats/Candidate/interface/const_iterator.h"
0013 #include "DataFormats/Math/interface/Error.h"
0014
0015 #include "DataFormats/Math/interface/Point3D.h"
0016 #include "DataFormats/Math/interface/Vector3D.h"
0017 #include "DataFormats/Math/interface/LorentzVector.h"
0018
0019 #include "DataFormats/Candidate/interface/Particle.h"
0020
0021 #include "DataFormats/Common/interface/CMS_CLASS_VERSION.h"
0022
0023 class OverlapChecker;
0024
0025 namespace reco {
0026 class Track;
0027 class Candidate {
0028 public:
0029 typedef size_t size_type;
0030 typedef candidate::const_iterator const_iterator;
0031 typedef candidate::iterator iterator;
0032
0033
0034 typedef int Charge;
0035
0036 typedef math::XYZTLorentzVector LorentzVector;
0037
0038 typedef math::PtEtaPhiMLorentzVector PolarLorentzVector;
0039
0040 typedef math::XYZPoint Point;
0041
0042 typedef math::XYZVector Vector;
0043
0044 enum { dimension = 3 };
0045
0046 typedef math::Error<dimension>::type CovarianceMatrix;
0047
0048 enum { size = dimension * (dimension + 1) / 2 };
0049
0050 typedef unsigned int index;
0051
0052
0053 Candidate() {}
0054
0055 virtual ~Candidate();
0056
0057 virtual int charge() const = 0;
0058
0059 virtual void setCharge(Charge q) = 0;
0060
0061 virtual int threeCharge() const = 0;
0062
0063 virtual void setThreeCharge(Charge qx3) = 0;
0064
0065 virtual const LorentzVector& p4() const = 0;
0066
0067 virtual const PolarLorentzVector& polarP4() const = 0;
0068
0069 virtual Vector momentum() const = 0;
0070
0071
0072 virtual Vector boostToCM() const = 0;
0073
0074 virtual double p() const = 0;
0075
0076 virtual double energy() const = 0;
0077
0078 virtual double et() const = 0;
0079
0080 virtual double et2() const = 0;
0081
0082 virtual double mass() const = 0;
0083
0084 virtual double massSqr() const = 0;
0085
0086 virtual double mt() const = 0;
0087
0088 virtual double mtSqr() const = 0;
0089
0090 virtual double px() const = 0;
0091
0092 virtual double py() const = 0;
0093
0094 virtual double pz() const = 0;
0095
0096 virtual double pt() const = 0;
0097
0098 virtual double phi() const = 0;
0099
0100 virtual double theta() const = 0;
0101
0102 virtual double eta() const = 0;
0103
0104 virtual double rapidity() const = 0;
0105
0106 virtual double y() const = 0;
0107
0108 virtual void setP4(const LorentzVector& p4) = 0;
0109
0110 virtual void setP4(const PolarLorentzVector& p4) = 0;
0111
0112 virtual void setMass(double m) = 0;
0113 virtual void setPz(double pz) = 0;
0114
0115 virtual const Point& vertex() const = 0;
0116
0117 virtual double vx() const = 0;
0118
0119 virtual double vy() const = 0;
0120
0121 virtual double vz() const = 0;
0122
0123 virtual void setVertex(const Point& vertex) = 0;
0124
0125 virtual int pdgId() const = 0;
0126
0127 virtual void setPdgId(int pdgId) = 0;
0128
0129 virtual int status() const = 0;
0130
0131 virtual void setStatus(int status) = 0;
0132
0133 virtual void setLongLived() = 0;
0134
0135 virtual bool longLived() const = 0;
0136
0137 virtual void setMassConstraint() = 0;
0138
0139 virtual bool massConstraint() const = 0;
0140
0141 virtual Candidate* clone() const = 0;
0142
0143 const_iterator begin() const { return const_iterator(this, 0); }
0144
0145 const_iterator end() const { return const_iterator(this, numberOfDaughters()); }
0146
0147 iterator begin() { return iterator(this, 0); }
0148
0149 iterator end() { return iterator(this, numberOfDaughters()); }
0150
0151 virtual size_type numberOfDaughters() const = 0;
0152
0153 virtual const Candidate* daughter(size_type i) const = 0;
0154
0155 virtual Candidate* daughter(size_type i) = 0;
0156
0157 virtual Candidate* daughter(const std::string& s) = 0;
0158
0159 virtual const Candidate* daughter(const std::string& s) const = 0;
0160
0161 virtual size_type numberOfMothers() const = 0;
0162
0163 virtual const Candidate* mother(size_type i = 0) const = 0;
0164
0165
0166 virtual size_t numberOfSourceCandidatePtrs() const = 0;
0167
0168
0169 virtual CandidatePtr sourceCandidatePtr(size_type i) const { return CandidatePtr(); }
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179 virtual void setSourceCandidatePtr(const CandidatePtr& ptr) {}
0180
0181
0182 virtual double vertexChi2() const = 0;
0183
0184
0185
0186
0187
0188
0189 virtual double vertexNdof() const = 0;
0190
0191 virtual double vertexNormalizedChi2() const = 0;
0192
0193 virtual double vertexCovariance(int i, int j) const = 0;
0194
0195 virtual CovarianceMatrix vertexCovariance() const {
0196 CovarianceMatrix m;
0197 fillVertexCovariance(m);
0198 return m;
0199 }
0200 virtual void fillVertexCovariance(CovarianceMatrix& v) const = 0;
0201
0202
0203 virtual bool hasMasterClone() const = 0;
0204
0205
0206 virtual const CandidateBaseRef& masterClone() const = 0;
0207
0208
0209 virtual bool hasMasterClonePtr() const = 0;
0210
0211
0212 virtual const CandidatePtr& masterClonePtr() const = 0;
0213
0214 template <typename Ref>
0215 Ref masterRef() const {
0216 return masterClone().template castTo<Ref>();
0217 }
0218
0219
0220 template <typename T>
0221 T get() const {
0222 if (hasMasterClone())
0223 return masterClone()->get<T>();
0224 else
0225 return reco::get<T>(*this);
0226 }
0227
0228 template <typename T, typename Tag>
0229 T get() const {
0230 if (hasMasterClone())
0231 return masterClone()->get<T, Tag>();
0232 else
0233 return reco::get<T, Tag>(*this);
0234 }
0235
0236 template <typename T>
0237 T get(size_type i) const {
0238 if (hasMasterClone())
0239 return masterClone()->get<T>(i);
0240 else
0241 return reco::get<T>(*this, i);
0242 }
0243
0244 template <typename T, typename Tag>
0245 T get(size_type i) const {
0246 if (hasMasterClone())
0247 return masterClone()->get<T, Tag>(i);
0248 else
0249 return reco::get<T, Tag>(*this, i);
0250 }
0251
0252 template <typename T>
0253 size_type numberOf() const {
0254 if (hasMasterClone())
0255 return masterClone()->numberOf<T>();
0256 else
0257 return reco::numberOf<T>(*this);
0258 }
0259
0260 template <typename T, typename Tag>
0261 size_type numberOf() const {
0262 if (hasMasterClone())
0263 return masterClone()->numberOf<T, Tag>();
0264 else
0265 return reco::numberOf<T, Tag>(*this);
0266 }
0267
0268 virtual const Track* bestTrack() const { return nullptr; }
0269
0270
0271 virtual float dzError() const {
0272 return 0;
0273 }
0274
0275 virtual float dxyError() const {
0276 return 0;
0277 }
0278
0279 virtual bool isElectron() const = 0;
0280 virtual bool isMuon() const = 0;
0281 virtual bool isStandAloneMuon() const = 0;
0282 virtual bool isGlobalMuon() const = 0;
0283 virtual bool isTrackerMuon() const = 0;
0284 virtual bool isCaloMuon() const = 0;
0285 virtual bool isPhoton() const = 0;
0286 virtual bool isConvertedPhoton() const = 0;
0287 virtual bool isJet() const = 0;
0288
0289 protected:
0290
0291 virtual bool overlap(const Candidate&) const = 0;
0292 template <typename, typename, typename>
0293 friend struct component;
0294 friend class ::OverlapChecker;
0295 friend class ShallowCloneCandidate;
0296 friend class ShallowClonePtrCandidate;
0297 };
0298
0299 namespace candidate {
0300
0301 const_iterator::reference const_iterator::operator*() const { return *(me->daughter(i)); }
0302 iterator::reference iterator::operator*() const { return *(me->daughter(i)); }
0303
0304 }
0305
0306 }
0307
0308 #endif