/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Reconstruction/MdcPatRec/TrkBase/TrkBase-00-01-12/src/TrkHitList.cxx

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 // File and Version Information:
00003 //      $Id: TrkHitList.cxx,v 1.5 2010/09/26 00:31:59 zhangy Exp $
00004 //
00005 // Description:
00006 //
00007 //
00008 // Environment:
00009 //      Software developed for the BaBar Detector at the SLAC B-Factory.
00010 //
00011 // Author(s): Steve Schaffner
00012 //
00013 //------------------------------------------------------------------------
00014 #include "TrkBase/TrkHitList.h"
00015 #include "TrkBase/TrkRecoTrk.h"
00016 #include "TrkBase/TrkHotList.h"
00017 #include "TrkBase/TrkHitOnTrk.h"
00018 #include "TrkBase/TrkHitOnTrkIter.h"
00019 #include "TrkBase/TrkErrCode.h"
00020 #include "TrkBase/TrkFundHit.h"
00021 #include "TrkBase/TrkRep.h"
00022 #include "TrkBase/TrkHitUse.h"
00023 #include "TrkBase/TrkRepIter.h"
00024 #include "MdcRecoUtil/PdtPid.h"//yzhang debug
00025 #include <iostream>
00026 using namespace std;
00027 
00028 TrkHitList::TrkHitList(TrkRecoTrk* trk, PdtPid::PidType hypo)
00029         : _theTrack(trk)
00030         , _myHypo(hypo)
00031 {
00032 }
00033 
00034 TrkHitList::~TrkHitList()
00035 {
00036 }
00037 
00038 TrkRep*
00039 TrkHitList::theRep()
00040 {
00041   return _theTrack->getRep(_myHypo);
00042 }
00043 
00044 const TrkRep*
00045 TrkHitList::theRep() const
00046 {
00047   return _theTrack->getRep(_myHypo);
00048 }
00049 
00050 const TrkHotList&
00051 TrkHitList::hotList() const
00052 {
00053   const TrkHotList* x = theRep()->hotList();
00054   assert(x!=0);
00055   return *x;
00056 }
00057 
00058 TrkErrCode
00059 TrkHitList::fit()
00060 {
00061   _theTrack->_fitNumber[_myHypo]++;
00062 
00063   TrkErrCode err = theRep()->fit();
00064   theRep()->hotList()->sort();
00065   return err;
00066 }
00067 
00068 bool
00069 TrkHitList::removeHit(const TrkFundHit *theHit)
00070 {
00071   // This would be more efficient if the Rep did the finding of the Hot
00072   //   (save one search through each hotlist).
00073   if (theHit == 0) return false;
00074   if (!theHit->usedOnTrack(_theTrack)) {
00075 #ifdef MDCPATREC_WARNING
00076     cout <<"ErrMsg(warning) "<<
00077       "TrkHitList: you just deleted a hit that was not on the track." << endl;
00078 #endif
00079     return false;
00080   }
00081   std::pair<TrkRepIter,TrkRepIter> reps = _theTrack->uniqueReps();
00082   for (TrkRepIter i= reps.first; i != reps.second; ++i) {
00083     // Find the Hot and ask the Rep to remove it
00084     TrkHitOnTrk* h = i->hotList()->findHot(theHit);
00085     if (h != 0) i->removeHot(h);
00086   }
00087   return true;
00088 }
00089 
00090 TrkHitOnTrk*
00091 TrkHitList::appendHot(const TrkHitOnTrk *theHot)
00092 {
00093   if (theHot == 0) return 0;
00094   // Test whether hit already on this track
00095   if (theHot->hit() != 0 && theHot->hit()->usedOnTrack(_theTrack)) {
00096 #ifdef MDCPATREC_WARNING
00097       cout <<"ErrMsg(warning)" 
00098            << "You just tried to add a hit to a track twice. "
00099            <<" Don't do that. "<< endl;
00100 #endif
00101       return 0;
00102   }
00103   TrkHitOnTrk* defaultHot = 0;
00104   std::pair<TrkRepIter,TrkRepIter> reps = _theTrack->uniqueReps();
00105   for (TrkRepIter i=reps.first; i != reps.second; ++i) {
00106     TrkHitOnTrk* h = theHot->clone(i.get());
00107     i->addHot(h);
00108     if (i->particleType() == _theTrack->defaultType()) defaultHot = h;
00109   }
00110   return defaultHot;
00111 }
00112 
00113 TrkHitOnTrk*
00114 TrkHitList::appendHit(const TrkHitUse& theHit)
00115 {
00116   // Test whether hit already on this track
00117   if (theHit.hit().usedOnTrack(_theTrack)) {
00118 #ifdef MDCPATREC_WARNING
00119     cout <<"ErrMsg(warning)" 
00120          <<"You just tried to add a hit to a track twice."
00121          <<" Don't do that. " << endl;
00122 #endif
00123     return 0;
00124   }
00125   TrkHitOnTrk* defaultHot = 0;
00126     
00127   std::pair<TrkRepIter,TrkRepIter> reps = _theTrack->uniqueReps();
00128   for (TrkRepIter i= reps.first; i != reps.second; ++i) {
00129     TrkHitOnTrk* h = theHit.createHitOnTrk(*i);
00130     
00131     i->addHot(h);
00132     if (i->particleType() == _theTrack->defaultType()) defaultHot = h;
00133   }
00134   return defaultHot;
00135 }
00136 
00137 bool
00138 TrkHitList::append(const TrkHitList& list)
00139 {
00140    bool x(true);
00141    for(TrkHitList::hot_iterator i = list.begin(); i!=list.end();++i) {
00142         TrkHitOnTrk* h = appendHot(i.get());
00143         x = ( x && h!=0);
00144    }
00145    return x;
00146 }

Generated on Tue Nov 29 23:13:40 2016 for BOSS_7.0.2 by  doxygen 1.4.7