CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  virtual ~CompositeRefCandidateT();
40  virtual CompositeRefCandidateT<D> * clone() const;
42  virtual const_iterator begin() const;
44  virtual const_iterator end() const;
46  virtual iterator begin();
48  virtual iterator end();
50  virtual size_t numberOfDaughters() const;
52  virtual size_t numberOfMothers() const;
54  virtual const Candidate * daughter(size_type) const;
55  using ::reco::LeafCandidate::daughter; // avoid hiding the base
57  virtual const Candidate * mother(size_type = 0) const;
59  virtual Candidate * daughter(size_type);
61  void addDaughter( const typename daughters::value_type & );
63  void addMother( const typename mothers::value_type & );
65  void clearDaughters() { dau.clear(); }
67  void clearMothers() { mom.clear(); }
69  typename daughters::value_type daughterRef( size_type i ) const { return dau[ i ]; }
71  const daughters & daughterRefVector() const { return dau; }
73  typename daughters::value_type motherRef( size_type i = 0 ) const { return mom[ i ]; }
75  const mothers & motherRefVector() const { return mom; }
77  void resetDaughters( const edm::ProductID & id ) { dau = daughters( id ); }
79  void resetMothers( const edm::ProductID & id ) { mom = mothers( id ); }
80 
81 
82  private:
92  virtual bool overlap( const Candidate & ) const;
93  };
94 
95  template<typename D>
96  inline void CompositeRefCandidateT<D>::addDaughter( const typename daughters::value_type & cand ) {
97  dau.push_back( cand );
98  }
99 
100  template<typename D>
101  inline void CompositeRefCandidateT<D>::addMother( const typename daughters::value_type & cand ) {
102  mom.push_back( cand );
103  }
104 
105  template<typename D>
107  }
108 
109  template<typename D>
110  CompositeRefCandidateT<D> * CompositeRefCandidateT<D>::clone() const {
111  return new CompositeRefCandidateT( * this );
112  }
113 
114  template<typename D>
116  return const_iterator( new const_iterator_imp_specific( dau.begin() ) );
117  }
118 
119  template<typename D>
121  return const_iterator( new const_iterator_imp_specific( dau.end() ) );
122  }
123 
124  template<typename D>
126  return iterator( new iterator_imp_specific );
127  }
128 
129  template<typename D>
131  return iterator( new iterator_imp_specific );
132  }
133 
134  template<typename D>
136  return ( i < numberOfDaughters() ) ? & * dau[ i ] : 0;
137  }
138 
139  template<typename D>
141  return ( i < numberOfMothers() ) ? & * mom[ i ] : 0;
142  }
143 
144  template<typename D>
146  return 0;
147  }
148 
149  template<typename D>
151  return dau.size();
152  }
153 
154  template<typename D>
156  return mom.size();
157  }
158 
159  template<typename D>
160  bool CompositeRefCandidateT<D>::overlap( const Candidate & c2 ) const {
161  throw cms::Exception( "Error" ) << "can't check overlap internally for CompositeRefCanddate";
162  }
163 }
164 
165 #endif
int Charge
electric charge type
Definition: Candidate.h:39
int i
Definition: DBlmapReader.cc:9
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:34
virtual const LorentzVector & p4() const GCC11_FINAL
four-momentum Lorentz vector
candidate::iterator_imp_specific_dummy< daughters > iterator_imp_specific
iterator implementation
candidate::const_iterator const_iterator
Definition: Candidate.h:35
virtual int pdgId() const GCC11_FINAL
PDG identifier.
daughters mom
collection of references to mothers
virtual bool overlap(const Candidate &) const
check overlap with another candidate
virtual ~CompositeRefCandidateT()
destructor
const daughters & daughterRefVector() const
references to daughtes
uint16_t size_type
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
virtual int status() const GCC11_FINAL
status word
virtual const_iterator begin() const
first daughter const_iterator
const mothers & motherRefVector() const
references to mothers
virtual size_t numberOfMothers() const
number of mothers
virtual size_t numberOfDaughters() const
number of daughters
virtual const Candidate * daughter(size_type) const
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
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
Container::value_type value_type
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
candidate::iterator iterator
Definition: Candidate.h:36
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:41
virtual CompositeRefCandidateT< D > * clone() const
returns a clone of the candidate
candidate::const_iterator_imp_specific< daughters > const_iterator_imp_specific
const iterator implementation
daughters dau
collection of references to daughters
D daughters
collection of references to daughters
CompositeRefCandidateT()
default constructor
math::XYZPoint Point
point in the space
Definition: Candidate.h:45
D mothers
collection of references to daughters
void resetMothers(const edm::ProductID &id)
set mother product ID
virtual const_iterator end() const
last daughter const_iterator
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
virtual const Candidate * mother(size_type=0) const
return mother at a given position, i = 0, ... numberOfMothers() - 1 (read only mode) ...
void clearMothers()
clear mother references
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:150
math::XYZPoint Point
point in the space
Definition: LeafCandidate.h:30
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:43