Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:48

0001 #ifndef Candidate_CompositePtrCandidate_h
0002 #define Candidate_CompositePtrCandidate_h
0003 #include "DataFormats/Candidate/interface/LeafCandidate.h"
0004 /** \class reco::CompositePtrCandidate
0005  *
0006  * a reco::Candidate composed of daughters. 
0007  * The daughters has persistent references (edm::Ptr <...>) 
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 CompositePtrCandidate : public LeafCandidate {
0018   public:
0019     /// collection of references to daughters
0020     typedef std::vector<CandidatePtr> daughters;
0021     /// collection of references to daughters
0022     typedef std::vector<CandidatePtr> mothers;
0023     /// default constructor
0024     CompositePtrCandidate() : LeafCandidate() {}
0025     /// constructor from values
0026     CompositePtrCandidate(Charge q,
0027                           const LorentzVector& p4,
0028                           const Point& vtx = Point(0, 0, 0),
0029                           int pdgId = 0,
0030                           int status = 0,
0031                           bool integerCharge = true)
0032         : LeafCandidate(q, p4, vtx, pdgId, status, integerCharge) {}
0033     /// constructor from values
0034     CompositePtrCandidate(Charge q,
0035                           const PolarLorentzVector& p4,
0036                           const Point& vtx = Point(0, 0, 0),
0037                           int pdgId = 0,
0038                           int status = 0,
0039                           bool integerCharge = true)
0040         : LeafCandidate(q, p4, vtx, pdgId, status, integerCharge) {}
0041     /// constructor from a Candidate
0042     explicit CompositePtrCandidate(const Candidate& p) : LeafCandidate(p) {}
0043     /// destructor
0044     ~CompositePtrCandidate() override;
0045     /// returns a clone of the candidate
0046     CompositePtrCandidate* clone() const override;
0047     /// number of daughters
0048     size_t numberOfDaughters() const override;
0049     /// number of mothers
0050     size_t numberOfMothers() const override;
0051     /// return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode)
0052     const Candidate* daughter(size_type) const override;
0053     using reco::LeafCandidate::daughter;  // avoid hiding the base
0054     /// return daughter at a given position, i = 0, ... numberOfDaughters() - 1
0055     Candidate* daughter(size_type) override;
0056     /// add a daughter via a reference
0057     void addDaughter(const CandidatePtr&);
0058     /// clear daughter references
0059     virtual void clearDaughters() { dau.clear(); }
0060     /// reference to daughter at given position
0061     virtual CandidatePtr daughterPtr(size_type i) const { return dau[i]; }
0062     /// references to daughtes
0063     virtual const daughters& daughterPtrVector() const { return dau; }
0064     /// return pointer to mother
0065     const Candidate* mother(size_t i = 0) const override;
0066     /// number of source candidates
0067     /// ( the candidates used to construct this Candidate).
0068     /// for CompositeRefBaseCandidates, the source candidates
0069     /// are the daughters.
0070     size_type numberOfSourceCandidatePtrs() const override;
0071     /// return a RefToBase to one of the source Candidates
0072     /// ( the candidates used to construct this Candidate).
0073     /// for CompositeRefBaseCandidates, the source candidates
0074     /// are the daughters.
0075     CandidatePtr sourceCandidatePtr(size_type i) const override;
0076 
0077   private:
0078     /// collection of references to daughters
0079     daughters dau;
0080     /// check overlap with another candidate
0081     bool overlap(const Candidate&) const override;
0082   };
0083 
0084   inline void CompositePtrCandidate::addDaughter(const CandidatePtr& cand) { dau.push_back(cand); }
0085 
0086 }  // namespace reco
0087 
0088 #endif