R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BNeulandCalToHitPar.cxx
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
3 * Copyright (C) 2019-2023 Members of R3B Collaboration *
4 * *
5 * This software is distributed under the terms of the *
6 * GNU General Public Licence (GPL) version 3, *
7 * copied verbatim in the file "LICENSE". *
8 * *
9 * In applying this license GSI does not waive the privileges and immunities *
10 * granted to it by virtue of its status as an Intergovernmental Organization *
11 * or submit itself to any jurisdiction. *
12 ******************************************************************************/
13
15#include "R3BException.h"
16#include "R3BNeulandParSet.h"
17#include "R3BValueError.h"
18#include <R3BNeulandCommon.h>
19#include <R3BShared.h>
20#include <Rtypes.h>
21#include <RtypesCore.h>
22#include <algorithm>
23#include <cmath>
24#include <fmt/format.h>
25#include <range/v3/algorithm/max_element.hpp>
26#include <range/v3/view/map.hpp>
27#include <range/v3/view/transform.hpp>
28#include <string_view>
29
30namespace
31{
32 auto calculate_threshold(const R3B::Neuland::HitModulePar& modulePar, R3B::Side side)
33 {
34 const auto value = modulePar.pmt_threshold.get(side).value *
36 const auto err = 0.;
37 return R3B::ValueError<double>{ value, err };
38 }
39
40} // namespace
41
42namespace R3B::Neuland
43{
44 Cal2HitPar::Cal2HitPar(std::string_view name, std::string_view title, std::string_view context, bool own)
45 : ParSet(name, title, context, own)
46 {
47 }
48
50 {
51 auto threshold_views =
52 ranges::views::transform(module_pars_ | ranges::views::values,
53 [](const auto& ele)
54 {
55 return std::max(calculate_threshold(ele, R3B::Side::left).value,
56 calculate_threshold(ele, R3B::Side::right).value);
57 });
58
59 auto max_value = ranges::max_element(threshold_views);
60 if (max_value != threshold_views.end())
61 {
62 energy_cut_ = *max_value;
63 }
64 }
65 auto Cal2HitPar::GetModuleParAt(int module_num) const -> const ::R3B::Neuland::HitModulePar&
66 {
67#ifdef HAS_CPP_STANDARD_17
68 if (module_pars_.find(module_num) == module_pars_.end())
69#else
70 if (!module_pars_.contains(module_num))
71#endif
72 {
73 throw R3B::logic_error(fmt::format("module pars has no module num {}", module_num));
74 }
75 return module_pars_.at(module_num);
76 }
77
78} // namespace R3B::Neuland
79
ClassImp(R3B::Neuland::Cal2HitPar)
std::unordered_map< int, ::R3B::Neuland::HitModulePar > module_pars_
auto GetModuleParAt(int module_num) const -> const ::R3B::Neuland::HitModulePar &
Cal2HitPar(std::string_view name="NeulandHitPar", std::string_view title="Neuland Cal2Hit calibration", std::string_view context="TestDefaultContext", bool own=true)
ParSet(std::string_view name="parSet", std::string_view title="Neuland parameter", std::string_view context="TestDefaultContext", bool own=true)
Simulation of NeuLAND Bar/Paddle.
constexpr auto TotalBarLength
ValueError< double > light_attenuation_length
cm, 1/alpha
LRPair< ValueError< double > > pmt_threshold