Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-27 07:23:59

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 // Detray include(s)
0012 #include "detray/definitions/algebra.hpp"
0013 #include "detray/material/material.hpp"
0014 #include "detray/utils/ratio.hpp"
0015 
0016 // System include(s)
0017 #include <tuple>
0018 
0019 namespace detray {
0020 
0021 /// Compile-time material mixture type. The summation of ratios should be equal
0022 /// to one
0023 template <concepts::scalar scalar_t, typename... material_types>
0024 struct mixture
0025     : public material<scalar_t, typename ratio_sum<
0026                                     typename material_types::ratio...>::ratio> {
0027  public:
0028   using ratio = typename ratio_sum<typename material_types::ratio...>::ratio;
0029 
0030   static_assert(is_ratio_one_v<ratio>,
0031                 "Sumation of ratios should be equal to 1");
0032 
0033   /// Constructor
0034   constexpr mixture() {
0035     // Compute effective relative atomic mass
0036     // Zeff = Ar0 * ratio0 + Ar1 * ratio1 + ...
0037     auto sum_Ar = [](material_types... M) constexpr -> decltype(auto) {
0038       return ((M.Ar() * M.fraction()) + ...);
0039     };
0040 
0041     this->set_Ar(std::apply(sum_Ar, std::tuple<material_types...>()));
0042 
0043     // Compute effective atomic number
0044     // Zeff = Z0 * ratio0 + Z1 * ratio1 + ...
0045     auto sum_Z = [](material_types... M) constexpr -> decltype(auto) {
0046       return ((M.Z() * M.fraction()) + ...);
0047     };
0048 
0049     this->set_Z(std::apply(sum_Z, std::tuple<material_types...>()));
0050 
0051     // Get averaged mass density
0052     auto sum_rho = [](material_types... M) constexpr -> decltype(auto) {
0053       return ((M.mass_density() * M.fraction()) + ...);
0054     };
0055 
0056     this->set_mass_density(
0057         std::apply(sum_rho, std::tuple<material_types...>()));
0058 
0059     // Compute effective radiation length (X0)
0060     // reference:
0061     // https://cds.cern.ch/record/1279627/files/PH-EP-Tech-Note-2010-013.pdf
0062     // X_avg = W_avg / Sum_i[ W_i / X_i ],
0063     // where:
0064     // W_i is mass density of i_th component
0065     // W_avg is the averaged mass density
0066     auto sum_rho_over_X0 = [](material_types... M) constexpr -> decltype(auto) {
0067       return ((M.fraction() / M.X0()) + ...);
0068     };
0069     this->set_X0(1.f /
0070                  std::apply(sum_rho_over_X0, std::tuple<material_types...>()));
0071 
0072     // Compute effective nuclear radiation length
0073     // Follow the same equation of effective X0
0074     auto sum_rho_over_L0 = [](material_types... M) constexpr -> decltype(auto) {
0075       return ((M.fraction() / M.L0()) + ...);
0076     };
0077 
0078     this->set_L0(1.f /
0079                  std::apply(sum_rho_over_L0, std::tuple<material_types...>()));
0080 
0081     // Compute molar density
0082     this->set_molar_density(
0083         this->mass_to_molar_density(this->Ar(), this->mass_density()));
0084 
0085     // @TODO: Calculate density effect data as well if exist?
0086   }
0087 };
0088 
0089 }  // namespace detray