BOSS 7.0.1
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcSegGrouper Class Referenceabstract

#include <MdcSegGrouper.h>

+ Inheritance diagram for MdcSegGrouper:

Public Member Functions

virtual ~MdcSegGrouper ()
 
int nextGroup (MdcSeg **segGroup, bool printit)
 
int updateGap ()
 
void resetGap (int nGap)
 
virtual void resetComb (const MdcSeg *seed)=0
 
virtual MdcTrackstorePar (MdcTrack *trk, double parms[2], double chisq, TrkContext &, double trackT0)=0
 
int nPly () const
 
virtual int incompWithSeg (const MdcSeg *refSeg, const MdcSeg *testSeg)=0
 
virtual int incompWithGroup (MdcSeg **segGroup, const MdcSeg *testSeg, int iply)=0
 
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)
 
virtual ~MdcSegGrouper ()
 
int nextGroup (MdcSeg **segGroup, bool printit)
 
int updateGap ()
 
void resetGap (int nGap)
 
virtual void resetComb (const MdcSeg *seed)=0
 
virtual MdcTrackstorePar (MdcTrack *trk, double parms[2], double chisq, TrkContext &, double trackT0)=0
 
int nPly () const
 
virtual int incompWithSeg (const MdcSeg *refSeg, const MdcSeg *testSeg)=0
 
virtual int incompWithGroup (MdcSeg **segGroup, const MdcSeg *testSeg, int iply)=0
 
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

 MdcSegGrouper (const MdcDetector *gm, int nDeep, int debug)
 
void resetSegCounters ()
 
 MdcSegGrouper (const MdcDetector *gm, int nDeep, int debug)
 
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
 
boolleaveGap
 
int nNull
 
int maxNull
 
int * gapCounter
 
bool lTestGroup
 
bool lTestSingle
 
int _debug
 

Detailed Description

Constructor & Destructor Documentation

◆ ~MdcSegGrouper() [1/2]

MdcSegGrouper::~MdcSegGrouper ( )
virtual

Definition at line 45 of file MdcSegGrouper.cxx.

◆ MdcSegGrouper() [1/2]

MdcSegGrouper::MdcSegGrouper ( const MdcDetector gm,
int  nDeep,
int  debug 
)
protected

Definition at line 63 of file MdcSegGrouper.cxx.

63 {
64 //------------------------------------------------------------------------
65 nDeep = nd;
66 int nsuper = gm->nSuper();
67 segList = new HepAList<MdcSeg>[nsuper];
68 currentSeg = new int[nDeep];
69 leaveGap = new bool[nDeep];
70 gapCounter = new int[nDeep];
72 _gm = gm;
73 firstGood = new int[nDeep];
74 firstBad = new int[nDeep];
75 lTestGroup = false;
76 lTestSingle = false;
77 _debug = debug;
78}

◆ ~MdcSegGrouper() [2/2]

virtual MdcSegGrouper::~MdcSegGrouper ( )
virtual

◆ MdcSegGrouper() [2/2]

MdcSegGrouper::MdcSegGrouper ( const MdcDetector gm,
int  nDeep,
int  debug 
)
protected

Member Function Documentation

◆ calcParByHits() [1/2]

double MdcSegGrouper::calcParByHits ( MdcSeg **  segGroup,
int  nToUse,
const TrkExchangePar par,
double &  qual,
int &  nSegFit,
double  param[2],
double  Bz 
)

Definition at line 585 of file MdcSegGrouper.cxx.

