MdcSegGrouperSt Class Reference

#include <MdcSegGrouperSt.h>

Inheritance diagram for MdcSegGrouperSt:

MdcSegGrouper List of all members.

Public Member Functions

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

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

Private Member Functions

void resetList ()
MdcSegGrouperStoperator= (const MdcSegGrouperSt &)

Detailed Description

Definition at line 29 of file MdcSegGrouperSt.h.


Constructor & Destructor Documentation

MdcSegGrouperSt::MdcSegGrouperSt ( const MdcDetector gm,
int  debug 
)

Definition at line 45 of file MdcSegGrouperSt.cxx.

References MdcSegGrouper::isValid, ganga-rec::j, MdcSegGrouper::lTestGroup, MdcSegGrouper::lTestSingle, and MdcSegGrouper::nPly().

00045                                                                  : 
00046   MdcSegGrouper(gm, gm->nStereoSuper(-1) + gm->nStereoSuper(1), debug) {
00047 //------------------------------------------------------------------------
00048 
00049     lTestGroup = true;
00050     lTestSingle = false;
00051 
00052     isValid = new bool * [nPly()];
00053     for (int j = 0; j < nPly(); j++) {
00054       isValid[j] = 0;
00055     }
00056   }

MdcSegGrouperSt::~MdcSegGrouperSt (  )  [inline]

Definition at line 33 of file MdcSegGrouperSt.h.

00033 { };


Member Function Documentation

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

Definition at line 585 of file MdcSegGrouper.cxx.

References MdcSegGrouper::_debug, MdcLine::chisq, MdcLine::fit(), MdcSeg::hit(), MdcSeg::info(), MdcLine::intercept, MdcHit::layernumber(), MdcHitUse::mdcHit(), MdcSeg::nHit(), MdcLine::nPoint, MdcLine::sigma, MdcLine::slope, MdcHit::wirenumber(), MdcLine::x, MdcLine::y, and MdcSegInfoSterO::zPosition().

Referenced by MdcSegGrouper::combineSegs().

00585                                                                                                                                                     {
00586   //************************************************************************
00587   //*** Calc. z and cot(theta) for stereo 
00588   int debug = false;
00589   if (11 == _debug ) debug = true;
00590   if (debug) std::cout<< "-----calculate group param by hit-----"<<std::endl;
00591   MdcLine span(50);
00592   MdcLine spanFit(50);
00593 
00594   int nHit = 0;
00595   if (debug) std::cout<< "nToUse="<<nToUse<<std::endl;
00596   for (int iPly = 0; iPly < nToUse; iPly++) {
00597     if (segGroup[iPly] == 0) continue;   // skipping this slayer
00598     nSegFit++;
00599     MdcSegInfoSterO *segInfo = dynamic_cast<MdcSegInfoSterO*> (segGroup[iPly]->info());
00600 
00601     if(debug) std::cout<< "nHit in segment="<<segGroup[iPly]->nHit()<<std::endl;
00602     for (int ii=0,iHit=0; ii<segGroup[iPly]->nHit(); ii++){
00603 
00604       if(debug)std::cout<< " calcParByHits ("<< segGroup[iPly]->hit(iHit)->mdcHit()->layernumber()<<","<<segGroup[iPly]->hit(iHit)->mdcHit()->wirenumber()<<")";
00605       //if(segGroup[iPly]->hit(iHit)->mdcHit()->layernumber()<4) continue;//yzhang TEMP TEST 2011-08-01 
00606 
00607       int szCode = segInfo->zPosition(*(segGroup[iPly]->hit(iHit)),par,&span,iHit,segGroup[iPly]->bunchTime(),Bz);
00608       if(debug)std::cout<< " szCode "<<szCode;
00609       if(szCode>0&&debug) std::cout<< iHit<<" s "<< span.x[iHit]<< " z "<<span.y[iHit] <<" sigma "<<span.sigma[iHit];
00610       if(debug)std::cout<<std::endl;
00611 
00612       spanFit.x[nHit]=span.x[iHit];
00613       spanFit.y[nHit]=span.y[iHit];
00614       //spanFit.sigma[nHit]=span.sigma[iHit];
00615       spanFit.sigma[nHit]=1.;
00616       if(debug)std::cout<< std::endl;
00617       iHit++;
00618       if(szCode>0) nHit++; 
00619     }
00620   }
00621 
00622   if(debug)std::cout<< __FILE__ << "   " << __LINE__ << " nHit  "<< nHit<<std::endl;
00623   if (nHit>0) spanFit.fit(nHit);
00624   else return -999;
00625 
00626   param[0] = spanFit.intercept;
00627   param[1] = spanFit.slope;
00628   if(debug)std::cout<< "nHit "<<nHit<<" intercept(z0) "<<param[0]<< " slope(ct) " << param[1] <<std::endl;
00629 
00630   qual = 2.*nHit - spanFit.chisq/(spanFit.nPoint - 2);
00631   if(debug)std::cout<< "chisq "<<spanFit.chisq<<" qual "<<qual<<std::endl;
00632 
00633   return spanFit.chisq;
00634 } 

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

Definition at line 475 of file MdcSegGrouper.cxx.

References MdcSegGrouper::_debug, MdcSegInfo::errmat(), ers::error, genRecEmupikp::i, MdcSeg::info(), MdcSegInfo::inverr(), ganga-rec::j, mdcTwoInv(), mdcTwoVec(), mdcWrapAng(), MdcSeg::nHit(), MdcSegInfo::par(), and MdcSegInfo::parIsAngle().

Referenced by MdcSegGrouper::combineSegs().

