Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:49:18

0001 #ifndef Candidate_ShallowClonePtrCandidate_h
0002 #define Candidate_ShallowClonePtrCandidate_h
0003 /** \class reco::ShallowClonePtrCandidate
0004  *
0005  * shallow clone of a particle candidate keepint a reference
0006  * to the master clone
0007  *
0008  * \author Luca Lista, INFN
0009  *
0010  *
0011  */
0012 #include "DataFormats/Candidate/interface/LeafCandidate.h"
0013 
0014 namespace reco {
0015   class ShallowClonePtrCandidate : public LeafCandidate {
0016   public:
0017     /// collection of daughter candidates
0018     typedef CandidateCollection daughters;
0019     /// default constructor
0020     ShallowClonePtrCandidate() : LeafCandidate() {}
0021     /// constructor from Particle
0022     explicit ShallowClonePtrCandidate(const CandidatePtr& masterClone)
0023         : LeafCandidate(*masterClone), masterClone_(masterClone) {}
0024     /// constructor from values
0025     ShallowClonePtrCandidate(const CandidatePtr& masterClone,
0026                              Charge q,
0027                              const LorentzVector& p4,
0028                              const Point& vtx = Point(0, 0, 0))
0029         : LeafCandidate(q, p4, vtx), masterClone_(masterClone) {}
0030     /// constructor from values
0031     ShallowClonePtrCandidate(const CandidatePtr& masterClone,
0032                              Charge q,
0033                              const PolarLorentzVector& p4,
0034                              const Point& vtx = Point(0, 0, 0))
0035         : LeafCandidate(q, p4, vtx), masterClone_(masterClone) {}
0036     /// destructor
0037     ~ShallowClonePtrCandidate() override;
0038     /// returns a clone of the Candidate object
0039     ShallowClonePtrCandidate* clone() const override;
0040     /// number of daughters
0041     size_t numberOfDaughters() const override;
0042     /// number of mothers
0043     size_t numberOfMothers() const override;
0044     /// return daughter at a given position (throws an exception)
0045     const Candidate* daughter(size_type i) const override;
0046     /// return mother at a given position (throws an exception)
0047     const Candidate* mother(size_type i) const override;
0048     /// return daughter at a given position (throws an exception)
0049     Candidate* daughter(size_type i) override;
0050     using reco::LeafCandidate::daughter;  // avoid hiding the base
0051     /// has master clone pointer
0052     bool hasMasterClonePtr() const override;
0053     /// returns reference to master clone pointer
0054     const CandidatePtr& masterClonePtr() const override;
0055 
0056     bool isElectron() const override;
0057     bool isMuon() const override;
0058     bool isGlobalMuon() const override;
0059     bool isStandAloneMuon() const override;
0060     bool isTrackerMuon() const override;
0061     bool isCaloMuon() const override;
0062     bool isPhoton() const override;
0063     bool isConvertedPhoton() const override;
0064     bool isJet() const override;
0065 
0066   private:
0067     /// check overlap with another Candidate
0068     bool overlap(const Candidate& c) const override { return masterClone_->overlap(c); }
0069     /// CandidatePtrerence to master clone
0070     CandidatePtr masterClone_;
0071   };
0072 
0073 }  // namespace reco
0074 
0075 #endif