Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 09:35:01

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