R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BNeulandCommon.h
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#pragma once
15#include "R3BValueError.h"
16#include <R3BMinMaxValue.h>
17#include <cassert>
18#include <limits>
19
20namespace R3B::Neuland
21{
22 // Constants
23
24 constexpr auto SQRT_12 = 3.464101615;
25 constexpr auto NaN = std::numeric_limits<double>::quiet_NaN();
26 constexpr auto Inf = std::numeric_limits<double>::infinity();
27
28 // Useful functions I do not want to redefine in every file
29
30 template <typename T>
31 constexpr auto Sqr(const T val) -> T
32 {
33 return val * val;
34 }
35
36 // Initialize variables from Birk' s Law
37 constexpr double BirkdP = 1.032;
38 constexpr double BirkC1 = 0.013 / BirkdP;
39 constexpr double BirkC2 = 9.6e-6 / (BirkdP * BirkdP);
40
41 constexpr auto GetLightYieldAfterBirk(const int charge, const double length_mm, const double edep_MeV) -> double
42 {
43 constexpr auto MAGIC_NUM_0 = 7.2;
44 constexpr auto MAGIC_NUM_1 = 12.6;
45 return (charge * length_mm == 0.
46 ? edep_MeV
47 : edep_MeV /
48 (1. + BirkC1 * (Sqr(charge) > 1 ? MAGIC_NUM_0 / MAGIC_NUM_1 : 1.) * (edep_MeV / length_mm) +
49 BirkC2 * Sqr(edep_MeV / length_mm)));
50 }
51
52 // Physical Constants
53
54 constexpr auto CLight = 29.9792458; // Speed of light [cm/ns]
55 constexpr auto CLight2 = 898.75517873681758374898; // Speed of light [cm/ns]
56 constexpr auto InvCLight = 1. / CLight; // Speed of light [cm/ns]>
57 constexpr auto MUON_MASS = 0.105; // Muonmass [GeV]
58
59 // Electronics Constants
60
61 constexpr auto COARSE_TIME_CLOCK_FREQUENCY_MHZ = 200.F;
62 constexpr auto MaxCalTime = 5. * 2048;
63 constexpr auto MaxFTValue = 4097;
64 constexpr auto MAXCTValue = 2048U;
65 // Geometry & Material Constants
66
67 constexpr auto BarSize_XY = 5.0; // cm NeuLAND parameter
68 constexpr auto BarUncertainty_XY = BarSize_XY / SQRT_12; // cm NeuLAND parameter
69 constexpr auto BarSize_Z = 5.0; // cm NeuLAND parameter
70 constexpr auto BarUncertainty_Z = BarSize_Z / SQRT_12; // cm NeuLAND parameter
71 constexpr auto BarLength = 250.0; // cm NeuLAND parameter
72 constexpr auto LightGuideLength = 10.0; // cm NeuLAND parameter
73 constexpr auto TotalBarLength =
74 BarLength + (2 * LightGuideLength); // cm NeuLAND parameter, Bar including Light Guide
75
76 constexpr auto ScintillatorDensity = 1.032; // g / cm^3
77 constexpr auto MIPStoppingPowerPerDensity = 1.956; // MeV cm^2 / g
78 constexpr auto MIPStoppingPower = 1.73; // MeV / cm
79
80 constexpr auto FirstHorizontalPlane = 0;
81 constexpr auto BarsPerPlane = 50;
82 constexpr auto MaxNumberOfPlanes = 26;
83 constexpr auto DefaultNumberOfPlanes = 26;
85
86 // naming convention:
87 // _num starts at 1 and _id starts at 0
88 // module number has the range of 1 ~ BarsPerPlane * NumOfPlanes
89 // bar number has the range of 1 ~ BarsPerPlane
90 constexpr auto GetBarVerticalDisplacement(int module_num) -> double
91 {
92 const auto bar_num = ((module_num - 1) % BarsPerPlane) + 1;
93 return (2 * bar_num - 1 - BarsPerPlane) / 2. * BarSize_XY;
94 }
95 constexpr auto IsPlaneIDHorizontal(int plane_id) -> bool { return (plane_id % 2 == FirstHorizontalPlane); }
96 constexpr auto IsPlaneIDVertical(int plane_id) -> bool { return !IsPlaneIDHorizontal(plane_id); }
97 constexpr auto ModuleID2PlaneID(int moduleID) -> int { return moduleID / BarsPerPlane; }
98 constexpr auto ModuleID2PlaneNum(int moduleID) -> int { return ModuleID2PlaneID(moduleID) + 1; }
99 constexpr auto IsModuleNumHorizontal(int module_num) -> bool
100 {
101 return IsPlaneIDHorizontal(ModuleID2PlaneID(module_num - 1));
102 }
103 // planeNum, barNum and ModuleNum is 1-based
104 constexpr auto Neuland_PlaneBar2ModuleNum(int planeNum, int barNum) -> int
105 {
106 assert(planeNum > 0);
107 return ((planeNum - 1) * BarsPerPlane) + barNum;
108 }
109 template <typename T = double>
110 constexpr auto PlaneID2ZPos(int plane_id) -> T
111 {
112 return static_cast<T>((plane_id + 0.5) * BarSize_Z);
113 }
114 template <typename T = double>
115 constexpr auto ModuleNum2ZPos(int module_num) -> T
116 {
117 return PlaneID2ZPos<T>(ModuleID2PlaneID(module_num - 1));
118 }
119
120 // Average Parameters
121
122 constexpr auto AvgTimeResolution = 0.150; // ns
123 constexpr auto AvgEffectiveCLight = -7.95; // cm / ns
124 constexpr auto AvgGain = 15; // MeV / ns
125 constexpr auto AvgThreshold = 1.75; // MeV
126 constexpr auto AvgAttenuationLength = 400.; // cm
127
128 constexpr auto SaturationCoefficient = 1.75e-3; // 1 / ns
129
130 // NeuLAND TPAT:
131 constexpr auto NeulandOnSpillTpatPos = 0U; // 0 based
132 namespace Calibration
133 {
136 constexpr auto DEFAULT_TSYNC_MAX_TIME_DIFF = 300; // ns
137 // Millepede calibration defaults:
138 constexpr auto DEFAULT_MINIMUM_PLANE_NUM = 10;
139 constexpr auto DEFAULT_MAX_SLOPE_VALUE = 10;
140 constexpr auto DEFAULT_EFFECTIVE_C = 8.; // cm/ns
141 constexpr auto DEFAULT_CALIBRATION_P_VALUE_CUT = 1e-10; // any smaller values will be discarded
142 constexpr auto DEFAULT_T_DIFF_RESIDUAL_CUT = 400; // any larger values will be discarded
143
144 } // namespace Calibration
145
146 // Default values:
147 constexpr auto DEFAULT_BOX_GENERATOR_THETA = MinMaxValueD{ 0., 3. }; // degree
148 constexpr auto DEFAULT_BOX_GENERATOR_PHI = MinMaxValueD{ 0., 360. }; // degree
149 constexpr auto DEFAULT_GENERATOR_ENERGY = ValueErrorD{ 1., 0.2 }; // [GeV]
150} // namespace R3B::Neuland
constexpr auto DEFAULT_MINIMUM_PLANE_NUM
constexpr auto DEFAULT_TSYNC_MAX_TIME_DIFF
constexpr auto DEFAULT_CALIBRATION_P_VALUE_CUT
constexpr auto DEFAULT_TSYNC_REFERENCE_BAR_VALUE
constexpr auto DEFAULT_TSYNC_REFERENCE_BAR_NUM
constexpr auto DEFAULT_MAX_SLOPE_VALUE
constexpr auto DEFAULT_T_DIFF_RESIDUAL_CUT
Simulation of NeuLAND Bar/Paddle.
constexpr auto COARSE_TIME_CLOCK_FREQUENCY_MHZ
constexpr auto BarsPerPlane
constexpr auto ModuleID2PlaneID(int moduleID) -> int
constexpr auto AvgTimeResolution
constexpr auto NeulandOnSpillTpatPos
constexpr auto BarUncertainty_Z
constexpr auto Neuland_PlaneBar2ModuleNum(int planeNum, int barNum) -> int
constexpr auto GetBarVerticalDisplacement(int module_num) -> double
constexpr auto SQRT_12
constexpr auto ModuleID2PlaneNum(int moduleID) -> int
constexpr auto InvCLight
constexpr auto SaturationCoefficient
constexpr double BirkC1
constexpr auto MaxNumberOfBars
constexpr auto BarLength
constexpr double BirkdP
constexpr auto BarSize_Z
constexpr auto MIPStoppingPower
constexpr auto AvgEffectiveCLight
constexpr auto CLight
constexpr auto GetLightYieldAfterBirk(const int charge, const double length_mm, const double edep_MeV) -> double
constexpr auto IsModuleNumHorizontal(int module_num) -> bool
constexpr auto BarSize_XY
constexpr auto FirstHorizontalPlane
constexpr auto TotalBarLength
constexpr auto NaN
constexpr auto ModuleNum2ZPos(int module_num) -> T
constexpr auto AvgAttenuationLength
constexpr auto AvgThreshold
constexpr auto DEFAULT_BOX_GENERATOR_THETA
constexpr auto BarUncertainty_XY
constexpr auto DEFAULT_GENERATOR_ENERGY
constexpr auto CLight2
constexpr double BirkC2
constexpr auto MUON_MASS
constexpr auto MaxFTValue
constexpr auto MAXCTValue
constexpr auto IsPlaneIDHorizontal(int plane_id) -> bool
constexpr auto LightGuideLength
constexpr auto DEFAULT_BOX_GENERATOR_PHI
ValueError< double > ValueErrorD
constexpr auto MaxNumberOfPlanes
constexpr auto IsPlaneIDVertical(int plane_id) -> bool
constexpr auto AvgGain
constexpr auto MIPStoppingPowerPerDensity
constexpr auto MaxCalTime
constexpr auto PlaneID2ZPos(int plane_id) -> T
constexpr auto DefaultNumberOfPlanes
constexpr auto Inf
constexpr auto Sqr(const T val) -> T
constexpr auto ScintillatorDensity
MinMaxValue< double > MinMaxValueD