R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BNeulandMillepede.h
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#pragma once
14
15#include "MilleEntry.h"
16#include "R3BDataMonitor.h"
17#include "R3BLogger.h"
18#include "R3BNeulandCalData2.h"
22#include <Mille.h>
23#include <ParResultReader.h>
24#include <PedeLauncher.h>
25#include <R3BNeulandCommon.h>
26#include <TH1.h>
27#include <cstdint>
28#include <fmt/core.h>
29#include <memory>
30#include <optional>
31#include <string>
32#include <string_view>
33#include <utility>
34#include <vector>
35// #include <RankChecker.h>
36
37class TGraphErrors;
38
40{
41 enum class GlobalLabel : int8_t
42 {
43 tsync, // tsync
44 offset_effective_c, // offset times effective_C
45 effective_c // effective speed of light
46 };
47
49 {
50 public:
51 MillepedeEngine() = default;
52 void enable_rank_check(bool rank_check = true) { has_rank_check_ = rank_check; }
54 void set_p_value_cut(double val) { p_value_cut_ = val; }
55
56 private:
57 bool has_rank_check_ = false;
58 int minimum_hit_ = 1;
59 float error_scale_factor_ = 1000.F;
60 // float minimum_pos_z_ = 0;
61 // float smallest_time_sum_ = 0.;
62 std::optional<float> average_t_sum_;
65 constexpr static std::string_view DEFAULT_SUB_DIR = "millepede";
66
68 std::string input_data_filename_ = "neuland_cosmic_mille.bin";
69 std::string pede_steer_filename_ = "neuland_steer.txt";
70 std::string parameter_filename_ = "neuland_pars.txt";
71 std::string working_dir_;
72
73 std::unique_ptr<Mille> binary_data_writer_;
76
77 // histograms:
78 TGraphErrors* graph_time_offset_ = nullptr;
79 TGraphErrors* graph_time_sync_ = nullptr;
80 TGraphErrors* graph_effective_c_ = nullptr;
81 TH1D* hist_t_offset_residual_ = nullptr;
82
83 // parameter:
85
86 std::unique_ptr<MilleDataProcessor> data_preprocessor_;
87
88 void Init() override;
89 void AddSignals(const std::vector<BarCalData>& signals) override;
90 void Calibrate(Cal2HitPar& hit_par) override;
91 void EndOfEvent(unsigned int event_num = 0) override;
92 void EventReset() override;
93 auto SignalFilter(const std::vector<BarCalData>& signals) -> bool override;
94 void EndOfTask() override;
95 void HistInit(DataMonitor& histograms) override;
96 void SetMinStat(int min) override
97 {
98 minimum_hit_ = min;
99 R3BLOG(info, fmt::format("Minimum number of hits is set to {}", minimum_hit_));
100 }
101 void SetErrorScale(float scale) override { error_scale_factor_ = scale; }
102
103 void buffer_clear();
104 void write_to_buffer();
105 void add_signal_t_sum(const MilleCalData& signal);
106 void add_signal_t_diff(const MilleCalData& signal);
107 void add_spacial_local_constraint(int plane_id, const std::vector<MilleCalData>& plane_signals);
108 auto set_minimum_values(const std::vector<R3B::Neuland::BarCalData>& signals) -> bool;
109 inline auto get_global_label_id(int module_num, GlobalLabel label) -> int;
110 inline auto to_module_num_label(int par_num) -> std::pair<int, GlobalLabel>;
111 void fill_module_parameters(const Millepede::ResultReader& result, Neuland::Cal2HitPar& cal_to_hit_par);
112 void fill_data_to_figure(Cal2HitPar& hit_par);
113
114 void init_parameter();
115 void init_steer_writer();
116 void set_working_dir();
117
118 auto select_t_diff_signal(const std::vector<MilleCalData>& plane_data);
119 };
120
121} // namespace R3B::Neuland::Calibration
#define R3BLOG(severity, x)
Definition R3BLogger.h:32
auto to_module_num_label(int par_num) -> std::pair< int, GlobalLabel >
void Calibrate(Cal2HitPar &hit_par) override
void add_spacial_local_constraint(int plane_id, const std::vector< MilleCalData > &plane_signals)
auto set_minimum_values(const std::vector< R3B::Neuland::BarCalData > &signals) -> bool
void EndOfEvent(unsigned int event_num=0) override
auto select_t_diff_signal(const std::vector< MilleCalData > &plane_data)
static constexpr std::string_view DEFAULT_SUB_DIR
void fill_module_parameters(const Millepede::ResultReader &result, Neuland::Cal2HitPar &cal_to_hit_par)
std::unique_ptr< MilleDataProcessor > data_preprocessor_
void add_signal_t_sum(const MilleCalData &signal)
void add_signal_t_diff(const MilleCalData &signal)
auto SignalFilter(const std::vector< BarCalData > &signals) -> bool override
void AddSignals(const std::vector< BarCalData > &signals) override
auto get_global_label_id(int module_num, GlobalLabel label) -> int
void HistInit(DataMonitor &histograms) override
constexpr auto DEFAULT_T_DIFF_RESIDUAL_CUT
constexpr auto DEFAULT_CALIBRATION_P_VALUE_CUT