#ifndef HOUGH_H_ #define HOUGH_H_ /** @file hough.h dynamic Hough transform implementation header */ #include #include "event-point.h" /** default grid size for HT; hardcoded, as it is used for template instantiation */ #define HOUGH_NG 256 using namespace std; /** parameters of the Hough transform (in future, will be parsed from the command line) */ struct HoughOptions { inline HoughOptions() : ngrid(HOUGH_NG), max_depth(2), nmax_tracks(128 * 1024), node_threshold(19), leaf_threshold(19) {} /** local grid size at each depth */ int ngrid; /** maximum nesting depth; 1 means simple Hough transform */ int max_depth; /** maximum number of tracks that can be reconstructed */ int nmax_tracks; /** node threshold - for continuing search */ int node_threshold; /** leaf threshold - for line detection */ int leaf_threshold; }; // struct HoughOptions /** this class implements adaptive Hough transform on the GPU */ class Hough { /** creates a Hough transform @param eps the event points @param opts the options for the Hough transform */ Hough(const vector &eps, const HoughOptions& opts); /** the destructor */ ~Hough(); /** performs the transformation @returns the tracks reconstructed by the transformation */ vector transform(); // fields /** event points being analyzed */ vector eps; /** Hough transform options */ HoughOptions opts; /** the number of points being analyzed */ int np; /** the number of events being analyzed */ int nevt; /** inverted of single top-level default bin size (in units of radius) for radius */ float rinv; /** host array of event starts [nevt + 1] */ int *h_evt_starts; /** device array of event starts [nevt + 1] */ int *d_evt_starts; /** device x point coordinates [np] */ float *d_xs; /** device y point coordinates [np] */ float *d_ys; /** device inverted x point coorindates [np] */ float *d_xis; /** device inverted y point coordinates [np] */ float *d_yis; /** device reconstructed tracks */ Track *d_tracks; /** device track counter */ int *d_pntracks; /** host track counter */ int ntracks; /** host tracks */ vector tracks; // functions for performing adaptive on-device HT (AHT) /** prepare input-independent (mostly) device data */ void prepare(); /** delimit event boundaries in the input array */ void delimit_events(); /** allocate device arrays and copy data */ void copy_to_dev(); /** do geometric inversion (on-device) of points */ void invert_points(); /** do AHT */ void hough_hough(); /** copy track data back to host */ void copy_tracks_back(); // friend functions friend vector hough_transform (const vector &eps, const HoughOptions &opts); }; // class Hough /** performs the Hough transform and other necessary processing, and returns the reconstructed tracks @param eps the event points @param opts the options for the Hough transform @returns the tracks reconstructed */ vector hough_transform(const vector &eps, const HoughOptions &opts = HoughOptions()); #endif