00001 #ifndef DCHAIN_DCDECAYLIST_H
00002 #define DCHAIN_DCDECAYLIST_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110 #include <assert.h>
00111 #include <iostream>
00112
00113
00114 #include "DecayChain/List/DecayList.h"
00115 #include "DecayChain/List/DCFillableNeutralList.h"
00116 #include "DecayChain/Function/DCSelectionFunction.h"
00117
00118 template < class DecayClass , class CandidateClass >
00119 class DCDecayList;
00120
00121 template < class DecayClass , class CandidateClass >
00122 DCDecayList< DecayClass, CandidateClass > operator+(
00123 const DCDecayList< DecayClass, CandidateClass >& iList1,
00124 const DCDecayList< DecayClass, CandidateClass >& iList2 );
00125 template < class DecayClass , class CandidateClass, class NeutralClass >
00126 DCDecayList< DecayClass, CandidateClass > operator+(
00127 const DCDecayList< DecayClass, CandidateClass >& iList1,
00128 const DCFillableNeutralList< NeutralClass >& iList2 );
00129 template < class DecayClass , class CandidateClass, class NeutralClass >
00130 DCDecayList< DecayClass, CandidateClass > operator+(
00131 const DCFillableNeutralList< NeutralClass >& iList1 ,
00132 const DCDecayList< DecayClass, CandidateClass >& iList2);
00133
00134 template < class DecayClass , class CandidateClass >
00135 class DCDecayList : public dchain::DecayList<DecayClass, CandidateClass>
00136 {
00137
00138
00139 friend
00140 DCDecayList< DecayClass, CandidateClass > operator+ <DecayClass, CandidateClass> (
00141 const DCDecayList< DecayClass, CandidateClass >& iList1,
00142 const DCDecayList< DecayClass, CandidateClass >& iList2 );
00143
00144 public:
00145
00146 typedef DecayClass value_type ;
00147
00148
00149 DCDecayList( bool ( * pFunction )( DecayClass& ) = 0 ) ;
00150
00151 DCDecayList( const DCDecayList< DecayClass , CandidateClass >& aOtherList ,
00152 bool ( * pFunction )( DecayClass& ) ) ;
00153 DCDecayList( DCSelectionFunction< DecayClass >& aFunctionalObject ) ;
00154
00155 DCDecayList(const DCDecayList<DecayClass,CandidateClass>& iList) :
00156 dchain::DecayList<DecayClass,CandidateClass>(
00157 static_cast<dchain::DecayList<DecayClass,CandidateClass> >(iList)),
00158 m_function(0), m_functionalObject(0) {}
00159
00160 DCDecayList(const dchain::DecayList<DecayClass,CandidateClass>& iList) :
00161 dchain::DecayList<DecayClass,CandidateClass>(iList),
00162 m_function(0), m_functionalObject(0) {}
00163
00164
00165
00166 template< class TDecay>
00167 const DCDecayList< DecayClass , CandidateClass >& operator=( const DCDecayList< TDecay , CandidateClass >& aOtherList ) {
00168 this->erase();
00169 fill(aOtherList);
00170 return ( *this ) ;
00171 }
00172
00173
00174 template< class TDecay>
00175 const DCDecayList< DecayClass , CandidateClass >& operator=( const dchain::DecayList< TDecay , CandidateClass >& aOtherList ) {
00176 this->erase();
00177 fill(aOtherList);
00178 return ( *this ) ;
00179 }
00180
00181 const DCDecayList< DecayClass , CandidateClass >& operator=( const dchain::CombinatoricList< CandidateClass >& aOtherList );
00182
00183 const DCDecayList< DecayClass , CandidateClass >& operator=( const DCDecayList< DecayClass , CandidateClass >& aOtherList ){
00184 this->erase();
00185 fill(aOtherList);
00186 return ( *this ) ;
00187 }
00188
00189 template<class TList>
00190 void operator+=( const TList& aOtherList) {
00191
00192 if( this->size() != 0 ) {
00193
00194
00195 bool can_only_add_lists_with_same_conjugation =
00196 this->isSelfConjugate() == aOtherList.isSelfConjugate();
00197 assert(can_only_add_lists_with_same_conjugation);
00198 }
00199 fill(aOtherList);
00200 }
00201
00202
00203 using dchain::DecayList<DecayClass,CandidateClass>::attempt_insert;
00204 void attempt_insert(DecayClass* pPossible,
00205 const dchain::conjugation::Label aLabel) {
00206
00207 if(0!= m_function) {
00208 this->attempt_insert(pPossible, aLabel, m_function);
00209 } else if(0!= m_functionalObject) {
00210 this->attempt_insert(pPossible, aLabel, *m_functionalObject);
00211 } else {
00212 dchain::SelectAll<DecayClass> selectAll;
00213 this->attempt_insert(pPossible, aLabel,selectAll );
00214 }
00215 }
00216 protected:
00217
00218
00219 public:
00220 DCDecayList(
00221 dchain::LabeledParticleList< DecayClass , CandidateClass >& aLabeledDecayList ,
00222 dchain::conjugation::Label aLabel ) ;
00223
00224 private:
00225
00226
00227
00228 using dchain::DecayList<DecayClass,CandidateClass>::fill;
00229 template<class TDecayList>
00230 void fill( const TDecayList& aList ) {
00231
00232 if(0!= m_function) {
00233 this->fill(aList, m_function);
00234 } else if(0!= m_functionalObject) {
00235 this->fill(aList, *m_functionalObject);
00236 } else {
00237 dchain::SelectAll<DecayClass> selectAll;
00238 this->fill(aList,selectAll );
00239 }
00240 }
00241
00242 private:
00243
00244
00245
00246
00247 bool ( * m_function )( DecayClass& ) ;
00248 DCSelectionFunction< DecayClass >* m_functionalObject ;
00249
00250
00251
00252
00253 } ;
00254
00255
00256
00257 #include <assert.h>
00258
00259 template < class DecayClass , class CandidateClass >
00260 inline
00261 DCDecayList< DecayClass, CandidateClass > operator+(
00262 const DCDecayList< DecayClass, CandidateClass >& iList1,
00263 const DCDecayList< DecayClass, CandidateClass >& iList2 )
00264 {
00265 bool can_only_add_lists_with_same_conjugation =
00266 iList1.isSelfConjugate()== iList2.isSelfConjugate();
00267 assert(can_only_add_lists_with_same_conjugation);
00268
00269 DCDecayList< DecayClass, CandidateClass> returnValue( iList1 );
00270 if( &iList1 != &iList2 ) {
00271 returnValue.fill( iList2 );
00272 }
00273 return returnValue;
00274 }
00275
00276 template < class DecayClass , class CandidateClass, class NeutralClass >
00277 inline
00278 DCDecayList< DecayClass, CandidateClass > operator+(
00279 const DCDecayList< DecayClass, CandidateClass >& iList1,
00280 const DCFillableNeutralList< NeutralClass >& iList2 )
00281 {
00282 bool can_only_add_lists_with_same_conjugation =
00283 iList1.isSelfConjugate()== iList2.isSelfConjugate();
00284 assert(can_only_add_lists_with_same_conjugation);
00285
00286
00287 DCDecayList< DecayClass, CandidateClass> returnValue( iList1 );
00288 typename dchain::LabeledParticleList< NeutralClass , CandidateClass >::const_iterator finished( iList2.particle_end() ) ;
00289 for( typename dchain::LabeledParticleList< NeutralClass , CandidateClass >::const_iterator entry(iList2.particle_begin()) ;
00290 entry != finished ;
00291 ++entry ){
00292 NeutralClass* localCopy = new NeutralClass( (*entry).particle() ) ;
00293 returnValue.attempt_insert( localCopy, (*entry).label() ) ;
00294 }
00295 return returnValue;
00296 }
00297
00298
00299 template < class DecayClass , class CandidateClass, class NeutralClass >
00300 inline
00301 DCDecayList< DecayClass, CandidateClass > operator+(
00302 const DCFillableNeutralList< NeutralClass >& iList1 ,
00303 const DCDecayList< DecayClass, CandidateClass >& iList2)
00304 {
00305 DCDecayList< DecayClass, CandidateClass> returnValue;
00306 returnValue = iList2 + iList1;
00307 return returnValue;
00308 }
00309
00310
00311
00312 #include "DecayChain/List/Template/DCDecayList.cc"
00313
00314 #endif
00315
00316
00317
00318