#include <MdcSegGrouperCsmc.h>
Inheritance diagram for MdcSegGrouperCsmc:
Public Member Functions | |
MdcSegGrouperCsmc (const MdcDetector *gm, int debug) | |
~MdcSegGrouperCsmc () | |
void | fillWithSegs (const MdcSegList *inSegs) |
virtual int | incompWithSeg (const MdcSeg *refSeg, const MdcSeg *testSeg) |
virtual int | incompWithGroup (MdcSeg **segGroup, const MdcSeg *testSeg, int iply) |
void | resetComb (const class MdcSeg *) |
virtual MdcTrack * | storePar (MdcTrack *trk, double parms[2], double chisq, TrkContext &, double trackT0) |
int | nextGroup (MdcSeg **segGroup, bool printit) |
int | updateGap () |
void | resetGap (int nGap) |
virtual void | resetComb (const MdcSeg *seed)=0 |
int | nPly () const |
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 | |
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 | |
MdcSegGrouperCsmc & | operator= (const MdcSegGrouperCsmc &) |
Private Attributes | |
const MdcSeg * | _seed |
Definition at line 28 of file MdcSegGrouperCsmc.h.
MdcSegGrouperCsmc::MdcSegGrouperCsmc | ( | const MdcDetector * | gm, | |
int | debug | |||
) |
Definition at line 35 of file MdcSegGrouperCsmc.cxx.
References MdcSegGrouper::isValid, ganga-rec::j, MdcSegGrouper::lTestGroup, MdcSegGrouper::lTestSingle, and MdcSegGrouper::nPly().
00035 : 00036 MdcSegGrouper(gm, gm->nAxialSuper()-1, debug) { 00037 //------------------------------------------------------------------------ 00038 00039 lTestGroup = false; 00040 lTestSingle = false; 00041 00042 isValid = new bool * [nPly()]; 00043 for (int j = 0; j < nPly(); j++) { 00044 isValid[j] = 0; 00045 } 00046 }
MdcSegGrouperCsmc::~MdcSegGrouperCsmc | ( | ) | [inline] |
double MdcSegGrouper::calcParByHits | ( | MdcSeg ** | segGroup, | |
int | nToUse, | |||
const TrkExchangePar & | par, | |||
double & | qual, | |||
int & | nSegFit, | |||
double | param[2], | |||
double | Bz | |||
) | [inherited] |
Definition at line 585 of file MdcSegGrouper.cxx.
References MdcSegGrouper::_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 MdcSegGrouper::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] | |||
) | [inherited] |
Definition at line 475 of file MdcSegGrouper.cxx.
References MdcSegGrouper::_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 MdcSegGrouper::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 | |||
) | [inherited] |
Definition at line 270 of file MdcSegGrouper.cxx.
References MdcSegGrouper::_debug, TrkRecoTrk::bField(), BField::bFieldZ(), MdcSegGrouper::calcParByHits(), MdcSegGrouper::calcParBySegs(), TrkRecoTrk::fitResult(), g_maxSegChisqAx, g_maxSegChisqSt, TrkFit::helix(), genRecEmupikp::i, MdcSeg::info(), iprint, MdcSegGrouper::nextGroup(), MdcSegGrouper::nPly(), MdcSegInfo::par(), MdcSegInfo::parIsAngle(), MdcSeg::plotSegAll(), MdcSegGrouper::resetComb(), MdcSegGrouper::storePar(), MdcTrack::track(), and MdcSegGrouper::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 | ( | ) | [inherited] |
Definition at line 464 of file MdcSegGrouper.cxx.
References genRecEmupikp::i, and MdcSegGrouper::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 }
void MdcSegGrouperCsmc::fillWithSegs | ( | const MdcSegList * | inSegs | ) |
Definition at line 50 of file MdcSegGrouperCsmc.cxx.
References MdcSegGrouper::_gm, MdcSegInfoCsmc::calcStraight(), GmsList::first(), GmsListLink::next(), MdcDetector::nSuper(), MdcSegList::oneList(), MdcSegInfoCsmc::phi0(), phi0, MdcSegGrouper::segList, MdcSeg::setInfo(), MdcSeg::superlayer(), and MdcSuperLayer::whichView().
Referenced by MdcTrackListCsmc::createFromSegs().
00050 { 00051 //------------------------------------------------------------------------ 00052 // Prepare for axial finding 00053 // Store the segments (pointers, actually), sorting by phi0 00054 for (int isuper = 0; isuper < _gm->nSuper(); isuper++) { 00055 const GmsList *inList = inSegs->oneList(isuper); 00056 if (inList->count() == 0) continue; 00057 00058 MdcSeg *inSeg = (MdcSeg *) inList->first(); 00059 // Only load axial segments 00060 if (inSeg->superlayer()->whichView() != 0) continue; 00061 00062 while (inSeg != 0) { 00063 // Create an info object within the seg to store info 00064 MdcSegInfoCsmc *info = new MdcSegInfoCsmc; 00065 inSeg->setInfo(info); 00066 info->calcStraight(inSeg); // calc. origin-dependent info 00067 00068 // Loop over the segs already stored, looking for the right place 00069 // to stick the new one 00070 int isInserted = 0; 00071 for (int iseg = 0; iseg < (int) segList[isuper].length(); iseg++) { 00072 MdcSeg *aSeg = segList[isuper][iseg]; 00073 if ( ((MdcSegInfoCsmc *)aSeg->info())->phi0() < info->phi0()) 00074 continue; 00075 segList[isuper].insert(inSeg, iseg); 00076 isInserted = 1; 00077 break; 00078 } // end of loop over existing segs 00079 if (isInserted == 0) segList[isuper].append(inSeg); 00080 00081 inSeg = (MdcSeg *) inSeg->next(); 00082 } // end loop over new segs 00083 } // end loop over superlayers 00084 00085 }
int MdcSegGrouperCsmc::incompWithGroup | ( | MdcSeg ** | segGroup, | |
const MdcSeg * | testSeg, | |||
int | iply | |||
) | [virtual] |
Implements MdcSegGrouper.
Definition at line 124 of file MdcSegGrouperCsmc.cxx.
00125 { 00126 //------------------------------------------------------------------------- 00127 00128 return 0; 00129 }
Implements MdcSegGrouper.
Definition at line 89 of file MdcSegGrouperCsmc.cxx.
References MdcSegInfoCsmc::d0(), MdcSeg::info(), mdcWrapAng(), MdcSegInfoCsmc::phi0(), MdcSegInfoCsmc::sigD0(), and MdcSegInfoCsmc::sigPhi0().
Referenced by resetComb().
00090 { 00091 //------------------------------------------------------------------------- 00092 00093 return 0; 00094 // Returns 0 if valid, -1 if invalid, +1 if invalid and no more valid 00095 // ones possible in this slayer (assumes they're ordered) 00096 if (testSeg == 0) return 0; 00097 00098 // Test phi0 match 00099 MdcSegInfoCsmc *refInfo = (MdcSegInfoCsmc *) refSeg->info(); 00100 MdcSegInfoCsmc *testInfo = (MdcSegInfoCsmc *) testSeg->info(); 00101 double sigPhi0 = (refInfo->sigPhi0() > testInfo->sigPhi0() ? 00102 refInfo->sigPhi0() : testInfo->sigPhi0()); 00103 double refPhi0 = refInfo->phi0(); 00104 double testPhi0 = testInfo->phi0(); 00105 double corrPhi0 = mdcWrapAng(refPhi0, testPhi0); 00106 if (refPhi0 - corrPhi0 > 6. * sigPhi0) return -1; 00107 if (corrPhi0 - refPhi0 > 6. * sigPhi0) { 00108 if (testPhi0 > refPhi0) return 1; 00109 else return -1; // => testPhi0>2pi & refPhi0<2pi 00110 } 00111 00112 // Test d0 match 00113 // use larger error of the two 00114 double sigD0 = (refInfo->sigD0() > testInfo->sigD0() ? 00115 refInfo->sigD0() : testInfo->sigD0()); 00116 double refD0 = refInfo->d0(); 00117 double testD0 = testInfo->d0(); 00118 if (fabs(refD0 - testD0) > 6. * sigD0) return -2; 00119 00120 return 0; 00121 }
Definition at line 83 of file MdcSegGrouper.cxx.
References MdcSegGrouper::combList, MdcSegInfoSterO::ct(), MdcSegGrouper::currentSeg, MdcSegGrouper::firstBad, MdcSegGrouper::firstGood, MdcSegGrouper::incompWithGroup(), MdcSegGrouper::isValid, MdcSegGrouper::leaveGap, MdcSegGrouper::lTestGroup, MdcSegGrouper::lTestSingle, MdcSegGrouper::maxNull, MdcSegGrouper::nDeep, MdcSegGrouper::nNull, MdcSegGrouper::nPlyFilled, MdcSegGrouper::resetGap(), MdcSegGrouper::resetSegCounters(), and MdcSegGrouper::updateGap().
Referenced by MdcSegGrouper::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, inherited] |
Definition at line 54 of file MdcSegGrouper.h.
Referenced by MdcSegGrouper::combineSegs(), MdcSegGrouperAx::MdcSegGrouperAx(), MdcSegGrouperCsmc(), and MdcSegGrouperSt::MdcSegGrouperSt().
00054 {return nDeep;}
MdcSegGrouperCsmc& MdcSegGrouperCsmc::operator= | ( | const MdcSegGrouperCsmc & | ) | [private] |
virtual void MdcSegGrouper::resetComb | ( | const MdcSeg * | seed | ) | [pure virtual, inherited] |
void MdcSegGrouperCsmc::resetComb | ( | const class MdcSeg * | ) |
Definition at line 133 of file MdcSegGrouperCsmc.cxx.
References MdcSegGrouper::_gm, _seed, MdcSegGrouper::combList, MdcSegGrouper::firstBad, MdcSegGrouper::firstGood, MdcDetector::firstSlay(), genRecEmupikp::i, incompWithSeg(), MdcSegGrouper::isValid, ganga-rec::j, MdcSegGrouper::leaveGap, MdcSegGrouper::maxNull, MdcSegGrouper::nDeep, MdcSuperLayer::next(), MdcSegGrouper::nNull, MdcSegGrouper::nPlyFilled, MdcSegGrouper::resetSegCounters(), and MdcSegGrouper::segList.
00133 { 00134 //--------------------------------------------------------------------- 00135 00136 // Delete existing list of valid/invalid segs 00137 if (isValid != 0) { 00138 int i; 00139 for (i = 0; i < nDeep; i++) { 00140 delete [] isValid[i]; 00141 isValid[i] = 0; 00142 } 00143 } 00144 00145 _seed = seed; 00146 //Grab the seglist for each slayer 00147 int islay = 0; 00148 int iply = 0; 00149 nPlyFilled = 0; 00150 nNull = 0; 00151 const MdcSuperLayer *seedSlay = 0; 00152 if (seed != 0) seedSlay = seed->superlayer(); 00153 00154 // Set up all sorts of stuff for fast grouping of segs in nextGroup() 00155 for (const MdcSuperLayer *thisSlay = _gm->firstSlay(); thisSlay != 0; 00156 thisSlay = thisSlay->next()) { 00157 bool noGoodYet = true; 00158 islay++; 00159 00160 if (thisSlay == seedSlay) continue; 00161 if (thisSlay->whichView() != 0) continue; 00162 firstGood[iply] = 0; 00163 // Loop over the segs, marking start & end of valid region for this seed 00164 firstBad[iply] = 0; 00165 if (segList[islay-1].length() != 0) 00166 isValid[iply] = new bool[segList[islay-1].length()]; 00167 for (int i = 0; i < (int) segList[islay-1].length(); i++) { 00168 MdcSeg *aSeg = segList[islay-1][i]; 00169 int invalid = incompWithSeg(seed, aSeg); 00170 isValid[iply][i] = true; 00171 if (invalid < 0) { 00172 firstBad[iply] = i; 00173 isValid[iply][i] = false; 00174 if (noGoodYet) firstGood[iply] = i+1; 00175 } 00176 else if (invalid > 0) { 00177 // No more valid segs in this slayer 00178 firstBad[iply] = i; 00179 for (int j = i; j < (int) segList[islay-1].length(); j++) 00180 isValid[iply][j] = false; 00181 break; 00182 } 00183 else { 00184 firstBad[iply] = i+1; 00185 noGoodYet = false; 00186 } 00187 } 00188 // if (thisSlay->whichView() != 0) continue; 00189 // firstGood[iply] = 0; 00190 // // Loop over the segs, marking start & end of valid region 00191 // firstBad[iply] = 0; 00192 // firstBad[iply] = segList[islay-1].length(); 00193 00194 00195 if (firstGood[iply] > firstBad[iply]) firstGood[iply] = firstBad[iply]; 00196 if (firstGood[iply] == firstBad[iply]) { 00197 // If there are no valid segs for this ply, skip it 00198 continue; 00199 } 00200 // Associate correct seglist with this ply 00201 combList[iply] = &segList[islay-1]; 00202 leaveGap[iply] = false; 00203 iply++; 00204 } 00205 nPlyFilled = iply; 00206 resetSegCounters(); 00207 maxNull = nPlyFilled - 2; 00208 maxNull++; 00209 }
void MdcSegGrouper::resetGap | ( | int | nGap | ) | [inherited] |
Definition at line 214 of file MdcSegGrouper.cxx.
References MdcSegGrouper::gapCounter, genRecEmupikp::i, and MdcSegGrouper::nPlyFilled.
Referenced by MdcSegGrouper::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, inherited] |
Definition at line 262 of file MdcSegGrouper.cxx.
References MdcSegGrouper::currentSeg, MdcSegGrouper::firstGood, genRecEmupikp::i, and MdcSegGrouper::nPlyFilled.
Referenced by MdcSegGrouper::nextGroup(), MdcSegGrouperSt::resetComb(), resetComb(), and MdcSegGrouperAx::resetComb().
00262 { 00263 //------------------------------------------------------------------------- 00264 for (int i = 0; i < nPlyFilled; i++) { 00265 currentSeg[i] = firstGood[i] - 1; 00266 } 00267 }
MdcTrack * MdcSegGrouperCsmc::storePar | ( | MdcTrack * | trk, | |
double | parms[2], | |||
double | chisq, | |||
TrkContext & | , | |||
double | trackT0 | |||
) | [virtual] |
Implements MdcSegGrouper.
Definition at line 212 of file MdcSegGrouperCsmc.cxx.
References MdcSegGrouper::_gm, MdcDetector::nSuper(), and BesAngle::Rad().
00213 { 00214 //--------------------------------------------------------------------- 00215 assert(trk == 0); 00216 BesAngle foundPhi0(parms[1]); 00217 TrkExchangePar par(parms[0], foundPhi0.Rad(), 0., 0., 0.); 00218 return new MdcTrack(_gm->nSuper(), par, chi2, context, t0); 00219 }
Definition at line 408 of file MdcSegGrouper.cxx.
References MdcSegGrouper::_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 MdcSegGrouper::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 | ( | ) | [inherited] |
Definition at line 226 of file MdcSegGrouper.cxx.
References MdcSegGrouper::gapCounter, genRecEmupikp::i, ganga-rec::j, MdcSegGrouper::leaveGap, MdcSegGrouper::nNull, and MdcSegGrouper::nPlyFilled.
Referenced by MdcSegGrouper::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, inherited] |
Definition at line 96 of file MdcSegGrouper.h.
Referenced by MdcSegGrouper::calcParByHits(), MdcSegGrouper::calcParBySegs(), MdcSegGrouper::combineSegs(), MdcSegGrouperSt::fillWithSegs(), MdcSegGrouperAx::fillWithSegs(), MdcSegGrouperSt::incompWithGroup(), MdcSegGrouperAx::incompWithSeg(), MdcSegGrouper::MdcSegGrouper(), MdcSegGrouperAx::resetComb(), MdcSegGrouperSt::storePar(), and MdcSegGrouper::transferHits().
const MdcDetector* MdcSegGrouper::_gm [protected, inherited] |
Definition at line 78 of file MdcSegGrouper.h.
Referenced by MdcSegGrouperSt::fillWithSegs(), fillWithSegs(), MdcSegGrouperAx::fillWithSegs(), MdcSegGrouper::MdcSegGrouper(), MdcSegGrouperSt::plotStereo(), MdcSegGrouperSt::resetComb(), resetComb(), MdcSegGrouperAx::resetComb(), MdcSegGrouperSt::resetList(), storePar(), and MdcSegGrouperAx::storePar().
const MdcSeg* MdcSegGrouperCsmc::_seed [private] |
HepAList<MdcSeg>** MdcSegGrouper::combList [protected, inherited] |
Definition at line 77 of file MdcSegGrouper.h.
Referenced by MdcSegGrouperSt::incompWithGroup(), MdcSegGrouper::MdcSegGrouper(), MdcSegGrouper::nextGroup(), MdcSegGrouperSt::resetComb(), resetComb(), MdcSegGrouperAx::resetComb(), and MdcSegGrouper::~MdcSegGrouper().
int* MdcSegGrouper::currentSeg [protected, inherited] |
Definition at line 70 of file MdcSegGrouper.h.
Referenced by MdcSegGrouperSt::incompWithGroup(), MdcSegGrouper::MdcSegGrouper(), MdcSegGrouper::nextGroup(), MdcSegGrouper::resetSegCounters(), and MdcSegGrouper::~MdcSegGrouper().
int* MdcSegGrouper::firstBad [protected, inherited] |
Definition at line 72 of file MdcSegGrouper.h.
Referenced by MdcSegGrouper::MdcSegGrouper(), MdcSegGrouper::nextGroup(), MdcSegGrouperSt::resetComb(), resetComb(), MdcSegGrouperAx::resetComb(), and MdcSegGrouper::~MdcSegGrouper().
int* MdcSegGrouper::firstGood [protected, inherited] |
Definition at line 71 of file MdcSegGrouper.h.
Referenced by MdcSegGrouper::MdcSegGrouper(), MdcSegGrouper::nextGroup(), MdcSegGrouperSt::resetComb(), resetComb(), MdcSegGrouperAx::resetComb(), MdcSegGrouper::resetSegCounters(), and MdcSegGrouper::~MdcSegGrouper().
int* MdcSegGrouper::gapCounter [protected, inherited] |
Definition at line 91 of file MdcSegGrouper.h.
Referenced by MdcSegGrouper::MdcSegGrouper(), MdcSegGrouper::resetGap(), MdcSegGrouper::updateGap(), and MdcSegGrouper::~MdcSegGrouper().
bool** MdcSegGrouper::isValid [protected, inherited] |
Definition at line 73 of file MdcSegGrouper.h.
Referenced by MdcSegGrouperAx::MdcSegGrouperAx(), MdcSegGrouperCsmc(), MdcSegGrouperSt::MdcSegGrouperSt(), MdcSegGrouper::nextGroup(), MdcSegGrouperSt::resetComb(), resetComb(), MdcSegGrouperAx::resetComb(), and MdcSegGrouper::~MdcSegGrouper().
bool* MdcSegGrouper::leaveGap [protected, inherited] |
Definition at line 88 of file MdcSegGrouper.h.
Referenced by MdcSegGrouperSt::incompWithGroup(), MdcSegGrouper::MdcSegGrouper(), MdcSegGrouper::nextGroup(), MdcSegGrouperSt::resetComb(), resetComb(), MdcSegGrouperAx::resetComb(), MdcSegGrouper::updateGap(), and MdcSegGrouper::~MdcSegGrouper().
bool MdcSegGrouper::lTestGroup [protected, inherited] |
Definition at line 93 of file MdcSegGrouper.h.
Referenced by MdcSegGrouper::MdcSegGrouper(), MdcSegGrouperAx::MdcSegGrouperAx(), MdcSegGrouperCsmc(), MdcSegGrouperSt::MdcSegGrouperSt(), and MdcSegGrouper::nextGroup().
bool MdcSegGrouper::lTestSingle [protected, inherited] |
Definition at line 94 of file MdcSegGrouper.h.
Referenced by MdcSegGrouper::MdcSegGrouper(), MdcSegGrouperAx::MdcSegGrouperAx(), MdcSegGrouperCsmc(), MdcSegGrouperSt::MdcSegGrouperSt(), and MdcSegGrouper::nextGroup().
int MdcSegGrouper::maxNull [protected, inherited] |
Definition at line 90 of file MdcSegGrouper.h.
Referenced by MdcSegGrouper::nextGroup(), MdcSegGrouperSt::resetComb(), resetComb(), and MdcSegGrouperAx::resetComb().
int MdcSegGrouper::nDeep [protected, inherited] |
Definition at line 68 of file MdcSegGrouper.h.
Referenced by MdcSegGrouper::MdcSegGrouper(), MdcSegGrouper::nextGroup(), MdcSegGrouperSt::resetComb(), resetComb(), MdcSegGrouperAx::resetComb(), and MdcSegGrouper::~MdcSegGrouper().
int MdcSegGrouper::nNull [protected, inherited] |
Definition at line 89 of file MdcSegGrouper.h.
Referenced by MdcSegGrouper::nextGroup(), MdcSegGrouperSt::resetComb(), resetComb(), MdcSegGrouperAx::resetComb(), and MdcSegGrouper::updateGap().
int MdcSegGrouper::nPlyFilled [protected, inherited] |
Definition at line 69 of file MdcSegGrouper.h.
Referenced by MdcSegGrouper::nextGroup(), MdcSegGrouperSt::resetComb(), resetComb(), MdcSegGrouperAx::resetComb(), MdcSegGrouper::resetGap(), MdcSegGrouper::resetSegCounters(), and MdcSegGrouper::updateGap().
HepAList<MdcSeg>* MdcSegGrouper::segList [protected, inherited] |
Definition at line 79 of file MdcSegGrouper.h.
Referenced by MdcSegGrouper::dumpSegList(), MdcSegGrouperSt::fillWithSegs(), fillWithSegs(), MdcSegGrouperAx::fillWithSegs(), MdcSegGrouper::MdcSegGrouper(), MdcSegGrouperSt::plotStereo(), MdcSegGrouperSt::resetComb(), resetComb(), MdcSegGrouperAx::resetComb(), MdcSegGrouperSt::resetList(), and MdcSegGrouper::~MdcSegGrouper().