BOSS 7.1.2
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.3 2022/01/25 06:34:53 maqm Exp $
16//
17// Revision history
18//
19// $Log: DecayList.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.2 2006/04/09 13:32:10 cdj
27// added back missing operator+
28//
29// Revision 1.1 2006/01/11 20:28:27 cdj
30// massive class renaming, addition of [] for selection and unit tests
31//
32//
33
34// system include files
35#include <assert.h>
36#include <iostream>
37
38// user include files
39#include "DecayChain/List/ConjugateList.h" // superclass declaration
46
47using namespace std;
48
49namespace dchain {
50 template < class DecayClass , class CandidateClass > class LabeledParticleList ;template < class DecayClass > class MuteWholeItr ;
51 template < class DecayClass > class WholeItr ;
52 template < class DecayClass > class PartialItr ;
53}
54
55namespace dchain {
56 template < class CandidateClass > class CombinatoricList ;
57 template < class DecayClass , class CandidateClass > class DecayList;
58
59template < class DecayClass , class CandidateClass >
60DecayList< DecayClass, CandidateClass > operator+(
61 const DecayList< DecayClass, CandidateClass >& iList1,
62 const DecayList< DecayClass, CandidateClass >& iList2 );
63template < class DecayClass , class CandidateClass, class NeutralClass >
64DecayList< DecayClass, CandidateClass > operator+(
65 const DecayList< DecayClass, CandidateClass >& iList1,
66 const NeutralVisibleList< NeutralClass >& iList2 );
67template < class DecayClass , class CandidateClass, class NeutralClass >
68DecayList< DecayClass, CandidateClass > operator+(
69 const NeutralVisibleList< NeutralClass >& iList1 ,
70 const DecayList< DecayClass, CandidateClass >& iList2);
71//
72// Note: To avoid a myriad of conpiler flags it is easier to
73// have a two parameter template class. The instantiation
74// of this class must look like
75//
76// template class DCDecayList< A , A::CandidateClass > ;
77
78template < class DecayClass , class CandidateClass = typename DecayClass::CandidateClass >
79class DecayList : public ConjugateList< CandidateClass >
80{
81 // friend classses and functions
82 friend DecayList< DecayClass, CandidateClass > operator+ <DecayClass, CandidateClass> (
85
86 public:
87 // constants, enums and typedefs
91
92 typedef DecayClass value_type ;
93
95
96 // Constructors and destructor
97 DecayList();
98 // need this function to stop default copy constructor
99 DecayList( const self_type& aOtherList);
100 virtual ~DecayList() ;
101
102 // assignment operator(s)
103 // need this function to stop default assignment operator
104 template< class TDecay>
106 m_list->erase( m_list->begin() ,
107 m_list->end() ) ;
108 fill( aOtherList, SelectAll<DecayClass>() ) ;
109 return ( *this ) ;
110 }
111
112 const self_type& operator=( const CombinatoricList< CandidateClass >& aOtherList );
113
115 //
116 template<class TList>
117 void operator+=( const TList& aOtherList) {
118
119 if(this->size() != 0 ) {
120 //only check compatable conjugation if something already in
121 // this list, otherwise could have problem with default value
122 bool can_only_add_lists_with_same_conjugation =
123 this->isSelfConjugate()== aOtherList.isSelfConjugate();
124 assert(can_only_add_lists_with_same_conjugation);
125 }
126 fill(aOtherList);
127 }
128
129 template<class TSelector>
133
134 // member functions
135 virtual iterator particle_begin() ;
136 virtual iterator particle_end() ;
137
138 // const member functions
141 virtual const_iterator particle_begin() const ;
142 virtual const_iterator particle_end() const ;
145 // The for following redeclarations are required because of function hidding
146 // ( See ARM p310 )
147 using ConjugateList< CandidateClass >::iterate;
148 template<class TAnalyze>
149 void iterate( const TAnalyze& analyze) const {
150 const_iterator finished ( particle_end() ) ;
151 for ( const_iterator entry ( particle_begin() ) ;
152 entry != finished ;
153 ++entry ) {
154 analyze( (*entry).particle() ) ;
155 }
156 }
157
158 template < class TAnalyzer>
159 void conjugation_iterate( const TAnalyzer& analyzer) const
160 {
161 const_iterator finished ( particle_end() ) ;
162 for ( const_iterator entry ( particle_begin() ) ;
163 entry != finished ;
164 ++entry ) {
165 analyze( (*entry)() , (*entry).label() == this->label() ) ;
166 }
167 }
168
169 template<class TAnalyze>
170 void iterate( TAnalyze& analyze) const {
171 const_iterator finished ( particle_end() ) ;
172 for ( const_iterator entry ( particle_begin() ) ;
173 entry != finished ;
174 ++entry ) {
175 analyze( (*entry).particle() ) ;
176 }
177 }
178
179 //using ConjugateList< CandidateClass >::iterate;
180 template<class TAnalyze>
181 void partial_iterate( TAnalyze& analyze ) const
182 {
185 entry != finished ;
186 ++entry ) {
187 analyze( (*entry).particle() ) ;
188 }
189 }
190 void eraseContents() ;
191
192 void erase() {
194 }
195 // static member functions
196
197 DecayList(
199 conjugation::Label aLabel ) ;
200 protected:
201
202 // protected member functions
205
206 // protected const member functions
209 public:
210 template <class TSelect>
211 bool attempt_insert( DecayClass* pPossible ,
212 const conjugation::Label aLabel,
213 const TSelect& aSelect ) {
214 ReferenceHolder<DecayClass> pHolder( pPossible );
215 bool returnValue = aSelect(*pPossible);
216 if (returnValue) {
217 this->insert(pPossible,aLabel);
218 }
219 return returnValue;
220 }
221
222 template <class THolder>
223 void insert(THolder& pPossible,
224 const conjugation::Label aLabel) {
225 m_list->push_back( LabeledParticle< DecayClass >( pPossible ,
226 aLabel ) ) ;
227 }
228 // Constructors and destructor
229
230 // private member functions
231 template<class TDecayList, class TSelector>
232 void fill( const TDecayList& aList, const TSelector& aSel = SelectAll<DecayClass>() ) {
233 //std::cout << "@DecayList::fill()" << std::endl;
234 DecayList::setLabel( aList.label() ) ;
235 typename TDecayList::const_iterator finished( aList.particle_end() ) ;
236 for ( typename TDecayList::const_iterator entry( aList.particle_begin() ) ;
237 entry != finished ;
238 ++entry ) {
239 //std::cout << "@ DecayList::fill()" << std::endl;
240 DecayClass* localCopy = new DecayClass( (*entry).particle() ) ;
241 attempt_insert( localCopy ,
242 (*entry).label(),
243 aSel ) ;
244 }
245 }
246
247 private:
248
249 // private const member functions
250
251 // data members
253} ;
254
255// inline function definitions
256
257
258
259#include <assert.h>
260
261template < class DecayClass , class CandidateClass >
262inline
266{
267 bool can_only_add_lists_with_same_conjugation =
268 iList1.isSelfConjugate()== iList2.isSelfConjugate();
269 assert(can_only_add_lists_with_same_conjugation);
270
271 DecayList< DecayClass, CandidateClass> returnValue( iList1 );
272 if( &iList1 != &iList2 ) {
273 returnValue.fill( iList2, SelectAll<DecayClass>() );
274 }
275 return returnValue;
276}
277
278template < class DecayClass , class CandidateClass, class NeutralClass >
279inline
283{
284 bool can_only_add_lists_with_same_conjugation =
285 iList1.isSelfConjugate()== iList2.isSelfConjugate();
286 assert(can_only_add_lists_with_same_conjugation);
287
288
289 DecayList< DecayClass, CandidateClass> returnValue =iList1 ;
292 entry != finished ;
293 ++entry ){
294 NeutralClass* localCopy = new NeutralClass( (*entry).particle() ) ;
295 returnValue.attempt_insert( localCopy, (*entry).label(),SelectAll<DecayClass>() ) ;
296 }
297 return returnValue;
298}
299
300
301template < class DecayClass , class CandidateClass, class NeutralClass >
302inline
306{
308 returnValue = iList2 + iList1;
309 return returnValue;
310}
311
312}
313
314// function definitions
316
317#endif /* DCHAIN_DECAYLIST_H */
virtual int size() const
bool attempt_insert(DecayClass *pPossible, const conjugation::Label aLabel, const TSelect &aSelect)
Definition DecayList.h:211
virtual const_partial_iterator partial_particle_begin() const
Definition DecayList.cc:227
void iterate(TAnalyze &analyze) const
Definition DecayList.h:170
DecayClass value_type
Definition DecayList.h:92
virtual LabeledParticleList< DecayClass, CandidateClass > & labeledParticleList()
Definition DecayList.cc:188
void operator+=(const TList &aOtherList)
Definition DecayList.h:117
void iterate(const TAnalyze &analyze) const
Definition DecayList.h:149
PartialItr< DecayClass > const_partial_iterator
Definition DecayList.h:90
virtual const_partial_iterator partial_particle_end() const
Definition DecayList.cc:234
void partial_iterate(TAnalyze &analyze) const
Definition DecayList.h:181
const DecayList< DecayClass, CandidateClass > bar() const
Definition DecayList.cc:199
FillListWithSelection< self_type, TSelector > operator[](const TSelector &iSel)
Definition DecayList.h:130
void insert(THolder &pPossible, const conjugation::Label aLabel)
Definition DecayList.h:223
WholeItr< DecayClass > const_iterator
Definition DecayList.h:89
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:159
DecayList< DecayClass, CandidateClass > self_type
Definition DecayList.h:94
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:232
const self_type & operator=(const DecayList< TDecay, CandidateClass > &aOtherList)
Definition DecayList.h:105
MuteWholeItr< DecayClass > iterator
Definition DecayList.h:88
DecayList< DecayClass, CandidateClass > operator+(const DecayList< DecayClass, CandidateClass > &iList1, const DecayList< DecayClass, CandidateClass > &iList2)
Definition DecayList.h:263