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

Go to the documentation of this file.
00001 #ifndef DCHAIN_NEUTRALVISIBLELIST_H
00002 #define DCHAIN_NEUTRALVISIBLELIST_H
00003 // -*- C++ -*-
00004 //
00005 // Package:     DChain
00006 // Module:      NeutralVisibleList
00007 // 
00008 // Description: List to hold Candidates generated from observed Tracks.
00009 //
00010 // Usage:
00011 //    <usage>
00012 //
00013 // Author:      Simon Patton
00014 // Created:     Fri Oct  4 11:04:47 EDT 1996
00015 // $Id: NeutralVisibleList.h,v 1.1.1.1 2009/03/03 06:06:56 maqm Exp $
00016 //
00017 // Revision history
00018 //
00019 // $Log: NeutralVisibleList.h,v $
00020 // Revision 1.1.1.1  2009/03/03 06:06:56  maqm
00021 // first import of DecayChain
00022 //
00023 // Revision 1.1  2006/01/11 20:28:29  cdj
00024 // massive class renaming, addition of [] for selection and unit tests
00025 //
00026 // Revision 1.4  2003/05/15 19:56:08  cdj
00027 // revamped memory handling so always use a ReferenceHolder to deal with the reference counting
00028 //
00029 // Revision 1.3  2001/03/28 14:27:58  urner
00030 // added same workaround as for charged because of NonTemplatedMemberFunctionBug
00031 //
00032 // Revision 1.2  2001/03/23 23:07:44  urner
00033 // modification needed to add pi0 eta and Ks decay lists in CleoDChain
00034 //
00035 // Revision 1.1.1.1  2000/12/18 22:16:53  cdj
00036 // imported DChain
00037 //
00038 // Revision 1.11  1998/08/20 19:59:05  sjp
00039 // Modified to use DChainBoolean
00040 //
00041 // Revision 1.10  1998/04/17 19:11:05  sjp
00042 // Modified to use latest types
00043 //
00044 // Revision 1.9  1997/09/17 20:05:29  sjp
00045 // Removed filling to superclass
00046 //
00047 // Revision 1.8  1997/08/28 06:59:56  sjp
00048 // Modified files to handle complete templating
00049 //
00050 // Revision 1.7  1997/08/19 15:55:10  sjp
00051 // Modified list to have no dependence on any other
00052 //   structures except its contents, which must have
00053 //   certain `typedef' available to use.
00054 //
00055 // Revision 1.6  1997/08/15 21:32:39  sjp
00056 // Updated to use <package>/<file>.h include structure.
00057 // Updated to use bug flags specified in Experiement.h
00058 //
00059 // Revision 1.5  1997/01/31 20:17:14  sjp
00060 // Modified to use the new `bug' include files
00061 //
00062 // Revision 1.4  1997/01/22 16:27:32  sjp
00063 // Fixed error in pre-processor labels
00064 //
00065 // Revision 1.3  1997/01/21 20:34:06  sjp
00066 // Changed CPP flags and include because of library reorganization
00067 //
00068 // Revision 1.2  1996/12/20 21:19:23  sjp
00069 // Extended pathnames for Include files
00070 //
00071 // Revision 1.1  1996/11/04 19:36:11  sjp
00072 // New file for new `List' module
00073 //
00074 
00075 // system include files
00076 
00077 // user include files
00078 #include "DecayChain/List/ConjugateList.h" // superclass declaration
00079 #include "DecayChain/Element/MutableReferenceHolder.h"
00080 
00081 #include "DecayChain/List/LabeledParticleList.h"
00082 #include "DecayChain/Element/MakerTrait.h"
00083 #include "DecayChain/Iterator/SelectiveInserter.h"
00084 #include "DecayChain/Function/SelectAll.h"
00085 #include "DecayChain/List/FillListWithSelection.h"
00086 
00087 namespace dchain {
00088 template < class DecayClass > class MuteWholeItr ;
00089 template < class DecayClass > class WholeItr ;
00090 template < class DecayClass > class PartialItr ;
00091 
00092 //
00093 //  Note: To avoid a myriad of conpiler flags it is easier to
00094 //        have a two parameter template class.  The instantiation
00095 //        of this class must look like
00096 //
00097 //        template class LabeledDecayList< A , A::CandidateClass > ;
00098 
00099 template< class Neutral , class CandidateClass = typename Neutral::CandidateClass >
00100 class NeutralVisibleList : public dchain::ConjugateList< CandidateClass >
00101 {
00102       // friend classses and functions
00103 
00104    public:
00105       // constants, enums and typedefs
00106       typedef dchain::MuteWholeItr< Neutral > iterator ;
00107       typedef dchain::WholeItr< Neutral > const_iterator ;
00108       //typedef dchain::PartialItr< Neutral > const_partial_iterator ;
00109 
00110       typedef Neutral value_type ;
00111 
00112       typedef NeutralVisibleList<Neutral,CandidateClass> self_type;
00113       // Constructors and destructor
00114       NeutralVisibleList() ;
00115       NeutralVisibleList( const self_type& aOtherList);
00116       template<class TSelector>
00117       NeutralVisibleList( const self_type& aOtherList ,
00118                             const TSelector& aSel) :
00119          ConjugateList< CandidateClass >( dchain::conjugation::kNone ),
00120          m_list(new LabeledParticleList<Neutral,CandidateClass>) {
00121          fill(*(aOtherList.m_list),
00122               typename MakerTrait<Neutral>::maker_type(),
00123               aSel);
00124       }
00125 
00126       template <class WitnessIterator>
00127       NeutralVisibleList(WitnessIterator first, WitnessIterator last) : 
00128          ConjugateList< CandidateClass >( dchain::conjugation::kNone ),
00129          m_list( new LabeledParticleList<Neutral,CandidateClass> ) {
00130          fill(first, last, typename MakerTrait<Neutral>::maker_type() ); }
00131 
00132       template<class WitnessIterator, class TSelector>
00133       NeutralVisibleList(WitnessIterator first, WitnessIterator last, 
00134                             const TSelector& aFunctionalObject )
00135          : 
00136          ConjugateList< CandidateClass >( dchain::conjugation::kNone ),
00137          m_list( new LabeledParticleList<Neutral,CandidateClass> )
00138       {
00139          fill(first, last, 
00140               typename MakerTrait<Neutral>::maker_type(), aFunctionalObject); }
00141       virtual ~NeutralVisibleList() ;
00142       
00143       // assignment operator(s)
00144       const self_type& operator=(const self_type& aOtherList );
00145       
00146       template<class Witness>
00147       const self_type& operator=(const Witness& aWitnessList) {
00148          eraseContents();
00149          fill(aWitnessList.begin(), aWitnessList.end(),
00150               typename MakerTrait<Neutral>::maker_type(),
00151               SelectAll<Neutral>() );
00152          return ( *this ) ;
00153       }
00154 
00155       // member functions
00156       template<class TSelector>
00157       FillListWithSelection<self_type, TSelector> operator[](const TSelector& iSel) {
00158          return FillListWithSelection<self_type,TSelector>(*this, iSel);
00159       }
00160 
00161       iterator particle_begin() ;
00162       iterator particle_end() ;
00163 
00164       // const member functions
00165       const_iterator particle_begin() const ;
00166       const_iterator particle_end() const ;
00167 
00168       using CandidateList< CandidateClass >::iterate;
00169       template<class TAnalyze>
00170       void iterate( const TAnalyze& analyze) const {
00171          const_iterator finished ( particle_end() ) ;
00172          for ( const_iterator entry ( particle_begin() ) ;
00173                entry != finished ;
00174                ++entry ) {
00175             analyze( (*entry)() ) ;
00176          }
00177       }
00178 
00179       template<class TAnalyze>
00180       void iterate( TAnalyze& analyze) const {
00181          const_iterator finished ( particle_end() ) ;
00182          for ( const_iterator entry ( particle_begin() ) ;
00183                entry != finished ;
00184                ++entry ) {
00185             analyze( (*entry)() ) ;
00186          }
00187       }
00188 
00190       template<class TSelect>
00191       SelectiveInserter<self_type,TSelect> selectiveInserter(const TSelect& iSelect) {
00192          return SelectiveInserter<self_type,TSelect>(*this,iSelect); }
00193 
00194       template <class THolder, class TSelect>
00195       bool attempt_insert( THolder& pPossible,
00196                            const TSelect& aSelect) {
00197          bool returnValue = (aSelect)(*pPossible);
00198          if (returnValue) {
00199             this->insert(pPossible);
00200          }
00201          return returnValue;
00202       }
00203       template <class THolder>
00204       void insert(THolder& pPossible) {
00205          m_list->push_back( LabeledParticle< Neutral >( pPossible ,
00206                                                         conjugation::kNone ) ) ;
00207       }
00208       void eraseContents() ;
00209 
00210       void erase() {
00211          eraseContents();
00212       }
00213       // static member functions
00214 
00215       template<class TMaker, class TSelector>
00216       void fill( const LabeledParticleList< Neutral , CandidateClass >& aList,
00217                  const TMaker& aMaker,
00218                  const TSelector& aSel) {
00219 
00220          for( const_iterator entry(aList.begin()); entry != aList.end(); ++entry){
00221             //NOTE: even though this is really just calling the copy constructor
00222             //it is best to use the maker since it allows further control
00223             const Neutral& from((*entry)());
00224             typename ResultTypeTrait<TMaker>::type localCopy( aMaker(from) );
00225             
00226             attempt_insert(localCopy,aSel);
00227          }
00228  
00229       }
00230       template<class Iterator, class TMaker, class TSelector>
00231       void fill(Iterator first, Iterator last,
00232                 const TMaker& aMaker,
00233                 const TSelector& aSel = SelectAll<Neutral>() ) {
00234          std::transform(first,last,
00235                         selectiveInserter(aSel),
00236                         aMaker);
00237       }
00238    protected:
00239       // protected member functions
00240       virtual dchain::LabeledParticleList< Neutral, CandidateClass >& labeledCandidateList() ;
00241 
00242       // protected const member functions
00243       virtual const dchain::LabeledParticleList< Neutral, CandidateClass >& labeledCandidateList() const ;
00244 
00245    private:
00246       // Constructors and destructor
00247 
00248       // private member functions
00249 
00250       // private const member functions
00251 
00252       // data members
00253       MutableReferenceHolder< dchain::LabeledParticleList< Neutral , CandidateClass > > m_list ;
00254 
00255       // static data members
00256 
00257 } ;
00258 
00259 // inline function definitions
00260    template<class TIList, class TSelector, class T, class U>
00261    void fill_using_selector(const TIList& iList,
00262                             const TSelector& iSel,
00263                             NeutralVisibleList<T,U>& oList) {
00264       oList.fill(iList.begin(), iList.end(),
00265                  typename MakerTrait<T>::maker_type(),
00266                  iSel);
00267    }
00268 
00269 }
00270 
00271 // function definitions
00272 #include "DecayChain/List/Template/NeutralVisibleList.cc"
00273 
00274 #endif /* DCHAIN_NEUTRALVISIBLELIST_H */

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