CMS 3D CMS Logo

CompositeRefCandidateT.h
Go to the documentation of this file.
1 #ifndef Candidate_CompositeRefCandidateT_h
2 #define Candidate_CompositeRefCandidateT_h
3 
15 
16 namespace reco {
17 
18  template<typename D>
20  public:
22  typedef D daughters;
24  typedef D mothers;
28  CompositeRefCandidateT( Charge q, const LorentzVector & p4, const Point & vtx = Point( 0, 0, 0 ),
29  int pdgId = 0, int status = 0, bool integerCharge = true ) :
30  LeafCandidate( q, p4, vtx, pdgId, status, integerCharge ) { }
32  CompositeRefCandidateT( Charge q, const PolarLorentzVector & p4, const Point & vtx = Point( 0, 0, 0 ),
33  int pdgId = 0, int status = 0, bool integerCharge = true ) :
34  LeafCandidate( q, p4, vtx, pdgId, status, integerCharge ) { }
36  explicit CompositeRefCandidateT( const LeafCandidate& c ) : LeafCandidate( c ) { }
38  ~CompositeRefCandidateT() override;
40  CompositeRefCandidateT<D> * clone() const override;
42  size_t numberOfDaughters() const override;
44  size_t numberOfMothers() const override;
46  const Candidate * daughter(size_type) const override;
47  using ::reco::LeafCandidate::daughter; // avoid hiding the base
49  const Candidate * mother(size_type = 0) const override;
51  Candidate * daughter(size_type) override;
53  void addDaughter( const typename daughters::value_type & );
55  void addMother( const typename mothers::value_type & );
57  void clearDaughters() { dau.clear(); }
59  void clearMothers() { mom.clear(); }
61  typename daughters::value_type daughterRef( size_type i ) const { return dau[ i ]; }
63  const daughters & daughterRefVector() const { return dau; }
65  typename daughters::value_type motherRef( size_type i = 0 ) const { return mom[ i ]; }
67  const mothers & motherRefVector() const { return mom; }
69  void resetDaughters( const edm::ProductID & id ) { dau = daughters( id ); }
71  void resetMothers( const edm::ProductID & id ) { mom = mothers( id ); }
72 
74 
75  private:
77  daughters dau;
79  daughters mom;
81  bool overlap( const Candidate & ) const override;
82  };
83 
84  template<typename D>
85  inline void CompositeRefCandidateT<D>::addDaughter( const typename daughters::value_type & cand ) {
86  dau.push_back( cand );
87  }
88 
89  template<typename D>
90  inline void CompositeRefCandidateT<D>::addMother( const typename daughters::value_type & cand ) {
91  mom.push_back( cand );
92  }
93 
94  template<typename D>
96  }
97 
98  template<typename D>
100  return new CompositeRefCandidateT( * this );
101  }
102 
103  template<typename D>
105  return ( i < numberOfDaughters() ) ? & * dau[ i ] : nullptr;
106  }
107 
108  template<typename D>
110  return ( i < numberOfMothers() ) ? & * mom[ i ] : nullptr;
111  }
112 
113  template<typename D>
115  return nullptr;
116  }
117 
118  template<typename D>
120  return dau.size();
121  }
122 
123  template<typename D>
125  return mom.size();
126  }
127 
128  template<typename D>
129  bool CompositeRefCandidateT<D>::overlap( const Candidate & c2 ) const {
130  throw cms::Exception( "Error" ) << "can't check overlap internally for CompositeRefCanddate";
131  }
132 }
133 
134 #endif
bool overlap(const Candidate &) const override
check overlap with another candidate
int pdgId() const final
PDG identifier.
const Candidate * daughter(size_type) const override
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
int Charge
electric charge type
Definition: Candidate.h:35
daughters::value_type daughterRef(size_type i) const
reference to daughter at given position
CompositeRefCandidateT(const LeafCandidate &c)
constructor from a particle
size_t size_type
Definition: Candidate.h:30
daughters mom
collection of references to mothers
size_t numberOfMothers() const override
number of mothers
const daughters & daughterRefVector() const
references to daughtes
#define CMS_CLASS_VERSION(_version_)
Definition: classes.h:31
void clearDaughters()
clear daughter references
void addDaughter(const typename daughters::value_type &)
add a daughter via a reference
void resetDaughters(const edm::ProductID &id)
set daughters product ID
void push_back(D *&d)
Definition: OwnVector.h:290
const mothers & motherRefVector() const
references to mothers
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:520
CompositeRefCandidateT(Charge q, const PolarLorentzVector &p4, const Point &vtx=Point(0, 0, 0), int pdgId=0, int status=0, bool integerCharge=true)
constructor from values
const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
daughters::value_type motherRef(size_type i=0) const
reference to mother at given position
void addMother(const typename mothers::value_type &)
add a daughter via a reference
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:151
size_t numberOfDaughters() const override
number of daughters
~CompositeRefCandidateT() override
destructor
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
fixed size matrix
daughters dau
collection of references to daughters
D daughters
collection of references to daughters
int status() const final
status word
CompositeRefCandidateT()
default constructor
math::XYZPoint Point
point in the space
Definition: Candidate.h:41
D mothers
collection of references to daughters
void resetMothers(const edm::ProductID &id)
set mother product ID
CompositeRefCandidateT(Charge q, const LorentzVector &p4, const Point &vtx=Point(0, 0, 0), int pdgId=0, int status=0, bool integerCharge=true)
constructor from values
void clearMothers()
clear mother references
const Candidate * mother(size_type=0) const override
return mother at a given position, i = 0, ... numberOfMothers() - 1 (read only mode) ...
CompositeRefCandidateT< D > * clone() const override
returns a clone of the candidate
math::XYZPoint Point
point in the space
Definition: LeafCandidate.h:27
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:39