00476                                                              {
00477   //************************************************************************
00478   if (11 == _debug) std::cout<< "-----calculate group param by segment param-----"<<std::endl;
00479   double wgtmat[3], wgtinv[3];
00480   double wgtpar[2];
00481   double temvec[2], diff[2];
00482   // Calculate track & chisq for this group 
00483   int nhit = 0;
00484   wgtmat[0] = wgtmat[1] = wgtmat[2] = wgtpar[0] = wgtpar[1] = 0.0;
00485 
00486   int iPly;
00487   for (iPly = 0; iPly < nToUse; iPly++) {
00488     if (11 == _debug) {
00489       //if (!lSeed) //if (segGroup[iPly] == 0) cout << "ply empty: " << iPly << "\n";
00490     }
00491     if (segGroup[iPly] == 0) continue;   // skipping this slayer
00492     nSegFit++;
00493     MdcSegInfo *segInfo = segGroup[iPly]->info();
00494     // Accumulate sums
00495     for (int i = 0; i < 3; i++) wgtmat[i] += (segInfo->inverr())[i];
00496     for (int k = 0; k < 2; k++) {
00497       param[k] = segInfo->par(k);
00498       //zhangy add
00499       if (segInfo->parIsAngle(k)) {
00500         param[k] = mdcWrapAng(seedAngle[k], param[k]);
00501       }
00502     }
00503     // Multiply by weight matrix.
00504     mdcTwoVec( segInfo->inverr(), param, temvec );
00505     wgtpar[0] += temvec[0];
00506     wgtpar[1] += temvec[1];
00507     if(11 == _debug) {
00508       std::cout<<0<<": param "<<param[0]<<" inverr "<< segInfo->inverr()[0]<<" par*W "<<temvec[0]<<std::endl;
00509       std::cout<<1<<": param "<<param[1]<<" "<<1/param[1]<<" inverr "<< segInfo->inverr()[1]<<" par*W "<<temvec[1]<<std::endl;
00510       std::cout<< "   " <<std::endl;
00511     }
00512     nhit += segGroup[iPly]->nHit();
00513   }
00514 
00515   // And the fitted parameters are . . . 
00516   int error = mdcTwoInv(wgtmat,wgtinv);
00517   if (error && (11 == _debug)) {
00518     cout << "ErrMsg(warning) " 
00519       <<  "failed matrix inversion in MdcTrackList::combineSegs" << endl;
00520     //continue;
00521     return -999.;
00522   }
00523   mdcTwoVec( wgtinv, wgtpar, param );
00524   if(11 == _debug) {
00525     std::cout<< " param of wgtinv * wgtpar" << std::endl;
00526     std::cout<<0<<": param "<<param[0]<< std::endl;
00527     std::cout<<1<<": param "<<param[1]<<" "<<1/param[1]<< std::endl;
00528     std::cout<< "   " <<std::endl;
00529   }
00530 
00531   //param[0]= 5.312286;
00532   //param[1]= -0.006;
00533   //std::cout<< "set param   " <<param[0]<< "   "<<param[1]<<std::endl;
00534   if(11 == _debug)cout<<endl<<"-- Calculate track & chisq for this group "<<endl;
00535 
00536   // Calc. chisq. = sum( (Vi - V0) * W * (Vi - V0) ) 
00537   // W = weight, Vi = measurement, V0 = fitted param. 
00538   double chisq = 0.0;
00539   for (iPly = 0; iPly < nToUse; iPly++) {
00540     if (segGroup[iPly] == 0) continue;   // skipping this slayer
00541     MdcSegInfo *segInfo = segGroup[iPly]->info();
00542     for (int j = 0; j < 2; j++) {
00543       double temPar;
00544       if (segInfo->parIsAngle(j)) {
00545         temPar = mdcWrapAng(seedAngle[j], segInfo->par(j));
00546       } else {
00547         temPar = segInfo->par(j);
00548       }
00549       if(11 == _debug) {
00550         std::cout<<" segPar"<<j<<" "<<temPar<<  std::endl;
00551       }
00552       diff[j] = temPar - param[j];
00553     }
00554 
00555     if(11 == _debug) {
00556       std::cout<<"inverr " <<segInfo->inverr()[0]<<" "
00557         <<segInfo->inverr()[1] <<" "<<segInfo->inverr()[2] <<  std::endl;
00558       std::cout<<"errmat " <<segInfo->errmat()[0]<< " "
00559         <<segInfo->errmat()[1] << " "<<segInfo->errmat()[2] <<  std::endl;
00560       std::cout<<"diff " <<diff[0]<<" "<<diff[1]<<" temvec "<<temvec[0]<<" "<<temvec[1]<< std::endl;
00561       std::cout<<  std::endl;
00562     }
00563     mdcTwoVec( segInfo->inverr(), diff, temvec);
00564 
00565     chisq += diff[0] * temvec[0] + diff[1] * temvec[1];
00566 
00567     if(11 == _debug){
00568       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;
00569     }
00570   }
00571 
00572   double chiDof = chisq/(2.*nSegFit - 2.);
00573   if (11 == _debug) {
00574     cout << "segment:"<<endl<<" chiDof "<<chiDof<<" chisq "<< chisq << " nhit " << nhit << " phi0/z0 " << 
00575       param[0] << " cpa/cot " << param[1] << " qual "<<(2. * nhit - chiDof) <<endl;
00576   }
00577 
00578   qual = 2. * nhit - chiDof;
00579 
00580   //if(is3d) std::cout<< __FILE__ << "   " << " z0 "<<param[0] << " ct "<<param[0] <<std::endl;//zhange TEMP test 2011-05-06 
00581   return chisq;
00582 }

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

Definition at line 270 of file MdcSegGrouper.cxx.

References MdcSegGrouper::_debug, TrkRecoTrk::bField(), BField::bFieldZ(), MdcSegGrouper::calcParByHits(), MdcSegGrouper::calcParBySegs(), TrkRecoTrk::fitResult(), g_maxSegChisqAx, g_maxSegChisqSt, TrkFit::helix(), genRecEmupikp::i, MdcSeg::info(), iprint, MdcSegGrouper::nextGroup(), MdcSegGrouper::nPly(), MdcSegInfo::par(), MdcSegInfo::parIsAngle(), MdcSeg::plotSegAll(), MdcSegGrouper::resetComb(), MdcSegGrouper::storePar(), MdcTrack::track(), and MdcSegGrouper::transferHits().

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

