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