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 
16 
17 namespace reco {
18 
19  template<typename D>
21  public:
23  typedef D daughters;
25  typedef D mothers;
29  CompositeRefCandidateT( Charge q, const LorentzVector & p4, const Point & vtx = Point( 0, 0, 0 ),
30  int pdgId = 0, int status = 0, bool integerCharge = true ) :
31  LeafCandidate( q, p4, vtx, pdgId, status, integerCharge ) { }
33  CompositeRefCandidateT( Charge q, const PolarLorentzVector & p4, const Point & vtx = Point( 0, 0, 0 ),
34  int pdgId = 0, int status = 0, bool integerCharge = true ) :
35  LeafCandidate( q, p4, vtx, pdgId, status, integerCharge ) { }
37  explicit CompositeRefCandidateT( const LeafCandidate& c ) : LeafCandidate( c ) { }
39  virtual ~CompositeRefCandidateT();
41  virtual CompositeRefCandidateT<D> * clone() const;
43  virtual const_iterator begin() const;
45  virtual const_iterator end() const;
47  virtual iterator begin();
49  virtual iterator end();
51  virtual size_t numberOfDaughters() const;
53  virtual size_t numberOfMothers() const;
55  virtual const Candidate * daughter(size_type) const;
56  using ::reco::LeafCandidate::daughter; // avoid hiding the base
58  virtual const Candidate * mother(size_type = 0) const;
60  virtual Candidate * daughter(size_type);
62  void addDaughter( const typename daughters::value_type & );
64  void addMother( const typename mothers::value_type & );
66  void clearDaughters() { dau.clear(); }
68  void clearMothers() { mom.clear(); }
70  typename daughters::value_type daughterRef( size_type i ) const { return dau[ i ]; }
72  const daughters & daughterRefVector() const { return dau; }
74  typename daughters::value_type motherRef( size_type i = 0 ) const { return mom[ i ]; }
76  const mothers & motherRefVector() const { return mom; }
78  void resetDaughters( const edm::ProductID & id ) { dau = daughters( id ); }
80  void resetMothers( const edm::ProductID & id ) { mom = mothers( id ); }
81 
82 
83  private:
93  virtual bool overlap( const Candidate & ) const;
94  };
95 
96  template<typename D>
97  inline void CompositeRefCandidateT<D>::addDaughter( const typename daughters::value_type & cand ) {
98  dau.push_back( cand );
99  }
100 
101  template<typename D>
102  inline void CompositeRefCandidateT<D>::addMother( const typename daughters::value_type & cand ) {
103  mom.push_back( cand );
104  }
105 
106  template<typename D>
108  }
109 
110  template<typename D>
111  CompositeRefCandidateT<D> * CompositeRefCandidateT<D>::clone() const {
112  return new CompositeRefCandidateT( * this );
113  }
114 
115  template<typename D>
117  return const_iterator( new const_iterator_imp_specific( dau.begin() ) );
118  }
119 
120  template<typename D>
122  return const_iterator( new const_iterator_imp_specific( dau.end() ) );
123  }
124 
125  template<typename D>
127  return iterator( new iterator_imp_specific );
128  }
129 
130  template<typename D>
132  return iterator( new iterator_imp_specific );
133  }
134 
135  template<typename D>
137  return ( i < numberOfDaughters() ) ? & * dau[ i ] : 0;
138  }
139 
140  template<typename D>
142  return ( i < numberOfMothers() ) ? & * mom[ i ] : 0;
143  }
144 
145  template<typename D>
147  return 0;
148  }
149 
150  template<typename D>
152  return dau.size();
153  }
154 
155  template<typename D>
157  return mom.size();
158  }
159 
160  template<typename D>
161  bool CompositeRefCandidateT<D>::overlap( const Candidate & c2 ) const {
162  throw cms::Exception( "Error" ) << "can't check overlap internally for CompositeRefCanddate";
163  }
164 }
165 
166 #endif
int Charge
electric charge type
Definition: Candidate.h:36
int i
Definition: DBlmapReader.cc:9
virtual int pdgId() const
PDG identifier.
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:31
candidate::iterator_imp_specific_dummy< daughters > iterator_imp_specific
iterator implementation
candidate::const_iterator const_iterator
Definition: Candidate.h:32
virtual int status() const
status word
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 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:33
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:150
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:38
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:42
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 LorentzVector & p4() const
four-momentum Lorentz vector
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
math::XYZPoint Point
point in the space
Definition: LeafCandidate.h:29
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:40