#include <MdcSegGrouperSt.h>
Inheritance diagram for MdcSegGrouperSt:
Public Member Functions | |
int | combineSegs (MdcTrack *&, MdcSeg *seed, TrkContext &, double trackT0, double maxSegChisqO) |
int | combineSegs (MdcTrack *&, MdcSeg *seed, TrkContext &, double trackT0, double maxSegChisqO) |
void | dumpSegList () |
void | dumpSegList () |
void | fillWithSegs (const MdcSegList *inSegs, const MdcTrack *axialTrack) |
void | fillWithSegs (const MdcSegList *inSegs, const MdcTrack *axialTrack) |
virtual int | incompWithGroup (MdcSeg **segGroup, const MdcSeg *testSeg, int iply) |
virtual int | incompWithGroup (MdcSeg **segGroup, const MdcSeg *testSeg, int iply) |
virtual int | incompWithSeg (const MdcSeg *refSeg, const MdcSeg *testSeg) |
virtual int | incompWithSeg (const MdcSeg *refSeg, const MdcSeg *testSeg) |
MdcSegGrouperSt (const MdcDetector *gm, int debug) | |
MdcSegGrouperSt (const MdcDetector *gm, int debug) | |
int | nextGroup (MdcSeg **segGroup, bool printit) |
int | nextGroup (MdcSeg **segGroup, bool printit) |
int | nPly () const |
int | nPly () const |
void | plotStereo () const |
void | plotStereo () const |
void | resetComb (const MdcSeg *seed=0) |
void | resetComb (const MdcSeg *seed=0) |
void | resetGap (int nGap) |
void | resetGap (int nGap) |
virtual MdcTrack * | storePar (MdcTrack *trk, double parms[2], double chisq, TrkContext &, double trackT0) |
virtual MdcTrack * | storePar (MdcTrack *trk, double parms[2], double chisq, TrkContext &, double trackT0) |
void | transferHits (MdcTrack *track, int nSegs, MdcSeg **segGroup) |
void | transferHits (MdcTrack *track, int nSegs, MdcSeg **segGroup) |
int | updateGap () |
int | updateGap () |
~MdcSegGrouperSt () | |
~MdcSegGrouperSt () | |
Protected Member Functions | |
void | resetSegCounters () |
void | resetSegCounters () |
Protected Attributes | |
int | _debug |
const MdcDetector * | _gm |
const MdcDetector * | _gm |
HepAList< MdcSeg > ** | combList |
HepAList< MdcSeg > ** | combList |
int * | currentSeg |
int * | currentSeg |
int * | firstBad |
int * | firstBad |
int * | firstGood |
int * | firstGood |
int * | gapCounter |
int * | gapCounter |
bool ** | isValid |
bool ** | isValid |
bool * | leaveGap |
bool * | leaveGap |
bool | lTestGroup |
bool | lTestSingle |
int | maxNull |
int | nDeep |
int | nNull |
int | nPlyFilled |
HepAList< MdcSeg > * | segList |
HepAList< MdcSeg > * | segList |
Private Member Functions | |
MdcSegGrouperSt & | operator= (const MdcSegGrouperSt &) |
MdcSegGrouperSt & | operator= (const MdcSegGrouperSt &) |
void | resetList () |
void | resetList () |
|
00045 : 00046 MdcSegGrouper(gm, gm->nStereoSuper(-1) + gm->nStereoSuper(1), debug) { 00047 //------------------------------------------------------------------------ 00048 00049 lTestGroup = true; 00050 lTestSingle = false; 00051 00052 isValid = new bool * [nPly()]; 00053 for (int j = 0; j < nPly(); j++) { 00054 isValid[j] = 0; 00055 } 00056 }
|
|
00033 { };
|
|
|
|
00033 { };
|
|
|
|
00248 { 00249 //************************************************************************/ 00250 // forms track from list of segs; does 2-param fit (either r-phi from origin 00251 // or s-z) and picks best combination. 00252 bool lSeed = (seed != 0); 00253 00254 double wgtmat[3], wgtinv[3]; 00255 double wgtpar[2]; 00256 double temvec[2], param[2], diff[2]; 00257 int success = 0; 00258 double qualBest = -1000.; 00259 int nSegBest = 0; 00260 int nHitBest = 0; 00261 double paramBest[2]; 00262 double chiBest = 9999.; 00263 int nToUse = nPly(); 00264 if (lSeed) nToUse++; // seed isn't included in the segs list 00265 MdcSeg **segGroup; 00266 MdcSeg **segGroupBest; 00267 segGroup = new MdcSeg * [nToUse]; 00268 segGroupBest = new MdcSeg * [nToUse]; 00269 // static int counter = 0; 00270 // counter++; 00271 // cout << counter << endl; 00272 00273 // Loop over all combinations of segs consistent with seed (including gaps) 00274 if ((3 == _debug)&&lSeed) { 00275 std::cout<<"seed segment: "<< std::endl; 00276 seed->plotSeg(); 00277 } 00278 resetComb(seed); 00279 00280 // Save seed params (if angles) for later use as reference angle in 00281 // mdcWrapAng (don't really have to test whether it's an angle, but I do) 00282 double seedAngle[2] = {0.,0.}; 00283 if (lSeed) { 00284 if (seed->info()->parIsAngle(0)) seedAngle[0] = seed->info()->par(0); 00285 if (seed->info()->parIsAngle(1)) seedAngle[1] = seed->info()->par(1); 00286 } 00287 00288 int iprint = (3 == _debug); 00289 int nInGroup = 0; 00290 while ( (nInGroup = nextGroup(segGroup, iprint)) != 0) { 00291 if (lSeed) { 00292 segGroup[nToUse-1] = seed; 00293 nInGroup++; 00294 } 00295 00296 if (nInGroup < 0) continue; 00297 if (nInGroup < 2) break; 00298 if (nInGroup < nSegBest) break; 00299 00300 // Calculate track & chisq for this group 00301 int nSegFit = 0; 00302 int nhit = 0; 00303 wgtmat[0] = wgtmat[1] = wgtmat[2] = wgtpar[0] = wgtpar[1] = 0.0; 00304 00305 if (3 == _debug) { 00306 cout << endl <<"--parameters of "<<nInGroup<<" segment in this group"<<endl; 00307 } 00308 int iPly; 00309 for (iPly = 0; iPly < nToUse; iPly++) { 00310 if (3 == _debug) { 00311 //if (!lSeed) //if (segGroup[iPly] == 0) cout << "ply empty: " << iPly << "\n"; 00312 } 00313 if (segGroup[iPly] == 0) continue; // skipping this slayer 00314 nSegFit++; 00315 MdcSegInfo *segInfo = segGroup[iPly]->info(); 00316 // Accumulate sums 00317 for (int i = 0; i < 3; i++) wgtmat[i] += (segInfo->inverr())[i]; 00318 for (int k = 0; k < 2; k++) { 00319 param[k] = segInfo->par(k); 00320 //zhangy add 00321 if (segInfo->parIsAngle(k)) { 00322 param[k] = mdcWrapAng(seedAngle[k], param[k]); 00323 } 00324 } 00325 // Multiply by weight matrix. 00326 mdcTwoVec( segInfo->inverr(), param, temvec ); 00327 wgtpar[0] += temvec[0]; 00328 wgtpar[1] += temvec[1]; 00329 if(3 == _debug) { 00330 std::cout<<" par * W "<<temvec[0]<<" "<<temvec[1]<< std::endl; 00331 } 00332 nhit += segGroup[iPly]->nHit(); 00333 } 00334 00335 // And the fitted parameters are . . . 00336 int error = mdcTwoInv(wgtmat,wgtinv); 00337 if (error && (3 == _debug)) { 00338 cout << "ErrMsg(warning) " 00339 << "failed matrix inversion in MdcTrackList::combineSegs" << endl; 00340 continue; 00341 } 00342 mdcTwoVec( wgtinv, wgtpar, param ); 00343 00344 if(_debug==3)cout<<endl<<"-- Calculate track & chisq for this group "<<endl; 00345 00346 // Calc. chisq. = sum( (Vi - V0) * W * (Vi - V0) ) 00347 // W = weight, Vi = measurement, V0 = fitted param. 00348 double chisq = 0.0; 00349 for (iPly = 0; iPly < nToUse; iPly++) { 00350 if (segGroup[iPly] == 0) continue; // skipping this slayer 00351 MdcSegInfo *segInfo = segGroup[iPly]->info(); 00352 for (int j = 0; j < 2; j++) { 00353 double temPar; 00354 if (segInfo->parIsAngle(j)) { 00355 temPar = mdcWrapAng(seedAngle[j], segInfo->par(j)); 00356 } 00357 else { 00358 temPar = segInfo->par(j); 00359 } 00360 if(3 == _debug) { 00361 std::cout<<" segPar"<<j<<" "<<temPar<< std::endl; 00362 } 00363 diff[j] = temPar - param[j]; 00364 } 00365 00366 if(3 == _debug) { 00367 std::cout<<"inverr " <<segInfo->inverr()[0]<<" " 00368 <<segInfo->inverr()[1] <<" "<<segInfo->inverr()[2] << std::endl; 00369 std::cout<<"errmat " <<segInfo->errmat()[0]<< " " 00370 <<segInfo->errmat()[1] << " "<<segInfo->errmat()[2] << std::endl; 00371 std::cout<< std::endl; 00372 } 00373 mdcTwoVec( segInfo->inverr(), diff, temvec); 00374 00375 chisq += diff[0] * temvec[0] + diff[1] * temvec[1]; 00376 00377 if(3 == _debug){ 00378 std::cout<<iPly<<" chi2Add:"<<diff[0] * temvec[0] + diff[1] * temvec[1]<<" diff0 "<<setw(10) << diff[0]<< " vec0 "<<setw(10)<<temvec[0]<<" diff1 "<<setw(10) 00379 << diff[1]<< " vec1 "<<setw(10)<<temvec[1] << std::endl; 00380 } 00381 } 00382 if (3 == _debug) { 00383 cout << "Candidate track:"<<endl<<" chisq: " 00384 << chisq << " nhit: " << nhit << " cpa/cot: " << 00385 param[0] << " phi0/z0: " << param[1] << endl; 00386 std::cout<< "chiDof="<<chisq/(2*nSegFit - 2) 00387 <<" maxSegChisqO="<<maxSegChisqO << std::endl;//yzhang debug 00388 if((chisq/(2*nSegFit - 2))<maxSegChisqO) cout << "---KEEP!---"<<endl; 00389 else cout << "---DROP!---"<<endl; 00390 } 00391 if (chisq < 0.) continue;//yzhang add 00392 // Chisq test 00393 double chiDof = chisq/(2.*nSegFit - 2.); 00394 if (g_maxSegChisqO ) { g_maxSegChisqO->fill(chiDof); } //yzhang hist cut 00395 if (chiDof > maxSegChisqO) continue; 00396 success = 1; 00397 double qual = 2. * nhit - chiDof; 00398 if (qual > qualBest) { 00399 qualBest = qual; 00400 nSegBest = nSegFit; 00401 nHitBest = nhit; 00402 paramBest[0] = param[0]; 00403 paramBest[1] = param[1]; 00404 chiBest = chisq; 00405 for (int i = 0; i < nToUse; i++) { 00406 segGroupBest[i] = segGroup[i]; 00407 //std::cout<<__FILE__<<" "<<__LINE__<<" Keep BEST"<< std::endl; 00408 } 00409 }// end test on qual 00410 } 00411 00412 if (success == 1) { 00413 // Store the results in a track, possibly creating it in the process 00414 trk = storePar(trk, paramBest, chiBest, context, t0); 00415 transferHits(trk, nToUse, segGroupBest); // Store hits with track 00416 } 00417 delete [] segGroupBest; 00418 delete [] segGroup; 00419 return success; 00420 }
|
|
|
|
00469 { 00470 //************************************************************************ 00471 for(int islayer=0; islayer<11; islayer++){ 00472 for(int i=0; i<segList[islayer].length(); i++){ 00473 segList[islayer][i]->plotSeg(); 00474 } 00475 } 00476 }
|
|
|
|
00070 { 00071 //------------------------------------------------------------------------ 00072 // Prepare for stereo finding 00073 // Load segments consistent with input track (already in phi order) 00074 // Assuming from origin 00075 int nsuper = _gm->nSuper(); 00076 resetList(); // Clear existing lists 00077 00078 const TrkFit* tkFit = track->track().fitResult(); 00079 if (tkFit == 0) return; 00080 TrkExchangePar par = tkFit->helix(0.0); 00081 double kap = 0.5 * par.omega(); 00082 double phi0 = par.phi0(); 00083 double d0 = par.d0(); 00084 MdcSegWorks segStuff; // holds some calculated values to pass to segInfo 00085 00086 bool lStraight = false; 00087 if (fabs(kap) < 1.e-9) { lStraight = true; } 00088 00089 double rCurl = 99999999.; 00090 if (!lStraight) { 00091 rCurl = fabs(d0 + 1./kap); 00092 } 00093 00094 // Create an info object to store the info (will be owned by seg) 00095 MdcSegInfoSterO *info = new MdcSegInfoSterO; 00096 00097 // Loop over superlayers 00098 for (int isuper = 0; isuper < nsuper; isuper++) { 00099 const GmsList *inList = inSegs->oneList(isuper); 00100 00101 if (inList->count() == 0) continue; 00102 00103 MdcSeg *inSeg = (MdcSeg *) inList->first(); 00104 // Only load stereo segments 00105 if (inSeg->superlayer()->whichView() == 0) continue; 00106 00107 // Calculate r & phi (approx) of axial track at slayer 00108 double radius = inSeg->superlayer()->rEnd(); 00109 if (radius >= rCurl) break; 00110 double phiArg = kap * radius; 00111 if (lStraight) phiArg = d0 / radius; 00112 if (phiArg < -1.0) phiArg = -1.0; 00113 else if (phiArg > 1.0) phiArg = 1.0; 00114 segStuff.phiArg = phiArg; 00115 segStuff.phiAx.setRad(phi0 + asin(phiArg)); // Approx??!!!! 00116 BesAngle delPhi( fabs(inSeg->superlayer()->delPhi()) ); 00117 BesAngle maxPhiA = segStuff.phiAx + delPhi + 0.05; // allow a little slop 00118 BesAngle minPhiA = segStuff.phiAx - delPhi - 0.05; 00119 double maxPhi = maxPhiA; 00120 double minPhi = minPhiA; 00121 bool phitest = (maxPhi > minPhi); 00122 //phitest = false => the valid range straddles phi = 0, so skip 00123 //checking against phimin and phimax 00124 00125 //Calc some things needed in segInfo::calcStereo 00126 segStuff.wirLen2inv = 1./ (inSeg->superlayer()->zEnd() * 00127 inSeg->superlayer()->zEnd() ); 00128 // Loop over segs in superlayer 00129 00130 for ( ; inSeg != 0; inSeg = (MdcSeg *) inSeg->next()) { 00131 // Test if within allowed phi range 00132 BesAngle phiSeg(inSeg->phi()); 00133 00134 if(_debug==3)inSeg->plotSeg(); 00135 if (phitest) { 00136 if (phiSeg < minPhi){ 00137 if (_debug ==3){std::cout << "St combine CUT! phi "<<setw(10)<<phiSeg 00138 << " < min "<<setw(10)<<minPhi << std::endl;}//yzhang debug 00139 continue; // not up to candidates 00140 } 00141 else if(phiSeg > maxPhi) { 00142 if (_debug ==3){std::cout << "St combine CUT! phi "<<setw(10)<<phiSeg 00143 <<" >max "<<setw(10)<<maxPhi<< std::endl;}//yzhang debug 00144 break; // past candidates 00145 } 00146 } else { // !phitest 00147 if (phiSeg > maxPhi && phiSeg < minPhi) { 00148 if (_debug ==3){std::cout << "!phitest "<<phiSeg 00149 <<" max "<<maxPhi<< " min "<<minPhi << std::endl;}//yzhang debug 00150 continue; 00151 } 00152 } 00153 00154 if(_debug == 3) std::cout<<" KEEP phi="<<phiSeg<< std::endl; 00155 00156 int isBad = info->calcStereo(inSeg, track->track(), segStuff); 00157 00158 if (isBad) { 00159 if (_debug ==3){std::cout << "St combine calcStereo isBad CUT!"<<std::endl;} 00160 continue; 00161 } 00162 if(_debug==3)inSeg->plotSeg(); 00163 // Test for sensible values of ct and z0 00164 if (g_z0Cut) {g_z0Cut->fill(info->z0());} 00165 if (g_ctCut) {g_ctCut->fill(info->ct());} 00166 if (fabs(info->ct()) > inSeg->segPar()->ctcut) { 00167 if (_debug ==3){std::cout << "St combine ctCut! CUT:" 00168 <<fabs(info->ct())<<" >cut "<< inSeg->segPar()->ctcut<<" "<<phiSeg<<std::endl; } 00169 continue; 00170 } 00171 if (fabs(info->z0()) > inSeg->segPar()->z0cut){ 00172 if (_debug ==3){std::cout << "St combine z0Cut! CUT:" 00173 <<fabs(info->z0())<<" >cut "<< inSeg->segPar()->z0cut<<" "<<phiSeg<<std::endl; } 00174 continue; 00175 } 00176 inSeg->setInfo(info); 00177 info = new MdcSegInfoSterO; 00178 segList[isuper].append(inSeg); 00179 if(_debug==3)std::cout<<__FILE__<<" APPEND"<< std::endl; 00180 00181 } // end loop over new segs 00182 } // end loop over superlayers 00183 delete info; 00184 }
|
|
Implements MdcSegGrouper. |
|
Implements MdcSegGrouper. 00225 { 00226 //------------------------------------------------------------------------- 00227 // Test that the latest seg lies more or less in a line with the others 00228 // Currently requiring line to point to IP; also require rough 00229 // agreement in ct. 00230 // iply = depth index of current seg (not yet in group) 00231 00232 int i; 00233 // Find first segment already in group 00234 for (i = iply - 1; i > 0; i--) { 00235 if (!leaveGap[i]) break; 00236 } 00237 const MdcSeg *first = (*combList[i])[currentSeg[i]]; 00238 00239 // Test ct 00240 MdcSegInfoSterO* firstInfo = (MdcSegInfoSterO *) first->info(); 00241 MdcSegInfoSterO* newInfo = (MdcSegInfoSterO *) testSeg->info(); 00242 00243 if (g_delCt) {g_delCt->fill( firstInfo->ct() - newInfo->ct());}//yzhang hist cut 00244 if (fabs( firstInfo->ct() - newInfo->ct() ) > 00245 testSeg->segPar()->delCtCut) { 00246 if(_debug==3){ 00247 cout << "---MdcSegGrouperSt Ct CUT!" << endl;//yzhang debug 00248 testSeg->plotSeg(); 00249 std::cout << "segInGroup.ct "<< firstInfo->ct() 00250 <<"new "<<newInfo->ct() 00251 << "delta ct "<<firstInfo->ct() - newInfo->ct() 00252 <<"Cut "<<testSeg->segPar()->delCtCut << std::endl;//yzhang debug 00253 00254 std::cout<<"--- "<< std::endl; 00255 } 00256 return -1; 00257 } 00258 00259 double arcFirst = firstInfo->arc(); 00260 double arcNew = newInfo->arc(); 00261 double zFirst = firstInfo->z0() + firstInfo->ct() * arcFirst; 00262 double zNew = newInfo->z0() + newInfo->ct() * arcNew; 00263 // project line from IP through 1st seg to new seg 00264 double zProj = zFirst / arcFirst * arcNew; 00265 if (g_delZ0) {g_delZ0->fill( zProj - zNew);}//yzhang hist cut 00266 00267 if (fabs(zProj - zNew) > testSeg->segPar()->delZ0Cut) { 00268 if(3==_debug){ 00269 cout << "MdcSegGrouperSt delZ0Cut not incompWithGroup CUT!" << endl;//yzhang debug 00270 testSeg->plotSeg(); 00271 std::cout<<" zProj "<< zProj << " zNew "<< zNew<< " CUT! " 00272 << testSeg->segPar()->delZ0Cut << std::endl; 00273 } 00274 return -1; 00275 } 00276 00277 /* 00278 double delZ = newInfo->z0() + newInfo->ct() * arcNew - zFirst; 00279 double z0 = zFirst - arcFirst * delZ / (arcNew - arcFirst); 00280 if (fabs(z0) > testSeg->segPar()->delZ0Cut)return -1; 00281 00282 for (i = iply - 1; i > 0; i--) { 00283 if (segGroup[i] != 0) break; 00284 } 00285 const MdcSeg *last = segGroup[i]; 00286 MdcSegInfoSterO* lastInfo = (MdcSegInfoSterO *) last->info(); 00287 00288 // Test that slope from last segment to new one is roughly = slope from 00289 // first seg to last 00290 double arcLast = lastInfo->arc(); 00291 double arcFirst = firstInfo->arc(); 00292 double arcNew = newInfo->arc(); 00293 00294 double delZold = lastInfo->z0() - firstInfo->z0() + 00295 lastInfo->ct() * arcLast - firstInfo->ct() * arcFirst; 00296 double delArcold = arcLast - arcFirst; 00297 double delZnew = newInfo->z0() - lastInfo->z0() + 00298 newInfo->ct() * arcNew - lastInfo->ct() * arcLast; 00299 double delArcnew = arcNew - arcLast; 00300 double p1 = delZold * delArcnew; 00301 double p2 = delZnew * delArcold; 00302 00303 cout << " test: " << p1 << " " << p2 << endl; 00304 00305 if (fabs(p2 - p1) > 0.02) return -1; 00306 00307 */ 00308 return 0; 00309 }
|
|
Implements MdcSegGrouper. |
|
Implements MdcSegGrouper. 00217 { 00218 //------------------------------------------------------------------------- 00219 00220 return 0; 00221 }
|
|
|
|
00079 { 00080 //------------------------------------------------------------------------ 00081 00082 // Loop over the superlayers, moving to next valid seg for each if necessary 00083 // First, loop over the slayers w/o good segs, filling segGroup w/ 0 00084 int iply; 00085 for (iply = nPlyFilled; iply < nDeep; iply++) { 00086 segGroup[iply] = 0; 00087 } 00088 00089 restart: 00090 if (printit) cout <<endl<< "MdcSegGrouper::nextGroup starting group finder, nply = " << nPlyFilled << endl; 00091 int nFound = 0; 00092 bool incrementNext = true; 00093 //int nSegUsed;//yzhang 2010-05-21 00094 for (iply = 0; iply < nPlyFilled; iply++) { 00095 segGroup[iply] = 0; 00096 if (!incrementNext && currentSeg[iply] >= firstGood[iply]) break; 00097 //if (nSegUsed > segPar.nSegUsedNextGroup) break; 00098 if (leaveGap[iply]) { 00099 // This ply is currently a gap; move on. 00100 if (iply == nPlyFilled - 1 && incrementNext) { 00101 // we've exhausted this gap group; start another 00102 iply = -1; 00103 resetSegCounters(); 00104 int lDone = updateGap(); 00105 if (lDone) { 00106 // all gap groups for nNull exhausted; increment nNull 00107 nNull++; 00108 if (nNull > maxNull) return 0; // All done 00109 resetGap(nNull); 00110 updateGap(); 00111 } // end if lDone 00112 } //end if exhausted gap group 00113 continue; 00114 } 00115 incrementNext = false; 00116 00117 // Loop through the segs in this ply until valid one found 00118 while (1) { 00119 currentSeg[iply]++; 00120 if (currentSeg[iply] == firstBad[iply]) { // reached end of segs 00121 incrementNext = true; 00122 currentSeg[iply] = firstGood[iply]; 00123 if (iply == nPlyFilled - 1) { 00124 // we've exhausted this gap group; start another 00125 iply = -1; 00126 resetSegCounters(); 00127 int lDone = updateGap(); 00128 if (lDone) { 00129 // all gap groups for nNull exhausted; increment nNull 00130 nNull++; 00131 if (nNull > maxNull) return 0; // All done 00132 resetGap(nNull); 00133 updateGap(); 00134 } // end if lDone 00135 } //end if exhausted gap group 00136 break; 00137 } // end reached end of segs 00138 if(3 == _debug) { 00139 if( (*combList[iply])[currentSeg[iply]]->segUsed()) { 00140 std::cout<< "segUsed! :"; 00141 (*combList[iply])[currentSeg[iply]]->plotSeg(); 00142 } 00143 } 00144 //yzhang 09-09-28 delete 00145 if( (*combList[iply])[currentSeg[iply]]->segUsed()) { 00146 continue; //yzhang 2010-05-21 add 00147 //nSegUsed++; 00148 } 00149 00150 // Test this seg for validity 00151 if (lTestSingle) { 00152 assert(isValid != 0); 00153 assert(isValid[iply] != 0); 00154 int invalid = (isValid[iply][currentSeg[iply]] == false); 00155 if (invalid) continue; 00156 } 00157 00158 // Whew. We successfully incremented. 00159 break; 00160 00161 } // end seg loop 00162 } // end ply loop 00163 00164 // Fill segGroup with appropriate segs 00165 for (iply = 0; iply < nPlyFilled; iply++) { 00166 if (leaveGap[iply]) { 00167 segGroup[iply] = 0; 00168 } else { 00169 segGroup[iply] = (*combList[iply])[currentSeg[iply]]; 00170 if (lTestGroup && nFound > 1) { 00171 int lBad = incompWithGroup(segGroup, segGroup[iply], iply); 00172 if(printit && lBad )std::cout<<" incompWithGroup Bad! restart" << std::endl; 00173 if (lBad) goto restart; 00174 } 00175 nFound++; 00176 } 00177 } 00178 if (printit) { 00179 cout << "-- end of nextGroup, nSeg="<<nFound <<endl; 00180 for (iply = 0; iply < nPlyFilled; iply++) { 00181 std::cout<<iply<<": "; 00182 if(0 != segGroup[iply]) segGroup[iply]->plotSeg(); 00183 } 00184 } 00185 00186 return nFound; 00187 }
|
|
00054 {return nDeep;}
|
|
00054 {return nDeep;}
|
|
|
|
|
|
|
|
00187 { 00188 //------------------------------------------------------------------------- 00189 int nsuper = _gm->nSuper(); 00190 int isuper; 00191 /* 00192 for (isuper = 0; isuper < nsuper; isuper++) { 00193 if (segList[isuper].length() == 0) continue; 00194 00195 MdcSeg *inSeg = (MdcSeg *) segList[isuper].first(); 00196 // Only draw stereo segments 00197 if (inSeg->superlayer()->whichView() == 0) continue; 00198 for (int j = 0 ; j < (int) segList[isuper].length(); j++) { 00199 segList[isuper][j]->plotSeg(0,orange); 00200 } 00201 } 00202 */ 00203 for (isuper = 0; isuper < nsuper; isuper++) { 00204 if (segList[isuper].length() == 0) continue; 00205 00206 MdcSeg *inSeg = (MdcSeg *) segList[isuper].first(); 00207 // Only draw stereo segments 00208 //if (inSeg->superlayer()->whichView() == 0) continue; 00209 for (int j = 0 ; j < (int) segList[isuper].length(); j++) { 00210 segList[isuper][j]->plotSeg(); 00211 } 00212 } 00213 00214 }
|
|
Implements MdcSegGrouper. |
|
Implements MdcSegGrouper. 00312 { 00313 //************************************************************************** 00314 00315 // Delete existing list of valid/invalid segs 00316 if (isValid != 0) { 00317 int i; 00318 for (i = 0; i < nDeep; i++) { 00319 delete [] isValid[i]; 00320 isValid[i] = 0; 00321 } 00322 } 00323 00324 //Grab the seglist for each slayer 00325 int islay = 0; 00326 int iply = 0; 00327 nPlyFilled = 0; 00328 nNull = 0; 00329 00330 00331 // Set up all sorts of stuff for fast grouping of segs in nextGroup() 00332 for (const MdcSuperLayer *thisSlay = _gm->firstSlay(); thisSlay != 0; 00333 thisSlay = thisSlay->next()) { 00334 //bool noGoodYet = true; 00335 islay++; 00336 if (thisSlay->whichView() == 0) continue; 00337 firstGood[iply] = 0; 00338 firstBad[iply] = segList[islay-1].length(); 00339 if (firstGood[iply] > firstBad[iply]) firstGood[iply] = firstBad[iply]; 00340 if (firstGood[iply] == firstBad[iply]) { 00341 // If there are no valid segs for this ply, skip it 00342 continue; 00343 } 00344 // Associate correct seglist with this ply 00345 combList[iply] = &segList[islay-1]; 00346 leaveGap[iply] = false; 00347 iply++; 00348 } 00349 00350 nPlyFilled = iply; 00351 resetSegCounters(); 00352 maxNull = nPlyFilled - 2; 00353 }
|
|
|
|
00190 { 00191 //************************************************************************** 00192 00193 for (int i = 0; i < nPlyFilled; i++) { 00194 gapCounter[i] = nGap - 1 - i; 00195 } 00196 gapCounter[0]--; // so 1st increment will put 1st counter in right place 00197 00198 return; 00199 }
|
|
|
|
00059 { 00060 //------------------------------------------------------------------------ 00061 // Clear existing lists for stereo finding 00062 int nsuper = _gm->nSuper(); 00063 for (int i = 0; i < nsuper; i++) { 00064 segList[i].removeAll(); 00065 } 00066 }
|
|
|
|
00238 { 00239 //------------------------------------------------------------------------- 00240 for (int i = 0; i < nPlyFilled; i++) { 00241 currentSeg[i] = firstGood[i] - 1; 00242 } 00243 }
|
|
Implements MdcSegGrouper. |
|
Implements MdcSegGrouper. 00358 { 00359 //--------------------------------------------------------------------- 00360 assert (trk != 0); 00361 TrkHelixMaker maker; 00362 maker.addZValues(trk->track(), parms[0], parms[1], chisq); 00363 return trk; 00364 }
|
|
|
|
00423 { 00424 //************************************************************************/ 00425 //Move hits from segments to track hitlist 00426 // Also note first and last layers in list 00427 // Only handles Mdc segments 00428 double smallRad = 1000.; 00429 if (trk->firstLayer() != 0) smallRad = trk->firstLayer()->rMid(); 00430 double bigRad = 0.; 00431 if (trk->lastLayer() != 0) bigRad = trk->lastLayer()->rMid(); 00432 00433 for (int i = 0; i < nSegs; i++) { 00434 if (segGroup[i] == 0) continue; // skipping this slayer 00435 if(3 == _debug) { 00436 cout << i << " " << segGroup[i] << endl; 00437 } 00438 segGroup[i]->setUsed(); // mark seg as used 00439 for (int ihit = 0; ihit < segGroup[i]->nHit(); ihit++) { 00440 MdcHitUse *aHit = segGroup[i]->hit(ihit); 00441 const MdcLayer *layer = aHit->mdcHit()->layer(); 00442 double radius = layer->rMid(); 00443 if (radius < smallRad) { 00444 smallRad = radius; 00445 trk->setFirstLayer(layer); 00446 } 00447 00448 // Assume that segs aren't added to backside of curler 00449 if (radius > bigRad && !trk->hasCurled()) { 00450 bigRad = radius; 00451 trk->setLastLayer(layer); 00452 } 00453 // Provide very crude starting guess of flightlength 00454 double flt = radius; 00455 flt += 0.000001 * (aHit->mdcHit()->x() +aHit->mdcHit()->y()); 00456 00457 aHit->setFltLen(flt); 00458 00459 TrkHitList* theHits = trk->track().hits(); 00460 00461 if (theHits == 0) return; 00462 theHits->appendHit(*aHit); 00463 //std::cout<<"in MdcSegGrouper append ok"<<std::endl;//yzhang debug 00464 } 00465 } // end loop over slayers 00466 }
|
|
|
|
00202 { 00203 //************************************************************************** 00204 if (nNull == 0) return 1; 00205 00206 for (int i = 0; i < nPlyFilled; i++) { 00207 leaveGap[i] = false; 00208 } 00209 for (int igap = 0; igap < nNull; igap++) { 00210 gapCounter[igap]++; 00211 if (gapCounter[igap] == nPlyFilled - igap) { 00212 // End of loop for this counter; look at the other counters to 00213 // decide where this one should be reset to. 00214 int inext = igap + 1; 00215 while (1) { 00216 if (inext >= nNull) return 1; // done with all combos 00217 if (gapCounter[inext] + inext + 1 < nPlyFilled) { 00218 // This is the right spot to reset to 00219 gapCounter[igap] = gapCounter[inext] + inext + 1 - igap; 00220 break; 00221 } 00222 inext++; 00223 } 00224 } 00225 else { 00226 // We successfully incremented. Quit looping and return. 00227 break; 00228 } 00229 } // end loop over igap 00230 00231 for (int j = 0; j < nNull; j++) { 00232 leaveGap[gapCounter[j]] = true; 00233 } 00234 return 0; 00235 00236 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|