00001 #ifndef DCHAIN_COMBINATORICLOOP_CC 00002 #define DCHAIN_COMBINATORICLOOP_CC 00003 // -*- C++ -*- 00004 // 00005 // Package: DChain 00006 // Module: CombinatoricLoop 00007 // 00008 // Description: <one line class summary> 00009 // 00010 // Implimentation: 00011 // <Notes on implimentation> 00012 // 00013 // Author: Simon Patton 00014 // Created: Mon Oct 21 10:06:47 EDT 1996 00015 // $Id: CombinatoricLoop.cc,v 1.1.1.1 2009/03/03 06:06:56 maqm Exp $ 00016 // 00017 // Revision history 00018 // 00019 // $Log: CombinatoricLoop.cc,v $ 00020 // Revision 1.1.1.1 2009/03/03 06:06:56 maqm 00021 // first import of DecayChain 00022 // 00023 // Revision 1.2 2006/01/12 13:44:47 cdj 00024 // missed a name change 00025 // 00026 // Revision 1.1 2006/01/11 20:28:35 cdj 00027 // massive class renaming, addition of [] for selection and unit tests 00028 // 00029 // Revision 1.2 2003/03/13 20:19:16 cleo3 00030 // now compiles under Linux 00031 // 00032 // Revision 1.1.1.1 2000/12/18 22:16:55 cdj 00033 // imported DChain 00034 // 00035 // Revision 1.10 1998/08/20 20:00:10 sjp 00036 // Modified to use DChainBoolean 00037 // 00038 // Revision 1.9 1998/08/19 20:46:22 sjp 00039 // Fixed comments and removed report references 00040 // 00041 // Revision 1.8 1997/09/03 14:58:23 sjp 00042 // Use new report.h and TBParticlePoint 00043 // 00044 // Revision 1.7 1997/08/28 07:00:37 sjp 00045 // Modified files to handle complete templating 00046 // 00047 // Revision 1.6 1997/08/19 23:03:16 sjp 00048 // Restructured package to be independent of Rock 00049 // 00050 // Revision 1.5 1997/08/19 16:19:06 sjp 00051 // Improved handling of STL containers 00052 // 00053 // Revision 1.4 1997/08/15 21:33:38 sjp 00054 // Updated to use <package>/<file>.h include structure. 00055 // Updated to use bug flags specified in Experiement.h 00056 // 00057 // Revision 1.3 1997/01/31 20:16:26 sjp 00058 // Modified to use the new `bug' include files 00059 // 00060 // Revision 1.2 1997/01/21 20:31:37 sjp 00061 // Changed CPP flags and include because of library reorganization 00062 // 00063 // Revision 1.1 1996/11/04 17:17:14 sjp 00064 // New file for new `List' module 00065 // 00066 00067 // system include files 00068 #include <stdlib.h> // For 'exit' 00069 00070 // user include files 00071 #include "DecayChain/Iterator/PartialCandidateItr.h" 00072 #include "DecayChain/List/CombinatoricLoop.h" 00073 00074 // 00075 // constants, enums and typedefs 00076 // 00077 namespace dchain { 00078 // 00079 // static data member definitions 00080 // 00081 00082 // 00083 // constructors and destructor 00084 // 00085 // CombinatoricLoop< CandidateClass >::CombinatoricLoop() 00086 // { 00087 // } 00088 00089 // CombinatoricLoop< CandidateClass >::CombinatoricLoop( const CombinatoricLoop< CandidateClass >& ) 00090 // { 00091 // } 00092 00093 template< class CandidateClass > 00094 CombinatoricLoop< CandidateClass >::CombinatoricLoop( const typename dchain::CandidateList< CandidateClass >::const_partial_iterator& aBegin , 00095 const typename dchain::CandidateList< CandidateClass >::const_partial_iterator& aEnd , 00096 _combinatoricloop_vector_& aLoopList ) : 00097 m_beginIterator( aBegin ) , 00098 m_endIterator( aEnd ) , 00099 m_previousDuplicate( 0 ) 00100 { 00101 typename _combinatoricloop_vector_::const_iterator lastLoop( aLoopList.begin() ) ; 00102 typename _combinatoricloop_vector_::const_iterator loopToCheck( aLoopList.end() ) ; 00103 while ( loopToCheck != lastLoop ) { 00104 --loopToCheck ; 00105 if ( ( (*(*loopToCheck)).m_beginIterator ) == m_beginIterator ) { 00106 m_previousDuplicate = new typename _combinatoricloop_vector_::const_iterator( loopToCheck ) ; 00107 (*(*(*m_previousDuplicate))).adjustEnd() ; 00108 // 00109 // only require one match, so prepare to terminate search for duplicate 00110 // 00111 loopToCheck = lastLoop ; 00112 } 00113 } 00114 } 00115 00116 template< class CandidateClass > 00117 CombinatoricLoop< CandidateClass >::~CombinatoricLoop() 00118 { 00119 delete m_previousDuplicate ; 00120 } 00121 00122 // 00123 // assignment operators 00124 // 00125 // const CombinatoricLoop< CandidateClass >& CombinatoricLoop< CandidateClass >::operator=( const CombinatoricLoop< CandidateClass >& ) 00126 // { 00127 // } 00128 00129 // 00130 // member functions 00131 // 00132 00133 template< class CandidateClass > 00134 void CombinatoricLoop< CandidateClass >::setCurrentIterator( typename dchain::CandidateList< CandidateClass >::const_partial_iterator& aIterator ) 00135 { 00136 m_currentIterator = aIterator ; 00137 } 00138 00139 // 00140 // const member functions 00141 // 00142 00143 template< class CandidateClass > 00144 const typename dchain::CandidateList< CandidateClass >::const_partial_iterator CombinatoricLoop< CandidateClass >::partial_begin() const 00145 { 00146 if ( 0 == m_previousDuplicate ) { 00147 return( m_beginIterator ) ; 00148 } 00149 typename dchain::CandidateList< CandidateClass >::const_partial_iterator newBegin( ( (*(*(*m_previousDuplicate))).m_currentIterator ) ) ; 00150 return( ++newBegin ) ; 00151 } 00152 00153 template< class CandidateClass > 00154 const typename dchain::CandidateList< CandidateClass >::const_partial_iterator CombinatoricLoop< CandidateClass >::partial_end() const 00155 { 00156 return( m_endIterator ) ; 00157 } 00158 00159 template< class CandidateClass > 00160 void CombinatoricLoop< CandidateClass >::adjustEnd() 00161 { 00162 if ( m_beginIterator != m_endIterator ) { 00163 --m_endIterator ; 00164 if ( 0 != m_previousDuplicate ) { 00165 (*(*(*m_previousDuplicate))).adjustEnd() ; 00166 } 00167 } 00168 } 00169 00170 // 00171 // static member functions 00172 // 00173 } 00174 #endif /* DCHAIN_COMBINATORICLOOP_CC */