R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BNeulandTimingCanvas.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 <R3BNeulandCommon.h>
17#include <TH2.h>
18#include <range/v3/view.hpp>
19
20namespace rng = ranges;
21
22namespace R3B::Neuland
23{
25 {
26 hit_data_.init();
27 cal_data_.init();
28 }
29
31 {
32 auto& canvas = CreateNewCanvas(histograms);
33 auto bar_numbers = GetBarNumber();
34 auto num_of_plane = static_cast<int>(bar_numbers / BarsPerPlane);
35
36 canvas.divide(2, 2);
37
38 constexpr auto TOF_BIN_SIZE = 3000;
39 constexpr auto TOF_MIN = -100;
40 constexpr auto TOF_MAX = 500;
41
42 constexpr auto X_BIN_SIZE = 1000;
43 constexpr auto X_MAX = 200;
44
45 constexpr auto TDC_BIN_SIZE = 1000;
46 constexpr auto TDC_MAX = 10000;
47
48 hTofvsZ_ =
49 canvas.add<1, TH2D>("hTofvsZ", "Tof vs Z", num_of_plane, 0, num_of_plane, TOF_BIN_SIZE, TOF_MIN, TOF_MAX);
50 hTofvsZ_.pad()->SetLogz();
51 hNeuLANDvsStart_ = canvas.add<2, TH2D>("hNeuLANDvsStart",
52 "hNeuLANDvsStart",
53 3 * TDC_BIN_SIZE,
54 -TDC_MAX,
55 4 * TDC_MAX,
56 TDC_BIN_SIZE,
57 -TDC_MAX,
58 TDC_MAX);
59 hTOFc_ = canvas.add<3, TH1D>("hTOFc", "hTOFc", TOF_BIN_SIZE, TOF_MIN, TOF_MAX);
60 hTOFc_.pad()->SetLogy();
61 hTofcvsX_ =
62 canvas.add<4, TH2D>("hTofcvsX", "Tofc vs X", X_BIN_SIZE, -X_MAX, X_MAX, TOF_BIN_SIZE, TOF_MIN, TOF_MAX);
63 hTofcvsX_.pad()->SetLogz();
64 }
65
66 void TimingCanvas::hit_data_fill()
67 {
68 const auto distance_to_target = GetOnlineSpectra()->GetDistanceToTarget();
69 auto* rand_gen = GetOnlineSpectra()->GetRandomGenerator();
70 for (const auto& hit : hit_data_)
71 {
72 const auto module_id = hit.module_id;
73 const auto plane_id = ModuleID2PlaneID(module_id);
74 const auto bar_width_error = rand_gen->Uniform(-BarSize_XY / 2., BarSize_XY / 2.);
75
76 const auto time = hit.time;
77 const auto correc_time = time - (hit.position.Mag() - distance_to_target) / CLight;
78 const auto pos_x = IsPlaneIDHorizontal(plane_id) ? hit.position.X() : hit.position.X() + bar_width_error;
79
80 hTofvsZ_->Fill(plane_id, time);
81 hTofcvsX_->Fill(pos_x, correc_time);
82 // fmt::print("hTofvsZ: plane_id: {}, time: {}\n", plane_id, time);
83 // fmt::print("hTofcvsX: pos_x: {}, correc_time: {}\n", pos_x, correc_time);
84 if (hit.energy > 0.)
85 {
86 hTOFc_->Fill(correc_time);
87 // fmt::print("hTOFc: correc_time: {}\n", correc_time);
88 }
89 }
90 }
91
92 void TimingCanvas::cal_data_fill()
93 {
94 auto* event_header = GetOnlineSpectra()->GetEventHeader();
95 const auto time_start = event_header->GetTStart();
96 if (std::isnan(time_start))
97 {
98 return;
99 }
100 for (const auto& cal_signal :
101 cal_data_ |
102 rng::views::transform([](const auto& bar_signal)
103 { return ranges::views::concat(bar_signal.left, bar_signal.right); }) |
104 ranges::views::join)
105 {
106 const auto time_cal = cal_signal.leading_time - cal_signal.trigger_time;
107 hNeuLANDvsStart_->Fill(time_start, time_cal.value);
108 // fmt::print("NeulandVsStart: time_start: {}, time_cal: {}\n", time_start, time_cal.value);
109 }
110 }
111
113 {
114 cal_data_fill();
115 hit_data_fill();
116 }
117
119} // namespace R3B::Neuland
auto CreateNewCanvas(DataMonitor &histograms) -> DataMonitorCanvas &
auto GetOnlineSpectra() const -> OnlineSpectra *
void CanvasFill(DataMonitor &histograms) override
void CanvasInit(DataMonitor &histograms) override
Simulation of NeuLAND Bar/Paddle.
constexpr auto BarsPerPlane
constexpr auto ModuleID2PlaneID(int moduleID) -> int
constexpr auto CLight
constexpr auto BarSize_XY
constexpr auto IsPlaneIDHorizontal(int plane_id) -> bool