MdcTrackListCsmc Class Reference

#include <MdcTrackListCsmc.h>

Inheritance diagram for MdcTrackListCsmc:

MdcTrackListBase List of all members.

Public Member Functions

 MdcTrackListCsmc (const MdcTrackParams &tkPar)
 ~MdcTrackListCsmc ()
int createFromSegs (MdcSegList *segs, const MdcHitMap *, const MdcDetector *, TrkContext &, double trackT0)
int finish3d (TrkRecoTrk &trk)
void remove (MdcTrack *atrack)
int nTrack () const
void setPlot (int plotFlag)
void newParams (const MdcTrackParams &tkPar)
void plot () const
void store (RecMdcTrackCol *, RecMdcHitCol *)
int arbitrateHits ()
void dropMultiHotInLayer (const MdcTrack *tk)
void setD0Cut (double d0Cut)
void setZ0Cut (double z0Cut)
void setPtCut (double ptCut)

Static Public Attributes

static double m_d0Cut = -999.
static double m_z0Cut = -999.
static double m_ptCut = -999.

Protected Attributes

MdcTrackParams tkParam

Detailed Description

Definition at line 30 of file MdcTrackListCsmc.h.


Constructor & Destructor Documentation

MdcTrackListCsmc::MdcTrackListCsmc ( const MdcTrackParams tkPar  ) 

Definition at line 34 of file MdcTrackListCsmc.cxx.

00034                                                               : 
00035   MdcTrackListBase(tkPar) { 
00036 // *************************************************************************
00037     return;
00038   }

MdcTrackListCsmc::~MdcTrackListCsmc (  ) 

Definition at line 41 of file MdcTrackListCsmc.cxx.

00041 {} 


Member Function Documentation

int MdcTrackListBase::arbitrateHits (  )  [inherited]

Definition at line 104 of file MdcTrackListBase.cxx.

References TrkHitList::begin(), TrkHitList::end(), TrkRecoTrk::fitResult(), for, MdcMap< K, V >::get(), TrkRecoTrk::hits(), genRecEmupikp::i, TrkRecoTrk::id(), MdcTrackParams::lPrint, MdcTrackParams::lRemoveInActive, MdcTrackListBase::nTrack(), MdcMap< K, V >::put(), q, TrkHitList::removeHit(), MdcTrackListBase::tkParam, and MdcTrack::track().

