/** @file trackdiff.cu compares tracks from two files */ #include #include #include #include #include #include #include #include "track.h" #include "util.h" #include "vec.h" using namespace std; void not_matched_tracks (const vector &tracks, const vector &matches, vector ¬_matched) { for(int itrack = 0; itrack < tracks.size(); itrack++) if(matches[itrack] == -1) not_matched.push_back(tracks[itrack]); } int main(int argc, char ** argv) { // check arguments if(argc < 2) { fprintf(stderr, "usage: trackdiff \n"); exit(-1); } // open files const char *path1 = argv[1], *path2 = argv[2]; FILE *f1, *f2; if(!(f1 = fopen(path1, "r"))) { fprintf(stderr, "cannot open file %s\n", path1); exit(-1); } if(!(f2 = fopen(path2, "r"))) { fprintf(stderr, "cannot open file %s\n", path2); exit(-1); } // read tracks vector tracks1, tracks2; read_tracks(f1, tracks1); read_tracks(f2, tracks2); fclose(f1); fclose(f2); int n1 = tracks1.size(), n2 = tracks2.size(); //printf("n1 = %d, n2 = %d\n", n1, n2); // compare tracks double EPS = 1.5; vector matches1(n1, -1), matches2(n2, -1); //vector match_counts1(n1, 0), match_counts2(n2, 0); // find a match for each track for(int i1 = 0; i1 < n1; i1++) { Track t1 = tracks1[i1]; for(int i2 = 0; i2 < n2; i2++) { if(matches2[i2] != -1) continue; if(diff_with_hits(t1, tracks2[i2]) < EPS) { //if(diff(t1, tracks2[i2]) < EPS) { // match found matches1[i1] = i2; matches2[i2] = i1; //match_counts1[i1]++; //match_counts2[i2]++; //printf("match: < %d > %d\n", i1, i2); break; } } // for(each track 2) } // for(each track 1) int nnot_matched1 = count_if(matches1.begin(), matches1.end(), bind2nd(equal_to(), -1)); int nnot_matched2 = count_if(matches2.begin(), matches2.end(), bind2nd(equal_to(), -1)); // int nnot_matched1 = count_if(match_counts1.begin(), match_counts1.end(), // bind2nd(equal_to(), 0)); // int nnot_matched2 = count_if(match_counts2.begin(), match_counts2.end(), // bind2nd(equal_to(), 0)); printf("< %d > %d\n", nnot_matched1, nnot_matched2); // print non-matched tracks vector not_matched1, not_matched2; not_matched_tracks(tracks1, matches1, not_matched1); not_matched_tracks(tracks2, matches2, not_matched2); printf("< %d:\n", nnot_matched1); write_tracks(stdout, not_matched1); printf("> %d:\n", nnot_matched2); write_tracks(stdout, not_matched2); return 0; } // main