00271                                                                                {
00272   //************************************************************************/
00273   // forms track from list of segs; does 2-param fit (either r-phi from origin
00274   //  or s-z) and picks best combination.
00275   if (3 == _debug) std::cout<<std::endl<<  "=====MdcSegGrouper::combineSegs=====" <<std::endl;
00276   bool lSeed = (seed != 0); // no seed for stereo group
00277 
00278   int success = 0;
00279   double qual;
00280   double qualBest = -1000.;
00281   int nSegFit = 0;
00282   int nSegBest = 0;
00283   //int nHitBest = 0;
00284   double param[2];
00285   double paramBest[2];
00286   double chiBest = 9999.;
00287   int nToUse = nPly();
00288   if (lSeed) nToUse++;   // seed isn't included in the segs list
00289   MdcSeg **segGroup;
00290   MdcSeg **segGroupBest;
00291   segGroup = new MdcSeg * [nToUse];
00292   segGroupBest = new MdcSeg * [nToUse];
00293   //  static int counter = 0;
00294   //  counter++;
00295   //  cout << counter << endl;
00296 
00297   //bool is3d = (seed==NULL);//zhange TEMP test 2011-05-06 
00298 
00299   // Loop over all combinations of segs consistent with seed (including gaps)
00300   if ((3 == _debug)&&lSeed) {
00301     std::cout<<"seed segment: ";
00302     seed->plotSegAll();
00303     std::cout<< std::endl;
00304   }
00305   resetComb(seed); 
00306 
00307   // Save seed params (if angles) for later use as reference angle in 
00308   //    mdcWrapAng (don't really have to test whether it's an angle, but I do)
00309   double seedAngle[2] = {0.,0.};
00310   if (lSeed) {
00311     if (seed->info()->parIsAngle(0)) seedAngle[0] = seed->info()->par(0);
00312     if (seed->info()->parIsAngle(1)) seedAngle[1] = seed->info()->par(1);
00313   }
00314 
00315   int iprint = ( 3 == _debug);
00316   int nInGroup = 0;
00317   while ( (nInGroup = nextGroup(segGroup, iprint)) != 0) {
00318 
00319     if (lSeed) {
00320       segGroup[nToUse-1] = seed;
00321       nInGroup++;
00322     }
00323     if (nInGroup < 0) continue;
00324     if (nInGroup < 2) break;
00325     if (nInGroup < nSegBest) break;
00326 
00327     if (3 == _debug || 11 == _debug) {
00328       cout << endl <<"-----found a segment group by nextGroup()----- nInGroup "<<nInGroup<<" nToUse "<<nToUse<<endl;
00329       for(int ii=0; ii<nToUse; ii++){ if(segGroup[ii]) {segGroup[ii]->plotSegAll(); cout<<endl;} }
00330       //cout << endl <<"--calc. parameters of this segment group"<<endl;
00331     }
00332 
00333     double chisq =-999.;
00334     nSegFit=0;
00335 
00336     if(lSeed){
00337       //2d
00338       chisq = calcParBySegs(segGroup, seedAngle, nToUse, qual, nSegFit, param);
00339     }else{
00340       if (combineByFitHits == 0){
00341         chisq = calcParBySegs(segGroup, seedAngle, nToUse, qual, nSegFit, param);
00342       }else{
00343         //3d 
00344         const TrkFit* tkFit = trk->track().fitResult();
00345         double Bz = trk->track().bField().bFieldZ();//??
00346         TrkExchangePar par = tkFit->helix(0.0);
00347         //par.print(std::cout);
00348         if (tkFit != 0) chisq = calcParByHits(segGroup, nToUse, par, qual,nSegFit, param, Bz);
00349         //std::cout<< __FILE__ << "   " << __LINE__ << " calcParByHits"<<std::endl;
00350         if(chisq<=0){
00351           //std::cout<< "calcParByHits failed! calc. by seg" <<std::endl;
00352           chisq = calcParBySegs(segGroup, seedAngle, nToUse, qual, nSegFit, param);
00353         }
00354       }
00355     }
00356 
00357 
00358     if (chisq < 0.) continue;//yzhang add
00359     double chiDof = chisq/(2.*nSegFit - 2.);
00360 
00361     if (g_maxSegChisqAx && lSeed ) { g_maxSegChisqAx->fill(chiDof); } //yzhang hist cut
00362     if (g_maxSegChisqSt && !lSeed) { g_maxSegChisqSt->fill(chiDof); } //yzhang hist cut
00363 
00364     //std::cout<<  " chisq  " << chisq<< " chi2dof "<<chiDof<<std::endl;
00365 
00366     if (3 == _debug || 11 == _debug) {
00367       std::cout<< endl<<"chisq "<<chisq<<" nSegFit " << nSegFit<< " chiDof "<<chiDof<<std::endl;
00368       if(chiDof > maxSegChisqO) {
00369         cout << "***** DROP this group by chiDof "<<chiDof<<" > maxSegChisqO:"<<maxSegChisqO<<endl;
00370       }else{
00371         cout << "***** KEEP this group by chiDof "<<chiDof<<" <= maxSegChisqO:"<<maxSegChisqO<<endl;
00372       }
00373     }
00374     // Chisq test
00375     if (chiDof > maxSegChisqO) continue;
00376 
00377     success = 1;
00378     if (qual > qualBest) {
00379       qualBest = qual;
00380       nSegBest = nSegFit;
00381       //nHitBest = nhit;
00382       paramBest[0] = param[0];
00383       paramBest[1] = param[1];
00384       chiBest = chisq;
00385       for (int i = 0; i < nToUse; i++) {
00386         segGroupBest[i] = segGroup[i];
00387       }
00388       if (3 == _debug && 11 == _debug) std::cout<<"Keep as best group. param: phi0/z0 "
00389         <<paramBest[0]<< " cpa/ct "<<paramBest[1]<<  std::endl;
00390     }// end test on qual
00391   }
00392 
00393   if (success == 1) {
00394     if(3 == _debug || 11 == _debug) {
00395       std::cout<< endl<<"-----Parameter best group-----    "<<std::endl;
00396       std::cout<< "paramBest "<<paramBest[0]<<" "<<paramBest[1]<< " chiBest " << chiBest<< std::endl;
00397     }
00398     // Store the results in a track, possibly creating it in the process
00399     trk = storePar(trk, paramBest, chiBest, context, t0);
00400     transferHits(trk, nToUse, segGroupBest);     // Store hits with track
00401   }
00402   delete [] segGroupBest;
00403   delete [] segGroup;
00404   return success;
00405 } 

void MdcSegGrouper::dumpSegList (  )  [inherited]

Definition at line 464 of file MdcSegGrouper.cxx.

References genRecEmupikp::i, and MdcSegGrouper::segList.

Referenced by MdcTrackList::createFromSegs().

00464                                {
00465   //************************************************************************
00466   for(int islayer=0; islayer<11; islayer++){
00467     for(int i=0; i<segList[islayer].length(); i++){
00468       segList[islayer][i]->plotSegAll();
00469       std::cout<< std::endl;
00470     }
00471   }
00472 }

void MdcSegGrouperSt::fillWithSegs ( const MdcSegList inSegs,
const MdcTrack axialTrack 
)

Definition at line 69 of file MdcSegGrouperSt.cxx.

References MdcSegGrouper::_debug, MdcSegGrouper::_gm, MdcSegInfoSterO::calcStereo(), MdcSegInfoSterO::ct(), MdcSegParams::ctcut, TrkExchangePar::d0(), MdcSuperLayer::delPhi(), GmsList::first(), TrkRecoTrk::fitResult(), g_ctCut, g_z0Cut, TrkFit::helix(), GmsListLink::next(), MdcDetector::nSuper(), TrkExchangePar::omega(), MdcSegList::oneList(), MdcSeg::phi(), TrkExchangePar::phi0(), phi0, MdcSegWorks::phiArg, MdcSegWorks::phiAx, MdcSeg::plotSeg(), MdcSuperLayer::rEnd(), resetList(), MdcSegGrouper::segList, MdcSeg::segPar(), MdcSeg::setInfo(), BesAngle::setRad(), MdcSeg::superlayer(), MdcTrack::track(), MdcSuperLayer::whichView(), MdcSegWorks::wirLen2inv, MdcSegInfoSterO::z0(), MdcSegParams::z0cut, and MdcSuperLayer::zEnd().

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

