BOSS 7.0.1
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcTrackList Class Reference

#include <MdcTrackList.h>

+ Inheritance diagram for MdcTrackList:

Public Member Functions

 MdcTrackList (const MdcTrackParams &tkPar)
 
 ~MdcTrackList ()
 
int createFromSegs (MdcSegList *segs, const MdcHitMap *, const MdcDetector *, TrkContext &, double bunchTime)
 
int finishCircle (MdcTrack &track, const MdcHitMap *, const MdcDetector *)
 
int finishHelix (MdcTrack &track, const MdcHitMap *, const MdcDetector *)
 
int pickHits (MdcTrack *, const MdcHitMap *, const MdcDetector *, bool pickAmb=true)
 
void dumpSeed (const MdcSeg *seed, bool goodOnly)
 
void dumpCircle (const MdcTrack *)
 
void dumpAxFill (const MdcTrack *)
 
void dumpAxCombine (const MdcTrack *)
 
void dumpD0 (const TrkExchangePar &)
 
void dumpStFill ()
 
void dumpStCombine (const MdcTrack *)
 
void dumpHelix (const MdcTrack *)
 
void dropMultiHotInLayer (const MdcTrack *tk)
 
 MdcTrackList (const MdcTrackParams &tkPar)
 
 ~MdcTrackList ()
 
int createFromSegs (MdcSegList *segs, const MdcHitMap *, const MdcDetector *, TrkContext &, double bunchTime)
 
int finishCircle (MdcTrack &track, const MdcHitMap *, const MdcDetector *)
 
int finishHelix (MdcTrack &track, const MdcHitMap *, const MdcDetector *)
 
int pickHits (MdcTrack *, const MdcHitMap *, const MdcDetector *, bool pickAmb=true)
 
void dumpSeed (const MdcSeg *seed, bool goodOnly)
 
void dumpCircle (const MdcTrack *)
 
void dumpAxFill (const MdcTrack *)
 
void dumpAxCombine (const MdcTrack *)
 
void dumpD0 (const TrkExchangePar &)
 
void dumpStFill ()
 
void dumpStCombine (const MdcTrack *)
 
void dumpHelix (const MdcTrack *)
 
void dropMultiHotInLayer (const MdcTrack *tk)
 
- Public Member Functions inherited from MdcTrackListBase
 MdcTrackListBase (const MdcTrackParams &tkPar)
 
virtual ~MdcTrackListBase ()
 
int nTrack () const
 
void setPlot (int plotFlag)
 
void newParams (const MdcTrackParams &tkPar)
 
void plot () const
 
void store (RecMdcTrackCol *, RecMdcHitCol *)
 
virtual int createFromSegs (MdcSegList *, const MdcHitMap *, const MdcDetector *, TrkContext &, double bunchTime)=0
 
int arbitrateHits ()
 
void dropMultiHotInLayer (const MdcTrack *tk)
 
void remove (MdcTrack *atrack)
 
void setD0Cut (double d0Cut)
 
void setZ0Cut (double z0Cut)
 
void setPtCut (double ptCut)
 
 MdcTrackListBase (const MdcTrackParams &tkPar)
 
virtual ~MdcTrackListBase ()
 
int nTrack () const
 
void setPlot (int plotFlag)
 
void newParams (const MdcTrackParams &tkPar)
 
void plot () const
 
void store (RecMdcTrackCol *, RecMdcHitCol *)
 
virtual int createFromSegs (MdcSegList *, const MdcHitMap *, const MdcDetector *, TrkContext &, double bunchTime)=0
 
int arbitrateHits ()
 
void dropMultiHotInLayer (const MdcTrack *tk)
 
void remove (MdcTrack *atrack)
 
void setD0Cut (double d0Cut)
 
void setZ0Cut (double z0Cut)
 
void setPtCut (double ptCut)
 

Additional Inherited Members

- Static Public Attributes inherited from MdcTrackListBase
static double m_d0Cut = -999.
 
static double m_z0Cut = -999.
 
static double m_ptCut = -999.
 
- Protected Attributes inherited from MdcTrackListBase
MdcTrackParams tkParam
 

Detailed Description

Constructor & Destructor Documentation

◆ MdcTrackList() [1/2]

MdcTrackList::MdcTrackList ( const MdcTrackParams tkPar)

Definition at line 91 of file MdcTrackList.cxx.

91 :
92 MdcTrackListBase(tkPar) {
93 // *************************************************************************
94 return;
95 }

◆ ~MdcTrackList() [1/2]

MdcTrackList::~MdcTrackList ( )

Definition at line 98 of file MdcTrackList.cxx.

98{}

◆ MdcTrackList() [2/2]

MdcTrackList::MdcTrackList ( const MdcTrackParams tkPar)

◆ ~MdcTrackList() [2/2]

MdcTrackList::~MdcTrackList ( )

Member Function Documentation

◆ createFromSegs() [1/2]

int MdcTrackList::createFromSegs ( MdcSegList segs,
const MdcHitMap map,
const MdcDetector gm,
TrkContext context,
double  bunchTime 
)
virtual

Implements MdcTrackListBase.

Definition at line 103 of file MdcTrackList.cxx.

