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 "R3BDataMonitor.h"
16#include <R3BNeulandCommon.h>
18#include <TH2.h>
19#include <fmt/core.h>
20#include <range/v3/view/iota.hpp>
21
22namespace R3B::Neuland
23{
26 {
27 auto& canvas = CreateNewCanvas(histograms);
28 auto bar_numbers = GetBarNumber();
29 auto num_of_plane = static_cast<int>(bar_numbers / BarsPerPlane);
30
31 canvas.divide(5, 6);
32
33 constexpr auto XY_BIN_SIZE = 300;
34 constexpr auto XY_MAX = 150;
35
36 h_xy_per_plane_.reserve(num_of_plane);
37 for (const auto& plane_id : ranges::views::iota(0, num_of_plane))
38 {
39 const auto hist_name = fmt::format("hHitXYPlane{}", plane_id);
40 const auto hist_title = fmt::format("Hit XY Plane{}", plane_id);
41 auto hist = canvas.add<TH2D>(
42 plane_id + 1, hist_name, hist_title, XY_BIN_SIZE, -XY_MAX, XY_MAX, XY_BIN_SIZE, -XY_MAX, XY_MAX);
43 h_xy_per_plane_.push_back(hist);
44 }
45 }
46
48 {
49 auto* rand_gen = GetOnlineSpectra()->GetRandomGenerator();
50 for (const auto& hit : hit_data_)
51 {
52 const auto module_id = hit.module_id;
53 const auto plane_id = ModuleID2PlaneID(module_id);
54 const auto bar_width_error = rand_gen->Uniform(-BarSize_XY / 2., BarSize_XY / 2.);
55 // TODO: introduce calibration errors
56 if (IsPlaneIDHorizontal(plane_id))
57 {
58 h_xy_per_plane_.at(plane_id)->Fill(hit.position.X(), hit.position.Y() + bar_width_error);
59 }
60 else
61 {
62 h_xy_per_plane_.at(plane_id)->Fill(hit.position.X() + bar_width_error, hit.position.Y());
63 }
64 }
65 }
67} // namespace R3B::Neuland
std::vector< CanvasElement< TH2D > > h_xy_per_plane_
void CanvasFill(DataMonitor &histograms) override
InputVectorConnector< R3BNeulandHit > hit_data_
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