CGEM BOSS 6.6.5.f
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)
 
void setNoInner (bool noInnerFlag)
 
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)
 
void setNoInner (bool noInnerFlag)
 

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
 
bool _noInner
 

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 _noInner = false;
79}

◆ ~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 595 of file MdcSegGrouper.cxx.

595 {
596 //************************************************************************
597 //*** Calc. z and cot(theta) for stereo
598 int debug = false;
599 if (11 == _debug ) debug = true;
600 if (debug) std::cout<< "-----calculate group param by hit-----"<<std::endl;
601 MdcLine span(50);
602 MdcLine spanFit(50);
603
604 int nHit = 0;
605 if (debug) std::cout<< "nToUse="<<nToUse<<std::endl;
606 for (int iPly = 0; iPly < nToUse; iPly++) {
607 if (segGroup[iPly] == 0) continue; // skipping this slayer
608 nSegFit++;
609 MdcSegInfoSterO *segInfo = dynamic_cast<MdcSegInfoSterO*> (segGroup[iPly]->info());
610
611 if(debug) std::cout<< "nHit in segment="<<segGroup[iPly]->nHit()<<std::endl;
612 for (int ii=0,iHit=0; ii<segGroup[iPly]->nHit(); ii++){
613
614 if(debug)std::cout<< " calcParByHits ("<< segGroup[iPly]->hit(iHit)->mdcHit()->layernumber()<<","<<segGroup[iPly]->hit(iHit)->mdcHit()->wirenumber()<<")";
615 //if(segGroup[iPly]->hit(iHit)->mdcHit()->layernumber()<4) continue;//yzhang TEMP TEST 2011-08-01
616
617 int szCode = segInfo->zPosition(*(segGroup[iPly]->hit(iHit)),par,&span,iHit,segGroup[iPly]->bunchTime(),Bz);
618 if(debug)std::cout<< " szCode "<<szCode;
619 if(szCode>0&&debug) std::cout<< iHit<<" s "<< span.x[iHit]<< " z "<<span.y[iHit] <<" sigma "<<span.sigma[iHit];
620 if(debug)std::cout<<std::endl;
621
622 spanFit.x[nHit]=span.x[iHit];
623 spanFit.y[nHit]=span.y[iHit];
624 //spanFit.sigma[nHit]=span.sigma[iHit];
625 spanFit.sigma[nHit]=1.;
626 if(debug)std::cout<< std::endl;
627 iHit++;
628 if(szCode>0) nHit++;
629 }
630 }
631
632 if(debug)std::cout<< __FILE__ << " " << __LINE__ << " nHit "<< nHit<<std::endl;
633 if (nHit>0) spanFit.fit(nHit);
634 else return -999;
635
636 param[0] = spanFit.intercept;
637 param[1] = spanFit.slope;
638 if(debug)std::cout<< "nHit "<<nHit<<" intercept(z0) "<<param[0]<< " slope(ct) " << param[1] <<std::endl;
639
640 qual = 2.*nHit - spanFit.chisq/(spanFit.nPoint - 2);
641 if(debug)std::cout<< "chisq "<<spanFit.chisq<<" qual "<<qual<<std::endl;
642
643 return spanFit.chisq;
644}
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 480 of file MdcSegGrouper.cxx.

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

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

469 {
470 //************************************************************************
471 for(int islayer=0; islayer<11; islayer++){
472 for(int i=0; i<segList[islayer].length(); i++){
473 segList[islayer][i]->plotSegAll();
474 std::cout<< std::endl;
475 }
476 }
477}

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 84 of file MdcSegGrouper.cxx.

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

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

Referenced by nextGroup().

◆ resetGap() [2/2]

void MdcSegGrouper::resetGap ( int  nGap)

◆ resetSegCounters() [1/2]

void MdcSegGrouper::resetSegCounters ( )
protected

Definition at line 263 of file MdcSegGrouper.cxx.

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

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

◆ resetSegCounters() [2/2]

void MdcSegGrouper::resetSegCounters ( )
protected

◆ setNoInner() [1/2]

void MdcSegGrouper::setNoInner ( bool  noInnerFlag)
inline

Definition at line 66 of file InstallArea/include/MdcTrkRecon/MdcTrkRecon/MdcSegGrouper.h.

66{_noInner = noInnerFlag;}

Referenced by MdcTrackList::createFromSegs().

◆ setNoInner() [2/2]

void MdcSegGrouper::setNoInner ( bool  noInnerFlag)
inline

◆ 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 413 of file MdcSegGrouper.cxx.

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

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

Referenced by nextGroup().

◆ updateGap() [2/2]

int MdcSegGrouper::updateGap ( )

Member Data Documentation

◆ _debug

◆ _gm

◆ _noInner

bool MdcSegGrouper::_noInner
protected

◆ 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: