R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
testNeulandBar.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 __sqrt12 = 3.464101615;
18
19 constexpr auto CLight = 29.9792458; // Speed of light [cm/ns]
20 constexpr auto InvCLight = 1. / CLight; // Speed of light [cm/ns]>
21
22 // Electronics Constans
23
24 constexpr auto MaxCalTime = 5. * 2048;
25
26 // Geometry & Material Constants
27
28 constexpr auto BarSize_XY = 5.0; // cm NeuLAND parameter
29 constexpr auto BarUncertainty_XY = BarSize_XY / __sqrt12; // cm NeuLAND parameter
30 constexpr auto BarSize_Z = 5.0; // cm NeuLAND parameter
31 constexpr auto BarUncertainty_Z = BarSize_Z / __sqrt12; // cm NeuLAND parameter
32 constexpr auto BarLength = 250.0; // cm NeuLAND parameter
33 constexpr auto LightGuideLength = 10.0; // cm NeuLAND parameter
34 constexpr auto TotalBarLength = BarLength + 2 * LightGuideLength; // cm NeuLAND parameter, Bar including Light Guide
35
36 constexpr auto ScintillatorDensity = 1.032; // g / cm^3
37 constexpr auto MIPStoppingPowerPerDensity = 1.956; // MeV cm^2 / g
38 constexpr auto MIPStoppingPower = 1.73; // MeV / cm
39
40 constexpr auto FirstHorizontalPlane = 0;
41 constexpr auto BarsPerPlane = 50;
42 constexpr auto MaxNumberOfPlanes = 60;
44
45 constexpr bool IsPlaneHorizontal(const int plane) { return (plane % 2 == FirstHorizontalPlane); }
46 constexpr bool IsPlaneVertical(const int plane) { return !IsPlaneHorizontal(plane); }
47 constexpr int GetPlaneNumber(const int barID) { return barID / BarsPerPlane; }
48
49 // Average Parameters
50
51 constexpr auto AvgTimeResolution = 0.150; // ns
52 constexpr auto AvgEffectiveCLight = -7.95; // cm / ns
53 constexpr auto AvgGain = 15; // MeV / ns
54 constexpr auto AvgThreshold = 1.75; // MeV
55 constexpr auto AvgAttenuationLength = 400.; // cm
56} // namespace Neuland
57
58constexpr UInt_t nEvents = (1U << 16);
59
61{
62 TRandom3 rnd(0);
63
64 const double tdiff = rnd.Uniform(-1000., 1000.);
65 const double veff = rnd.Gaus(Neuland::AvgEffectiveCLight, 0.2);
66 const double invveff = 1. / veff;
67 const std::array<double, 2> gain = { rnd.Gaus(Neuland::AvgGain, 0.2), rnd.Gaus(Neuland::AvgGain, 0.2) };
68 const double attlen = rnd.Gaus(Neuland::AvgAttenuationLength, 25.);
69 const double invattlen = 1. / attlen;
70
72
73 for (auto event = 0; event < nEvents; ++event)
74 {
75 const auto position = rnd.Uniform(-0.5 * Neuland::BarLength, 0.5 * Neuland::BarLength);
76 const std::array<double, 2> distance = { 0.5 * Neuland::TotalBarLength + position,
77 0.5 * Neuland::TotalBarLength - position };
78 const std::array<double, 2> time = { distance[0] * 0.5 * fabs(invveff) + tdiff * 0.5,
79 distance[1] * 0.5 * fabs(invveff) - tdiff * 0.5 };
80
81 const auto eloss = rnd.Uniform(1., 20.);
82 const std::array<double, 2> eatpmt = { eloss * std::exp(-invattlen * distance[0]),
83 eloss * std::exp(-invattlen * distance[1]) };
84
85 const auto pos = rnd.Gaus(position, 1.);
86 const std::array<double, 2> tdc = { rnd.Gaus(time[0], 0.05), rnd.Gaus(time[1], 0.05) };
87 const std::array<double, 2> qdc = { gain[0] * eatpmt[0] / (1. + Neuland::AvgSaturationConstant * eatpmt[0]),
88 gain[1] * eatpmt[1] / (1. + Neuland::AvgSaturationConstant * eatpmt[1]) };
89 const auto energy = rnd.Gaus(eloss, eloss * 0.05);
90
91 if (energy <= 0.)
92 continue;
93
94 for (auto side = 0; side < 2; ++side)
95 bar->Set(side, tdc[side], qdc[side]);
96
97 bar->Add(0., pos, pos, energy);
98 }
99
100 bar->Calibrate();
101
102 const auto pars = bar->GetParameters();
103 std::cout << endl << pars.GetTimeOffset(2) - pars.GetTimeOffset(1) << " " << tdiff << std::endl;
104 std::cout << pars.GetEffectiveSpeed() << " " << veff << std::endl;
105 std::cout << pars.GetEnergyGain(1) << " " << gain[0] << std::endl;
106 std::cout << pars.GetEnergyGain(2) << " " << gain[1] << std::endl;
107 std::cout << pars.GetLightAttenuationLength() << " " << attlen << std::endl;
108
109 if (fabs(pars.GetTimeOffset(2) - pars.GetTimeOffset(1) - tdiff) < 0.01 &&
110 fabs(pars.GetEffectiveSpeed() - veff) < 0.1 && fabs(pars.GetEnergyGain(1) - gain[0]) < 0.1 &&
111 fabs(pars.GetEnergyGain(2) - gain[1]) < 0.01 && fabs(pars.GetLightAttenuationLength() - attlen) < 25)
112 {
113 std::cout << "SUCCESS" << std::endl;
114 }
115 else
116 {
117 std::cout << "FAILED" << std::endl;
118 }
119}
Simulation of NeuLAND Bar/Paddle.
constexpr auto __sqrt12
constexpr auto BarsPerPlane
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 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
void testNeulandBar()