00070                            {
00071   //------------------------------------------------------------------------
00072   // Prepare for stereo finding 
00073   // Load segments consistent with input track (already in phi order)
00074   //  Assuming from origin
00075   int nsuper = _gm->nSuper();
00076   resetList();    // Clear existing lists 
00077   if(3==_debug) std::cout<<std::endl<< "=====MdcSegGrouperSt::fillWithSegs====="<<std::endl;
00078 
00079   const TrkFit* tkFit = track->track().fitResult();
00080   if (tkFit == 0) return;
00081   TrkExchangePar par = tkFit->helix(0.0);
00082   double kap = 0.5 * par.omega();
00083   double phi0 = par.phi0();
00084   double d0 = par.d0();
00085   MdcSegWorks segStuff;   // holds some calculated values to pass to segInfo
00086 
00087   bool lStraight = false;
00088   if (fabs(kap) < 1.e-9) { lStraight = true; }
00089 
00090   double rCurl = 99999999.;
00091   if (!lStraight) {
00092     rCurl = fabs(d0 + 1./kap);
00093   }
00094 
00095   // Create an info object to store the info (will be owned by seg)
00096   MdcSegInfoSterO *info = new MdcSegInfoSterO;
00097 
00098   // Loop over superlayers
00099   for (int isuper = 0; isuper < nsuper; isuper++) {
00100     const GmsList *inList = inSegs->oneList(isuper);
00101 
00102     if (inList->count() == 0) continue;
00103 
00104     MdcSeg *inSeg = (MdcSeg *) inList->first();
00105     // Only load stereo segments
00106     if (inSeg->superlayer()->whichView() == 0) continue;
00107 
00108     // Calculate r & phi (approx) of axial track at slayer
00109     double radius = inSeg->superlayer()->rEnd();  
00110     if (radius >= rCurl) break;
00111     double phiArg = kap * radius;
00112     if (lStraight) phiArg = d0 / radius;
00113     if (phiArg < -1.0) phiArg = -1.0;
00114     else if (phiArg > 1.0) phiArg = 1.0;
00115     segStuff.phiArg = phiArg;
00116     segStuff.phiAx.setRad(phi0 + asin(phiArg));  // Approx??!!!!
00117     BesAngle delPhi( fabs(inSeg->superlayer()->delPhi()) );
00118     //BesAngle maxPhiA = segStuff.phiAx + delPhi + 0.05;  // allow a little slop
00119     //BesAngle minPhiA = segStuff.phiAx - delPhi - 0.05;
00120     BesAngle maxPhiA = segStuff.phiAx + delPhi + 0.1;  // allow a little slop yzhang 2011-06-15 
00121     BesAngle minPhiA = segStuff.phiAx - delPhi - 0.1;//yzhang TEMP 2011-06-15 
00122     //yzhang FIXME
00123     double maxPhi = maxPhiA;
00124     double minPhi = minPhiA;
00125     bool phitest = (maxPhi > minPhi);
00126     //phitest = false => the valid range straddles phi = 0, so skip 
00127     //checking against phimin and phimax
00128 
00129     //Calc some things needed in segInfo::calcStereo
00130     segStuff.wirLen2inv = 1./ (inSeg->superlayer()->zEnd() * 
00131         inSeg->superlayer()->zEnd() );
00132     // Loop over segs in superlayer
00133     if(_debug==3) std::cout<<std::endl<<"Pick segment by phi from " <<minPhi<< " to "<<maxPhi<<" phiAx="<<segStuff.phiAx<<" delPhi="<<delPhi<<std::endl;
00134     for ( ; inSeg != 0; inSeg = (MdcSeg *) inSeg->next()) {
00135       // Test if within allowed phi range
00136       BesAngle phiSeg(inSeg->phi()); 
00137 
00138       if(_debug==3){ inSeg->plotSeg(); }
00139       if (phitest) {
00140         if (phiSeg < minPhi){
00141           if (_debug ==3){std::cout << " CUT by phi "<<phiSeg
00142             << "<min "<<minPhi << std::endl;}//yzhang debug     
00143           continue;  // not up to candidates
00144         }
00145         else if(phiSeg > maxPhi) {
00146           if (_debug ==3){std::cout << " CUT by phi "<<phiSeg
00147             <<">max "<<maxPhi<< std::endl;}//yzhang debug       
00148           break;  // past candidates
00149         }
00150       } else { // !phitest
00151         if (phiSeg > maxPhi && phiSeg < minPhi) {
00152           if (_debug ==3){std::cout << "!phitest "<<phiSeg
00153             <<" max "<<maxPhi<< " min "<<minPhi << std::endl;}//yzhang debug    
00154           continue;
00155         }
00156       }
00157 
00158       if(_debug == 3) std::cout<<" **KEEP seg phi="<<phiSeg<<  std::endl;
00159 
00160       //std::cout<< __FILE__ << "   " << __LINE__ << " MdcSegGrouperSt::fillWithSegs call calcStereo "<<std::endl;
00161       int isBad = info->calcStereo(inSeg, track->track(), segStuff);  
00162 
00163       if (isBad) {
00164         if (_debug ==3){std::cout << " CUT by calcStereo isBad!"<<std::endl;}
00165         continue;
00166       }
00167       // Test for sensible values of ct and z0
00168       if (g_z0Cut) {g_z0Cut->fill(info->z0());}
00169       if (g_ctCut) {g_ctCut->fill(info->ct());}
00170       if (fabs(info->ct()) > inSeg->segPar()->ctcut) {
00171         if (_debug ==3){std::cout << " CUT by ctcut! "
00172           <<fabs(info->ct())<<" > cut:"<< inSeg->segPar()->ctcut<<" "<<phiSeg<<std::endl; }
00173         continue;
00174       }
00175       if (fabs(info->z0()) > inSeg->segPar()->z0cut){
00176         if (_debug ==3){std::cout << " CUT by z0cut! "
00177           <<fabs(info->z0())<<" >cut "<< inSeg->segPar()->z0cut<<" "<<phiSeg<<std::endl; }
00178         continue;
00179       }
00180       inSeg->setInfo(info);
00181       info = new MdcSegInfoSterO;      
00182       segList[isuper].append(inSeg);
00183       //if(_debug==3)std::cout<<" APPEND this stereo seg"<<  std::endl;
00184 
00185     }  // end loop over new segs
00186   }  //  end loop over superlayers
00187   delete info;
00188 }

int MdcSegGrouperSt::incompWithGroup ( MdcSeg **  segGroup,
const MdcSeg testSeg,
int  iply 
) [virtual]

Implements MdcSegGrouper.

Definition at line 228 of file MdcSegGrouperSt.cxx.

References MdcSegGrouper::_debug, MdcSegInfo::arc(), MdcSegGrouper::combList, MdcSegInfoSterO::ct(), MdcSegGrouper::currentSeg, MdcSegParams::delCtCut, MdcSegParams::delZ0Cut, first, g_delCt, g_delZ0, genRecEmupikp::i, MdcSeg::info(), MdcSegGrouper::leaveGap, MdcSeg::plotSeg(), MdcSeg::segPar(), and MdcSegInfoSterO::z0().

