Functions | |
| int | GetMCTracks (const RBKTrack &trk, std::vector< int > &trkList) |
| Fill a vector of MC track numbers which generated this track. | |
| int MCUtil::GetMCTracks | ( | const RBKTrack & | trk, | |
| std::vector< int > & | trkList | |||
| ) |
Fill a vector of MC track numbers which generated this track.
The first entry in the vector will be the most "significant" MCTrack. Use that for MCTrack-TPCRTrack association.
Definition at line 37 of file MCUtil.cxx.
References RBKTrack::NSpacePoints(), RBKTrack::NViewHits(), RBKTrack::SpacePoint(), tl, and RBKTrack::ViewHit().
Referenced by RICHReco::EvFill().
00038 { 00039 // Loop over all hits in the track 00040 int nhit = trk.NSpacePoints(); 00041 trkList.clear(); 00042 00043 map<int, int, TrkNumComp> trkHitCount; 00044 00045 for (int i = 0; i < nhit; ++i) { 00046 const TPCRHit* hit = 00047 dynamic_cast<const TPCRHit*>(&trk.SpacePoint(i)); 00048 if (!hit) continue; 00049 00050 // Loop over all the digits that make up this hit 00051 int ndig = hit->Cluster()->NDigits(); 00052 for (int j = 0; j < ndig; ++j) { 00053 const TPCDigit* dig = hit->Cluster()->Digit(j); 00054 if (!dig) continue; 00055 00056 const MCCTrkList* tl = dig->TrkList(); 00057 if (!tl) continue; 00058 00059 // Loop over all the MCCHit's that make up this digit and 00060 // count the number of times each MC track happens 00061 for (int k = 0; k < tl->NTrack(); ++k) 00062 ++(trkHitCount[tl->Track(k)]); 00063 } 00064 } 00065 00066 // Now loop over wire clusters 00067 for (int i = 0; i < trk.NViewHits(); ++i) { 00068 const WireClust* hit = 00069 dynamic_cast<const WireClust*>(&trk.ViewHit(i)); 00070 if (!hit) continue; 00071 00072 // And loop over wires that make up the cluster 00073 for (int j = 0; j < hit->NWire(); ++j) { 00074 const Wire* w = hit->GetWire(j); 00075 if (!w) continue; 00076 00077 const MCCTrkList* tl = w->MCTracks(); 00078 if (!tl) continue; 00079 00080 for (int k = 0; k < tl->NTrack(); ++k) 00081 ++(trkHitCount[tl->Track(k)]); 00082 } 00083 } 00084 00085 if (trkHitCount.empty()) return 0; 00086 00087 // Find the most populous track and the second most populous track 00088 int maxNmcTrk = 0; 00089 int maxIndx = 0; 00090 int maxNmcTrk2 = 0; 00091 int maxIndx2 = 0; 00092 map<int, int, TrkNumComp>::iterator itr(trkHitCount.begin()); 00093 map<int, int, TrkNumComp>::iterator itrEnd(trkHitCount.end()); 00094 for ( ; itr != itrEnd; ++itr) { 00095 int n = (*itr).second; 00096 if (n > maxNmcTrk) { 00097 maxNmcTrk2 = maxNmcTrk; 00098 maxIndx2 = maxIndx; 00099 00100 maxNmcTrk = n; 00101 maxIndx = (*itr).first; 00102 } 00103 else if (n > maxNmcTrk2) { 00104 maxNmcTrk2 = n; 00105 maxIndx2 = (*itr).first; 00106 } 00107 } 00108 00109 // Insert the "most visible" track first -- this is what most 00110 // everyone should use for TPCRTrack-MCTrack association 00111 trkList.push_back(maxIndx); 00112 if (trkHitCount.size() == 1) return 0; 00113 trkList.push_back(maxIndx2); 00114 00115 itr = trkHitCount.begin(); 00116 for ( ; itr != itrEnd; ++itr) { 00117 int trkNum = (*itr).first; 00118 if (trkNum == maxIndx || trkNum == maxIndx2) continue; 00119 trkList.push_back(trkNum); 00120 } 00121 00122 return maxNmcTrk - maxNmcTrk2; 00123 00124 }
1.4.7