00104                                 {
00105   //*************************************************************************
00106   // Look at all hits used in two or more tracks.  Assign hits to the track
00107   // that gives the lower residual.  If, however, many hits are shared by
00108   // a pair of tracks, assign them all to one or the other.
00109   // Refit any tracks that have had hits dropped.
00110   // The implementation is very clumsy, since the arrays were originally
00111   // indexed by id # => there is an unneeded layer of indexing.
00112 
00113   // return # of tracks deleted
00114 
00115   if (8 == tkParam.lPrint){
00116     std::cout << "=======Print before arbitrateHits=======" << std::endl;
00117   }
00118 
00119   int nDeleted = 0;
00120   std::vector<MdcTrack*> trksToKill;
00121   trksToKill.reserve(4);
00122 
00123   MdcMap<long,long> idMap;
00124 
00125   //usedInTrackNum records how many shared hits track has with each other track
00126   int* usedInTrackNum = new int [nTrack()];
00127   // to navigate from track id # to track pointer:
00128   MdcTrack** trkXRef = new MdcTrack* [nTrack()];
00129   //refitTrack flags track id #s of tracks to be refit
00130   int *refitTrack = new int [nTrack()];
00131   for (int i = 0; i < nTrack(); i++) {
00132     refitTrack[i] = 0;
00133   }
00134 
00135   // Fill xref table
00136   int itrack;
00137   for (itrack = 0; itrack < nTrack(); itrack++) {
00138     MdcTrack *atrack = (*this)[itrack];
00139     if (atrack == 0) continue;  // I don't think it can be, but . . .
00140     idMap.put(atrack->track().id(), itrack);
00141     trkXRef[itrack] = atrack;
00142   }
00143   // Loop through the tracks
00144   for (itrack = 0; itrack < nTrack(); itrack++) {
00145 
00146     if (8 == tkParam.lPrint) std::cout<<"arbitrate track No."<<itrack<<  std::endl;
00147     MdcTrack *atrack = (*this)[itrack];
00148     if (atrack == 0) continue;
00149     TrkRecoTrk& aRecoTrk = atrack->track();
00150     int lRefit = 0;
00151     int trackOld = -1;
00152     const TrkFit* tkFit = aRecoTrk.fitResult();
00153     assert (tkFit != 0);
00154     TrkHitList* hitList = aRecoTrk.hits();
00155     assert (hitList != 0);
00156 restart:
00157     for (int ii = 0; ii < nTrack(); ii++) usedInTrackNum[ii] = 0;
00158 
00159     // Loop through hits on track, counting # used in other tracks
00160     int nPrev = 0;
00161     int nHitDeleted = 0;
00162     int maxGapLength = 0;//yzhang 2011-07-29 # of max continuous no hits layer for a track, Gap defined as missing layer >=2 
00163     int nGapGE2= 0;//yzhang 2011-07-29 # of no hits gap for a track 
00164     int nGapGE3= 0;//yzhang 2011-07-29 # of no hits gap for a track 
00165     int nHitInLayer[43];//yzhang 2010-09-20 for bad tracking testing
00166     int nDeleteInLayer[43];//yzhang 2010-09-20 
00167     for(int i=0;i<43;i++){
00168       nHitInLayer[i]=0;
00169       nDeleteInLayer[i]=0;
00170     }
00171     if(8 == tkParam.lPrint) std::cout<< "--arbitrate--"<<std::endl;
00172     for (TrkHitList::hot_iterator ihit(hitList->begin()); ihit != hitList->end(); ++ihit){
00173       int nUsed = ihit->hit()->nUsedHits();
00174       if (8 == tkParam.lPrint){
00175         std::cout<<"nUsed="<<nUsed<<":";
00176         ihit->hit()->printAll(std::cout);
00177       }
00178       if (8 == tkParam.lPrint) {
00179         double deltaChi = -999;
00180         ihit->getFitStuff(deltaChi);
00181         std::cout<< "deltaChi="<<deltaChi<<std::endl;
00182       }
00183       int layer = ihit->layerNumber();
00184       nHitInLayer[layer]++;
00185 
00186       if (!ihit->isActive()) {
00187         //-----------------------------------
00188         //yzhang delete not ACT hit 2010-05-14 
00189         //-----------------------------------
00190         if(tkParam.lRemoveInActive ) {//2010-05-16 
00191           nDeleteInLayer[layer]++;
00192           if (8 == tkParam.lPrint) {
00193             std::cout<< "=remove above inactive "<<std::endl;
00194           }
00195           TrkFundHit* hit = const_cast<TrkFundHit*> (ihit->hit());
00196           hitList->removeHit(hit);
00197           if(ihit == hitList->end()) break;
00198           --ihit;//be careful of the iterator, yzhang
00199         }
00200         continue;   // active hits only yzhang 2009-11-03 delete
00201       }
00202       if (nUsed > 1) {
00203         bool wasUsed = false;
00204         std::pair<TrkFundHit::hot_iterator,TrkFundHit::hot_iterator> q =
00205           ihit->hit()->getUsedHits();
00206         for (TrkFundHit::hot_iterator i = q.first; i != q.second; ++i) {
00207           if ( !i->isActive() ) continue; //yzhang 2009-11-03 delete
00208           TrkRecoTrk * recoTrk=i->parentTrack();
00209           int id = recoTrk->id();
00210           if (id == aRecoTrk.id()) continue; //skip same track
00211           long index = 0;
00212           idMap.get(id, index);
00213           assert(index >= 0);
00214           usedInTrackNum[index]++;
00215           if (8 == tkParam.lPrint){
00216             std::cout<<" track "<<itrack<<"&" <<index
00217               << " shared hits "<<usedInTrackNum[index]<<":";
00218             ihit->printAll(std::cout);
00219           }
00220           wasUsed = true;
00221         }
00222         if (wasUsed) nPrev++;
00223       }// end nUsed > 1
00224     } // end loop over hits
00225 
00226     int testGap = 0;
00227     //std::cout<< __FILE__ << "   " << itrack<< "   "<<std::endl;
00228     for (int i=0;i<43;i++){
00229       //std::cout<< __FILE__ << "   " << i<< " nHitInLayer  "<<nHitInLayer[i]<<" nDeleteInLayer "<<nDeleteInLayer[i]<<std::endl;
00230       if (8 == tkParam.lPrint) {
00231         std::cout<<i<<" nHitInLayer  "<<nHitInLayer[i]
00232           <<" nDeleteInLayer "<<nDeleteInLayer[i]<<std::endl;
00233       }
00234       //1.only hit in layer deleted; 2.no hits in layer; 3.got hits in layer;
00235       if(nHitInLayer[i]>0 && (nHitInLayer[i]-nDeleteInLayer[i])==0) {
00236         //only hit in layer i has been deleted
00237         nHitDeleted++;
00238         if (8 == tkParam.lPrint) { 
00239           cout << "rec hits have been deleted in this layer"<<std::endl; 
00240         }
00241         testGap++;
00242         //std::cout<< __FILE__ << "   " << __LINE__ << " testGap3  "<<testGap<<std::endl;
00243       }else if(nHitInLayer[i]==0){
00244         //no hits in this layer i
00245         testGap++;
00246         //std::cout<< __FILE__ << "   " << __LINE__ << " testGap3  "<<testGap<<std::endl;
00247       }else{
00248         //std::cout<< __FILE__ << "   " << __LINE__ << " testGap3  "<<testGap<<std::endl;
00249         //got hit in layer i
00250         if(testGap>=2){
00251           nGapGE2++;
00252           if(testGap>=3){ nGapGE3++; }
00253           if(testGap>maxGapLength) maxGapLength=testGap;
00254           //std::cout<< __FILE__ << "   " << __LINE__ << " maxGapLength  "<<maxGapLength<<std::endl;
00255         }
00256         testGap=0;
00257       }//end for layer 43
00258     }
00259 
00260     bool toBeDeleted = false;
00261 
00262     if(tkParam.lPrint>1) std::cout<< "arbitrateHits tkNo:"<<itrack<<" nGapGE2=  "<<nGapGE2 << " nGapGE3=  "<<nGapGE3 << " maxGapLength=  "<<maxGapLength<<std::endl;
00263     //yzhang add nHitDeleted cut 2010-09-13 
00264     // remove track if # not Active 
00265     if (nHitDeleted >= tkParam.nHitDeleted) {
00266       if (tkParam.lPrint>1) {
00267         cout << "arbitrateHits: nHitDeleted "<<nHitDeleted<<" >= "<<tkParam.nHitDeleted
00268           <<" Killing tkNo " << itrack << endl;
00269       }
00270       toBeDeleted = true;
00271     }
00272 
00273     //yzhang add nGap cut 2011-07-29 
00274     // remove track with gaps and big gap
00275     if (nGapGE2 >= tkParam.nGapGE2) {
00276       if (tkParam.lPrint>1) {
00277         cout << "arbitrateHits: nGapGE2 "<<nGapGE2<<" >= "<<tkParam.nGapGE2 <<" Killing tkNo " << itrack << endl;
00278       }
00279       toBeDeleted = true;
00280     } 
00281     if (nGapGE3 >= tkParam.nGapGE3) {
00282       if (tkParam.lPrint>1) {
00283         cout << "arbitrateHits: nGapGE3 "<<nGapGE3<<" >= "<<tkParam.nGapGE3 <<" Killing tkNo " << itrack << endl;
00284       }
00285       toBeDeleted = true;
00286     } 
00287     if (maxGapLength >= tkParam.maxGapLength) {
00288       if (tkParam.lPrint>1) {
00289         cout << "arbitrateHits: maxGapLength "<<maxGapLength<<" >= "<<tkParam.maxGapLength<<" Killing tkNo " << itrack << endl;
00290       }
00291       toBeDeleted = true;
00292     } 
00293 
00294     if(toBeDeleted){
00295       nDeleted++;
00296       delete &(atrack->track());    // Delete the RecoTrk inside atrack
00297       atrack->setTrack(0);
00298       trksToKill.push_back(atrack);
00299       continue;
00300     } 
00301 
00302     //*******
00303     // How many hits are shared with a single track?
00304     int nMost = 0;
00305     int trackMost = 0;
00306     for (int ii = 0; ii < nTrack(); ii++) {
00307       if (8 == tkParam.lPrint){
00308         std::cout<<"tk:"<<itrack<<"&"<<ii
00309           <<" shared "<<usedInTrackNum[ii]<<" hits "<<  std::endl;
00310       }
00311       if (usedInTrackNum[ii] > nMost) {
00312         nMost = usedInTrackNum[ii];
00313         trackMost = ii;  //index of track w/ most hits in common w/ current trk
00314       }
00315     }
00316 
00317     // A little precaution against infinite loops:
00318     if (trackMost == trackOld) {
00319       std::cout << "ErrMsg(error) MdcTrackListBase:"
00320         << "Something ghastly happened in MdcTrackListBase::arbitrateHits"
00321         << std::endl;
00322       return 0;
00323     }
00324     trackOld = trackMost;
00325 
00326 
00327     //******
00328     // Decide whether to handle hits individually or in group
00329     double groupDiff = 0.0;   // relative quality of grouped hits for the two
00330     // tracks; > 0. => current track worse
00331     int nFound = 0;    // # of grouped hits located so far
00332     TrkHitOnTrk **theseHits = 0;  // grouped hits as seen in current track
00333     TrkHitOnTrk **thoseHits = 0;  // grouped hits as seen in the other track
00334     int lGroupHits = 0;
00335 
00336     if (nMost >= tkParam.nOverlap) {
00337       if (8 == tkParam.lPrint){
00338         std::cout<<"track "<<trackMost<<" shared "<<nMost<<" hits > Cut nOverlap "
00339           <<tkParam.nOverlap<<", group hits!"<<std::endl;
00340       }
00341       lGroupHits = 1;
00342       theseHits = new TrkHitOnTrk*[nMost];
00343       thoseHits = new TrkHitOnTrk*[nMost];
00344     }
00345 
00346     //*********
00347     // Go back through hits on this track, looking up the overlap of each
00348     // if grouping hits, only deal with hits shared with trackMost on this pass
00349     // otherwise, deal with all shared hits as encountered
00350     if(8 == tkParam.lPrint) std::cout<<"Go back through hits, looking up overlap hits"<< std::endl;
00351     if (nMost > 0) {
00352       if (8 == tkParam.lPrint) std::cout<<" nHits= "<< hitList->nHit()<< std::endl;
00353       for (TrkHitList::hot_iterator ihit(hitList->begin()); ihit != hitList->end(); ++ihit) {
00354         int nUsed = ihit->hit()->nUsedHits();
00355 
00356         if (8 == tkParam.lPrint){
00357           std::cout<< "--hit go back, nUsed="<<nUsed<<":";
00358           ihit->hit()->printAll(std::cout);
00359         }
00360 
00361         // only shared hits 
00362         if (nUsed < 2) { continue; }
00363 
00364         // active hits only
00365         if (!ihit->isActive()) {
00366           if (8 == tkParam.lPrint){ std::cout<<"act=0 continue"<<std::endl; }
00367           continue;   
00368         }
00369 
00370         //*** look at all overlaps for this hit
00371         std::pair<TrkFundHit::hot_iterator,TrkFundHit::hot_iterator> q = ihit->hit()->getUsedHits();
00372         while (q.first!=q.second) { // nUsed > 0
00373           int dropThisHit = 0;
00374           TrkHitOnTrk *otherHot = const_cast<TrkHitOnTrk*>((--q.second).get());
00375           TrkRecoTrk *otherTrack = otherHot->parentTrack();
00376 
00377           if (!otherHot->isActive()) continue;
00378 
00379           // Again, skip "overlap" of track with itself
00380           if ( &aRecoTrk == otherTrack) continue;
00381           int otherId = otherTrack->id();
00382           long otherIndex = -1;
00383           idMap.get(otherId, otherIndex); assert(otherIndex >= 0);
00384 
00385           // if grouping hits, only look at hits shared with trackMost
00386           if (lGroupHits && otherIndex != trackMost) continue;
00387 
00388           if (lGroupHits) {
00389             if (8 == tkParam.lPrint) {
00390               std::cout<<"group hits "<<  std::endl;
00391             }
00392             // Calculate contribution of group to each chisq/dof
00393             //        groupDiff += fabs(ihit->resid(0)) -
00394             //          fabs(otherHot->resid(0));
00395             // Hack to handle tracks with 5 active hits:
00396             int aDof = tkFit->nActive() - 5;
00397             assert (otherTrack->fitResult() != 0);
00398             int otherDof = otherTrack->fitResult()->nActive() - 5;
00399             if (aDof <= 0) {groupDiff = 999;}
00400             else if (otherDof <= 0) {groupDiff = -999;}
00401             else {
00402               groupDiff += ihit->resid(0) * ihit->resid(0) * ihit->weight() /
00403                 aDof -
00404                 otherHot->resid(0) * otherHot->resid(0) * otherHot->weight() /
00405                 otherDof;
00406             }
00407             theseHits[nFound] = const_cast<TrkHitOnTrk*>(ihit.get());
00408             thoseHits[nFound] = otherHot;
00409             nFound++;
00410             dropThisHit = 1;
00411           } else {   // handle hits individually
00412 
00413             if (8 == tkParam.lPrint) {
00414               std::cout<<"handle hits individually"<<  std::endl;
00415             }
00416             nFound++;
00417             if (fabs(ihit->resid(0)) > fabs(otherHot->resid(0)) ) {
00418               // turn off (inactivate) hit on this track
00419               lRefit = 1;
00420               //              ihit->hit()->setUnusedHit(ihit.get());
00421               //Should I be setting inactive, or deleting the hit???????
00422               const_cast<TrkHitOnTrk*>(ihit.get())->setActivity(0);
00423               dropThisHit = 1;
00424               if (8 == tkParam.lPrint) {
00425                 std::cout<<"dorp hit ";
00426                 const_cast<TrkHitOnTrk*>(ihit.get())->print(std::cout);
00427               }
00428               break;      // found other hit, so quit loop
00429             } else {
00430               // inactivate hit on other track
00431               refitTrack[otherIndex] = 1;
00432               //              otherHot->hit()->setUnusedHit(otherHot);
00433               otherHot->setActivity(0);
00434               if (8 == tkParam.lPrint) {
00435                 std::cout<<"inactive hit on other track";
00436                 const_cast<TrkHitOnTrk*>(ihit.get())->print(std::cout);
00437               }
00438               break;      // found other hit, so quit loop
00439             }
00440           } // end grouped/individual treatment
00441 
00442           if (dropThisHit == 1) break; // don't look for other matches since
00443           // this hit is now turned off
00444         } // end loop over nUsed
00445 
00446         // Quit if we've found all of the shared hits on this track
00447         if (lGroupHits && nFound == nMost  ||  nFound == nPrev) {
00448           if (8 == tkParam.lPrint) {
00449             std::cout<<"we've found all of the shared hits on this track,Quit"<<std::endl;
00450           }
00451           break;
00452         }
00453 
00454       }  // end loop over hits
00455 
00456       // Decide which track grouped hits belong with and inactivate accordingly
00457       if (lGroupHits) {
00458         if (8 == tkParam.lPrint) {
00459           cout << "nGroup: " << nMost << "  groupDiff: " << groupDiff << endl;
00460           cout << "Track: " << aRecoTrk.id() << "  nHit: "
00461             << hitList->nHit() << "  nActive: "
00462             << tkFit->nActive() << " chisq/dof: " <<
00463             tkFit->chisq()/(tkFit->nActive() - 5) << endl;
00464           TrkRecoTrk& othTrack = trkXRef[trackMost]->track();
00465           cout << "Track: "<< othTrack.id() << "  nHit: " <<
00466             othTrack.hits()->nHit() << "  nActive: " <<
00467             othTrack.fitResult()->nActive() << " chisq/dof: " <<
00468             othTrack.fitResult()->chisq() /
00469             (othTrack.fitResult()->nActive() - 5) << endl;
00470         }
00471 
00472         if (groupDiff > 0.0) {
00473           // inactivate hits on this track
00474           lRefit = 1;
00475           for (int ii = 0; ii < nMost; ii++) {
00476             TrkHitOnTrk *alink = theseHits[ii];
00477             TrkFundHit* hit = const_cast<TrkFundHit*> (alink->hit());
00478             hitList->removeHit(hit);//yzhang 2011-02-12 
00479             //alink->setActivity(0);
00480           }
00481           if (8 == tkParam.lPrint) std::cout<<"inactive hits on this track, No."<<aRecoTrk.id()<<  std::endl;
00482         } else {
00483           // inactivate hits on other track
00484           refitTrack[trackMost] = 1;
00485           for (int ii = 0; ii < nMost; ii++) {
00486             TrkHitOnTrk *alink = thoseHits[ii];
00487             TrkFundHit* hit = const_cast<TrkFundHit*> (alink->hit());
00488             hitList->removeHit(hit);//yzhang 2011-02-12 
00489             //alink->setActivity(0);
00490           }
00491           if (8 == tkParam.lPrint) std::cout<<"inactive hits on other track "<<   std::endl;
00492         }
00493         delete [] theseHits;
00494         delete [] thoseHits;
00495 
00496       } // end if lGroupHits
00497 
00498     } // end if nMost > 0
00499 
00500     //*********
00501     // Refit this track, if any hits have been dropped
00502     TrkErrCode fitResult;
00503     long index = -1;
00504     idMap.get(aRecoTrk.id(), index); assert (index >= 0);
00505 
00506     if (lRefit || refitTrack[index] == 1) {
00507       if (8 == tkParam.lPrint) {
00508         std::cout<<"after group ,refit track"<<aRecoTrk.id()<<  std::endl;
00509       }
00510       fitResult = hitList->fit();
00511       aRecoTrk.status()->addHistory(
00512           TrkErrCode(fitResult.success()?TrkErrCode::succeed:TrkErrCode::fail,14,"Arbitrated"), "MdcTrkRecon");
00513       if (fitResult.failure() && (8 == tkParam.lPrint )) {
00514         fitResult.print(std::cerr);
00515       }
00516 
00517 
00518       double chisqperDOF;
00519       bool badFit = true;
00520       if (fitResult.success()) {
00521         badFit = false;
00522         int nDOF = tkFit->nActive() - 5;
00523         if (nDOF > 5){
00524           chisqperDOF = tkFit->chisq() / nDOF;
00525         }else{
00526           chisqperDOF = tkFit->chisq();
00527         }
00528 
00529         if (chisqperDOF > tkParam.maxChisq) badFit = true;
00530         if (tkFit->nActive() < tkParam.minHits) badFit = true;
00531         double tem2 = (float) hitList->nHit() - tkFit->nActive();
00532         if (tkParam.lUseQualCuts) {
00533           if (tem2 >= tkParam.maxNmissTrack) badFit = true;
00534           if (tem2 /float(hitList->nHit()) > tkParam.maxNmissNorm){
00535             badFit = true;
00536           }
00537         }
00538         if(8== tkParam.lPrint) std::cout<<"fit quality:"<<
00539           " chisqperDof "<<chisqperDOF<<"?>"<<tkParam.maxChisq<<
00540             " nActive "<<tkFit->nActive()<<"?<"<<tkParam.minHits<<
00541             " nHit "<<hitList->nHit()<<" nhit-act "<<tem2<<"?>= nMiss "<<tkParam.maxNmissTrack<<
00542             " hit-act/nhit "<<tem2/float(hitList->nHit())<<"?> MissNorm "<<tkParam.maxNmissNorm
00543             <<  std::endl;
00544 
00545 
00546       }
00547       if (8 == tkParam.lPrint)  {
00548         cout << "Refitting track " << aRecoTrk.id() << " success = "
00549           << fitResult.success() << "\n";
00550       }
00551       // If the track no longer passes cuts, delete it
00552       if (fitResult.failure() || badFit ) {
00553         nDeleted++;
00554         //  Don't change the track list while we're iterating through it!
00555         //      remove(atrack);
00556         //int id = aRecoTrk.id();
00557         if (8 == tkParam.lPrint) {
00558           cout << "fitResult.failure? "<<fitResult.failure()
00559             <<" badFit? "<<badFit <<" Killing tkNo " << itrack << endl;
00560         }
00561         delete &(atrack->track());    // Delete the RecoTrk inside atrack
00562         atrack->setTrack(0);
00563         trksToKill.push_back(atrack);
00564         continue;
00565       }
00566     } // end if lRefit
00567 
00568     if (lGroupHits) goto restart;
00569 
00570   } // end loop over tracks
00571   if (8 == tkParam.lPrint) std::cout<<"end of loop over tracks"<<  std::endl;
00572 
00573   // Remove dead track husks
00574   for (int itk = 0; itk < (int)trksToKill.size(); itk++) {
00575     remove(trksToKill[itk]);
00576     if (8 == tkParam.lPrint) std::cout<<"remode dead track No."<<itk<<  std::endl;
00577   }
00578   if (8 == tkParam.lPrint) std::cout<<"---end of arbitrateHits"<<  std::endl;
00579 
00580   delete [] usedInTrackNum;
00581   delete [] refitTrack;
00582   delete [] trkXRef;
00583   return nDeleted;
00584 }

int MdcTrackListCsmc::createFromSegs ( MdcSegList segs,
const MdcHitMap ,
const MdcDetector ,
TrkContext ,
double  trackT0 
) [virtual]

Implements MdcTrackListBase.

Definition at line 45 of file MdcTrackListCsmc.cxx.

References EvtCyclic3::append(), MdcSegGrouper::combineSegs(), MdcSegGrouperSt::fillWithSegs(), MdcSegGrouperCsmc::fillWithSegs(), finish3d(), MdcSegList::getSeed(), MdcTrackParams::lPrint, MdcTrackParams::maxSegChisqO, TrkRecoTrk::printAll(), MdcSegList::resetSeed(), MdcTrackListBase::tkParam, and MdcTrack::track().

00047                                                                      {
00048 // *************************************************************************
00049   // Forms tracks out of list of superlayer segments
00050   int nTracks = 0;
00051   // Create empty list of stereo segs (to save time)
00052   MdcSegGrouperSt stereoSegs(gm,tkParam.lPrint);
00053   // *** Create r-phi track
00054 
00055   // Create list of axial segments, treated as on straight tracks
00056   MdcSegGrouperCsmc straightSegs(gm, tkParam.lPrint);
00057   straightSegs.fillWithSegs(segs);
00058   //std::cout<< "after straight fill  " << std::endl; 
00059   //segs->plot();//yzhang debug
00060   MdcSeg *seed;
00061   int goodOnly = 1;
00062   MdcTrack* trialTrack = 0;
00063   while (1) {
00064     seed = segs->getSeed(0,goodOnly);
00065     if (seed == 0 && goodOnly == 1) {
00066       segs->resetSeed(gm);
00067       goodOnly = 0;
00068       continue;
00069     }
00070     else if (seed == 0 && goodOnly == 0) {
00071       break;
00072     }
00073     delete trialTrack;
00074     trialTrack = 0;            
00075     int success = straightSegs.combineSegs(trialTrack, seed,
00076                                            context, t0, tkParam.maxSegChisqO);
00077     if (!success) {
00078       //std::cout<< " MdcTrackListCsmc::combineSegs not successed!" << std::endl;
00079       continue;
00080     }
00081 
00082     if (tkParam.lPrint > 1) {
00083       trialTrack->track().printAll(cout);
00084     }
00085     // *** End r-phi track-finding
00086 
00087     // *** Add stereo to taste
00088     stereoSegs.fillWithSegs(segs, trialTrack);
00089 
00090     success = stereoSegs.combineSegs(trialTrack, 0, context, t0, 
00091                                      tkParam.maxSegChisqO);
00092     if (success) {
00093     // Finish 3-d track;
00094       success = finish3d(trialTrack->track());
00095       //      success = finish3d(trialTrack->track()); // GSciolla: try to repeat
00096     }  
00097     if (!success) {
00098       //std::cout<< " MdcTrackListCsmc::finish3d not successed!" << std::endl;
00099       continue;
00100     }
00101 
00102     if (tkParam.lPrint > 1) {
00103       trialTrack->track().printAll(cout);
00104     }
00105 
00106     nTracks++;
00107     append(trialTrack);    // Add to list of Tracks
00108     trialTrack = 0;
00109     
00110   }  // end while(1)   
00111   delete trialTrack;
00112   
00113 
00114   //cout << " Number of Tracks found= " << nTracks  ;
00115   //cout << " " << endl;
00116   return nTracks;
00117 }

void MdcTrackListBase::dropMultiHotInLayer ( const MdcTrack tk  )  [inherited]

Reimplemented in MdcTrackList.

int MdcTrackListCsmc::finish3d ( TrkRecoTrk trk  ) 

Definition at line 120 of file MdcTrackListCsmc.cxx.

References TrkSimpleMaker< T >::changeFit(), TrkAbsFit::chisq(), TrkHitList::fit(), TrkRecoTrk::fitResult(), TrkRecoTrk::hits(), MdcTrackParams::maxChisq, MdcTrackParams::minHits, TrkFit::nActive(), TrkSimpleMaker< T >::setFlipAndDrop(), TrkErrCode::success(), and MdcTrackListBase::tkParam.

Referenced by createFromSegs().

00120                                               {
00121 // ************************************************************************
00122   int success = 0;
00123   int nParamFit = 0 ;
00124 
00125   TrkErrCode fitResult;
00126 
00127   // ------------------------
00128   //   4 param fit (line)
00129   // ------------------------
00130   nParamFit = 4;
00131   TrkLineMaker makeFit;
00132   makeFit.changeFit(trk);
00133   makeFit.setFlipAndDrop(trk, true, true);
00134   //setCosmic(&trk);    // set hot to cosmics OBSOLETE! REMOVE!
00135   fitResult = trk.hits()->fit();
00136   makeFit.setFlipAndDrop(trk, false, false);  
00137   
00138   // ---------------------------------------------------------------
00139   // Are there some TDC that can be replaced with later measurements? ( beginning) 
00140   // ---------------------------------------------------------------
00141   // Note to Sciolla: multiple hits commented out for now OK! I will put it back later...
00142   /*  if( _flags.useMultipleHits ) { 
00143     int NHITS   = trk.nHit(); 
00144     
00145     if (fitResult.success()) {
00146       int ifirst = 0;     
00147       for (int ihot = 0; ihot < NHITS ; ihot++) {
00148         
00149         MdcHitOnTrack* ahot = (MdcHitOnTrack*)trk.hitAList()[ihot];
00150         double firstTime = ahot->mdcHit()->rawTime(0); 
00151         
00152         // Get the list of times for this Digi 
00153         const MdcDigi* tmpDigi = ahot->mdcHit()->digi() ; 
00154 //      int nTDChits = tmpDigi->getTdcTimeAList()->length() ;
00155         int nTDChits = tmpDigi->tmdcits() ;
00156         
00157         double newTime=0. ; 
00158         
00159         for( int il = 1; il<nTDChits ; il++){ 
00160           
00161           // get the time corresponding to this doca ---> distance to time 
00162           newTime = tmpDigi->TdcTime(il); 
00163           double newDrift = ahot->layer()->timeToDistance(newTime); 
00164           
00165           double tmp_doca  = ahot->dcaToWire();
00166           double new_diff = fabs(fabs(tmp_doca)-fabs(newDrift)); 
00167           double tmp_drift = ahot->drift();
00168           double tmp_drift2 = 
00169             ahot->layer()->timeToDistance(tmpDigi->TdcTime(0)); 
00170           double old_diff  = fabs(fabs(tmp_doca)-fabs(tmp_drift2)); 
00171           
00172           if( ((old_diff-new_diff)>0.1)  // new time better then old of at least 1 mm  
00173               && (new_diff<=0.8) ) { // and newresid < 2 mm 
00174             //  if(_flags.debug) {                  
00175             if(1) { 
00176               
00177               if(ifirst==0) { 
00178                 ifirst = 1 ; 
00179                 cout <<" nHits | time1  |fittim | time2 | doca(mm) | drift1 " 
00180                      <<"  drift1(rec) | drift2 | layer | wire | isActive" 
00181                      << " | chi2 | nactive" << endl; 
00182               }
00183               
00184               int isAct = 1 ; 
00185               if (!ahot->isActive()) { 
00186                 isAct = 0 ; 
00187                 //      cout<< " >> " ;    
00188                 //      cout << "This hit is not active " << endl ;
00189               }
00190               
00191               cout << "   " << nTDChits 
00192                    << "    " << tmpDigi->TdcTime(0) 
00193                    << "  " << ahot->fitTime()
00194                    << "  " <<  newTime  
00195                    << "  " << tmp_doca*10
00196                    << "  " << tmp_drift*10 
00197                    << "  " << tmp_drift2*10 
00198                    << "  " << newDrift*10 
00199                    << "  " << ahot->layer()->layNum() 
00200                    << "  " << ahot->wire()
00201                    << "  " <<  isAct 
00202                    << "  " << trk.chisq()
00203                    << "  " << trk.nActive() 
00204                    << endl;       
00205               
00206               cout << " old/new diff (mm) = " << old_diff*10 
00207                    << " | " << new_diff*10
00208                    << endl ; 
00209             }     
00210             
00211             ahot->setTimeIndex(il) ; 
00212             //  cout << "new rawtime =" 
00213             //     << ahot->mdcHit()->rawTime(0)<< endl ; // check the new value 
00214             
00215             
00216             // store results in ntuple to see improvements ... before ...               
00217             HepTuple* tupleMultHits = _manager->ntuple("multiHits");
00218             
00219             tupleMultHits->column("ch2Dof1", trk.chisq()/(trk.nActive() - 4));
00220             tupleMultHits->column("nActiv1", trk.nActive());
00221             tupleMultHits->column("resid1",ahot->resid());
00222             tupleMultHits->column("doca1",ahot->resid()+ahot->drift()); 
00223             tupleMultHits->column("time1",  ahot->fitTime() );   
00224             tupleMultHits->column("rawtime1",  ahot->mdcHit()->rawTime(il) ); 
00225             
00226             // - make the hit active and usable 
00227             ahot->setActivity(true);
00228             
00229             // now refit the track ... 
00230             fitResult = trk.fit();
00231             
00232             // store results in ntuple to see improvements ... after ...                
00233             tupleMultHits->column("ch2Dof2", trk.chisq()/(trk.nActive() - 4));
00234             tupleMultHits->column("nActiv2", trk.nActive());
00235             tupleMultHits->column("resid2",ahot->resid());
00236             tupleMultHits->column("doca2",ahot->resid()+ahot->drift()); 
00237             tupleMultHits->column("time2",  ahot->fitTime() );   
00238             tupleMultHits->column("rawtime2",  ahot->mdcHit()->rawTime(il) );   
00239             tupleMultHits->dumpData();
00240           }
00241         }
00242       }
00243     }  
00244   } // Are there some TDC that can be replaced with later measurements?  (end)
00245   */
00246   
00247   const TrkFit* tkFit = trk.fitResult();
00248   double chisqperDOF = 0.;
00249   if (fitResult.success()) {
00250     int nDOF = tkFit->nActive() - nParamFit;
00251     if (nDOF > nParamFit) 
00252       chisqperDOF = tkFit->chisq() / nDOF;
00253     else 
00254       chisqperDOF = tkFit->chisq();
00255     int goodMatch = 1;
00256     if (chisqperDOF > tkParam.maxChisq) goodMatch = 0;
00257     if (tkFit->nActive() < tkParam.minHits) goodMatch = 0;
00258 
00259     if (goodMatch) success = 1;
00260   }
00261   
00262   return success;
00263 }