00229               {
00230   //-------------------------------------------------------------------------
00231   // Test that the latest seg lies more or less in a line with the others
00232   //  Currently requiring line to point to IP; also require rough 
00233   //  agreement in ct.
00234   // iply = depth index of current seg (not yet in group)
00235 
00236   int i;
00237   // Find first segment already in group
00238   for (i = iply - 1; i > 0; i--) {
00239     if (!leaveGap[i]) break;
00240   }
00241   const MdcSeg *first = (*combList[i])[currentSeg[i]];
00242 
00243   // Test ct
00244   MdcSegInfoSterO* firstInfo = (MdcSegInfoSterO *) first->info(); 
00245   MdcSegInfoSterO* newInfo = (MdcSegInfoSterO *) testSeg->info(); 
00246 
00247   if (g_delCt) {g_delCt->fill( firstInfo->ct() - newInfo->ct());}//yzhang hist cut
00248   if (fabs( firstInfo->ct() - newInfo->ct() ) > 
00249       testSeg->segPar()->delCtCut) {
00250     if(_debug==3){
00251       cout << "---MdcSegGrouperSt Ct CUT!" << endl;//yzhang debug
00252       std::cout<<"first:"; first->plotSeg(); std::cout<<std::endl;
00253       std::cout<<"test:"; testSeg->plotSeg();std::cout<<std::endl;
00254       std::cout << "first.ct "<< firstInfo->ct()
00255         <<" test.ct "<<newInfo->ct()
00256         <<" delta ct "<<firstInfo->ct() - newInfo->ct()
00257         <<" Cut "<<testSeg->segPar()->delCtCut << std::endl;//yzhang debug
00258 
00259       std::cout<<"--- "<<  std::endl;
00260     } 
00261     return -1;
00262   }else{
00263   }
00264 
00265   double arcFirst = firstInfo->arc();
00266   double arcNew = newInfo->arc();
00267   double zFirst = firstInfo->z0() + firstInfo->ct() * arcFirst;
00268   double zNew = newInfo->z0() + newInfo->ct() * arcNew; 
00269   // project line from IP through 1st seg to new seg
00270   double zProj = zFirst / arcFirst * arcNew;
00271   if (g_delZ0) {g_delZ0->fill( zProj - zNew);}//yzhang hist cut
00272 
00273   if (fabs(zProj - zNew) > testSeg->segPar()->delZ0Cut) {
00274     if(3==_debug){
00275       cout << "MdcSegGrouperSt delZ0Cut  not incompWithGroup CUT!" << endl;//yzhang debug 
00276       testSeg->plotSeg(); 
00277       std::cout<<" zProj "<< zProj << " zNew "<< zNew<< " CUT! "
00278         << testSeg->segPar()->delZ0Cut <<  std::endl;
00279     }
00280     return -1;
00281   }
00282 
00283   /*
00284      double delZ = newInfo->z0() + newInfo->ct() * arcNew - zFirst;
00285      double z0 = zFirst - arcFirst * delZ / (arcNew - arcFirst);
00286      if (fabs(z0) > testSeg->segPar()->delZ0Cut)return -1;
00287 
00288      for (i = iply - 1; i > 0; i--) {
00289      if (segGroup[i] != 0) break;
00290      }
00291      const MdcSeg *last = segGroup[i];
00292      MdcSegInfoSterO* lastInfo = (MdcSegInfoSterO *) last->info(); 
00293 
00294   // Test that slope from last segment to new one is roughly = slope from 
00295   //   first seg to last
00296   double arcLast = lastInfo->arc();
00297   double arcFirst = firstInfo->arc();
00298   double arcNew = newInfo->arc();
00299 
00300   double delZold = lastInfo->z0() - firstInfo->z0() + 
00301   lastInfo->ct() * arcLast - firstInfo->ct() * arcFirst;
00302   double delArcold = arcLast - arcFirst;
00303   double delZnew = newInfo->z0() - lastInfo->z0() + 
00304   newInfo->ct() * arcNew - lastInfo->ct() * arcLast;
00305   double delArcnew = arcNew - arcLast;
00306   double p1 = delZold * delArcnew;
00307   double p2 = delZnew * delArcold;
00308 
00309   cout << " test: " << p1 << "  " << p2 << endl;
00310 
00311   if (fabs(p2 - p1) > 0.02) return -1;
00312 
00313 */
00314   return 0;
00315 }

int MdcSegGrouperSt::incompWithSeg ( const MdcSeg refSeg,
const MdcSeg testSeg 
) [virtual]

Implements MdcSegGrouper.

Definition at line 220 of file MdcSegGrouperSt.cxx.

00221                            {
00222   //-------------------------------------------------------------------------
00223 
00224   return 0;
00225 }

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

Definition at line 83 of file MdcSegGrouper.cxx.

References MdcSegGrouper::combList, MdcSegInfoSterO::ct(), MdcSegGrouper::currentSeg, MdcSegGrouper::firstBad, MdcSegGrouper::firstGood, MdcSegGrouper::incompWithGroup(), MdcSegGrouper::isValid, MdcSegGrouper::leaveGap, MdcSegGrouper::lTestGroup, MdcSegGrouper::lTestSingle, MdcSegGrouper::maxNull, MdcSegGrouper::nDeep, MdcSegGrouper::nNull, MdcSegGrouper::nPlyFilled, MdcSegGrouper::resetGap(), MdcSegGrouper::resetSegCounters(), and MdcSegGrouper::updateGap().

Referenced by MdcSegGrouper::combineSegs().

