R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BNeulandHitCosmicCanvas.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/algorithm.hpp>
19
20constexpr auto REFERENCE_BAR_ID_FRONT = 624;
21constexpr auto REFERENCE_BAR_ID_BACK = 674;
22
23namespace R3B::Neuland
24{
25 void HitCosmicCanvas::DataInit() { hit_data_.init(); }
27 {
28 auto& canvas = CreateNewCanvas(histograms);
29 auto bar_numbers = GetBarNumber();
30 canvas.divide(2, 3);
31
32 constexpr auto TIME_BIN_SIZE = 1000;
33 constexpr auto ENERGY_BIN_SIZE = 2000;
34 constexpr auto ENERGY_MAX = 120.;
35 constexpr auto TIME_MAX = 20.;
36
37 hHitEvsBarCosmics_ = canvas.add<1, TH2D>("hHitEvsBarCosmics",
38 "HitLevel: Energy vs Bars cosmics",
39 bar_numbers,
40 -0.5,
41 bar_numbers + 0.5,
42 ENERGY_BIN_SIZE,
43 0,
44 ENERGY_MAX);
45
46 hTdiffvsBarCosmics_ = canvas.add<2, TH2D>("hTdiffvsBarCosmics",
47 "Tdiff vs Bars cosmics",
48 bar_numbers,
49 -0.5,
50 bar_numbers + 0.5,
51 TIME_BIN_SIZE,
52 -ENERGY_MAX,
53 ENERGY_MAX);
54
55 hDTBack_ = canvas.add<3, TH2D>("hDT675",
56 "Thit - Thit675 vs Bars cosmics",
57 bar_numbers,
58 -0.5,
59 bar_numbers + 0.5,
60 TIME_BIN_SIZE,
61 -TIME_MAX,
62 TIME_MAX);
63
64 hDTBackc_ = canvas.add<4, TH2D>("hDT675c",
65 "Thit - Thit675 vs Bars cosmics corrected",
66 bar_numbers,
67 -0.5,
68 bar_numbers + 0.5,
69 TIME_BIN_SIZE,
70 -TIME_MAX,
71 TIME_MAX);
72
73 hDTFront_ = canvas.add<5, TH2D>("hDT625",
74 "Thit - Thit625 vs Bars cosmics",
75 bar_numbers,
76 -0.5,
77 bar_numbers + 0.5,
78 TIME_BIN_SIZE,
79 -TIME_MAX,
80 TIME_MAX);
81
82 hDTFrontc_ = canvas.add<6, TH2D>("hDT625c",
83 "Thit - Thit625 vs Bars cosmics corrected",
84 bar_numbers,
85 -0.5,
86 bar_numbers + 0.5,
87 TIME_BIN_SIZE,
88 -TIME_MAX,
89 TIME_MAX);
90 }
91
93 {
94 for (const auto& hit : hit_data_)
95 {
96 const auto module_id = hit.module_id;
97 hHitEvsBarCosmics_->Fill(module_id, hit.energy);
98 // std::cout << "energy: " << hit.energy << "\n";
99 hTdiffvsBarCosmics_->Fill(module_id, hit.tdc_left - hit.tdc_right);
100
101 auto fill_data_ref = [this, &hit, module_id](auto module_id_ref, auto& hist, auto& hist_c)
102 {
103 if (module_id == module_id_ref)
104 {
105 return;
106 }
107
108 if (auto res = ranges::find_if(
109 hit_data_.get(), [&module_id_ref](const auto& ele) { return ele.module_id == module_id_ref; });
110 res != hit_data_.get().end())
111 {
112 const auto& hit_ref = *(res);
113 const auto time_mean = (hit.tdc_left + hit.tdc_right) / 2;
114 const auto time_mean_ref = (hit_ref.tdc_left + hit_ref.tdc_right) / 2;
115 const auto time_diff = time_mean - time_mean_ref;
116
117 const auto distance = hit.position - hit_ref.position;
118 const auto time_c = std::copysign(distance.Mag() / CLight, distance.Y());
119
120 hist->Fill(module_id, time_diff);
121 hist_c->Fill(module_id, time_diff + time_c);
122 }
123 };
124
125 fill_data_ref(REFERENCE_BAR_ID_FRONT, hDTFront_, hDTFrontc_);
126 fill_data_ref(REFERENCE_BAR_ID_BACK, hDTBack_, hDTBackc_);
127 }
128 }
130} // namespace R3B::Neuland
constexpr auto REFERENCE_BAR_ID_FRONT
constexpr auto REFERENCE_BAR_ID_BACK
void CanvasInit(DataMonitor &histograms) override
void CanvasFill(DataMonitor &histograms) override
auto CreateNewCanvas(DataMonitor &histograms) -> DataMonitorCanvas &
Simulation of NeuLAND Bar/Paddle.
constexpr auto CLight