BOSS 7.0.7
BESIII Offline Software System
Loading...
Searching...
No Matches
DecayList.h
Go to the documentation of this file.
1#ifndef DCHAIN_DECAYLIST_H
2#define DCHAIN_DECAYLIST_H
3// -*- C++ -*-
4//
5// Package: DChain
6// Module: DecayList
7//
8// Description: container of subclasses of Decay, used for iteration
9//
10// Usage:
11// <usage>
12//
13// Author: Simon Patton
14// Created: Fri Oct 4 11:04:47 EDT 1996
15// $Id: DecayList.h,v 1.1.1.1 2009/03/03 06:06:56 maqm Exp $
16//
17// Revision history
18//
19// $Log: DecayList.h,v $
20// Revision 1.1.1.1 2009/03/03 06:06:56 maqm
21// first import of DecayChain
22//
23// Revision 1.2 2006/04/09 13:32:10 cdj
24// added back missing operator+
25//
26// Revision 1.1 2006/01/11 20:28:27 cdj
27// massive class renaming, addition of [] for selection and unit tests
28//
29//
30
31// system include files
32#include <assert.h>
33#include <iostream>
34
35// user include files
36#include "DecayChain/List/ConjugateList.h" // superclass declaration
43
44namespace dchain {
45 template < class DecayClass , class CandidateClass > class LabeledParticleList ;template < class DecayClass > class MuteWholeItr ;
46 template < class DecayClass > class WholeItr ;
47 template < class DecayClass > class PartialItr ;
48}
49
50namespace dchain {
51 template < class CandidateClass > class CombinatoricList ;
52 template < class DecayClass , class CandidateClass > class DecayList;
53
54template < class DecayClass , class CandidateClass >
58template < class DecayClass , class CandidateClass, class NeutralClass >
61 const NeutralVisibleList< NeutralClass >& iList2 );
62template < class DecayClass , class CandidateClass, class NeutralClass >
64 const NeutralVisibleList< NeutralClass >& iList1 ,
66//
67// Note: To avoid a myriad of conpiler flags it is easier to
68// have a two parameter template class. The instantiation
69// of this class must look like
70//
71// template class DCDecayList< A , A::CandidateClass > ;
72
73template < class DecayClass , class CandidateClass = typename DecayClass::CandidateClass >
74class DecayList : public ConjugateList< CandidateClass >
75{
76 // friend classses and functions
77 friend DecayList< DecayClass, CandidateClass > operator+ <DecayClass, CandidateClass> (
80
81 public:
82 // constants, enums and typedefs
86
87 typedef DecayClass value_type ;
88
90
91 // Constructors and destructor
92 DecayList();
93 // need this function to stop default copy constructor
94 DecayList( const self_type& aOtherList);
95 virtual ~DecayList() ;
96
97 // assignment operator(s)
98 // need this function to stop default assignment operator
99 template< class TDecay>
101 m_list->erase( m_list->begin() ,
102 m_list->end() ) ;
103 fill( aOtherList, SelectAll<DecayClass>() ) ;
104 return ( *this ) ;
105 }
106
107 const self_type& operator=( const CombinatoricList< CandidateClass >& aOtherList );
108
110 //
111 template<class TList>
112 void operator+=( const TList& aOtherList) {
113
114 if(this->size() != 0 ) {
115 //only check compatable conjugation if something already in
116 // this list, otherwise could have problem with default value
117 bool can_only_add_lists_with_same_conjugation =
118 this->isSelfConjugate()== aOtherList.isSelfConjugate();
119 assert(can_only_add_lists_with_same_conjugation);
120 }
121 fill(aOtherList);
122 }
123
124 template<class TSelector>
127 }
128
129 // member functions
130 virtual iterator particle_begin() ;
131 virtual iterator particle_end() ;
132
133 // const member functions
136 virtual const_iterator particle_begin() const ;
137 virtual const_iterator particle_end() const ;
140 // The for following redeclarations are required because of function hidding
141 // ( See ARM p310 )
142 using ConjugateList< CandidateClass >::iterate;
143 template<class TAnalyze>
144 void iterate( const TAnalyze& analyze) const {
145 const_iterator finished ( particle_end() ) ;
146 for ( const_iterator entry ( particle_begin() ) ;
147 entry != finished ;
148 ++entry ) {
149 analyze( (*entry).particle() ) ;
150 }
151 }
152
153 template < class TAnalyzer>
154 void conjugation_iterate( const TAnalyzer& analyzer) const
155 {
156 const_iterator finished ( particle_end() ) ;
157 for ( const_iterator entry ( particle_begin() ) ;
158 entry != finished ;
159 ++entry ) {
160 analyze( (*entry)() , (*entry).label() == this->label() ) ;
161 }
162 }
163
164 template<class TAnalyze>
165 void iterate( TAnalyze& analyze) const {
166 const_iterator finished ( particle_end() ) ;
167 for ( const_iterator entry ( particle_begin() ) ;
168 entry != finished ;
169 ++entry ) {
170 analyze( (*entry).particle() ) ;
171 }
172 }
173
174 using ConjugateList< CandidateClass >::iterate;
175 template<class TAnalyze>
176 void partial_iterate( TAnalyze& analyze ) const
177 {
180 entry != finished ;
181 ++entry ) {
182 analyze( (*entry).particle() ) ;
183 }
184 }
185 void eraseContents() ;
186
187 void erase() {
189 }
190 // static member functions
191
192 DecayList(
194 conjugation::Label aLabel ) ;
195 protected:
196
197 // protected member functions
200
201 // protected const member functions
204 public:
205 template <class TSelect>
206 bool attempt_insert( DecayClass* pPossible ,
207 const conjugation::Label aLabel,
208 const TSelect& aSelect ) {
209 ReferenceHolder<DecayClass> pHolder( pPossible );
210 bool returnValue = aSelect(*pPossible);
211 if (returnValue) {
212 this->insert(pPossible,aLabel);
213 }
214 return returnValue;
215 }
216
217 template <class THolder>
218 void insert(THolder& pPossible,
219 const conjugation::Label aLabel) {
220 m_list->push_back( LabeledParticle< DecayClass >( pPossible ,
221 aLabel ) ) ;
222 }
223 // Constructors and destructor
224
225 // private member functions
226 template<class TDecayList, class TSelector>
227 void fill( const TDecayList& aList, const TSelector& aSel = SelectAll<DecayClass>() ) {
228 //std::cout << "@DecayList::fill()" << std::endl;
229 setLabel( aList.label() ) ;
230 typename TDecayList::const_iterator finished( aList.particle_end() ) ;
231 for ( typename TDecayList::const_iterator entry( aList.particle_begin() ) ;
232 entry != finished ;
233 ++entry ) {
234 //std::cout << "@ DecayList::fill()" << std::endl;
235 DecayClass* localCopy = new DecayClass( (*entry).particle() ) ;
236 attempt_insert( localCopy ,
237 (*entry).label(),
238 aSel ) ;
239 }
240 }
241
242 private:
243
244 // private const member functions
245
246 // data members
248} ;
249
250// inline function definitions
251
252
253
254#include <assert.h>
255
256template < class DecayClass , class CandidateClass >
257inline
261{
262 bool can_only_add_lists_with_same_conjugation =
263 iList1.isSelfConjugate()== iList2.isSelfConjugate();
264 assert(can_only_add_lists_with_same_conjugation);
265
266 DecayList< DecayClass, CandidateClass> returnValue( iList1 );
267 if( &iList1 != &iList2 ) {
268 returnValue.fill( iList2, SelectAll<DecayClass>() );
269 }
270 return returnValue;
271}
272
273template < class DecayClass , class CandidateClass, class NeutralClass >
274inline
278{
279 bool can_only_add_lists_with_same_conjugation =
280 iList1.isSelfConjugate()== iList2.isSelfConjugate();
281 assert(can_only_add_lists_with_same_conjugation);
282
283
284 DecayList< DecayClass, CandidateClass> returnValue =iList1 ;
287 entry != finished ;
288 ++entry ){
289 NeutralClass* localCopy = new NeutralClass( (*entry).particle() ) ;
290 returnValue.attempt_insert( localCopy, (*entry).label(),SelectAll<DecayClass>() ) ;
291 }
292 return returnValue;
293}
294
295
296template < class DecayClass , class CandidateClass, class NeutralClass >
297inline
301{
303 returnValue = iList2 + iList1;
304 return returnValue;
305}
306
307}
308
309// function definitions
311
312#endif /* DCHAIN_DECAYLIST_H */
virtual int size() const
void setLabel(const conjugation::Label aLabel)
virtual bool isSelfConjugate() const
bool attempt_insert(DecayClass *pPossible, const conjugation::Label aLabel, const TSelect &aSelect)
Definition: DecayList.h:206
WholeItr< DecayClass > const_iterator
Definition: DecayList.h:84
virtual const_partial_iterator partial_particle_begin() const
Definition: DecayList.cc:227
void iterate(TAnalyze &analyze) const
Definition: DecayList.h:165
virtual LabeledParticleList< DecayClass, CandidateClass > & labeledParticleList()
Definition: DecayList.cc:188
DecayList< DecayClass, CandidateClass > self_type
Definition: DecayList.h:89
void operator+=(const TList &aOtherList)
Definition: DecayList.h:112
void iterate(const TAnalyze &analyze) const
Definition: DecayList.h:144
void eraseContents()
Definition: DecayList.cc:243
MuteWholeItr< DecayClass > iterator
Definition: DecayList.h:83
virtual const_partial_iterator partial_particle_end() const
Definition: DecayList.cc:234
void partial_iterate(TAnalyze &analyze) const
Definition: DecayList.h:176
const DecayList< DecayClass, CandidateClass > bar() const
Definition: DecayList.cc:199
FillListWithSelection< self_type, TSelector > operator[](const TSelector &iSel)
Definition: DecayList.h:125
void insert(THolder &pPossible, const conjugation::Label aLabel)
Definition: DecayList.h:218
PartialItr< DecayClass > const_partial_iterator
Definition: DecayList.h:85
virtual iterator particle_begin()
Definition: DecayList.cc:169
virtual LabeledCandidateList< CandidateClass > & labeledCandidateList()
Definition: DecayList.cc:182
void conjugation_iterate(const TAnalyzer &analyzer) const
Definition: DecayList.h:154
DecayClass value_type
Definition: DecayList.h:87
virtual ~DecayList()
Definition: DecayList.cc:139
const DecayList< DecayClass, CandidateClass > & operator()() const
Definition: DecayList.cc:206
virtual iterator particle_end()
Definition: DecayList.cc:176
void fill(const TDecayList &aList, const TSelector &aSel=SelectAll< DecayClass >())
Definition: DecayList.h:227
const self_type & operator=(const DecayList< TDecay, CandidateClass > &aOtherList)
Definition: DecayList.h:100
DecayList< DecayClass, CandidateClass > operator+(const DecayList< DecayClass, CandidateClass > &iList1, const DecayList< DecayClass, CandidateClass > &iList2)
Definition: DecayList.h:258