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