00083                                                               {
00084   //------------------------------------------------------------------------
00085 
00086   // Loop over the superlayers, moving to next valid seg for each if necessary
00087   // First, loop over the slayers w/o good segs, filling segGroup w/ 0
00088   int iply;
00089   for (iply = nPlyFilled; iply < nDeep; iply++) {
00090     segGroup[iply] = 0;
00091   }
00092 
00093 restart:
00094   if (printit) cout <<endl<< "MdcSegGrouper::nextGroup starting group finder, nply = " << nPlyFilled << endl;
00095   int nFound = 0;
00096   bool incrementNext = true;
00097   //int nSegUsed;//yzhang 2010-05-21 
00098   for (iply = 0; iply < nPlyFilled; iply++) {
00099     segGroup[iply] = 0;
00100     if (!incrementNext && currentSeg[iply] >= firstGood[iply]) {
00101       if(printit) std::cout<< " reach end of list, break." << iply<< std::endl;
00102       break;
00103     }
00104     //if (nSegUsed > segPar.nSegUsedNextGroup) break;
00105     if (leaveGap[iply]) {
00106       if(printit) std::cout<< "  leaveGap  " <<std::endl;
00107       // This ply is currently a gap; move on.
00108       if (iply == nPlyFilled - 1 && incrementNext) {
00109         // we've exhausted this gap group; start another
00110         iply = -1;
00111         resetSegCounters();
00112         int lDone = updateGap();
00113         if (lDone) {
00114           // all gap groups for nNull exhausted; increment nNull
00115           nNull++;
00116           if (nNull > maxNull) return 0;  // All done 
00117           resetGap(nNull);
00118           updateGap();
00119         } // end if lDone
00120       }  //end if exhausted gap group
00121       continue;
00122     }
00123     incrementNext = false;
00124 
00125     // Loop through the segs in this ply until valid one found
00126     while (1) {
00127       currentSeg[iply]++;
00128       if (currentSeg[iply] == firstBad[iply]) {   // reached end of segs
00129         incrementNext = true;
00130         currentSeg[iply] = firstGood[iply];
00131         if(printit) { std::cout<< "reach end of segs  "<<std::endl; }
00132         if (iply == nPlyFilled - 1) {  
00133           // we've exhausted this gap group; start another
00134           iply = -1;
00135           resetSegCounters();
00136           int lDone = updateGap();
00137           if (lDone) {
00138             // all gap groups for nNull exhausted; increment nNull
00139             nNull++;
00140             if (nNull > maxNull) {
00141               if(printit) { std::cout<<endl<< " All done!  "<<std::endl; }
00142               return 0;  // All done
00143             }
00144             resetGap(nNull);
00145             updateGap();
00146           } // end if lDone
00147         }  //end if exhausted gap group
00148         break;
00149       }  // end reached end of segs
00150 
00151       if(printit){
00152         std::cout<< "ply " << iply<< " seg "<<currentSeg[iply]<<": ";
00153         (*combList[iply])[currentSeg[iply]]->plotSeg();
00154         if((*combList[iply])[currentSeg[iply]]->superlayer()->whichView()!= 0){
00155           MdcSegInfoSterO* info = (MdcSegInfoSterO *) (*combList[iply])[currentSeg[iply]]->info();
00156           std::cout<< " ct " << info->ct();
00157         }
00158       }
00159 
00160       //yzhang 09-09-28 delete
00161       if( (*combList[iply])[currentSeg[iply]]->segUsed()) {
00162         if(printit) {
00163           std::cout<< std::endl<<" Used??";
00164           (*combList[iply])[currentSeg[iply]]->plotSeg();
00165         }
00166         if(printit) { std::cout<< " segUsed! SKIP "<<std::endl; }
00167         continue;  //yzhang 2010-05-21 add
00168         //nSegUsed++;
00169       }
00170 
00171       // Test this seg for validity
00172       if (lTestSingle) {
00173         assert(isValid != 0);
00174         assert(isValid[iply] != 0);
00175         int invalid = (isValid[iply][currentSeg[iply]] == false);
00176         if(printit) {
00177           if(invalid){ std::cout<<" invalid "<< std::endl;
00178           }else{ std::cout<<" KEEP 1 "<< std::endl; }
00179         }
00180         if (invalid) continue;
00181       }else{
00182         if(printit) std::cout<<" KEEP 2 "<< std::endl; 
00183       }
00184 
00185       // Whew.  We successfully incremented.  
00186       break;
00187 
00188     }  // end seg loop
00189   } // end ply loop
00190 
00191   // Fill segGroup with appropriate segs
00192   for (iply = 0; iply < nPlyFilled; iply++) {
00193     if (leaveGap[iply]) {
00194       segGroup[iply] = 0;
00195     } else {
00196       segGroup[iply] = (*combList[iply])[currentSeg[iply]];     
00197       if (lTestGroup && nFound > 1) {
00198         int lBad = incompWithGroup(segGroup, segGroup[iply], iply);
00199         if(printit){
00200           if(lBad) std::cout<<" incompWithGroup Bad! restart" << std::endl;
00201           //else std::cout<<" incompWithGroup Bad! restart" << std::endl;
00202         }
00203         if (lBad) goto restart;
00204       }
00205       nFound++;
00206     }
00207   }
00208 
00209   if (printit) std::cout<< "nextGoup() found " << nFound << " segment(s)"<<std::endl;
00210   return nFound;
00211 }

int MdcSegGrouper::nPly (  )  const [inline, inherited]

Definition at line 54 of file MdcSegGrouper.h.

Referenced by MdcSegGrouper::combineSegs(), MdcSegGrouperAx::MdcSegGrouperAx(), MdcSegGrouperCsmc::MdcSegGrouperCsmc(), and MdcSegGrouperSt().

00054 {return nDeep;}

MdcSegGrouperSt& MdcSegGrouperSt::operator= ( const MdcSegGrouperSt  )  [private]

void MdcSegGrouperSt::plotStereo (  )  const

Definition at line 191 of file MdcSegGrouperSt.cxx.

References MdcSegGrouper::_gm, first, ganga-rec::j, MdcDetector::nSuper(), and MdcSegGrouper::segList.

00191                                         {
00192   //-------------------------------------------------------------------------
00193   int nsuper = _gm->nSuper();
00194   int isuper;
00195   /*
00196      for (isuper = 0; isuper < nsuper; isuper++) {
00197      if (segList[isuper].length() == 0) continue;
00198 
00199      MdcSeg *inSeg = (MdcSeg *) segList[isuper].first();
00200   // Only draw stereo segments
00201   if (inSeg->superlayer()->whichView() == 0) continue;
00202   for (int j = 0 ; j < (int) segList[isuper].length(); j++) {
00203   segList[isuper][j]->plotSeg(0,orange);
00204   }
00205   }
00206   */
00207   for (isuper = 0; isuper < nsuper; isuper++) {
00208     if (segList[isuper].length() == 0) continue;
00209 
00210     MdcSeg *inSeg = (MdcSeg *) segList[isuper].first();
00211     // Only draw stereo segments
00212     //if (inSeg->superlayer()->whichView() == 0) continue;
00213     for (int j = 0 ; j < (int) segList[isuper].length(); j++) {
00214       segList[isuper][j]->plotSeg();
00215     }
00216   }
00217 
00218 }

void MdcSegGrouperSt::resetComb ( const MdcSeg seed = 0  )  [virtual]

Implements MdcSegGrouper.

Definition at line 318 of file MdcSegGrouperSt.cxx.

References MdcSegGrouper::_gm, MdcSegGrouper::combList, MdcSegGrouper::firstBad, MdcSegGrouper::firstGood, MdcDetector::firstSlay(), genRecEmupikp::i, MdcSegGrouper::isValid, MdcSegGrouper::leaveGap, MdcSegGrouper::maxNull, MdcSegGrouper::nDeep, MdcSuperLayer::next(), MdcSegGrouper::nNull, MdcSegGrouper::nPlyFilled, MdcSegGrouper::resetSegCounters(), and MdcSegGrouper::segList.