void MdcTrackListBase::newParams ( const MdcTrackParams tkPar  )  [inherited]

Definition at line 588 of file MdcTrackListBase.cxx.

References MdcTrackListBase::tkParam.

00588                                                        {
00589   //**************************************************************************
00590   tkParam = tkPar;
00591 }

int MdcTrackListBase::nTrack (  )  const [inline, inherited]

Definition at line 39 of file MdcTrackListBase.h.

Referenced by MdcTrackListBase::arbitrateHits(), MdcTrackListBase::plot(), and MdcTrackListBase::store().

00039 {return length();}

void MdcTrackListBase::plot (  )  const [inherited]

Definition at line 92 of file MdcTrackListBase.cxx.

References MdcTrackListBase::nTrack().

00092                              {
00093   //*************************************************************************
00094   std::cout<< "nTrack   "<<nTrack() << std::endl;//yzhang debug
00095   for (int itrack = 0; itrack < nTrack(); itrack++) {
00096     MdcTrack *atrack = (*this)[itrack];
00097     if (atrack == NULL) continue;
00098     atrack->track().printAll(cout);
00099   }
00100 }

void MdcTrackListCsmc::remove ( MdcTrack atrack  ) 

Reimplemented from MdcTrackListBase.

void MdcTrackListBase::setD0Cut ( double  d0Cut  )  [inline, inherited]

