#include <MdcSegGrouper.h>
Inheritance diagram for MdcSegGrouper:
Public Member Functions | |
virtual | ~MdcSegGrouper () |
int | nextGroup (MdcSeg **segGroup, bool printit) |
int | updateGap () |
void | resetGap (int nGap) |
virtual void | resetComb (const MdcSeg *seed)=0 |
virtual MdcTrack * | storePar (MdcTrack *trk, double parms[2], double chisq, TrkContext &, double trackT0)=0 |
int | nPly () const |
virtual int | incompWithSeg (const MdcSeg *refSeg, const MdcSeg *testSeg)=0 |
virtual int | incompWithGroup (MdcSeg **segGroup, const MdcSeg *testSeg, int iply)=0 |
int | combineSegs (MdcTrack *&, MdcSeg *seed, TrkContext &, double trackT0, double maxSegChisqO, int combineByFitHits=0) |
void | transferHits (MdcTrack *track, int nSegs, MdcSeg **segGroup) |
void | dumpSegList () |
double | calcParBySegs (MdcSeg **segGroup, double seedAngle[2], int nToUse, double &qual, int &nSegFit, double param[2]) |
double | calcParByHits (MdcSeg **segGroup, int nToUse, const TrkExchangePar &par, double &qual, int &nSegFit, double param[2], double Bz) |
Protected Member Functions | |
MdcSegGrouper (const MdcDetector *gm, int nDeep, int debug) | |
void | resetSegCounters () |
Protected Attributes | |
int | nDeep |
int | nPlyFilled |
int * | currentSeg |
int * | firstGood |
int * | firstBad |
bool ** | isValid |
HepAList< MdcSeg > ** | combList |
const MdcDetector * | _gm |
HepAList< MdcSeg > * | segList |
bool * | leaveGap |
int | nNull |
int | maxNull |
int * | gapCounter |
bool | lTestGroup |
bool | lTestSingle |
int | _debug |
Private Member Functions | |
MdcSegGrouper & | operator= (const MdcSegGrouper &) |
MdcSegGrouper (const MdcSegGrouper &) |
Definition at line 39 of file MdcSegGrouper.h.
MdcSegGrouper::~MdcSegGrouper | ( | ) | [virtual] |
Definition at line 45 of file MdcSegGrouper.cxx.
References combList, currentSeg, firstBad, firstGood, gapCounter, genRecEmupikp::i, isValid, leaveGap, nDeep, and segList.
00045 { 00046 //------------------------------------------------------------------------ 00047 delete [] segList; 00048 delete [] combList; 00049 delete [] currentSeg; 00050 delete [] leaveGap; 00051 delete [] gapCounter; 00052 delete [] firstGood; 00053 delete [] firstBad; 00054 if (isValid != 0) { 00055 for (int i = 0; i < nDeep; i++) { 00056 delete [] isValid[i]; 00057 } 00058 delete [] isValid; 00059 } 00060 00061 }
MdcSegGrouper::MdcSegGrouper | ( | const MdcDetector * | gm, | |
int | nDeep, | |||
int | debug | |||
) | [protected] |
Definition at line 63 of file MdcSegGrouper.cxx.
References _debug, _gm, combList, currentSeg, firstBad, firstGood, gapCounter, leaveGap, lTestGroup, lTestSingle, nDeep, MdcDetector::nSuper(), and segList.
00063 { 00064 //------------------------------------------------------------------------ 00065 nDeep = nd; 00066 int nsuper = gm->nSuper(); 00067 segList = new HepAList<MdcSeg>[nsuper]; 00068 currentSeg = new int[nDeep]; 00069 leaveGap = new bool[nDeep]; 00070 gapCounter = new int[nDeep]; 00071 combList = new HepAList<MdcSeg> * [nDeep]; 00072 _gm = gm; 00073 firstGood = new int[nDeep]; 00074 firstBad = new int[nDeep]; 00075 lTestGroup = false; 00076 lTestSingle = false; 00077 _debug = debug; 00078 }
MdcSegGrouper::MdcSegGrouper | ( | const MdcSegGrouper & | ) | [private] |
double MdcSegGrouper::calcParByHits | ( | MdcSeg ** | segGroup, | |
int | nToUse, | |||
const TrkExchangePar & | par, | |||
double & | qual, | |||
int & | nSegFit, | |||
double | param[2], | |||
double | Bz | |||
) |
Definition at line 585 of file MdcSegGrouper.cxx.
References _debug, MdcLine::chisq, MdcLine::fit(), MdcSeg::hit(), MdcSeg::info(), MdcLine::intercept, MdcHit::layernumber(), MdcHitUse::mdcHit(), MdcSeg::nHit(), MdcLine::nPoint, MdcLine::sigma, MdcLine::slope, MdcHit::wirenumber(), MdcLine::x, MdcLine::y, and MdcSegInfoSterO::zPosition().
Referenced by combineSegs().
00585 { 00586 //************************************************************************ 00587 //*** Calc. z and cot(theta) for stereo 00588 int debug = false; 00589 if (11 == _debug ) debug = true; 00590 if (debug) std::cout<< "-----calculate group param by hit-----"<<std::endl; 00591 MdcLine span(50); 00592 MdcLine spanFit(50); 00593 00594 int nHit = 0; 00595 if (debug) std::cout<< "nToUse="<<nToUse<<std::endl; 00596 for (int iPly = 0; iPly < nToUse; iPly++) { 00597 if (segGroup[iPly] == 0) continue; // skipping this slayer 00598 nSegFit++; 00599 MdcSegInfoSterO *segInfo = dynamic_cast<MdcSegInfoSterO*> (segGroup[iPly]->info()); 00600 00601 if(debug) std::cout<< "nHit in segment="<<segGroup[iPly]->nHit()<<std::endl; 00602 for (int ii=0,iHit=0; ii<segGroup[iPly]->nHit(); ii++){ 00603 00604 if(debug)std::cout<< " calcParByHits ("<< segGroup[iPly]->hit(iHit)->mdcHit()->layernumber()<<","<<segGroup[iPly]->hit(iHit)->mdcHit()->wirenumber()<<")"; 00605 //if(segGroup[iPly]->hit(iHit)->mdcHit()->layernumber()<4) continue;//yzhang TEMP TEST 2011-08-01 00606 00607 int szCode = segInfo->zPosition(*(segGroup[iPly]->hit(iHit)),par,&span,iHit,segGroup[iPly]->bunchTime(),Bz); 00608 if(debug)std::cout<< " szCode "<<szCode; 00609 if(szCode>0&&debug) std::cout<< iHit<<" s "<< span.x[iHit]<< " z "<<span.y[iHit] <<" sigma "<<span.sigma[iHit]; 00610 if(debug)std::cout<<std::endl; 00611 00612 spanFit.x[nHit]=span.x[iHit]; 00613 spanFit.y[nHit]=span.y[iHit]; 00614 //spanFit.sigma[nHit]=span.sigma[iHit]; 00615 spanFit.sigma[nHit]=1.; 00616 if(debug)std::cout<< std::endl; 00617 iHit++; 00618 if(szCode>0) nHit++; 00619 } 00620 } 00621 00622 if(debug)std::cout<< __FILE__ << " " << __LINE__ << " nHit "<< nHit<<std::endl; 00623 if (nHit>0) spanFit.fit(nHit); 00624 else return -999; 00625 00626 param[0] = spanFit.intercept; 00627 param[1] = spanFit.slope; 00628 if(debug)std::cout<< "nHit "<<nHit<<" intercept(z0) "<<param[0]<< " slope(ct) " << param[1] <<std::endl; 00629 00630 qual = 2.*nHit - spanFit.chisq/(spanFit.nPoint - 2); 00631 if(debug)std::cout<< "chisq "<<spanFit.chisq<<" qual "<<qual<<std::endl; 00632 00633 return spanFit.chisq; 00634 }
double MdcSegGrouper::calcParBySegs | ( | MdcSeg ** | segGroup, | |
double | seedAngle[2], | |||
int | nToUse, | |||
double & | qual, | |||
int & | nSegFit, | |||
double | param[2] | |||
) |
Definition at line 475 of file MdcSegGrouper.cxx.
References _debug, MdcSegInfo::errmat(), ers::error, genRecEmupikp::i, MdcSeg::info(), MdcSegInfo::inverr(), ganga-rec::j, mdcTwoInv(), mdcTwoVec(), mdcWrapAng(), MdcSeg::nHit(), MdcSegInfo::par(), and MdcSegInfo::parIsAngle().
Referenced by combineSegs().
00476 { 00477 //************************************************************************ 00478 if (11 == _debug) std::cout<< "-----calculate group param by segment param-----"<<std::endl; 00479 double wgtmat[3], wgtinv[3]; 00480 double wgtpar[2]; 00481 double temvec[2], diff[2]; 00482 // Calculate track & chisq for this group 00483 int nhit = 0; 00484 wgtmat[0] = wgtmat[1] = wgtmat[2] = wgtpar[0] = wgtpar[1] = 0.0; 00485 00486 int iPly; 00487 for (iPly = 0; iPly < nToUse; iPly++) { 00488 if (11 == _debug) { 00489 //if (!lSeed) //if (segGroup[iPly] == 0) cout << "ply empty: " << iPly << "\n"; 00490 } 00491 if (segGroup[iPly] == 0) continue; // skipping this slayer 00492 nSegFit++; 00493 MdcSegInfo *segInfo = segGroup[iPly]->info(); 00494 // Accumulate sums 00495 for (int i = 0; i < 3; i++) wgtmat[i] += (segInfo->inverr())[i]; 00496 for (int k = 0; k < 2; k++) { 00497 param[k] = segInfo->par(k); 00498 //zhangy add 00499 if (segInfo->parIsAngle(k)) { 00500 param[k] = mdcWrapAng(seedAngle[k], param[k]); 00501 } 00502 } 00503 // Multiply by weight matrix. 00504 mdcTwoVec( segInfo->inverr(), param, temvec ); 00505 wgtpar[0] += temvec[0]; 00506 wgtpar[1] += temvec[1]; 00507 if(11 == _debug) { 00508 std::cout<<0<<": param "<<param[0]<<" inverr "<< segInfo->inverr()[0]<<" par*W "<<temvec[0]<<std::endl; 00509 std::cout<<1<<": param "<<param[1]<<" "<<1/param[1]<<" inverr "<< segInfo->inverr()[1]<<" par*W "<<temvec[1]<<std::endl; 00510 std::cout<< " " <<std::endl; 00511 } 00512 nhit += segGroup[iPly]->nHit(); 00513 } 00514 00515 // And the fitted parameters are . . . 00516 int error = mdcTwoInv(wgtmat,wgtinv); 00517 if (error && (11 == _debug)) { 00518 cout << "ErrMsg(warning) " 00519 << "failed matrix inversion in MdcTrackList::combineSegs" << endl; 00520 //continue; 00521 return -999.; 00522 } 00523 mdcTwoVec( wgtinv, wgtpar, param ); 00524 if(11 == _debug) { 00525 std::cout<< " param of wgtinv * wgtpar" << std::endl; 00526 std::cout<<0<<": param "<<param[0]<< std::endl; 00527 std::cout<<1<<": param "<<param[1]<<" "<<1/param[1]<< std::endl; 00528 std::cout<< " " <<std::endl; 00529 } 00530 00531 //param[0]= 5.312286; 00532 //param[1]= -0.006; 00533 //std::cout<< "set param " <<param[0]<< " "<<param[1]<<std::endl; 00534 if(11 == _debug)cout<<endl<<"-- Calculate track & chisq for this group "<<endl; 00535 00536 // Calc. chisq. = sum( (Vi - V0) * W * (Vi - V0) ) 00537 // W = weight, Vi = measurement, V0 = fitted param. 00538 double chisq = 0.0; 00539 for (iPly = 0; iPly < nToUse; iPly++) { 00540 if (segGroup[iPly] == 0) continue; // skipping this slayer 00541 MdcSegInfo *segInfo = segGroup[iPly]->info(); 00542 for (int j = 0; j < 2; j++) { 00543 double temPar; 00544 if (segInfo->parIsAngle(j)) { 00545 temPar = mdcWrapAng(seedAngle[j], segInfo->par(j)); 00546 } else { 00547 temPar = segInfo->par(j); 00548 } 00549 if(11 == _debug) { 00550 std::cout<<" segPar"<<j<<" "<<temPar<< std::endl; 00551 } 00552 diff[j] = temPar - param[j]; 00553 } 00554 00555 if(11 == _debug) { 00556 std::cout<<"inverr " <<segInfo->inverr()[0]<<" " 00557 <<segInfo->inverr()[1] <<" "<<segInfo->inverr()[2] << std::endl; 00558 std::cout<<"errmat " <<segInfo->errmat()[0]<< " " 00559 <<segInfo->errmat()[1] << " "<<segInfo->errmat()[2] << std::endl; 00560 std::cout<<"diff " <<diff[0]<<" "<<diff[1]<<" temvec "<<temvec[0]<<" "<<temvec[1]<< std::endl; 00561 std::cout<< std::endl; 00562 } 00563 mdcTwoVec( segInfo->inverr(), diff, temvec); 00564 00565 chisq += diff[0] * temvec[0] + diff[1] * temvec[1]; 00566 00567 if(11 == _debug){ 00568 std::cout<<iPly<<" chi2Add:"<<diff[0] * temvec[0] + diff[1] * temvec[1]<<" diff0 "<< diff[0]<< " vec0 "<<temvec[0]<<" diff1 "<< diff[1]<< " vec1 "<<temvec[1] << std::endl; 00569 } 00570 } 00571 00572 double chiDof = chisq/(2.*nSegFit - 2.); 00573 if (11 == _debug) { 00574 cout << "segment:"<<endl<<" chiDof "<<chiDof<<" chisq "<< chisq << " nhit " << nhit << " phi0/z0 " << 00575 param[0] << " cpa/cot " << param[1] << " qual "<<(2. * nhit - chiDof) <<endl; 00576 } 00577 00578 qual = 2. * nhit - chiDof; 00579 00580 //if(is3d) std::cout<< __FILE__ << " " << " z0 "<<param[0] << " ct "<<param[0] <<std::endl;//zhange TEMP test 2011-05-06 00581 return chisq; 00582 }
int MdcSegGrouper::combineSegs | ( | MdcTrack *& | , | |
MdcSeg * | seed, | |||
TrkContext & | , | |||
double | trackT0, | |||
double | maxSegChisqO, | |||
int | combineByFitHits = 0 | |||
) |
Definition at line 270 of file MdcSegGrouper.cxx.
References _debug, TrkRecoTrk::bField(), BField::bFieldZ(), calcParByHits(), calcParBySegs(), TrkRecoTrk::fitResult(), g_maxSegChisqAx, g_maxSegChisqSt, TrkFit::helix(), genRecEmupikp::i, MdcSeg::info(), iprint, nextGroup(), nPly(), MdcSegInfo::par(), MdcSegInfo::parIsAngle(), MdcSeg::plotSegAll(), resetComb(), storePar(), MdcTrack::track(), and transferHits().
Referenced by MdcTrackListCsmc::createFromSegs(), and MdcTrackList::createFromSegs().
00271 { 00272 //************************************************************************/ 00273 // forms track from list of segs; does 2-param fit (either r-phi from origin 00274 // or s-z) and picks best combination. 00275 if (3 == _debug) std::cout<<std::endl<< "=====MdcSegGrouper::combineSegs=====" <<std::endl; 00276 bool lSeed = (seed != 0); // no seed for stereo group 00277 00278 int success = 0; 00279 double qual; 00280 double qualBest = -1000.; 00281 int nSegFit = 0; 00282 int nSegBest = 0; 00283 //int nHitBest = 0; 00284 double param[2]; 00285 double paramBest[2]; 00286 double chiBest = 9999.; 00287 int nToUse = nPly(); 00288 if (lSeed) nToUse++; // seed isn't included in the segs list 00289 MdcSeg **segGroup; 00290 MdcSeg **segGroupBest; 00291 segGroup = new MdcSeg * [nToUse]; 00292 segGroupBest = new MdcSeg * [nToUse]; 00293 // static int counter = 0; 00294 // counter++; 00295 // cout << counter << endl; 00296 00297 //bool is3d = (seed==NULL);//zhange TEMP test 2011-05-06 00298 00299 // Loop over all combinations of segs consistent with seed (including gaps) 00300 if ((3 == _debug)&&lSeed) { 00301 std::cout<<"seed segment: "; 00302 seed->plotSegAll(); 00303 std::cout<< std::endl; 00304 } 00305 resetComb(seed); 00306 00307 // Save seed params (if angles) for later use as reference angle in 00308 // mdcWrapAng (don't really have to test whether it's an angle, but I do) 00309 double seedAngle[2] = {0.,0.}; 00310 if (lSeed) { 00311 if (seed->info()->parIsAngle(0)) seedAngle[0] = seed->info()->par(0); 00312 if (seed->info()->parIsAngle(1)) seedAngle[1] = seed->info()->par(1); 00313 } 00314 00315 int iprint = ( 3 == _debug); 00316 int nInGroup = 0; 00317 while ( (nInGroup = nextGroup(segGroup, iprint)) != 0) { 00318 00319 if (lSeed) { 00320 segGroup[nToUse-1] = seed; 00321 nInGroup++; 00322 } 00323 if (nInGroup < 0) continue; 00324 if (nInGroup < 2) break; 00325 if (nInGroup < nSegBest) break; 00326 00327 if (3 == _debug || 11 == _debug) { 00328 cout << endl <<"-----found a segment group by nextGroup()----- nInGroup "<<nInGroup<<" nToUse "<<nToUse<<endl; 00329 for(int ii=0; ii<nToUse; ii++){ if(segGroup[ii]) {segGroup[ii]->plotSegAll(); cout<<endl;} } 00330 //cout << endl <<"--calc. parameters of this segment group"<<endl; 00331 } 00332 00333 double chisq =-999.; 00334 nSegFit=0; 00335 00336 if(lSeed){ 00337 //2d 00338 chisq = calcParBySegs(segGroup, seedAngle, nToUse, qual, nSegFit, param); 00339 }else{ 00340 if (combineByFitHits == 0){ 00341 chisq = calcParBySegs(segGroup, seedAngle, nToUse, qual, nSegFit, param); 00342 }else{ 00343 //3d 00344 const TrkFit* tkFit = trk->track().fitResult(); 00345 double Bz = trk->track().bField().bFieldZ();//?? 00346 TrkExchangePar par = tkFit->helix(0.0); 00347 //par.print(std::cout); 00348 if (tkFit != 0) chisq = calcParByHits(segGroup, nToUse, par, qual,nSegFit, param, Bz); 00349 //std::cout<< __FILE__ << " " << __LINE__ << " calcParByHits"<<std::endl; 00350 if(chisq<=0){ 00351 //std::cout<< "calcParByHits failed! calc. by seg" <<std::endl; 00352 chisq = calcParBySegs(segGroup, seedAngle, nToUse, qual, nSegFit, param); 00353 } 00354 } 00355 } 00356 00357 00358 if (chisq < 0.) continue;//yzhang add 00359 double chiDof = chisq/(2.*nSegFit - 2.); 00360 00361 if (g_maxSegChisqAx && lSeed ) { g_maxSegChisqAx->fill(chiDof); } //yzhang hist cut 00362 if (g_maxSegChisqSt && !lSeed) { g_maxSegChisqSt->fill(chiDof); } //yzhang hist cut 00363 00364 //std::cout<< " chisq " << chisq<< " chi2dof "<<chiDof<<std::endl; 00365 00366 if (3 == _debug || 11 == _debug) { 00367 std::cout<< endl<<"chisq "<<chisq<<" nSegFit " << nSegFit<< " chiDof "<<chiDof<<std::endl; 00368 if(chiDof > maxSegChisqO) { 00369 cout << "***** DROP this group by chiDof "<<chiDof<<" > maxSegChisqO:"<<maxSegChisqO<<endl; 00370 }else{ 00371 cout << "***** KEEP this group by chiDof "<<chiDof<<" <= maxSegChisqO:"<<maxSegChisqO<<endl; 00372 } 00373 } 00374 // Chisq test 00375 if (chiDof > maxSegChisqO) continue; 00376 00377 success = 1; 00378 if (qual > qualBest) { 00379 qualBest = qual; 00380 nSegBest = nSegFit; 00381 //nHitBest = nhit; 00382 paramBest[0] = param[0]; 00383 paramBest[1] = param[1]; 00384 chiBest = chisq; 00385 for (int i = 0; i < nToUse; i++) { 00386 segGroupBest[i] = segGroup[i]; 00387 } 00388 if (3 == _debug && 11 == _debug) std::cout<<"Keep as best group. param: phi0/z0 " 00389 <<paramBest[0]<< " cpa/ct "<<paramBest[1]<< std::endl; 00390 }// end test on qual 00391 } 00392 00393 if (success == 1) { 00394 if(3 == _debug || 11 == _debug) { 00395 std::cout<< endl<<"-----Parameter best group----- "<<std::endl; 00396 std::cout<< "paramBest "<<paramBest[0]<<" "<<paramBest[1]<< " chiBest " << chiBest<< std::endl; 00397 } 00398 // Store the results in a track, possibly creating it in the process 00399 trk = storePar(trk, paramBest, chiBest, context, t0); 00400 transferHits(trk, nToUse, segGroupBest); // Store hits with track 00401 } 00402 delete [] segGroupBest; 00403 delete [] segGroup; 00404 return success; 00405 }
void MdcSegGrouper::dumpSegList | ( | ) |
Definition at line 464 of file MdcSegGrouper.cxx.
References genRecEmupikp::i, and segList.
Referenced by MdcTrackList::createFromSegs().
00464 { 00465 //************************************************************************ 00466 for(int islayer=0; islayer<11; islayer++){ 00467 for(int i=0; i<segList[islayer].length(); i++){ 00468 segList[islayer][i]->plotSegAll(); 00469 std::cout<< std::endl; 00470 } 00471 } 00472 }
virtual int MdcSegGrouper::incompWithSeg | ( | const MdcSeg * | refSeg, | |
const MdcSeg * | testSeg | |||
) | [pure virtual] |
Implemented in MdcSegGrouperAx, MdcSegGrouperCsmc, and MdcSegGrouperSt.
Definition at line 83 of file MdcSegGrouper.cxx.
References combList, MdcSegInfoSterO::ct(), currentSeg, firstBad, firstGood, incompWithGroup(), isValid, leaveGap, lTestGroup, lTestSingle, maxNull, nDeep, nNull, nPlyFilled, resetGap(), resetSegCounters(), and updateGap().
Referenced by combineSegs().
00083 { 00084 //------------------------------------------------------------------------ 00085 00086 // Loop over the superlayers, moving to next valid seg for each if necessary 00087 // First, loop over the slayers w/o good segs, filling segGroup w/ 0 00088 int iply; 00089 for (iply = nPlyFilled; iply < nDeep; iply++) { 00090 segGroup[iply] = 0; 00091 } 00092 00093 restart: 00094 if (printit) cout <<endl<< "MdcSegGrouper::nextGroup starting group finder, nply = " << nPlyFilled << endl; 00095 int nFound = 0; 00096 bool incrementNext = true; 00097 //int nSegUsed;//yzhang 2010-05-21 00098 for (iply = 0; iply < nPlyFilled; iply++) { 00099 segGroup[iply] = 0; 00100 if (!incrementNext && currentSeg[iply] >= firstGood[iply]) { 00101 if(printit) std::cout<< " reach end of list, break." << iply<< std::endl; 00102 break; 00103 } 00104 //if (nSegUsed > segPar.nSegUsedNextGroup) break; 00105 if (leaveGap[iply]) { 00106 if(printit) std::cout<< " leaveGap " <<std::endl; 00107 // This ply is currently a gap; move on. 00108 if (iply == nPlyFilled - 1 && incrementNext) { 00109 // we've exhausted this gap group; start another 00110 iply = -1; 00111 resetSegCounters(); 00112 int lDone = updateGap(); 00113 if (lDone) { 00114 // all gap groups for nNull exhausted; increment nNull 00115 nNull++; 00116 if (nNull > maxNull) return 0; // All done 00117 resetGap(nNull); 00118 updateGap(); 00119 } // end if lDone 00120 } //end if exhausted gap group 00121 continue; 00122 } 00123 incrementNext = false; 00124 00125 // Loop through the segs in this ply until valid one found 00126 while (1) { 00127 currentSeg[iply]++; 00128 if (currentSeg[iply] == firstBad[iply]) { // reached end of segs 00129 incrementNext = true; 00130 currentSeg[iply] = firstGood[iply]; 00131 if(printit) { std::cout<< "reach end of segs "<<std::endl; } 00132 if (iply == nPlyFilled - 1) { 00133 // we've exhausted this gap group; start another 00134 iply = -1; 00135 resetSegCounters(); 00136 int lDone = updateGap(); 00137 if (lDone) { 00138 // all gap groups for nNull exhausted; increment nNull 00139 nNull++; 00140 if (nNull > maxNull) { 00141 if(printit) { std::cout<<endl<< " All done! "<<std::endl; } 00142 return 0; // All done 00143 } 00144 resetGap(nNull); 00145 updateGap(); 00146 } // end if lDone 00147 } //end if exhausted gap group 00148 break; 00149 } // end reached end of segs 00150 00151 if(printit){ 00152 std::cout<< "ply " << iply<< " seg "<<currentSeg[iply]<<": "; 00153 (*combList[iply])[currentSeg[iply]]->plotSeg(); 00154 if((*combList[iply])[currentSeg[iply]]->superlayer()->whichView()!= 0){ 00155 MdcSegInfoSterO* info = (MdcSegInfoSterO *) (*combList[iply])[currentSeg[iply]]->info(); 00156 std::cout<< " ct " << info->ct(); 00157 } 00158 } 00159 00160 //yzhang 09-09-28 delete 00161 if( (*combList[iply])[currentSeg[iply]]->segUsed()) { 00162 if(printit) { 00163 std::cout<< std::endl<<" Used??"; 00164 (*combList[iply])[currentSeg[iply]]->plotSeg(); 00165 } 00166 if(printit) { std::cout<< " segUsed! SKIP "<<std::endl; } 00167 continue; //yzhang 2010-05-21 add 00168 //nSegUsed++; 00169 } 00170 00171 // Test this seg for validity 00172 if (lTestSingle) { 00173 assert(isValid != 0); 00174 assert(isValid[iply] != 0); 00175 int invalid = (isValid[iply][currentSeg[iply]] == false); 00176 if(printit) { 00177 if(invalid){ std::cout<<" invalid "<< std::endl; 00178 }else{ std::cout<<" KEEP 1 "<< std::endl; } 00179 } 00180 if (invalid) continue; 00181 }else{ 00182 if(printit) std::cout<<" KEEP 2 "<< std::endl; 00183 } 00184 00185 // Whew. We successfully incremented. 00186 break; 00187 00188 } // end seg loop 00189 } // end ply loop 00190 00191 // Fill segGroup with appropriate segs 00192 for (iply = 0; iply < nPlyFilled; iply++) { 00193 if (leaveGap[iply]) { 00194 segGroup[iply] = 0; 00195 } else { 00196 segGroup[iply] = (*combList[iply])[currentSeg[iply]]; 00197 if (lTestGroup && nFound > 1) { 00198 int lBad = incompWithGroup(segGroup, segGroup[iply], iply); 00199 if(printit){ 00200 if(lBad) std::cout<<" incompWithGroup Bad! restart" << std::endl; 00201 //else std::cout<<" incompWithGroup Bad! restart" << std::endl; 00202 } 00203 if (lBad) goto restart; 00204 } 00205 nFound++; 00206 } 00207 } 00208 00209 if (printit) std::cout<< "nextGoup() found " << nFound << " segment(s)"<<std::endl; 00210 return nFound; 00211 }
int MdcSegGrouper::nPly | ( | ) | const [inline] |
Definition at line 54 of file MdcSegGrouper.h.
Referenced by combineSegs(), MdcSegGrouperAx::MdcSegGrouperAx(), MdcSegGrouperCsmc::MdcSegGrouperCsmc(), and MdcSegGrouperSt::MdcSegGrouperSt().
00054 {return nDeep;}
MdcSegGrouper& MdcSegGrouper::operator= | ( | const MdcSegGrouper & | ) | [private] |
virtual void MdcSegGrouper::resetComb | ( | const MdcSeg * | seed | ) | [pure virtual] |
void MdcSegGrouper::resetGap | ( | int | nGap | ) |
Definition at line 214 of file MdcSegGrouper.cxx.
References gapCounter, genRecEmupikp::i, and nPlyFilled.
Referenced by nextGroup().
00214 { 00215 //************************************************************************** 00216 00217 for (int i = 0; i < nPlyFilled; i++) { 00218 gapCounter[i] = nGap - 1 - i; 00219 } 00220 gapCounter[0]--; // so 1st increment will put 1st counter in right place 00221 00222 return; 00223 }
void MdcSegGrouper::resetSegCounters | ( | ) | [protected] |
Definition at line 262 of file MdcSegGrouper.cxx.
References currentSeg, firstGood, genRecEmupikp::i, and nPlyFilled.
Referenced by nextGroup(), MdcSegGrouperSt::resetComb(), MdcSegGrouperCsmc::resetComb(), and MdcSegGrouperAx::resetComb().
00262 { 00263 //------------------------------------------------------------------------- 00264 for (int i = 0; i < nPlyFilled; i++) { 00265 currentSeg[i] = firstGood[i] - 1; 00266 } 00267 }
virtual MdcTrack* MdcSegGrouper::storePar | ( | MdcTrack * | trk, | |
double | parms[2], | |||
double | chisq, | |||
TrkContext & | , | |||
double | trackT0 | |||
) | [pure virtual] |
Implemented in MdcSegGrouperAx, MdcSegGrouperCsmc, and MdcSegGrouperSt.
Referenced by combineSegs().
Definition at line 408 of file MdcSegGrouper.cxx.
References _debug, TrkHitList::appendHit(), MdcTrack::firstLayer(), MdcTrack::hasCurled(), TrkRecoTrk::hits(), genRecEmupikp::i, MdcTrack::lastLayer(), MdcSeg::nHit(), MdcSeg::plotSegAll(), MdcLayer::rMid(), MdcTrack::setFirstLayer(), MdcTrack::setLastLayer(), MdcSeg::setUsed(), and MdcTrack::track().
Referenced by combineSegs().
00408 { 00409 //************************************************************************/ 00410 //Move hits from segments to track hitlist 00411 // Also note first and last layers in list 00412 // Only handles Mdc segments 00413 double smallRad = 1000.; 00414 if (trk->firstLayer() != 0) smallRad = trk->firstLayer()->rMid(); 00415 double bigRad = 0.; 00416 if (trk->lastLayer() != 0) bigRad = trk->lastLayer()->rMid(); 00417 00418 //yzhang 2011-05-04 00419 //bool maintainAmbiguity = (trk->track().status()->is2d() == 0) ? false: true; 00420 //bool maintainAmbiguity = false; 00421 //std::cout<< __FILE__ << " " << __LINE__ << " maintainAmbiguity "<<maintainAmbiguity<<std::endl; 00422 00423 if(3 == _debug) std::cout<< endl<<"-----transferHits for this segGroup----- " <<std::endl; 00424 for (int i = 0; i < nSegs; i++) { 00425 if (segGroup[i] == 0) continue; // skipping this slayer 00426 if(3 == _debug) { 00427 cout << i << " "; segGroup[i]->plotSegAll(); cout<< endl; 00428 } 00429 segGroup[i]->setUsed(); // mark seg as used 00430 for (int ihit = 0; ihit < segGroup[i]->nHit(); ihit++) { 00431 MdcHitUse *aHit = segGroup[i]->hit(ihit); 00432 const MdcLayer *layer = aHit->mdcHit()->layer(); 00433 double radius = layer->rMid(); 00434 if (radius < smallRad) { 00435 smallRad = radius; 00436 trk->setFirstLayer(layer); 00437 } 00438 00439 // Assume that segs aren't added to backside of curler 00440 if (radius > bigRad && !trk->hasCurled()) { 00441 bigRad = radius; 00442 trk->setLastLayer(layer); 00443 } 00444 // Provide very crude starting guess of flightlength 00445 double flt = radius; 00446 flt += 0.000001 * (aHit->mdcHit()->x() +aHit->mdcHit()->y()); 00447 00448 aHit->setFltLen(flt); 00449 00450 TrkHitList* theHits = trk->track().hits(); 00451 00452 if (theHits == 0) return; 00453 00454 //theHits->appendHit(*aHit, maintainAmbiguity); 00455 theHits->appendHit(*aHit); 00456 //zhangy 00457 00458 //std::cout<<"in MdcSegGrouper append ok"<<std::endl;//yzhang debug 00459 } 00460 } // end loop over slayers 00461 }
int MdcSegGrouper::updateGap | ( | ) |
Definition at line 226 of file MdcSegGrouper.cxx.
References gapCounter, genRecEmupikp::i, ganga-rec::j, leaveGap, nNull, and nPlyFilled.
Referenced by nextGroup().
00226 { 00227 //************************************************************************** 00228 if (nNull == 0) return 1; 00229 00230 for (int i = 0; i < nPlyFilled; i++) { 00231 leaveGap[i] = false; 00232 } 00233 for (int igap = 0; igap < nNull; igap++) { 00234 gapCounter[igap]++; 00235 if (gapCounter[igap] == nPlyFilled - igap) { 00236 // End of loop for this counter; look at the other counters to 00237 // decide where this one should be reset to. 00238 int inext = igap + 1; 00239 while (1) { 00240 if (inext >= nNull) return 1; // done with all combos 00241 if (gapCounter[inext] + inext + 1 < nPlyFilled) { 00242 // This is the right spot to reset to 00243 gapCounter[igap] = gapCounter[inext] + inext + 1 - igap; 00244 break; 00245 } 00246 inext++; 00247 } 00248 } 00249 else { 00250 // We successfully incremented. Quit looping and return. 00251 break; 00252 } 00253 } // end loop over igap 00254 00255 for (int j = 0; j < nNull; j++) { 00256 leaveGap[gapCounter[j]] = true; 00257 } 00258 return 0; 00259 00260 }
int MdcSegGrouper::_debug [protected] |
Definition at line 96 of file MdcSegGrouper.h.
Referenced by calcParByHits(), calcParBySegs(), combineSegs(), MdcSegGrouperSt::fillWithSegs(), MdcSegGrouperAx::fillWithSegs(), MdcSegGrouperSt::incompWithGroup(), MdcSegGrouperAx::incompWithSeg(), MdcSegGrouper(), MdcSegGrouperAx::resetComb(), MdcSegGrouperSt::storePar(), and transferHits().
const MdcDetector* MdcSegGrouper::_gm [protected] |
Definition at line 78 of file MdcSegGrouper.h.
Referenced by MdcSegGrouperSt::fillWithSegs(), MdcSegGrouperCsmc::fillWithSegs(), MdcSegGrouperAx::fillWithSegs(), MdcSegGrouper(), MdcSegGrouperSt::plotStereo(), MdcSegGrouperSt::resetComb(), MdcSegGrouperCsmc::resetComb(), MdcSegGrouperAx::resetComb(), MdcSegGrouperSt::resetList(), MdcSegGrouperCsmc::storePar(), and MdcSegGrouperAx::storePar().
HepAList<MdcSeg>** MdcSegGrouper::combList [protected] |
Definition at line 77 of file MdcSegGrouper.h.
Referenced by MdcSegGrouperSt::incompWithGroup(), MdcSegGrouper(), nextGroup(), MdcSegGrouperSt::resetComb(), MdcSegGrouperCsmc::resetComb(), MdcSegGrouperAx::resetComb(), and ~MdcSegGrouper().
int* MdcSegGrouper::currentSeg [protected] |
Definition at line 70 of file MdcSegGrouper.h.
Referenced by MdcSegGrouperSt::incompWithGroup(), MdcSegGrouper(), nextGroup(), resetSegCounters(), and ~MdcSegGrouper().
int* MdcSegGrouper::firstBad [protected] |
Definition at line 72 of file MdcSegGrouper.h.
Referenced by MdcSegGrouper(), nextGroup(), MdcSegGrouperSt::resetComb(), MdcSegGrouperCsmc::resetComb(), MdcSegGrouperAx::resetComb(), and ~MdcSegGrouper().
int* MdcSegGrouper::firstGood [protected] |
Definition at line 71 of file MdcSegGrouper.h.
Referenced by MdcSegGrouper(), nextGroup(), MdcSegGrouperSt::resetComb(), MdcSegGrouperCsmc::resetComb(), MdcSegGrouperAx::resetComb(), resetSegCounters(), and ~MdcSegGrouper().
int* MdcSegGrouper::gapCounter [protected] |
Definition at line 91 of file MdcSegGrouper.h.
Referenced by MdcSegGrouper(), resetGap(), updateGap(), and ~MdcSegGrouper().
bool** MdcSegGrouper::isValid [protected] |
Definition at line 73 of file MdcSegGrouper.h.
Referenced by MdcSegGrouperAx::MdcSegGrouperAx(), MdcSegGrouperCsmc::MdcSegGrouperCsmc(), MdcSegGrouperSt::MdcSegGrouperSt(), nextGroup(), MdcSegGrouperSt::resetComb(), MdcSegGrouperCsmc::resetComb(), MdcSegGrouperAx::resetComb(), and ~MdcSegGrouper().
bool* MdcSegGrouper::leaveGap [protected] |
Definition at line 88 of file MdcSegGrouper.h.
Referenced by MdcSegGrouperSt::incompWithGroup(), MdcSegGrouper(), nextGroup(), MdcSegGrouperSt::resetComb(), MdcSegGrouperCsmc::resetComb(), MdcSegGrouperAx::resetComb(), updateGap(), and ~MdcSegGrouper().
bool MdcSegGrouper::lTestGroup [protected] |
Definition at line 93 of file MdcSegGrouper.h.
Referenced by MdcSegGrouper(), MdcSegGrouperAx::MdcSegGrouperAx(), MdcSegGrouperCsmc::MdcSegGrouperCsmc(), MdcSegGrouperSt::MdcSegGrouperSt(), and nextGroup().
bool MdcSegGrouper::lTestSingle [protected] |
Definition at line 94 of file MdcSegGrouper.h.
Referenced by MdcSegGrouper(), MdcSegGrouperAx::MdcSegGrouperAx(), MdcSegGrouperCsmc::MdcSegGrouperCsmc(), MdcSegGrouperSt::MdcSegGrouperSt(), and nextGroup().
int MdcSegGrouper::maxNull [protected] |
Definition at line 90 of file MdcSegGrouper.h.
Referenced by nextGroup(), MdcSegGrouperSt::resetComb(), MdcSegGrouperCsmc::resetComb(), and MdcSegGrouperAx::resetComb().
int MdcSegGrouper::nDeep [protected] |
Definition at line 68 of file MdcSegGrouper.h.
Referenced by MdcSegGrouper(), nextGroup(), MdcSegGrouperSt::resetComb(), MdcSegGrouperCsmc::resetComb(), MdcSegGrouperAx::resetComb(), and ~MdcSegGrouper().
int MdcSegGrouper::nNull [protected] |
Definition at line 89 of file MdcSegGrouper.h.
Referenced by nextGroup(), MdcSegGrouperSt::resetComb(), MdcSegGrouperCsmc::resetComb(), MdcSegGrouperAx::resetComb(), and updateGap().
int MdcSegGrouper::nPlyFilled [protected] |
Definition at line 69 of file MdcSegGrouper.h.
Referenced by nextGroup(), MdcSegGrouperSt::resetComb(), MdcSegGrouperCsmc::resetComb(), MdcSegGrouperAx::resetComb(), resetGap(), resetSegCounters(), and updateGap().
HepAList<MdcSeg>* MdcSegGrouper::segList [protected] |
Definition at line 79 of file MdcSegGrouper.h.
Referenced by dumpSegList(), MdcSegGrouperSt::fillWithSegs(), MdcSegGrouperCsmc::fillWithSegs(), MdcSegGrouperAx::fillWithSegs(), MdcSegGrouper(), MdcSegGrouperSt::plotStereo(), MdcSegGrouperSt::resetComb(), MdcSegGrouperCsmc::resetComb(), MdcSegGrouperAx::resetComb(), MdcSegGrouperSt::resetList(), and ~MdcSegGrouper().