585 {
586 //************************************************************************
587 //*** Calc. z and cot(theta) for stereo
588 int debug = false;
589 if (11 == _debug ) debug = true;
590 if (debug) std::cout<< "-----calculate group param by hit-----"<<std::endl;
591 MdcLine span(50);
592 MdcLine spanFit(50);
593
594 int nHit = 0;
595 if (debug) std::cout<< "nToUse="<<nToUse<<std::endl;
596 for (int iPly = 0; iPly < nToUse; iPly++) {
597 if (segGroup[iPly] == 0) continue; // skipping this slayer
598 nSegFit++;
599 MdcSegInfoSterO *segInfo = dynamic_cast<MdcSegInfoSterO*> (segGroup[iPly]->info());
600
601 if(debug) std::cout<< "nHit in segment="<<segGroup[iPly]->nHit()<<std::endl;
602 for (int ii=0,iHit=0; ii<segGroup[iPly]->nHit(); ii++){
603
604 if(debug)std::cout<< " calcParByHits ("<< segGroup[iPly]->hit(iHit)->mdcHit()->layernumber()<<","<<segGroup[iPly]->hit(iHit)->mdcHit()->wirenumber()<<")";
605 //if(segGroup[iPly]->hit(iHit)->mdcHit()->layernumber()<4) continue;//yzhang TEMP TEST 2011-08-01
606
607 int szCode = segInfo->zPosition(*(segGroup[iPly]->hit(iHit)),par,&span,iHit,segGroup[iPly]->bunchTime(),Bz);
608 if(debug)std::cout<< " szCode "<<szCode;
609 if(szCode>0&&debug) std::cout<< iHit<<" s "<< span.x[iHit]<< " z "<<span.y[iHit] <<" sigma "<<span.sigma[iHit];
610 if(debug)std::cout<<std::endl;
611
612 spanFit.x[nHit]=span.x[iHit];
613 spanFit.y[nHit]=span.y[iHit];
614 //spanFit.sigma[nHit]=span.sigma[iHit];
615 spanFit.sigma[nHit]=1.;
616 if(debug)std::cout<< std::endl;
617 iHit++;
618 if(szCode>0) nHit++;
619 }
620 }
621
622 if(debug)std::cout<< __FILE__ << " " << __LINE__ << " nHit "<< nHit<<std::endl;
623 if (nHit>0) spanFit.fit(nHit);
624 else return -999;
625
626 param[0] = spanFit.intercept;
627 param[1] = spanFit.slope;
628 if(debug)std::cout<< "nHit "<<nHit<<" intercept(z0) "<<param[0]<< " slope(ct) " << param[1] <<std::endl;
629
630 qual = 2.*nHit - spanFit.chisq/(spanFit.nPoint - 2);
631 if(debug)std::cout<< "chisq "<<spanFit.chisq<<" qual "<<qual<<std::endl;
632
633 return spanFit.chisq;
634}
const MdcHit * mdcHit() const
Definition: MdcHitUse.cxx:69
int zPosition(MdcHitUse &hitUse, const TrkRecoTrk &track, MdcLine *span, int hitFit, double t0) const
int nHit() const
Definition: MdcSeg.cxx:368

Referenced by combineSegs().

◆ calcParByHits() [2/2]

double MdcSegGrouper::calcParByHits ( MdcSeg **  segGroup,
int  nToUse,
const TrkExchangePar par,
double &  qual,
int &  nSegFit,
double  param[2],
double  Bz 
)

◆ calcParBySegs() [1/2]

double MdcSegGrouper::calcParBySegs ( MdcSeg **  segGroup,
double  seedAngle[2],
int  nToUse,
double &  qual,
int &  nSegFit,
double  param[2] 
)

Definition at line 475 of file MdcSegGrouper.cxx.