Definition at line 57 of file MdcTrackListBase.h.

References MdcTrackListBase::m_d0Cut.

00057 {m_d0Cut = d0Cut;}//yzhang add 

void MdcTrackListBase::setPlot ( int  plotFlag  )  [inline, inherited]

Definition at line 40 of file MdcTrackListBase.h.

References MdcTrackParams::lPlot, and MdcTrackListBase::tkParam.

00040 { tkParam.lPlot = plotFlag;};

void MdcTrackListBase::setPtCut ( double  ptCut  )  [inline, inherited]

Definition at line 59 of file MdcTrackListBase.h.

References MdcTrackListBase::m_ptCut.

00059 {m_ptCut = ptCut;}//yzhang add 2009-10-27

void MdcTrackListBase::setZ0Cut ( double  z0Cut  )  [inline, inherited]

Definition at line 58 of file MdcTrackListBase.h.

References MdcTrackListBase::m_z0Cut.

00058 {m_z0Cut = z0Cut;}//yzhang add 2010-05-21 

void MdcTrackListBase::store ( RecMdcTrackCol ,
RecMdcHitCol  
) [inherited]

Definition at line 75 of file MdcTrackListBase.cxx.

References MdcTrackListBase::nTrack().

00075                                                                         {
00076   // ***********************************************************************
00077   int trackId = 0;
00078   for (int itrack = 0; itrack < nTrack(); itrack++) {
00079     MdcTrack* track = (*this)[itrack];
00080     //tkStat:  0,PatRec 1,MdcxReco 2,Tsf 3,CurlFinder
00081     int tkStat = 0;
00082     track->storeTrack(trackId, trackList, hitList, tkStat);
00083     ++trackId;
00084   }
00085   HepAListDeleteAll(*this);   // Discard the husks
00086   removeAll(); 
00087   return;
00088 }


