Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef Candidate_ShallowCloneCandidate_h
0002 #define Candidate_ShallowCloneCandidate_h
0003 /** \class reco::ShallowCloneCandidate
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 ShallowCloneCandidate : public LeafCandidate {
0016   public:
0017     /// collection of daughter candidates
0018     typedef CandidateCollection daughters;
0019     /// default constructor
0020     ShallowCloneCandidate() : LeafCandidate() {}
0021     /// constructor from Particle
0022     explicit ShallowCloneCandidate(const CandidateBaseRef& masterClone)
0023         : LeafCandidate(*masterClone),
0024           masterClone_(masterClone->hasMasterClone() ? masterClone->masterClone() : masterClone) {}
0025     /// constructor from values
0026     ShallowCloneCandidate(const CandidateBaseRef& masterClone,
0027                           Charge q,
0028                           const LorentzVector& p4,
0029                           const Point& vtx = Point(0, 0, 0))
0030         : LeafCandidate(q, p4, vtx), masterClone_(masterClone) {}
0031     /// constructor from values
0032     ShallowCloneCandidate(const CandidateBaseRef& masterClone,
0033                           Charge q,
0034                           const PolarLorentzVector& p4,
0035                           const Point& vtx = Point(0, 0, 0))
0036         : LeafCandidate(q, p4, vtx), masterClone_(masterClone) {}
0037     /// destructor
0038     ~ShallowCloneCandidate() override;
0039     /// returns a clone of the Candidate object
0040     ShallowCloneCandidate* clone() const override;
0041     /// number of daughters
0042     size_t numberOfDaughters() const override;
0043     /// number of daughters
0044     size_t numberOfMothers() const override;
0045     /// return daughter at a given position (throws an exception)
0046     const Candidate* daughter(size_type i) const override;
0047     /// return daughter at a given position (throws an exception)
0048     const Candidate* mother(size_type i) const override;
0049     /// return daughter at a given position (throws an exception)
0050     Candidate* daughter(size_type i) override;
0051     using reco::LeafCandidate::daughter;  // avoid hiding the base
0052     /// has master clone
0053     bool hasMasterClone() const override;
0054     /// returns reference to master clone
0055     const CandidateBaseRef& masterClone() const override;
0056 
0057     bool isElectron() const override;
0058     bool isMuon() const override;
0059     bool isGlobalMuon() const override;
0060     bool isStandAloneMuon() const override;
0061     bool isTrackerMuon() const override;
0062     bool isCaloMuon() const override;
0063     bool isPhoton() const override;
0064     bool isConvertedPhoton() const override;
0065     bool isJet() const override;
0066 
0067   private:
0068     /// check overlap with another Candidate
0069     bool overlap(const Candidate& c) const override { return masterClone_->overlap(c); }
0070     /// CandidateBaseReference to master clone
0071     CandidateBaseRef masterClone_;
0072   };
0073 
0074 }  // namespace reco
0075 
0076 #endif