00001 #ifndef DCHAIN_NEUTRALNCVISIBLELIST_H
00002 #define DCHAIN_NEUTRALNCVISIBLELIST_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 #include "DecayChain/List/CandidateList.h"
00035 #include "DecayChain/List/ChosenConjugateList.h"
00036 #include "DecayChain/Element/MutableReferenceHolder.h"
00037
00038 #include "DecayChain/List/LabeledParticleList.h"
00039
00040 #include "DecayChain/Element/MakerTrait.h"
00041 #include "DecayChain/Iterator/SelectiveInserter.h"
00042 #include "DecayChain/Function/SelectAll.h"
00043 #include "DecayChain/List/FillListWithSelection.h"
00044
00045 namespace dchain {
00046 template < class DecayClass > class MuteWholeItr ;
00047 template < class DecayClass > class WholeItr ;
00048 template < class DecayClass > class PartialItr ;
00049
00050
00051 template<class T>
00052 int is_bar(const T& iNeutralNC) {
00053 return static_cast<int>(iNeutralNC.isBar());
00054 }
00055
00056 template<class T>
00057 int is_bar(const T* iNeutralNC) {
00058 return static_cast<int>(iNeutralNC->isBar());
00059 }
00060
00061 template<class T>
00062 int is_bar(T* iNeutralNC) {
00063 return static_cast<int>(iNeutralNC->isBar());
00064 }
00065
00066 template<class TPtr,class TRef>
00067 int is_bar(const ReferenceHolderBase<TPtr,TRef>& iHolder) {
00068 return is_bar(*iHolder);
00069 }
00070
00071
00072
00073
00074
00075
00076
00077
00078 template < class NeutralNC , class CandidateClass = typename NeutralNC::CandidateClass >
00079 class NeutralNCVisibleList : public dchain::CandidateList< CandidateClass >
00080 {
00081
00082
00083 public:
00084
00085 typedef dchain::MuteWholeItr< NeutralNC > iterator ;
00086 typedef dchain::WholeItr< NeutralNC > const_iterator ;
00087 typedef dchain::PartialItr< NeutralNC > const_partial_iterator ;
00088
00089 typedef NeutralNC value_type ;
00090
00091 typedef NeutralNCVisibleList<NeutralNC, CandidateClass> self_type;
00092
00093
00094 NeutralNCVisibleList();
00095 NeutralNCVisibleList( const self_type& aOtherList);
00096 template< class TSelector>
00097 NeutralNCVisibleList( const self_type& aOtherList,
00098 const TSelector& aSel):
00099 m_list( new LabeledParticleList<NeutralNC,CandidateClass> ),
00100 m_ntBarList(0),
00101 m_isBarList(0)
00102 {
00103 fill(*(aOtherList.m_list),
00104 typename MakerTrait<NeutralNC>::maker_type(),
00105 aSel);
00106 }
00107
00108 virtual ~NeutralNCVisibleList() ;
00109
00110
00111
00112
00113 template<class Witness>
00114 const self_type& operator=(const Witness& aWitnessList) {
00115 eraseContents();
00116 fill(aWitnessList.begin(), aWitnessList.end(),
00117 typename MakerTrait<NeutralNC>::maker_type(),
00118 SelectAll<NeutralNC>() );
00119 return ( *this ) ;
00120 }
00121
00122
00123 template<class TSelector>
00124 FillListWithSelection<self_type, TSelector> operator[](const TSelector& iSel) {
00125 return FillListWithSelection<self_type,TSelector>(*this, iSel);
00126 }
00127
00128 iterator particle_begin() ;
00129 iterator particle_end() ;
00130 ChosenConjugateList< NeutralNC , CandidateClass >& bar() ;
00131 ChosenConjugateList< NeutralNC , CandidateClass >& operator()() ;
00132
00133
00134 const_iterator particle_begin() const ;
00135 const_iterator particle_end() const ;
00136
00137
00138
00139
00140
00141 using CandidateList< CandidateClass >::iterate;
00142 template<class TAnalyze>
00143 void iterate( const TAnalyze& analyze) const {
00144 const_iterator finished ( particle_end() ) ;
00145 for ( const_iterator entry ( particle_begin() ) ;
00146 entry != finished ;
00147 ++entry ) {
00148 analyze( (*entry)() ) ;
00149 }
00150 }
00151
00152 template<class TAnalyze>
00153 void iterate( TAnalyze& analyze) const {
00154 const_iterator finished ( particle_end() ) ;
00155 for ( const_iterator entry ( particle_begin() ) ;
00156 entry != finished ;
00157 ++entry ) {
00158 analyze( (*entry)() ) ;
00159 }
00160 }
00161
00163 template<class TSelect>
00164 SelectiveInserter<self_type,TSelect> selectiveInserter(const TSelect& iSelect) {
00165 return SelectiveInserter<self_type,TSelect>(*this,iSelect); }
00166
00167 template <class THolder, class TSelect>
00168 bool attempt_insert( THolder& pPossible,
00169 const TSelect& aSelect) {
00170 bool returnValue = (aSelect)(*pPossible);
00171 if (returnValue) {
00172 this->insert(pPossible);
00173 }
00174 return returnValue;
00175 }
00176
00177 template <class THolder>
00178 void insert(THolder& pPossible) {
00179 if (is_bar(pPossible)) {
00180 m_list->push_back( LabeledParticle< NeutralNC >( pPossible ,
00181 kIsBar ) ) ;
00182 }
00183 else {
00184 m_list->push_back( LabeledParticle< NeutralNC >( pPossible ,
00185 kIsntBar ) ) ;
00186 }
00187 }
00188
00189 void eraseContents() ;
00190 void erase() {
00191 eraseContents();
00192 }
00193
00194 template<class TMaker, class TSelector>
00195 void fill( const LabeledParticleList< NeutralNC , CandidateClass >& aList,
00196 const TMaker& aMaker,
00197 const TSelector& aSel) {
00198
00199 for( const_iterator entry(aList.begin()); entry != aList.end(); ++entry){
00200
00201
00202 const NeutralNC& from((*entry)());
00203 typename ResultTypeTrait<TMaker>::type localCopy( aMaker(from) );
00204
00205 attempt_insert(localCopy,aSel);
00206 }
00207
00208 }
00209 template<class Iterator, class TMaker, class TSelector>
00210 void fill(Iterator first, Iterator last,
00211 const TMaker& aMaker,
00212 const TSelector& aSel = SelectAll<NeutralNC>() ) {
00213 std::transform(first,last,
00214 selectiveInserter(aSel),
00215 aMaker);
00216 }
00217
00218
00219
00220 protected:
00221
00222 virtual dchain::LabeledParticleList< NeutralNC, CandidateClass >& labeledCandidateList() ;
00223
00224
00225 virtual const dchain::LabeledParticleList< NeutralNC, CandidateClass >& labeledCandidateList() const ;
00226
00227 private:
00228
00229
00230
00231 const NeutralNCVisibleList< NeutralNC , CandidateClass >& operator=( const NeutralNCVisibleList< NeutralNC , CandidateClass >& aOtherList ) ;
00232
00233
00234
00235
00236 MutableReferenceHolder<dchain::LabeledParticleList< NeutralNC , CandidateClass > > m_list ;
00237
00238 mutable ChosenConjugateList< NeutralNC , CandidateClass >* m_ntBarList;
00239 mutable ChosenConjugateList< NeutralNC , CandidateClass >* m_isBarList;
00240
00241
00242 static const dchain::conjugation::Label kIsntBar = dchain::conjugation::kHeads ;
00243 static const dchain::conjugation::Label kIsBar = dchain::conjugation::kTails ;
00244
00245 } ;
00246
00247
00248 template<class TIList, class TSelector, class T, class U>
00249 void fill_using_selector(const TIList& iList,
00250 const TSelector& iSel,
00251 NeutralNCVisibleList<T,U>& oList) {
00252 oList.fill(iList.begin(), iList.end(),
00253 typename MakerTrait<T>::maker_type(),
00254 iSel);
00255 }
00256
00257 }
00258
00259
00260 #include "DecayChain/List/Template/NeutralNCVisibleList.cc"
00261
00262 #endif
00263