00318                                                   {
00319   //**************************************************************************
00320 
00321   // Delete existing list of valid/invalid segs
00322   if (isValid != 0) {
00323     int i;
00324     for (i = 0; i < nDeep; i++) {
00325       delete [] isValid[i];
00326       isValid[i] = 0;
00327     }
00328   }
00329 
00330   //Grab the seglist for each slayer
00331   int islay = 0;
00332   int iply = 0;
00333   nPlyFilled = 0;
00334   nNull = 0;
00335 
00336 
00337   // Set up all sorts of stuff for fast grouping of segs in nextGroup()
00338   for (const MdcSuperLayer *thisSlay = _gm->firstSlay(); thisSlay != 0;
00339       thisSlay = thisSlay->next()) {
00340     //bool noGoodYet = true;
00341     islay++;
00342     if (thisSlay->whichView() == 0) continue;
00343     firstGood[iply] = 0;
00344     firstBad[iply] = segList[islay-1].length();
00345     if (firstGood[iply] > firstBad[iply]) firstGood[iply] = firstBad[iply];
00346     if (firstGood[iply] == firstBad[iply]) {
00347       // If there are no valid segs for this ply, skip it
00348       continue;
00349     }
00350     // Associate correct seglist with this ply
00351     combList[iply] = &segList[islay-1];
00352     leaveGap[iply] = false;
00353     iply++;
00354   }
00355 
00356   nPlyFilled = iply;
00357   resetSegCounters();
00358   maxNull = nPlyFilled - 2;
00359 }

void MdcSegGrouper::resetGap ( int  nGap  )  [inherited]

Definition at line 214 of file MdcSegGrouper.cxx.

References MdcSegGrouper::gapCounter, genRecEmupikp::i, and MdcSegGrouper::nPlyFilled.

Referenced by MdcSegGrouper::nextGroup().

00214                                      {
00215   //**************************************************************************
00216 
00217   for (int i = 0; i < nPlyFilled; i++) {
00218     gapCounter[i] = nGap - 1 - i;
00219   }
00220   gapCounter[0]--; // so 1st increment will put 1st counter in right place
00221 
00222   return;
00223 }

void MdcSegGrouperSt::resetList (  )  [private]

Definition at line 59 of file MdcSegGrouperSt.cxx.

References MdcSegGrouper::_gm, genRecEmupikp::i, MdcDetector::nSuper(), and MdcSegGrouper::segList.

Referenced by fillWithSegs().

00059                                 {
00060 //------------------------------------------------------------------------
00061   // Clear existing lists for stereo finding
00062   int nsuper = _gm->nSuper();
00063   for (int i = 0; i < nsuper; i++) {
00064     segList[i].removeAll();
00065   }
00066 }

void MdcSegGrouper::resetSegCounters (  )  [protected, inherited]

Definition at line 262 of file MdcSegGrouper.cxx.

References MdcSegGrouper::currentSeg, MdcSegGrouper::firstGood, genRecEmupikp::i, and MdcSegGrouper::nPlyFilled.

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

00262                                      {
00263   //-------------------------------------------------------------------------
00264   for (int i = 0; i < nPlyFilled; i++) {
00265     currentSeg[i] = firstGood[i] - 1;
00266   }
00267 }

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

Implements MdcSegGrouper.

Definition at line 362 of file MdcSegGrouperSt.cxx.

References MdcSegGrouper::_debug, TrkHelixMaker::addZValues(), and MdcTrack::track().

00364                          {
00365   //---------------------------------------------------------------------
00366   assert (trk != 0);
00367   TrkHelixMaker maker;
00368   if(3==_debug) std::cout<< "-----storePar z0 "<<parms[0]<<" ct "<<parms[1]<<std::endl;
00369   maker.addZValues(trk->track(), parms[0], parms[1], chisq);
00370   return trk;
00371 }

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

Definition at line 408 of file MdcSegGrouper.cxx.

References MdcSegGrouper::_debug, TrkHitList::appendHit(), MdcTrack::firstLayer(), MdcTrack::hasCurled(), TrkRecoTrk::hits(), genRecEmupikp::i, MdcTrack::lastLayer(), MdcSeg::nHit(), MdcSeg::plotSegAll(), MdcLayer::rMid(), MdcTrack::setFirstLayer(), MdcTrack::setLastLayer(), MdcSeg::setUsed(), and MdcTrack::track().

Referenced by MdcSegGrouper::combineSegs().

00408                                                                             {
00409   //************************************************************************/
00410   //Move hits from segments to track hitlist
00411   // Also note first and last layers in list
00412   // Only handles Mdc segments
00413   double smallRad = 1000.;
00414   if (trk->firstLayer() != 0) smallRad = trk->firstLayer()->rMid();
00415   double bigRad = 0.;
00416   if (trk->lastLayer() != 0) bigRad = trk->lastLayer()->rMid();
00417 
00418   //yzhang 2011-05-04 
00419   //bool maintainAmbiguity = (trk->track().status()->is2d() == 0) ? false: true;
00420   //bool maintainAmbiguity = false;
00421   //std::cout<< __FILE__ << "   " << __LINE__ << " maintainAmbiguity "<<maintainAmbiguity<<std::endl;
00422 
00423   if(3 == _debug) std::cout<< endl<<"-----transferHits for this segGroup-----  " <<std::endl;
00424   for (int i = 0; i < nSegs; i++) {
00425     if (segGroup[i] == 0) continue;   // skipping this slayer
00426     if(3 == _debug) {
00427       cout << i << "  "; segGroup[i]->plotSegAll(); cout<< endl;
00428     }
00429     segGroup[i]->setUsed();  // mark seg as used
00430     for (int ihit = 0; ihit < segGroup[i]->nHit(); ihit++) {
00431       MdcHitUse *aHit = segGroup[i]->hit(ihit);
00432       const MdcLayer *layer = aHit->mdcHit()->layer();
00433       double radius = layer->rMid();
00434       if (radius < smallRad) {
00435         smallRad = radius;
00436         trk->setFirstLayer(layer);
00437       }
00438 
00439       // Assume that segs aren't added to backside of curler
00440       if (radius > bigRad && !trk->hasCurled()) {
00441         bigRad = radius;
00442         trk->setLastLayer(layer);
00443       }
00444       // Provide very crude starting guess of flightlength
00445       double flt = radius;
00446       flt += 0.000001 * (aHit->mdcHit()->x() +aHit->mdcHit()->y());
00447 
00448       aHit->setFltLen(flt);
00449 
00450       TrkHitList* theHits = trk->track().hits();
00451 
00452       if (theHits == 0) return;
00453 
00454       //theHits->appendHit(*aHit, maintainAmbiguity);
00455       theHits->appendHit(*aHit);
00456       //zhangy
00457 
00458       //std::cout<<"in MdcSegGrouper  append ok"<<std::endl;//yzhang debug
00459     }   
00460   }  // end loop over slayers
00461 } 

