8 #include <dqm_core/AlgorithmManager.h>
9 #include "dqm_core/AlgorithmConfig.h"
10 #include <dqm_core/exceptions.h>
12 #include <TDirectory.h>
17 #include <string_view>
18 #include <system_error>
36 const TObject&
object,
37 const dqm_core::AlgorithmConfig&
config ) {
38 if ( !
object.
IsA()->InheritsFrom(
"TH2" ) ) {
39 throw dqm_core::BadConfig( ERS_HERE,
name,
"does not inherit from TH2" );
45 throw dqm_core::BadConfig( ERS_HERE,
name,
"histogram has more than 2 dimensions" );
60 std::string_view
s = RANGES_22;
71 auto result = std::from_chars(
s.data(),
s.data() +
s.size(), y_bins[
i]);
72 if (
result.ec == std::errc::invalid_argument ||
result.ec == std::errc::result_out_of_range) {valid_arg = 0;}
83 const std::string trains[4] = {
"0",
"1",
"2",
"3"};
84 auto projections_tr = std::vector<TH1D *>(4);
86 float max_bins_content[4] = {};
87 float all_bins_content[4][4] = {};
90 projections_tr[
i] =
new TH1D((
"projections_tr"+trains[
i]).c_str(),(
"projections_tr"+trains[
i]).c_str(), 16, 0, 4);
91 projections_tr[
i] =
histogram->ProjectionX((
"projections_tr"+trains[
i]).c_str(), y_bins[
i*2], y_bins[
i*2+1],
"cutg");
93 int num_bars_off[4] = {};
94 std::vector<int> bar_off = {};
97 if (projections_tr[
i]->GetBinContent(j) < 1)
99 int train = ( (j - 5) / 4 );
100 num_bars_off[train]++;
101 bar_off.push_back(j);
104 int sum_bars_off = 0;
105 sum_bars_off =
std::accumulate(num_bars_off, num_bars_off+4, sum_bars_off);
107 if (sum_bars_off > 0)
109 for (
int k = 0;
k < sum_bars_off; ++
k)
112 int train = ( bar_off[
k] - 5 ) / 4;
113 int bin = train * 4 + 5;
114 for (
int j =
bin; j <
bin + 4; ++j)
115 mean =
mean +
float(projections_tr[
i]->GetBinContent(j));
116 mean =
mean / (4 - num_bars_off[train]);
117 projections_tr[
i]->SetBinContent(bar_off[
k],
mean);
120 projections_tr[
i]->Rebin(4);
121 max_bins[
i] = (projections_tr[
i]->GetMaximumBin())-2;
122 max_bins_content[
i] = (projections_tr[
i]->GetBinContent(max_bins[
i]+2));
123 for (
size_t j = 0; j < 4; j++)
124 all_bins_content[
i][j] = (projections_tr[
i]->GetBinContent(j+2));
125 delete projections_tr[
i];
129 for (
int i = 0;
i < 4; ++
i)
131 if (max_bins[
i] !=
i)
137 else if (false_bins == gthreshold_tr)
139 else if (false_bins >= rthreshold_tr)
143 float check_devided_bins[4][4] = {};
144 int false_bins_devided[4] = {};
150 check_devided_bins[
i][j] = max_bins_content[
i]/all_bins_content[
i][j];
151 if ((check_devided_bins[
i][j] < pronounciation_level_down) || (check_devided_bins[
i][j] > pronounciation_level_up))
152 false_bins_devided[
i]++;
154 if (false_bins_devided[
i] > 1)
155 false_bins_devided_tr++;
158 if (false_bins_devided_tr == 0)
159 status_bins_devided = 1;
160 else if ((false_bins_devided_tr >= gthreshold_st) && (false_bins_devided_tr < rthreshold_st))
161 status_bins_devided = 2;
162 else if (false_bins_devided_tr >= rthreshold_st)
163 status_bins_devided = 3;
168 if (status_bins_devided > status_bins) {status_general = status_bins_devided;}
169 else if (status_bins_devided <= status_bins) {status_general = status_bins;}
174 result->tags_[
"N Trains on wrong positions/not existing" ] = false_bins;
175 result->tags_[
"N Stairs not pronounced" ] = false_bins_devided_tr;
177 if ( status_general == 0 )
179 else if ( status_general == 3 )
181 else if ( status_general == 2 )
182 result->status_ = dqm_core::Result::Yellow;
183 else if ( status_general == 1 )
190 out <<
"AFP_ToFSiTCorrCheck: Print out how many stairs are not on their places and how many are not pronounced\n"
191 <<
"Required Parameter: pronounciation_level_down: how pronounced the stair is (down limit)\n"
192 <<
"Required Parameter: pronounciation_level_up: how pronounced the stair is (upper limit)\n"
193 <<
"Required Parameter: RANGES: ranges of SiT, corresponding to ToF trains, in bins of hist"<< std::endl;