Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BinnedSurfaceMaterial.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file BinnedSurfaceMaterial.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2016-2020 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
10 
12 
13 #include <ostream>
14 #include <utility>
15 #include <vector>
16 
18  const BinUtility& binUtility, MaterialSlabVector fullProperties,
19  double splitFactor, Acts::MappingType mappingType)
20  : ISurfaceMaterial(splitFactor, mappingType), m_binUtility(binUtility) {
21  // fill the material with deep copy
22  m_fullMaterial.push_back(std::move(fullProperties));
23 }
24 
26  const BinUtility& binUtility, MaterialSlabMatrix fullProperties,
27  double splitFactor, Acts::MappingType mappingType)
28  : ISurfaceMaterial(splitFactor, mappingType),
29  m_binUtility(binUtility),
30  m_fullMaterial(std::move(fullProperties)) {}
31 
33  double scale) {
34  for (auto& materialVector : m_fullMaterial) {
35  for (auto& materialBin : materialVector) {
36  materialBin.scaleThickness(scale);
37  }
38  }
39  return (*this);
40 }
41 
43  const Vector2& lp) const {
44  // the first bin
45  size_t ibin0 = m_binUtility.bin(lp, 0);
46  size_t ibin1 = m_binUtility.max(1) != 0u ? m_binUtility.bin(lp, 1) : 0;
47  return m_fullMaterial[ibin1][ibin0];
48 }
49 
51  const Acts::Vector3& gp) const {
52  // the first bin
53  size_t ibin0 = m_binUtility.bin(gp, 0);
54  size_t ibin1 = m_binUtility.max(1) != 0u ? m_binUtility.bin(gp, 1) : 0;
55  return m_fullMaterial[ibin1][ibin0];
56 }
57 
58 std::ostream& Acts::BinnedSurfaceMaterial::toStream(std::ostream& sl) const {
59  sl << "Acts::BinnedSurfaceMaterial : " << std::endl;
60  sl << " - Number of Material bins [0,1] : " << m_binUtility.max(0) + 1
61  << " / " << m_binUtility.max(1) + 1 << std::endl;
62  sl << " - Parse full update material : " << std::endl; //
63  // output the full material
64  unsigned int imat1 = 0;
65  for (auto& materialVector : m_fullMaterial) {
66  unsigned int imat0 = 0;
67  // the vector iterator
68  for (auto& materialBin : materialVector) {
69  sl << " Bin [" << imat1 << "][" << imat0 << "] - " << (materialBin);
70  ++imat0;
71  }
72  ++imat1;
73  }
74  sl << " - BinUtility: " << m_binUtility << std::endl;
75  return sl;
76 }