476 {
477 //************************************************************************
478 if (11 == _debug) std::cout<< "-----calculate group param by segment param-----"<<std::endl;
479 double wgtmat[3], wgtinv[3];
480 double wgtpar[2];
481 double temvec[2], diff[2];
482 // Calculate track & chisq for this group
483 int nhit = 0;
484 wgtmat[0] = wgtmat[1] = wgtmat[2] = wgtpar[0] = wgtpar[1] = 0.0;
485
486 int iPly;
487 for (iPly = 0; iPly < nToUse; iPly++) {
488 if (11 == _debug) {
489 //if (!lSeed) //if (segGroup[iPly] == 0) cout << "ply empty: " << iPly << "\n";
490 }
491 if (segGroup[iPly] == 0) continue; // skipping this slayer
492 nSegFit++;
493 MdcSegInfo *segInfo = segGroup[iPly]->info();
494 // Accumulate sums
495 for (int i = 0; i < 3; i++) wgtmat[i] += (segInfo->inverr())[i];
496 for (int k = 0; k < 2; k++) {
497 param[k] = segInfo->par(k);
498 //zhangy add
499 if (segInfo->parIsAngle(k)) {
500 param[k] = mdcWrapAng(seedAngle[k], param[k]);
501 }
502 }
503 // Multiply by weight matrix.
504 mdcTwoVec( segInfo->inverr(), param, temvec );
505 wgtpar[0] += temvec[0];
506 wgtpar[1] += temvec[1];
507 if(11 == _debug) {
508 std::cout<<0<<": param "<<param[0]<<" inverr "<< segInfo->inverr()[0]<<" par*W "<<temvec[0]<<std::endl;
509 std::cout<<1<<": param "<<param[1]<<" "<<1/param[1]<<" inverr "<< segInfo->inverr()[1]<<" par*W "<<temvec[1]<<std::endl;
510 std::cout<< " " <<std::endl;
511 }
512 nhit += segGroup[iPly]->nHit();
513 }
514
515 // And the fitted parameters are . . .
516 int error = mdcTwoInv(wgtmat,wgtinv);
517 if (error && (11 == _debug)) {
518 cout << "ErrMsg(warning) "
519 << "failed matrix inversion in MdcTrackList::combineSegs" << endl;
520 //continue;
521 return -999.;
522 }
523 mdcTwoVec( wgtinv, wgtpar, param );
524 if(11 == _debug) {
525 std::cout<< " param of wgtinv * wgtpar" << std::endl;
526 std::cout<<0<<": param "<<param[0]<< std::endl;
527 std::cout<<1<<": param "<<param[1]<<" "<<1/param[1]<< std::endl;
528 std::cout<< " " <<std::endl;
529 }
530
531 //param[0]= 5.312286;
532 //param[1]= -0.006;
533 //std::cout<< "set param " <<param[0]<< " "<<param[1]<<std::endl;
534 if(11 == _debug)cout<<endl<<"-- Calculate track & chisq for this group "<<endl;
535
536 // Calc. chisq. = sum( (Vi - V0) * W * (Vi - V0) )
537 // W = weight, Vi = measurement, V0 = fitted param.
538 double chisq = 0.0;
539 for (iPly = 0; iPly < nToUse; iPly++) {
540 if (segGroup[iPly] == 0) continue; // skipping this slayer
541 MdcSegInfo *segInfo = segGroup[iPly]->info();
542 for (int j = 0; j < 2; j++) {
543 double temPar;
544 if (segInfo->parIsAngle(j)) {
545 temPar = mdcWrapAng(seedAngle[j], segInfo->par(j));
546 } else {
547 temPar = segInfo->par(j);
548 }
549 if(11 == _debug) {
550 std::cout<<" segPar"<<j<<" "<<temPar<< std::endl;
551 }
552 diff[j] = temPar - param[j];
553 }
554
555 if(11 == _debug) {
556 std::cout<<"inverr " <<segInfo->inverr()[0]<<" "
557 <<segInfo->inverr()[1] <<" "<<segInfo->inverr()[2] << std::endl;
558 std::cout<<"errmat " <<segInfo->errmat()[0]<< " "
559 <<segInfo->errmat()[1] << " "<<segInfo->errmat()[2] << std::endl;
560 std::cout<<"diff " <<diff[0]<<" "<<diff[1]<<" temvec "<<temvec[0]<<" "<<temvec[1]<< std::endl;
561 std::cout<< std::endl;
562 }
563 mdcTwoVec( segInfo->inverr(), diff, temvec);
564
565 chisq += diff[0] * temvec[0] + diff[1] * temvec[1];
566
567 if(11 == _debug){
568 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;
569 }
570 }
571
572 double chiDof = chisq/(2.*nSegFit - 2.);
573 if (11 == _debug) {
574 cout << "segment:"<<endl<<" chiDof "<<chiDof<<" chisq "<< chisq << " nhit " << nhit << " phi0/z0 " <<
575 param[0] << " cpa/cot " << param[1] << " qual "<<(2. * nhit - chiDof) <<endl;
576 }
577
578 qual = 2. * nhit - chiDof;
579
580 //if(is3d) std::cout<< __FILE__ << " " << " z0 "<<param[0] << " ct "<<param[0] <<std::endl;//zhange TEMP test 2011-05-06
581 return chisq;
582}
int mdcTwoInv(double matrix[3], double invmat[3])
void mdcTwoVec(const double matrix[3], const double invect[2], double outvect[2])
double mdcWrapAng(double phi1, double phi2)
virtual bool parIsAngle(int i) const =0

Referenced by combineSegs().

