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

Go to the documentation of this file.
00001 #ifndef DCHAIN_DCDECAYLIST_H
00002 #define DCHAIN_DCDECAYLIST_H
00003 // -*- C++ -*-
00004 //
00005 // Package:     DChain
00006 // Module:      DCDecayList
00007 // 
00008 // Description: container of subclasses of Decay, used for iteration
00009 //
00010 // Usage:
00011 //    <usage>
00012 //
00013 // Author:      Simon Patton
00014 // Created:     Fri Oct  4 11:04:47 EDT 1996
00015 // $Id: DCDecayList.h,v 1.1.1.1 2009/03/03 06:06:56 maqm Exp $
00016 //
00017 // Revision history
00018 //
00019 // $Log: DCDecayList.h,v $
00020 // Revision 1.1.1.1  2009/03/03 06:06:56  maqm
00021 // first import of DecayChain
00022 //
00023 // Revision 1.16  2006/04/09 13:32:09  cdj
00024 // added back missing operator+
00025 //
00026 // Revision 1.15  2006/02/03 18:29:33  cdj
00027 // fixed bug in copy constructor and operator=
00028 //
00029 // Revision 1.14  2006/01/14 15:29:43  cdj
00030 // fixed missing symbol problem
00031 //
00032 // Revision 1.13  2006/01/13 18:10:15  cdj
00033 // improved backwards compatibility
00034 //
00035 // Revision 1.12  2006/01/11 20:28:24  cdj
00036 // massive class renaming, addition of [] for selection and unit tests
00037 //
00038 // Revision 1.11  2004/02/19 21:30:26  cdj
00039 // added operator+= to DecayList
00040 //
00041 // Revision 1.10  2003/10/23 18:43:39  cdj
00042 // can now use DCDecayList with other Decay objects
00043 //
00044 // Revision 1.9  2003/05/15 19:56:08  cdj
00045 // revamped memory handling so always use a ReferenceHolder to deal with the reference counting
00046 //
00047 // Revision 1.8  2002/06/19 20:36:03  cleo3
00048 // now compiles under Solaris 8
00049 //
00050 // Revision 1.7  2001/05/24 19:46:20  urner
00051 // first tag
00052 //
00053 // Revision 1.6  2001/04/12 13:43:58  urner
00054 // explicitely instantiated operator+ to make Solaris happy
00055 //
00056 // Revision 1.5  2001/04/10 13:56:45  urner
00057 // bug fixes
00058 //
00059 // Revision 1.4  2001/04/03 11:43:10  cdj
00060 // made operator+ a friend
00061 //
00062 // Revision 1.3  2001/03/30 16:34:53  cdj
00063 // added simplistic operator+
00064 //
00065 // Revision 1.2  2001/03/23 23:07:43  urner
00066 // modification needed to add pi0 eta and Ks decay lists in CleoDChain
00067 //
00068 // Revision 1.1.1.1  2000/12/18 22:16:52  cdj
00069 // imported DChain
00070 //
00071 // Revision 1.12  1998/08/27 04:56:07  sjp
00072 // Added value_type typedef
00073 //
00074 // Revision 1.11  1998/08/20 19:58:58  sjp
00075 // Modified to use DChainBoolean
00076 //
00077 // Revision 1.10  1998/08/19 20:38:03  sjp
00078 // Fixed include path for defintions
00079 //
00080 // Revision 1.9  1998/05/01 20:20:01  sjp
00081 // Removed unnecessary functions which were causing infinate loop
00082 //
00083 // Revision 1.8  1998/04/17 19:10:58  sjp
00084 // Modified to use latest types
00085 //
00086 // Revision 1.7  1997/08/28 06:59:42  sjp
00087 // Modified files to handle complete templating
00088 //
00089 // Revision 1.6  1997/08/15 21:32:05  sjp
00090 // Updated to use <package>/<file>.h include structure.
00091 // Updated to use bug flags specified in Experiement.h
00092 //
00093 // Revision 1.5  1997/01/31 20:16:58  sjp
00094 // Modified to use the new `bug' include files
00095 //
00096 // Revision 1.4  1997/01/22 16:27:06  sjp
00097 // Fixed error in pre-processor labels
00098 //
00099 // Revision 1.3  1997/01/21 20:34:07  sjp
00100 // Changed CPP flags and include because of library reorganization
00101 //
00102 // Revision 1.2  1996/12/20 21:19:25  sjp
00103 // Extended pathnames for Include files
00104 //
00105 // Revision 1.1  1996/11/04 19:36:12  sjp
00106 // New file for new `List' module
00107 //
00108 
00109 // system include files
00110 #include <assert.h>
00111 #include <iostream>
00112 
00113 // user include files
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    // friend classses and functions
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    // constants, enums and typedefs
00146    typedef DecayClass value_type ;
00147 
00148    // Constructors and destructor
00149    DCDecayList( bool ( * pFunction )( DecayClass& ) = 0 ) ;
00150    // need this function to stop default copy constructor
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    // assignment operator(s)
00165    // need this function to stop default assignment operator
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             //only check compatable conjugation if something already in
00194             // this list, otherwise could have problem with default value
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    // member functions
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    // Constructors and destructor
00218 
00219    public:
00220    DCDecayList(
00221          dchain::LabeledParticleList< DecayClass , CandidateClass >& aLabeledDecayList ,
00222          dchain::conjugation::Label aLabel ) ;
00223 
00224    private:
00225    // Constructors and destructor
00226 
00227    // private member functions
00228    using dchain::DecayList<DecayClass,CandidateClass>::fill;
00229    template<class TDecayList>
00230       void fill( const TDecayList& aList ) {
00231          //std::cout << "@DCDecayList::fill()" << std::endl;
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    // private const member functions
00245 
00246    // data members
00247    bool ( * m_function )( DecayClass& ) ;
00248    DCSelectionFunction< DecayClass >* m_functionalObject ;
00249 
00250 
00251    // static data members
00252 
00253 } ;
00254 
00255 // inline function definitions
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 // function definitions
00312 #include "DecayChain/List/Template/DCDecayList.cc"
00313 
00314 #endif /* DCHAIN_DCDECAYLIST_H */
00315 
00316 
00317 
00318 

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