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  virtual ~CompositeRefCandidateT();
40  virtual CompositeRefCandidateT<D> * clone() const;
42  virtual size_t numberOfDaughters() const;
44  virtual size_t numberOfMothers() const;
46  virtual const Candidate * daughter(size_type) const;
47  using ::reco::LeafCandidate::daughter; // avoid hiding the base
49  virtual const Candidate * mother(size_type = 0) const;
51  virtual Candidate * daughter(size_type);
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  virtual bool overlap( const Candidate & ) const;
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 ] : 0;
106  }
107 
108  template<typename D>
110  return ( i < numberOfMothers() ) ? & * mom[ i ] : 0;
111  }
112 
113  template<typename D>
115  return 0;
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
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
virtual bool overlap(const Candidate &) const
check overlap with another candidate
virtual ~CompositeRefCandidateT()
destructor
const daughters & daughterRefVector() const
references to daughtes
virtual int status() const final
status word
#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
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) ...
virtual int pdgId() const final
PDG identifier.
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
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
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
virtual CompositeRefCandidateT< D > * clone() const
returns a clone of the candidate
fixed size matrix
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:41
D mothers
collection of references to daughters
void resetMothers(const edm::ProductID &id)
set mother product ID
virtual const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
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
math::XYZPoint Point
point in the space
Definition: LeafCandidate.h:27
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:39