R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BNeulandTSyncAnalysis.h
Go to the documentation of this file.
1#pragma once
2
3#include "R3BValueError.h"
4#include <cstdint>
5#include <unordered_map>
6#include <vector>
7
8class TH2D;
9class TH1I;
10
11namespace R3B
12{
13 class DataMonitor;
14}
15
16namespace R3B::Neuland
17{
18 class Cal2HitPar;
19} // namespace R3B::Neuland
20
22{
23
30
32 {
33 public:
34 struct Point
35 {
36 int module_num = 0;
37 double t_mean = 0;
38 };
39
47
48 TSyncEngine() = default;
49
57 void add_point(double t_sum, int module_num);
58
59 // /**
60 // * @brief set histograms.
61 // *
62 // * @param hist Pointer to the histogram
63 // */
64 // void set_tsync_hist(TH2D* hist) { hist_tsync_ = hist; }
65
66 void init_hist(DataMonitor& data_monitor);
67
73
74 void set_max_time_difference(double max_time_val) { max_time_difference_ = max_time_val; }
75
76 void init();
77
83 void end_of_event();
84
85 void reset();
86
87 void set_number_of_modules(int num_of_modules) { num_of_modules_ = num_of_modules; }
88
89 void calibrate(Cal2HitPar& hit_par);
90
91 [[nodiscard]] auto get_hist_tsync() const -> TH2D* { return hist_horizontal_plane_; }
92 auto get_record_type() const -> RecordType { return record_type_; }
93 auto get_num_of_dp() const -> int { return num_of_dp_; }
94
95 private:
98 int num_of_dp_ = 0;
100 TH1I* hist_record_type_ = nullptr;
101 TH2D* hist_horizontal_plane_ = nullptr;
102 TH2D* hist_horizontal_dp_ = nullptr;
103 TH2D* hist_vertical_dp_ = nullptr;
104 std::unordered_map<int, int> ref_bars_in_planes_;
105
106 // temp variables
108 double buffer_ref_time_ = 0.;
109 std::vector<Point> buffer_points_;
110
111 static constexpr auto TIME_SUM_BIN_NUM = 500;
112
113 void analyze_event();
114
115 auto try_in_xy_plane(const std::vector<Point>& collection) -> bool;
122 auto try_in_same_dp(const std::vector<Point>& collection, int offset = 0) -> bool;
123 auto try_in_same_vertical_dp(const std::vector<Point>& collection) -> bool;
124 void set_plane_ref_bar_time(const std::vector<Point>& collection, int plane_num);
125 void fill_histogram(RecordType record_type);
126 void fill_one_plane_histogram(double time_val, int module_num);
127 void fill_two_planes_histogram(double time_val, int module_num);
128
129 auto calculate_best_vertical_bar_num() const -> int;
130 auto calculate_time_diff_to_prev_ref(int plane_id, int best_vert_bar_num) const -> ValueErrorD;
131 auto calculate_time_diffs_to_first() const -> std::unordered_map<int, ValueErrorD>;
132
133 // auto check_global_ref_bar(const std::vector<Point>& collection) -> bool;
134 // template <typename RefCriterion>
135 // auto try_with_ref_bar(const std::vector<Point>& collection, RefCriterion criterion) -> bool;
136 // auto try_in_yz_plane(const std::vector<Point>& collection) -> bool;
137 // auto try_with_ref_z_direction(const std::vector<Point>& collection) -> bool;
138 };
139} // namespace R3B::Neuland::Calibration
void fill_one_plane_histogram(double time_val, int module_num)
auto calculate_time_diff_to_prev_ref(int plane_id, int best_vert_bar_num) const -> ValueErrorD
void end_of_event()
Actions in the end of the event.
auto try_in_same_vertical_dp(const std::vector< Point > &collection) -> bool
auto try_in_same_dp(const std::vector< Point > &collection, int offset=0) -> bool
Check if all points are in the same horizontal or vertical double plane.
@ same_vertical_dp
All the points within vertical plane followed by horizontal one.
@ xy_plane
All points within one single horizontal plane.
@ same_horizontal_dp
All the points within horizontal plane followed by vertical one.
void init_hist(DataMonitor &data_monitor)
set histograms.
std::unordered_map< int, int > ref_bars_in_planes_
key: plane_id, value: global module number
auto try_in_xy_plane(const std::vector< Point > &collection) -> bool
auto calculate_time_diffs_to_first() const -> std::unordered_map< int, ValueErrorD >
void set_max_time_difference(double max_time_val)
Set the bar num of the reference bar.
void fill_two_planes_histogram(double time_val, int module_num)
void add_point(double t_sum, int module_num)
Add the t_sum value from a bar.
void set_plane_ref_bar_time(const std::vector< Point > &collection, int plane_num)
Simulation of NeuLAND Bar/Paddle.
ValueError< double > ValueErrorD