Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-23 07:35:55

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