#include <MdcTrackList.h>
Inheritance diagram for MdcTrackList:
Public Member Functions | |
int | arbitrateHits () |
int | arbitrateHits () |
int | createFromSegs (MdcSegList *segs, const MdcHitMap *, const MdcDetector *, TrkContext &, double bunchTime) |
int | createFromSegs (MdcSegList *segs, const MdcHitMap *, const MdcDetector *, TrkContext &, double bunchTime) |
void | dropMultiHotInLayer (const MdcTrack *tk) |
void | dropMultiHotInLayer (const MdcTrack *tk) |
void | dumpAxCombine (const MdcTrack *) |
void | dumpAxCombine (const MdcTrack *) |
void | dumpAxFill (const MdcTrack *) |
void | dumpAxFill (const MdcTrack *) |
void | dumpCircle (const MdcTrack *) |
void | dumpCircle (const MdcTrack *) |
void | dumpD0 (const TrkExchangePar &) |
void | dumpD0 (const TrkExchangePar &) |
void | dumpHelix (const MdcTrack *) |
void | dumpHelix (const MdcTrack *) |
void | dumpSeed (const MdcSeg *seed, bool goodOnly) |
void | dumpSeed (const MdcSeg *seed, bool goodOnly) |
void | dumpStCombine (const MdcTrack *) |
void | dumpStCombine (const MdcTrack *) |
void | dumpStFill () |
void | dumpStFill () |
int | finishCircle (MdcTrack &track, const MdcHitMap *, const MdcDetector *) |
int | finishCircle (MdcTrack &track, const MdcHitMap *, const MdcDetector *) |
int | finishHelix (MdcTrack &track, const MdcHitMap *, const MdcDetector *) |
int | finishHelix (MdcTrack &track, const MdcHitMap *, const MdcDetector *) |
MdcTrackList (const MdcTrackParams &tkPar) | |
MdcTrackList (const MdcTrackParams &tkPar) | |
void | newParams (const MdcTrackParams &tkPar) |
void | newParams (const MdcTrackParams &tkPar) |
int | nTrack () const |
int | nTrack () const |
int | pickHits (MdcTrack *, const MdcHitMap *, const MdcDetector *, bool pickAmb=true) |
int | pickHits (MdcTrack *, const MdcHitMap *, const MdcDetector *, bool pickAmb=true) |
void | plot () const |
void | plot () const |
void | remove (MdcTrack *atrack) |
void | remove (MdcTrack *atrack) |
void | setD0Cut (double d0Cut) |
void | setD0Cut (double d0Cut) |
void | setPlot (int plotFlag) |
void | setPlot (int plotFlag) |
void | setPtCut (double ptCut) |
void | setPtCut (double ptCut) |
void | setZ0Cut (double z0Cut) |
void | setZ0Cut (double z0Cut) |
void | store (RecMdcTrackCol *, RecMdcHitCol *) |
void | store (RecMdcTrackCol *, RecMdcHitCol *) |
~MdcTrackList () | |
~MdcTrackList () | |
Static Public Attributes | |
double | m_d0Cut = -999. |
double | m_ptCut = -999. |
double | m_z0Cut = -999. |
Protected Attributes | |
MdcTrackParams | tkParam |
Private Member Functions | |
MdcTrackList (const MdcTrackList &) | |
MdcTrackList (const MdcTrackList &) | |
MdcTrackList & | operator= (const MdcTrackList &) |
MdcTrackList & | operator= (const MdcTrackList &) |
Private Attributes | |
int | m_debug |
|
00064 : 00065 MdcTrackListBase(tkPar) { 00066 // ************************************************************************* 00067 return; 00068 }
|
|
00071 {}
|
|
|
|
|
|
|
|
|
|
|
|
00104 { 00105 //************************************************************************* 00106 // Look at all hits used in two or more tracks. Assign hits to the track 00107 // that gives the lower residual. If, however, many hits are shared by 00108 // a pair of tracks, assign them all to one or the other. 00109 // Refit any tracks that have had hits dropped. 00110 // The implementation is very clumsy, since the arrays were originally 00111 // indexed by id # => there is an unneeded layer of indexing. 00112 00113 // return # of tracks deleted 00114 00115 if (8 == tkParam.lPrint){ 00116 std::cout << "=======Print before arbitrateHits=======" << std::endl; 00117 } 00118 00119 int nDeleted = 0; 00120 std::vector<MdcTrack*> trksToKill; 00121 trksToKill.reserve(4); 00122 00123 MdcMap<long,long> idMap; 00124 00125 //usedInTrackNum records how many shared hits track has with each other track 00126 int* usedInTrackNum = new int [nTrack()]; 00127 // to navigate from track id # to track pointer: 00128 MdcTrack** trkXRef = new MdcTrack* [nTrack()]; 00129 //refitTrack flags track id #s of tracks to be refit 00130 int *refitTrack = new int [nTrack()]; 00131 for (int i = 0; i < nTrack(); i++) { 00132 refitTrack[i] = 0; 00133 } 00134 00135 // Fill xref table 00136 int itrack; 00137 for (itrack = 0; itrack < nTrack(); itrack++) { 00138 MdcTrack *atrack = (*this)[itrack]; 00139 if (atrack == 0) continue; // I don't think it can be, but . . . 00140 idMap.put(atrack->track().id(), itrack); 00141 trkXRef[itrack] = atrack; 00142 } 00143 // Loop through the tracks 00144 for (itrack = 0; itrack < nTrack(); itrack++) { 00145 00146 if (8 == tkParam.lPrint) std::cout<<"arbitrate track No."<<itrack<< std::endl; 00147 MdcTrack *atrack = (*this)[itrack]; 00148 if (atrack == 0) continue; 00149 TrkRecoTrk& aRecoTrk = atrack->track(); 00150 int lRefit = 0; 00151 int trackOld = -1; 00152 const TrkFit* tkFit = aRecoTrk.fitResult(); 00153 assert (tkFit != 0); 00154 TrkHitList* hitList = aRecoTrk.hits(); 00155 assert (hitList != 0); 00156 restart: 00157 for (int ii = 0; ii < nTrack(); ii++) usedInTrackNum[ii] = 0; 00158 00159 // Loop through hits on track, counting # used in other tracks 00160 int nPrev = 0; 00161 int nHitDeleted = 0; 00162 int nHitInLayer[43];//yzhang 2010-09-20 for bad tracking testing 00163 int nDeleteInLayer[43];//yzhang 2010-09-20 00164 for(int i=0;i<43;i++){ 00165 nHitInLayer[i]=0; 00166 nDeleteInLayer[i]=0; 00167 } 00168 if(8 == tkParam.lPrint) std::cout<< "--arbitrate--"<<std::endl; 00169 for (TrkHitList::hot_iterator ihit(hitList->begin()); ihit != hitList->end(); ++ihit){ 00170 int nUsed = ihit->hit()->nUsedHits(); 00171 if (8 == tkParam.lPrint){ 00172 std::cout<<"nUsed="<<nUsed<<":"; 00173 ihit->hit()->printAll(std::cout); 00174 } 00175 if (8 == tkParam.lPrint) { 00176 double deltaChi = -999; 00177 ihit->getFitStuff(deltaChi); 00178 std::cout<< "deltaChi="<<deltaChi<<std::endl; 00179 } 00180 int layer = ihit->layerNumber(); 00181 nHitInLayer[layer]++; 00182 00183 if (!ihit->isActive()) { 00184 //----------------------------------- 00185 //yzhang delete not ACT hit 2010-05-14 00186 //----------------------------------- 00187 if(tkParam.lRemoveInActive ) {//2010-05-16 00188 if (8 == tkParam.lPrint) { 00189 std::cout<< "=remove above inactive "<<std::endl; 00190 } 00191 TrkFundHit* hit = const_cast<TrkFundHit*> (ihit->hit()); 00192 if(hitList->removeHit(hit)){ hit->setUnusedHit(&(*ihit)); } 00193 if(ihit == hitList->end()) break; 00194 --ihit;//be careful of the iterator, yzhang 00195 nDeleteInLayer[layer]++; 00196 } 00197 continue; // active hits only yzhang 2009-11-03 delete 00198 } 00199 if (nUsed > 1) { 00200 bool wasUsed = false; 00201 std::pair<TrkFundHit::hot_iterator,TrkFundHit::hot_iterator> q = 00202 ihit->hit()->getUsedHits(); 00203 for (TrkFundHit::hot_iterator i = q.first; i != q.second; ++i) { 00204 if ( !i->isActive() ) continue; //yzhang 2009-11-03 delete 00205 TrkRecoTrk * recoTrk=i->parentTrack(); 00206 int id = recoTrk->id(); 00207 if (id == aRecoTrk.id()) continue; //skip same track 00208 long index = 0; 00209 idMap.get(id, index); 00210 assert(index >= 0); 00211 usedInTrackNum[index]++; 00212 if (8 == tkParam.lPrint){ 00213 std::cout<<" track "<<itrack<<"&" <<index 00214 << " shared hits "<<usedInTrackNum[index]<<":"; 00215 ihit->printAll(std::cout); 00216 } 00217 wasUsed = true; 00218 } 00219 if (wasUsed) nPrev++; 00220 }// end nUsed > 1 00221 } // end loop over hits 00222 00223 for (int i=0;i<43;i++){ 00224 if (8 == tkParam.lPrint) { 00225 std::cout<<i<<" nHitInLayer "<<nHitInLayer[i] 00226 <<" nDeleteInLayer "<<nDeleteInLayer[i]<<std::endl; 00227 } 00228 if(nHitInLayer[i]>0 && (nHitInLayer[i]-nDeleteInLayer[i])==0) { 00229 nHitDeleted++; 00230 if (8 == tkParam.lPrint) { 00231 cout << "rec hits have been deleted in this layer"<<std::endl; 00232 } 00233 } 00234 } 00235 00236 if (8 == tkParam.lPrint) { cout << " nHitDeleted = "<<nHitDeleted<<std::endl; } 00237 //yzhang add nHitDeleted cut 2010-09-13 00238 // remove track if # not Active 00239 if (nHitDeleted >= tkParam.nHitDeleted) { 00240 if (8 == tkParam.lPrint) { 00241 cout << " nHitDeleted "<<nHitDeleted<<" > "<<tkParam.nHitDeleted 00242 <<" Killing tkNo " << itrack << endl; 00243 } 00244 nDeleted++; 00245 delete &(atrack->track()); // Delete the RecoTrk inside atrack 00246 atrack->setTrack(0); 00247 trksToKill.push_back(atrack); 00248 continue; 00249 } 00250 00251 //******* 00252 // How many hits are shared with a single track? 00253 int nMost = 0; 00254 int trackMost = 0; 00255 for (int ii = 0; ii < nTrack(); ii++) { 00256 if (8 == tkParam.lPrint){ 00257 std::cout<<"tk:"<<itrack<<"&"<<ii 00258 <<" shared "<<usedInTrackNum[ii]<<" hits "<< std::endl; 00259 } 00260 if (usedInTrackNum[ii] > nMost) { 00261 nMost = usedInTrackNum[ii]; 00262 trackMost = ii; //index of track w/ most hits in common w/ current trk 00263 } 00264 } 00265 00266 // A little precaution against infinite loops: 00267 if (trackMost == trackOld) { 00268 std::cout << "ErrMsg(error) MdcTrackListBase:" 00269 << "Something ghastly happened in MdcTrackListBase::arbitrateHits" 00270 << std::endl; 00271 return 0; 00272 } 00273 trackOld = trackMost; 00274 00275 00276 //****** 00277 // Decide whether to handle hits individually or in group 00278 double groupDiff = 0.0; // relative quality of grouped hits for the two 00279 // tracks; > 0. => current track worse 00280 int nFound = 0; // # of grouped hits located so far 00281 TrkHitOnTrk **theseHits = 0; // grouped hits as seen in current track 00282 TrkHitOnTrk **thoseHits = 0; // grouped hits as seen in the other track 00283 int lGroupHits = 0; 00284 00285 if (nMost >= tkParam.nOverlap) { 00286 if (8 == tkParam.lPrint){ 00287 std::cout<<"track "<<trackMost<<" shared "<<nMost<<" hits > Cut nOverlap " 00288 <<tkParam.nOverlap<<", group hits!"<<std::endl; 00289 } 00290 lGroupHits = 1; 00291 theseHits = new TrkHitOnTrk*[nMost]; 00292 thoseHits = new TrkHitOnTrk*[nMost]; 00293 } 00294 00295 //********* 00296 // Go back through hits on this track, looking up the overlap of each 00297 // if grouping hits, only deal with hits shared with trackMost on this pass 00298 // otherwise, deal with all shared hits as encountered 00299 if(8 == tkParam.lPrint) std::cout<<"Go back through hits, looking up overlap hits"<< std::endl; 00300 if (nMost > 0) { 00301 if (8 == tkParam.lPrint) std::cout<<" nHits= "<< hitList->nHit()<< std::endl; 00302 for (TrkHitList::hot_iterator ihit(hitList->begin()); ihit != hitList->end(); ++ihit) { 00303 int nUsed = ihit->hit()->nUsedHits(); 00304 00305 if (8 == tkParam.lPrint){ 00306 std::cout<< "--hit go back, nUsed="<<nUsed<<":"; 00307 ihit->hit()->printAll(std::cout); 00308 } 00309 00310 // only shared hits 00311 if (nUsed < 2) { continue; } 00312 00313 // active hits only 00314 if (!ihit->isActive()) { 00315 if (8 == tkParam.lPrint){ std::cout<<"act=0 continue"<<std::endl; } 00316 continue; 00317 } 00318 00319 //*** look at all overlaps for this hit 00320 std::pair<TrkFundHit::hot_iterator,TrkFundHit::hot_iterator> q = ihit->hit()->getUsedHits(); 00321 while (q.first!=q.second) { // nUsed > 0 00322 int dropThisHit = 0; 00323 TrkHitOnTrk *otherHot = const_cast<TrkHitOnTrk*>((--q.second).get()); 00324 TrkRecoTrk *otherTrack = otherHot->parentTrack(); 00325 00326 if (!otherHot->isActive()) continue; 00327 00328 // Again, skip "overlap" of track with itself 00329 if ( &aRecoTrk == otherTrack) continue; 00330 int otherId = otherTrack->id(); 00331 long otherIndex = -1; 00332 idMap.get(otherId, otherIndex); assert(otherIndex >= 0); 00333 00334 // if grouping hits, only look at hits shared with trackMost 00335 if (lGroupHits && otherIndex != trackMost) continue; 00336 00337 if (lGroupHits) { 00338 if (8 == tkParam.lPrint) { 00339 std::cout<<"group hits "<< std::endl; 00340 } 00341 // Calculate contribution of group to each chisq/dof 00342 // groupDiff += fabs(ihit->resid(0)) - 00343 // fabs(otherHot->resid(0)); 00344 // Hack to handle tracks with 5 active hits: 00345 int aDof = tkFit->nActive() - 5; 00346 assert (otherTrack->fitResult() != 0); 00347 int otherDof = otherTrack->fitResult()->nActive() - 5; 00348 if (aDof <= 0) {groupDiff = 999;} 00349 else if (otherDof <= 0) {groupDiff = -999;} 00350 else { 00351 groupDiff += ihit->resid(0) * ihit->resid(0) * ihit->weight() / 00352 aDof - 00353 otherHot->resid(0) * otherHot->resid(0) * otherHot->weight() / 00354 otherDof; 00355 } 00356 theseHits[nFound] = const_cast<TrkHitOnTrk*>(ihit.get()); 00357 thoseHits[nFound] = otherHot; 00358 nFound++; 00359 dropThisHit = 1; 00360 } else { // handle hits individually 00361 00362 if (8 == tkParam.lPrint) { 00363 std::cout<<"handle hits individually"<< std::endl; 00364 } 00365 nFound++; 00366 if (fabs(ihit->resid(0)) > fabs(otherHot->resid(0)) ) { 00367 // turn off (inactivate) hit on this track 00368 lRefit = 1; 00369 // ihit->hit()->setUnusedHit(ihit.get()); 00370 //Should I be setting inactive, or deleting the hit??????? 00371 const_cast<TrkHitOnTrk*>(ihit.get())->setActivity(0); 00372 dropThisHit = 1; 00373 if (8 == tkParam.lPrint) { 00374 std::cout<<"dorp hit "; 00375 const_cast<TrkHitOnTrk*>(ihit.get())->print(std::cout); 00376 } 00377 break; // found other hit, so quit loop 00378 } else { 00379 // inactivate hit on other track 00380 refitTrack[otherIndex] = 1; 00381 // otherHot->hit()->setUnusedHit(otherHot); 00382 otherHot->setActivity(0); 00383 if (8 == tkParam.lPrint) { 00384 std::cout<<"inactive hit on other track"; 00385 const_cast<TrkHitOnTrk*>(ihit.get())->print(std::cout); 00386 } 00387 break; // found other hit, so quit loop 00388 } 00389 } // end grouped/individual treatment 00390 00391 if (dropThisHit == 1) break; // don't look for other matches since 00392 // this hit is now turned off 00393 } // end loop over nUsed 00394 00395 // Quit if we've found all of the shared hits on this track 00396 if (lGroupHits && nFound == nMost || nFound == nPrev) { 00397 if (8 == tkParam.lPrint) { 00398 std::cout<<"we've found all of the shared hits on this track,Quit"<<std::endl; 00399 } 00400 break; 00401 } 00402 00403 } // end loop over hits 00404 00405 // Decide which track grouped hits belong with and inactivate accordingly 00406 if (lGroupHits) { 00407 if (8 == tkParam.lPrint) { 00408 cout << "nGroup: " << nMost << " groupDiff: " << groupDiff << endl; 00409 cout << "Track: " << aRecoTrk.id() << " nHit: " 00410 << hitList->nHit() << " nActive: " 00411 << tkFit->nActive() << " chisq/dof: " << 00412 tkFit->chisq()/(tkFit->nActive() - 5) << endl; 00413 TrkRecoTrk& othTrack = trkXRef[trackMost]->track(); 00414 cout << "Track: "<< othTrack.id() << " nHit: " << 00415 othTrack.hits()->nHit() << " nActive: " << 00416 othTrack.fitResult()->nActive() << " chisq/dof: " << 00417 othTrack.fitResult()->chisq() / 00418 (othTrack.fitResult()->nActive() - 5) << endl; 00419 } 00420 00421 if (groupDiff > 0.0) { 00422 // inactivate hits on this track 00423 lRefit = 1; 00424 for (int ii = 0; ii < nMost; ii++) { 00425 TrkHitOnTrk *alink = theseHits[ii]; 00426 TrkFundHit* hit = const_cast<TrkFundHit*> (alink->hit()); 00427 if(hitList->removeHit(hit)){ 00428 alink->hit()->setUnusedHit(alink);//yzhang 2009-11-03 open 00429 } 00430 //alink->setActivity(0); 00431 } 00432 if (8 == tkParam.lPrint) std::cout<<"inactive hits on this track, No."<<aRecoTrk.id()<< std::endl; 00433 } else { 00434 // inactivate hits on other track 00435 refitTrack[trackMost] = 1; 00436 for (int ii = 0; ii < nMost; ii++) { 00437 TrkHitOnTrk *alink = thoseHits[ii]; 00438 TrkFundHit* hit = const_cast<TrkFundHit*> (alink->hit()); 00439 if(hitList->removeHit(hit)){ 00440 alink->hit()->setUnusedHit(alink);//yzhang 2009-11-03 open 00441 } 00442 //alink->setActivity(0); 00443 } 00444 if (8 == tkParam.lPrint) std::cout<<"inactive hits on other track "<< std::endl; 00445 } 00446 delete [] theseHits; 00447 delete [] thoseHits; 00448 00449 } // end if lGroupHits 00450 00451 } // end if nMost > 0 00452 00453 //********* 00454 // Refit this track, if any hits have been dropped 00455 TrkErrCode fitResult; 00456 long index = -1; 00457 idMap.get(aRecoTrk.id(), index); assert (index >= 0); 00458 00459 if (lRefit || refitTrack[index] == 1) { 00460 if (8 == tkParam.lPrint) { 00461 std::cout<<"after group ,refit track"<<aRecoTrk.id()<< std::endl; 00462 } 00463 fitResult = hitList->fit(); 00464 aRecoTrk.status()->addHistory( 00465 TrkErrCode(fitResult.success()?TrkErrCode::succeed:TrkErrCode::fail,14,"Arbitrated"), "MdcTrkRecon"); 00466 if (fitResult.failure() && (8 == tkParam.lPrint )) { 00467 fitResult.print(std::cerr); 00468 } 00469 00470 00471 double chisqperDOF; 00472 bool badFit = true; 00473 if (fitResult.success()) { 00474 badFit = false; 00475 int nDOF = tkFit->nActive() - 5; 00476 if (nDOF > 5){ 00477 chisqperDOF = tkFit->chisq() / nDOF; 00478 }else{ 00479 chisqperDOF = tkFit->chisq(); 00480 } 00481 00482 if (chisqperDOF > tkParam.maxChisq) badFit = true; 00483 if (tkFit->nActive() < tkParam.minHits) badFit = true; 00484 double tem2 = (float) hitList->nHit() - tkFit->nActive(); 00485 if (tkParam.lUseQualCuts) { 00486 if (tem2 >= tkParam.maxNmissTrack) badFit = true; 00487 if (tem2 /float(hitList->nHit()) > tkParam.maxNmissNorm){ 00488 badFit = true; 00489 } 00490 } 00491 if(8== tkParam.lPrint) std::cout<<"fit quality:"<< 00492 " chisqperDof "<<chisqperDOF<<"?>"<<tkParam.maxChisq<< 00493 " nActive "<<tkFit->nActive()<<"?<"<<tkParam.minHits<< 00494 " nHit "<<hitList->nHit()<<" nhit-act "<<tem2<<"?>= nMiss "<<tkParam.maxNmissTrack<< 00495 " hit-act/nhit "<<tem2/float(hitList->nHit())<<"?> MissNorm "<<tkParam.maxNmissNorm 00496 << std::endl; 00497 00498 00499 } 00500 if (8 == tkParam.lPrint) { 00501 cout << "Refitting track " << aRecoTrk.id() << " success = " 00502 << fitResult.success() << "\n"; 00503 } 00504 // If the track no longer passes cuts, delete it 00505 if (fitResult.failure() || badFit ) { 00506 nDeleted++; 00507 // Don't change the track list while we're iterating through it! 00508 // remove(atrack); 00509 //int id = aRecoTrk.id(); 00510 if (8 == tkParam.lPrint) { 00511 cout << "fitResult.failure? "<<fitResult.failure() 00512 <<" badFit? "<<badFit <<" Killing tkNo " << itrack << endl; 00513 } 00514 delete &(atrack->track()); // Delete the RecoTrk inside atrack 00515 atrack->setTrack(0); 00516 trksToKill.push_back(atrack); 00517 continue; 00518 } 00519 } // end if lRefit 00520 00521 if (lGroupHits) goto restart; 00522 00523 } // end loop over tracks 00524 if (8 == tkParam.lPrint) std::cout<<"end of loop over tracks"<< std::endl; 00525 00526 // Remove dead track husks 00527 for (int itk = 0; itk < (int)trksToKill.size(); itk++) { 00528 remove(trksToKill[itk]); 00529 if (8 == tkParam.lPrint) std::cout<<"remode dead track No."<<itk<< std::endl; 00530 } 00531 if (8 == tkParam.lPrint) std::cout<<"---end of arbitrateHits"<< std::endl; 00532 00533 delete [] usedInTrackNum; 00534 delete [] refitTrack; 00535 delete [] trkXRef; 00536 return nDeleted; 00537 }
|
|
Implements MdcTrackListBase. |
|
Implements MdcTrackListBase. 00078 { 00079 // ************************************************************************* 00080 //Forms tracks out of list of superlayer segments 00081 int nTracks = 0; 00082 00083 m_debug = tkParam.lPrint;//yzhang debug 00084 00085 // Create empty list of stereo segs (to save time) 00086 MdcSegGrouperSt stereoSegs(gm, tkParam.lPrint); 00087 00088 // *** Create r-phi track 00089 00090 // Create list of axial segments, treated as on tracks from origin 00091 #ifdef MDCPATREC_TIMETEST 00092 TAU_PROFILE_TIMER(timer8,"fill ax seg", "int ()", TAU_DEFAULT); 00093 TAU_PROFILE_START(timer8); 00094 #endif 00095 MdcSegGrouperAx origSegs(gm, tkParam.lPrint); 00096 origSegs.fillWithSegs(segs); 00097 //std::cout << "Plot segs after ax fillWithSegs " << std::endl;//yzhang debug 00098 //segs->plot(0);//yzhang debug 00099 #ifdef MDCPATREC_TIMETEST 00100 TAU_PROFILE_STOP(timer8); 00101 #endif 00102 MdcSeg *seed; 00103 bool goodOnly = true; 00104 bool useBad = (segs->count() < 400); // if true, use non-good seeds 00105 segs->resetSeed(gm); 00106 MdcTrack *trialTrack = 0; 00107 00108 while (1) { 00109 seed = segs->getSeed(0,goodOnly); 00110 if (seed == 0 && goodOnly && useBad) { 00111 segs->resetSeed(gm); 00112 goodOnly = false; 00113 continue; 00114 } 00115 else if (seed == 0 && (!goodOnly || !useBad)) { 00116 break; 00117 } 00118 00119 if (3 == m_debug) dumpSeed(seed, goodOnly);//yzhang debug 00120 00121 // Pass through first superlayer of MDC required, Field layer No5 = 12.135 cm 00122 if ( fabs( ((MdcSegInfoAxialO *) seed->info())->curv()) > 0.0417) continue;//curv cut yzhang 00123 delete trialTrack; 00124 trialTrack = 0; 00125 00126 //---------Combine Ax segs-------- 00127 #ifdef MDCPATREC_TIMETEST 00128 TAU_PROFILE_TIMER(timer3,"combine ax seg", "int ()", TAU_DEFAULT); 00129 TAU_PROFILE_START(timer3); 00130 #endif 00131 int success = origSegs.combineSegs(trialTrack, seed, context, bunchTime, 00132 tkParam.maxSegChisqO); 00133 #ifdef MDCPATREC_TIMETEST 00134 TAU_PROFILE_STOP(timer3); 00135 #endif 00136 00137 00138 if (3 <= m_debug){ 00139 cout<<"Ax.combineSegs success? " << success<<"\n"; 00140 dumpAxCombine(trialTrack);//yzhang debug 00141 } 00142 if (!success) continue; 00143 00144 00145 //--------Finish circle-------- 00146 #ifdef MDCPATREC_TIMETEST 00147 TAU_PROFILE_TIMER(timer4,"circle fitting", "int ()", TAU_DEFAULT); 00148 TAU_PROFILE_START(timer4); 00149 #endif 00150 success = finishCircle(*trialTrack, map, gm); 00151 #ifdef MDCPATREC_TIMETEST 00152 TAU_PROFILE_STOP(timer4); 00153 #endif 00154 00155 if (3 <= m_debug){ 00156 cout<<"finishCircle success? " << success<<"\n"; 00157 dumpCircle(trialTrack);//yzhang debug 00158 } 00159 00160 if (!success) continue; 00161 //--------Make sure it really did come from origin-------- 00162 const TrkFit* tkFit = trialTrack->track().fitResult(); 00163 assert (tkFit != 0); 00164 TrkExchangePar par = tkFit->helix(0.0); 00165 //dumpD0(par); 00166 00167 //------------------d0 cut------------------- 00168 // 2010-03-31 , m_d0Cut from 0 to epsilon 00169 00170 //std::cout<< __FILE__ <<" d0 cut------------"<< fabs(par.d0())<<" d0cut "<< m_d0Cut << std::endl; 00171 if ( (m_d0Cut > Constants::epsilon) && (fabs(par.d0()) > m_d0Cut) ){ 00172 if (tkParam.lPrint>1)cout<<__FILE__<<" Killing track by d0:" <<par.d0()<<">"<<m_d0Cut << endl; 00173 continue; 00174 } 00175 00176 //------------------pt cut------------------- 00177 if ( (fabs(m_ptCut)>0.) && (fabs(tkFit->pt(0.)) < m_ptCut) ){ 00178 if (tkParam.lPrint>1)cout<<__FILE__<<" Killing track by pt:" <<tkFit->pt(0.)<<"<"<<m_ptCut << endl; 00179 continue; 00180 } 00181 00182 // *** End r-phi track-finding 00183 if (3 <= m_debug) std::cout << " *** End r-phi track-finding "<<std::endl; 00184 00185 //--------Add stereo to taste-------- 00186 #ifdef MDCPATREC_TIMETEST 00187 TAU_PROFILE_TIMER(timer5,"fill st seg", "int ()", TAU_DEFAULT); 00188 TAU_PROFILE_START(timer5); 00189 #endif 00190 stereoSegs.fillWithSegs(segs, trialTrack); 00191 #ifdef MDCPATREC_TIMETEST 00192 TAU_PROFILE_STOP(timer5); 00193 #endif 00194 if (3 <= m_debug){ 00195 //dumpStFill();//yzhang debug 00196 std::cout<<"Segment list after St.fillWithSegs "<< std::endl; 00197 stereoSegs.dumpSegList(); 00198 } 00199 00200 #ifdef MDCPATREC_TIMETEST 00201 TAU_PROFILE_TIMER(timer6,"combine st seg", "int ()", TAU_DEFAULT); 00202 TAU_PROFILE_START(timer6); 00203 #endif 00204 success = stereoSegs.combineSegs(trialTrack, 0, context, bunchTime, 00205 tkParam.maxSegChisqO); 00206 #ifdef MDCPATREC_TIMETEST 00207 TAU_PROFILE_STOP(timer6); 00208 #endif 00209 00210 if (3 <= m_debug){ 00211 cout<<"St.combineSegs success? " << success<<"\n"; 00212 dumpStCombine(trialTrack); 00213 } 00214 00215 00216 //--------Finish 3-d track-------- 00217 if (success) { 00218 #ifdef MDCPATREC_TIMETEST 00219 TAU_PROFILE_TIMER(timer7,"helix fitting", "int ()", TAU_DEFAULT); 00220 TAU_PROFILE_START(timer7); 00221 #endif 00222 success = finishHelix(*trialTrack, map, gm); 00223 if(3==tkParam.lPrint){cout<<"Final fit2:"<<endl<<trialTrack->track()<< endl; } 00224 #ifdef MDCPATREC_TIMETEST 00225 TAU_PROFILE_STOP(timer7); 00226 #endif 00227 } // end if (success -- st) 00228 00229 if(3==tkParam.lPrint){cout<<"Final fit3:"<<endl<<trialTrack->track()<< endl; } 00230 if (3 == m_debug){ 00231 dumpHelix(trialTrack); 00232 cout<<"finishHelix success? " << success<<"\n"; 00233 } 00234 if (!success) continue; 00235 00236 if ( (m_z0Cut > Constants::epsilon) && (fabs(par.z0()) > m_z0Cut) ){ 00237 if (tkParam.lPrint>1)cout<<__FILE__ 00238 <<" Killing track by z0:" <<par.z0()<<">"<<m_z0Cut << endl; 00239 continue; 00240 } 00241 00242 00243 nTracks++; 00244 append(trialTrack); // Add to list of Tracks 00245 00246 trialTrack = 0; 00247 00248 if (3 == m_debug) std::cout << " *** End one track-finding "<<std::endl; 00249 } // end while(1) 00250 00251 delete trialTrack; 00252 return nTracks; 00253 00254 }
|
|
Reimplemented from MdcTrackListBase. |
|
Reimplemented from MdcTrackListBase. 00986 { 00987 double tdr[43]; 00988 double tdr_wire[43]; 00989 for(int i=0; i<43; i++){tdr[i]=9999.;} 00990 00991 // make flag 00992 TrkHotList::hot_iterator hotIter= tk->track().hits()->hotList().begin(); 00993 while (hotIter!=tk->track().hits()->hotList().end()) { 00994 MdcHitOnTrack* hot = const_cast<MdcHitOnTrack*> (&(*hotIter->mdcHitOnTrack())); 00995 00996 //driftTime(tof,z) 00997 double dt = hot->mdcHit()->driftTime(0.,0.); 00998 int layer = hot->mdcHit()->layernumber(); 00999 int wire = hot->mdcHit()->wirenumber(); 01000 if (dt < tdr[layer]) { 01001 tdr[layer] = dt; 01002 tdr_wire[layer] = wire; 01003 } 01004 hotIter++; 01005 } 01006 01007 std::cout<<" tdr wire "; 01008 for(int i=0;i<43;i++){ 01009 std::cout<<i<<" "<<tdr[i]<<" "<<tdr_wire<<" "; 01010 } 01011 std::cout<<" "<< std::endl; 01012 // inactive multi hit 01013 hotIter= tk->track().hits()->hotList().begin(); 01014 while (hotIter!=tk->track().hits()->hotList().end()) { 01015 int layer = hotIter->mdcHitOnTrack()->mdcHit()->layernumber(); 01016 int wire = hotIter->mdcHitOnTrack()->mdcHit()->wirenumber(); 01017 double dt = hotIter->mdcHitOnTrack()->mdcHit()->driftTime(0.,0.); 01018 01019 if ((tdr[layer] <9998.) && (tdr_wire[layer]!=wire)){ 01020 MdcHitOnTrack* hot = const_cast<MdcHitOnTrack*> (&(*hotIter->mdcHitOnTrack())); 01021 hot->setActivity(false); 01022 01023 std::cout<<__FILE__<<" inactive "<< layer<<" "<<wire<<" dt "<<dt << std::endl; 01024 } 01025 hotIter++; 01026 } 01027 }
|
|
|
|
00892 { 00893 if (trialTrack){ 00894 trialTrack->track().printAll(cout);//yzhang debug 00895 cout << "combined hits " << endl;//yzhang debug 00896 TrkHotList::hot_iterator hotIter= trialTrack->track().hits()->hotList().begin(); 00897 while (hotIter!=trialTrack->track().hits()->hotList().end()) { 00898 cout <<"(" <<((MdcHit*)(hotIter->hit()))->layernumber() 00899 <<","<<((MdcHit*)(hotIter->hit()))->wirenumber() 00900 <<":"<<hotIter->isActive()<<") "; 00901 hotIter++; 00902 } 00903 std::cout << std::endl; 00904 } 00905 }
|
|
|
|
00880 { 00881 std::cout << "ax fill: "<<std::endl; 00882 if(!trialTrack){ 00883 trialTrack->track().printAll(cout);//yzhang debug 00884 } 00885 }
|
|
|
|
00907 { 00908 if(trialTrack == NULL) return; 00909 if(trialTrack)trialTrack->track().printAll(cout); 00910 00911 // TrkExchangePar par = trialTrack->track().fitResult()->helix(0.0); 00912 double omega,r,pt; 00913 if (!trialTrack->track().fitResult()) return; 00914 omega =trialTrack->track().fitResult()->helix(0.0).omega(); 00915 if (omega == 0) pt = 0; 00916 else pt = (-1) * 1/(omega * 333.576 ); 00917 std::cout<<"in MdcTrackList Circle Pt = "<< pt <<std::endl;//yzhang deubg 00918 00919 if (omega == 0) r=0; 00920 else r = 1/ omega; 00921 std::cout<<"in MdcTrackList Circle R = "<< r <<std::endl;//yzhang deubg 00922 //m_nHitCir = trialTrack->track().hits()->hotList().nHit(); 00923 00924 std::cout << "hitList after finishCircle, nHit=" << trialTrack->track().hits()->hotList().nHit()<< std::endl;//yzhang debug 00925 TrkHotList::hot_iterator hotIter= trialTrack->track().hits()->hotList().begin(); 00926 while (hotIter!=trialTrack->track().hits()->hotList().end()) { 00927 //m_nHitCir = ((MdcHit*)(hotIter->hit()))->layernumber();//yzhang debug 00928 cout <<"(" <<((MdcHit*)(hotIter->hit()))->layernumber() 00929 <<","<<((MdcHit*)(hotIter->hit()))->wirenumber() 00930 <<":"<<hotIter->isActive()<<") "; 00931 //double tphi = gm->Wire(((MdcHit*)(hotIter->hit()))->layernumber(), 00932 // ((MdcHit*)(hotIter->hit()))->wirenumber())->phiE(); 00933 hotIter++; 00934 //std::cout <<"in MdcTrackList Circle tphiEnd "<< tphi << std::endl;//yzhang debug 00935 //m_lwPhi = tphi; 00936 } 00937 cout <<endl; 00938 }
|
|
|
|
00940 { 00941 //yzhang hist 00942 //m_hd0->fill(par.d0()); 00943 //m_d0 = par.d0(); 00944 // m_tuple1->write();//yzhang hist 00945 std::cout << " MdcTrackList::par.d0() " << par.d0()<<"\n";//yzhang debug 00946 00947 //zhangy hist 00948 }
|
|
|
|
00970 { 00971 std::cout << "hitList after finishHelix, nHit=" << trialTrack->track().hits()->hotList().nHit()<< std::endl;//yzhang debug 00972 trialTrack->track().printAll(cout); 00973 TrkHotList::hot_iterator hotIter= trialTrack->track().hits()->hotList().begin(); 00974 int tmplay = -1; 00975 while (hotIter!=trialTrack->track().hits()->hotList().end()) { 00976 int layer = ((MdcHit*)(hotIter->hit()))->layernumber(); 00977 if( (layer%4) ==0 ) { if( tmplay != layer ) cout<<endl; } 00978 cout <<"(" <<layer <<","<<((MdcHit*)(hotIter->hit()))->wirenumber() 00979 <<":"<<hotIter->isActive() <<") "; 00980 hotIter++; 00981 tmplay = layer; 00982 } 00983 cout <<endl; 00984 }
|
|
|
|
00887 { 00888 std::cout << "seed segment: goodOnly="<<goodOnly<<" "; 00889 seed->plotSeg(); 00890 }
|
|
|
|
00955 { 00956 std::cout << "hitList after StCombine" << std::endl;//yzhang debug 00957 if(trialTrack)trialTrack->track().printAll(cout); 00958 TrkHotList::hot_iterator hotIter= trialTrack->track().hits()->hotList().begin(); 00959 int tmplay = -1; 00960 while (hotIter!=trialTrack->track().hits()->hotList().end()) { 00961 int layer = ((MdcHit*)(hotIter->hit()))->layernumber(); 00962 if( (layer%4) ==0 ) { if( tmplay != layer ) cout<<endl; } 00963 cout <<"(" <<layer <<","<<((MdcHit*)(hotIter->hit()))->wirenumber() 00964 <<":"<<hotIter->isActive() <<") "; 00965 hotIter++; 00966 tmplay=layer; 00967 } 00968 cout <<endl; 00969 }
|
|
|
|
00949 {
00950 std::cout << "Plot segs after st fillWithSegs " << std::endl;
00951 cout <<endl;
00952
00953 }
|
|
|
|
00792 { 00793 //************************************************************************ 00794 TrkRecoTrk& trk = mdcTrk.track(); 00795 if(9==tkParam.lPrint){ 00796 std::cout << __FILE__ << " finishCircle "<< std::endl; 00797 trk.print(std::cout); 00798 } 00799 00800 const TrkFit* tkFit = trk.fitResult(); 00801 if(9==tkParam.lPrint){ cout << "Before circle fit, nactive " << tkFit->nActive() << endl;} 00802 assert (tkFit != 0); 00803 TrkHitList* hitList = trk.hits(); 00804 assert (hitList != 0); 00805 TrkCircleMaker circMaker; 00806 circMaker.setFlipAndDrop(trk, false, false); // reset as a precaution 00807 //circMaker.setFactor(trk, 1.);//nSigma cut factor//yzhang FIXME 2010-09-13 00808 00809 TrkErrCode fitResult = hitList->fit(); 00810 if (fitResult.failure()) { 00811 trk.status()->addHistory(TrkErrCode(TrkErrCode::fail,15,"finishCircle"),"MdcTrkRecon"); 00812 if (tkParam.lPrint > 1) { 00813 cout << "First circle fit failed: " << endl; 00814 fitResult.print(std::cout); 00815 } 00816 return 0; 00817 } 00818 trk.status()->addHistory(TrkErrCode(TrkErrCode::succeed,15,"finishCircle"),"MdcTrkRecon"); 00819 00820 if(9==tkParam.lPrint){ cout << "After circle fit, nactive " << tkFit->nActive() << endl;} 00821 double chisqperDOF; 00822 int nDOF = tkFit->nActive() - 3; 00823 if (nDOF > 3){ 00824 chisqperDOF = tkFit->chisq() / nDOF; 00825 }else{ 00826 chisqperDOF = tkFit->chisq(); 00827 } 00828 00829 if(g_cirTkChi2) { g_cirTkChi2->fill( chisqperDOF ); }//yzhang hist cut 00830 int success = (chisqperDOF <= tkParam.maxChisq && tkFit->nActive() >= 3); 00831 00832 if(9==tkParam.lPrint){ 00833 std::cout<<__FILE__<<" "<<__LINE__ 00834 << " success "<<success 00835 << " chisqperDOF "<< chisqperDOF<<"<? maxChisq "<< tkParam.maxChisq 00836 << " nAct "<<tkFit->nActive()<<">=3 " 00837 << std::endl; 00838 mdcTrk.track().hots()->printAll(std::cout); 00839 } 00840 bool lcurler(fabs(tkFit->helix(0).omega()) > 3.4);//yzhang FIXME, ?? 00841 int nHits = pickHits(&mdcTrk, map, gm, lcurler); 00842 if (nHits <= 0) { return success; }//yzhang FIXME 00843 00844 circMaker.setFlipAndDrop(trk, true, true); 00845 fitResult = hitList->fit(); 00846 if (fitResult.failure()) { 00847 if(9==tkParam.lPrint){ 00848 cout << "Second circle fit failed: " << endl; 00849 fitResult.print(std::cout); 00850 } 00851 return 0; 00852 } 00853 if(9==tkParam.lPrint){ 00854 cout << "Final fit: " << endl << trk << endl; 00855 } 00856 circMaker.setFlipAndDrop(trk, false, false); 00857 00858 nDOF = tkFit->nActive() - 3; 00859 if (nDOF > 3) { 00860 chisqperDOF = tkFit->chisq() / nDOF; 00861 } 00862 else { 00863 chisqperDOF = tkFit->chisq(); 00864 } 00865 if(g_cirTkChi2) { g_cirTkChi2->fill( chisqperDOF ); }//yzhang hist cut 00866 success = (chisqperDOF <= tkParam.maxChisq) && (tkFit->nActive() >= 3); 00867 00868 if(9==tkParam.lPrint){ 00869 cout << "chisqperDOF "<<chisqperDOF<<"=?" << tkParam.maxChisq<< endl; 00870 cout << "nActive "<<tkFit->nActive()<<">= 3"<< endl; 00871 } 00872 00873 if(9==tkParam.lPrint){ 00874 trk.printAll(cout); 00875 } 00876 00877 return success; 00878 }
|
|
|
|
00706 { 00707 //*********************************************************************** 00708 int success = 1; 00709 00710 TrkRecoTrk& trk = mdcTrk.track(); 00711 TrkErrCode fitResult; 00712 TrkHelixMaker helMaker; 00713 const TrkFit* tkFit = trk.fitResult(); 00714 assert (tkFit != 0); 00715 TrkHitList* hitList = trk.hits(); 00716 assert (hitList != 0); 00717 TrkExchangePar par = tkFit->helix(0.0); 00718 00719 00720 helMaker.setFlipAndDrop(trk, true, true); 00721 fitResult = hitList->fit(); 00722 00723 if (!fitResult.success() && (3 == tkParam.lPrint)) { 00724 cout << "Helix fit failure: " << endl; 00725 fitResult.print(cout); 00726 } 00727 helMaker.setFlipAndDrop(trk, false, false); 00728 00729 if (!fitResult.success()) return 0; 00730 00731 bool lcurler(fabs(tkFit->helix(0).omega()) > 3.4);//yzhang FIXME, ?? 00732 int nHits = pickHits(&mdcTrk, map, gm, lcurler);//yzhang add 2010-05-10 00733 //if (nHits <= 0) { return success; }//yzhang FIXME 00734 00735 helMaker.setFlipAndDrop(trk, true, true); 00736 fitResult = hitList->fit(); 00737 if (fitResult.failure()) { 00738 if(3==tkParam.lPrint){ 00739 cout << "Second helix fit failed: " << endl; 00740 fitResult.print(std::cout); 00741 } 00742 return 0; 00743 } 00744 if(3==tkParam.lPrint){ cout << "Final fit: " << endl << trk << endl; } 00745 helMaker.setFlipAndDrop(trk, false, false); 00746 00747 double chisqperDOF = 0.; 00748 int nACT = tkFit->nActive(); 00749 int nDOF = nACT - 5; 00750 if (nDOF > 5) { 00751 chisqperDOF = tkFit->chisq() / nDOF; 00752 } else { 00753 chisqperDOF = tkFit->chisq(); 00754 } 00755 if(g_3dTkChi2) { g_3dTkChi2->fill( chisqperDOF ); }//yzhang hist cut 00756 if(g_fitNAct) { g_fitNAct->fill(nACT ); }//yzhang hist cut 00757 00758 int goodMatch = 1; 00759 if (fitResult.failure() || chisqperDOF > tkParam.maxChisq || nACT < tkParam.minHits ) { 00760 goodMatch = 0; 00761 if (3 == tkParam.lPrint) { 00762 std::cout<<" goodMatch=0; chi2/dof "<<chisqperDOF <<" > maxChisq"<<tkParam.maxChisq 00763 <<" nAct:"<<nACT <<"<minHits"<<tkParam.minHits << std::endl; 00764 } 00765 } 00766 //yzhang add 00768 //if (tkParam.lUseQualCuts) { 00769 //double tem2 = (float) trk.hits()->nHit() - nACT; 00770 //if (tem2 >= tkParam.maxNmissTrack) goodMatch = 0; 00771 //if (tem2 / float(trk.hits()->nHit()) > tkParam.maxNmissNorm) 00772 //goodMatch = 0; 00773 //} 00774 //zhangy add 00775 00776 if (goodMatch) { 00777 if(3 <= m_debug){std::cout<<" finishHelix success!"<< std::endl;} 00778 trk.fitResult()->positionErr(0.0); 00779 } else { // Not a good match 00780 success = 0; 00781 if(3 <= m_debug){std::cout<<" finishHelix failure!"<< std::endl;} 00782 } // end if goodmatch 00783 00784 if(3==tkParam.lPrint){ cout << "Final fit1: " << endl << trk << endl; } 00785 return success; 00786 }
|
|
|
|
00541 { 00542 //************************************************************************** 00543 tkParam = tkPar; 00544 }
|
|
00039 {return length();}
|
|
00039 {return length();}
|
|
|
|
|
|
|
|
!! change to using omega itself 00260 { 00261 00262 /***************************************************************************/ 00263 00264 // Selects candidate hits along track; 00265 // sorts them into "active" (small residual) and "inactive" (large resid); 00266 // throws away hits separated from main group by large gaps. //?? FIXME 00267 // pickAm => pick the ambiguity for hits already on track 00268 // Return # of active hits found 00269 00270 if(6==tkParam.lPrint){ 00271 cout << "Before pickHits: " << endl << trk << endl; 00272 } 00273 00274 int nFound = 0; 00275 int nCand = 0; // cells tried 00276 double rMin, rMax; // min & max search radii for this track 00277 double rEnter, rExit; // radii at which track enters, exits layer 00278 BesAngle phiEnter, phiExit;//yzhang change 00279 int wireLow, wireHigh; 00280 double phiLow, phiHigh; 00281 int nCell; 00282 MdcHit *thisHit; 00283 HepAList<MdcHitOnTrack> localHistory; //temporary list of added hits 00284 //until bogus hits are chucked 00285 double cellWidth; 00286 double goodDriftCut; // missing hits with predDrift > goodDriftCut don't count in figuring gaps 00287 double aresid = 0.; // = abs(resid) 00288 int firstInputHit = -1; //first hit in firstInputLayer/lastInputLayer region 00289 int lCurl = 0; // reached curl point 00290 00291 //****************************************************/ 00292 const MdcLayer *firstInputLayer = trk->firstLayer(); 00293 const MdcLayer *lastInputLayer = trk->lastLayer(); 00294 00295 double bunchTime = trk->track().trackT0(); 00296 const TrkFit* tkFit = trk->track().fitResult(); 00297 assert (tkFit != 0); 00298 const TrkFitStatus* tkStatus = trk->track().status(); 00299 assert (tkStatus != 0); 00300 TrkHitList* hitList = trk->track().hits(); 00301 assert (hitList != 0); 00302 TrkExchangePar par = tkFit->helix(0.0); 00303 double d0 = par.d0(); 00304 double curv = 0.5 * par.omega(); 00305 double sinPhi0 = sin(par.phi0()); 00306 double cosPhi0 = cos(par.phi0()); 00307 00308 // *** Set min and max radius for track 00309 rMin = gm->firstLayer()->rIn(); 00310 double absd0 = fabs(d0); 00311 if (absd0 > rMin) rMin = absd0 + Constants::epsilon; 00312 00313 bool willCurl = false; 00314 double rCurl = fabs(d0 + 1./curv); 00315 rMax = gm->lastLayer()->rOut(); 00316 //std::cout<< __FILE__ <<" "<< __LINE__<<" rCurl "<< rCurl <<" rMax "<< rMax << std::endl; 00317 if (rCurl < rMax) { 00318 willCurl = true; 00319 rMax = rCurl - Constants::epsilon; 00320 } 00321 //std::cout<<" willCurl "<< willCurl << std::endl; 00322 bool reachedLastInput = false; 00323 bool hasCurled = false; // hit found past curl point 00324 00325 // *** Loop through layers in view, looking for the hits 00326 // assumes axial inner 00327 for (const MdcLayer *layer = gm->firstLayer(); layer != 0; 00328 layer = ((!lCurl) ? ( (hasCurled) ? gm->prevLayer(layer) : 00329 gm->nextLayer(layer)) : layer) ) { 00330 00331 if (lCurl) { 00332 lCurl = 0; 00333 hasCurled = true; 00334 } 00335 if (tkStatus->is2d() && layer->view() != 0) continue; 00336 //std::cout<< __FILE__ <<" "<< __LINE__ << " lCurl "<< lCurl 00337 //<<" hasCurled "<< hasCurled <<" layer "<< layer->layNum() << std::endl; 00338 bool lContinue = true; 00339 if(tkParam.pickUitlLastLayer) {//yzhang change 2010-09-10 00340 if (layer == lastInputLayer) reachedLastInput = true; 00341 } 00342 00343 // *** Find enter and exit points 00344 if (hasCurled) { 00345 rEnter = layer->rOut(); 00346 if (rEnter < rMin) { 00347 //std::cout<< __FILE__ <<" "<< __LINE__ 00348 //<<" rEnter<rMin "<<rEnter<<" "<<rMin<< std::endl; 00349 break; 00350 } 00351 rExit = layer->rIn(); 00352 if (rExit < rMin) rExit = rMin; 00353 if (rEnter > rMax) rEnter = rMax; 00354 00355 //std::cout<< __FILE__ <<" hasCurled: rEnter "<< rEnter 00356 //<<" rExit " << rExit << " rMin "<<rMin<<" rMax "<<rMax<< std::endl; 00357 } else { 00358 rEnter = layer->rIn(); 00359 rExit = layer->rOut(); 00360 //std::cout<< __FILE__ <<" NOT hasCurled: rEnter "<< rEnter 00361 //<<" rExit " << rExit << " rMin "<<rMin<<" rMax "<<rMax<< std::endl; 00362 if (rExit < rMin) continue; 00363 00364 if (willCurl) { 00365 if (rEnter > rMax) { 00366 //std::cout<< __FILE__<<" Reached curl point before entering layer"<< std::endl; 00367 // Reached curl point before entering layer 00368 hasCurled = 1; 00369 continue; 00370 } 00371 if (rExit > rMax) { 00372 lCurl = 1; 00373 rExit = rMax; 00374 } 00375 } else { // not a potential curler 00376 //std::cout<< __FILE__ <<" "<< __LINE__ <<" not a potential curler"<< std::endl; 00377 if (rEnter > rMax) { 00378 //std::cout<< __FILE__ <<" rEnter> rMax "<< rEnter << std::endl; 00379 break; 00380 } 00381 if (rExit > rMax) rExit = rMax; 00382 } 00383 } // end if curled already 00384 00385 nCell = layer->nWires(); 00386 cellWidth = Constants::twoPi * layer->rMid() / nCell;//?? 00387 // don't count outer xmm of cell 00388 goodDriftCut = 0.5 * cellWidth * M_SQRT2 +tkParam.pickHitMargin; 00389 //goodDriftCut = 0.5 * cellWidth - tkParam.pickHitMargin;//yzhang delete 00390 00391 //**** Find entrance and exit phi's 00392 BesAngle phiTemp(0.0); 00393 int ierror = trk->projectToR(rEnter, phiTemp, hasCurled); 00394 phiEnter = phiTemp.posRad(); 00395 if (ierror != 0) { 00396 if(6==tkParam.lPrint) std::cout<< " ErrMsg(warning) " 00397 << "Error in MdcTrackList::pickHits projection" << std::endl; 00398 } 00399 ierror = trk->projectToR(rExit, phiTemp, hasCurled); 00400 phiExit = phiTemp.posRad(); 00401 if (ierror != 0) { 00402 if(6==tkParam.lPrint) std::cout<< " ErrMsg(warning) " 00403 << "Error in MdcTrackList::pickHits projection" << std::endl; 00404 } 00405 00406 //stereo layer pick hit phi wider 00407 double maxInactiveResid = tkParam.maxInactiveResid; 00408 00409 //std::cout<< __FILE__ <<" maxInactiveResid "<< maxInactiveResid <<" pickHitPhiFactor "<<tkParam.pickHitPhiFactor<< std::endl; 00410 if ( 0 != layer->view()) maxInactiveResid *= (tkParam.pickHitPhiFactor*fabs(layer->dPhiz()));//FIXME yzhang 2010-05-18 , original 5 00411 00412 //std::cout<< " facotr "<<tkParam.pickHitPhiFactor<< " dPhiz "<<layer->dPhiz() 00413 //<< " factor*dPhiz "<<layer->dPhiz()*tkParam.pickHitPhiFactor<< std::endl; 00414 if (curv >= 0.0) { 00415 phiLow = phiEnter; 00416 phiHigh = phiExit; 00417 // Allow some slop in phi 00418 phiLow -= tkParam.maxInactiveResid / rEnter; 00419 phiHigh += tkParam.maxInactiveResid / rExit; 00420 } else { 00421 phiLow = phiExit; 00422 phiHigh = phiEnter; 00423 phiLow -= tkParam.maxInactiveResid / rExit; 00424 phiHigh += tkParam.maxInactiveResid / rEnter; 00425 } 00426 00427 double lowFloat = nCell /Constants::twoPi * 00428 (phiLow - layer->phiOffset()) + 0.5; 00429 double highFloat = nCell /Constants::twoPi * 00430 (phiHigh - layer->phiOffset()) + 0.5; 00431 wireLow = (lowFloat >= 0.0) ? int(lowFloat) : int(floor(lowFloat)); 00432 wireHigh = (highFloat >= 0.0) ? int(highFloat) : int(floor(highFloat)); 00433 00434 if(6==tkParam.lPrint){ 00435 std::cout<<__FILE__ << " phiLow "<<phiLow 00436 << " phiHigh "<<phiHigh << std::endl; 00437 std::cout<<__FILE__ << " wireLow "<<wireLow 00438 << " wireHigh "<<wireHigh << std::endl; 00439 } 00440 // *** Loop through the predicted hit wires 00441 for (int thisWire = wireLow; thisWire <= wireHigh; thisWire++) { 00442 int corrWire = mdcWrapWire(thisWire, nCell); 00443 thisHit = map->hitWire(layer->layNum(), corrWire); 00444 double tof = 0.; 00445 double z = 0.; 00446 double driftDist = 0.; 00447 if(6==tkParam.lPrint){ 00448 if(thisHit != 0) thisHit->print(std::cout); 00449 else std::cout << " test "<<layer->layNum()<<" "<<corrWire<< std::endl; 00450 } 00451 // Calculate expected drift distance 00452 double delx, dely; 00453 double resid = 0., predDrift = 0.; 00454 int ambig = 0; 00455 const MdcHitOnTrack *alink = 0; 00456 if (thisHit == 0 ) { 00457 delx = -d0 * sinPhi0 - layer->xWire(corrWire); 00458 dely = d0 * cosPhi0 - layer->yWire(corrWire); 00459 predDrift = cosPhi0 * dely - sinPhi0 * delx + 00460 curv * (delx * delx + dely * dely); 00461 } else { 00462 // look for existing hit 00463 //if (thisHit->nUsedHits()==0) break;//yzhang temp 00464 //yzhang CHANGE 00465 if(thisHit->getHitOnTrack(&(trk->track())) ==0){ 00466 if(6==tkParam.lPrint)std::cout << "getHit==0 " << std::endl;//yzhang debug 00467 alink = 0;//yzhang temp 00468 }else{ 00469 alink = thisHit->getHitOnTrack(&(trk->track()))->mdcHitOnTrack();//yzhang temp 00470 } 00471 00472 if(6==tkParam.lPrint) { 00473 cout << " Fetched existing hot " << endl;//yzhang debug 00474 } 00475 if (alink == 0 || pickAm) { 00476 if ((!tkStatus->is2d()) && layer->view() != 0){ 00477 double rc = 9999.; 00478 if(fabs(par.omega())>Constants::epsilon) rc = 1./par.omega(); 00479 //std::cout<< par.omega()<<" "<< rc << std::endl; 00480 double rw = layer->rMid(); 00481 double alpha = acos(1 - rw*rw/(2*rc*rc)); 00482 //std::cout<< rw <<" "<< 1 - rw*rw/(2*rc*rc)<<" alpha " <<alpha << std::endl; 00483 double fltLen = rw; 00484 if(fabs(1 - rw*rw/(2*rc*rc))<1) fltLen = rc * alpha; 00485 z = par.z0() + fltLen* par.tanDip(); 00486 //std::cout<<"z "<<z<<" fltLen "<<fltLen<< " tanl "<<par.tanDip() << std::endl; 00487 tof = fltLen / Constants::c; 00488 double x = layer->getWire(corrWire)->xWireDC(z); 00489 double y = layer->getWire(corrWire)->yWireDC(z); 00490 delx = -d0 * sinPhi0 - x; 00491 dely = d0 * cosPhi0 - y; 00492 //std::cout<< "new x "<<x <<" y: "<< y << std::endl; 00493 //std::cout<< layer->xWire(corrWire) <<" old y: "<< layer->yWire(corrWire) << std::endl; 00494 }else{ 00495 delx = -d0 * sinPhi0 - thisHit->x(); 00496 dely = d0 * cosPhi0 - thisHit->y(); 00497 } 00498 predDrift = cosPhi0 * dely - sinPhi0 * delx + 00499 curv * (delx * delx + dely * dely); 00500 if(6==tkParam.lPrint){ 00501 if (alink == 0) cout << "hit not on track: pred drift dist = " << predDrift << endl;//yzhang debug 00502 else cout << "picking all " << predDrift << endl;//yzhang debug 00503 } 00504 // predDrift = predDrift * (1. - curv() * predDrift); 00505 ambig = (predDrift >= 0) ? 1 : -1; 00506 if (hasCurled) ambig = -ambig; 00507 //std::cout<<bunchTime<<" bunchTime "<< std::endl; 00508 double entranceAngle=0.; 00509 driftDist = thisHit->driftDist(tof,ambig,entranceAngle,0.,z); 00510 //FIXME 00511 //std::cout<< thisHit->driftDist(bunchTime,ambig) <<" new drift "<< driftDist << std::endl; 00512 if (alink == 0) { 00513 // FIXME: is this ambig here VVVVV OK for incoming tracks? 00514 //resid = ambig * fabs(thisHit->driftDist(bunchTime,ambig)) - predDrift; 00515 resid = ambig * fabs(driftDist) - predDrift; 00516 aresid = fabs(resid); 00517 if (aresid > tkParam.maxInactiveResid ) ambig = 0; 00518 } 00519 if(6==tkParam.lPrint) cout << " pickAm ambig " << ambig << 00520 " drift "<<driftDist<< " predDrift "<<predDrift<<" resid "<<resid<< endl;//yzhang debug 00521 } else { 00522 ambig = alink->ambig(); 00523 if(6==tkParam.lPrint) cout << " alink==0 ambig " << ambig<< 00524 " drift "<<driftDist<< " predDrift "<<predDrift<<" resid "<<resid<< endl;//yzhang debug 00525 } 00526 } 00527 00528 // Cases 00529 // (1) No good hit, but track near cell-edge => do nothing and continue 00530 if(6==tkParam.lPrint) std::cout << __FILE__ << " predDrift "<<fabs(predDrift)<<">? goodDriftCut "<<3. * goodDriftCut<< std::endl; 00531 if (ambig == 0 && fabs(predDrift) > 3.*goodDriftCut){//yzhang 2009-11-03 add 3factor 00532 if(6==tkParam.lPrint) cout << " (1) No good hit, but track near cell-edge " << endl;//yzhang debug 00533 continue; 00534 } 00535 00536 // (2) Hit found: 00537 if (ambig != 0) { 00538 //yzhang changed 2009-10-19 00539 //if resid> maxActiveSimga * sigma do not add hits to track 00540 double entranceAngle = 0.; 00541 double sigma = thisHit->sigma(driftDist, ambig, entranceAngle, atan(par.tanDip()), z); 00542 double factor = tkParam.pickHitFactor; 00543 00544 double residCut = tkParam.maxActiveSigma * factor * sigma; 00545 if(6==tkParam.lPrint){ 00546 std::cout<< "aresid "<<aresid<<"<?" <<residCut 00547 <<" maxActiveSigma "<<tkParam.maxActiveSigma 00548 <<" factor="<<factor <<" sigma "<<sigma<< std::endl; 00549 } 00550 00551 if(fabs(par.tanDip())<2) factor = (2-par.tanDip())/2 * factor; 00552 if (alink == 0 && (aresid <= residCut ) ) { 00553 //if (alink == 0) 00554 int isActive = 1; 00555 if (aresid > residCut) isActive = 0; 00556 if(6==tkParam.lPrint) { 00557 if (aresid > residCut) 00558 std::cout << "notACT, resid "<<aresid<<" > " << residCut<< std::endl; 00559 } 00560 MdcRecoHitOnTrack tempHot(*thisHit, ambig, bunchTime); 00561 tempHot.setActivity(isActive); 00562 // Don't add active hits if they're in use. 00563 if (thisHit->usedHit()){ 00564 tempHot.setUsability(false); 00565 //std::cout<< " thisHit used, setUsability false " << std::endl; 00566 } 00567 // very crude starting point for flight length !!!! improve 00568 double flt = layer->rMid(); 00569 if (hasCurled) flt = Constants::twoPi * rCurl - layer->rMid(); 00570 flt += 0.000001 * (thisHit->x() + thisHit->y()); 00571 tempHot.setFltLen(flt); 00572 if(6==tkParam.lPrint) std::cout<< "appendHot " << std::endl; 00573 alink = (MdcHitOnTrack*) hitList->appendHot(&tempHot); 00574 } 00575 if (!localHistory.member(const_cast<MdcHitOnTrack*>(alink))) { 00576 localHistory.append(const_cast<MdcHitOnTrack*>(alink)); 00577 if (hasCurled) trk->setHasCurled(); 00578 nFound++; 00579 if (layer == firstInputLayer && firstInputHit < 0) { 00580 firstInputHit = nCand; 00581 } 00582 } else { 00583 if(6==tkParam.lPrint) std::cout << "ErrMsg(warning) "<< "would have inserted identical HOT " 00584 "twice in history buffer" << std::endl; 00585 } 00586 if(6==tkParam.lPrint) cout << " (2) Hit found " << endl;//yzhang debug 00587 } 00588 00589 // (3) No hit found; if beyond known good region, should we continue? 00590 else if (ambig == 0 && reachedLastInput) { 00591 lContinue = false; 00592 int nSuccess = 0; 00593 int last = 8; 00594 if (nCand < 8) last = nCand; 00595 for (int i = 0; i < last; i++) { 00596 int j = nCand - 1 - i; 00597 if (localHistory[j] != 0) { 00598 //std::cout<< __FILE__ <<" localHistory["<<j<<"]!=0 nSuccess++ "<< std::endl; 00599 nSuccess++; 00600 } 00601 if (i == 2 && nSuccess >= 2) lContinue = true; 00602 if (i == 4 && nSuccess >= 3) lContinue = true; 00603 if (i == 7 && nSuccess >= 5) lContinue = true; 00604 if(6==tkParam.lPrint) cout <<i<< " (3) No hit found; if beyond known good region " << endl;//yzhang debug 00605 if (lContinue) { 00606 //std::cout<< __FILE__ <<" "<< __LINE__ <<" break by lContinue "<< std::endl; 00607 break; 00608 } 00609 } 00610 00611 if(6==tkParam.lPrint) cout << " (3) No hit found; if beyond known good region " << endl;//yzhang debug 00612 // if lContinue == false => there's been a gap, so quit 00613 if (!lContinue) { 00614 //std::cout<< __FILE__ <<" "<< __LINE__ <<" break by !lContinue "<< std::endl; 00615 break; 00616 } 00617 localHistory.append(0); 00618 } 00619 nCand++; 00620 // Update last layer: 00621 if (ambig != 0 && reachedLastInput) { 00622 if (trk->hasCurled() == 0) { 00623 if (thisHit->layer()->rEnd() > trk->lastLayer()->rEnd()) { 00624 trk->setLastLayer(thisHit->layer()); 00625 } 00626 } 00627 else { 00628 if (thisHit->layer()->rEnd() < trk->lastLayer()->rEnd()) { 00629 trk->setLastLayer(thisHit->layer()); 00630 } 00631 } 00632 } 00633 00634 } // end loop over hit wires 00635 if (!lContinue && reachedLastInput) { 00636 //std::cout<< __FILE__ <<" break by !lContinue && reachedLastInput "<< std::endl; 00637 break; 00638 } 00639 } // end loop over layers 00640 00641 // Now look back at hits in early layer and see if there are any to be thrown away there. 00642 bool lContinue = true; 00643 for (int ihit = firstInputHit; ihit >= 0; ihit--) { 00644 if (localHistory[ihit] != 0) { 00645 if (lContinue) { 00646 // Update firstLayer 00647 const MdcHitOnTrack *mdcHit = localHistory[ihit]->mdcHitOnTrack(); 00648 if (mdcHit != 0) { 00649 if (mdcHit->layer()->rEnd() < trk->firstLayer()->rEnd()) { 00650 trk->setFirstLayer(mdcHit->layer()); 00651 } 00652 } 00653 continue; // no gap yet 00654 } else { 00655 // gap found; delete hits 00656 if(6==tkParam.lPrint){ 00657 std::cout << " gap found; delete hits. "; 00658 } 00659 if (!localHistory[ihit]->isUsable()) { 00660 if(6==tkParam.lPrint){ 00661 cout << "about to delete hit for unusable HOT:" << endl; 00662 localHistory[ihit]->print(std::cout); 00663 } 00664 hitList->removeHit(localHistory[ihit]->hit()); 00665 } 00666 if(6==tkParam.lPrint){ 00667 cout << " current contents of localHistory: " 00668 <<localHistory.length()<<"hot" << endl; 00669 //for (int i=0; i<localHistory.length();++i) { 00670 //cout << " hit @ " << localHistory[i]->hit() << "; hot @ " << localHistory[i] << endl; 00671 //} 00672 } 00673 nFound--; 00674 } 00675 } 00676 else if (localHistory[ihit] == 0) { 00677 if(6==tkParam.lPrint){ cout << " localHistory= 0 " << endl; } 00678 int nSuccess = 0; 00679 lContinue = false; 00680 int last = 8; 00681 if (nCand < 8) last = nCand; 00682 for (int i = 0; i < last; i++) { 00683 int j = ihit + 1 + i; 00684 if (localHistory[j] != 0) nSuccess++; 00685 if (i == 2 && nSuccess >= 2) lContinue = true; 00686 if (i == 4 && nSuccess >= 3) lContinue = true; 00687 // if (i == 7 && nSuccess >= 5) lContinue = true; 00688 if (lContinue) break; 00689 } 00690 } 00691 } 00692 //std::cout<< "nFound="<<nFound <<" < "<< tkParam.pickHitFract*nCand<<" pickHitFract? "<< tkParam.pickHitFract<<"*"<<nCand << std::endl; 00693 //if (nFound < tkParam.pickHitFract * nCand) nFound = 0;//yzhang delete 2010-05-10 00694 if(6==tkParam.lPrint){ cout << " localHistory= 0 " << endl; } 00695 00696 if(6==tkParam.lPrint){ 00697 cout << "After pickHits found " << nFound <<" hits"<< endl; 00698 hitList->hotList().print(std::cout); 00699 } 00700 return nFound; 00701 }
|
|
|
|
00092 { 00093 //************************************************************************* 00094 std::cout<< "nTrack "<<nTrack() << std::endl;//yzhang debug 00095 for (int itrack = 0; itrack < nTrack(); itrack++) { 00096 MdcTrack *atrack = (*this)[itrack]; 00097 if (atrack == NULL) continue; 00098 atrack->track().printAll(cout); 00099 } 00100 }
|
|
Reimplemented in MdcTrackListCsmc, and MdcTrackListCsmc. |
|
Reimplemented in MdcTrackListCsmc, and MdcTrackListCsmc. 00548 { 00549 //-------------------------------------------------------------------- 00550 if (atrack != 0) { 00551 HepAList<MdcTrack>::remove( atrack ); 00552 delete atrack; 00553 } 00554 }
|
|
00057 {m_d0Cut = d0Cut;}//yzhang add
|
|
00057 {m_d0Cut = d0Cut;}//yzhang add
|
|
|
|
|
|
00059 {m_ptCut = ptCut;}//yzhang add 2009-10-27
|
|
00059 {m_ptCut = ptCut;}//yzhang add 2009-10-27
|
|
00058 {m_z0Cut = z0Cut;}//yzhang add 2010-05-21
|
|
00058 {m_z0Cut = z0Cut;}//yzhang add 2010-05-21
|
|
|
|
00075 { 00076 // *********************************************************************** 00077 int trackId = 0; 00078 for (int itrack = 0; itrack < nTrack(); itrack++) { 00079 MdcTrack* track = (*this)[itrack]; 00080 //tkStat: 0,PatRec 1,MdcxReco 2,Tsf 3,CurlFinder 00081 int tkStat = 0; 00082 track->storeTrack(trackId, trackList, hitList, tkStat); 00083 ++trackId; 00084 } 00085 HepAListDeleteAll(*this); // Discard the husks 00086 removeAll(); 00087 return; 00088 }
|
|
|
|
|
|
|
|
|
|
|