CGEM BOSS 6.6.5.i
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 "TrkBase/TrkRecoTrk.h"
16#include "TrkBase/TrkHotList.h"
17#include "TrkBase/TrkHitOnTrk.h"
19#include "TrkBase/TrkErrCode.h"
20#include "TrkBase/TrkFundHit.h"
21#include "TrkBase/TrkRep.h"
22#include "TrkBase/TrkHitUse.h"
23#include "TrkBase/TrkRepIter.h"
24#include "MdcRecoUtil/PdtPid.h"//yzhang debug
25#include <iostream>
26using namespace std;
27
28TrkHitList::TrkHitList(TrkRecoTrk* trk, PdtPid::PidType hypo)
29 : _theTrack(trk)
30 , _myHypo(hypo)
31{
32}
33
37
38TrkRep*
39TrkHitList::theRep()
40{
41 return _theTrack->getRep(_myHypo);
42}
43
44const TrkRep*
45TrkHitList::theRep() const
46{
47 return _theTrack->getRep(_myHypo);
48}
49
50const TrkHotList&
52{
53 const TrkHotList* x = theRep()->hotList();
54 assert(x!=0);
55 return *x;
56}
57
60{
61 _theTrack->_fitNumber[_myHypo]++;
62
63 TrkErrCode err = theRep()->fit();
64 theRep()->hotList()->sort();
65 return err;
66}
67
68bool
70{
71 // This would be more efficient if the Rep did the finding of the Hot
72 // (save one search through each hotlist).
73 if (theHit == 0) return false;
74 if (!theHit->usedOnTrack(_theTrack)) {
75#ifdef MDCPATREC_WARNING
76 cout <<"ErrMsg(warning) "<<
77 "TrkHitList: you just deleted a hit that was not on the track." << endl;
78#endif
79 return false;
80 }
81 std::pair<TrkRepIter,TrkRepIter> reps = _theTrack->uniqueReps();
82 for (TrkRepIter i= reps.first; i != reps.second; ++i) {
83 // Find the Hot and ask the Rep to remove it
84 TrkHitOnTrk* h = i->hotList()->findHot(theHit);
85 if (h != 0) i->removeHot(h);
86 }
87 return true;
88}
89
92{
93 if (theHot == 0) return 0;
94 // Test whether hit already on this track
95 if (theHot->hit() != 0 && theHot->hit()->usedOnTrack(_theTrack)) {
96#ifdef MDCPATREC_WARNING
97 cout <<"ErrMsg(warning)"
98 << "You just tried to add a hit to a track twice. "
99 <<" Don't do that. "<< endl;
100#endif
101 return 0;
102 }
103 TrkHitOnTrk* defaultHot = 0;
104 std::pair<TrkRepIter,TrkRepIter> reps = _theTrack->uniqueReps();
105 for (TrkRepIter i=reps.first; i != reps.second; ++i) {
106 TrkHitOnTrk* h = theHot->clone(i.get());
107 i->addHot(h);
108 if (i->particleType() == _theTrack->defaultType()) defaultHot = h;
109 }
110 return defaultHot;
111}
112
115{
116 // Test whether hit already on this track
117 if (theHit.hit().usedOnTrack(_theTrack)) {
118#ifdef MDCPATREC_WARNING
119 cout <<"ErrMsg(warning)"
120 <<"You just tried to add a hit to a track twice."
121 <<" Don't do that. " << endl;
122#endif
123 return 0;
124 }
125 TrkHitOnTrk* defaultHot = 0;
126
127 std::pair<TrkRepIter,TrkRepIter> reps = _theTrack->uniqueReps();
128 for (TrkRepIter i= reps.first; i != reps.second; ++i) {
129 TrkHitOnTrk* h = theHit.createHitOnTrk(*i);
130
131 i->addHot(h);
132 if (i->particleType() == _theTrack->defaultType()) defaultHot = h;
133 }
134 return defaultHot;
135}
136
137bool
139{
140 bool x(true);
141 for(TrkHitList::hot_iterator i = list.begin(); i!=list.end();++i) {
142 TrkHitOnTrk* h = appendHot(i.get());
143 x = ( x && h!=0);
144 }
145 return x;
146}
Double_t x[10]
PidType
Definition PdtPid.h:11
bool usedOnTrack(const TrkRecoTrk *t) const
Definition TrkFundHit.h:67
TrkErrCode fit()
hot_iterator begin() const
Definition TrkHitList.h:45
TrkHitOnTrk * appendHot(const TrkHitOnTrk *theHot)
const TrkHotList & hotList() const
hot_iterator end() const
Definition TrkHitList.h:46
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
const TrkFundHit * hit() const
Definition TrkHitOnTrk.h:75
const TrkFundHit & hit() const
Definition TrkHitUse.h:35
virtual TrkHitOnTrk * createHitOnTrk(const TrkRep &) const =0
virtual void sort()
PdtPid::PidType defaultType() const
Definition TrkRecoTrk.h:78
std::pair< TrkRepIter, TrkRepIter > uniqueReps() const
TrkRep * getRep(PdtPid::PidType hypo)
virtual TrkErrCode fit()=0
virtual TrkHotList * hotList()
Definition TrkRep.h:109