◆ calcParBySegs() [2/2]

double MdcSegGrouper::calcParBySegs ( MdcSeg **  segGroup,
double  seedAngle[2],
int  nToUse,
double &  qual,
int &  nSegFit,
double  param[2] 
)

◆ combineSegs() [1/2]

int MdcSegGrouper::combineSegs ( MdcTrack *&  trk,
MdcSeg seed,
TrkContext context,
double  trackT0,
double  maxSegChisqO,
int  combineByFitHits = 0 
)

Definition at line 270 of file MdcSegGrouper.cxx.

271 {
272 //************************************************************************/
273 // forms track from list of segs; does 2-param fit (either r-phi from origin
274 // or s-z) and picks best combination.
275 if (3 == _debug) std::cout<<std::endl<< "=====MdcSegGrouper::combineSegs=====" <<std::endl;
276 bool lSeed = (seed != 0); // no seed for stereo group
277
278 int success = 0;
279 double qual;
280 double qualBest = -1000.;
281 int nSegFit = 0;
282 int nSegBest = 0;
283 //int nHitBest = 0;
284 double param[2];
285 double paramBest[2];
286 double chiBest = 9999.;
287 int nToUse = nPly();
288 if (lSeed) nToUse++; // seed isn't included in the segs list
289 MdcSeg **segGroup;
290 MdcSeg **segGroupBest;
291 segGroup = new MdcSeg * [nToUse];
292 segGroupBest = new MdcSeg * [nToUse];
293 // static int counter = 0;
294 // counter++;
295 // cout << counter << endl;
296
297 //bool is3d = (seed==NULL);//zhange TEMP test 2011-05-06
298
299 // Loop over all combinations of segs consistent with seed (including gaps)
300 if ((3 == _debug)&&lSeed) {
301 std::cout<<"seed segment: ";
302 seed->plotSegAll();
303 std::cout<< std::endl;
304 }
305 resetComb(seed);
306
307 // Save seed params (if angles) for later use as reference angle in
308 // mdcWrapAng (don't really have to test whether it's an angle, but I do)
309 double seedAngle[2] = {0.,0.};
310 if (lSeed) {
311 if (seed->info()->parIsAngle(0)) seedAngle[0] = seed->info()->par(0);
312 if (seed->info()->parIsAngle(1)) seedAngle[1] = seed->info()->par(1);
313 }
314
315 int iprint = ( 3 == _debug);
316 int nInGroup = 0;
317 while ( (nInGroup = nextGroup(segGroup, iprint)) != 0) {
318
319 if (lSeed) {
320 segGroup[nToUse-1] = seed;
321 nInGroup++;
322 }
323 if (nInGroup < 0) continue;
324 if (nInGroup < 2) break;
325 if (nInGroup < nSegBest) break;
326
327 if (3 == _debug || 11 == _debug) {
328 cout << endl <<"-----found a segment group by nextGroup()----- nInGroup "<<nInGroup<<" nToUse "<<nToUse<<endl;
329 for(int ii=0; ii<nToUse; ii++){ if(segGroup[ii]) {segGroup[ii]->plotSegAll(); cout<<endl;} }
330 //cout << endl <<"--calc. parameters of this segment group"<<endl;
331 }
332
333 double chisq =-999.;
334 nSegFit=0;
335
336 if(lSeed){
337 //2d
338 chisq = calcParBySegs(segGroup, seedAngle, nToUse, qual, nSegFit, param);
339 }else{
340 if (combineByFitHits == 0){
341 chisq = calcParBySegs(segGroup, seedAngle, nToUse, qual, nSegFit, param);
342 }else{
343 //3d
344 const TrkFit* tkFit = trk->track().fitResult();
345 double Bz = trk->track().bField().bFieldZ();//??
346 TrkExchangePar par = tkFit->helix(0.0);
347 //par.print(std::cout);
348 if (tkFit != 0) chisq = calcParByHits(segGroup, nToUse, par, qual,nSegFit, param, Bz);
349 //std::cout<< __FILE__ << " " << __LINE__ << " calcParByHits"<<std::endl;
350 if(chisq<=0){
351 //std::cout<< "calcParByHits failed! calc. by seg" <<std::endl;
352 chisq = calcParBySegs(segGroup, seedAngle, nToUse, qual, nSegFit, param);
353 }
354 }
355 }
356
357
358 if (chisq < 0.) continue;//yzhang add
359 double chiDof = chisq/(2.*nSegFit - 2.);
360
361 if (g_maxSegChisqAx && lSeed ) { g_maxSegChisqAx->fill(chiDof); } //yzhang hist cut
362 if (g_maxSegChisqSt && !lSeed) { g_maxSegChisqSt->fill(chiDof); } //yzhang hist cut
363
364 //std::cout<< " chisq " << chisq<< " chi2dof "<<chiDof<<std::endl;
365
366 if (3 == _debug || 11 == _debug) {
367 std::cout<< endl<<"chisq "<<chisq<<" nSegFit " << nSegFit<< " chiDof "<<chiDof<<std::endl;
368 if(chiDof > maxSegChisqO) {
369 cout << "***** DROP this group by chiDof "<<chiDof<<" > maxSegChisqO:"<<maxSegChisqO<<endl;
370 }else{
371 cout << "***** KEEP this group by chiDof "<<chiDof<<" <= maxSegChisqO:"<<maxSegChisqO<<endl;
372 }
373 }
374 // Chisq test
375 if (chiDof > maxSegChisqO) continue;
376
377 success = 1;
378 if (qual > qualBest) {
379 qualBest = qual;
380 nSegBest = nSegFit;
381 //nHitBest = nhit;
382 paramBest[0] = param[0];
383 paramBest[1] = param[1];
384 chiBest = chisq;
385 for (int i = 0; i < nToUse; i++) {
386 segGroupBest[i] = segGroup[i];
387 }
388 if (3 == _debug && 11 == _debug) std::cout<<"Keep as best group. param: phi0/z0 "
389 <<paramBest[0]<< " cpa/ct "<<paramBest[1]<< std::endl;
390 }// end test on qual
391 }
392
393 if (success == 1) {
394 if(3 == _debug || 11 == _debug) {
395 std::cout<< endl<<"-----Parameter best group----- "<<std::endl;
396 std::cout<< "paramBest "<<paramBest[0]<<" "<<paramBest[1]<< " chiBest " << chiBest<< std::endl;
397 }
398 // Store the results in a track, possibly creating it in the process
399 trk = storePar(trk, paramBest, chiBest, context, t0);
400 transferHits(trk, nToUse, segGroupBest); // Store hits with track
401 }
402 delete [] segGroupBest;
403 delete [] segGroup;
404 return success;
405}
virtual void resetComb(const MdcSeg *seed)=0
int nextGroup(MdcSeg **segGroup, bool printit)
double calcParBySegs(MdcSeg **segGroup, double seedAngle[2], int nToUse, double &qual, int &nSegFit, double param[2])
void transferHits(MdcTrack *track, int nSegs, MdcSeg **segGroup)
double calcParByHits(MdcSeg **segGroup, int nToUse, const TrkExchangePar &par, double &qual, int &nSegFit, double param[2], double Bz)
virtual MdcTrack * storePar(MdcTrack *trk, double parms[2], double chisq, TrkContext &, double trackT0)=0
void plotSegAll() const
Definition: MdcSeg.cxx:159
virtual TrkExchangePar helix(double fltL) const =0
const TrkFit * fitResult() const
Definition: TrkRecoTrk.cxx:387

