File indexing completed on 2025-06-30 07:52:11
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Material/detail/AverageMaterials.hpp"
0010
0011 #include "Acts/Material/Material.hpp"
0012
0013 #include <cmath>
0014
0015 Acts::MaterialSlab Acts::detail::combineSlabs(const MaterialSlab& slab1,
0016 const MaterialSlab& slab2) {
0017 const auto& mat1 = slab1.material();
0018 const auto& mat2 = slab2.material();
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 const double thickness1 = static_cast<double>(slab1.thickness());
0033 const double thickness2 = static_cast<double>(slab2.thickness());
0034
0035 if (thickness1 == 0) {
0036 return slab2;
0037 }
0038 if (thickness2 == 0) {
0039 return slab1;
0040 }
0041
0042
0043 const double thickness = thickness1 + thickness2;
0044
0045
0046
0047 if (mat1 == mat2) {
0048 return {mat1, static_cast<float>(thickness)};
0049 }
0050
0051
0052 const double molarDensity1 = static_cast<double>(mat1.molarDensity());
0053 const double molarDensity2 = static_cast<double>(mat2.molarDensity());
0054
0055 const double molarAmount1 = molarDensity1 * thickness1;
0056 const double molarAmount2 = molarDensity2 * thickness2;
0057 const double molarAmount = molarAmount1 + molarAmount2;
0058
0059
0060 if (!(0.0 < molarAmount)) {
0061 return {Material::Vacuum(), static_cast<float>(thickness)};
0062 }
0063
0064
0065 const double thicknessX01 = static_cast<double>(slab1.thicknessInX0());
0066 const double thicknessX02 = static_cast<double>(slab2.thicknessInX0());
0067 const double thicknessL01 = static_cast<double>(slab1.thicknessInL0());
0068 const double thicknessL02 = static_cast<double>(slab2.thicknessInL0());
0069
0070 const double thicknessInX0 = thicknessX01 + thicknessX02;
0071 const double thicknessInL0 = thicknessL01 + thicknessL02;
0072
0073 const float x0 = static_cast<float>(thickness / thicknessInX0);
0074 const float l0 = static_cast<float>(thickness / thicknessInL0);
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093 const double ar1 = static_cast<double>(mat1.Ar());
0094 const double ar2 = static_cast<double>(mat2.Ar());
0095
0096 const double molarWeight1 = molarAmount1 / molarAmount;
0097 const double molarWeight2 = molarAmount2 / molarAmount;
0098 const float ar = static_cast<float>(molarWeight1 * ar1 + molarWeight2 * ar2);
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113 const double z1 = static_cast<double>(mat1.Z());
0114 const double z2 = static_cast<double>(mat2.Z());
0115
0116 const double thicknessWeight1 = thickness1 / thickness;
0117 const double thicknessWeight2 = thickness2 / thickness;
0118 float z = 0.f;
0119 if (z1 > 0. && z2 > 0.) {
0120 z = static_cast<float>(std::exp(thicknessWeight1 * std::log(z1) +
0121 thicknessWeight2 * std::log(z2)));
0122 } else {
0123 z = static_cast<float>(thicknessWeight1 * z1 + thicknessWeight2 * z2);
0124 }
0125
0126
0127
0128 const float molarDensity = static_cast<float>(molarAmount / thickness);
0129
0130 const double molarElectronAmount1 = mat1.molarElectronDensity() * thickness1;
0131 const double molarElectronAmount2 = mat2.molarElectronDensity() * thickness2;
0132 const double molarElectronAmount =
0133 molarElectronAmount1 + molarElectronAmount2;
0134 const float molarElectronDensity =
0135 static_cast<float>(molarElectronAmount / thickness);
0136
0137 float meanExcitationEnergy = 0.f;
0138 if (mat1.meanExcitationEnergy() > 0 && mat2.meanExcitationEnergy() > 0) {
0139 meanExcitationEnergy = static_cast<float>(
0140 std::exp(thicknessWeight1 * std::log(mat1.meanExcitationEnergy())) *
0141 std::exp(thicknessWeight2 * std::log(mat2.meanExcitationEnergy())));
0142 } else {
0143 meanExcitationEnergy =
0144 static_cast<float>(thicknessWeight1 * mat1.meanExcitationEnergy() +
0145 thicknessWeight2 * mat2.meanExcitationEnergy());
0146 }
0147
0148 return {
0149 Material::fromMolarDensity(x0, l0, ar, z, molarDensity,
0150 molarElectronDensity, meanExcitationEnergy),
0151 static_cast<float>(thickness)};
0152 }