R3BROOT
R3B analysis software
Toggle main menu visibility
Loading...
Searching...
No Matches
R3BNeulandCalMonitorTask.cxx
Go to the documentation of this file.
1
#include "
R3BNeulandCalMonitorTask.h
"
2
#include "
R3BDataMonitor.h
"
3
#include "
R3BNeulandCalibrationTask.h
"
4
#include "
R3BNeulandCommon.h
"
5
#include "
R3BNeulandCommonFunc.h
"
6
#include <FairRootManager.h>
7
#include <algorithm>
8
#include <fmt/format.h>
9
#include <functional>
10
#include <ranges>
11
#include <string_view>
12
13
namespace
R3B::Neuland
14
{
15
16
constexpr
auto
MINIMAL_N_PLANE
= 1;
17
CalMonitorTask::CalMonitorTask
(std::string_view cal_data_name)
18
:
CalibrationTask
(
"R3BNeulandCalMonitorTask"
, 1)
19
,
cal_data_
{ cal_data_name }
20
{
21
}
22
23
void
CalMonitorTask::ExtraInit
([[maybe_unused]] FairRootManager* rootMan) {
cal_data_
.init(); }
24
25
void
CalMonitorTask::HistogramInit
(
DataMonitor
& histograms)
26
{
27
const
auto
n_plane =
GetBasePar
()->get_num_of_planes();
28
29
hist_module_hit_num_
= histograms.
add_hist
<TH2D>(
"module_hit_num"
,
30
"Number of hits for each module"
,
31
n_plane,
32
-0.5,
33
-0.5 + n_plane,
34
BarsPerPlane
,
35
-0.5,
36
-0.5 +
BarsPerPlane
);
37
hist_module_hit_num_
->GetXaxis()->SetTitle(
"Plane ID"
);
38
hist_module_hit_num_
->GetYaxis()->SetTitle(
"Bar ID"
);
39
40
for
(
auto
planes_num : std::views::iota(
MINIMAL_N_PLANE
, n_plane + 1))
41
{
42
auto
* hist =
43
hist_module_hit_n_planes_
44
.try_emplace(planes_num,
45
histograms.
add_hist
<TH2D>(
46
fmt::format(
"module_hit_{}_planes"
, planes_num),
47
fmt::format(
"Number of hits for each module if {} planes hit"
, planes_num),
48
n_plane,
49
-0.5,
50
-0.5 + n_plane,
51
BarsPerPlane
,
52
-0.5,
53
-0.5 +
BarsPerPlane
)
54
55
)
56
.first->second;
57
hist->GetXaxis()->SetTitle(
"Plane ID"
);
58
hist->GetYaxis()->SetTitle(
"Bar ID"
);
59
}
60
static
constexpr
auto
MAX_MODULE_NUM = 200;
61
hist_n_module_n_planes_
= histograms.
add_hist
<TH2D>(
"n_module_n_planes"
,
62
"Number of hit modules vs n hit planes"
,
63
n_plane + 1,
64
-0.5,
65
0.5 + n_plane,
66
MAX_MODULE_NUM,
67
0.5,
68
0.5 + MAX_MODULE_NUM);
69
hist_n_module_n_planes_
->GetXaxis()->SetTitle(
"Plane ID"
);
70
hist_n_module_n_planes_
->GetYaxis()->SetTitle(
"Number of modules"
);
71
72
hist_module_hit_n_half_planes_
=
73
histograms.
add_hist
<TH2D>(
"module_hit_n_half_planes"
,
74
"Number of hits for each module if first 13 planes hit"
,
75
n_plane,
76
-0.5,
77
-0.5 + n_plane,
78
BarsPerPlane
,
79
-0.5,
80
-0.5 +
BarsPerPlane
);
81
hist_plane_hit_num_
=
82
histograms.
add_hist
<TH1D>(
"plane_hit_num"
,
"Number of hit planes"
, n_plane + 1, -0.5, 0.5 + n_plane);
83
hist_plane_hit_num_
->GetXaxis()->SetTitle(
"Number of planes hit"
);
84
hist_plane_hit_num_
->GetYaxis()->SetTitle(
"Counts"
);
85
86
constexpr
static
auto
MAX_HIT_SIZE = 10;
87
hist_bar_hit_sizes_
= histograms.
add_hist
<TH1D>(
88
"hit_sizes_of_bar"
,
"Hit sizes of each bar"
, MAX_HIT_SIZE + 1, -0.5, 0.5 + MAX_HIT_SIZE);
89
hist_bar_hit_sizes_
->GetXaxis()->SetTitle(
"Number of hits in the bar"
);
90
hist_bar_hit_sizes_
->GetYaxis()->SetTitle(
"Counts"
);
91
}
92
93
void
CalMonitorTask::TriggeredExec
()
94
{
95
const
auto
n_plane =
GetBasePar
()->get_num_of_planes();
96
plane_counter_
.clear();
97
plane_counter_
.resize(n_plane, 0);
98
99
for
(
const
auto
& bar_data :
cal_data_
)
100
{
101
if
(bar_data.left.size() != bar_data.right.size())
102
{
103
continue
;
104
}
105
hist_bar_hit_sizes_
->Fill(
static_cast<
double
>
(bar_data.left.size()));
106
if
(bar_data.left.size() != 1)
107
{
108
continue
;
109
}
110
const
auto
module_num = bar_data.module_num;
111
const
auto
plane_id =
Common::ModuleID2PlaneID
(module_num - 1);
112
const
auto
bar_id =
Common::ModuleNum2BarID
(module_num);
113
hist_module_hit_num_
->Fill(plane_id, bar_id);
114
++
plane_counter_
.at(plane_id);
115
}
116
117
const
auto
n_hit_plane = std::ranges::count_if(
plane_counter_
, [](
auto
val) ->
bool
{
return
val != 0; });
118
const
auto
n_hit_plane_half = std::ranges::count_if(
plane_counter_
| std::views::take(n_plane / 2),
119
[](
auto
val) ->
bool
{
return
val != 0; });
120
const
auto
n_hit_modules = std::ranges::fold_left(
plane_counter_
, 0, std::plus{});
121
hist_plane_hit_num_
->Fill(
static_cast<
double
>
(n_hit_plane));
122
hist_n_module_n_planes_
->Fill(
static_cast<
double
>
(n_hit_plane), n_hit_modules);
123
124
// auto has_bar = false;
125
// auto has_bar_1 = false;
126
for
(
const
auto
& bar_data :
cal_data_
)
127
{
128
if
(bar_data.left.size() != bar_data.right.size())
129
{
130
continue
;
131
}
132
hist_bar_hit_sizes_
->Fill(
static_cast<
double
>
(bar_data.left.size()));
133
if
(bar_data.left.size() != 1)
134
{
135
continue
;
136
}
137
const
auto
module_num = bar_data.module_num;
138
const
auto
plane_id =
Common::ModuleID2PlaneID
(module_num - 1);
139
const
auto
bar_id =
Common::ModuleNum2BarID
(module_num);
140
if
(n_hit_plane >=
MINIMAL_N_PLANE
)
141
{
142
hist_module_hit_n_planes_
.at(
static_cast<
int
>
(n_hit_plane))->Fill(plane_id, bar_id);
143
}
144
if
(n_hit_plane_half == n_plane / 2)
145
{
146
hist_module_hit_n_half_planes_
->Fill(plane_id, bar_id);
147
}
148
// if(module_num == 501 or module_num == 550)
149
// {
150
// has_bar = true;
151
// }
152
// if(module_num == 701 or module_num == 750)
153
// {
154
// has_bar_1 = true;
155
// }
156
}
157
// if (n_hit_plane == 12 and has_bar)
158
// {
159
// fmt::println("------------left----------------");
160
// fmt::println("plane_id: {:>2}", fmt::join(std::views::iota(0, n_plane), ", "));
161
// fmt::println("vec : {:>2}", fmt::join(plane_counter_, ", "));
162
// fmt::println("module_n: {:>2}", fmt::join(cal_data_ | std::views::transform([](const auto&
163
// cal_data){return cal_data.module_num;}), ", "));
164
// }
165
// if (n_hit_plane == 12 and has_bar_1)
166
// {
167
// fmt::println("------------right----------------");
168
// fmt::println("plane_id: {:>2}", fmt::join(std::views::iota(0, n_plane), ", "));
169
// fmt::println("vec : {:>2}", fmt::join(plane_counter_, ", "));
170
// fmt::println("module_n: {:>2}", fmt::join(cal_data_ | std::views::transform([](const auto&
171
// cal_data){return cal_data.module_num;}), ", "));
172
// }
173
}
174
}
// namespace R3B::Neuland
R3BDataMonitor.h
R3BNeulandCalMonitorTask.h
R3BNeulandCalibrationTask.h
R3BNeulandCommon.h
R3BNeulandCommonFunc.h
R3B::DataMonitor
Definition
R3BDataMonitor.h:38
R3B::DataMonitor::add_hist
auto add_hist(std::unique_ptr< TH1 > hist) -> TH1 *
Definition
R3BDataMonitor.h:47
R3B::Neuland::CalMonitorTask::hist_module_hit_n_planes_
std::map< int, TH2D * > hist_module_hit_n_planes_
Definition
R3BNeulandCalMonitorTask.h:33
R3B::Neuland::CalMonitorTask::hist_module_hit_n_half_planes_
TH2D * hist_module_hit_n_half_planes_
Definition
R3BNeulandCalMonitorTask.h:32
R3B::Neuland::CalMonitorTask::hist_module_hit_num_
TH2D * hist_module_hit_num_
Definition
R3BNeulandCalMonitorTask.h:28
R3B::Neuland::CalMonitorTask::hist_n_module_n_planes_
TH2D * hist_n_module_n_planes_
Definition
R3BNeulandCalMonitorTask.h:29
R3B::Neuland::CalMonitorTask::cal_data_
InputVectorConnector< BarCalData > cal_data_
Definition
R3BNeulandCalMonitorTask.h:25
R3B::Neuland::CalMonitorTask::TriggeredExec
void TriggeredExec() override
Definition
R3BNeulandCalMonitorTask.cxx:93
R3B::Neuland::CalMonitorTask::CalMonitorTask
CalMonitorTask(std::string_view cal_data_name="NeulandCalData")
Definition
R3BNeulandCalMonitorTask.cxx:17
R3B::Neuland::CalMonitorTask::ExtraInit
void ExtraInit(FairRootManager *rootMan) override
Definition
R3BNeulandCalMonitorTask.cxx:23
R3B::Neuland::CalMonitorTask::HistogramInit
void HistogramInit(DataMonitor &histograms) override
Definition
R3BNeulandCalMonitorTask.cxx:25
R3B::Neuland::CalMonitorTask::plane_counter_
std::vector< int > plane_counter_
Definition
R3BNeulandCalMonitorTask.h:26
R3B::Neuland::CalMonitorTask::hist_plane_hit_num_
TH1D * hist_plane_hit_num_
Definition
R3BNeulandCalMonitorTask.h:30
R3B::Neuland::CalMonitorTask::hist_bar_hit_sizes_
TH1D * hist_bar_hit_sizes_
Definition
R3BNeulandCalMonitorTask.h:31
R3B::Neuland::CalibrationTask::GetBasePar
auto GetBasePar() const -> auto *
Definition
R3BNeulandCalibrationTask.h:55
R3B::Neuland::CalibrationTask::CalibrationTask
CalibrationTask()
Definition
R3BNeulandCalibrationTask.cxx:28
R3B::Neuland::Common::ModuleNum2BarID
static constexpr auto ModuleNum2BarID(int module_num) -> int
Definition
R3BNeulandCommonFunc.h:38
R3B::Neuland::Common::ModuleID2PlaneID
static constexpr auto ModuleID2PlaneID(int moduleID) -> int
Definition
R3BNeulandCommonFunc.h:36
R3B::Neuland
Simulation of NeuLAND Bar/Paddle.
Definition
R3BNeulandAnalysisApp.cxx:44
R3B::Neuland::BarsPerPlane
constexpr auto BarsPerPlane
Definition
R3BNeulandCommon.h:81
R3B::Neuland::MINIMAL_N_PLANE
constexpr auto MINIMAL_N_PLANE
Definition
R3BNeulandCalMonitorTask.cxx:16
neuland
calibration
cal_to_hit
R3BNeulandCalMonitorTask.cxx
Generated by
1.18.0