#include <MdcSegGrouperAx.h>
Inheritance diagram for MdcSegGrouperAx:
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) |
void | fillWithSegs (const MdcSegList *inSegs) |
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) |
MdcSegGrouperAx (const MdcDetector *gm, int debug) | |
MdcSegGrouperAx (const MdcDetector *gm, int debug) | |
int | nextGroup (MdcSeg **segGroup, bool printit) |
int | nextGroup (MdcSeg **segGroup, bool printit) |
int | nPly () const |
int | nPly () const |
void | resetComb (const MdcSeg *seed) |
void | resetComb (const MdcSeg *seed) |
void | resetGap (int nGap) |
void | resetGap (int nGap) |
virtual MdcTrack * | storePar (MdcTrack *, double parms[2], double chisq, TrkContext &, double trackT0) |
virtual MdcTrack * | storePar (MdcTrack *, 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 () |
~MdcSegGrouperAx () | |
~MdcSegGrouperAx () | |
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 | |
MdcSegGrouperAx & | operator= (const MdcSegGrouperAx &) |
MdcSegGrouperAx & | operator= (const MdcSegGrouperAx &) |
Private Attributes | |
const MdcSeg * | _seed |
const MdcSeg * | _seed |
|
00051 : 00052 MdcSegGrouper(gm, gm->nAxialSuper() - 1, debug) { 00053 //------------------------------------------------------------------------ 00054 lTestGroup = false; 00055 lTestSingle = true; 00056 00057 isValid = new bool * [nPly()]; 00058 for (int j = 0; j < nPly(); j++) { 00059 isValid[j] = 0; 00060 } 00061 }
|
|
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 }
|
|
|
|
00064 { 00065 //------------------------------------------------------------------------ 00066 // Prepare for axial finding 00067 // Store the segments (pointers, actually), sorting by phi0 00068 for (int isuper = 0; isuper < _gm->nSuper(); isuper++) { 00069 const GmsList *inList = inSegs->oneList(isuper); 00070 if (inList->count() == 0) continue; 00071 MdcSeg *inSeg = (MdcSeg *) inList->first(); 00072 // Only load axial segments 00073 if (inSeg->superlayer()->whichView() != 0) continue; 00074 00075 while (inSeg != 0) { 00076 // Create an info object within the seg to store info 00077 MdcSegInfoAxialO *info = new MdcSegInfoAxialO; 00078 inSeg->setInfo(info); 00079 info->calcFromOrigin(inSeg); // calc. origin-dependent info 00080 00081 // Loop over the segs already stored, looking for the right place 00082 // to stick the new one 00083 int isInserted = 0; 00084 for (int iseg = 0; iseg < (int) segList[isuper].length(); iseg++) { 00085 MdcSeg *aSeg = segList[isuper][iseg]; 00086 if ( ((MdcSegInfoAxialO *)aSeg->info())->phi0() < info->phi0()) { 00087 continue; } 00088 segList[isuper].insert(inSeg, iseg); 00089 isInserted = 1; 00090 break; 00091 } // end of loop over existing segs 00092 if (isInserted == 0) segList[isuper].append(inSeg); 00093 inSeg = (MdcSeg *) inSeg->next(); 00094 } // end loop over new segs 00095 // cout<<"segList["<<isuper<<"].length"<< segList[isuper].length()<<endl;//yzhang debug 00096 } // end loop over superlayers 00097 00099 /* for(int isuper = 0; isuper < _gm->nSuper(); isuper++) { 00100 std::cout<<"-------super layer "<<isuper<<std::endl; 00101 for (int iseg = 0; iseg < (int) segList[isuper].length(); iseg++) { 00102 MdcSeg *aSeg = segList[isuper][iseg]; 00103 std::cout << " seg phi "<<iseg<< " "<<((MdcSegInfoAxialO*)aSeg->info())->phi0()<<std::endl; 00104 } // end of loop over existing segs 00105 } 00106 00107 */ 00108 00109 }
|
|
Implements MdcSegGrouper. |
|
Implements MdcSegGrouper. 00203 { 00204 //------------------------------------------------------------------------- 00205 00206 return 0; 00207 }
|
|
Implements MdcSegGrouper. |
|
Implements MdcSegGrouper. 00113 { 00114 //------------------------------------------------------------------------- 00115 00116 // Returns 0 if valid, -1 if invalid, +1 if invalid and no more valid 00117 // ones possible in this slayer (assumes they're ordered) 00118 if (testSeg == 0) return 0; 00119 if(3 == _debug) { 00120 std::cout<< "ref" << std::endl;//yzhang debug 00121 refSeg->plotSeg(); 00122 std::cout<< "testSeg " << std::endl;//yzhang debug 00123 testSeg->plotSeg(); 00124 00125 } 00126 // Test phi0 match 00127 MdcSegInfoAxialO *refInfo = (MdcSegInfoAxialO *) refSeg->info(); 00128 MdcSegInfoAxialO *testInfo = (MdcSegInfoAxialO *) testSeg->info(); 00129 00130 00131 //double sigPhi0 = (refInfo->sigPhi0() > testInfo->sigPhi0() ? 00132 //refInfo->sigPhi0() : testInfo->sigPhi0()); 00133 double refPhi0 = refInfo->phi0(); 00134 double testPhi0 = testInfo->phi0(); 00135 double corrPhi0 = mdcWrapAng(refPhi0, testPhi0); 00136 00137 //double sigCurv = (refInfo->sigCurv() > testInfo->sigCurv() ? 00138 //refInfo->sigCurv() : testInfo->sigCurv()); 00139 double refCurv = refInfo->curv(); 00140 double testCurv = testInfo->curv(); 00141 //double nSigmaPhi0 = MdcTrkReconCut_combAxPhi0;//4. for default 00142 //double nSigmaCurv = MdcTrkReconCut_combAxCurv;//4. for default 00143 double phi0Cut = MdcTrkReconCut_combAxPhi0Cut; 00144 double curvCut = MdcTrkReconCut_combAxCurvCut; 00145 //std::cout << "test phi0 "<<corrPhi0<<" ref "<<refPhi0<<" sig "<< nSigmaPhi0 * sigPhi0 << std::endl; 00146 //std::cout << "test Curv "<<testCurv<<" ref "<<refCurv<<" sig "<< nSigmaCurv * sigCurv << std::endl; 00147 /* 00148 if (g_tupleCombAx) { 00149 g_combAxdPhi0 = refPhi0 - corrPhi0; 00150 g_combAxdCurv = refCurv - testCurv; 00151 g_combAxSigPhi0 = sigPhi0; 00152 g_combAxSigCurv = sigCurv; 00153 g_combAxSlSeed = refSeg->superlayer()->slayNum();; 00154 g_combAxSlTest = testSeg->superlayer()->slayNum(); 00155 g_combAxQualitySeed = refSeg->quality(); 00156 g_combAxQualityTest = testSeg->quality(); 00157 //const MdcHit* h = refSeg->hit(0)->mdcHit(); 00158 //unsigned int l = h->layernumber(); 00159 //unsigned int w = h->wirenumber(); 00160 00161 //g_combAxMcPt = mcPt[havedigi[l][w]]; 00162 //test if the combined segments in the same track 00163 // return -1:seed false 00164 // return value = n hits on the seed track/ n hits of test seg 00165 g_combAxMc = refSeg->testCombSeg(testSeg); 00166 //std::cout<< "mc seg "<< refSeg->testCombSeg(testSeg) << std::endl;//yzhang debug 00167 g_tupleCombAx->write(); 00168 } 00169 */ 00170 //yzhang add 2009-10-16 00171 //if (refPhi0 - corrPhi0 > nSigmaPhi0 * sigPhi0) 00172 if(3 == _debug){ 00173 std::cout << " phi0 ref"<<refPhi0 00174 <<" corr "<<corrPhi0 00175 << " diff "<<fabs(corrPhi0-refPhi0) 00176 <<" >? "<<phi0Cut<<std::endl; 00177 std::cout << " curv ref"<<refCurv 00178 <<" test "<<testCurv<< " diff "<<refCurv-testCurv 00179 <<" >? "<<curvCut<< std::endl; 00180 } 00181 00182 if (fabs(corrPhi0 - refPhi0) > phi0Cut) { 00183 if(3 == _debug) std::cout << " SKIP by phi0"<<std::endl; 00184 //yzhang delete 00185 //if (testPhi0 > refPhi0) return 1; 00186 //else 00187 return -1; // => testPhi0>2pi & refPhi0<2pi 00188 } 00189 00190 // Test curvature match 00191 // use larger error of the two 00192 //if (fabs(refCurv - testCurv) > nSigmaCurv * sigCurv) 00193 if (fabs(refCurv - testCurv) > curvCut){ 00194 if(3 == _debug) std::cout << " SKIP by curv"<<std::endl; 00195 return -2; 00196 } 00197 if(3 == _debug) std::cout << " ADD "<<std::endl; 00198 //std::cout<< "ok! " << std::endl;//yzhang debug 00199 return 0; 00200 }
|
|
|
|
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;}
|
|
|
|
|
|
Implements MdcSegGrouper. |
|
Implements MdcSegGrouper. 00210 { 00211 //------------------------------------------------------------------------- 00212 00213 // Delete existing list of valid/invalid segs 00214 if (isValid != 0) { 00215 int i; 00216 for (i = 0; i < nDeep; i++) { 00217 delete [] isValid[i]; 00218 isValid[i] = 0; 00219 } 00220 } 00221 00222 _seed = seed; 00223 //Grab the seglist for each non-seed slayer 00224 int islay = 0; 00225 int iply = 0; 00226 nPlyFilled = 0; 00227 nNull = 0; 00228 const MdcSuperLayer *seedSlay = 0; 00229 if (seed != 0) seedSlay = seed->superlayer(); 00230 00231 00232 // Set up all sorts of stuff for fast grouping of segs in nextGroup() 00233 for (const MdcSuperLayer *thisSlay = _gm->firstSlay(); thisSlay != 0; 00234 thisSlay = thisSlay->next()) { 00235 bool noGoodYet = true; 00236 islay++; 00237 00238 if (thisSlay == seedSlay) continue; 00239 if (thisSlay->whichView() != 0) continue;//Axial slayer 00240 firstGood[iply] = 0; 00241 00242 // Loop over the segs, marking start & end of valid region for this seed 00243 firstBad[iply] = 0; 00244 if (segList[islay-1].length() != 0) { 00245 isValid[iply] = new bool[segList[islay-1].length()]; 00246 } 00247 for (int i = 0; i < (int) segList[islay-1].length(); i++) { 00248 MdcSeg *aSeg = segList[islay-1][i]; 00249 int invalid = incompWithSeg(seed, aSeg); 00250 isValid[iply][i] = true; 00251 if (invalid < 0) { 00252 firstBad[iply] = i; 00253 isValid[iply][i] = false; 00254 if (noGoodYet) firstGood[iply] = i+1; 00255 } else if (invalid > 0) { 00256 // No more valid segs in this slayer 00257 firstBad[iply] = i; 00258 for (int j = i; j < (int) segList[islay-1].length(); j++) 00259 isValid[iply][j] = false; 00260 break; 00261 } else { 00262 firstBad[iply] = i+1; 00263 noGoodYet = false; 00264 } 00265 } 00266 00267 if(3 == _debug) std::cout<<iply<<" islay "<<islay<<" firstGood "<<firstGood[iply]<<" "<<firstBad[iply]<< std::endl; 00268 if (firstGood[iply] > firstBad[iply]) firstGood[iply] = firstBad[iply]; 00269 if (firstGood[iply] == firstBad[iply]) { 00270 // If there are no valid segs for this ply, drop it 00271 delete [] isValid[iply]; 00272 isValid[iply] = 0; 00273 continue; 00274 } 00275 // Associate correct seglist with this ply 00276 combList[iply] = &segList[islay-1]; 00277 leaveGap[iply] = false; 00278 iply++; 00279 } 00280 nPlyFilled = iply; 00281 resetSegCounters(); 00282 maxNull = nPlyFilled - 2; 00283 maxNull++; 00284 }
|
|
|
|
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 }
|
|
|
|
00238 { 00239 //------------------------------------------------------------------------- 00240 for (int i = 0; i < nPlyFilled; i++) { 00241 currentSeg[i] = firstGood[i] - 1; 00242 } 00243 }
|
|
Implements MdcSegGrouper. |
|
Implements MdcSegGrouper. 00288 { 00289 //--------------------------------------------------------------------- 00290 // cout << "storePar in MdcSegGrouperAx" <<endl;//yzhang debug 00291 assert(trk == 0); 00292 BesAngle foundPhi0(parms[0]); 00293 // factor of two to convert to BaBar def of curvature (omega) 00294 TrkExchangePar par(0.0, foundPhi0.rad(), 2.*parms[1], 0.0, 0.0); 00295 return new MdcTrack(_gm->nSuper(), par, chisq, context, t0); 00296 }
|
|
|
|
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 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|