Member Data Documentation

double MdcTrackListBase::m_d0Cut = -999. [static, inherited]

Definition at line 60 of file MdcTrackListBase.h.

Referenced by MdcTrackList::createFromSegs(), MdcTrkRecon::initialize(), and MdcTrackListBase::setD0Cut().

double MdcTrackListBase::m_ptCut = -999. [static, inherited]

Definition at line 62 of file MdcTrackListBase.h.

Referenced by MdcTrackList::createFromSegs(), MdcTrkRecon::initialize(), and MdcTrackListBase::setPtCut().

double MdcTrackListBase::m_z0Cut = -999. [static, inherited]

Definition at line 61 of file MdcTrackListBase.h.

Referenced by MdcTrackList::createFromSegs(), MdcTrkRecon::initialize(), and MdcTrackListBase::setZ0Cut().

MdcTrackParams MdcTrackListBase::tkParam [protected, inherited]

Definition at line 72 of file MdcTrackListBase.h.

Referenced by MdcTrackListBase::arbitrateHits(), createFromSegs(), MdcTrackList::createFromSegs(), finish3d(), MdcTrackList::finishCircle(), MdcTrackList::finishHelix(), MdcTrackListBase::MdcTrackListBase(), MdcTrackListBase::newParams(), MdcTrackList::pickHits(), and MdcTrackListBase::setPlot().


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