Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:24:24

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 #include "ActsPlugins/GeoModel/GeoModelMaterialConverter.hpp"
0010 
0011 #include "Acts/Material/Material.hpp"
0012 
0013 #include "GeoModelKernel/GeoMaterial.h"
0014 #include "GeoModelKernel/Units.h"
0015 namespace {
0016 constexpr double s_densityCnvFactor = 1. / GeoModelKernelUnits::gram;
0017 }
0018 
0019 using namespace Acts;
0020 
0021 Material ActsPlugins::GeoModel::geoMaterialConverter(const GeoMaterial& gm,
0022                                                      bool useMolarDensity) {
0023   double x0 = gm.getRadLength();
0024   double l0 = gm.getIntLength();
0025   double density = gm.getDensity() * s_densityCnvFactor;
0026   double A = 0.;
0027   double Z = 0.;
0028   // Get number elements
0029   int numberOfElements = gm.getNumElements();
0030   // Loop
0031   for (int iEl = 0; iEl < numberOfElements; ++iEl) {
0032     const GeoElement* geoEl = gm.getElement(iEl);
0033     double fraction = gm.getFraction(iEl);
0034     A += fraction * (geoEl->getA() / GeoModelKernelUnits::gram);
0035     Z += fraction * geoEl->getZ();
0036   }
0037   if (useMolarDensity) {
0038     return Material::fromMolarDensity(x0, l0, A, Z, density);
0039   } else {
0040     return Material::fromMassDensity(x0, l0, A, Z, density);
0041   }
0042 }