00001 // 00002 // File: CDCandidate.cc 00003 // Author: Simon Patton 00004 // Package: Taxi - a prototype set of objects for Physics analysis 00005 // Contents: Definitions of the members of `CDCandidate' class. 00006 // 00007 // Class Description: See CDCandidate.h. 00008 // 00009 // $Id: CDCandidate.cxx,v 1.4 2011/10/27 06:15:12 zoujh Exp $ 00010 // 00011 00012 #include <stdlib.h> // For 'exit' 00013 #include <iostream> 00014 00015 #include "EvtRecEvent/EvtRecTrack.h" 00016 #include "EvtRecEvent/EvtRecPi0.h" 00017 #include "EvtRecEvent/EvtRecEtaToGG.h" 00018 #include "EvtRecEvent/EvtRecVeeVertex.h" 00019 #include "DecayChain/Element/ReferenceHolder.h" 00020 00021 #include "BesDChain/util/KinematicData.h" 00022 #include "BesDChain/CDCandidate.h" 00023 #include "BesDChain/CDDecay.h" 00024 00025 using namespace dchain; 00026 00027 using DecayChain::KinematicData; 00028 00029 #ifdef EXTEND 00030 //for recover 4p after kinematic fit 00031 void CDCandidate::recover() const { kinematicData()->recover(); } 00032 #endif 00033 //------ Constructor ----- 00034 // copy constructor 00035 // 00036 CDCandidate::CDCandidate( const CDCandidate& aOtherCDCandidate ) : 00037 ReferenceCount(), 00038 m_kinematicDataPtr(0), 00039 m_footPrint( aOtherCDCandidate.footPrint() ) 00040 { 00041 if ( 0 != aOtherCDCandidate.m_kinematicDataPtr ) { 00042 setKinematicData( * (aOtherCDCandidate.kinematicData()) ) ; 00043 } 00044 } 00045 00046 00047 //------ Constructor ----- 00048 // constructor with just a footprint 00049 // 00050 CDCandidate::CDCandidate( const CDFootPrint& aCDFootPrint ) : 00051 m_kinematicDataPtr( 0 ) , 00052 m_footPrint( aCDFootPrint ) 00053 { 00054 } 00055 00056 //------ Destructor ----- 00057 // 00058 CDCandidate::~CDCandidate() 00059 { 00060 delete m_kinematicDataPtr ; 00061 } 00062 00063 00064 //------ assignment ----- 00065 // fill an *empty* candidate with aother CDCandidate's information 00066 // 00067 const CDCandidate& CDCandidate::operator=( const CDCandidate& aOtherCDCandidate ) 00068 { 00069 if ( 0 == aOtherCDCandidate.m_kinematicDataPtr ) { 00070 delete m_kinematicDataPtr ; 00071 m_kinematicDataPtr = 0 ; 00072 } 00073 else { 00074 setKinematicData( * (aOtherCDCandidate.kinematicData()) ) ; 00075 } 00076 m_footPrint = aOtherCDCandidate.footPrint() ; 00077 return ( *this ) ; 00078 } 00079 00080 00081 void CDCandidate::setUserTag(int tag) 00082 { 00083 this->modifiableKinematicData()->setUserTag( tag ); 00084 } 00085 00086 //------ setMomentum ----- 00087 // 00088 CDCandidate& CDCandidate::setP4( const HepLorentzVector& aMomentum ) 00089 { 00090 this->modifiableKinematicData()->setP4( aMomentum ) ; 00091 return( *this ) ; 00092 } 00093 00094 00095 //------ setKinematicData ----- 00096 // set the KTKinematicData to a new values 00097 // Does not fill initial value with defaultKinematicData. 00098 // 00099 void CDCandidate::setKinematicData( const KinematicData& aKinematicData ) 00100 { 00101 if ( 0 == m_kinematicDataPtr ) { 00102 m_kinematicDataPtr = new KinematicData( aKinematicData ) ; 00103 if ( 0 == m_kinematicDataPtr ) { 00104 std::cerr << "No memory to allocate another kinematicData" << std::endl ; 00105 exit( 1 ) ; 00106 } 00107 return ; 00108 } 00109 (*(this->modifiableKinematicData())) = aKinematicData ; 00110 return ; 00111 } 00112 00113 00114 //------ setCDFootPrint ----- 00115 // set the CDFootPrint to a new value 00116 // 00117 void CDCandidate::setCDFootPrint( const CDFootPrint& aCDFootPrint ) 00118 { 00119 m_footPrint = aCDFootPrint ; 00120 } 00121 00122 //------ modifiableKinematicData ----- 00123 // get the non-const KTKinematicData for this candidate 00124 // 00125 KinematicData* CDCandidate::modifiableKinematicData() 00126 { 00127 if ( 0 == m_kinematicDataPtr ) { 00128 m_kinematicDataPtr = defaultKinematicData() ; 00129 if ( 0 == m_kinematicDataPtr ) { 00130 std::cerr << "No memory to allocate another kinematicData" << std::endl ; 00131 exit( 1 ) ; 00132 } 00133 } 00134 return m_kinematicDataPtr ; 00135 } 00136 00137 int CDCandidate::userTag() const 00138 { 00139 return kinematicData()->userTag(); 00140 } 00141 00142 //------ mass ----- 00143 // get the mass for this CDCandidate 00144 // 00145 double CDCandidate::mass() const 00146 { 00147 return kinematicData()->mass(); 00148 } 00149 00150 00151 //------ charge ----- 00152 // get the charge for this CDCandidate 00153 // 00154 int CDCandidate::charge() const 00155 { 00156 return kinematicData()->charge(); 00157 } 00158 00159 00160 //------ energy ----- 00161 // get the energy for this CDCandidate 00162 // 00163 double CDCandidate::energy() const 00164 { 00165 return kinematicData()->energy(); 00166 } 00167 00168 00169 //------ momentum ----- 00170 // get the momentum for this CDCandidate 00171 // 00172 const Hep3Vector& CDCandidate::momentum() const 00173 { 00174 return kinematicData()->p4(); 00175 } 00176 00177 const HepLorentzVector& CDCandidate::p4() const 00178 { 00179 return kinematicData()->p4(); 00180 } 00181 00182 //------ kinematicData ----- 00183 // get the kinematicData for this CDCandidate 00184 // 00185 const KinematicData* CDCandidate::kinematicData() const 00186 { 00187 // Cast away `const' to pick up the function. 00188 // This is safe as the result is being returned as a `const' 00189 return ( (*(CDCandidate*)this).modifiableKinematicData() ); 00190 } 00191 00192 CDCandidate::TracksAndShowers 00193 CDCandidate::finalChildren() const 00194 { 00195 TracksAndShowers blocks; 00196 recurseNode(blocks, *this); 00197 return blocks; 00198 } 00199 00200 void 00201 CDCandidate::recurseNode(CDCandidate::TracksAndShowers& final, 00202 const CDCandidate& cand) const 00203 { 00204 if(cand.builtFromTrack()) 00205 { 00206 final.first.push_back( cand.track() ); 00207 return; 00208 } 00209 if(cand.builtFromCDPhoton()) 00210 { 00211 final.second.push_back( cand.photon() ); 00212 return; 00213 } 00214 const DecayEvidence& decay = cand.decay(); 00215 const vector< ReferenceHolder<CDCandidate> >& children = decay.children(); 00216 vector< ReferenceHolder<CDCandidate> >::const_iterator lastChild = children.end(); 00217 for(vector<ReferenceHolder<CDCandidate> >::const_iterator child = children.begin(); 00218 child != lastChild; ++child) 00219 { 00220 recurseNode(final, **child); 00221 } 00222 } 00223 00224 //------ buildFromCDCharged ----- 00225 // false is there in no CDChargedEvidence associated with this CDCandidate 00226 // 00227 bool CDCandidate::builtFromTrack() const 00228 { 00229 return ( false ) ; 00230 } 00231 00232 00233 //------ chargedEvidence ----- 00234 // return the CDChargedEvidence that is associated with this CDCandidate 00235 // 00236 const EvtRecTrack* CDCandidate::track() const 00237 { 00238 std::cerr << "No navtrack for this CDCandidate" << std::endl ; 00239 exit( 1 ) ; 00240 return ( (EvtRecTrack*)0 ) ; 00241 } 00242 00243 00244 //------ builtFromCDPhoton ----- 00245 // false is there in no CDNeutralEvidence associated with this CDCandidate 00246 // 00247 bool CDCandidate::builtFromCDPhoton() const 00248 { 00249 return ( false ) ; 00250 } 00251 00252 00253 //------ photon ----- 00254 // return the NavShower that is associated with this CDCandidate 00255 // 00256 const EvtRecTrack* CDCandidate::photon() const 00257 { 00258 std::cerr << "No NavShower for this CDCandidate" << std::endl ; 00259 exit( 1 ) ; 00260 return ( (EvtRecTrack*)0 ) ; 00261 } 00262 00263 00264 //------ builtFromCDPi0 ----- 00265 // false is there in no CDNeutralEvidence associated with this CDCandidate 00266 // 00267 bool CDCandidate::builtFromCDPi0() const 00268 { 00269 return ( false ) ; 00270 } 00271 00272 00273 //------ pi0 ----- 00274 // return the NavCDPi0 that is associated with this CDCandidate 00275 // 00276 const EvtRecPi0* CDCandidate::navPi0() const 00277 { 00278 std::cerr << "No NavCDPi0 for this CDCandidate" << std::endl ; 00279 exit( 1 ) ; 00280 return ( (EvtRecPi0*)0 ) ; 00281 } 00282 00283 00284 //------ builtFromCDEta ----- 00285 // false is there in no CDNeutralEvidence associated with this CDCandidate 00286 // 00287 bool CDCandidate::builtFromCDEta() const 00288 { 00289 return ( false ) ; 00290 } 00291 00292 00293 //------ eta ----- 00294 // return the NavCDEta that is associated with this CDCandidate 00295 // 00296 const EvtRecEtaToGG* CDCandidate::navEta() const 00297 { 00298 std::cerr << "No NavCDEta for this CDCandidate" << std::endl ; 00299 exit( 1 ) ; 00300 return ( (EvtRecEtaToGG*)0 ) ; 00301 } 00302 00303 00304 //------ builtFromCDKs ----- 00305 // false is there in no CDNeutralEvidence associated with this CDCandidate 00306 // 00307 bool CDCandidate::builtFromCDKs() const 00308 { 00309 return ( false ) ; 00310 } 00311 00312 00313 //------ CDKs ----- 00314 // return the NavKs that is associated with this CDCandidate 00315 // 00316 const EvtRecVeeVertex* CDCandidate::navKshort() const 00317 { 00318 std::cerr << "No NavKs for this CDCandidate" << std::endl ; 00319 exit( 1 ) ; 00320 return ( (EvtRecVeeVertex*)0 ) ; 00321 } 00322 00323 00324 //------ builtFromCDLambda ----- 00325 // false is there in no CDNeutralEvidence associated with this CDCandidate 00326 // 00327 bool CDCandidate::builtFromCDLambda() const 00328 { 00329 return ( false ) ; 00330 } 00331 00332 00333 //------ CDLambda ----- 00334 // return the NavLambda that is associated with this CDCandidate 00335 // 00336 const EvtRecVeeVertex* CDCandidate::navLambda() const 00337 { 00338 std::cerr << "No NavLambda for this CDCandidate" << std::endl ; 00339 exit( 1 ) ; 00340 return ( (EvtRecVeeVertex*)0 ) ; 00341 } 00342 00343 00344 //------ builtFromCDDecay ----- 00345 // false is there in no CDDecay associated with this CDCandidate 00346 // 00347 bool CDCandidate::builtFromCDDecay() const 00348 { 00349 return ( false ) ; 00350 } 00351 00352 00353 //------ decay ----- 00354 // return the decay that is associated with this CDCandidate 00355 // 00356 const CDDecay& CDCandidate::decay() const 00357 { 00358 std::cerr << "No CDDecay for this CDCandidate" << std::endl ; 00359 exit( 1 ) ; 00360 return ( *(CDDecay*)0 ) ; 00361 } 00362 00363 //------ overlap ----- 00364 // returns false if this Candodate and OtherCDCandidate have no elements 00365 // in common 00366 // 00367 bool CDCandidate::overlap( const CDCandidate& aOtherCDCandidate ) const 00368 { 00369 return ( m_footPrint.overlap( aOtherCDCandidate.footPrint() ) ) ; 00370 } 00371 00372 //------ footPrint ----- 00373 // get the CDFootPrint for this CDCandidate 00374 // 00375 const CDFootPrint& CDCandidate::footPrint() const 00376 { 00377 return ( m_footPrint ) ; 00378 } 00379 00380 00381 //---------------------------------------------------------------------- 00382 // 00383 // $Log: CDCandidate.cxx,v $ 00384 // Revision 1.4 2011/10/27 06:15:12 zoujh 00385 // add user tag to particle data 00386 // 00387 // Revision 1.3 2009/09/22 08:24:41 hujf 00388 // see ChangeLog 00389 // 00390 // Revision 1.2 2009/06/22 14:55:48 zoujh 00391 // See ChangeLog 00392 // 00393 // Revision 1.1.1.1 2009/03/03 06:05:56 maqm 00394 // first import of BesDChain 00395 // 00396 // Revision 1.7 2006/06/05 16:14:58 gregor 00397 // Reordered constructor initializers to match .h file 00398 // 00399 // Revision 1.6 2006/01/11 20:37:25 cdj 00400 // work with renaming done in DChain package 00401 // 00402 // Revision 1.5 2004/03/05 22:01:43 chengp 00403 // implemented Monte Carlo matching 00404 // 00405 // Revision 1.4 2003/05/15 19:58:08 cdj 00406 // revamped memory handling so always use a ReferenceHolder to deal with the reference counting 00407 // 00408 // Revision 1.3 2001/09/12 19:10:32 ajm36 00409 // add lambda functions to CDCandidate 00410 // 00411 // Revision 1.2 2001/04/20 14:03:34 ajm36 00412 // add finalChildren function to return tracks and showers 00413 // 00414 // Revision 1.1 2001/04/11 13:19:00 urner 00415 // transition to files with CD prefix. Addition of new files 00416 // 00417 // Revision 1.3 2001/04/03 17:24:57 cdj 00418 // now always initialize m_kinematicDataPtr to 0 00419 // 00420 // Revision 1.2 2001/03/23 23:05:27 urner 00421 // added pi0 eta and CDKs decay lists 00422 // 00423 // Revision 1.1.1.1 2000/12/18 22:17:24 cdj 00424 // imported CleoDChain 00425 // 00426 // Revision 1.29 1998/05/04 19:10:41 sjp 00427 // Fixed access confusion for kinematicData 00428 // 00429 // Revision 1.28 1998/04/17 18:55:49 sjp 00430 // Modified to use latest types 00431 // 00432 // Revision 1.27 1997/09/03 14:58:30 sjp 00433 // Use new report.h and KTKinematicData 00434 // 00435 // Revision 1.26 1997/08/29 17:00:32 sjp 00436 // Modified to handle new Cairn Templated classes 00437 // 00438 // Revision 1.25 1997/08/25 02:50:34 sjp 00439 // empty returns now use typedef names 00440 // 00441 // Revision 1.24 1997/08/22 16:18:51 sjp 00442 // New name for access functions 00443 // 00444 // Revision 1.23 1997/08/20 12:45:36 sjp 00445 // Removed unnecessary <math.h> 00446 // 00447 // Revision 1.22 1997/08/19 23:02:44 sjp 00448 // Restructured package to be independent of CleoDChain 00449 // 00450 // Revision 1.21 1997/08/19 20:40:14 sjp 00451 // Updated to use <package>/<file>.h include structure. 00452 // (Note: This version of the code has not been compiled) 00453 // 00454 // Revision 1.20 1997/01/21 20:29:57 sjp 00455 // Changed CPP flags and include because of library reorganization 00456 // 00457 // Revision 1.19 1996/12/20 21:00:32 sjp 00458 // Request of non-existant reference is now and error 00459 // 00460 // Revision 1.18 1996/11/04 16:58:33 sjp 00461 // Separaqted of CDDecay part of CDCandidate into new class 00462 // 00463 // Revision 1.17 1996/07/16 19:05:28 sjp 00464 // Restructed Libraries 00465 // Put relative pathnames into all includes 00466 // 00467 // Revision 1.16 1996/06/21 21:21:19 sjp 00468 // Fixed bug, which was missing a return statment 00469 // 00470 // Revision 1.15 1996/06/19 19:30:13 sjp 00471 // Changed to use vector<> rather than deque<> 00472 // 00473 // Revision 1.14 1996/06/13 18:18:37 sjp 00474 // KTKinematicData is now a cached value 00475 // 00476 // Revision 1.13 1996/06/04 14:54:17 sjp 00477 // Coverted to use DB Classes 00478 // 00479 // Revision 1.12 1996/04/11 14:25:16 sjp 00480 // Set Z of missedDistance to Z0CD (a kludge) 00481 // 00482 // Revision 1.11 1996/04/05 20:05:12 sjp 00483 // Added function to get MCParticle, Track and Shower matches. 00484 // Reorganized the file. 00485 // Added a cobbled version of missedDistance. 00486 // 00487 // Revision 1.10 1996/02/27 15:50:15 sjp 00488 // Added functions to link CDCandidate with Track and Showers. 00489 // Allowed derived classes ability to addChild to children. 00490 // 00491 // Revision 1.9 1996/02/06 20:37:24 sjp 00492 // Added new functionality to map a CDCandidate onto its `truth'. 00493 // 00494 // Revision 1.8 1995/11/28 17:34:46 sjp 00495 // Changed `list' class to `deque' and added SJP_NOSTL switch. 00496 // Added child() and iterateChild() operations, and thus added Children 00497 // include file for enum. 00498 // Moved `Log' information. 00499 // 00500 // Revision 1.6 1995/11/25 23:26:43 sjp 00501 // Ammended to use KTKinematicData a basis for kinematic data. 00502 // 00503 // Revision 1.5 1995/11/22 02:49:59 sjp 00504 // list constructors no longer accept Size, now use set_max_size. 00505 // 00506 // Revision 1.4 1995/11/14 22:04:56 sjp 00507 // Updated to use `list' rather than SimpleList, and to use STL style 00508 // iterators. 00509 // 00510 // Revision 1.3 1995/11/14 21:24:01 sjp 00511 // Corrected bug, energy was not begin accumulated in constructor. 00512 // 00513 // Revision 1.2 1995/11/09 16:53:48 sjp 00514 // Move responsibility for mass, charge, momentum and energy into this class. 00515 // 00516 // Revision 1.1 1995/11/07 21:26:57 sjp 00517 // New base class for all CDCandidates. 00518 // 00519 //