ToolDAQFramework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
test_vertices.h
Go to the documentation of this file.
1 #ifndef test_vertices_H
2 #define test_vertices_H
3 
4 #include <string>
5 #include <iostream>
6 
7 #include "Tool.h"
8 
9 #include "GPUFunctions.h"
10 #include "Stopwatch.h"
11 
12 class test_vertices: public Tool {
13 
14 
15  public:
16 
17  test_vertices();
18  bool Initialise(std::string configfile,DataModel &data);
19  bool Execute();
20  bool Finalise();
21 
22 
23  private:
24 
44 
53 
55  typedef unsigned short offset_t;
56  typedef unsigned int histogram_t;
57  typedef unsigned int time_of_flight_t;
60  int CPU_test_vertices_execute(std::vector<int> PMTid, std::vector<int> time, std::vector<int> * trigger_ns, std::vector<int> * trigger_ts);
61 
62  void make_test_vertices();
63  void make_table_of_tofs();
65  unsigned int get_distance_index(unsigned int pmt_id, unsigned int vertex_block);
66  unsigned int get_time_index(unsigned int hit_index, unsigned int vertex_block);
67  unsigned int get_direction_index_at_pmt(unsigned int pmt_id, unsigned int vertex_index, unsigned int direction_index);
68  unsigned int get_direction_index_at_angles(unsigned int iphi, unsigned int itheta);
69  unsigned int get_direction_index_at_time(unsigned int time_bin, unsigned int vertex_index, unsigned int direction_index);
70  void free_global_memories();
71  bool read_the_input_ToolDAQ(std::vector<int> PMTid, std::vector<int> time, int * earliest_time);
72  void write_output();
74  void correct_times_and_get_histo_per_vertex_shared(unsigned int *ct);
75  void find_vertex_with_max_npmts_in_timebin(histogram_t * np, histogram_t * mnp, unsigned int * vmnp);
77  void coalesce_triggers();
78  void separate_triggers_into_gates(std::vector<int> * trigger_ns, std::vector<int> * trigger_ts);
79  void free_event_memories();
80 
82  double distance_between_vertices; // linear distance between test vertices
83  double wall_like_distance; // distance from wall (in units of distance_between_vertices) to define wall-like events
84  unsigned int time_step_size; // time binning for the trigger
85  unsigned int water_like_threshold_number_of_pmts; // number of pmts above which a trigger is possible for water-like events
86  unsigned int wall_like_threshold_number_of_pmts; // number of pmts above which a trigger is possible for wall-like events
88  double coalesce_time; // time such that if two triggers are closer than this they are coalesced into a single trigger
89  double trigger_gate_up; // duration to be saved after the trigger time
90  double trigger_gate_down; // duration to be saved before the trigger time
91  unsigned int max_n_hits_per_job; // max n of pmt hits per job
92  double dark_rate;
93  float costheta_cone_cut; // max distance between measured costheta and cerenkov costheta
94  bool select_based_on_cone; // for mode == 10, set to 0 to select based on vertices, to 1 to select based on cone
96  double detector_height; // detector height
97  double detector_radius; // detector radius
99  unsigned int n_PMTs; // number of pmts in the detector
100  double * PMT_x, *PMT_y, *PMT_z; // coordinates of the pmts in the detector
102  unsigned int n_test_vertices; // number of test vertices
103  unsigned int n_water_like_test_vertices; // number of test vertices
104  double * vertex_x, * vertex_y, * vertex_z; // coordinates of test vertices
106  offset_t time_offset; // ns, offset to make times positive
107  unsigned int n_time_bins; // number of time bins
108  unsigned int n_direction_bins_theta; // number of direction bins
109  unsigned int n_direction_bins_phi; // number of direction bins
110  unsigned int n_direction_bins; // number of direction bins
111  unsigned int n_hits; // number of input hits from the detector
112  unsigned int * host_ids; // pmt id of a hit
113  unsigned int * host_times; // time of a hit
114  // corrected tim bin of each hit (for each vertex)
115  unsigned int * host_time_bin_of_hit;
116  // npmts per time bin
117  unsigned int * host_n_pmts_per_time_bin;
118  unsigned int * host_n_pmts_nhits;
119  //unsigned int * host_time_nhits;
120  // tof
124  double twopi;
132  // triggers
133  std::vector<std::pair<unsigned int,unsigned int> > candidate_trigger_pair_vertex_time; // pair = (v, t) = (a vertex, a time at the end of the 2nd of two coalesced bins)
134  std::vector<unsigned int> candidate_trigger_npmts_in_time_bin; // npmts in time bin
136  std::vector<std::pair<unsigned int,unsigned int> > trigger_pair_vertex_time;
137  std::vector<unsigned int> trigger_npmts_in_time_bin;
138  std::vector<unsigned int> trigger_npmts_in_cone_in_time_bin;
139  std::vector<std::pair<unsigned int,unsigned int> > final_trigger_pair_vertex_time;
140  std::vector<double> output_trigger_information;
141  // make output txt file for plotting?
143  unsigned int correct_mode;
144  unsigned int write_output_mode;
145  // find candidates
149  // gpu properties
152  // verbosity level
155  // files
156  std::string event_file;
157  std::string detector_file;
158  std::string pmts_file;
159  std::string output_file;
160  std::string event_file_base;
161  std::string event_file_suffix;
162  std::string output_file_base;
169  unsigned int greatest_divisor;
170  unsigned int the_max_time;
171  unsigned int nhits_window;
172  int n_events;
173 
174 
175 
176 
177 #ifdef GPU
178  std::vector<int> m_time_int;
180 #else
181  std::vector<int> m_time_int;
182 #endif
183 
187  std::string m_stopwatch_file;
188 
191 
193  std::stringstream m_ss;
194 
197  void StreamToLog(int level) {
198  Log(m_ss.str(), level, m_verbose);
199  m_ss.str("");
200  }
201 
203  enum LogLevel {FATAL=-1, ERROR=0, WARN=1, INFO=2, DEBUG1=3, DEBUG2=4, DEBUG3=5};
204 
205 };
206 
207 
208 #endif
float elapsed_threads_candidates
int CPU_test_vertices_execute(std::vector< int > PMTid, std::vector< int > time, std::vector< int > *trigger_ns, std::vector< int > *trigger_ts)
unsigned int n_water_like_test_vertices
float elapsed_directions_copy_dev
unsigned int nhits_threshold_max
Definition: test_vertices.h:87
unsigned int * host_times
unsigned int n_direction_bins
float elapsed_vertices
void choose_candidates_above_threshold()
double cerenkov_angle_water
unsigned int * host_max_number_of_pmts_in_cone_in_time_bin
float * host_light_dy
double * PMT_z
double detector_radius
Definition: test_vertices.h:97
util::Stopwatch * m_stopwatch
The stopwatch, if we&#39;re using one.
unsigned int * host_vertex_with_max_n_pmts
bool m_return_vertex
Definition: test_vertices.h:42
float m_coalesce_time
Definition: test_vertices.h:29
float elapsed_parameters
int CPU_test_vertices_initialize()
std::string output_file
unsigned int n_direction_bins_phi
float elapsed_detector
float elapsed_memory_dev
void allocate_candidates_memory_on_host()
void free_global_memories()
unsigned int get_time_index(unsigned int hit_index, unsigned int vertex_block)
bool m_cylindrical_grid
Definition: test_vertices.h:33
float elapsed_memory_directions_dev
float elapsed_directions
float elapsed_tofs_free
unsigned int n_test_vertices
vertices
void find_vertex_with_max_npmts_in_timebin(histogram_t *np, histogram_t *mnp, unsigned int *vmnp)
std::vector< unsigned int > candidate_trigger_npmts_in_time_bin
int m_n_direction_bins_theta
Definition: test_vertices.h:32
bool Initialise(std::string configfile, DataModel &data)
std::vector< unsigned int > trigger_npmts_in_cone_in_time_bin
float elapsed_candidates_copy_host
std::string event_file_base
int m_max_n_hits_per_job
Definition: test_vertices.h:37
void StreamToLog(int level)
void free_event_memories()
unsigned int * host_n_pmts_per_time_bin
float elapsed_write_output
void coalesce_triggers()
float costheta_cone_cut
Definition: test_vertices.h:93
float m_distance_between_vertices
Definition: test_vertices.h:25
unsigned int n_PMTs
pmts
Definition: test_vertices.h:99
std::vector< unsigned int > candidate_trigger_npmts_in_cone_in_time_bin
float elapsed_kernel_correct_times_and_get_n_pmts_per_time_bin
unsigned int get_distance_index(unsigned int pmt_id, unsigned int vertex_block)
bool m_return_direction
Definition: test_vertices.h:43
double speed_light_water
unsigned int n_hits
float m_wall_like_threshold_number_of_pmts
Definition: test_vertices.h:28
std::stringstream m_ss
For easy formatting of Log messages.
float m_wall_like_distance
Definition: test_vertices.h:26
unsigned int nhits_window
double trigger_gate_down
Definition: test_vertices.h:90
std::string output_file_base
int m_verbose
Verbosity level, as defined in tool parameter file.
double * vertex_z
std::vector< std::pair< unsigned int, unsigned int > > final_trigger_pair_vertex_time
unsigned int histogram_t
Definition: test_vertices.h:56
std::vector< double > output_trigger_information
double trigger_gate_up
Definition: test_vertices.h:89
unsigned int wall_like_threshold_number_of_pmts
Definition: test_vertices.h:86
std::string event_file_suffix
std::vector< unsigned int > trigger_npmts_in_time_bin
double * PMT_y
std::string pmts_file
double detector_height
detector
Definition: test_vertices.h:96
void make_test_vertices()
float elapsed_candidates_memory_dev
histogram_t * host_max_number_of_pmts_in_time_bin
unsigned int water_like_threshold_number_of_pmts
Definition: test_vertices.h:85
unsigned int nhits_threshold_min
Definition: test_vertices.h:87
double coalesce_time
Definition: test_vertices.h:88
float choose_candidates
unsigned int greatest_divisor
int m_num_threads_per_block_y
Definition: test_vertices.h:39
float elapsed_candidates_kernel
int max_n_threads_per_block
std::string detector_file
unsigned int * host_ids
int m_write_output_mode
Definition: test_vertices.h:41
TimeDelta m_trigger_mask_window_pre
Pre-trigger time for masking digits from future tools.
Definition: test_vertices.h:50
LogLevel
Log level enumerations.
unsigned int write_output_mode
void separate_triggers_into_gates(std::vector< int > *trigger_ns, std::vector< int > *trigger_ts)
unsigned int get_direction_index_at_pmt(unsigned int pmt_id, unsigned int vertex_index, unsigned int direction_index)
unsigned int correct_mode
bool * host_directions_for_vertex_and_pmt
void correct_times_and_get_histo_per_vertex_shared(unsigned int *ct)
TimeDelta m_trigger_save_window_pre
Pre-trigger time for saving digits.
Definition: test_vertices.h:46
unsigned int time_step_size
Definition: test_vertices.h:84
unsigned int the_max_time
unsigned short offset_t
CPU version of the algorithm.
Definition: test_vertices.h:55
double * vertex_y
unsigned int get_direction_index_at_time(unsigned int time_bin, unsigned int vertex_index, unsigned int direction_index)
float * host_light_dx
bool read_the_input_ToolDAQ(std::vector< int > PMTid, std::vector< int > time, int *earliest_time)
std::vector< int > m_time_int
float elapsed_threads
float * host_light_dz
void Log(const std::string &message, const int message_level)
Format messages in the same way as for tools.
Definition: Utilities.cpp:276
int CPU_test_vertices_finalize()
double * vertex_x
float elapsed_memory_candidates_host
float * host_light_dr
offset_t time_offset
hits
std::vector< std::pair< unsigned int, unsigned int > > candidate_trigger_pair_vertex_time
unsigned int * host_time_bin_of_hit
bool m_trigger_threshold_adjust_for_noise
Definition: test_vertices.h:36
unsigned int * host_n_pmts_nhits
float elapsed_copy_dev
float cerenkov_costheta
unsigned int time_of_flight_t
Definition: test_vertices.h:57
std::vector< std::pair< unsigned int, unsigned int > > trigger_pair_vertex_time
unsigned int max_n_hits_per_job
Definition: test_vertices.h:91
float m_costheta_cone_cut
Definition: test_vertices.h:34
double distance_between_vertices
CPU parameters.
Definition: test_vertices.h:82
float elapsed_memory_tofs_dev
unsigned int get_direction_index_at_angles(unsigned int iphi, unsigned int itheta)
time_of_flight_t * host_times_of_flight
std::string m_stopwatch_file
Image filename to save the histogram to, if required.
TimeDelta m_trigger_save_window_post
Post-trigger time for saving digits.
Definition: test_vertices.h:48
bool m_select_based_on_cone
Definition: test_vertices.h:35
void make_table_of_directions()
bool select_based_on_cone
Definition: test_vertices.h:94
double dark_rate
Definition: test_vertices.h:92
float elapsed_coalesce
float elapsed_tofs_copy_dev
std::string event_file
unsigned int n_direction_bins_theta
int m_num_threads_per_block_x
Definition: test_vertices.h:40
unsigned int n_time_bins
TimeDelta m_trigger_mask_window_post
Post-trigger time for masking digits from future tools.
Definition: test_vertices.h:52
float m_water_like_threshold_number_of_pmts
Definition: test_vertices.h:27
void make_table_of_tofs()
double * PMT_x
double wall_like_distance
Definition: test_vertices.h:83