Referenced by MdcTrackList::createFromSegs(), and MdcTrackListCsmc::createFromSegs().

◆ combineSegs() [2/2]

int MdcSegGrouper::combineSegs ( MdcTrack *&  ,
MdcSeg seed,
TrkContext ,
double  trackT0,
double  maxSegChisqO,
int  combineByFitHits = 0 
)

◆ dumpSegList() [1/2]

void MdcSegGrouper::dumpSegList ( )

Definition at line 464 of file MdcSegGrouper.cxx.

464 {
465 //************************************************************************
466 for(int islayer=0; islayer<11; islayer++){
467 for(int i=0; i<segList[islayer].length(); i++){
468 segList[islayer][i]->plotSegAll();
469 std::cout<< std::endl;
470 }
471 }
472}

Referenced by MdcTrackList::createFromSegs().

◆ dumpSegList() [2/2]

void MdcSegGrouper::dumpSegList ( )

◆ incompWithGroup() [1/2]

virtual int MdcSegGrouper::incompWithGroup ( MdcSeg **  segGroup,
const MdcSeg testSeg,
int  iply 
)
pure virtual

◆ incompWithGroup() [2/2]

virtual int MdcSegGrouper::incompWithGroup ( MdcSeg **  segGroup,
const MdcSeg testSeg,
int  iply 
)
pure virtual

