Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:52:54

0001 #ifndef Candidate_CompositeRefBaseCandidate_h
0002 #define Candidate_CompositeRefBaseCandidate_h
0003 #include "DataFormats/Candidate/interface/LeafCandidate.h"
0004 /** \class reco::CompositeRefBaseCandidate
0005  *
0006  * a reco::Candidate composed of daughters. 
0007  * The daughters has persistent references (edm::RefToBase<...>) 
0008  * to reco::Candidate stored in a separate collection.
0009  *
0010  * \author Luca Lista, INFN
0011  *
0012  *
0013  */
0014 
0015 namespace reco {
0016 
0017   class CompositeRefBaseCandidate : public LeafCandidate {
0018   public:
0019     /// collection of references to daughters
0020     typedef std::vector<CandidateBaseRef> daughters;
0021     /// default constructor
0022     CompositeRefBaseCandidate() : LeafCandidate() {}
0023     /// constructor from values
0024     CompositeRefBaseCandidate(Charge q,
0025                               const LorentzVector& p4,
0026                               const Point& vtx = Point(0, 0, 0),
0027                               int pdgId = 0,
0028                               int status = 0,
0029                               bool integerCharge = true)
0030         : LeafCandidate(q, p4, vtx, pdgId, status, integerCharge) {}
0031     /// constructor from values
0032     CompositeRefBaseCandidate(Charge q,
0033                               const PolarLorentzVector& p4,
0034                               const Point& vtx = Point(0, 0, 0),
0035                               int pdgId = 0,
0036                               int status = 0,
0037                               bool integerCharge = true)
0038         : LeafCandidate(q, p4, vtx, pdgId, status, integerCharge) {}
0039     /// constructor from a particle
0040     explicit CompositeRefBaseCandidate(const Candidate& c) : LeafCandidate(c) {}
0041     /// destructor
0042     ~CompositeRefBaseCandidate() override;
0043     /// returns a clone of the candidate
0044     CompositeRefBaseCandidate* clone() const override;
0045     /// number of daughters
0046     size_t numberOfDaughters() const override;
0047     /// number of mothers
0048     size_t numberOfMothers() const override;
0049     /// return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode)
0050     const Candidate* daughter(size_type) const override;
0051     /// return mother at a given position, i = 0, ... numberOfMothers() - 1 (read only mode)
0052     const Candidate* mother(size_type) const override;
0053     /// return daughter at a given position, i = 0, ... numberOfDaughters() - 1
0054     Candidate* daughter(size_type) override;
0055     using reco::LeafCandidate::daughter;  // avoid hiding the base
0056     /// add a daughter via a reference
0057     void addDaughter(const CandidateBaseRef&);
0058     /// clear daughter references
0059     void clearDaughters() { dau.clear(); }
0060     /// reference to daughter at given position
0061     CandidateBaseRef daughterRef(size_type i) const { return dau[i]; }
0062 
0063   private:
0064     /// collection of references to daughters
0065     daughters dau;
0066     /// check overlap with another candidate
0067     bool overlap(const Candidate&) const override;
0068   };
0069 
0070   inline void CompositeRefBaseCandidate::addDaughter(const CandidateBaseRef& cand) { dau.push_back(cand); }
0071 }  // namespace reco
0072 
0073 #endif