149 {
150
151
153 if (!trackList) return -1;
154
155 int needMerge = 0;
156
157
158 RecMdcTrackCol::iterator iterRefTk = trackList->begin();
159 for (; iterRefTk != trackList->end(); iterRefTk++) {
161 if (refTk->
stat()<0)
continue;
162 std::vector<RecMdcTrack*> mergeTkList;
163 mergeTkList.push_back(refTk);
164
165
166 bool curl = false;
167 int sameParm = 0;
168 RecMdcTrackCol::iterator iterTestTk = trackList->begin();
169 for (; iterTestTk != trackList->end(); iterTestTk++) {
171 if (iterRefTk == iterTestTk || (testTk->
stat()<0))
continue;
172
173
175 if(m_debug>0)std::cout<<__FILE__<<
" overlape tk:" <<refTk->
trackId()<<
" with "<<testTk->
trackId()<< std::endl;
176 mergeTkList.push_back(testTk);
177 curl = true;
178 }
180 if(sameParm >0) {
181 if(m_debug>0) std::cout<<__FILE__<<
" same param tk:" <<refTk->
trackId()<<
" with "<<testTk->
trackId()<< std::endl;
182 mergeTkList.push_back(testTk);
183 }
184 }
185 if (mergeTkList.size()>1 && curl) needMerge =
doMergeCurl(mergeTkList);
186 if ((needMerge < 999) && mergeTkList.size()>1 ) needMerge =
doMergeLong(mergeTkList);
187
188 }
189
190
191 if( needMerge <=0 ) return 0;
192
193
194 iterRefTk = trackList->begin();
195 int iTk=0;
196 int nDeleted = 0;
197 for (; iterRefTk != trackList->end(); ) {
198 if ( (*iterRefTk)->stat() >= 0 ){
199 (*iterRefTk)->setTrackId(iTk);
200 iterRefTk++;
201 iTk++;
202 }else {
203 int id = (*iterRefTk)->trackId();
205 if ( erased ){
206 nDeleted++;
207 if(m_debug>0)std::cout<<__FILE__<<" erase track No."<<id<< std::endl;
208 }else {
209 if(m_debug>0)std::cout<<__FILE__<<" erase failed !"<< std::endl;
210 }
211 }
212
213 }
214 if(m_debug>0) std::cout<<__FILE__<<" After merge save "<<iTk<<" tracks"<< std::endl;
215
216 return nDeleted;
217}
int doMergeLong(std::vector< RecMdcTrack * > mergeTkList)
int testByParam(RecMdcTrack *refTk, RecMdcTrack *testTk)
bool eraseTdsTrack(RecMdcTrackCol::iterator tk)
int testByOverlapHit(RecMdcTrack *refTk, RecMdcTrack *testTk)
int doMergeCurl(std::vector< RecMdcTrack * > mergeTkList)