◆ incompWithSeg() [1/2]

virtual int MdcSegGrouper::incompWithSeg ( const MdcSeg refSeg,
const MdcSeg testSeg 
)
pure virtual

◆ incompWithSeg() [2/2]

virtual int MdcSegGrouper::incompWithSeg ( const MdcSeg refSeg,
const MdcSeg testSeg 
)
pure virtual

◆ nextGroup() [1/2]

int MdcSegGrouper::nextGroup ( MdcSeg **  segGroup,
bool  printit 
)

Definition at line 83 of file MdcSegGrouper.cxx.

83 {
84 //------------------------------------------------------------------------
85
86 // Loop over the superlayers, moving to next valid seg for each if necessary
87 // First, loop over the slayers w/o good segs, filling segGroup w/ 0
88 int iply;
89 for (iply = nPlyFilled; iply < nDeep; iply++) {
90 segGroup[iply] = 0;
91 }
92
93restart:
94 if (printit) cout <<endl<< "MdcSegGrouper::nextGroup starting group finder, nply = " << nPlyFilled << endl;
95 int nFound = 0;
96 bool incrementNext = true;
97 //int nSegUsed;//yzhang 2010-05-21
98 for (iply = 0; iply < nPlyFilled; iply++) {
99 segGroup[iply] = 0;
100 if (!incrementNext && currentSeg[iply] >= firstGood[iply]) {
101 if(printit) std::cout<< " reach end of list, break." << iply<< std::endl;
102 break;
103 }
104 //if (nSegUsed > segPar.nSegUsedNextGroup) break;
105 if (leaveGap[iply]) {
106 if(printit) std::cout<< " leaveGap " <<std::endl;
107 // This ply is currently a gap; move on.
108 if (iply == nPlyFilled - 1 && incrementNext) {
109 // we've exhausted this gap group; start another
110 iply = -1;
112 int lDone = updateGap();
113 if (lDone) {
114 // all gap groups for nNull exhausted; increment nNull
115 nNull++;
116 if (nNull > maxNull) return 0; // All done
118 updateGap();
119 } // end if lDone
120 } //end if exhausted gap group
121 continue;
122 }
123 incrementNext = false;
124
125 // Loop through the segs in this ply until valid one found
126 while (1) {
127 currentSeg[iply]++;
128 if (currentSeg[iply] == firstBad[iply]) { // reached end of segs
129 incrementNext = true;
130 currentSeg[iply] = firstGood[iply];
131 if(printit) { std::cout<< "reach end of segs "<<std::endl; }
132 if (iply == nPlyFilled - 1) {
133 // we've exhausted this gap group; start another
134 iply = -1;
136 int lDone = updateGap();
137 if (lDone) {
138 // all gap groups for nNull exhausted; increment nNull
139 nNull++;
140 if (nNull > maxNull) {
141 if(printit) { std::cout<<endl<< " All done! "<<std::endl; }
142 return 0; // All done
143 }
145 updateGap();
146 } // end if lDone
147 } //end if exhausted gap group
148 break;
149 } // end reached end of segs
150
151 if(printit){
152 std::cout<< "ply " << iply<< " seg "<<currentSeg[iply]<<": ";
153 (*combList[iply])[currentSeg[iply]]->plotSeg();
154 if((*combList[iply])[currentSeg[iply]]->superlayer()->whichView()!= 0){
155 MdcSegInfoSterO* info = (MdcSegInfoSterO *) (*combList[iply])[currentSeg[iply]]->info();
156 std::cout<< " ct " << info->ct();
157 }
158 }
159
160 //yzhang 09-09-28 delete
161 if( (*combList[iply])[currentSeg[iply]]->segUsed()) {
162 if(printit) {
163 std::cout<< std::endl<<" Used??";
164 (*combList[iply])[currentSeg[iply]]->plotSeg();
165 }
166 if(printit) { std::cout<< " segUsed! SKIP "<<std::endl; }
167 continue; //yzhang 2010-05-21 add
168 //nSegUsed++;
169 }
170
171 // Test this seg for validity
172 if (lTestSingle) {
173 assert(isValid != 0);
174 assert(isValid[iply] != 0);
175 int invalid = (isValid[iply][currentSeg[iply]] == false);
176 if(printit) {
177 if(invalid){ std::cout<<" invalid "<< std::endl;
178 }else{ std::cout<<" KEEP 1 "<< std::endl; }
179 }
180 if (invalid) continue;
181 }else{
182 if(printit) std::cout<<" KEEP 2 "<< std::endl;
183 }
184
185 // Whew. We successfully incremented.
186 break;
187
188 } // end seg loop
189 } // end ply loop
190
191 // Fill segGroup with appropriate segs
192 for (iply = 0; iply < nPlyFilled; iply++) {
193 if (leaveGap[iply]) {
194 segGroup[iply] = 0;
195 } else {
196 segGroup[iply] = (*combList[iply])[currentSeg[iply]];
197 if (lTestGroup && nFound > 1) {
198 int lBad = incompWithGroup(segGroup, segGroup[iply], iply);
199 if(printit){
200 if(lBad) std::cout<<" incompWithGroup Bad! restart" << std::endl;
201 //else std::cout<<" incompWithGroup Bad! restart" << std::endl;
202 }
203 if (lBad) goto restart;
204 }
205 nFound++;
206 }
207 }
208
209 if (printit) std::cout<< "nextGoup() found " << nFound << " segment(s)"<<std::endl;
210 return nFound;
211}
void resetGap(int nGap)
void resetSegCounters()
virtual int incompWithGroup(MdcSeg **segGroup, const MdcSeg *testSeg, int iply)=0

