BOSS 7.0.7
BESIII Offline Software System
Loading...
Searching...
No Matches
DCDecayList.h
Go to the documentation of this file.
1#ifndef DCHAIN_DCDECAYLIST_H
2#define DCHAIN_DCDECAYLIST_H
3// -*- C++ -*-
4//
5// Package: DChain
6// Module: DCDecayList
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: DCDecayList.h,v 1.1.1.1 2009/03/03 06:06:56 maqm Exp $
16//
17// Revision history
18//
19// $Log: DCDecayList.h,v $
20// Revision 1.1.1.1 2009/03/03 06:06:56 maqm
21// first import of DecayChain
22//
23// Revision 1.16 2006/04/09 13:32:09 cdj
24// added back missing operator+
25//
26// Revision 1.15 2006/02/03 18:29:33 cdj
27// fixed bug in copy constructor and operator=
28//
29// Revision 1.14 2006/01/14 15:29:43 cdj
30// fixed missing symbol problem
31//
32// Revision 1.13 2006/01/13 18:10:15 cdj
33// improved backwards compatibility
34//
35// Revision 1.12 2006/01/11 20:28:24 cdj
36// massive class renaming, addition of [] for selection and unit tests
37//
38// Revision 1.11 2004/02/19 21:30:26 cdj
39// added operator+= to DecayList
40//
41// Revision 1.10 2003/10/23 18:43:39 cdj
42// can now use DCDecayList with other Decay objects
43//
44// Revision 1.9 2003/05/15 19:56:08 cdj
45// revamped memory handling so always use a ReferenceHolder to deal with the reference counting
46//
47// Revision 1.8 2002/06/19 20:36:03 cleo3
48// now compiles under Solaris 8
49//
50// Revision 1.7 2001/05/24 19:46:20 urner
51// first tag
52//
53// Revision 1.6 2001/04/12 13:43:58 urner
54// explicitely instantiated operator+ to make Solaris happy
55//
56// Revision 1.5 2001/04/10 13:56:45 urner
57// bug fixes
58//
59// Revision 1.4 2001/04/03 11:43:10 cdj
60// made operator+ a friend
61//
62// Revision 1.3 2001/03/30 16:34:53 cdj
63// added simplistic operator+
64//
65// Revision 1.2 2001/03/23 23:07:43 urner
66// modification needed to add pi0 eta and Ks decay lists in CleoDChain
67//
68// Revision 1.1.1.1 2000/12/18 22:16:52 cdj
69// imported DChain
70//
71// Revision 1.12 1998/08/27 04:56:07 sjp
72// Added value_type typedef
73//
74// Revision 1.11 1998/08/20 19:58:58 sjp
75// Modified to use DChainBoolean
76//
77// Revision 1.10 1998/08/19 20:38:03 sjp
78// Fixed include path for defintions
79//
80// Revision 1.9 1998/05/01 20:20:01 sjp
81// Removed unnecessary functions which were causing infinate loop
82//
83// Revision 1.8 1998/04/17 19:10:58 sjp
84// Modified to use latest types
85//
86// Revision 1.7 1997/08/28 06:59:42 sjp
87// Modified files to handle complete templating
88//
89// Revision 1.6 1997/08/15 21:32:05 sjp
90// Updated to use <package>/<file>.h include structure.
91// Updated to use bug flags specified in Experiement.h
92//
93// Revision 1.5 1997/01/31 20:16:58 sjp
94// Modified to use the new `bug' include files
95//
96// Revision 1.4 1997/01/22 16:27:06 sjp
97// Fixed error in pre-processor labels
98//
99// Revision 1.3 1997/01/21 20:34:07 sjp
100// Changed CPP flags and include because of library reorganization
101//
102// Revision 1.2 1996/12/20 21:19:25 sjp
103// Extended pathnames for Include files
104//
105// Revision 1.1 1996/11/04 19:36:12 sjp
106// New file for new `List' module
107//
108
109// system include files
110#include <assert.h>
111#include <iostream>
112
113// user include files
117
118template < class DecayClass , class CandidateClass >
119class DCDecayList;
120
121template < class DecayClass , class CandidateClass >
125template < class DecayClass , class CandidateClass, class NeutralClass >
129template < class DecayClass , class CandidateClass, class NeutralClass >
133
134template < class DecayClass , class CandidateClass >
135class DCDecayList : public dchain::DecayList<DecayClass, CandidateClass>
136{
137 // friend classses and functions
138
139 friend
140 DCDecayList< DecayClass, CandidateClass > operator+ <DecayClass, CandidateClass> (
143
144 public:
145 // constants, enums and typedefs
146 typedef DecayClass value_type ;
147
148 // Constructors and destructor
149 DCDecayList( bool ( * pFunction )( DecayClass& ) = 0 ) ;
150 // need this function to stop default copy constructor
152 bool ( * pFunction )( DecayClass& ) ) ;
153 DCDecayList( DCSelectionFunction< DecayClass >& aFunctionalObject ) ;
154
156 dchain::DecayList<DecayClass,CandidateClass>(
157 static_cast<dchain::DecayList<DecayClass,CandidateClass> >(iList)),
158 m_function(0), m_functionalObject(0) {}
159
161 dchain::DecayList<DecayClass,CandidateClass>(iList),
162 m_function(0), m_functionalObject(0) {}
163
164 // assignment operator(s)
165 // need this function to stop default assignment operator
166 template< class TDecay>
168 this->erase();
169 fill(aOtherList);
170 return ( *this ) ;
171 }
172
173
174 template< class TDecay>
176 this->erase();
177 fill(aOtherList);
178 return ( *this ) ;
179 }
180
182
184 this->erase();
185 fill(aOtherList);
186 return ( *this ) ;
187 }
188 //
189 template<class TList>
190 void operator+=( const TList& aOtherList) {
191
192 if( this->size() != 0 ) {
193 //only check compatable conjugation if something already in
194 // this list, otherwise could have problem with default value
195 bool can_only_add_lists_with_same_conjugation =
196 this->isSelfConjugate() == aOtherList.isSelfConjugate();
197 assert(can_only_add_lists_with_same_conjugation);
198 }
199 fill(aOtherList);
200 }
201
202 // member functions
203 using dchain::DecayList<DecayClass,CandidateClass>::attempt_insert;
204 void attempt_insert(DecayClass* pPossible,
205 const dchain::conjugation::Label aLabel) {
206
207 if(0!= m_function) {
208 this->attempt_insert(pPossible, aLabel, m_function);
209 } else if(0!= m_functionalObject) {
210 this->attempt_insert(pPossible, aLabel, *m_functionalObject);
211 } else {
213 this->attempt_insert(pPossible, aLabel,selectAll );
214 }
215 }
216 protected:
217 // Constructors and destructor
218
219 public:
223
224 private:
225 // Constructors and destructor
226
227 // private member functions
228 using dchain::DecayList<DecayClass,CandidateClass>::fill;
229 template<class TDecayList>
230 void fill( const TDecayList& aList ) {
231 //std::cout << "@DCDecayList::fill()" << std::endl;
232 if(0!= m_function) {
233 this->fill(aList, m_function);
234 } else if(0!= m_functionalObject) {
235 this->fill(aList, *m_functionalObject);
236 } else {
238 this->fill(aList,selectAll );
239 }
240 }
241
242 private:
243
244 // private const member functions
245
246 // data members
247 bool ( * m_function )( DecayClass& ) ;
248 DCSelectionFunction< DecayClass >* m_functionalObject ;
249
250
251 // static data members
252
253} ;
254
255// inline function definitions
256
257#include <assert.h>
258
259template < class DecayClass , class CandidateClass >
260inline
264{
265 bool can_only_add_lists_with_same_conjugation =
266 iList1.isSelfConjugate()== iList2.isSelfConjugate();
267 assert(can_only_add_lists_with_same_conjugation);
268
269 DCDecayList< DecayClass, CandidateClass> returnValue( iList1 );
270 if( &iList1 != &iList2 ) {
271 returnValue.fill( iList2 );
272 }
273 return returnValue;
274}
275
276template < class DecayClass , class CandidateClass, class NeutralClass >
277inline
281{
282 bool can_only_add_lists_with_same_conjugation =
283 iList1.isSelfConjugate()== iList2.isSelfConjugate();
284 assert(can_only_add_lists_with_same_conjugation);
285
286
287 DCDecayList< DecayClass, CandidateClass> returnValue( iList1 );
290 entry != finished ;
291 ++entry ){
292 NeutralClass* localCopy = new NeutralClass( (*entry).particle() ) ;
293 returnValue.attempt_insert( localCopy, (*entry).label() ) ;
294 }
295 return returnValue;
296}
297
298
299template < class DecayClass , class CandidateClass, class NeutralClass >
300inline
304{
306 returnValue = iList2 + iList1;
307 return returnValue;
308}
309
310
311// function definitions
313
314#endif /* DCHAIN_DCDECAYLIST_H */
315
316
317
318
DCDecayList< DecayClass, CandidateClass > operator+(const DCDecayList< DecayClass, CandidateClass > &iList1, const DCDecayList< DecayClass, CandidateClass > &iList2)
Definition: DCDecayList.h:261
const DCDecayList< DecayClass, CandidateClass > & operator=(const DCDecayList< DecayClass, CandidateClass > &aOtherList)
Definition: DCDecayList.h:183
DCDecayList(const dchain::DecayList< DecayClass, CandidateClass > &iList)
Definition: DCDecayList.h:160
DCDecayList(const DCDecayList< DecayClass, CandidateClass > &iList)
Definition: DCDecayList.h:155
const DCDecayList< DecayClass, CandidateClass > & operator=(const dchain::DecayList< TDecay, CandidateClass > &aOtherList)
Definition: DCDecayList.h:175
const DCDecayList< DecayClass, CandidateClass > & operator=(const DCDecayList< TDecay, CandidateClass > &aOtherList)
Definition: DCDecayList.h:167
DecayClass value_type
Definition: DCDecayList.h:146
void attempt_insert(DecayClass *pPossible, const dchain::conjugation::Label aLabel)
Definition: DCDecayList.h:204
void operator+=(const TList &aOtherList)
Definition: DCDecayList.h:190
virtual int size() const
virtual bool isSelfConjugate() const