File indexing completed on 2024-04-06 12:03:48
0001 #ifndef Candidate_CandidateWithRef_h
0002 #define Candidate_CandidateWithRef_h
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include "DataFormats/Candidate/interface/Candidate.h"
0012 #include "DataFormats/Candidate/interface/LeafCandidate.h"
0013 #include "DataFormats/Common/interface/RefToBase.h"
0014
0015 namespace reco {
0016
0017 template <typename Ref>
0018 class CandidateWithRef : public LeafCandidate {
0019 public:
0020 typedef Ref reference;
0021
0022 CandidateWithRef() : LeafCandidate() {}
0023
0024 CandidateWithRef(const LorentzVector &p4, Charge q = 0, const Point &vtx = Point(0, 0, 0))
0025 : LeafCandidate(q, p4, vtx) {}
0026
0027 ~CandidateWithRef() override;
0028
0029 CandidateWithRef *clone() const override;
0030
0031 void setRef(const Ref &r) { ref_ = r; }
0032
0033 reference ref() const { return ref_; }
0034
0035 CMS_CLASS_VERSION(13)
0036
0037 private:
0038
0039 bool overlap(const Candidate &) const override;
0040
0041 reference ref_;
0042 };
0043
0044
0045
0046
0047 template <typename Ref>
0048 CandidateWithRef<Ref>::~CandidateWithRef() {}
0049
0050 template <typename Ref>
0051 CandidateWithRef<Ref> *CandidateWithRef<Ref>::clone() const {
0052 return new CandidateWithRef<Ref>(*this);
0053 }
0054
0055 template <typename Ref>
0056 bool CandidateWithRef<Ref>::overlap(const Candidate &c) const {
0057 const CandidateWithRef *o = dynamic_cast<const CandidateWithRef *>(&c);
0058 if (o == nullptr)
0059 return false;
0060 if (ref().isNull())
0061 return false;
0062 if (o->ref().isNull())
0063 return false;
0064 return (ref() != o->ref());
0065 }
0066
0067 }
0068
0069 #endif