00001
00002
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
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114 #include <stdlib.h>
00115 #include <cmath>
00116
00117
00118 #include "BesDChain/util/KinematicData.h"
00119 #include "DecayChain/Function/DCAnalysisFunction.h"
00120 #include "BesDChain/CDDecay.h"
00121
00122 using namespace dchain;
00123 using std::vector;
00124 using DecayChain::KinematicData;
00125
00126 CDDecay::CDDecay( const CDDecay& aOtherCDDecay ) :
00127 #ifdef EXTEND
00128 m_kmfit_chisq(aOtherCDDecay.chisq()),
00129 m_vxfit_chisq(aOtherCDDecay.vchisq()),
00130 #endif
00131 CDCandidate( aOtherCDDecay ) ,
00132 m_children( *new vector< ReferenceHolder< CDCandidate > >( aOtherCDDecay.children() ) )
00133 {
00134 }
00135
00136 CDDecay::CDDecay( const CDCandidate& aProduct ) :
00137 #ifdef EXTEND
00138 m_kmfit_chisq(500000.),
00139 m_vxfit_chisq(500000.),
00140 #endif
00141 CDCandidate( aProduct.footPrint() ) ,
00142 m_children( *new vector< ReferenceHolder<CDCandidate> >
00143 ( 1, ReferenceHolder<CDCandidate>(&aProduct ) ) )
00144 {
00145 }
00146
00147 CDDecay::CDDecay( const CDDecay& aProducts, const CDCandidate& aAdditionalProduct ) :
00148 #ifdef EXTEND
00149 m_kmfit_chisq(500000.),
00150 m_vxfit_chisq(500000.),
00151 #endif
00152 CDCandidate( aProducts.footPrint() + aAdditionalProduct.footPrint() ) ,
00153 m_children( *new vector< ReferenceHolder<CDCandidate> >( aProducts.children() ) )
00154 {
00155 m_children.push_back( ReferenceHolder<CDCandidate>(&aAdditionalProduct) ) ;
00156 }
00157
00158 CDDecay::~CDDecay()
00159 {
00160 delete &m_children ;
00161 }
00162
00163 CDDecay::CDDecay() :
00164 #ifdef EXTEND
00165 m_kmfit_chisq(500000.),
00166 m_vxfit_chisq(500000.),
00167 #endif
00168 CDCandidate( CDFootPrint() ),
00169 m_children( *new vector< ReferenceHolder<CDCandidate> > )
00170 {
00171 }
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187 void CDDecay::addChild( const CDCandidate& aAdditionalProduct )
00188 {
00189 setCDFootPrint( footPrint() + aAdditionalProduct.footPrint() );
00190 m_children.push_back( ReferenceHolder<CDCandidate>(&aAdditionalProduct) ) ;
00191 }
00192
00193 void CDDecay::setKinematicData( const KinematicData& aKinematicData )
00194 {
00195
00196 CDCandidate::setKinematicData( aKinematicData );
00197 }
00198
00199
00200
00201
00202
00203 bool CDDecay::builtFromCDDecay() const
00204 {
00205 return ( !false ) ;
00206 }
00207
00208 const CDDecay& CDDecay::decay() const
00209 {
00210 return ( *this ) ;
00211 }
00212
00213
00214
00215
00216 uint32_t CDDecay::numberChildren() const
00217 {
00218 return ( m_children.size() ) ;
00219 }
00220
00221
00222
00223
00224 void CDDecay::iterateChildren( void ( * analyze )( const CDCandidate& ) ) const
00225 {
00226 vector< ReferenceHolder<CDCandidate> >::const_iterator finished( m_children.end() ) ;
00227 for ( vector< ReferenceHolder<CDCandidate> >::const_iterator child( m_children.begin() ) ;
00228 child != finished ;
00229 ++child ) {
00230 analyze( (*(*child)) ) ;
00231 }
00232 }
00233
00234
00235
00236
00237 void CDDecay::iterateChildren( DCAnalysisFunction< CDCandidate >& analyze ) const
00238 {
00239 vector< ReferenceHolder<CDCandidate> >::const_iterator finished ( m_children.end() ) ;
00240 for ( vector< ReferenceHolder<CDCandidate> >::const_iterator child ( m_children.begin() ) ;
00241 child != finished ;
00242 ++child ) {
00243 analyze( (*(*child)) ) ;
00244 }
00245 }
00246
00247 const CDCandidate& CDDecay::child( unsigned int aPosition ) const
00248 {
00249 if ( aPosition >= m_children.size() ) {
00250 std::cerr << "Trying to access an invalid Child" << std::endl ;
00251 return ( *(m_children[ 0 ]) ) ;
00252 }
00253 return ( *(m_children[ aPosition ]) ) ;
00254 }
00255
00256 const vector< ReferenceHolder<CDCandidate> >& CDDecay::children() const
00257 {
00258 return ( m_children ) ;
00259 }
00260
00261 KinematicData*
00262 CDDecay::defaultKinematicData() const
00263 {
00264 int userTag = 1 ;
00265 double energySum = 0 ;
00266 int chargeSum = 0 ;
00267 HepLorentzVector p4( 0.0 , 0.0 , 0.0, 0.0 ) ;
00268 vector< ReferenceHolder<CDCandidate> >::const_iterator finished( m_children.end() ) ;
00269 for ( vector< ReferenceHolder<CDCandidate> >::const_iterator child( m_children.begin() ) ;
00270 child != finished ;
00271 ++child ) {
00272 userTag &= (*(*child)).userTag();
00273 chargeSum += (*(*child)).charge() ;
00274 p4 += (*(*child)).p4() ;
00275 }
00276
00277 KinematicData* tmp = new KinematicData();
00278
00279 tmp->setUserTag( userTag );
00280 tmp->setCharge( chargeSum );
00281 tmp->setP4( p4 );
00282
00283 return tmp;
00284 }
00285
00286
00287