15#include "G4Element.hh"
16#include "G4Material.hh"
17#include "G4PAIxSection.hh"
18#include "G4SandiaTable.hh"
19#include "G4SystemOfUnits.hh"
20#include "G4Version.hh"
35static void table(
const Gas& gas,
double cut)
37 const double dco = 0.00186;
39 auto* el =
new G4Element(gas.
name, gas.
name, gas.
z, gas.
a *
g / mole);
40 auto*
c =
new G4Element(
"C_" + gas.
name,
"C", 6., 12.0107 *
g / mole);
41 auto* o =
new G4Element(
"O_" + gas.
name,
"O", 8., 15.9994 *
g / mole);
42 const double w[3] = {gas.
nNoble * gas.
a, gas.
nC * 12.0107, gas.
nO * 15.9994};
43 const double ws =
w[0] +
w[1] +
w[2];
44 auto* mat =
new G4Material(
"TRD_" + gas.
name +
"CO2", dens, 3, kStateGas, 293.15 * kelvin);
45 mat->AddElement(el,
w[0] / ws);
46 mat->AddElement(
c,
w[1] / ws);
47 mat->AddElement(o,
w[2] / ws);
49 std::vector<double> lbgs;
53 std::vector<double> egrid;
54 std::vector<std::vector<double>> ccdf;
55 std::vector<double> nsub,
dedx;
56 for (
double lbg : lbgs) {
57 const double bg = std::pow(10., lbg);
59 sandia.Initialize(mat);
61 xs.Initialize(mat, 1. * MeV, bg * bg, &sandia);
62 const int n = xs.GetSplineSize();
63 std::vector<double> en(
n), in(
n),
de(
n);
64 for (
int i = 1;
i <=
n; ++
i) {
65 en[
i - 1] = xs.GetSplineEnergy(
i);
66 in[
i - 1] = xs.GetIntegralPAIxSection(
i);
67 de[
i - 1] = xs.GetIntegralPAIdEdx(
i);
69 auto interp = [&](
const std::vector<double>&
v,
double e) {
70 if (
e <= en.front()) {
73 for (
int i = 1;
i <
n; ++
i) {
75 const double t = std::log(
e / en[
i - 1]) / std::log(en[
i] / en[
i - 1]);
76 return v[
i - 1] +
t * (
v[
i] -
v[
i - 1]);
82 egrid.push_back(en[0] / eV);
83 for (
int j = 0;
j <= 30; ++
j) {
84 const double e = std::pow(10., 1. + 0.1 *
j);
85 if (
e > en[0] / eV * 1.001) {
90 const double ns = (in[0] - interp(in, cut)) * 10.;
92 dedx.push_back((
de[0] - interp(
de, cut)) * 10. / eV);
93 std::vector<double>
row;
94 for (
double e : egrid) {
95 row.push_back(std::max((interp(in,
e * eV) - interp(in, cut)) * 10. / ns, 0.));
101 std::printf(
"// %s/CO2: density %.6g g/cm3, mean excitation energy %.4g eV\n", gas.
name.c_str(), dens / (
g / cm3),
102 mat->GetIonisation()->GetMeanExcitationEnergy() / eV);
103 std::printf(
"constexpr double k%sEnergy[%zu] = {", gas.
name.c_str(), egrid.size());
104 for (
size_t j = 0;
j < egrid.size(); ++
j) {
105 std::printf(
"%s%.5g",
j ?
", " :
"", egrid[
j]);
107 std::printf(
"};\nconstexpr double k%sCollisionsPerCm[%zu] = {", gas.
name.c_str(), nsub.size());
108 for (
size_t k = 0; k < nsub.size(); ++k) {
109 std::printf(
"%s%.6g", k ?
", " :
"", nsub[k]);
111 std::printf(
"};\nconstexpr double k%sRestrictedDEdx[%zu] = {", gas.
name.c_str(),
dedx.size());
112 for (
size_t k = 0; k <
dedx.size(); ++k) {
113 std::printf(
"%s%.6g", k ?
", " :
"",
dedx[k]);
115 std::printf(
"};\nconstexpr float k%sFractionAbove[%zu][%zu] = {\n", gas.
name.c_str(), ccdf.size(), egrid.size());
116 for (
auto&
row : ccdf) {
118 for (
size_t j = 0;
j <
row.size(); ++
j) {
119 std::printf(
"%s%.5g",
j ?
", " :
"",
row[
j]);
128 const double cut = 10. * keV;
129 std::printf(
"// Generated with Geant4 %d G4PAIxSection, delta-ray cut %.4g keV\n", G4VERSION_NUMBER, cut / keV);
130 std::printf(
"constexpr double kDeltaRayCut = %.6g; // eV\n", cut / eV);
131 std::printf(
"constexpr int kNBetaGamma = %d;\n",
kNBetaGamma);
132 std::printf(
"constexpr double kLogBetaGammaMin = %.6g; // beta*gamma of row k is 10^(min + k * step)\n",
kLogBetaGammaMin);
134 table({
"Xe", 54., 131.29, 8.5, 1.5, 3.0, 0.85, 0.00549}, cut);
135 table({
"Ar", 18., 39.948, 8.2, 1.8, 3.6, 0.82, 0.00166}, cut);
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char e
GLubyte GLubyte GLubyte GLubyte w
constexpr double kLogBetaGammaStep
constexpr int kNBetaGamma
constexpr double kLogBetaGammaMin