R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BNeulandHitXYCanvas.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#include <range/v3/view.hpp>
20
21namespace R3B::Neuland
22{
23 void HitXYCanvas::DataInit() { hit_data_.init(); }
25 {
26 auto& canvas = CreateNewCanvas(histograms);
27 auto bar_numbers = GetBarNumber();
28 auto num_of_plane = static_cast<int>(bar_numbers / BarsPerPlane);
29
30 canvas.divide(5, 6);
31
32 constexpr auto XY_BIN_SIZE = 300;
33 constexpr auto XY_MAX = 150;
34
35 h_xy_per_plane_.reserve(num_of_plane);
36 for (const auto& plane_id : ranges::views::iota(0, num_of_plane))
37 {
38 const auto hist_name = fmt::format("hHitXYPlane{}", plane_id);
39 const auto hist_title = fmt::format("Hit XY Plane{}", plane_id);
40 auto hist = canvas.add<TH2D>(
41 plane_id + 1, hist_name, hist_title, XY_BIN_SIZE, -XY_MAX, XY_MAX, XY_BIN_SIZE, -XY_MAX, XY_MAX);
42 h_xy_per_plane_.push_back(hist);
43 }
44 }
45
47 {
48 auto* rand_gen = GetOnlineSpectra()->GetRandomGenerator();
49 for (const auto& hit : hit_data_)
50 {
51 const auto module_id = hit.module_id;
52 const auto plane_id = ModuleID2PlaneID(module_id);
53 const auto bar_width_error = rand_gen->Uniform(-BarSize_XY / 2., BarSize_XY / 2.);
54 // TODO: introduce calibration errors
55 if (IsPlaneIDHorizontal(plane_id))
56 {
57 h_xy_per_plane_.at(plane_id)->Fill(hit.position.X(), hit.position.Y() + bar_width_error);
58 }
59 else
60 {
61 h_xy_per_plane_.at(plane_id)->Fill(hit.position.X() + bar_width_error, hit.position.Y());
62 }
63 }
64 }
66} // namespace R3B::Neuland
void CanvasFill(DataMonitor &histograms) override
void CanvasInit(DataMonitor &histograms) override
auto CreateNewCanvas(DataMonitor &histograms) -> DataMonitorCanvas &
auto GetOnlineSpectra() const -> OnlineSpectra *
Simulation of NeuLAND Bar/Paddle.
constexpr auto BarsPerPlane
constexpr auto ModuleID2PlaneID(int moduleID) -> int
constexpr auto BarSize_XY
constexpr auto IsPlaneIDHorizontal(int plane_id) -> bool