R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BNeulandCalToHitParTask.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 "R3BDataMonitor.h"
16#include "R3BException.h"
17#include "R3BNeulandBasePar.h"
20#include "R3BNeulandCommon.h"
22#include <FairRootManager.h>
23#include <FairRuntimeDb.h>
24#include <R3BLogger.h>
26#include <R3BNeulandMillepede.h>
28#include <TH1.h>
29#include <fairlogger/Logger.h>
30#include <memory>
31#include <utility>
32
33namespace R3B::Neuland
34{
36
37 : CalibrationTask(config.name, 1)
38 , config_{ config }
39 , cal_data_{ get_from_sep_string(0, config.read) }
40 , base_par_{ AddInputPar<CalibrationBasePar>(get_from_sep_string(1, config.read)) }
41 , hit_par_(AddOutputPar<Cal2HitPar>(get_from_sep_string(0, config.write)))
42
43 {
45 {
46 auto millepede_engine = std::make_unique<Calibration::MillepedeEngine>();
47 millepede_engine->set_options(config.millepede);
48 SetMethod(std::move(millepede_engine));
49 }
50 else
51 {
52 SetMethod(config.method);
53 }
54 SetMinStat(config.min_stat);
55 SetTrigger(config.mode);
56 }
57
59 {
60 if (engine_ == nullptr)
61 {
62 LOGP(warn, "Engine is nullptr!");
63 return;
64 }
65 engine_->SetMinStat(min);
66 }
67
69 {
70 if (engine_ == nullptr)
71 {
72 LOGP(warn, "Engine is nullptr!");
73 return;
74 }
75 engine_->SetErrorScale(scale);
76 }
77
79 {
80 switch (method)
81 {
83 engine_ = std::make_unique<Calibration::MuonReconstruction>();
84 break;
86 engine_ = std::make_unique<Calibration::MillepedeEngine>();
87 break;
89 engine_ = std::make_unique<Calibration::HistAnalysis>();
90 break;
91 }
92 }
93
94 void Cal2HitParTask::HistogramInit(DataMonitor& histograms) { engine_->HistInit(histograms); }
95
96 void Cal2HitParTask::ExtraInit(FairRootManager* /*rootMan*/)
97 {
98 cal_data_.init();
99
100 const auto plane_num = base_par_->get_num_of_planes();
101 if (plane_num == 0)
102 {
103 throw R3B::runtime_error("Plane number extracted from Map2CalPar is 0!");
104 }
105 if (engine_ == nullptr)
106 {
107 throw R3B::logic_error("Calibration engine is not set!");
108 }
109 engine_->SetTask(this);
110 engine_->SetModuleSize(plane_num * BarsPerPlane);
111 engine_->Init();
112 }
113
114 void Cal2HitParTask::SetExtraPar(FairRuntimeDb* rtdb) {}
115
117 {
118 engine_->EventReset();
119 engine_->AddSignals(cal_data_.get());
120 // for (const auto& bar_signal : cal_data_)
121 // {
122 // engine_->AddSignal(bar_signal);
123 // }
124 auto* eventHeader = GetEventHeader();
125 if (eventHeader != nullptr)
126 {
127 engine_->EndOfEvent(eventHeader->GetEventno());
128 }
129 else
130 {
131 throw R3B::runtime_error("Event header is nullptr!");
132 }
133 }
134
136 {
137 if (hit_par_ == nullptr)
138 {
139 throw R3B::runtime_error("Hit parameter is nullptr during the calibration!");
140 }
141
142 R3BLOG(info, "Starting to do cosmic calibration calibration!");
143 engine_->Calibrate(*hit_par_);
144 engine_->EndOfTask();
145 }
146 void Cal2HitParTask::BeginOfEvent() { engine_->BeginOfEvent(); }
147
148 auto Cal2HitParTask::CheckConditions([[maybe_unused]] TH1L* hist_condition) const -> bool
149 {
150 auto res = engine_->SignalFilter(cal_data_.get());
151 return res;
152 }
153} // namespace R3B::Neuland
#define R3BLOG(severity, x)
Definition R3BLogger.h:33
InputVectorConnector< BarCalData > cal_data_
void ExtraInit(FairRootManager *rootMan) override
std::unique_ptr< Calibration::CosmicEngineInterface > engine_
void SetExtraPar(FairRuntimeDb *rtdb) override
void SetMethod(Cal2HitParMethod method)
void HistogramInit(DataMonitor &histograms) override
auto CheckConditions(TH1L *hist_condition) const -> bool override
auto AddOutputPar(std::string_view par_name, FairRuntimeDb *rtdb=FairRuntimeDb::instance()) -> ParType *
auto AddInputPar(std::string_view par_name, FairRuntimeDb *rtdb=FairRuntimeDb::instance()) -> ParType *
Simulation of NeuLAND Bar/Paddle.
constexpr auto BarsPerPlane