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 // Usefull 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 // Millepede calibration defaults:
37 constexpr auto DEFAULT_EFFECTIVE_C = 8.; // cm/ns
38 constexpr auto DEFAULT_CALIBRATION_P_VALUE_CUT = 1e-10; // any smaller values will be discarded
39 constexpr auto DEFAULT_T_DIFF_RESIDUAL_CUT = 400; // any larger values will be discarded
40
41 // Initialize variables from Birk' s Law
42
43 constexpr double BirkdP = 1.032;
44 constexpr double BirkC1 = 0.013 / BirkdP;
45 constexpr double BirkC2 = 9.6e-6 / (BirkdP * BirkdP);
46
47 constexpr auto GetLightYieldAfterBirk(const int charge, const double length_mm, const double edep_MeV) -> double
48 {
49 constexpr auto MAGIC_NUM_0 = 7.2;
50 constexpr auto MAGIC_NUM_1 = 12.6;
51 return (charge * length_mm == 0.
52 ? edep_MeV
53 : edep_MeV /
54 (1. + BirkC1 * (Sqr(charge) > 1 ? MAGIC_NUM_0 / MAGIC_NUM_1 : 1.) * (edep_MeV / length_mm) +
55 BirkC2 * Sqr(edep_MeV / length_mm)));
56 }
57
58 // Physical Constants
59
60 constexpr auto CLight = 29.9792458; // Speed of light [cm/ns]
61 constexpr auto CLight2 = 898.75517873681758374898; // Speed of light [cm/ns]
62 constexpr auto InvCLight = 1. / CLight; // Speed of light [cm/ns]>
63 constexpr auto MUON_MASS = 0.105; // Muonmass [GeV]
64
65 // Electronics Constans
66
67 constexpr auto COARSE_TIME_CLOCK_FREQUENCY_MHZ = 200.F;
68 constexpr auto MaxCalTime = 5. * 2048;
69 constexpr auto MaxFTValue = 4097;
70 constexpr auto MAXCTValue = 2048U;
71 // Geometry & Material Constants
72
73 constexpr auto BarSize_XY = 5.0; // cm NeuLAND parameter
74 constexpr auto BarUncertainty_XY = BarSize_XY / SQRT_12; // cm NeuLAND parameter
75 constexpr auto BarSize_Z = 5.0; // cm NeuLAND parameter
76 constexpr auto BarUncertainty_Z = BarSize_Z / SQRT_12; // cm NeuLAND parameter
77 constexpr auto BarLength = 250.0; // cm NeuLAND parameter
78 constexpr auto LightGuideLength = 10.0; // cm NeuLAND parameter
79 constexpr auto TotalBarLength =
80 BarLength + (2 * LightGuideLength); // cm NeuLAND parameter, Bar including Light Guide
81
82 constexpr auto ScintillatorDensity = 1.032; // g / cm^3
83 constexpr auto MIPStoppingPowerPerDensity = 1.956; // MeV cm^2 / g
84 constexpr auto MIPStoppingPower = 1.73; // MeV / cm
85
86 constexpr auto FirstHorizontalPlane = 0;
87 constexpr auto BarsPerPlane = 50;
88 constexpr auto MaxNumberOfPlanes = 26;
90
91 // naming convention:
92 // _num starts at 1 and _id starts at 0
93 // module number has the range of 1 ~ BarsPerPlane * NumOfPlanes
94 // bar number has the range of 1 ~ BarsPerPlane
95 constexpr auto GetBarVerticalDisplacement(int module_num) -> double
96 {
97 const auto bar_num = module_num % BarsPerPlane;
98 return (2 * bar_num - 1 - BarsPerPlane) / 2. * BarSize_XY;
99 }
100 constexpr auto IsPlaneIDHorizontal(int plane_id) -> bool { return (plane_id % 2 == FirstHorizontalPlane); }
101 constexpr auto IsPlaneIDVertical(int plane_id) -> bool { return !IsPlaneIDHorizontal(plane_id); }
102 constexpr auto ModuleID2PlaneID(int moduleID) -> int { return moduleID / BarsPerPlane; }
103 constexpr auto ModuleID2PlaneNum(int moduleID) -> int { return ModuleID2PlaneID(moduleID) + 1; }
104 // planeNum, barNum and ModuleNum is 1-based
105 constexpr auto Neuland_PlaneBar2ModuleNum(unsigned int planeNum, unsigned int barNum) -> unsigned int
106 {
107 assert(planeNum > 0);
108 return ((planeNum - 1) * BarsPerPlane) + barNum;
109 }
110 template <typename T = double>
111 constexpr auto PlaneID2ZPos(int plane_id) -> T
112 {
113 return static_cast<T>((plane_id + 0.5) * BarSize_Z);
114 }
115 template <typename T = double>
116 constexpr auto ModuleNum2ZPos(int module_num) -> T
117 {
118 return PlaneID2ZPos<T>(ModuleID2PlaneID(module_num - 1));
119 }
120
121 // Average Parameters
122
123 constexpr auto AvgTimeResolution = 0.150; // ns
124 constexpr auto AvgEffectiveCLight = -7.95; // cm / ns
125 constexpr auto AvgGain = 15; // MeV / ns
126 constexpr auto AvgThreshold = 1.75; // MeV
127 constexpr auto AvgAttenuationLength = 400.; // cm
128
129 constexpr auto SaturationCoefficient = 1.75e-3; // 1 / ns
130
131 // NeuLAND TPAT:
132 constexpr auto NeulandOnSpillTpatPos = 0U; // 0 based
133
134 // Default values:
135 constexpr auto DEFAULT_BOX_GENERATOR_THETA = MinMaxValueD{ 0., 3. }; // degree
136 constexpr auto DEFAULT_BOX_GENERATOR_PHI = MinMaxValueD{ 0., 360. }; // degree
137 constexpr auto DEFAULT_GENERATOR_ENERGY = ValueErrorD{ 1., 0.2 }; // [GeV]
138} // namespace R3B::Neuland
Simulation of NeuLAND Bar/Paddle.
constexpr auto COARSE_TIME_CLOCK_FREQUENCY_MHZ
constexpr auto BarsPerPlane
constexpr auto DEFAULT_T_DIFF_RESIDUAL_CUT
constexpr auto ModuleID2PlaneID(int moduleID) -> int
constexpr auto AvgTimeResolution
constexpr auto NeulandOnSpillTpatPos
constexpr auto BarUncertainty_Z
constexpr auto GetBarVerticalDisplacement(int module_num) -> double
constexpr auto Neuland_PlaneBar2ModuleNum(unsigned int planeNum, unsigned int barNum) -> unsigned int
constexpr auto SQRT_12
constexpr auto ModuleID2PlaneNum(int moduleID) -> int
constexpr auto DEFAULT_CALIBRATION_P_VALUE_CUT
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 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
constexpr auto MaxNumberOfPlanes
constexpr auto IsPlaneIDVertical(int plane_id) -> bool
constexpr auto AvgGain
constexpr auto MIPStoppingPowerPerDensity
constexpr auto MaxCalTime
constexpr auto DEFAULT_EFFECTIVE_C
constexpr auto PlaneID2ZPos(int plane_id) -> T
constexpr auto Inf
constexpr auto Sqr(const T val) -> T
constexpr auto ScintillatorDensity
MinMaxValue< double > MinMaxValueD
ValueError< double > ValueErrorD