R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BNeulandHitOnlineMonitorTask.cxx
Go to the documentation of this file.
3#include "R3BNeulandCommon.h"
6#include <string_view>
7
9{
11 : CalibrationTask(config.name, 1)
12 , config_{ config }
13 , hit_data_{ get_from_sep_string(0, config.read) }
14 {
16 }
17
19 {
20 const auto module_size = GetBasePar()->get_num_of_planes() * BarsPerPlane;
21 static constexpr auto POSITION_BINS = 1000;
22
23 auto set_x_title = [](auto* hist, std::string_view title) -> void { hist->GetXaxis()->SetTitle(title.data()); };
24 auto set_y_title = [](auto* hist, std::string_view title) -> void { hist->GetYaxis()->SetTitle(title.data()); };
25
26 hist_positions_along_bar_ = histograms.add_hist<TH2D>("position_along_bar",
27 "Positions along the bar directions",
28 module_size,
29 0.5,
30 0.5 + module_size,
31 POSITION_BINS,
32 -BarLength / 2.,
33 BarLength / 2.);
34 set_x_title(hist_positions_along_bar_, "module number");
35 set_y_title(hist_positions_along_bar_, "position (cm)");
36
37 static constexpr auto TIME_MIN_NS = 120;
38 static constexpr auto TIME_MAX_NS = 220;
39 static constexpr auto TIME_VALUE_BINS = 1000;
40 hist_times_ = histograms.add_hist<TH2D>("time_val",
41 "Positions along the bar directions",
42 module_size,
43 0.5,
44 0.5 + module_size,
45 TIME_VALUE_BINS,
46 TIME_MIN_NS,
47 TIME_MAX_NS);
48 set_x_title(hist_times_, "module number");
49 set_y_title(hist_times_, "time (ns)");
50 }
51
53 {
54 for (const auto& hit : hit_data_)
55 {
56 const auto& position = hit.position;
57 const auto module_num = hit.module_id + 1;
58 const auto is_horizontal = IsModuleNumHorizontal(module_num);
59
60 const auto pos_along_bar = is_horizontal ? position.X() : position.Y();
61 hist_positions_along_bar_->Fill(module_num, pos_along_bar.value);
62 hist_times_->Fill(module_num, hit.time.value);
63 }
64 }
65
66 void HitOnlineMonitorTask::ExtraInit([[maybe_unused]] FairRootManager* rootMan) { hit_data_.init(); }
67
68 auto HitOnlineMonitorTask::CheckConditions([[maybe_unused]] TH1L* hist_condition) const -> bool
69 {
70 if (hit_data_.get().size() < config_.n_hit_min)
71 {
72 ConditionFillToHist(hist_condition, "undersized");
73 return false;
74 }
75 return true;
76 }
77} // namespace R3B::Neuland::Calibration
auto add_hist(std::unique_ptr< TH1 > hist) -> TH1 *
auto CheckConditions(TH1L *hist_condition) const -> bool override
static void ConditionFillToHist(TH1L *hist_condition, std::string_view condition)
constexpr auto BarsPerPlane
constexpr auto BarLength
constexpr auto IsModuleNumHorizontal(int module_num) -> bool