105 {
106 // *************************************************************************
107 //Forms tracks out of list of superlayer segments
108 int nTracks = 0;
109
110 m_debug = tkParam.lPrint;//yzhang debug
111
112 // Create empty list of stereo segs (to save time)
113 MdcSegGrouperSt stereoSegs(gm, tkParam.lPrint);
114
115 // *** Create r-phi track
116
117 // Create list of axial segments, treated as on tracks from origin
118#ifdef MDCPATREC_TIMETEST
119 TAU_PROFILE_TIMER(timer8,"fill ax seg", "int ()", TAU_DEFAULT);
120 TAU_PROFILE_START(timer8);
121#endif
122 MdcSegGrouperAx origSegs(gm, tkParam.lPrint);
123 origSegs.fillWithSegs(segs);
124 //std::cout << "Plot segs after ax fillWithSegs " << std::endl;//yzhang debug
125 //segs->plot(0);//yzhang debug
126#ifdef MDCPATREC_TIMETEST
127 TAU_PROFILE_STOP(timer8);
128#endif
129 MdcSeg *seed;
130 bool goodOnly = true;
131 bool useBad = (segs->count() < 400); // if true, use non-good seeds
132 //bool useBad = false;
133 segs->resetSeed(gm);
134 MdcTrack *trialTrack = 0;
135
136 while (1) {
137 seed = segs->getSeed(0,goodOnly);
138 if (seed == 0 && goodOnly && useBad) {
139 segs->resetSeed(gm);
140 goodOnly = false;
141 continue;
142 }
143 else if (seed == 0 && (!goodOnly || !useBad)) {
144 break;
145 }
146
147 if (3 == m_debug) dumpSeed(seed, goodOnly);//yzhang debug
148
149 // Pass through first superlayer of MDC required, Field layer No5 = 12.135 cm
150 if ( fabs( ((MdcSegInfoAxialO *) seed->info())->curv()) > 0.0417) continue;//curv cut yzhang
151 delete trialTrack;
152 trialTrack = 0;
153
154 //---------Combine Ax segs--------
155#ifdef MDCPATREC_TIMETEST
156 TAU_PROFILE_TIMER(timer3,"combine ax seg", "int ()", TAU_DEFAULT);
157 TAU_PROFILE_START(timer3);
158#endif
159 int success = origSegs.combineSegs(trialTrack, seed, context, bunchTime,
161#ifdef MDCPATREC_TIMETEST
162 TAU_PROFILE_STOP(timer3);
163#endif
164
165
166 if (3 <= m_debug){
167 cout<<" ***** Ax.combineSegs success? " << success<<"\n";
168 dumpAxCombine(trialTrack);//yzhang debug
169 }
170 if (!success) continue;
171
172
173 //--------Finish circle--------
174#ifdef MDCPATREC_TIMETEST
175 TAU_PROFILE_TIMER(timer4,"circle fitting", "int ()", TAU_DEFAULT);
176 TAU_PROFILE_START(timer4);
177#endif
178 success = finishCircle(*trialTrack, map, gm);
179#ifdef MDCPATREC_TIMETEST
180 TAU_PROFILE_STOP(timer4);
181#endif
182
183 if (3 <= m_debug){
184 cout<<"finishCircle success? " << success<<"\n";
185 dumpCircle(trialTrack);//yzhang debug
186 }
187
188 if (!success) continue;
189 //--------Make sure it really did come from origin--------
190 const TrkFit* tkFit = trialTrack->track().fitResult();
191 assert (tkFit != 0);
192 TrkExchangePar par = tkFit->helix(0.0);
193 //dumpD0(par);
194
195 //------------------d0 cut-------------------
196 // 2010-03-31 , m_d0Cut from 0 to epsilon
197
198 //std::cout<< __FILE__ <<" d0 cut------------"<< fabs(par.d0())<<" d0cut "<< m_d0Cut << std::endl;
199 if ( (m_d0Cut > Constants::epsilon) && (fabs(par.d0()) > m_d0Cut) ){
200 if (tkParam.lPrint>1)cout<<__FILE__<<" Killing track by d0:" <<par.d0()<<">"<<m_d0Cut << endl;
201 continue;
202 }
203
204 //------------------pt cut-------------------
205 if ( (fabs(m_ptCut)>0.) && (fabs(tkFit->pt(0.)) < m_ptCut) ){
206 if (tkParam.lPrint>1)cout<<__FILE__<<" Killing track by pt:" <<tkFit->pt(0.)<<"<"<<m_ptCut << endl;
207 continue;
208 }
209
210 // *** End r-phi track-finding
211 if (3 <= m_debug) std::cout << " *** End r-phi track-finding "<<std::endl;
212
213 //--------Add stereo to taste--------
214#ifdef MDCPATREC_TIMETEST
215 TAU_PROFILE_TIMER(timer5,"fill st seg", "int ()", TAU_DEFAULT);
216 TAU_PROFILE_START(timer5);
217#endif
218 stereoSegs.fillWithSegs(segs, trialTrack);
219#ifdef MDCPATREC_TIMETEST
220 TAU_PROFILE_STOP(timer5);
221#endif
222 if (3 <= m_debug){
223 //dumpStFill();//yzhang debug
224 std::cout<<std::endl<<"----------------------------------------"<< std::endl;
225 std::cout<<" Segment list after St.fillWithSegs "<< std::endl;
226 stereoSegs.dumpSegList();
227 }
228
229#ifdef MDCPATREC_TIMETEST
230 TAU_PROFILE_TIMER(timer6,"combine st seg", "int ()", TAU_DEFAULT);
231 TAU_PROFILE_START(timer6);
232#endif
233 success = stereoSegs.combineSegs(trialTrack, 0, context, bunchTime,
235#ifdef MDCPATREC_TIMETEST
236 TAU_PROFILE_STOP(timer6);
237#endif
238
239 if (3 <= m_debug){
240 cout<<" ***** St.combineSegs success? " << success<<"\n";
241 dumpStCombine(trialTrack);
242 }
243
244
245 //--------Finish 3-d track--------
246 if (success) {
247#ifdef MDCPATREC_TIMETEST
248 TAU_PROFILE_TIMER(timer7,"helix fitting", "int ()", TAU_DEFAULT);
249 TAU_PROFILE_START(timer7);
250#endif
251 success = finishHelix(*trialTrack, map, gm);
252#ifdef MDCPATREC_TIMETEST
253 TAU_PROFILE_STOP(timer7);
254#endif
255 } // end if (success -- st)
256
257 if (3 == m_debug){
258 dumpHelix(trialTrack);
259 }
260 if (!success) continue;
261
262 //------------------d0 cut after helix fitting-------------------
263 //yzhang add 2011-08-01
264 double d0par = trialTrack->track().fitResult()->helix(0.).d0();
265 if ( (m_d0Cut > Constants::epsilon) && (fabs(d0par) > m_d0Cut) ){
266 if (tkParam.lPrint>1) {cout<<__FILE__
267 <<" Killing track by d0 after 3d fit:" <<d0par<<">"<<m_d0Cut << endl;}
268 continue;
269 }
270
271 double z0par = trialTrack->track().fitResult()->helix(0.).z0();
272 if ( (m_z0Cut > Constants::epsilon) && (fabs(z0par) > m_z0Cut) ){
273 if (tkParam.lPrint>1) {cout<<__FILE__
274 <<" Killing track by z0:" <<z0par<<">"<<m_z0Cut << endl;}
275 continue;
276 }
277
278
279 nTracks++;
280 append(trialTrack); // Add to list of Tracks
281
282 trialTrack = 0;
283
284 if (3 == m_debug) std::cout << " ***** End one track-finding *****"<<std::endl;
285 } // end while(1)
286
287 delete trialTrack;
288 return nTracks;
289
290}
int count() const
Definition: MdcSegList.cxx:419
MdcSeg * getSeed(int iview, int goodOnly)
Definition: MdcSegList.cxx:139
void resetSeed(const MdcDetector *gm)
Definition: MdcSegList.cxx:57
void dumpHelix(const MdcTrack *)
void dumpCircle(const MdcTrack *)
int finishHelix(MdcTrack &track, const MdcHitMap *, const MdcDetector *)
void dumpAxCombine(const MdcTrack *)
void dumpSeed(const MdcSeg *seed, bool goodOnly)
int finishCircle(MdcTrack &track, const MdcHitMap *, const MdcDetector *)
void dumpStCombine(const MdcTrack *)
virtual double pt(double fltL=0.) const =0
virtual TrkExchangePar helix(double fltL) const =0
const TrkFit * fitResult() const
Definition: TrkRecoTrk.cxx:387
char * append(const char *str, EvtCyclic3::Index i)
Definition: EvtCyclic3.cc:284

◆ createFromSegs() [2/2]

int MdcTrackList::createFromSegs ( MdcSegList segs,
const MdcHitMap ,
const MdcDetector ,
TrkContext ,
double  bunchTime 
)
virtual

Implements MdcTrackListBase.

◆ dropMultiHotInLayer() [1/2]

void MdcTrackList::dropMultiHotInLayer ( const MdcTrack tk)

Definition at line 1151 of file MdcTrackList.cxx.

1151 {
1152 double tdr[43];
1153 double tdr_wire[43];
1154 for(int i=0; i<43; i++){tdr[i]=9999.;}
1155
1156 // make flag
1157 TrkHotList::hot_iterator hotIter= tk->track().hits()->hotList().begin();
1158 while (hotIter!=tk->track().hits()->hotList().end()) {
1159 MdcHitOnTrack* hot = const_cast<MdcHitOnTrack*> (&(*hotIter->mdcHitOnTrack()));
1160
1161 //driftTime(tof,z)
1162 double dt = hot->mdcHit()->driftTime(0.,0.);
1163 int layer = hot->mdcHit()->layernumber();
1164 int wire = hot->mdcHit()->wirenumber();
1165 if (dt < tdr[layer]) {
1166 tdr[layer] = dt;
1167 tdr_wire[layer] = wire;
1168 }
1169 hotIter++;
1170 }
1171
1172 std::cout<<" tdr wire ";
1173 for(int i=0;i<43;i++){
1174 std::cout<<i<<" "<<tdr[i]<<" "<<tdr_wire<<" ";
1175 }
1176 std::cout<<" "<< std::endl;
1177 // inactive multi hit
1178 hotIter= tk->track().hits()->hotList().begin();
1179 while (hotIter!=tk->track().hits()->hotList().end()) {
1180 int layer = hotIter->mdcHitOnTrack()->mdcHit()->layernumber();
1181 int wire = hotIter->mdcHitOnTrack()->mdcHit()->wirenumber();
1182 double dt = hotIter->mdcHitOnTrack()->mdcHit()->driftTime(0.,0.);
1183
1184 if ((tdr[layer] <9998.) && (tdr_wire[layer]!=wire)){
1185 MdcHitOnTrack* hot = const_cast<MdcHitOnTrack*> (&(*hotIter->mdcHitOnTrack()));
1186 hot->setActivity(false);
1187
1188 std::cout<<__FILE__<<" inactive "<< layer<<" "<<wire<<" dt "<<dt << std::endl;
1189 }
1190 hotIter++;
1191 }
1192}
TGraph2DErrors * dt
Definition: McCor.cxx:45
virtual const MdcHit * mdcHit() const
double driftTime(double tof, double z) const
Definition: MdcHit.cxx:142
const TrkHotList & hotList() const
Definition: TrkHitList.cxx:51
void setActivity(bool turnOn)
Definition: TrkHitOnTrk.cxx:96

◆ dropMultiHotInLayer() [2/2]

void MdcTrackList::dropMultiHotInLayer ( const MdcTrack tk)

◆ dumpAxCombine() [1/2]

void MdcTrackList::dumpAxCombine ( const MdcTrack trialTrack)

Definition at line 1057 of file MdcTrackList.cxx.

1057 {
1058 if (NULL == trialTrack) return;
1059 std::cout<<std::endl<< "-------------------------------------"<<std::endl;
1060 std::cout<<"Track and hitList after AxCombine "<<std::endl;
1061 trialTrack->track().printAll(cout);//yzhang debug
1062 TrkHotList::hot_iterator hotIter= trialTrack->track().hits()->hotList().begin();
1063 while (hotIter!=trialTrack->track().hits()->hotList().end()) {
1064 cout <<"(" <<((MdcHit*)(hotIter->hit()))->layernumber()
1065 <<","<<((MdcHit*)(hotIter->hit()))->wirenumber()
1066 <<":"<<hotIter->isActive()<<") ";
1067 hotIter++;
1068 }
1069 std::cout << std::endl;
1070 std::cout<< "-------------------------------------"<<std::endl;
1071}
virtual void printAll(std::ostream &) const

Referenced by createFromSegs().

◆ dumpAxCombine() [2/2]

void MdcTrackList::dumpAxCombine ( const MdcTrack )

◆ dumpAxFill() [1/2]

void MdcTrackList::dumpAxFill ( const MdcTrack trialTrack)

Definition at line 1044 of file MdcTrackList.cxx.

1044 {
1045 std::cout << "ax fill: "<<std::endl;
1046 if(!trialTrack){
1047 trialTrack->track().printAll(cout);//yzhang debug
1048 }
1049}

◆ dumpAxFill() [2/2]

void MdcTrackList::dumpAxFill ( const MdcTrack )

◆ dumpCircle() [1/2]

void MdcTrackList::dumpCircle ( const MdcTrack trialTrack)

Definition at line 1073 of file MdcTrackList.cxx.

1073 {
1074 if(NULL == trialTrack) return;
1075 if (!trialTrack->track().fitResult()) return;
1076 /*
1077 double omega,r,pt;
1078 omega =trialTrack->track().fitResult()->helix(0.0).omega();
1079 if (omega == 0) pt = 0;
1080 else pt = (-1) * 1/(omega * 333.576 );
1081 std::cout<<"in MdcTrackList Circle Pt = "<< pt <<std::endl;//yzhang deubg
1082
1083 if (omega == 0) r=0;
1084 else r = 1/ omega;
1085 std::cout<<"in MdcTrackList Circle R = "<< r <<std::endl;//yzhang deubg
1086 */
1087 std::cout<<std::endl<< "-------------------------------------"<<std::endl;
1088 std::cout << "Track and hitList after finishCircle" << std::endl;
1089 trialTrack->track().printAll(cout);
1090 TrkHotList::hot_iterator hotIter= trialTrack->track().hits()->hotList().begin();
1091 while (hotIter!=trialTrack->track().hits()->hotList().end()) {
1092 cout <<"(" <<((MdcHit*)(hotIter->hit()))->layernumber()
1093 <<","<<((MdcHit*)(hotIter->hit()))->wirenumber()
1094 <<":"<<hotIter->isActive()<<") ";
1095 hotIter++;
1096 }
1097 cout <<endl;
1098 std::cout<< "-------------------------------------"<<std::endl;
1099}

Referenced by createFromSegs().

◆ dumpCircle() [2/2]

void MdcTrackList::dumpCircle ( const MdcTrack )

◆ dumpD0() [1/2]

void MdcTrackList::dumpD0 ( const TrkExchangePar par)

Definition at line 1101 of file MdcTrackList.cxx.

1101 {
1102 //yzhang hist
1103 //m_hd0->fill(par.d0());
1104 //m_d0 = par.d0();
1105 // m_tuple1->write();//yzhang hist
1106 std::cout <<std::endl<< " Dump d0() " << par.d0()<<"\n";//yzhang debug
1107
1108 //zhangy hist
1109}

◆ dumpD0() [2/2]

void MdcTrackList::dumpD0 ( const TrkExchangePar )

◆ dumpHelix() [1/2]

void MdcTrackList::dumpHelix ( const MdcTrack trialTrack)

Definition at line 1133 of file MdcTrackList.cxx.

1133 {
1134 std::cout<< std::endl<<"-------------------------------------"<<std::endl;
1135 std::cout<< "Track and hitList after finishHelix " << std::endl;
1136 trialTrack->track().printAll(cout);
1137 TrkHotList::hot_iterator hotIter= trialTrack->track().hits()->hotList().begin();
1138 int tmplay = -1;
1139 while (hotIter!=trialTrack->track().hits()->hotList().end()) {
1140 int layer = ((MdcHit*)(hotIter->hit()))->layernumber();
1141 if( (layer%4) ==0 ) { if( tmplay != layer ) cout<<endl; }
1142 cout <<"(" <<layer <<","<<((MdcHit*)(hotIter->hit()))->wirenumber()
1143 <<":"<<hotIter->isActive() <<") ";
1144 hotIter++;
1145 tmplay = layer;
1146 }
1147 cout <<endl;
1148 std::cout<< "-------------------------------------"<<std::endl;
1149}

Referenced by createFromSegs().

◆ dumpHelix() [2/2]

void MdcTrackList::dumpHelix ( const MdcTrack )

◆ dumpSeed() [1/2]

void MdcTrackList::dumpSeed ( const MdcSeg seed,
bool  goodOnly 
)

Definition at line 1051 of file MdcTrackList.cxx.

1051 {
1052 std::cout << std::endl<<"Dump seed segment goodOnly="<<goodOnly<<" ";
1053 seed->plotSegAll();
1054 std::cout<< std::endl;
1055}
void plotSegAll() const
Definition: MdcSeg.cxx:159

Referenced by createFromSegs().

◆ dumpSeed() [2/2]

void MdcTrackList::dumpSeed ( const MdcSeg seed,
bool  goodOnly 
)

◆ dumpStCombine() [1/2]

void MdcTrackList::dumpStCombine ( const MdcTrack trialTrack)

Definition at line 1116 of file MdcTrackList.cxx.

1116 {
1117 std::cout<<std::endl<< "-------------------------------------"<<std::endl;
1118 std::cout<<"Track and hitList after StCombine "<<std::endl;
1119 if(trialTrack)trialTrack->track().printAll(cout);
1120 TrkHotList::hot_iterator hotIter= trialTrack->track().hits()->hotList().begin();
1121 int tmplay = -1;
1122 while (hotIter!=trialTrack->track().hits()->hotList().end()) {
1123 int layer = ((MdcHit*)(hotIter->hit()))->layernumber();
1124 if( (layer%4) ==0 ) { if( tmplay != layer ) cout<<endl; }
1125 cout <<"(" <<layer <<","<<((MdcHit*)(hotIter->hit()))->wirenumber()
1126 <<" act:"<<hotIter->isActive() <<" lr:"<<hotIter->ambig() <<") ";
1127 hotIter++;
1128 tmplay=layer;
1129 }
1130 cout <<endl;
1131 std::cout<< "-------------------------------------"<<std::endl;
1132}

Referenced by createFromSegs().

◆ dumpStCombine() [2/2]

void MdcTrackList::dumpStCombine ( const MdcTrack )

◆ dumpStFill() [1/2]

void MdcTrackList::dumpStFill ( )

Definition at line 1110 of file MdcTrackList.cxx.

1110 {
1111 std::cout << "Plot segs after st fillWithSegs " << std::endl;
1112 cout <<endl;
1113
1114}

◆ dumpStFill() [2/2]

void MdcTrackList::dumpStFill ( )

◆ finishCircle() [1/2]

int MdcTrackList::finishCircle ( MdcTrack track,
const MdcHitMap map,
const MdcDetector gm 
)

Definition at line 951 of file MdcTrackList.cxx.

952 {
953 //************************************************************************
954 TrkRecoTrk& trk = mdcTrk.track();
955 if(9==tkParam.lPrint){
956 std::cout << " finishCircle "<< std::endl;
957 trk.print(std::cout);
958 }
959
960 const TrkFit* tkFit = trk.fitResult();
961 if(9==tkParam.lPrint){ cout << "Before circle fit, nactive " << tkFit->nActive() << endl;}
962 assert (tkFit != 0);
963 TrkHitList* hitList = trk.hits();
964 assert (hitList != 0);
965 TrkCircleMaker circMaker;
966 circMaker.setFlipAndDrop(trk, false, false); // reset as a precaution
967 //circMaker.setFactor(trk, 1.);//nSigma cut factor//yzhang FIXME 2010-09-13
968
969 TrkErrCode fitResult = hitList->fit();
970 if (fitResult.failure()) {
971 trk.status()->addHistory(TrkErrCode(TrkErrCode::fail,15,"finishCircle"),"MdcTrkRecon");
972 if (tkParam.lPrint > 1) {
973 cout << "First circle fit failed: " << endl;
974 fitResult.print(std::cout);
975 }
976 return 0;
977 }
978 trk.status()->addHistory(TrkErrCode(TrkErrCode::succeed,15,"finishCircle"),"MdcTrkRecon");
979
980 if(9==tkParam.lPrint){ cout << "After circle fit, nactive " << tkFit->nActive() << endl;}
981 double chisqperDOF;
982 int nDOF = tkFit->nActive() - 3;
983 if (nDOF > 3){
984 chisqperDOF = tkFit->chisq() / nDOF;
985 }else{
986 chisqperDOF = tkFit->chisq();
987 }
988
989 if(g_cirTkChi2) { g_cirTkChi2->fill( chisqperDOF ); }//yzhang hist cut
990 int success = (chisqperDOF <= tkParam.maxChisq && tkFit->nActive() >= 3);
991
992 if(9==tkParam.lPrint){
993 std::cout<<__FILE__<<" "<<__LINE__
994 << " success "<<success
995 << " chisqperDOF "<< chisqperDOF<<"<? maxChisq "<< tkParam.maxChisq
996 << " nAct "<<tkFit->nActive()<<">=3 "
997 << std::endl;
998 mdcTrk.track().hots()->printAll(std::cout);
999 }
1000 bool lcurler(fabs(tkFit->helix(0).omega()) > 3.4);//yzhang FIXME, ??
1001 pickHits(&mdcTrk, map, gm, lcurler);
1002
1003 if(9==tkParam.lPrint){
1004 std::cout<< __FILE__ << " " << __LINE__ << " nHit after pickHit "<<hitList->nHit() <<std::endl;
1005 }
1006 //if(hitList->nHit()<=0) return 0;
1007
1008 circMaker.setFlipAndDrop(trk, true, true);
1009 fitResult = hitList->fit();
1010 if (fitResult.failure()) {
1011 if(9==tkParam.lPrint){
1012 cout << "Second circle fit failed: " << endl;
1013 fitResult.print(std::cout);
1014 }
1015 return 0;
1016 }
1017 if(9==tkParam.lPrint){
1018 cout << "Final fit: " << endl << trk << endl;
1019 }
1020 circMaker.setFlipAndDrop(trk, false, false);
1021
1022 nDOF = tkFit->nActive() - 3;
1023 if (nDOF > 3) {
1024 chisqperDOF = tkFit->chisq() / nDOF;
1025 }
1026 else {
1027 chisqperDOF = tkFit->chisq();
1028 }
1029 if(g_cirTkChi2) { g_cirTkChi2->fill( chisqperDOF ); }//yzhang hist cut
1030 success = (chisqperDOF <= tkParam.maxChisq) && (tkFit->nActive() >= 3);
1031
1032 if(9==tkParam.lPrint){
1033 cout << "chisqperDOF "<<chisqperDOF<<"=?" << tkParam.maxChisq<< endl;
1034 cout << "nActive "<<tkFit->nActive()<<">= 3"<< endl;
1035 }
1036
1037 if(9==tkParam.lPrint){
1038 trk.printAll(cout);
1039 }
1040
1041 return success;
1042}
int pickHits(MdcTrack *, const MdcHitMap *, const MdcDetector *, bool pickAmb=true)
virtual double chisq() const =0
void print(std::ostream &ostr) const
virtual void addHistory(const TrkErrCode &status, const char *modulename)
virtual int nActive() const =0
TrkErrCode fit()
Definition: TrkHitList.cxx:59
virtual void print(std::ostream &) const
const TrkFitStatus * status() const
Definition: TrkRecoTrk.cxx:400
bool setFlipAndDrop(TrkRecoTrk &, bool allowFlips, bool allowDrops) const

Referenced by createFromSegs().

◆ finishCircle() [2/2]

int MdcTrackList::finishCircle ( MdcTrack track,
const MdcHitMap ,
const MdcDetector  
)

◆ finishHelix() [1/2]

int MdcTrackList::finishHelix ( MdcTrack track,
const MdcHitMap map,
const MdcDetector gm 
)

Definition at line 863 of file MdcTrackList.cxx.

864 {
865 //***********************************************************************
866 int success = 1;
867
868 TrkRecoTrk& trk = mdcTrk.track();
869 TrkErrCode fitResult;
870 TrkHelixMaker helMaker;
871 const TrkFit* tkFit = trk.fitResult();
872 assert (tkFit != 0);
873 TrkHitList* hitList = trk.hits();
874 assert (hitList != 0);
875 TrkExchangePar par = tkFit->helix(0.0);
876
877
878 helMaker.setFlipAndDrop(trk, true, true);
879 fitResult = hitList->fit();
880
881 if (!fitResult.success() && (3 == tkParam.lPrint)) {
882 cout << "Helix fit failure: " << endl;
883 fitResult.print(cout);
884 }
885 helMaker.setFlipAndDrop(trk, false, false);
886
887 if (!fitResult.success()) return 0;
888
889 bool lcurler(fabs(tkFit->helix(0).omega()) > 3.4);//yzhang FIXME, ??
890 pickHits(&mdcTrk, map, gm, lcurler);//yzhang add 2010-05-10
891
892 if(3==tkParam.lPrint) std::cout<< __FILE__ << " " << __LINE__ << " nHit after pickHit "<<hitList->nHit() <<std::endl;
893 if(3==tkParam.lPrint) hitList->hotList().printAll(std::cout);
894 //if(hitList->nHit()<=0) return 0;
895
896 helMaker.setFlipAndDrop(trk, true, true);
897 fitResult = hitList->fit();
898 if (fitResult.failure()) {
899 if(3==tkParam.lPrint){
900 cout << "Second helix fit failed: " << endl;
901 fitResult.print(std::cout);
902 }
903 return 0;
904 }
905 if(3==tkParam.lPrint){ cout << "Final fit: " << endl << trk << endl; }
906 helMaker.setFlipAndDrop(trk, false, false);
907
908 double chisqperDOF = 0.;
909 int nACT = tkFit->nActive();
910 int nDOF = nACT - 5;
911 if (nDOF > 5) {
912 chisqperDOF = tkFit->chisq() / nDOF;
913 } else {
914 chisqperDOF = tkFit->chisq();
915 }
916 if(g_3dTkChi2) { g_3dTkChi2->fill( chisqperDOF ); }//yzhang hist cut
917 if(g_fitNAct) { g_fitNAct->fill(nACT ); }//yzhang hist cut
918
919 int goodMatch = 1;
920 if (fitResult.failure() || chisqperDOF > tkParam.maxChisq || nACT < tkParam.minHits ) {
921 goodMatch = 0;
922 if (3 == tkParam.lPrint) {
923 std::cout<<" goodMatch=0; chi2/dof "<<chisqperDOF <<" >?maxChisq"<<tkParam.maxChisq
924 <<" nAct:"<<nACT <<"<?minHits"<<tkParam.minHits << std::endl;
925 }
926 }
927 //yzhang add
928 ////yzhang FIXME
929 //if (tkParam.lUseQualCuts) {
930 //double tem2 = (float) trk.hits()->nHit() - nACT;
931 //if (tem2 >= tkParam.maxNmissTrack) goodMatch = 0;
932 //if (tem2 / float(trk.hits()->nHit()) > tkParam.maxNmissNorm)
933 //goodMatch = 0;
934 //}
935 //zhangy add
936
937 if (goodMatch) {
938 if(3 <= m_debug){std::cout<<" ***** finishHelix success!"<< std::endl;}
939 trk.fitResult()->positionErr(0.0);
940 } else { // Not a good match
941 success = 0;
942 if(3 <= m_debug){std::cout<<" ***** finishHelix failure!"<< std::endl;}
943 } // end if goodmatch
944
945 return success;
946}
virtual BesPointErr positionErr(double fltL) const =0
void printAll(std::ostream &o) const

Referenced by createFromSegs().

◆ finishHelix() [2/2]

int MdcTrackList::finishHelix ( MdcTrack track,
const MdcHitMap ,
const MdcDetector  
)

◆ pickHits() [1/2]

int MdcTrackList::pickHits ( MdcTrack trk,
const MdcHitMap map,
const MdcDetector gm,
bool  pickAmb = true 
)

!! change to using omega itself

Definition at line 295 of file MdcTrackList.cxx.

296 {
297
298 /***************************************************************************/
299
300 // Selects candidate hits along track;
301 // sorts them into "active" (small residual) and "inactive" (large resid);
302 // throws away hits separated from main group by large gaps. //?? FIXME
303 // pickAm => pick the ambiguity for hits already on track
304 // Return # of active hits found
305
306 bool is2d = trk->track().status()->is2d();
307 if(6==tkParam.lPrint){
308 cout << "Before pickHits";
309 if (is2d) cout<<" 2d:";
310 else cout<<" 3d:";
311 cout<< endl;
312 }
313
314 int nFound = 0;
315 int nCand = 0; // cells tried
316 double rMin, rMax; // min & max search radii for this track
317 double rEnter, rExit; // radii at which track enters, exits layer
318 BesAngle phiEnter, phiExit;//yzhang change
319 int wireLow, wireHigh;
320 double phiLow, phiHigh;
321 int nCell;
322 MdcHit *thisHit;
323 HepAList<MdcHitOnTrack> localHistory; //temporary list of added hits
324 //until bogus hits are chucked
325 double cellWidth;
326 double goodDriftCut; // missing hits with predDrift > goodDriftCut don't count in figuring gaps
327 double aresid = 0.; // = abs(resid)
328 int firstInputHit = -1; //first hit in firstInputLayer/lastInputLayer region
329 int lCurl = 0; // reached curl point
330
331 //****************************************************/
332 const MdcLayer *firstInputLayer = trk->firstLayer();
333 const MdcLayer *lastInputLayer = trk->lastLayer();
334
335 double bunchTime = trk->track().trackT0();
336 const TrkFit* tkFit = trk->track().fitResult();
337 assert (tkFit != 0);
338 const TrkFitStatus* tkStatus = trk->track().status();
339 assert (tkStatus != 0);
340 TrkHitList* hitList = trk->track().hits();
341 assert (hitList != 0);
342 TrkExchangePar par = tkFit->helix(0.0);
343 double d0 = par.d0();
344 double curv = 0.5 * par.omega(); //!!! change to using omega itself
345 double sinPhi0 = sin(par.phi0());
346 double cosPhi0 = cos(par.phi0());
347
348 // *** Set min and max radius for track
349 rMin = gm->firstLayer()->rIn();
350 double absd0 = fabs(d0);
351 if (absd0 > rMin) rMin = absd0 + Constants::epsilon;
352
353 bool willCurl = false;
354 double rCurl = fabs(d0 + 1./curv);
355 rMax = gm->lastLayer()->rOut();
356 //std::cout<< __FILE__ <<" "<< __LINE__<<" rCurl "<< rCurl <<" rMax "<< rMax << std::endl;
357 if (rCurl < rMax) {
358 willCurl = true;
359 rMax = rCurl - Constants::epsilon;
360 }
361 //std::cout<<" willCurl "<< willCurl << std::endl;
362 bool reachedLastInput = false;
363 bool hasCurled = false; // hit found past curl point
364
365 //yzhang add skip layer with hot, 2011-05-03
366 bool isHotOnLayer[43];
368 for(int ii=0; ii<43; ii++) isHotOnLayer[ii]=false;
369 for (TrkHitList::hot_iterator ihit(hitList->begin()); ihit != hitList->end(); ++ihit){
370 isHotOnLayer[ihit->layerNumber()]=true;
371 }
372 }
373
374 // *** Loop through layers in view, looking for the hits
375 // assumes axial inner
376 for (const MdcLayer *layer = gm->firstLayer(); layer != 0;
377 layer = ((!lCurl) ? ( (hasCurled) ? gm->prevLayer(layer) :
378 gm->nextLayer(layer)) : layer) ) {
379
380
381 if (lCurl) {
382 lCurl = 0;
383 hasCurled = true;
384 }
385 if (tkStatus->is2d() && layer->view() != 0) continue;
386
387 if(tkParam.pickSkipExistLayer && isHotOnLayer[layer->layNum()]) continue;//yzhang add 2011-05-03
388
389 //std::cout<< __FILE__ <<" "<< __LINE__ << " lCurl "<< lCurl
390 //<<" hasCurled "<< hasCurled <<" layer "<< layer->layNum() << std::endl;
391 bool lContinue = true;
392 if(tkParam.pickUitlLastLayer) {//yzhang change 2010-09-10
393 if (layer == lastInputLayer) reachedLastInput = true;
394 }
395
396 // *** Find enter and exit points
397 if (hasCurled) {
398 rEnter = layer->rOut();
399 if (rEnter < rMin) {
400 //std::cout<< __FILE__ <<" "<< __LINE__
401 //<<" rEnter<rMin "<<rEnter<<" "<<rMin<< std::endl;
402 break;
403 }
404 rExit = layer->rIn();
405 if (rExit < rMin) rExit = rMin;
406 if (rEnter > rMax) rEnter = rMax;
407
408 //std::cout<< __FILE__ <<" hasCurled: rEnter "<< rEnter
409 //<<" rExit " << rExit << " rMin "<<rMin<<" rMax "<<rMax<< std::endl;
410 } else {
411 rEnter = layer->rIn();
412 rExit = layer->rOut();
413 //std::cout<< __FILE__ <<" NOT hasCurled: rEnter "<< rEnter
414 //<<" rExit " << rExit << " rMin "<<rMin<<" rMax "<<rMax<< std::endl;
415 if (rExit < rMin) continue;
416
417 if (willCurl) {
418 if (rEnter > rMax) {
419 //std::cout<< __FILE__<<" Reached curl point before entering layer"<< std::endl;
420 // Reached curl point before entering layer
421 hasCurled = 1;
422 continue;
423 }
424 if (rExit > rMax) {
425 lCurl = 1;
426 rExit = rMax;
427 }
428 } else { // not a potential curler
429 //std::cout<< __FILE__ <<" "<< __LINE__ <<" not a potential curler"<< std::endl;
430 if (rEnter > rMax) {
431 //std::cout<< __FILE__ <<" rEnter> rMax "<< rEnter << std::endl;
432 break;
433 }
434 if (rExit > rMax) rExit = rMax;
435 }
436 } // end if curled already
437
438 nCell = layer->nWires();
439 cellWidth = Constants::twoPi * layer->rMid() / nCell;//??
440 // don't count outer xmm of cell
441 goodDriftCut = 0.5 * cellWidth * M_SQRT2 + tkParam.pickHitMargin;
442 //goodDriftCut = 0.5 * cellWidth - tkParam.pickHitMargin;//yzhang change 2012-08-17
443 double deltaPhiCellWidth = 0.5 * (cellWidth * M_SQRT2)/layer->rMid();
444
445 //**** Find entrance and exit phi's
446 BesAngle phiTemp(0.0);
447 int ierror = trk->projectToR(rEnter, phiTemp, hasCurled);
448 phiEnter = phiTemp.posRad();
449 if (ierror != 0) {
450 if(6==tkParam.lPrint) std::cout<< " ErrMsg(warning) "
451 << "Error in MdcTrackList::pickHits projection, ierror " <<ierror<< std::endl;
452 continue;//yzhang 2011-04-14
453 }
454 ierror = trk->projectToR(rExit, phiTemp, hasCurled);
455 phiExit = phiTemp.posRad();
456 if (ierror != 0) {
457 if(6==tkParam.lPrint) std::cout<< " ErrMsg(warning) "
458 << "Error in MdcTrackList::pickHits projection, ierror "<<ierror << std::endl;
459 continue;//yzhang 2011-04-14
460 }
461
462
463 if(6==tkParam.lPrint){
464 std::cout<< endl<<"--pickHit of layer "<<layer->layNum()<<"--"<<std::endl;
465 std::cout<< " track phiEnter "<< phiEnter.deg()<<" phiExit "<<phiExit.deg()<<" degree"<< std::endl;
466 std::cout<< " cell width "<< 360./layer->nWires()<<" dPhiz "<<layer->dPhiz()*Constants::radToDegrees <<" deltaPhiCellWidth "<<0.5 * (cellWidth * M_SQRT2)/layer->rMid() * Constants::radToDegrees<<std::endl;
467 std::cout<< " maxInactiveResid "<< tkParam.maxInactiveResid <<" pickHitPhiFactor "<<tkParam.pickHitPhiFactor<< std::endl;
468 std::cout<< " goodDriftCut "<< goodDriftCut <<"=sqrt(2)*0.5*"<<cellWidth<<"+"<<tkParam.pickHitMargin<< std::endl;
469 }
470
471 double Bz = trk->track().bField().bFieldZ();
472 //std::cout<< " facotr "<<tkParam.pickHitPhiFactor<< " dPhiz "<<layer->dPhiz()
473 //<< " factor*dPhiz "<<layer->dPhiz()*tkParam.pickHitPhiFactor<< std::endl;
474 double t_phiHit = -999.;
475 if (curv*Bz <= 0.0) {
476 //positive track in minus Bz
477 phiLow = phiEnter;
478 phiHigh = phiExit;
479 // Allow some slop in phi
480 phiLow -= tkParam.maxInactiveResid / rEnter;
481 phiHigh += tkParam.maxInactiveResid / rExit;
482 } else {
483 phiLow = phiExit;
484 phiHigh = phiEnter;
485 phiLow -= tkParam.maxInactiveResid / rExit;
486 phiHigh += tkParam.maxInactiveResid / rEnter;
487 }
488 //yzhang fix cross x axis bug 2011-04-10
489 if((phiHigh>0 && phiLow<0)){
490 phiLow += Constants::twoPi;
491 }else if((phiHigh<0 && phiLow>0)){
492 phiHigh += Constants::twoPi;
493 }
494
495 double lowFloat = nCell /Constants::twoPi * (phiLow - layer->phiOffset()) + 0.5;
496 double highFloat = nCell /Constants::twoPi * (phiHigh - layer->phiOffset()) + 0.5;
497 wireLow = (lowFloat >= 0.0) ? int(lowFloat) : int(floor(lowFloat));
498 wireHigh = (highFloat >= 0.0) ? int(highFloat) : int(floor(highFloat));
499
500 if(6==tkParam.lPrint){
501 std::cout << " wireLow "<<wireLow << " wireHigh "<<wireHigh <<" phiLow "<<phiLow*180./Constants::pi << " phiHigh "<<phiHigh*180./Constants::pi << std::endl;
502 }
503 // *** Loop through the predicted hit wires
504 int tempDiff = 0;
505 if(g_pickHitWire) {
506 int tempN = Constants::maxCell[layer->layNum()];
507 if(wireLow>tempN/2. && wireHigh<tempN/2.){
508 g_pickHitWire->fill(wireHigh+tempN - wireLow);
509 tempDiff = wireHigh+tempN - wireLow +1;
510 }else{
511 g_pickHitWire->fill(wireHigh - wireLow);
512 tempDiff = wireHigh - wireLow +1;
513 }
514 }//yzhang hist cut
515
516 if(wireLow>wireHigh) wireLow -= nCell;//yzhang 2011-05-16
517 long t_iHit = 0;
518 for (int thisWire = wireLow; thisWire <= wireHigh; thisWire++) {
519 int corrWire = mdcWrapWire(thisWire, nCell);
520 thisHit = map->hitWire(layer->layNum(), corrWire);
521
522 if(6==tkParam.lPrint){
523 if(thisHit != 0) {cout<<endl<<"test hit "; thisHit->print(std::cout);}
524 else std::cout << endl<<"test hit ("<<layer->layNum()<<","<<corrWire<<")"<< std::endl;
525 }
526
527 double tof = 0.;
528 double z = 0.;
529 double driftDist = 0.;
530 // Calculate expected drift distance
531 double delx, dely;
532 double resid = 0., predDrift = 0.;
533 int ambig = 0;
534 const MdcHitOnTrack *alink = 0;
535 double mcTkId = -9999; //yzhang for tuple 2011-06-28
536 if (thisHit == 0 ) {
537 delx = -d0 * sinPhi0 - layer->xWire(corrWire);
538 dely = d0 * cosPhi0 - layer->yWire(corrWire);
539 predDrift = cosPhi0 * dely - sinPhi0 * delx +
540 curv * (delx * delx + dely * dely);
541 if(6==tkParam.lPrint) cout<<"No hit. predDrift="<<predDrift<<endl;
542 continue;
543 } else {
544 if(m_tuplePick) mcTkId = thisHit->digi()->getTrackIndex();
545 // look for existing hit
546 if(thisHit->getHitOnTrack(&(trk->track())) ==0){
547 alink = 0;//yzhang temp
548 }else{
549 alink = thisHit->getHitOnTrack(&(trk->track()))->mdcHitOnTrack();//yzhang temp
550 if(6==tkParam.lPrint) { cout << " existing hot; " ;}
551 }
552
553 if (alink == 0 || pickAm) {
554 if ((!tkStatus->is2d()) && layer->view() != 0){
555 double rc = 9999.;
556 if(fabs(par.omega())>Constants::epsilon) rc = 1./fabs(par.omega());
557 double rw = layer->rMid();
558 double alpha = acos(1 - rw*rw/(2*rc*rc));
559 double fltLen = rw;
560 if(fabs(1 - rw*rw/(2*rc*rc))<1) fltLen = rc * alpha;
561 z = par.z0() + fltLen* par.tanDip();
562 tof = fltLen / Constants::c;
563 double x = layer->getWire(corrWire)->xWireDC(z);
564 double y = layer->getWire(corrWire)->yWireDC(z);
565 delx = -d0 * sinPhi0 - x;
566 dely = d0 * cosPhi0 - y;
567 if(m_tuplePick) t_phiHit = thisHit->phi(z);
568 }else{
569 delx = -d0 * sinPhi0 - thisHit->x();
570 dely = d0 * cosPhi0 - thisHit->y();
571 if(m_tuplePick) t_phiHit = thisHit->phi();
572 }
573 predDrift = cosPhi0 * dely - sinPhi0 * delx +
574 curv * (delx * delx + dely * dely);
575
576 // predDrift = predDrift * (1. - curv() * predDrift);
577 ambig = (predDrift >= 0) ? 1 : -1;
578 if (hasCurled) ambig = -ambig;
579 double entranceAngle=0.;
580 driftDist = thisHit->driftDist(tof+bunchTime,ambig,entranceAngle,0.,z);
581 if (alink == 0) {
582 // FIXME: is this ambig here VVVVV OK for incoming tracks?
583 resid = ambig * fabs(driftDist) - predDrift;
584 aresid = fabs(resid);
585 //if (aresid > tkParam.maxInactiveResid ) ambig = 0;//yzhang delete 2012-10-09
586 }
587 } else {
588 ambig = alink->ambig();
589 if(6==tkParam.lPrint) cout << " pick ambig for hot"<<endl;
590 if(m_tuplePick) t_phiHit = par.phi0()+par.omega()*alink->fltLen();
591 }
592 }
593
594 //yzhang 2012-08-20 , guess phi of this hit on z
595 double zGuess = par.z0() + layer->rMid() * par.tanDip();
596 double phiDCz = layer->getWire(corrWire)->phiDC(zGuess);
597 BesAngle phiDCzMax(phiDCz + deltaPhiCellWidth);
598 BesAngle phiDCzMin(phiDCz - deltaPhiCellWidth);
599
600 if(m_tuplePick && alink==0) {
601 double sigma = 999.;
602 if (thisHit != 0 &&alink==0) {
603 double entranceAngle = 0.;
604 sigma = thisHit->sigma(driftDist, ambig, entranceAngle, atan(par.tanDip()), z);
605 }
606 m_pickPredDrift[t_iHit] = predDrift;
607 m_pickDrift[t_iHit] = driftDist;
608 m_pickDriftTruth[t_iHit] = haveDigiDrift[thisHit->layernumber()][thisHit->wirenumber()];
609 if(curv*Bz<=0.){
610 //positive track under minus Bz
611 if((phiDCzMin-phiExit>0) || (phiDCzMax-phiEnter<0)) m_pickPhizOk[t_iHit] = 0;
612 else m_pickPhizOk[t_iHit] = 1;
613 }else{
614 if((phiDCzMin-phiEnter>0) || (phiDCzMax-phiExit<0)) m_pickPhizOk[t_iHit] = 0;
615 else m_pickPhizOk[t_iHit] = 1;
616 }
617 m_pickZ[t_iHit] = z;
618 m_pickWire[t_iHit]=thisHit->wirenumber();
619 m_pickResid[t_iHit] = aresid;
620 if(abs(sigma)>0.000001) m_pickSigma[t_iHit] = sigma;
621 else m_pickSigma[t_iHit] = 999.;
622 double t_phiLowCut=-999.;
623 double t_phiHighCut= -999.;
624 if(t_phiHit > -998.){
625 t_phiLowCut = (phiEnter-t_phiHit)*rEnter;
626 t_phiHighCut = (phiExit-t_phiHit)*rExit;
627 }
628 m_pickPhiLowCut[t_iHit] = t_phiLowCut;
629 m_pickPhiHighCut[t_iHit] = t_phiHighCut;
630 m_pickDriftCut[t_iHit] = goodDriftCut;
631 m_pickMcTk[t_iHit] = mcTkId;
632 m_pickPt[t_iHit] = tkFit->pt();
633 m_pickCurv[t_iHit] = curv;
634 t_iHit++;
635 }
636
637 if(curv*Bz<=0.){
638 //positive track
639 if((phiDCzMin-phiExit>0) || (phiDCzMax-phiEnter<0)) {
640 if(6==tkParam.lPrint){ std::cout<<" CUT by phiDCz not in phi En Ex range, curv>=0"<<std::endl; }
641 continue;
642 }
643 }else{
644 //negtive track
645 if((phiDCzMin-phiEnter>0) || (phiDCzMax-phiExit<0)) {
646 if(6==tkParam.lPrint){ std::cout<<" CUT by phiDCz not in phi En Ex range, curv<0"<<std::endl; }
647 continue;
648 }
649 }
650
651 // Cases
652 // (0) pred drift dist > goodDriftCut, drop Hit
653 if (ambig != 0 && fabs(predDrift) > goodDriftCut){//yzhang add 2012-08-17
654 if(6==tkParam.lPrint){cout<<" predDrift "<<predDrift<<">goodDriftCut "<<goodDriftCut<<endl;}
655 continue;
656 }
657
658 // (1) No good hit, but track near cell-edge => do nothing and continue
659 if (ambig == 0 && fabs(predDrift) > goodDriftCut){//yzhang 2009-11-03 add 3factor, 2011-05-30 from 3 to 2,2012-08-17 from 2 to 1
660 if(6==tkParam.lPrint){
661 cout<<" ambig==0 && |predDirft| "<<fabs(predDrift) <<"> goodDriftCut "<< goodDriftCut<<endl;
662 cout<<" No good hit, but track near cell-edge " << endl;
663 }
664 continue;
665 }
666
667
668 // (2) Hit found:
669 if (ambig != 0) {
670 //yzhang changed 2009-10-19
671 //if resid> maxActiveSimga * sigma do not add hits to track
672 double entranceAngle = 0.;
673 double sigma = thisHit->sigma(driftDist, ambig, entranceAngle, atan(par.tanDip()), z);
674 double factor = tkParam.pickHitFactor;
675 //yzhang delete 2012-10-09
676 //if(!is2d fabs(par.tanDip())<2) factor = (2-par.tanDip())/2 * factor;
677 double residCut = tkParam.maxActiveSigma * factor * sigma;//yzhang 2012-08-21
678 //if(6==tkParam.lPrint){
679 //std::cout<< "aresid "<<aresid<<" residCut "<<residCut<<" sigma "<<sigma <<" tanDip "<< par.tanDip() <<" factor "<<factor <<" tkParam.maxActiveSigma "<<tkParam.maxActiveSigma<<std::endl;
680 //}
681
682 if (alink == 0 && (aresid <= residCut) ) {
683 if(6==tkParam.lPrint){
684 cout << " (2) New hit found " << endl;//yzhang debug
685 }
686 //yzhang 2012-08-17 delete
687 int isActive = 1;
688 //if (aresid > residCut) isActive = 0;
689 //if(6==tkParam.lPrint) {
690 // if (aresid > residCut)
691 // std::cout << "notACT, resid "<<aresid<<" >residCut " << residCut<< std::endl;
692 //}
693 MdcRecoHitOnTrack tempHot(*thisHit, ambig, bunchTime);
694 tempHot.setActivity(isActive);
695 // Don't add active hits if they're in use.
696 if (thisHit->usedHit()){
697 tempHot.setUsability(false);
698 if(6==tkParam.lPrint) std::cout<< " thisHit used, setUsability false " << std::endl;
699 }
700 // very crude starting point for flight length !!!! improve
701 double flt = layer->rMid();
702 if (hasCurled) flt = Constants::twoPi * rCurl - layer->rMid();
703 flt += 0.000001 * (thisHit->x() + thisHit->y());
704 tempHot.setFltLen(flt);
705 if(6==tkParam.lPrint) {
706 std::cout<< " aresid "<<aresid<<"<=residCut " <<residCut<<" nSig "<<aresid/sigma<< " nSigCut "<<(tkParam.maxActiveSigma*factor)<<" factor "<<factor<<" maxActiveSigma "<<tkParam.maxActiveSigma<<" tanDip "<<par.tanDip()<<std::endl;
707 std::cout<< " Append Hot " << std::endl;
708 }
709 alink = (MdcHitOnTrack*) hitList->appendHot(&tempHot);
710 }else{
711 if(6==tkParam.lPrint){
712 if(alink!=0){
713 std::cout<< "Exist hot found"<<std::endl;
714 }else if(aresid > residCut){
715 thisHit->print(std::cout);
716 std::cout<< " Drop hit. aresid "<<aresid<<">residCut " <<residCut<<" nSig "<<aresid/sigma<< " nSigCut "<<(tkParam.maxActiveSigma*factor)<<" factor "<<factor<<" maxActiveSigma "<<tkParam.maxActiveSigma<<" tanDip "<<par.tanDip()<<std::endl;
717 }
718 }
719 }
720 if (!localHistory.member(const_cast<MdcHitOnTrack*>(alink))) {
721 localHistory.append(const_cast<MdcHitOnTrack*>(alink));
722 if (hasCurled) trk->setHasCurled();
723 nFound++;
724 if(6==tkParam.lPrint) std::cout<<" nFound="<<nFound<<" nCand "<<nCand<<std::endl;
725 if (layer == firstInputLayer && firstInputHit < 0) {
726 firstInputHit = nCand;
727 }
728 } else {
729 if(6==tkParam.lPrint) std::cout << "ErrMsg(warning) "<< "would have inserted identical HOT "
730 "twice in history buffer" << std::endl;
731 }
732 }
733
734 // (3) No hit found; if beyond known good region, should we continue?
735 else if (ambig == 0 && reachedLastInput) {
736 if(6==tkParam.lPrint) std::cout << "ambig==0 "<<std::endl;
737 lContinue = false;
738 int nSuccess = 0;
739 int last = 8;
740 if (nCand < 8) last = nCand;
741 for (int i = 0; i < last; i++) {
742 int j = nCand - 1 - i;
743 if (localHistory[j] != 0) {
744 //std::cout<< __FILE__ <<" localHistory["<<j<<"]!=0 nSuccess++ "<< std::endl;
745 nSuccess++;
746 }
747 if (i == 2 && nSuccess >= 2) lContinue = true;
748 if (i == 4 && nSuccess >= 3) lContinue = true;
749 if (i == 7 && nSuccess >= 5) lContinue = true;
750 if(6==tkParam.lPrint) cout <<i<< " (3) No hit found; if beyond known good region " << endl;//yzhang debug
751 if (lContinue) {
752 if(6==tkParam.lPrint) std::cout<<" pickHits break by lContinue. i="<<i<<" nSuccess="<<nSuccess<< std::endl;
753 break;
754 }
755 }
756
757 if(6==tkParam.lPrint) cout << " (3) No hit found; if beyond known good region " << endl;//yzhang debug
758 // if lContinue == false => there's been a gap, so quit
759 if (!lContinue) {
760 //std::cout<< __FILE__ <<" "<< __LINE__ <<" break by !lContinue "<< std::endl;
761 break;
762 }
763 localHistory.append(0);
764 }
765
766 nCand++;
767 // Update last layer:
768 if (ambig != 0 && reachedLastInput) {
769 if (trk->hasCurled() == 0) {
770 if (thisHit->layer()->rEnd() > trk->lastLayer()->rEnd()) {
771 trk->setLastLayer(thisHit->layer());
772 }
773 }
774 else {
775 if (thisHit->layer()->rEnd() < trk->lastLayer()->rEnd()) {
776 trk->setLastLayer(thisHit->layer());
777 }
778 }
779 }
780
781 } // end loop over hit wires
782 if(t_iHit>0 && m_tuplePick) {
783 m_pickNCell = tempDiff;
784 m_pickNCellWithDigi = t_iHit;
785 m_pickLayer = layer->layNum();
786 m_pickIs2D = is2d;
787 m_tuplePick->write();
788 }
789 if (!lContinue && reachedLastInput) {
790 //std::cout<< __FILE__ <<" break by !lContinue && reachedLastInput "<< std::endl;
791 break;
792 }
793 } // end loop over layers
794
795 // Now look back at hits in early layer and see if there are any to be thrown away there.
796 bool lContinue = true;
797 for (int ihit = firstInputHit; ihit >= 0; ihit--) {
798 if (localHistory[ihit] != 0) {
799 if (lContinue) {
800 // Update firstLayer
801 const MdcHitOnTrack *mdcHit = localHistory[ihit]->mdcHitOnTrack();
802 if (mdcHit != 0) {
803 if (mdcHit->layer()->rEnd() < trk->firstLayer()->rEnd()) {
804 trk->setFirstLayer(mdcHit->layer());
805 }
806 }
807 continue; // no gap yet
808 } else {
809 // gap found; delete hits
810 if(6==tkParam.lPrint){
811 std::cout << " gap found; delete hits. ";
812 }
813 if (!localHistory[ihit]->isUsable()) {
814 if(6==tkParam.lPrint){
815 cout << "about to delete hit for unusable HOT:" << endl;
816 localHistory[ihit]->print(std::cout);
817 }
818 hitList->removeHit(localHistory[ihit]->hit());
819 }
820 if(6==tkParam.lPrint){
821 cout << " current contents of localHistory: "
822 <<localHistory.length()<<"hot" << endl;
823 //for (int i=0; i<localHistory.length();++i) {
824 //cout << " hit @ " << localHistory[i]->hit() << "; hot @ " << localHistory[i] << endl;
825 //}
826 }
827 nFound--;
828 }
829 }
830 else if (localHistory[ihit] == 0) {
831 if(6==tkParam.lPrint){ cout << " localHistory= 0 " << endl; }
832 int nSuccess = 0;
833 lContinue = false;
834 int last = 8;
835 if (nCand < 8) last = nCand;
836 for (int i = 0; i < last; i++) {
837 int j = ihit + 1 + i;
838 if (localHistory[j] != 0) nSuccess++;
839 if (i == 2 && nSuccess >= 2) lContinue = true;
840 if (i == 4 && nSuccess >= 3) lContinue = true;
841 // if (i == 7 && nSuccess >= 5) lContinue = true;
842 if (lContinue) break;
843 }
844 }
845 }
846 if(6==tkParam.lPrint){
847 std::cout<< "nFound="<<nFound <<" < "<< tkParam.pickHitFract*nCand<<" pickHitFract? "<< tkParam.pickHitFract<<"*"<<nCand << std::endl;
848 }
849 if (nFound < tkParam.pickHitFract * nCand) nFound = 0;//yzhang delete 2010-05-10 use pickHitFract=0.
850 if(6==tkParam.lPrint){ cout << " localHistory= 0 " << endl; }
851
852 if(6==tkParam.lPrint || 3==tkParam.lPrint){
853 cout << "After pickHits found " << nFound <<" hit(s)"<< endl;
854 hitList->hotList().print(std::cout);
855 std::cout<< std::endl;
856 }
857
858 return nFound;
859}
Double_t x[10]
const double alpha
double sin(const BesAngle a)
double cos(const BesAngle a)
NTuple::Array< double > m_pickPhiLowCut
NTuple::Array< double > m_pickDriftCut
NTuple::Array< double > m_pickDriftTruth
NTuple::Array< double > m_pickPredDrift
NTuple::Array< double > m_pickPhiHighCut
int mdcWrapWire(int wireIn, int nCell)
const MdcLayer * prevLayer(int lay) const
const MdcLayer * nextLayer(int lay) const
MdcHit * hitWire(int lay, int wire) const
const MdcLayer * layer() const
const MdcDigi * digi() const
void print(std::ostream &o) const
double sigma(double, int, double, double, double) const
Definition: MdcHit.cxx:184
double driftDist(double, int, double, double, double) const
Definition: MdcHit.cxx:156
const MdcLayer * layer() const
int projectToR(double radius, BesAngle &phiIntersect, int lCurl=0) const
Definition: MdcTrack.cxx:63
int getTrackIndex() const
Definition: RawData.cxx:50
const TrkHitOnTrk * getHitOnTrack(const TrkRecoTrk *trk) const
Definition: TrkFundHit.cxx:95
TrkHitOnTrk * appendHot(const TrkHitOnTrk *theHot)
Definition: TrkHitList.cxx:91
bool removeHit(const TrkFundHit *theHit)
Definition: TrkHitList.cxx:69
void print(std::ostream &o) const
double trackT0() const
Definition: TrkRecoTrk.cxx:140

Referenced by finishCircle(), and finishHelix().

◆ pickHits() [2/2]

int MdcTrackList::pickHits ( MdcTrack ,
const MdcHitMap ,
const MdcDetector ,
bool  pickAmb = true 
)

The documentation for this class was generated from the following files: