13snd::analysis_tools::USPlane::USPlane(TClonesArray *snd_hits,
snd::Configuration configuration,
MuFilter *muon_filter_geometry,
int index_begin,
int index_end,
int station) : configuration_(configuration), centroid_(std::nan(
""), std::nan(
""), std::nan(
"")), centroid_error_(std::nan(
""), std::nan(
""),std::nan(
"")), station_(station)
15 if (index_begin > index_end)
17 throw std::runtime_error{
"Begin index > end index"};
19 for (
int j{index_begin}; j < index_end; ++j)
21 auto mu_hit =
static_cast<MuFilterHit *
>(snd_hits->At(j));
23 for (
int i{0}; i < 16; ++i)
25 if (mu_hit->isMasked(i) || mu_hit->GetSignal(i) < -990.)
continue;
27 hit.
bar =
static_cast<int>(mu_hit->GetDetectorID() % 1000);
30 hit.
qdc = mu_hit->GetSignal(i);
34 int detectorID = mu_hit->GetDetectorID();
35 muon_filter_geometry->
GetPosition(detectorID, A, B);
48 if (hits_.size() < configuration_.us_min_n_hits_for_centroid)
54 double total_qdc = GetTotQdc().large;
57 for (
const auto &hit : hits_)
60 double weighted_sum_x{0.0}, weighted_sum_y{0.0}, weighted_sum_z{0.0};
61 double total_qdc_positive{0.0};
65 weighted_sum_x += hit.x * hit.qdc;
66 weighted_sum_y += hit.y * hit.qdc;
67 weighted_sum_z += hit.z * hit.qdc;
68 total_qdc_positive += hit.qdc;
71 double x = weighted_sum_x / total_qdc_positive;
72 double y = weighted_sum_y / total_qdc_positive;
73 double z = weighted_sum_z / total_qdc_positive;
74 centroid_.SetXYZ(x, y, z);
77 centroid_error_.SetXYZ(configuration_.us_centroid_error_x, configuration_.us_centroid_error_y, configuration_.us_centroid_error_z);