BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
TrkHitList.cxx
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2// File and Version Information:
3// $Id: TrkHitList.cxx,v 1.5 2010/09/26 00:31:59 zhangy Exp $
4//
5// Description:
6//
7//
8// Environment:
9// Software developed for the BaBar Detector at the SLAC B-Factory.
10//
11// Author(s): Steve Schaffner
12//
13//------------------------------------------------------------------------
14#include "TrkBase/TrkHitList.h"
15#include "MdcRecoUtil/PdtPid.h" //yzhang debug
16#include "TrkBase/TrkErrCode.h"
17#include "TrkBase/TrkFundHit.h"
18#include "TrkBase/TrkHitOnTrk.h"
19#include "TrkBase/TrkHitOnTrkIter.h"
20#include "TrkBase/TrkHitUse.h"
21#include "TrkBase/TrkHotList.h"
22#include "TrkBase/TrkRecoTrk.h"
23#include "TrkBase/TrkRep.h"
24#include "TrkBase/TrkRepIter.h"
25#include <iostream>
26using namespace std;
27
28TrkHitList::TrkHitList( TrkRecoTrk* trk, PdtPid::PidType hypo )
29 : _theTrack( trk ), _myHypo( hypo ) {}
30
32
33TrkRep* TrkHitList::theRep() { return _theTrack->getRep( _myHypo ); }
34
35const TrkRep* TrkHitList::theRep() const { return _theTrack->getRep( _myHypo ); }
36
38 const TrkHotList* x = theRep()->hotList();
39 assert( x != 0 );
40 return *x;
41}
42
44 _theTrack->_fitNumber[_myHypo]++;
45
46 TrkErrCode err = theRep()->fit();
47 theRep()->hotList()->sort();
48 return err;
49}
50
51bool TrkHitList::removeHit( const TrkFundHit* theHit ) {
52 // This would be more efficient if the Rep did the finding of the Hot
53 // (save one search through each hotlist).
54 if ( theHit == 0 ) return false;
55 if ( !theHit->usedOnTrack( _theTrack ) )
56 {
57#ifdef MDCPATREC_WARNING
58 cout << "ErrMsg(warning) "
59 << "TrkHitList: you just deleted a hit that was not on the track." << endl;
60#endif
61 return false;
62 }
63 std::pair<TrkRepIter, TrkRepIter> reps = _theTrack->uniqueReps();
64 for ( TrkRepIter i = reps.first; i != reps.second; ++i )
65 {
66 // Find the Hot and ask the Rep to remove it
67 TrkHitOnTrk* h = i->hotList()->findHot( theHit );
68 if ( h != 0 ) i->removeHot( h );
69 }
70 return true;
71}
72
74 if ( theHot == 0 ) return 0;
75 // Test whether hit already on this track
76 if ( theHot->hit() != 0 && theHot->hit()->usedOnTrack( _theTrack ) )
77 {
78#ifdef MDCPATREC_WARNING
79 cout << "ErrMsg(warning)"
80 << "You just tried to add a hit to a track twice. "
81 << " Don't do that. " << endl;
82#endif
83 return 0;
84 }
85 TrkHitOnTrk* defaultHot = 0;
86 std::pair<TrkRepIter, TrkRepIter> reps = _theTrack->uniqueReps();
87 for ( TrkRepIter i = reps.first; i != reps.second; ++i )
88 {
89 TrkHitOnTrk* h = theHot->clone( i.get() );
90 i->addHot( h );
91 if ( i->particleType() == _theTrack->defaultType() ) defaultHot = h;
92 }
93 return defaultHot;
94}
95
97 // Test whether hit already on this track
98 if ( theHit.hit().usedOnTrack( _theTrack ) )
99 {
100#ifdef MDCPATREC_WARNING
101 cout << "ErrMsg(warning)"
102 << "You just tried to add a hit to a track twice."
103 << " Don't do that. " << endl;
104#endif
105 return 0;
106 }
107 TrkHitOnTrk* defaultHot = 0;
108
109 std::pair<TrkRepIter, TrkRepIter> reps = _theTrack->uniqueReps();
110 for ( TrkRepIter i = reps.first; i != reps.second; ++i )
111 {
112 TrkHitOnTrk* h = theHit.createHitOnTrk( *i );
113
114 i->addHot( h );
115 if ( i->particleType() == _theTrack->defaultType() ) defaultHot = h;
116 }
117 return defaultHot;
118}
119
120bool TrkHitList::append( const TrkHitList& list ) {
121 bool x( true );
122 for ( TrkHitList::hot_iterator i = list.begin(); i != list.end(); ++i )
123 {
124 TrkHitOnTrk* h = appendHot( i.get() );
125 x = ( x && h != 0 );
126 }
127 return x;
128}
Double_t x[10]
TrkErrCode fit()
TrkHitOnTrk * appendHot(const TrkHitOnTrk *theHot)
const TrkHotList & hotList() const
virtual ~TrkHitList()
bool removeHit(const TrkFundHit *theHit)
bool append(const TrkHitList &list)
TrkHitOnTrk * appendHit(const TrkHitUse &theHit)
virtual TrkHitOnTrk * clone(TrkRep *parentRep, const TrkDifTraj *trkTraj=0) const =0
virtual TrkHitOnTrk * createHitOnTrk(const TrkRep &) const =0
TrkRep * getRep(PdtPid::PidType hypo)