Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:25

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/Material/BinnedSurfaceMaterial.hpp"
0010 
0011 #include "Acts/Material/MaterialSlab.hpp"
0012 
0013 #include <ostream>
0014 #include <utility>
0015 #include <vector>
0016 
0017 Acts::BinnedSurfaceMaterial::BinnedSurfaceMaterial(
0018     const BinUtility& binUtility, MaterialSlabVector fullProperties,
0019     double splitFactor, Acts::MappingType mappingType)
0020     : ISurfaceMaterial(splitFactor, mappingType), m_binUtility(binUtility) {
0021   // fill the material with deep copy
0022   m_fullMaterial.push_back(std::move(fullProperties));
0023 }
0024 
0025 Acts::BinnedSurfaceMaterial::BinnedSurfaceMaterial(
0026     const BinUtility& binUtility, MaterialSlabMatrix fullProperties,
0027     double splitFactor, Acts::MappingType mappingType)
0028     : ISurfaceMaterial(splitFactor, mappingType),
0029       m_binUtility(binUtility),
0030       m_fullMaterial(std::move(fullProperties)) {}
0031 
0032 Acts::BinnedSurfaceMaterial& Acts::BinnedSurfaceMaterial::scale(double factor) {
0033   for (auto& materialVector : m_fullMaterial) {
0034     for (auto& materialBin : materialVector) {
0035       materialBin.scaleThickness(factor);
0036     }
0037   }
0038   return (*this);
0039 }
0040 
0041 const Acts::MaterialSlab& Acts::BinnedSurfaceMaterial::materialSlab(
0042     const Vector2& lp) const {
0043   // the first bin
0044   std::size_t ibin0 = m_binUtility.bin(lp, 0);
0045   std::size_t ibin1 = m_binUtility.max(1) != 0u ? m_binUtility.bin(lp, 1) : 0;
0046   return m_fullMaterial[ibin1][ibin0];
0047 }
0048 
0049 const Acts::MaterialSlab& Acts::BinnedSurfaceMaterial::materialSlab(
0050     const Acts::Vector3& gp) const {
0051   // the first bin
0052   std::size_t ibin0 = m_binUtility.bin(gp, 0);
0053   std::size_t ibin1 = m_binUtility.max(1) != 0u ? m_binUtility.bin(gp, 1) : 0;
0054   return m_fullMaterial[ibin1][ibin0];
0055 }
0056 
0057 std::ostream& Acts::BinnedSurfaceMaterial::toStream(std::ostream& sl) const {
0058   sl << "Acts::BinnedSurfaceMaterial : " << std::endl;
0059   sl << "   - Number of Material bins [0,1] : " << m_binUtility.max(0) + 1
0060      << " / " << m_binUtility.max(1) + 1 << std::endl;
0061   sl << "   - Parse full update material    : " << std::endl;  //
0062   // output  the full material
0063   unsigned int imat1 = 0;
0064   for (auto& materialVector : m_fullMaterial) {
0065     unsigned int imat0 = 0;
0066     // the vector iterator
0067     for (auto& materialBin : materialVector) {
0068       sl << " Bin [" << imat1 << "][" << imat0 << "] - " << (materialBin);
0069       ++imat0;
0070     }
0071     ++imat1;
0072   }
0073   sl << "  - BinUtility: " << m_binUtility << std::endl;
0074   return sl;
0075 }