newisbest=false;// guess we're not the best, give up!
break;
}
}
}// loop over incoming tracks
// if the new track is better than all the matching old tracks, remove the old tracks and add this one, otherwise do nothing (the new track is dropped)
if(newisbest){
//yikes, we're better than all the matching old tracks
boolreplacedfirsttrack=false;//I want to check that the algorithm really replaces the first old track with the new one, and just once
for(unsignedinte:matching_oldtracks){
if(e==matching_oldtracks[0]){//this should be a little faster than removing all the old matching tracks and then adding the new one
m_trks_nodups->at(e)=(FTK_RawTrack*)track;// replace the first matching track with this new track
if(replacedfirsttrack)ATH_MSG_WARNING("We already did replace the first matching track!");
replacedfirsttrack=true;//just check that we really did it!
}
else{
//remove the old matching tracks beyond the first one
m_trks_nodups->erase(m_trks_nodups->begin()+e);// yes this is really the way you remove an element from a vector, you have to pass in the iterator
}
}
if(!replacedfirsttrack)ATH_MSG_WARNING("Why did I not replace the first track?!");
}// new track is best one
}// deciding what to do based on the number of matches
//maybe at the end we should do a check that no further matches exist?