28#include "AIDA/IHistogram1D.h"
51void MdcSegList::zeroSeed() {
53 seedSeg[0] = seedSeg[1] = seedSeg[2] = 0;
54 seedSlay[0] = seedSlay[1] = seedSlay[2] = 0;
60 for (
int iview = -1; iview <= 1; iview++) {
61 int viewIndex = iview + 1;
70 if (seedSlay[viewIndex] != 0) seedSeg[viewIndex] =
79 for (
int i = 0; i < _nsupers; i++) {
80 std::cout <<
" ---------------MdcSeg of Slayer "<<i<<
"-------------" << std::endl;
82 aSeg = (
MdcSeg *) segList[i].first();
97 for (
int i = 0; i < _nsupers; i++) {
98 aSeg = (
MdcSeg *) segList[i].first();
101 segList[i].
remove( aSeg );
110void MdcSegList::sortByPhi() {
114 for (
int isuper = 0; isuper < _nsupers; isuper++) {
116 if (segList[isuper].first() == 0)
continue;
117 MdcSeg *aseg = (
MdcSeg *) segList[isuper].first()->next();
118 for (
int j = 1; j < (int) segList[isuper].
count(); j++) {
119 double phiSeg = aseg->
phi();
123 if (phiSeg < bseg->phi() ) {
124 while (bseg != 0 && phiSeg < bseg->phi()) {
149 int viewIndex = iview + 1;
150 if (seedSlay[viewIndex] == 0)
return 0;
156 if (seedSeg[viewIndex] == 0) {
158 seedSlay[viewIndex] = seedSlay[viewIndex]->
prevInView();
159 if (seedSlay[viewIndex] == 0)
return 0;
160 seedSeg[viewIndex] = (
MdcSeg *)
163 else if (seedSeg[viewIndex]->segUsed()) {
165 seedSeg[viewIndex] = (
MdcSeg *) seedSeg[viewIndex]->next();
167 else if (seedSeg[viewIndex]->segAmbig() && goodOnly) {
169 seedSeg[viewIndex] = (
MdcSeg *) seedSeg[viewIndex]->next();
173 else if ( !seedSeg[viewIndex]->segFull() && goodOnly) {
175 seedSeg[viewIndex] = (
MdcSeg *) seedSeg[viewIndex]->next();
180 int navail = seedSeg[viewIndex]->
nHit();
181 for (
int ihit = 0; ihit < seedSeg[viewIndex]->
nHit(); ihit++) {
186 if (navail - nused < 2 && navail > 0) {
187 seedSeg[viewIndex] = (
MdcSeg *) seedSeg[viewIndex]->next();
203 MdcSeg *theSeed = seedSeg[viewIndex];
204 seedSeg[viewIndex] = (
MdcSeg *) seedSeg[viewIndex]->next();
209void MdcSegList::tagAmbig() {
214 for (
int isuper = 0; isuper < _nsupers; isuper++) {
215 const GmsList *thisSegList = &segList[isuper];
216 if (thisSegList->
count() < 2)
return;
220 double thisphi, nextphi;
227 ((
MdcSeg *)thisSegList->
first())->superlayer()->firstLayer();
229 diff = nisocell * width;
233 startSeg != 0; startSeg = (
MdcSeg *) startSeg->
next() ) {
235 if (nextSeg == 0) nextSeg = (
MdcSeg *) thisSegList->
first();
237 thisphi = startSeg->phi();
238 nextphi = nextSeg->
phi();
239 if (nextphi < thisphi) nextphi +=
_twopi;
241 if (nextphi - thisphi < diff) {
242 startSeg->setAmbig();
262void MdcSegList::massageSegs() {
271void MdcSegList::deleteDups(
bool ldrop) {
286 if(printit) std::cout<<
" =======MdcSegList::deleteDups()===== " << std::endl;
289 for (
int isuper = 0; isuper < _nsupers; isuper++) {
290 if(isuper==10)
continue;
291 GmsList *thisSegList = &segList[isuper];
292 if (thisSegList->
count() < 2)
continue;
294 std::cout<<endl<<
" -----slayer " << isuper<<
"-----"<< std::endl;
297 double thisphi, nextphi;
302 ((
MdcSeg *)thisSegList->
first())->superlayer()->firstLayer();
309 while ( startSeg != 0 ) {
310 if (thisSegList->
count() < 2)
break;
312 thisphi = startSeg->
phi();
313 MdcSeg *nextSeg = startSeg;
315 startSeg->
plotSeg();std::cout<<std::endl;
322 if (lWrapped == 1)
break;
325 if( nextSeg == startSeg )
break;
326 nextphi = nextSeg->
phi();
328 if (nextphi < thisphi) nextphi +=
_twopi;
331 std::cout<<std::endl<<
"----start "; startSeg->
plotSeg(); std::cout<<std::endl;
332 std::cout<<
" next "; nextSeg->
plotSeg(); std::cout<<std::endl;
333 std::cout<<
" phi diff "<< nextphi -thisphi <<
" cut phidiff "<<phidiff;
334 std::cout<<
" slope diff "<< nextSeg->
slope() - startSeg->
slope()
335 <<
" cut slopdiff "<<slopediff<<std::endl;
341 if (nextphi - thisphi > phidiff) {
342 if(printit){ std::cout<<
" --not same phi" <<std::endl; }
346 }
else if (fabs( nextSeg->
slope() - startSeg->
slope() ) > slopediff) {
347 if(printit){ std::cout<<
" --attached, but not identical -- move on to next nextSeg "<< std::endl; }
353 assert (startSeg->
nHit() > 2);
354 double chiFirst = startSeg->
chisq() / (startSeg->
nHit() - 2);
355 assert (nextSeg->
nHit() > 2);
356 double chiNext = nextSeg->
chisq() / (nextSeg->
nHit() - 2);
358 int cdiff = (int) nextSeg->
nHit() - (int) startSeg->
nHit();
359 theDiff = (chiFirst - chiNext) + 2. * (cdiff);
360 if (theDiff < 0.) firstBetter = 1;
362 std::cout<<
" --identical; choose better "<< std::endl;
363 std::cout<<
" chi start "<<chiFirst<<
" chi next "<< chiNext<<
" cdiff "<<cdiff<< std::endl;
367 if(printit){ std::cout<<
" startSeg better,"; }
368 MdcSeg *tempSeg = nextSeg;
371 if(printit){ std::cout<<
" delete nextSeg"<<std::endl; }
372 thisSegList->
remove(tempSeg);
375 if(printit){ std::cout<<
" nextSeg->setUsed(true) "<<std::endl; }
380 if (lWrapped == 1)
break;
384 if(printit){ std::cout<<
" nextSeg better,"; }
385 MdcSeg *tempSeg = startSeg;
388 if(printit){ std::cout<<
" delete startSeg"<<std::endl; }
389 thisSegList->
remove(tempSeg);
392 if(printit){ std::cout<<
" startSeg->setUsed(true) "<<std::endl; }
414 return &segList[slayIndex];
422 for (
int i = 0; i < _nsupers; i++) cnt += segList[i].
count();
AIDA::IHistogram1D * g_phiDiff
AIDA::IHistogram1D * g_slopeDiff
AIDA::IHistogram1D * g_phiDiff
AIDA::IHistogram1D * g_slopeDiff
static const double twoPi
GmsListLink * prev() const
GmsListLink * next() const
GmsListLink * first() const
GmsList & moveAfter(GmsListLink *link, GmsListLink *insertHere)
GmsList & append(GmsListLink *)
unsigned int count() const
GmsList & remove(GmsListLink *)
const MdcSuperLayer * lastSlayInView(int iview) const
const MdcHit * mdcHit() const
void append(MdcSeg *aSeg)
MdcSegList(int nSupers, const MdcSegParams segParms)
const GmsList * oneList(int slayIndex) const
MdcSeg * getSeed(int iview, int goodOnly)
void resetSeed(const MdcDetector *gm)
const MdcSuperLayer * superlayer() const
static MdcSegParams * segPar()
static void setParam(MdcSegParams *segpar)
MdcHitUse * hit(int i) const
const MdcSuperLayer * prevInView(void) const