Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:09:38

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2016-2020 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 http://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::operator*=(
0033     double scale) {
0034   for (auto& materialVector : m_fullMaterial) {
0035     for (auto& materialBin : materialVector) {
0036       materialBin.scaleThickness(scale);
0037     }
0038   }
0039   return (*this);
0040 }
0041 
0042 const Acts::MaterialSlab& Acts::BinnedSurfaceMaterial::materialSlab(
0043     const Vector2& lp) const {
0044   // the first bin
0045   std::size_t ibin0 = m_binUtility.bin(lp, 0);
0046   std::size_t ibin1 = m_binUtility.max(1) != 0u ? m_binUtility.bin(lp, 1) : 0;
0047   return m_fullMaterial[ibin1][ibin0];
0048 }
0049 
0050 const Acts::MaterialSlab& Acts::BinnedSurfaceMaterial::materialSlab(
0051     const Acts::Vector3& gp) const {
0052   // the first bin
0053   std::size_t ibin0 = m_binUtility.bin(gp, 0);
0054   std::size_t ibin1 = m_binUtility.max(1) != 0u ? m_binUtility.bin(gp, 1) : 0;
0055   return m_fullMaterial[ibin1][ibin0];
0056 }
0057 
0058 std::ostream& Acts::BinnedSurfaceMaterial::toStream(std::ostream& sl) const {
0059   sl << "Acts::BinnedSurfaceMaterial : " << std::endl;
0060   sl << "   - Number of Material bins [0,1] : " << m_binUtility.max(0) + 1
0061      << " / " << m_binUtility.max(1) + 1 << std::endl;
0062   sl << "   - Parse full update material    : " << std::endl;  //
0063   // output  the full material
0064   unsigned int imat1 = 0;
0065   for (auto& materialVector : m_fullMaterial) {
0066     unsigned int imat0 = 0;
0067     // the vector iterator
0068     for (auto& materialBin : materialVector) {
0069       sl << " Bin [" << imat1 << "][" << imat0 << "] - " << (materialBin);
0070       ++imat0;
0071     }
0072     ++imat1;
0073   }
0074   sl << "  - BinUtility: " << m_binUtility << std::endl;
0075   return sl;
0076 }