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"
21#include <FairRootManager.h>
22#include <FairRuntimeDb.h>
23#include <R3BLogger.h>
25#include <R3BNeulandMillepede.h>
27#include <memory>
28#include <string_view>
29
30namespace R3B::Neuland
31{
32 // NOLINTBEGIN
34 std::string_view cal_data_name,
35 std::string_view base_par_name,
36 std::string_view hit_par_name,
37 std::string_view name,
38 int iVerbose)
39 : CalibrationTask(name, iVerbose)
40 , cal_data_{ cal_data_name }
41 , base_par_{ InputPar<CalibrationBasePar>(base_par_name) }
42 // NOLINTEND
43 {
44 switch (method)
45 {
47 R3BLOG(info, "Cal2HitPar method: LSQT.");
48 engine_ = std::make_unique<Calibration::LSQREngineAdaptor>();
49 hit_par_ = OutputPar<Cal2HitPar>(hit_par_name);
50 break;
52 R3BLOG(info, "Cal2HitPar method: Millepede.");
53 engine_ = std::make_unique<Calibration::MillepedeEngine>();
54 hit_par_ = InputPar<Cal2HitPar>(hit_par_name);
55 break;
57 R3BLOG(info, "Cal2HitPar method: predecessor.");
58 engine_ = std::make_unique<Calibration::Predecessor>();
59 hit_par_ = OutputPar<Cal2HitPar>(hit_par_name);
60 break;
61 }
62 }
63
64 void Cal2HitParTask::HistogramInit(DataMonitor& histograms) { engine_->HistInit(histograms); }
65
66 void Cal2HitParTask::ExtraInit(FairRootManager* /*rootMan*/)
67 {
68 cal_data_.init();
69
70 const auto plane_num = base_par_->GetNumOfPlanes();
71 if (plane_num == 0)
72 {
73 throw R3B::runtime_error("Plane number extracted from Map2CalPar is 0!");
74 }
75 engine_->SetTask(this);
76 engine_->SetModuleSize(plane_num * BarsPerPlane);
77 engine_->Init();
78 }
79
80 void Cal2HitParTask::SetExtraPar(FairRuntimeDb* rtdb) {}
81
83 {
84 engine_->EventReset();
85 engine_->AddSignals(cal_data_.get());
86 // for (const auto& bar_signal : cal_data_)
87 // {
88 // engine_->AddSignal(bar_signal);
89 // }
90 auto* eventHeader = GetEventHeader();
91 if (eventHeader != nullptr)
92 {
93 engine_->EndOfEvent(eventHeader->GetEventno());
94 }
95 else
96 {
97 throw R3B::runtime_error("Event header is nullptr!");
98 }
99 }
100
102 {
103 if (hit_par_ == nullptr)
104 {
105 throw R3B::runtime_error("Hit parameter is nullptr during the calibration!");
106 }
107
108 R3BLOG(info, "Starting to do cosmic calibration calibration!");
109 engine_->Calibrate(*hit_par_);
110 engine_->EndOfTask();
111 }
112
114 {
115 auto res = engine_->SignalFilter(cal_data_.get());
116 return res;
117 }
118} // namespace R3B::Neuland
#define R3BLOG(severity, x)
Definition R3BLogger.h:35
void ExtraInit(FairRootManager *rootMan) override
void SetExtraPar(FairRuntimeDb *rtdb) override
void HistogramInit(DataMonitor &histograms) override
auto CheckConditions() const -> bool override
Cal2HitParTask(Cal2HitParMethod method=Cal2HitParMethod::LSQT, std::string_view cal_data_name="NeulandCalData", std::string_view base_par_name="NeulandCalibrationBasePar", std::string_view hit_par_name="NeulandHitPar", std::string_view name="NeulandCal2HitParTask", int iVerbose=1)
auto InputPar(std::string_view par_name, FairRuntimeDb *rtdb=FairRuntimeDb::instance()) -> ParType *
auto OutputPar(std::string_view par_name, FairRuntimeDb *rtdb=FairRuntimeDb::instance()) -> ParType *
Simulation of NeuLAND Bar/Paddle.
constexpr auto BarsPerPlane