#ifndef TRIPLETS_TRACK_H_ #define TRIPLETS_TRACK_H_ /** @file track.h track data */ #include #include #include #include "data.h" #include "layout-ptr.h" #include "triplet.h" #include "util.h" #include "vec.h" using namespace std; /** the track structure */ template struct Track_flex { typedef float layfield_t; typedef laygroup_t group_t; typedef Track_flex Track; hostdevice__ Track_flex() : t0(0), min_t0(FLT_MAX), max_t0(0), wstart(0), wend(0), nhits(0), center(fvec3::from(0)), radius(0), is_clockwise(false), vertex(fvec3::from(0)), momentum(fvec3::from(0)), inner_tube_id(0), outer_tube_id(0) { } hostdevice__ operator Track() const { Track track; track.t0 = t0; track.min_t0 = min_t0; track.max_t0 = max_t0; track.wstart = wstart; track.wend = wend; track.nhits = nhits; track.center = (fvec3)center; track.radius = radius; track.is_clockwise = is_clockwise; track.vertex = (fvec3)vertex; track.momentum = (fvec3)momentum; track.inner_tube_id = inner_tube_id; track.outer_tube_id = outer_tube_id; return track; } hostdevice__ Track operator=(const Track &track) { t0 = track.t0; min_t0 = track.min_t0; max_t0 = track.max_t0; wstart = track.wstart; wend = track.wend; nhits = track.nhits; center = track.center; radius = track.radius; is_clockwise = track.is_clockwise; vertex = track.vertex; momentum = track.momentum; inner_tube_id = track.inner_tube_id; outer_tube_id = track.outer_tube_id; //return track; return (Track)*this; } /** compute the distance between the track and the tube */ hostdevice__ float dist(const fvec3 &hit_pos) const; /** checks whether the hit is in the specified space range; the hit is represented by its center */ hostdevice__ bool hit_in_range (const fvec2 &hit_pos, float max_dist) const; hostdevice__ bool hit_in_range (const fvec3 &hit_pos, float max_dist) const; /** checks whether the hit is in range, but performs only the sign check */ hostdevice__ bool hit_sign_in_range(fvec3 &hit_pos) const; /** checks whether the hit is in the specified space range */ hostdevice__ bool hit_in_range (const Hit &hit, layptr tubes, float max_dist) const; /** checks whether the triplet (skewlet) is in range */ hostdevice__ bool triplet_in_range (const Triplet &triplet, float max_dist) const; /** adds the hit */ hostdevice__ void add_hit(const Hit &hit); /** adds the hit time (the only thing from the hit needed to be added */ hostdevice__ void add_hit_time(float t); /** the possible time interval of the track */ union {float t0; group_t dummy0; }; union {float min_t0; group_t dummy1; }; union {float max_t0; group_t dummy2; }; /** the window times */ union {float wstart; group_t dummy3; }; union {float wend; group_t dummy4; }; /** vertex of the track (CMS of the inner triplet) */ vec3_flex vertex; /** momentum of the track (CMS of the outer triplet) */ vec3_flex momentum; /** center of the track circle */ vec3_flex center; /** radius of track circle */ union{float radius; group_t dummy5; }; union { struct { /** whether the track is clockwise */ bool is_clockwise; /** number of hits associated with the track */ short nhits; }; group_t dummy6; }; union { struct { /** inner tube (triplet pivot straw) of the track */ short inner_tube_id; /** outer tube (triplet pivot straw) of the track */ short outer_tube_id; }; group_t dummy7; }; }; typedef Track_flex Track; template struct layflex_t { typedef Track_flex flex_t; }; /** track time comparator */ class track_t0_less { public: bool operator()(const Track &a, const Track &b) { return a.t0 < b.t0; } }; // track_t0_less /** writes the tracks to the specified file @param file the file where to write the tracks @param tracks the vector of tracks to write */ void write_tracks(FILE *file, const vector &tracks); /** writes the tracks to the specified file @param path the path to the file into which to write tracks @param tracks the tracks to write */ void write_tracks(const char *path, const vector &tracks); /** reads the tracks from the file and appends them to the vector @param file file from which to read tracks @param tracks [out] the vector in which to read tracks */ void read_tracks(FILE *file, vector &tracks); /** gets absolute difference between tracks (with respect to xy vertex/momentum and timestamp) */ double diff(const Track &t1, const Track &t2); /** gets absolute difference between tracks, including number of hits */ double diff_with_hits(const Track &t1, const Track &t2); /** a helper function to check whether the hit is in range */ hostdevice__ bool hit_in_range (const fvec3 ¢er, float radius, bool is_clockwise, const fvec2 &hit_pos, float max_dist); #endif