File indexing completed on 2024-04-06 12:03:48
0001 #ifndef Candidate_CompositeRefCandidateT_h
0002 #define Candidate_CompositeRefCandidateT_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include "DataFormats/Candidate/interface/LeafCandidate.h"
0014 #include "DataFormats/Common/interface/CMS_CLASS_VERSION.h"
0015
0016 namespace reco {
0017
0018 template <typename D>
0019 class CompositeRefCandidateT : public LeafCandidate {
0020 public:
0021
0022 typedef D daughters;
0023
0024 typedef D mothers;
0025
0026 CompositeRefCandidateT() : LeafCandidate() {}
0027
0028 CompositeRefCandidateT(Charge q,
0029 const LorentzVector& p4,
0030 const Point& vtx = Point(0, 0, 0),
0031 int pdgId = 0,
0032 int status = 0,
0033 bool integerCharge = true)
0034 : LeafCandidate(q, p4, vtx, pdgId, status, integerCharge) {}
0035
0036 CompositeRefCandidateT(Charge q,
0037 const PolarLorentzVector& p4,
0038 const Point& vtx = Point(0, 0, 0),
0039 int pdgId = 0,
0040 int status = 0,
0041 bool integerCharge = true)
0042 : LeafCandidate(q, p4, vtx, pdgId, status, integerCharge) {}
0043
0044 explicit CompositeRefCandidateT(const LeafCandidate& c) : LeafCandidate(c) {}
0045
0046 ~CompositeRefCandidateT() override;
0047
0048 CompositeRefCandidateT<D>* clone() const override;
0049
0050 size_t numberOfDaughters() const override;
0051
0052 size_t numberOfMothers() const override;
0053
0054 const Candidate* daughter(size_type) const override;
0055 using ::reco::LeafCandidate::daughter;
0056
0057 const Candidate* mother(size_type = 0) const override;
0058
0059 Candidate* daughter(size_type) override;
0060
0061 void addDaughter(const typename daughters::value_type&);
0062
0063 void addMother(const typename mothers::value_type&);
0064
0065 void clearDaughters() { dau.clear(); }
0066
0067 void clearMothers() { mom.clear(); }
0068
0069 typename daughters::value_type daughterRef(size_type i) const { return dau[i]; }
0070
0071 const daughters& daughterRefVector() const { return dau; }
0072
0073 typename daughters::value_type motherRef(size_type i = 0) const { return mom[i]; }
0074
0075 const mothers& motherRefVector() const { return mom; }
0076
0077 void resetDaughters(const edm::ProductID& id) { dau = daughters(id); }
0078
0079 void resetMothers(const edm::ProductID& id) { mom = mothers(id); }
0080
0081 CMS_CLASS_VERSION(13)
0082
0083 private:
0084
0085 daughters dau;
0086
0087 daughters mom;
0088
0089 bool overlap(const Candidate&) const override;
0090 };
0091
0092 template <typename D>
0093 inline void CompositeRefCandidateT<D>::addDaughter(const typename daughters::value_type& cand) {
0094 dau.push_back(cand);
0095 }
0096
0097 template <typename D>
0098 inline void CompositeRefCandidateT<D>::addMother(const typename daughters::value_type& cand) {
0099 mom.push_back(cand);
0100 }
0101
0102 template <typename D>
0103 CompositeRefCandidateT<D>::~CompositeRefCandidateT() {}
0104
0105 template <typename D>
0106 CompositeRefCandidateT<D>* CompositeRefCandidateT<D>::clone() const {
0107 return new CompositeRefCandidateT(*this);
0108 }
0109
0110 template <typename D>
0111 const Candidate* CompositeRefCandidateT<D>::daughter(size_type i) const {
0112 return (i < numberOfDaughters()) ? &*dau[i] : nullptr;
0113 }
0114
0115 template <typename D>
0116 const Candidate* CompositeRefCandidateT<D>::mother(size_type i) const {
0117 return (i < numberOfMothers()) ? &*mom[i] : nullptr;
0118 }
0119
0120 template <typename D>
0121 Candidate* CompositeRefCandidateT<D>::daughter(size_type i) {
0122 return nullptr;
0123 }
0124
0125 template <typename D>
0126 size_t CompositeRefCandidateT<D>::numberOfDaughters() const {
0127 return dau.size();
0128 }
0129
0130 template <typename D>
0131 size_t CompositeRefCandidateT<D>::numberOfMothers() const {
0132 return mom.size();
0133 }
0134
0135 template <typename D>
0136 bool CompositeRefCandidateT<D>::overlap(const Candidate& c2) const {
0137 throw cms::Exception("Error") << "can't check overlap internally for CompositeRefCanddate";
0138 }
0139 }
0140
0141 #endif