R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
testNeulandTSyncer.C
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
3 * Copyright (C) 2019-2025 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
14// FIXME Root Problem remove this as soon as Fairsoft is using Root >=6.20.00
15namespace Neuland
16{
17 constexpr auto CLight = 29.9792458; // Speed of light [cm/ns]
18 constexpr auto InvCLight = 1. / CLight; // Speed of light [cm/ns]>
19
20 // Electronics Constans
21
22 constexpr auto MaxCalTime = 5. * 2048;
23
24 // Geometry & Material Constants
25
26 constexpr auto BarSize_XY = 5.0; // cm NeuLAND parameter
27 constexpr auto BarUncertainty_XY = BarSize_XY / __sqrt12; // cm NeuLAND parameter
28 constexpr auto BarSize_Z = 5.0; // cm NeuLAND parameter
29 constexpr auto BarUncertainty_Z = BarSize_Z / __sqrt12; // cm NeuLAND parameter
30 constexpr auto BarLength = 250.0; // cm NeuLAND parameter
31 constexpr auto LightGuideLength = 10.0; // cm NeuLAND parameter
32 constexpr auto TotalBarLength = BarLength + 2 * LightGuideLength; // cm NeuLAND parameter, Bar including Light Guide
33
34 constexpr auto ScintillatorDensity = 1.032; // g / cm^3
35 constexpr auto MIPStoppingPowerPerDensity = 1.956; // MeV cm^2 / g
36 constexpr auto MIPStoppingPower = 1.73; // MeV / cm
37
38 constexpr auto FirstHorizontalPlane = 0;
39 constexpr auto BarsPerPlane = 50;
40 constexpr auto MaxNumberOfPlanes = 60;
42
43 constexpr bool IsPlaneHorizontal(const int plane) { return (plane % 2 == FirstHorizontalPlane); }
44 constexpr bool IsPlaneVertical(const int plane) { return !IsPlaneHorizontal(plane); }
45 constexpr int GetPlaneNumber(const int barID) { return barID / BarsPerPlane; }
46
47 // Average Parameters
48
49 constexpr auto AvgTimeResolution = 0.150; // ns
50 constexpr auto AvgEffectiveCLight = -7.95; // cm / ns
51 constexpr auto AvgGain = 15; // MeV / ns
52 constexpr auto AvgThreshold = 1.75; // MeV
53 constexpr auto AvgAttenuationLength = 400.; // cm
54} // namespace Neuland
55
56constexpr Int_t nPlanes = 2;
57constexpr Int_t nEvents = 1024;
58
60{
61 TRandom3 rnd(23);
62
63 std::array<std::array<Double_t, Neuland::BarsPerPlane>, nPlanes> tsync;
65
66 for (auto plane = 0; plane < nPlanes; ++plane)
67 {
68 for (auto bar = 0; bar < Neuland::BarsPerPlane; ++bar)
69 {
70 tsync[plane][bar] = rnd.Uniform(-100., 100.);
71 }
72 }
73
74 for (auto event = 0; event < nEvents; ++event)
75 {
76 const auto offset = rnd.Uniform(-100., 100.);
77 for (auto plane = 0; plane < nPlanes; ++plane)
78 {
79 for (auto bar = 0; bar < Neuland::BarsPerPlane; ++bar)
80 {
81 syncer->AddBarData(plane * Neuland::BarsPerPlane + bar, rnd.Gaus(tsync[plane][bar], 0.05) + offset);
82 }
83 }
84 syncer->DoEvent();
85 }
86
87 const auto result = syncer->GetTSync(nPlanes);
88 const auto offset = result[0].Value - tsync[0][0];
89 for (auto plane = 0; plane < nPlanes; ++plane)
90 {
91 for (auto bar = 0; bar < Neuland::BarsPerPlane; ++bar)
92 {
93 if (!std::isfinite(result[plane * Neuland::BarsPerPlane + bar].Value) ||
94 fabs(result[plane * Neuland::BarsPerPlane + bar].Value - tsync[plane][bar] - offset) > 0.05)
95 {
96 std::cout << "FAILED" << std::endl;
97 return;
98 }
99 }
100 }
101
102 std::cout << "SUCCESS" << std::endl;
103}
void AddBarData(const Int_t barID, const Double_t time)
std::vector< ValueErrorPair > GetTSync(UInt_t nPlanes=Neuland::MaxNumberOfPlanes)
Simulation of NeuLAND Bar/Paddle.
constexpr auto __sqrt12
constexpr auto BarsPerPlane
constexpr auto AvgTimeResolution
constexpr auto BarUncertainty_Z
constexpr auto InvCLight
constexpr auto MaxNumberOfBars
constexpr auto BarLength
constexpr auto BarSize_Z
constexpr auto MIPStoppingPower
constexpr auto AvgEffectiveCLight
constexpr auto CLight
constexpr auto BarSize_XY
constexpr auto FirstHorizontalPlane
constexpr auto TotalBarLength
constexpr auto AvgAttenuationLength
constexpr auto AvgThreshold
constexpr auto BarUncertainty_XY
constexpr bool IsPlaneVertical(const int plane)
constexpr auto LightGuideLength
constexpr auto MaxNumberOfPlanes
constexpr auto AvgGain
constexpr int GetPlaneNumber(const int barID)
constexpr auto MIPStoppingPowerPerDensity
constexpr auto MaxCalTime
constexpr bool IsPlaneHorizontal(const int plane)
constexpr auto ScintillatorDensity
constexpr UInt_t nEvents
constexpr Int_t nPlanes
void testNeulandTSyncer()