Referenced by combineSegs().

◆ nextGroup() [2/2]

int MdcSegGrouper::nextGroup ( MdcSeg **  segGroup,
bool  printit 
)

◆ nPly() [1/2]

◆ nPly() [2/2]

int MdcSegGrouper::nPly ( ) const
inline

◆ resetComb() [1/2]

virtual void MdcSegGrouper::resetComb ( const MdcSeg seed)
pure virtual

◆ resetComb() [2/2]

virtual void MdcSegGrouper::resetComb ( const MdcSeg seed)
pure virtual

◆ resetGap() [1/2]

void MdcSegGrouper::resetGap ( int  nGap)

Definition at line 214 of file MdcSegGrouper.cxx.

214 {
215 //**************************************************************************
216
217 for (int i = 0; i < nPlyFilled; i++) {
218 gapCounter[i] = nGap - 1 - i;
219 }
220 gapCounter[0]--; // so 1st increment will put 1st counter in right place
221
222 return;
223}

Referenced by nextGroup().

◆ resetGap() [2/2]

void MdcSegGrouper::resetGap ( int  nGap)

◆ resetSegCounters() [1/2]

void MdcSegGrouper::resetSegCounters ( )
protected

Definition at line 262 of file MdcSegGrouper.cxx.

262 {
263 //-------------------------------------------------------------------------
264 for (int i = 0; i < nPlyFilled; i++) {
265 currentSeg[i] = firstGood[i] - 1;
266 }
267}

Referenced by nextGroup(), MdcSegGrouperCsmc::resetComb(), MdcSegGrouperAx::resetComb(), and MdcSegGrouperSt::resetComb().

◆ resetSegCounters() [2/2]

void MdcSegGrouper::resetSegCounters ( )
protected

◆ storePar() [1/2]

virtual MdcTrack * MdcSegGrouper::storePar ( MdcTrack trk,
double  parms[2],
double  chisq,
TrkContext ,
double  trackT0 
)
pure virtual

◆ storePar() [2/2]

virtual MdcTrack * MdcSegGrouper::storePar ( MdcTrack trk,
double  parms[2],
double  chisq,
TrkContext ,
double  trackT0 
)
pure virtual

◆ transferHits() [1/2]

void MdcSegGrouper::transferHits ( MdcTrack track,
int  nSegs,
MdcSeg **  segGroup 
)

Definition at line 408 of file MdcSegGrouper.cxx.

