/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Event/DecayChain/DecayChain-00-00-03-slc6tag/DecayChain/List/NeutralNCVisibleList.h

Go to the documentation of this file.
00001 #ifndef DCHAIN_NEUTRALNCVISIBLELIST_H
00002 #define DCHAIN_NEUTRALNCVISIBLELIST_H
00003 // -*- C++ -*-
00004 //
00005 // Package:     DChain
00006 // Module:      NeutralNCVisibleList
00007 // 
00008 // Description: List to hold Candidate subclasses generated from VisibleEvidence
00009 //
00010 // Usage:
00011 //    <usage>
00012 //
00013 // Author:      Simon Patton
00014 // Created:     Fri Oct  4 11:04:47 EDT 1996
00015 // $Id: NeutralNCVisibleList.h,v 1.2 2009/06/22 08:38:08 zoujh Exp $
00016 //
00017 // Revision history
00018 //
00019 // $Log: NeutralNCVisibleList.h,v $
00020 // Revision 1.2  2009/06/22 08:38:08  zoujh
00021 // See ChangeLog
00022 //
00023 // Revision 1.1.1.1  2009/03/03 06:06:56  maqm
00024 // first import of DecayChain
00025 //
00026 // Revision 1.1  2006/01/11 20:28:29  cdj
00027 // massive class renaming, addition of [] for selection and unit tests
00028 //
00029 //
00030 
00031 // system include files
00032 
00033 // user include files
00034 #include "DecayChain/List/CandidateList.h" // superclass declaration
00035 #include "DecayChain/List/ChosenConjugateList.h" // for return-by-value
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 //  Note: To avoid a myriad of compiler flags it is easier to
00073 //        have a two parameter template class.  The instantiation
00074 //        of this class must look like
00075 //
00076 //        template class dchain::LabeledParticleList< A , A::CandidateClass > ;
00077 
00078 template < class NeutralNC , class CandidateClass = typename NeutralNC::CandidateClass >
00079 class NeutralNCVisibleList : public dchain::CandidateList< CandidateClass >
00080 {
00081       // friend classses and functions
00082 
00083    public:
00084       // constants, enums and typedefs
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       // Constructors and destructor
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       // assignment operator(s)
00111       //const NeutralNCVisibleList< NeutralNC , CandidateClass >& operator=( const NeutralNCVisibleList< NeutralNC , CandidateClass >& aOtherList ) ;
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       // member functions
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       // const member functions
00134       const_iterator particle_begin() const ;
00135       const_iterator particle_end() const ;
00136 
00137 // The two following redeclarations are required because of function hidding
00138 //   ( See ARM p310 )
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             //NOTE: even though this is really just calling the copy constructor
00201             //it is best to use the maker since it allows further control
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       // static member functions
00219 
00220    protected:
00221       // protected member functions
00222       virtual dchain::LabeledParticleList< NeutralNC, CandidateClass >& labeledCandidateList() ;
00223 
00224       // protected const member functions
00225       virtual const dchain::LabeledParticleList< NeutralNC, CandidateClass >& labeledCandidateList() const ;
00226 
00227    private:
00228       // Constructors and destructor
00229 
00230       // private member functions
00231       const NeutralNCVisibleList< NeutralNC , CandidateClass >& operator=( const NeutralNCVisibleList< NeutralNC , CandidateClass >& aOtherList ) ; //stop default
00232 
00233       // private const member functions
00234 
00235       // data members
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       // static data members
00242       static const dchain::conjugation::Label kIsntBar = dchain::conjugation::kHeads ;
00243       static const dchain::conjugation::Label kIsBar = dchain::conjugation::kTails ;
00244 
00245 } ;
00246 
00247 // inline function definitions
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 // function definitions
00260 #include "DecayChain/List/Template/NeutralNCVisibleList.cc"
00261 
00262 #endif /* DCHAIN_NEUTRALNCVISIBLELIST_H */
00263 

Generated on Tue Nov 29 22:58:23 2016 for BOSS_7.0.2 by  doxygen 1.4.7