R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BNeulandAnalysisApp.cxx
Go to the documentation of this file.
1#include "R3BLosMapped2Cal.h"
2#include "R3BLosMapped2CalPar.h"
3#include "R3BLosProvideTStart.h"
4#include "R3BNeulandApp.h"
15#include <CLI/CLI.hpp>
16#include <FairRun.h>
17#include <FairRunAna.h>
18#include <R3BEventHeader.h>
21#include <R3BNeulandDigitizer.h>
22#include <R3BNeulandHitMon.h>
29#include <fairlogger/Logger.h>
30#include <fmt/base.h>
31#include <functional>
32#include <memory>
33#include <nlohmann/json.hpp>
34#include <nlohmann/json_fwd.hpp>
35#include <string>
36#include <string_view>
37#include <type_traits>
38#include <utility>
39#include <vector>
40
41using nlohmann::ordered_json;
42
43namespace R3B::Neuland
44{
46
48 : CLIApplication{ "neuland_ana", std::make_unique<FairRunAna>(), std::ref(options_.general) }
49 {
50 options_.general.input.data.emplace_back("sim.output.root");
51 options_.general.input.par.emplace_back("sim.par.root");
52
53 options_.general.output.data = "digi.output.root";
54 options_.general.output.par = "digi.par.root";
55 }
56
57 void AnalysisApplication::setup_application_options(CLI::App& program_options)
58 {
59 const auto analysis_option_group = std::string{ "Analysis options" };
60 program_options
61 .add_option("--paddle", options_.tasks.neuland_digitizer.paddle, R"(Set the paddle name. e.g. "neuland")")
62 ->capture_default_str()
63 ->group(analysis_option_group);
64 program_options
65 .add_option("--channel", options_.tasks.neuland_digitizer.channel, R"(Set the channel name. e.g. "tamex")")
66 ->capture_default_str()
67 ->group(analysis_option_group);
68 }
69
71 {
72
73 auto event_header = std::make_unique<R3BEventHeader>();
74 auto read_branch_names = std::vector<std::string>{};
75 auto write_branch_names = std::vector<std::string>{};
76 LOGP(info, "Setting the event header to be R3BEventHeader!");
77 run->SetEventHeader(std::move(event_header));
78
79 auto task_option = options_.tasks;
80
81 if (const auto& option = task_option.neuland_digitizer; option.enable)
82 {
83 auto task = Digitizer::Create(option, run);
84 run->AddTask(task.release());
85 }
86
87 if (const auto& option = task_option.neuland_sim_cal_to_cal; option.enable)
88 {
89 parse_io_branch_names(option, read_branch_names, 1, write_branch_names, 1);
90 auto task = std::make_unique<R3B::Neuland::SimCal2Cal>(read_branch_names.at(0), write_branch_names.at(0));
91 task->SetName(option.name.c_str());
92 run->AddTask(task.release());
93 }
94
95 if (const auto& option = task_option.neuland_hit_mon; option.enable)
96 {
97 parse_io_branch_names(option, read_branch_names, 1, write_branch_names, 0);
98 auto task = std::make_unique<R3BNeulandHitMon>(read_branch_names.at(0));
99 task->SetName(option.name.c_str());
100 run->AddTask(task.release());
101 }
102
103 if (const auto& option = task_option.neuland_primary_interaction_finder; option.enable)
104 {
105 parse_io_branch_names(option, read_branch_names, 2, write_branch_names, 3);
106 auto task = std::make_unique<R3BNeulandPrimaryInteractionFinder>(read_branch_names.at(0),
107 read_branch_names.at(1),
108 write_branch_names.at(0),
109 write_branch_names.at(1),
110 write_branch_names.at(2));
111 task->SetName(option.name.c_str());
112 run->AddTask(task.release());
113 }
114
115 if (const auto& option = task_option.neuland_cluster_finder; option.enable)
116 {
117 parse_io_branch_names(option, read_branch_names, 1, write_branch_names, 1);
118 auto task = std::make_unique<R3BNeulandClusterFinder>(read_branch_names.at(0), write_branch_names.at(0));
119 task->SetName(option.name.c_str());
120 run->AddTask(task.release());
121 }
122
123 if (const auto& option = task_option.neuland_primary_cluster_finder; option.enable)
124 {
125 parse_io_branch_names(option, read_branch_names, 2, write_branch_names, 2);
126 auto task = std::make_unique<R3BNeulandPrimaryClusterFinder>(
127 read_branch_names.at(0), read_branch_names.at(1), write_branch_names.at(0), write_branch_names.at(1));
128 task->SetName(option.name.c_str());
129 run->AddTask(task.release());
130 }
131
132 if (const auto& option = task_option.neuland_multi_calorimeter_train; option.enable)
133 {
134 parse_io_branch_names(option, read_branch_names, 3, write_branch_names, 0);
135 auto task = std::make_unique<R3BNeulandMultiplicityCalorimetricTrain>(
136 read_branch_names.at(0), read_branch_names.at(1), read_branch_names.at(2));
137 task->SetName(option.name.c_str());
138 task->SetUseHits(option.use_hit);
139 task->SetWeight(option.weight);
140 task->SetEdepOpt(option.edep_opt.init, option.edep_opt.step, option.edep_opt.lower, option.edep_opt.upper);
141 task->SetEdepOffOpt(option.edep_off_opt.init,
142 option.edep_off_opt.step,
143 option.edep_off_opt.lower,
144 option.edep_off_opt.upper);
145 task->SetNclusterOffOpt(option.n_cluster_opt.init,
146 option.n_cluster_opt.step,
147 option.n_cluster_opt.lower,
148 option.n_cluster_opt.upper);
149 task->SetNclusterOffOpt(option.n_cluster_off_opt.init,
150 option.n_cluster_off_opt.step,
151 option.n_cluster_off_opt.lower,
152 option.n_cluster_off_opt.upper);
153 run->AddTask(task.release());
154 }
155
156 if (const auto& option = task_option.neuland_multi_bayes_train; option.enable)
157 {
158 parse_io_branch_names(option, read_branch_names, 2, write_branch_names, 0);
159 auto task =
160 std::make_unique<R3BNeulandMultiplicityBayesTrain>(read_branch_names.at(0), read_branch_names.at(1));
161 task->SetName(option.name.c_str());
162 run->AddTask(task.release());
163 }
164
165 if (const auto& option = task_option.neuland_multi_bayes; option.enable)
166 {
167 parse_io_branch_names(option, read_branch_names, 1, write_branch_names, 1);
168 auto task =
169 std::make_unique<R3BNeulandMultiplicityBayes>(read_branch_names.at(0), write_branch_names.at(0));
170 task->SetName(option.name.c_str());
171 run->AddTask(task.release());
172 }
173
174 if (const auto& option = task_option.neuland_neutron_r_value; option.enable)
175 {
176 parse_io_branch_names(option, read_branch_names, 2, write_branch_names, 1);
177 auto task = std::make_unique<R3BNeulandNeutronsRValue>(
178 option.neutron_energy_mev, read_branch_names.at(0), read_branch_names.at(1), write_branch_names.at(0));
179 task->SetName(option.name.c_str());
180 run->AddTask(task.release());
181 }
182
183 if (const auto& option = task_option.neuland_map_data_converter_task; option.enable)
184 {
185 parse_io_branch_names(option, read_branch_names, 2, write_branch_names, 2);
186 auto task = std::make_unique<Calibration::MapDataConverterTask>(
187 read_branch_names.at(0), read_branch_names.at(1), write_branch_names.at(0), write_branch_names.at(1));
188 task->SetName(option.name.c_str());
189 run->AddTask(task.release());
190 }
191
192 if (const auto& option = task_option.neuland_map_to_cal_par_task; option.enable)
193 {
194 parse_io_branch_names(option, read_branch_names, 2, write_branch_names, 2);
195 auto task = std::make_unique<R3B::Neuland::Map2CalParTask>(
196 read_branch_names.at(0), read_branch_names.at(1), write_branch_names.at(0), write_branch_names.at(1));
197 task->SetTrigEnabled(option.has_trig_enabled);
198 task->SetErrorMethod(option.error_method);
199 run->AddTask(task.release());
200 }
201
202 if (const auto& option = task_option.neuland_map_to_cal_task; option.enable)
203 {
204 auto task = std::make_unique<std::remove_cvref_t<decltype(option)>::Task>(option);
205 run->AddTask(task.release());
206 }
207
208 if (const auto& option = task_option.los_map_to_cal_par_task; option.enable)
209 {
210 parse_io_branch_names(option, read_branch_names, 2, write_branch_names, 1);
211 auto task = std::make_unique<R3BLosMapped2CalPar>();
212 run->AddTask(task.release());
213 }
214
215 if (const auto& option = task_option.los_map_to_cal_task; option.enable)
216 {
217 parse_io_branch_names(option, read_branch_names, 3, write_branch_names, 1);
218 auto task = std::make_unique<R3BLosMapped2Cal>();
219 static constexpr auto LOS_MODULE_NUM = 8;
220 task->SetNofModules(1, LOS_MODULE_NUM);
221 task->SetTrigger(1);
222 run->AddTask(task.release());
223 }
224
225 if (const auto& option = task_option.neuland_cal_to_hit_par_task; option.enable)
226 {
227 auto task = std::make_unique<std::remove_cvref_t<decltype(option)>::Task>(option);
228 run->AddTask(task.release());
229 }
230
231 if (const auto& option = task_option.los_provide_t_start; option.enable)
232 {
233 parse_io_branch_names(option, read_branch_names, 2, write_branch_names, 0);
234 auto task = std::make_unique<R3BLosProvideTStart>();
235 run->AddTask(task.release());
236 }
237
238 if (const auto& option = task_option.neuland_cal_to_hit_task; option.enable)
239 {
240 parse_io_branch_names(option, read_branch_names, 2, write_branch_names, 1);
241 auto task = std::make_unique<R3B::Neuland::Cal2HitTask>(
242 read_branch_names.at(0), read_branch_names.at(1), write_branch_names.at(0));
243 task->SetTrigger(option.mode);
244 task->SetGlobalTimeOffset(option.global_time_offset);
245 run->AddTask(task.release());
246 }
247
248 if (const auto& option = task_option.neuland_cosmic_monitor_task; option.enable)
249 {
250 auto task = std::make_unique<std::remove_cvref_t<decltype(option)>::Task>(option);
251 run->AddTask(task.release());
252 }
253
254 if (const auto& option = task_option.neuland_hit_online_monitor_task; option.enable)
255 {
256 auto task = std::make_unique<std::remove_cvref_t<decltype(option)>::Task>(option);
257 run->AddTask(task.release());
258 }
259
260 if (const auto& option = task_option.neuland_cal_monitor_task; option.enable)
261 {
262 parse_io_branch_names(option, read_branch_names, 1, write_branch_names, 0);
263 auto task = std::make_unique<R3B::Neuland::CalMonitorTask>(read_branch_names.at(0));
264 task->SetTrigger(option.mode);
265 run->AddTask(task.release());
266 }
267 }
268
270
272
273 void AnalysisApplication::dump_json_options(const std::string& filename)
274 {
276 }
277
278 void AnalysisApplication::ParseApplicationOption(const std::vector<std::string>& filename)
279 {
281 }
282} // namespace R3B::Neuland
void ParseApplicationOption(const std::vector< std::string > &filename) override
void setup_application_options(CLI::App &program_options) override
void dump_json_options(const std::string &filename) override
void run() override
Run the CLI program.
void ParseApplicationOptionImp(const std::vector< std::string > &filename, OptionType &options)
CLIApplication(std::string_view name, std::unique_ptr< FairRun > run, std::reference_wrapper< Options > option)
void dump_json_options(const OptionType &options, const std::string &filename)
static auto Create(const R3B::Neuland::DigiTaskOptions &option, FairRun *run) -> std::unique_ptr< Digitizer >
Generator of the digitizing class.
Simulation of NeuLAND Bar/Paddle.
AnalysisApplication::Options Options