408 {
409 //************************************************************************/
410 //Move hits from segments to track hitlist
411 // Also note first and last layers in list
412 // Only handles Mdc segments
413 double smallRad = 1000.;
414 if (trk->firstLayer() != 0) smallRad = trk->firstLayer()->rMid();
415 double bigRad = 0.;
416 if (trk->lastLayer() != 0) bigRad = trk->lastLayer()->rMid();
417
418 //yzhang 2011-05-04
419 //bool maintainAmbiguity = (trk->track().status()->is2d() == 0) ? false: true;
420 //bool maintainAmbiguity = false;
421 //std::cout<< __FILE__ << " " << __LINE__ << " maintainAmbiguity "<<maintainAmbiguity<<std::endl;
422
423 if(3 == _debug) std::cout<< endl<<"-----transferHits for this segGroup----- " <<std::endl;
424 for (int i = 0; i < nSegs; i++) {
425 if (segGroup[i] == 0) continue; // skipping this slayer
426 if(3 == _debug) {
427 cout << i << " "; segGroup[i]->plotSegAll(); cout<< endl;
428 }
429 segGroup[i]->setUsed(); // mark seg as used
430 for (int ihit = 0; ihit < segGroup[i]->nHit(); ihit++) {
431 MdcHitUse *aHit = segGroup[i]->hit(ihit);
432 const MdcLayer *layer = aHit->mdcHit()->layer();
433 double radius = layer->rMid();
434 if (radius < smallRad) {
435 smallRad = radius;
436 trk->setFirstLayer(layer);
437 }
438
439 // Assume that segs aren't added to backside of curler
440 if (radius > bigRad && !trk->hasCurled()) {
441 bigRad = radius;
442 trk->setLastLayer(layer);
443 }
444 // Provide very crude starting guess of flightlength
445 double flt = radius;
446 flt += 0.000001 * (aHit->mdcHit()->x() +aHit->mdcHit()->y());
447
448 aHit->setFltLen(flt);
449
450 TrkHitList* theHits = trk->track().hits();
451
452 if (theHits == 0) return;
453
454 //theHits->appendHit(*aHit, maintainAmbiguity);
455 theHits->appendHit(*aHit);
456 //zhangy
457
458 //std::cout<<"in MdcSegGrouper append ok"<<std::endl;//yzhang debug
459 }
460 } // end loop over slayers
461}
const MdcLayer * layer() const
TrkHitOnTrk * appendHit(const TrkHitUse &theHit)
Definition: TrkHitList.cxx:114

Referenced by combineSegs().

◆ transferHits() [2/2]

void MdcSegGrouper::transferHits ( MdcTrack track,
int  nSegs,
MdcSeg **  segGroup 
)

◆ updateGap() [1/2]

int MdcSegGrouper::updateGap ( )

Definition at line 226 of file MdcSegGrouper.cxx.

226 {
227 //**************************************************************************
228 if (nNull == 0) return 1;
229
230 for (int i = 0; i < nPlyFilled; i++) {
231 leaveGap[i] = false;
232 }
233 for (int igap = 0; igap < nNull; igap++) {
234 gapCounter[igap]++;
235 if (gapCounter[igap] == nPlyFilled - igap) {
236 // End of loop for this counter; look at the other counters to
237 // decide where this one should be reset to.
238 int inext = igap + 1;
239 while (1) {
240 if (inext >= nNull) return 1; // done with all combos
241 if (gapCounter[inext] + inext + 1 < nPlyFilled) {
242 // This is the right spot to reset to
243 gapCounter[igap] = gapCounter[inext] + inext + 1 - igap;
244 break;
245 }
246 inext++;
247 }
248 }
249 else {
250 // We successfully incremented. Quit looping and return.
251 break;
252 }
253 } // end loop over igap
254
255 for (int j = 0; j < nNull; j++) {
256 leaveGap[gapCounter[j]] = true;
257 }
258 return 0;
259
260}

Referenced by nextGroup().

◆ updateGap() [2/2]

int MdcSegGrouper::updateGap ( )

Member Data Documentation

◆ _debug

◆ _gm

◆ combList

◆ currentSeg

◆ firstBad

◆ firstGood

◆ gapCounter

int * MdcSegGrouper::gapCounter
protected

◆ isValid

◆ leaveGap

◆ lTestGroup

◆ lTestSingle

◆ maxNull

◆ nDeep

◆ nNull

◆ nPlyFilled

◆ segList


The documentation for this class was generated from the following files: