Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

MdcSegGrouperCsmc Class Reference

#include <MdcSegGrouperCsmc.h>

Inheritance diagram for MdcSegGrouperCsmc:

MdcSegGrouper MdcSegGrouper List of all members.

Public Member Functions

int combineSegs (MdcTrack *&, MdcSeg *seed, TrkContext &, double trackT0, double maxSegChisqO)
int combineSegs (MdcTrack *&, MdcSeg *seed, TrkContext &, double trackT0, double maxSegChisqO)
void dumpSegList ()
void dumpSegList ()
void fillWithSegs (const MdcSegList *inSegs)
void fillWithSegs (const MdcSegList *inSegs)
virtual int incompWithGroup (MdcSeg **segGroup, const MdcSeg *testSeg, int iply)
virtual int incompWithGroup (MdcSeg **segGroup, const MdcSeg *testSeg, int iply)
virtual int incompWithSeg (const MdcSeg *refSeg, const MdcSeg *testSeg)
virtual int incompWithSeg (const MdcSeg *refSeg, const MdcSeg *testSeg)
 MdcSegGrouperCsmc (const MdcDetector *gm, int debug)
 MdcSegGrouperCsmc (const MdcDetector *gm, int debug)
int nextGroup (MdcSeg **segGroup, bool printit)
int nextGroup (MdcSeg **segGroup, bool printit)
int nPly () const
int nPly () const
virtual void resetComb (const MdcSeg *seed)=0
void resetComb (const class MdcSeg *)
void resetComb (const class MdcSeg *)
void resetGap (int nGap)
void resetGap (int nGap)
virtual MdcTrackstorePar (MdcTrack *trk, double parms[2], double chisq, TrkContext &, double trackT0)
virtual MdcTrackstorePar (MdcTrack *trk, double parms[2], double chisq, TrkContext &, double trackT0)
void transferHits (MdcTrack *track, int nSegs, MdcSeg **segGroup)
void transferHits (MdcTrack *track, int nSegs, MdcSeg **segGroup)
int updateGap ()
int updateGap ()
 ~MdcSegGrouperCsmc ()
 ~MdcSegGrouperCsmc ()

Protected Member Functions

void resetSegCounters ()
void resetSegCounters ()

Protected Attributes

int _debug
const MdcDetector_gm
const MdcDetector_gm
HepAList< MdcSeg > ** combList
HepAList< MdcSeg > ** combList
int * currentSeg
int * currentSeg
int * firstBad
int * firstBad
int * firstGood
int * firstGood
int * gapCounter
int * gapCounter
bool ** isValid
bool ** isValid
boolleaveGap
boolleaveGap
bool lTestGroup
bool lTestSingle
int maxNull
int nDeep
int nNull
int nPlyFilled
HepAList< MdcSeg > * segList
HepAList< MdcSeg > * segList

Private Member Functions

MdcSegGrouperCsmcoperator= (const MdcSegGrouperCsmc &)
MdcSegGrouperCsmcoperator= (const MdcSegGrouperCsmc &)

Private Attributes

const MdcSeg_seed
const MdcSeg_seed

Constructor & Destructor Documentation

MdcSegGrouperCsmc::MdcSegGrouperCsmc const MdcDetector gm,
int  debug
 

00035                                                                      : 
00036   MdcSegGrouper(gm, gm->nAxialSuper()-1, debug) {
00037 //------------------------------------------------------------------------
00038                     
00039   lTestGroup = false;
00040   lTestSingle = false;
00041 
00042   isValid = new bool * [nPly()];
00043   for (int j = 0; j < nPly(); j++) {
00044     isValid[j] = 0;
00045   } 
00046 }

MdcSegGrouperCsmc::~MdcSegGrouperCsmc  )  [inline]
 

00032 { };

MdcSegGrouperCsmc::MdcSegGrouperCsmc const MdcDetector gm,
int  debug
 

MdcSegGrouperCsmc::~MdcSegGrouperCsmc  )  [inline]
 

00032 { };


Member Function Documentation

int MdcSegGrouper::combineSegs MdcTrack *&  ,
MdcSeg seed,
TrkContext ,
double  trackT0,
double  maxSegChisqO
[inherited]
 

int MdcSegGrouper::combineSegs MdcTrack *&  ,
MdcSeg seed,
TrkContext ,
double  trackT0,
double  maxSegChisqO
[inherited]
 

00248                          {
00249   //************************************************************************/
00250   // forms track from list of segs; does 2-param fit (either r-phi from origin
00251   //  or s-z) and picks best combination.
00252   bool lSeed = (seed != 0);
00253 
00254   double wgtmat[3], wgtinv[3];
00255   double wgtpar[2];
00256   double temvec[2], param[2], diff[2];
00257   int success = 0;
00258   double qualBest = -1000.;
00259   int nSegBest = 0;
00260   int nHitBest = 0;
00261   double paramBest[2];
00262   double chiBest = 9999.;
00263   int nToUse = nPly();
00264   if (lSeed) nToUse++;   // seed isn't included in the segs list
00265   MdcSeg **segGroup;
00266   MdcSeg **segGroupBest;
00267   segGroup = new MdcSeg * [nToUse];
00268   segGroupBest = new MdcSeg * [nToUse];
00269   //  static int counter = 0;
00270   //  counter++;
00271   //  cout << counter << endl;
00272 
00273   // Loop over all combinations of segs consistent with seed (including gaps)
00274   if ((3 == _debug)&&lSeed) {
00275     std::cout<<"seed segment: "<<  std::endl;
00276     seed->plotSeg();
00277   }
00278   resetComb(seed); 
00279 
00280   // Save seed params (if angles) for later use as reference angle in 
00281   //    mdcWrapAng (don't really have to test whether it's an angle, but I do)
00282   double seedAngle[2] = {0.,0.};
00283   if (lSeed) {
00284     if (seed->info()->parIsAngle(0)) seedAngle[0] = seed->info()->par(0);
00285     if (seed->info()->parIsAngle(1)) seedAngle[1] = seed->info()->par(1);
00286   }
00287 
00288   int iprint = (3 == _debug);
00289   int nInGroup = 0;
00290   while ( (nInGroup = nextGroup(segGroup, iprint)) != 0) {
00291     if (lSeed) {
00292       segGroup[nToUse-1] = seed;
00293       nInGroup++;
00294     }
00295 
00296     if (nInGroup < 0) continue;
00297     if (nInGroup < 2) break;
00298     if (nInGroup < nSegBest) break;
00299 
00300     // Calculate track & chisq for this group 
00301     int nSegFit = 0;
00302     int nhit = 0;
00303     wgtmat[0] = wgtmat[1] = wgtmat[2] = wgtpar[0] = wgtpar[1] = 0.0;
00304 
00305     if (3 == _debug) {
00306       cout << endl <<"--parameters of "<<nInGroup<<" segment in this group"<<endl;
00307     }
00308     int iPly;
00309     for (iPly = 0; iPly < nToUse; iPly++) {
00310       if (3 == _debug) {
00311         //if (!lSeed) //if (segGroup[iPly] == 0) cout << "ply empty: " << iPly << "\n";
00312       }
00313       if (segGroup[iPly] == 0) continue;   // skipping this slayer
00314       nSegFit++;
00315       MdcSegInfo *segInfo = segGroup[iPly]->info();
00316       // Accumulate sums
00317       for (int i = 0; i < 3; i++) wgtmat[i] += (segInfo->inverr())[i];
00318       for (int k = 0; k < 2; k++) {
00319         param[k] = segInfo->par(k);
00320         //zhangy add
00321         if (segInfo->parIsAngle(k)) {
00322           param[k] = mdcWrapAng(seedAngle[k], param[k]);
00323         }
00324       }
00325       // Multiply by weight matrix.
00326       mdcTwoVec( segInfo->inverr(), param, temvec );  
00327       wgtpar[0] += temvec[0];
00328       wgtpar[1] += temvec[1];
00329       if(3 == _debug) {
00330         std::cout<<" par * W "<<temvec[0]<<" "<<temvec[1]<<  std::endl;
00331       }
00332       nhit += segGroup[iPly]->nHit();
00333     }
00334 
00335     // And the fitted parameters are . . . 
00336     int error = mdcTwoInv(wgtmat,wgtinv);
00337     if (error && (3 == _debug)) {
00338       cout << "ErrMsg(warning) " 
00339         <<  "failed matrix inversion in MdcTrackList::combineSegs" << endl;
00340       continue;
00341     }
00342     mdcTwoVec( wgtinv, wgtpar, param );
00343 
00344     if(_debug==3)cout<<endl<<"-- Calculate track & chisq for this group "<<endl;
00345 
00346     // Calc. chisq. = sum( (Vi - V0) * W * (Vi - V0) ) 
00347     // W = weight, Vi = measurement, V0 = fitted param. 
00348     double chisq = 0.0;
00349     for (iPly = 0; iPly < nToUse; iPly++) {
00350       if (segGroup[iPly] == 0) continue;   // skipping this slayer
00351       MdcSegInfo *segInfo = segGroup[iPly]->info();
00352       for (int j = 0; j < 2; j++) {
00353         double temPar;
00354         if (segInfo->parIsAngle(j)) {
00355           temPar = mdcWrapAng(seedAngle[j], segInfo->par(j));
00356         }
00357         else {
00358           temPar = segInfo->par(j);
00359         }
00360         if(3 == _debug) {
00361           std::cout<<" segPar"<<j<<" "<<temPar<<  std::endl;
00362         }
00363         diff[j] = temPar - param[j];
00364       }
00365 
00366       if(3 == _debug) {
00367         std::cout<<"inverr " <<segInfo->inverr()[0]<<" "
00368           <<segInfo->inverr()[1] <<" "<<segInfo->inverr()[2] <<  std::endl;
00369         std::cout<<"errmat " <<segInfo->errmat()[0]<< " "
00370           <<segInfo->errmat()[1] << " "<<segInfo->errmat()[2] <<  std::endl;
00371         std::cout<<  std::endl;
00372       }
00373       mdcTwoVec( segInfo->inverr(), diff, temvec);
00374 
00375       chisq += diff[0] * temvec[0] + diff[1] * temvec[1];
00376 
00377       if(3 == _debug){
00378         std::cout<<iPly<<" chi2Add:"<<diff[0] * temvec[0] + diff[1] * temvec[1]<<" diff0 "<<setw(10) << diff[0]<< " vec0 "<<setw(10)<<temvec[0]<<" diff1 "<<setw(10)
00379           << diff[1]<< " vec1 "<<setw(10)<<temvec[1] << std::endl;
00380       }
00381     }
00382     if (3 == _debug) {
00383       cout << "Candidate track:"<<endl<<" chisq: " 
00384         << chisq << " nhit: " << nhit << " cpa/cot: " << 
00385         param[0] << " phi0/z0: " << param[1] << endl;
00386       std::cout<< "chiDof="<<chisq/(2*nSegFit - 2)
00387         <<" maxSegChisqO="<<maxSegChisqO << std::endl;//yzhang debug
00388       if((chisq/(2*nSegFit - 2))<maxSegChisqO)  cout << "---KEEP!---"<<endl;
00389       else cout << "---DROP!---"<<endl;
00390     }
00391     if (chisq < 0.) continue;//yzhang add
00392     // Chisq test
00393     double chiDof = chisq/(2.*nSegFit - 2.);
00394     if (g_maxSegChisqO ) { g_maxSegChisqO->fill(chiDof); } //yzhang hist cut
00395     if (chiDof > maxSegChisqO) continue;
00396     success = 1;
00397     double qual = 2. * nhit - chiDof;
00398     if (qual > qualBest) {
00399       qualBest = qual;
00400       nSegBest = nSegFit;
00401       nHitBest = nhit;
00402       paramBest[0] = param[0];
00403       paramBest[1] = param[1];
00404       chiBest = chisq;
00405       for (int i = 0; i < nToUse; i++) {
00406         segGroupBest[i] = segGroup[i];
00407         //std::cout<<__FILE__<<" "<<__LINE__<<" Keep BEST"<<  std::endl;
00408       }
00409     }// end test on qual
00410   }
00411 
00412   if (success == 1) {
00413     // Store the results in a track, possibly creating it in the process
00414     trk = storePar(trk, paramBest, chiBest, context, t0);
00415     transferHits(trk, nToUse, segGroupBest);     // Store hits with track
00416   }
00417   delete [] segGroupBest;
00418   delete [] segGroup;
00419   return success;
00420 } 

void MdcSegGrouper::dumpSegList  )  [inherited]
 

void MdcSegGrouper::dumpSegList  )  [inherited]
 

00469                                {
00470   //************************************************************************
00471   for(int islayer=0; islayer<11; islayer++){
00472     for(int i=0; i<segList[islayer].length(); i++){
00473       segList[islayer][i]->plotSeg();
00474     }
00475   }
00476 }

void MdcSegGrouperCsmc::fillWithSegs const MdcSegList inSegs  ) 
 

void MdcSegGrouperCsmc::fillWithSegs const MdcSegList inSegs  ) 
 

00050                                                          {
00051 //------------------------------------------------------------------------
00052   // Prepare for axial finding
00053   // Store the segments (pointers, actually), sorting by phi0 
00054   for (int isuper = 0; isuper < _gm->nSuper(); isuper++) {
00055     const GmsList *inList = inSegs->oneList(isuper);
00056     if (inList->count() == 0) continue;
00057     
00058     MdcSeg *inSeg = (MdcSeg *) inList->first();
00059     // Only load axial segments
00060     if (inSeg->superlayer()->whichView() != 0) continue;
00061 
00062     while (inSeg != 0) {
00063       // Create an info object within the seg to store info
00064       MdcSegInfoCsmc *info = new MdcSegInfoCsmc;
00065       inSeg->setInfo(info);
00066       info->calcStraight(inSeg);  // calc. origin-dependent info
00067 
00068       // Loop over the segs already stored, looking for the right place 
00069       //   to stick the new one
00070       int isInserted = 0;
00071       for (int iseg = 0; iseg < (int) segList[isuper].length(); iseg++) {
00072         MdcSeg *aSeg = segList[isuper][iseg];
00073         if ( ((MdcSegInfoCsmc *)aSeg->info())->phi0() < info->phi0()) 
00074           continue;  
00075         segList[isuper].insert(inSeg, iseg);
00076         isInserted = 1;
00077         break;
00078       }  // end of loop over existing segs
00079       if (isInserted == 0) segList[isuper].append(inSeg);
00080 
00081       inSeg = (MdcSeg *) inSeg->next();
00082     }  // end loop over new segs
00083   }  //  end loop over superlayers
00084 
00085 }

virtual int MdcSegGrouperCsmc::incompWithGroup MdcSeg **  segGroup,
const MdcSeg testSeg,
int  iply
[virtual]
 

Implements MdcSegGrouper.

int MdcSegGrouperCsmc::incompWithGroup MdcSeg **  segGroup,
const MdcSeg testSeg,
int  iply
[virtual]
 

Implements MdcSegGrouper.

00125                                       {
00126 //-------------------------------------------------------------------------
00127 
00128   return 0;
00129 }

virtual int MdcSegGrouperCsmc::incompWithSeg const MdcSeg refSeg,
const MdcSeg testSeg
[virtual]
 

Implements MdcSegGrouper.

int MdcSegGrouperCsmc::incompWithSeg const MdcSeg refSeg,
const MdcSeg testSeg
[virtual]
 

Implements MdcSegGrouper.

00090                                                           {
00091 //-------------------------------------------------------------------------
00092 
00093   return 0;
00094   // Returns 0 if valid, -1 if invalid, +1 if invalid and no more valid 
00095   //   ones possible in this slayer (assumes they're ordered)
00096   if (testSeg == 0) return 0;
00097  
00098   // Test phi0 match
00099   MdcSegInfoCsmc *refInfo = (MdcSegInfoCsmc *) refSeg->info();
00100   MdcSegInfoCsmc *testInfo = (MdcSegInfoCsmc *) testSeg->info();
00101   double sigPhi0 = (refInfo->sigPhi0() > testInfo->sigPhi0() ? 
00102                     refInfo->sigPhi0() : testInfo->sigPhi0());
00103   double refPhi0 = refInfo->phi0();
00104   double testPhi0 =  testInfo->phi0();
00105   double corrPhi0 = mdcWrapAng(refPhi0, testPhi0);
00106   if (refPhi0 - corrPhi0 > 6. * sigPhi0) return -1;
00107   if (corrPhi0 - refPhi0 > 6. * sigPhi0) { 
00108     if (testPhi0 > refPhi0) return  1;  
00109     else return -1; // => testPhi0>2pi & refPhi0<2pi
00110   }
00111 
00112   // Test d0 match
00113   // use larger error of the two
00114   double sigD0 = (refInfo->sigD0() > testInfo->sigD0() ? 
00115                     refInfo->sigD0() : testInfo->sigD0());
00116   double refD0 = refInfo->d0();
00117   double testD0 = testInfo->d0();
00118   if (fabs(refD0 - testD0) > 6. * sigD0) return -2;
00119 
00120   return 0;
00121 }

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

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

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

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

00054 {return nDeep;}

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

00054 {return nDeep;}

MdcSegGrouperCsmc& MdcSegGrouperCsmc::operator= const MdcSegGrouperCsmc  )  [private]
 

MdcSegGrouperCsmc& MdcSegGrouperCsmc::operator= const MdcSegGrouperCsmc  )  [private]
 

virtual void MdcSegGrouper::resetComb const MdcSeg seed  )  [pure virtual, inherited]
 

Implemented in MdcSegGrouperAx, MdcSegGrouperSt, MdcSegGrouperAx, and MdcSegGrouperSt.

void MdcSegGrouperCsmc::resetComb const class MdcSeg  ) 
 

void MdcSegGrouperCsmc::resetComb const class MdcSeg  ) 
 

00133                                                      {
00134 //---------------------------------------------------------------------
00135   
00136   // Delete existing list of valid/invalid segs
00137   if (isValid != 0) {
00138     int i;
00139     for (i = 0; i < nDeep; i++) {
00140       delete [] isValid[i];
00141       isValid[i] = 0;
00142     }
00143   }
00144 
00145   _seed = seed;
00146   //Grab the seglist for each slayer
00147   int islay = 0;
00148   int iply = 0;
00149   nPlyFilled = 0;
00150   nNull = 0;
00151   const MdcSuperLayer *seedSlay = 0;
00152   if (seed != 0) seedSlay = seed->superlayer();
00153 
00154   // Set up all sorts of stuff for fast grouping of segs in nextGroup()
00155   for (const MdcSuperLayer *thisSlay = _gm->firstSlay(); thisSlay != 0;
00156        thisSlay = thisSlay->next()) {
00157     bool noGoodYet = true;
00158     islay++;
00159 
00160     if (thisSlay == seedSlay) continue;
00161     if (thisSlay->whichView() != 0) continue;
00162     firstGood[iply] = 0;
00163     // Loop over the segs, marking start & end of valid region for this seed
00164     firstBad[iply] = 0;
00165     if (segList[islay-1].length() != 0) 
00166       isValid[iply] = new bool[segList[islay-1].length()];
00167     for (int i = 0; i < (int) segList[islay-1].length(); i++) {
00168       MdcSeg *aSeg = segList[islay-1][i];
00169       int invalid = incompWithSeg(seed, aSeg);
00170       isValid[iply][i] = true;
00171       if (invalid < 0) {
00172         firstBad[iply] = i;
00173         isValid[iply][i] = false;
00174         if (noGoodYet) firstGood[iply] = i+1;
00175       }
00176       else if (invalid > 0) {
00177         // No more valid segs in this slayer
00178         firstBad[iply] = i;
00179         for (int j = i; j < (int) segList[islay-1].length(); j++) 
00180           isValid[iply][j] = false;
00181         break;
00182       }
00183       else {
00184         firstBad[iply] = i+1;
00185         noGoodYet = false;
00186       }
00187     }
00188     //    if (thisSlay->whichView() != 0) continue;
00189     //    firstGood[iply] = 0;
00190     //    // Loop over the segs, marking start & end of valid region
00191     //    firstBad[iply] = 0;
00192     //    firstBad[iply] = segList[islay-1].length();
00193 
00194 
00195     if (firstGood[iply] > firstBad[iply]) firstGood[iply] = firstBad[iply];
00196     if (firstGood[iply] == firstBad[iply]) {
00197       // If there are no valid segs for this ply, skip it
00198       continue;
00199     }
00200     // Associate correct seglist with this ply
00201     combList[iply] = &segList[islay-1];
00202     leaveGap[iply] = false;
00203     iply++;
00204   }
00205   nPlyFilled = iply;
00206   resetSegCounters();
00207   maxNull = nPlyFilled - 2;
00208   maxNull++;
00209 }

void MdcSegGrouper::resetGap int  nGap  )  [inherited]
 

void MdcSegGrouper::resetGap int  nGap  )  [inherited]
 

00190                                      {
00191   //**************************************************************************
00192 
00193   for (int i = 0; i < nPlyFilled; i++) {
00194     gapCounter[i] = nGap - 1 - i;
00195   }
00196   gapCounter[0]--; // so 1st increment will put 1st counter in right place
00197 
00198   return;
00199 }

void MdcSegGrouper::resetSegCounters  )  [protected, inherited]
 

void MdcSegGrouper::resetSegCounters  )  [protected, inherited]
 

00238                                      {
00239   //-------------------------------------------------------------------------
00240   for (int i = 0; i < nPlyFilled; i++) {
00241     currentSeg[i] = firstGood[i] - 1;
00242   }
00243 }

virtual MdcTrack* MdcSegGrouperCsmc::storePar MdcTrack trk,
double  parms[2],
double  chisq,
TrkContext ,
double  trackT0
[virtual]
 

Implements MdcSegGrouper.

MdcTrack * MdcSegGrouperCsmc::storePar MdcTrack trk,
double  parms[2],
double  chisq,
TrkContext ,
double  trackT0
[virtual]
 

Implements MdcSegGrouper.

00213                                                            {
00214 //---------------------------------------------------------------------
00215   assert(trk == 0);
00216   BesAngle foundPhi0(parms[1]);
00217   TrkExchangePar par(parms[0], foundPhi0.Rad(), 0., 0., 0.);
00218   return new MdcTrack(_gm->nSuper(), par, chi2, context, t0);
00219 }

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

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

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

int MdcSegGrouper::updateGap  )  [inherited]
 

int MdcSegGrouper::updateGap  )  [inherited]
 

00202                              {
00203   //**************************************************************************
00204   if (nNull == 0) return 1;
00205 
00206   for (int i = 0; i < nPlyFilled; i++) {
00207     leaveGap[i] = false;
00208   }
00209   for (int igap = 0; igap < nNull; igap++) {
00210     gapCounter[igap]++;
00211     if (gapCounter[igap] == nPlyFilled - igap) {
00212       // End of loop for this counter; look at the other counters to 
00213       //  decide where this one should be reset to.
00214       int inext = igap + 1;
00215       while (1) {
00216         if (inext >= nNull) return 1; // done with all combos
00217         if (gapCounter[inext] + inext + 1 < nPlyFilled) {
00218           // This is the right spot to reset to
00219           gapCounter[igap] = gapCounter[inext] + inext + 1 - igap;
00220           break;
00221         }
00222         inext++;
00223       } 
00224     }
00225     else {
00226       // We successfully incremented.  Quit looping and return.
00227       break;
00228     }
00229   }  // end loop over igap
00230 
00231   for (int j = 0; j < nNull; j++) {
00232     leaveGap[gapCounter[j]] = true;
00233   }
00234   return 0;
00235 
00236 }


Member Data Documentation

int MdcSegGrouper::_debug [protected, inherited]
 

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

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

const MdcSeg* MdcSegGrouperCsmc::_seed [private]
 

const MdcSeg* MdcSegGrouperCsmc::_seed [private]
 

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

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

int* MdcSegGrouper::currentSeg [protected, inherited]
 

int* MdcSegGrouper::currentSeg [protected, inherited]
 

int* MdcSegGrouper::firstBad [protected, inherited]
 

int* MdcSegGrouper::firstBad [protected, inherited]
 

int* MdcSegGrouper::firstGood [protected, inherited]
 

int* MdcSegGrouper::firstGood [protected, inherited]
 

int* MdcSegGrouper::gapCounter [protected, inherited]
 

int* MdcSegGrouper::gapCounter [protected, inherited]
 

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

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

bool* MdcSegGrouper::leaveGap [protected, inherited]
 

bool* MdcSegGrouper::leaveGap [protected, inherited]
 

bool MdcSegGrouper::lTestGroup [protected, inherited]
 

bool MdcSegGrouper::lTestSingle [protected, inherited]
 

int MdcSegGrouper::maxNull [protected, inherited]
 

int MdcSegGrouper::nDeep [protected, inherited]
 

int MdcSegGrouper::nNull [protected, inherited]
 

int MdcSegGrouper::nPlyFilled [protected, inherited]
 

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

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


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 16:28:28 2011 for BOSS6.5.5 by  doxygen 1.3.9.1