int MdcSegGrouper::updateGap (  )  [inherited]

Definition at line 226 of file MdcSegGrouper.cxx.

References MdcSegGrouper::gapCounter, genRecEmupikp::i, ganga-rec::j, MdcSegGrouper::leaveGap, MdcSegGrouper::nNull, and MdcSegGrouper::nPlyFilled.

Referenced by MdcSegGrouper::nextGroup().

00226                              {
00227   //**************************************************************************
00228   if (nNull == 0) return 1;
00229 
00230   for (int i = 0; i < nPlyFilled; i++) {
00231     leaveGap[i] = false;
00232   }
00233   for (int igap = 0; igap < nNull; igap++) {
00234     gapCounter[igap]++;
00235     if (gapCounter[igap] == nPlyFilled - igap) {
00236       // End of loop for this counter; look at the other counters to 
00237       //  decide where this one should be reset to.
00238       int inext = igap + 1;
00239       while (1) {
00240         if (inext >= nNull) return 1; // done with all combos
00241         if (gapCounter[inext] + inext + 1 < nPlyFilled) {
00242           // This is the right spot to reset to
00243           gapCounter[igap] = gapCounter[inext] + inext + 1 - igap;
00244           break;
00245         }
00246         inext++;
00247       } 
00248     }
00249     else {
00250       // We successfully incremented.  Quit looping and return.
00251       break;
00252     }
00253   }  // end loop over igap
00254 
00255   for (int j = 0; j < nNull; j++) {
00256     leaveGap[gapCounter[j]] = true;
00257   }
00258   return 0;
00259 
00260 }


Member Data Documentation

int MdcSegGrouper::_debug [protected, inherited]

Definition at line 96 of file MdcSegGrouper.h.

Referenced by MdcSegGrouper::calcParByHits(), MdcSegGrouper::calcParBySegs(), MdcSegGrouper::combineSegs(), fillWithSegs(), MdcSegGrouperAx::fillWithSegs(), incompWithGroup(), MdcSegGrouperAx::incompWithSeg(), MdcSegGrouper::MdcSegGrouper(), MdcSegGrouperAx::resetComb(), storePar(), and MdcSegGrouper::transferHits().

const MdcDetector* MdcSegGrouper::_gm [protected, inherited]

Definition at line 78 of file MdcSegGrouper.h.

Referenced by fillWithSegs(), MdcSegGrouperCsmc::fillWithSegs(), MdcSegGrouperAx::fillWithSegs(), MdcSegGrouper::MdcSegGrouper(), plotStereo(), resetComb(), MdcSegGrouperCsmc::resetComb(), MdcSegGrouperAx::resetComb(), resetList(), MdcSegGrouperCsmc::storePar(), and MdcSegGrouperAx::storePar().

HepAList<MdcSeg>** MdcSegGrouper::combList [protected, inherited]

Definition at line 77 of file MdcSegGrouper.h.

Referenced by incompWithGroup(), MdcSegGrouper::MdcSegGrouper(), MdcSegGrouper::nextGroup(), resetComb(), MdcSegGrouperCsmc::resetComb(), MdcSegGrouperAx::resetComb(), and MdcSegGrouper::~MdcSegGrouper().

int* MdcSegGrouper::currentSeg [protected, inherited]

Definition at line 70 of file MdcSegGrouper.h.

Referenced by incompWithGroup(), MdcSegGrouper::MdcSegGrouper(), MdcSegGrouper::nextGroup(), MdcSegGrouper::resetSegCounters(), and MdcSegGrouper::~MdcSegGrouper().

int* MdcSegGrouper::firstBad [protected, inherited]

Definition at line 72 of file MdcSegGrouper.h.

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

int* MdcSegGrouper::firstGood [protected, inherited]

Definition at line 71 of file MdcSegGrouper.h.

Referenced by MdcSegGrouper::MdcSegGrouper(), MdcSegGrouper::nextGroup(), resetComb(), MdcSegGrouperCsmc::resetComb(), MdcSegGrouperAx::resetComb(), MdcSegGrouper::resetSegCounters(), and MdcSegGrouper::~MdcSegGrouper().

int* MdcSegGrouper::gapCounter [protected, inherited]

Definition at line 91 of file MdcSegGrouper.h.

Referenced by MdcSegGrouper::MdcSegGrouper(), MdcSegGrouper::resetGap(), MdcSegGrouper::updateGap(), and MdcSegGrouper::~MdcSegGrouper().

bool** MdcSegGrouper::isValid [protected, inherited]

Definition at line 73 of file MdcSegGrouper.h.

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

bool* MdcSegGrouper::leaveGap [protected, inherited]

Definition at line 88 of file MdcSegGrouper.h.

Referenced by incompWithGroup(), MdcSegGrouper::MdcSegGrouper(), MdcSegGrouper::nextGroup(), resetComb(), MdcSegGrouperCsmc::resetComb(), MdcSegGrouperAx::resetComb(), MdcSegGrouper::updateGap(), and MdcSegGrouper::~MdcSegGrouper().

bool MdcSegGrouper::lTestGroup [protected, inherited]

Definition at line 93 of file MdcSegGrouper.h.

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

bool MdcSegGrouper::lTestSingle [protected, inherited]

Definition at line 94 of file MdcSegGrouper.h.

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

int MdcSegGrouper::maxNull [protected, inherited]

Definition at line 90 of file MdcSegGrouper.h.

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

int MdcSegGrouper::nDeep [protected, inherited]

Definition at line 68 of file MdcSegGrouper.h.

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

int MdcSegGrouper::nNull [protected, inherited]

Definition at line 89 of file MdcSegGrouper.h.

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

int MdcSegGrouper::nPlyFilled [protected, inherited]

Definition at line 69 of file MdcSegGrouper.h.

Referenced by MdcSegGrouper::nextGroup(), resetComb(), MdcSegGrouperCsmc::resetComb(), MdcSegGrouperAx::resetComb(), MdcSegGrouper::resetGap(), MdcSegGrouper::resetSegCounters(), and MdcSegGrouper::updateGap().

HepAList<MdcSeg>* MdcSegGrouper::segList [protected, inherited]

Definition at line 79 of file MdcSegGrouper.h.

Referenced by MdcSegGrouper::dumpSegList(), fillWithSegs(), MdcSegGrouperCsmc::fillWithSegs(), MdcSegGrouperAx::fillWithSegs(), MdcSegGrouper::MdcSegGrouper(), plotStereo(), resetComb(), MdcSegGrouperCsmc::resetComb(), MdcSegGrouperAx::resetComb(), resetList(), and MdcSegGrouper::~MdcSegGrouper().


Generated on Tue Nov 29 23:20:17 2016 for BOSS_7.0.2 by  doxygen 1.4.7