#include <MdcSegList.h>
Public Member Functions | |
void | append (MdcSeg *aSeg) |
void | append (MdcSeg *aSeg) |
int | count () const |
int | count () const |
void | destroySegs () |
void | destroySegs () |
MdcSeg * | getSeed (int iview, int goodOnly) |
MdcSeg * | getSeed (int iview, int goodOnly) |
MdcSegList (int nSupers, const MdcSegParams segParms) | |
MdcSegList (int nSupers, const MdcSegParams segParms) | |
const GmsList * | oneList (int slayIndex) const |
const GmsList * | oneList (int slayIndex) const |
void | plot () const |
void | plot () const |
void | resetSeed (const MdcDetector *gm) |
void | resetSeed (const MdcDetector *gm) |
MdcSegParams * | segPar () |
MdcSegParams * | segPar () |
void | setPlot (int lPlt) |
void | setPlot (int lPlt) |
~MdcSegList () | |
~MdcSegList () | |
Private Member Functions | |
void | deleteDups (bool drop) |
void | deleteDups (bool drop) |
void | massageSegs () |
void | massageSegs () |
void | sortByPhi () |
void | sortByPhi () |
void | tagAmbig () |
void | tagAmbig () |
void | zeroSeed () |
void | zeroSeed () |
Private Attributes | |
int | _nsupers |
MdcSeg * | seedSeg [3] |
MdcSeg * | seedSeg [3] |
const MdcSuperLayer * | seedSlay [3] |
const MdcSuperLayer * | seedSlay [3] |
GmsList * | segList |
GmsList * | segList |
MdcSegParams | segParam |
Friends | |
class | MdcSegFinder |
|
00035 { 00036 /**************************************************************************/ 00037 segParam = segP; // bit-wise copy 00038 MdcSeg::setParam(&segParam); 00039 zeroSeed(); 00040 segList = new GmsList[nSlayer]; 00041 _nsupers = nSlayer; 00042 }
|
|
00045 { 00046 /**************************************************************************/ 00047 delete [] segList; 00048 }
|
|
|
|
|
|
|
|
00250 { 00251 /****************************************************************************/ 00252 segList[aSeg->superlayer()->index()].append(aSeg); 00253 }
|
|
|
|
00395 { 00396 //------------------------------------------------------------------------- 00397 int cnt = 0; 00398 for (int i = 0; i < _nsupers; i++) cnt += segList[i].count(); 00399 return cnt; 00400 }
|
|
|
|
00264 { 00265 /****************************************************************************/ 00266 // Removes segments that have almost identical parameters. A bit risky, 00267 // perhaps, but what kind of life would you have if you never took 00268 // any risks? 00269 00270 // On second thought, offer the option of just marking them as used. 00271 00272 // Takes pairs of segments, and if they have the same slope and phi 00273 // (within cuts), selects better, using nHit and chisq. Note that 2 00274 // identical segs may be separated in list by non-identical 00275 00276 for (int isuper = 0; isuper < _nsupers; isuper++) { 00277 GmsList *thisSegList = &segList[isuper]; 00278 if (thisSegList->count() < 2) continue; 00279 00280 double thisphi, nextphi; 00281 double slopediff = segPar()->slopeDiffDrop; //FIXME 00282 00283 // Calculate road width for this slayer. 00284 const MdcLayer *aLayer = 00285 ((MdcSeg *)thisSegList->first())->superlayer()->firstLayer(); 00286 double width = _twopi / aLayer->nWires(); 00287 double phidiff = segPar()->phiDiffDropMult * width; //FIXME 00288 00289 int lWrapped = 0; 00290 00291 MdcSeg *startSeg = (MdcSeg *) thisSegList->first(); 00292 while ( startSeg != 0 ) { 00293 if (thisSegList->count() < 2) break; 00294 if (lWrapped) break; 00295 thisphi = startSeg->phi(); 00296 MdcSeg *nextSeg = startSeg; 00297 00298 while (1) { // loop over nextSeg 00299 nextSeg = (MdcSeg *) nextSeg->next(); 00300 if (nextSeg == 0) { 00301 nextSeg = (MdcSeg *) thisSegList->first(); 00302 if (lWrapped == 1) break; // cluster covers 2pi; run, screaming 00303 lWrapped = 1; 00304 } 00305 nextphi = nextSeg->phi(); 00306 00307 if (nextphi < thisphi) nextphi += _twopi; 00308 00309 if(5 == segPar()->lPrint){ 00310 std::cout<<__FILE__<<" "<<__LINE__<<" start "<< std::endl; 00311 startSeg->plotSeg(); 00312 std::cout<<__FILE__<<" "<<__LINE__<<" next "<< std::endl; 00313 nextSeg->plotSeg(); 00314 std::cout<<__FILE__<<" phi diff "<< nextphi -thisphi 00315 << " phidiff "<<phidiff<< std::endl; 00316 std::cout<<__FILE__<<" slope diff "<< nextSeg->slope() - startSeg->slope() 00317 << " slopdiff "<<slopediff<< std::endl; 00318 } 00319 00320 if (g_phiDiff) {g_phiDiff->fill((nextphi - thisphi)/width);}//yzhang hist cut 00321 if (g_slopeDiff) {g_slopeDiff->fill(nextSeg->slope() - startSeg->slope());}//yzhang hist cut 00322 00323 if (nextphi - thisphi > phidiff) { 00324 // Done with this segment (aSeg) 00325 startSeg = (MdcSeg *) startSeg->next(); 00326 break; 00327 } 00328 else if (fabs( nextSeg->slope() - startSeg->slope() ) > slopediff) { 00329 // attached, but not identical -- move on to next nextSeg 00330 continue; 00331 } 00332 else { 00333 // identical; choose better 00334 int firstBetter = 0; 00335 assert (startSeg->nHit() > 2); 00336 double chiFirst = startSeg->chisq() / (startSeg->nHit() - 2); 00337 assert (nextSeg->nHit() > 2); 00338 double chiNext = nextSeg->chisq() / (nextSeg->nHit() - 2); 00339 double theDiff; 00340 int cdiff = (int) nextSeg->nHit() - (int) startSeg->nHit(); 00341 theDiff = (chiFirst - chiNext) + 00342 2. * (cdiff); 00343 if (theDiff < 0.) firstBetter = 1; 00344 00345 if (firstBetter) { 00346 MdcSeg *tempSeg = nextSeg; 00347 nextSeg = (MdcSeg *) nextSeg->next(); 00348 if (ldrop) { 00349 thisSegList->remove(tempSeg); 00350 delete tempSeg; 00351 } 00352 else { 00353 tempSeg->setUsed(); 00354 } 00355 if (nextSeg == 0) { 00356 nextSeg = (MdcSeg *) thisSegList->first(); 00357 if (lWrapped == 1) break; // cluster covers 2pi; run, screaming 00358 lWrapped = 1; 00359 } 00360 } 00361 else { 00362 MdcSeg *tempSeg = startSeg; 00363 startSeg = (MdcSeg *) startSeg->next(); 00364 if (ldrop) { 00365 thisSegList->remove(tempSeg); 00366 delete tempSeg; 00367 } 00368 else { 00369 tempSeg->setUsed(); 00370 } 00371 break; 00372 } 00373 00374 } // end if identical 00375 } // end loop over nextSeg 00376 00377 } // end primary loop over segments 00378 } // end loop over superlayers 00379 }
|
|
|
|
00092 { 00093 /****************************************************************************/ 00094 00095 zeroSeed(); 00096 MdcSeg *aSeg, *bSeg; 00097 for (int i = 0; i < _nsupers; i++) { 00098 aSeg = (MdcSeg *) segList[i].first(); 00099 while (aSeg != 0) { 00100 bSeg = (MdcSeg *) aSeg->next(); 00101 segList[i].remove( aSeg ); 00102 delete aSeg ; 00103 aSeg = bSeg; 00104 } 00105 } 00106 return; 00107 }
|
|
|
|
00139 { 00140 //*************************************************************************** 00141 00142 // Find a suitable segment for starting a track. If goodOnly=1, look for 00143 // isolated, unambiguous segments; unambiguous is 00144 // defined as being the only segment within a band in phiseg (typically 00145 // 2 cell widths wide), or as differing only slightly from nearby 00146 // segments in phi and slope. When these have been exhausted, take any 00147 // unused segment. Return pointer to seed seg, or 0 if none found. 00148 00149 int viewIndex = iview + 1; 00150 if (seedSlay[viewIndex] == 0) return 0; 00151 while (1) { 00152 //if(seedSeg[viewIndex] != 0){ 00153 //seedSeg[viewIndex]->plotSeg(0,0);//yzhang debug 00154 //std::cout<<__FILE__<<" "<<__LINE__<<" goodOnly "<<goodOnly<< std::endl; 00155 //} 00156 if (seedSeg[viewIndex] == 0) { 00157 //seedSlay[viewIndex] = seedSlay[viewIndex]->nextInView();//yzhang temp 00158 seedSlay[viewIndex] = seedSlay[viewIndex]->prevInView(); //yzhang del 00159 if (seedSlay[viewIndex] == 0) return 0; 00160 seedSeg[viewIndex] = (MdcSeg *) 00161 oneList(seedSlay[viewIndex]->index())->first(); 00162 } // We have a segment; is it a viable seed? 00163 else if (seedSeg[viewIndex]->segUsed()) { 00164 //std::cout<<__FILE__<<" segUsed " << std::endl; 00165 seedSeg[viewIndex] = (MdcSeg *) seedSeg[viewIndex]->next(); 00166 } 00167 else if (seedSeg[viewIndex]->segAmbig() && goodOnly) { 00168 //std::cout<<__FILE__<<" segAmbig && goodOnly" << std::endl; 00169 seedSeg[viewIndex] = (MdcSeg *) seedSeg[viewIndex]->next(); 00170 //yzhang delete 09-10-10 00171 //delete (!seedSeg[viewIndex]->segAmbig() && !goodOnly) 00172 } //yzhang add 09-09-28 00173 else if ( !seedSeg[viewIndex]->segFull() && goodOnly) { 00174 //std::cout<<__FILE__<<" segFull && goodOnly" << std::endl; 00175 seedSeg[viewIndex] = (MdcSeg *) seedSeg[viewIndex]->next(); 00176 //zhangy add 00177 } else { 00178 // Reject segments with a lot of used hits 00179 int nused = 0; 00180 int navail = seedSeg[viewIndex]->nHit(); 00181 for (int ihit = 0; ihit < seedSeg[viewIndex]->nHit(); ihit++) { 00182 MdcHitUse *ahit = seedSeg[viewIndex]->hit(ihit); 00183 if ( ahit->mdcHit()->usedHit() ) nused++; 00184 } 00185 // Minimum 2 unused hits (but allow special-purpose segs w/ 0 hits) 00186 if (navail - nused < 2 && navail > 0) { 00187 seedSeg[viewIndex] = (MdcSeg *) seedSeg[viewIndex]->next(); 00188 } else { 00189 //std::cout<<__FILE__<<" Reject segments with a lot of used hits" << std::endl; 00190 break; 00191 } 00192 } 00193 } 00194 00195 // We have a seed 00196 MdcSeg *theSeed = seedSeg[viewIndex]; 00197 seedSeg[viewIndex] = (MdcSeg *) seedSeg[viewIndex]->next(); 00198 00199 return theSeed; 00200 }
|
|
|
|
00255 { 00256 /****************************************************************************/ 00257 sortByPhi(); 00258 // Delete duplicates only if there are too many segments 00259 bool drop = (segPar()->dropDups && count() > 200);//yzhang FIXME 00260 deleteDups(drop); 00261 tagAmbig(); 00262 }
|
|
|
|
00388 { 00389 //------------------------------------------------------------------------- 00390 return &segList[slayIndex]; 00391 }
|
|
|
|
00075 { 00076 /**************************************************************************/ 00077 00078 MdcSeg *aSeg; 00079 for (int i = 0; i < _nsupers; i++) { 00080 std::cout << " ---------------MdcSeg of Slayer "<<i<<"-------------" << std::endl; 00081 00082 aSeg = (MdcSeg *) segList[i].first(); 00083 while (aSeg != 0) { 00084 aSeg->plotSegAll(); 00085 std::cout << endl; 00086 aSeg = (MdcSeg *) aSeg->next(); 00087 } 00088 } 00089 }
|
|
|
|
00057 { 00058 /**************************************************************************/ 00059 00060 for (int iview = -1; iview <= 1; iview++) { 00061 int viewIndex = iview + 1; 00062 /* 00063 if(0 == iview){ 00064 seedSlay[viewIndex] = gm->firstSlayInView(iview); 00065 }else{ 00066 seedSlay[viewIndex] = gm->lastSlayInView(iview); 00067 } 00068 */ 00069 seedSlay[viewIndex] = gm->lastSlayInView(iview); 00070 if (seedSlay[viewIndex] != 0) seedSeg[viewIndex] = 00071 (MdcSeg *) oneList(seedSlay[viewIndex]->index())->first(); 00072 } 00073 }
|
|
00038 {return &segParam;}
|
|
00038 {return &segParam;}
|
|
|
|
00382 { 00383 MdcSeg::segPar()->lPlot = lPlt; 00384 }
|
|
|
|
00110 { 00111 //**************************************************************************** 00112 // Sort the list of segments by phi. Insertion sort, good only for small n 00113 00114 for (int isuper = 0; isuper < _nsupers; isuper++) { 00115 00116 if (segList[isuper].first() == 0) continue; 00117 MdcSeg *aseg = (MdcSeg *) segList[isuper].first()->next(); 00118 for (int j = 1; j < (int) segList[isuper].count(); j++) { 00119 double phiSeg = aseg->phi(); 00120 MdcSeg *nextseg = (MdcSeg *) aseg->next(); 00121 00122 MdcSeg *bseg = (MdcSeg *) aseg->prev(); 00123 if (phiSeg < bseg->phi() ) { 00124 while (bseg != 0 && phiSeg < bseg->phi()) { 00125 bseg = (MdcSeg *) bseg->prev(); 00126 } 00127 segList[isuper].moveAfter(aseg, bseg); // insert aseg after bseg 00128 } 00129 00130 aseg = nextseg; 00131 } 00132 00133 } 00134 return; 00135 }
|
|
|
|
00202 { 00203 //*************************************************************************** 00204 // Go through the list of segments and tag ones that will not make good 00205 // seeds -- i.e. ones that overlap with each other 00206 00207 for (int isuper = 0; isuper < _nsupers; isuper++) { 00208 const GmsList *thisSegList = &segList[isuper]; 00209 if (thisSegList->count() < 2) return; 00210 00211 // Bunch some declarations: 00212 double width, diff; 00213 double thisphi, nextphi; 00214 double nisocell = 2; 00215 // width = cell width in phi for this superlayer 00216 // diff = width of band about the track = nisocell * width 00217 00218 // Calculate road width for this slayer. 00219 const MdcLayer *aLayer = 00220 ((MdcSeg *)thisSegList->first())->superlayer()->firstLayer(); 00221 width = _twopi / aLayer->nWires(); 00222 diff = nisocell * width; 00223 00224 00225 for ( MdcSeg *startSeg = (MdcSeg *) thisSegList->first(); 00226 startSeg != 0; startSeg = (MdcSeg *) startSeg->next() ) { 00227 MdcSeg *nextSeg = (MdcSeg *) startSeg->next(); 00228 if (nextSeg == 0) nextSeg = (MdcSeg *) thisSegList->first(); 00229 00230 thisphi = startSeg->phi(); 00231 nextphi = nextSeg->phi(); 00232 if (nextphi < thisphi) nextphi += _twopi; 00233 00234 if (nextphi - thisphi < diff) { 00235 startSeg->setAmbig(); 00236 nextSeg->setAmbig(); 00237 } 00238 00239 } // end loop over segments 00240 } // end loop over superlayers 00241 00242 return; 00243 }
|
|
|
|
00051 { 00052 /**************************************************************************/ 00053 seedSeg[0] = seedSeg[1] = seedSeg[2] = 0; 00054 seedSlay[0] = seedSlay[1] = seedSlay[2] = 0; 00055 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|