ATLAS Offline Software
Loading...
Searching...
No Matches
BinnedLayerMaterial.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6// BinnedLayerMaterial.cxx, (c) ATLAS Detector software
8
10
12
13#include "GaudiKernel/MsgStream.h"
14
15
18
20 : Trk::LayerMaterialProperties(), m_binUtility(binutility.clone()) {
21 // reserve
22 m_fullMaterial.reserve(binutility.max(1) + 1);
23 for (unsigned int ibin2 = 0; ibin2 < (unsigned int)binutility.max(1) + 1;
24 ++ibin2) {
25 // create the vector for the push_back
27 matVec.reserve(binutility.max(0) + 1);
28 for (unsigned int ibin = 0; ibin < (unsigned int)binutility.max(0) + 1;
29 ++ibin)
30 matVec.push_back(nullptr);
31 m_fullMaterial.push_back(std::move(matVec));
32 }
33}
34
36 const Trk::BinUtility& binutility,
37 const MaterialPropertiesVector& fullProperties, double splitFactor)
38 : Trk::LayerMaterialProperties(splitFactor),
39 m_binUtility(binutility.clone()) {
40 // constructor from a single vector
42 // fill the material with deep copy
43 m_fullMaterial.push_back(fullProperties);
44}
45
47 const Trk::BinUtility& binutility,
48 const MaterialPropertiesMatrix& fullProperties, double splitFactor)
49 : Trk::LayerMaterialProperties(splitFactor),
50 m_binUtility(binutility.clone()),
51 m_fullMaterial(fullProperties) {}
52
57
59 const Trk::BinnedLayerMaterial& lmp)
62 // clear the material
64 // and fill the material
66}
67
69 const Trk::BinnedLayerMaterial& lmp) {
70 if (this != &lmp) {
72 // first delete everything
73 delete m_binUtility;
74 // reassign
75 m_binUtility = lmp.binUtility()->clone();
77 // reassign the material
79 }
80 return (*this);
81}
82
85 if (this != &lmp) {
86
87 // first delete everything
88 delete m_binUtility;
90 m_binUtility = std::exchange(lmp.m_binUtility, nullptr);
91 // reassign the material
92 m_fullMaterial = std::move(lmp.m_fullMaterial);
94 }
95 return (*this);
96}
97
101
103 // clear the full material
104 for (auto& matMatrixIter : m_fullMaterial) {
105 for (auto& matIter : matMatrixIter) delete matIter;
106 }
107
108 m_fullMaterial.clear();
109}
110
112 const Trk::MaterialPropertiesMatrix& matMatrix) {
113 m_fullMaterial.reserve(m_binUtility->max(1) + 1);
114 for (const auto& matMatrixIter : matMatrix) {
115 // the vector to be copied
117 matVector.reserve(m_binUtility->max(0) + 1);
118 // reassign
119 for (const auto& matIter : matMatrixIter)
120 matVector.push_back(matIter ? matIter->clone() : nullptr);
121 m_fullMaterial.push_back(std::move(matVector));
122 }
123}
124
126 // scale the full material
127 unsigned int imat2 = 0;
128 for (auto& matMatrixIter : m_fullMaterial) {
129 unsigned int imat1 = 0;
130 // the vector iterator
131 for (auto& matIter : matMatrixIter) {
132 if (matIter) {
133 Trk::MaterialProperties* mprop = matIter->clone();
134 (*mprop) *= scale;
135 delete matIter;
136 m_fullMaterial[imat2][imat1] = mprop;
137 }
138 ++imat1;
139 }
140 ++imat2;
141 }
142 return (*this);
143}
144
146 const Amg::Vector3D& gp) const {
147 if (m_fullMaterial.empty() || !m_binUtility) return nullptr;
148 // the first bin
149 size_t ibin1 = m_binUtility->bin(gp, 0);
150 size_t ibin2 = m_binUtility->max(1) ? m_binUtility->bin(gp, 1) : 0;
151 return m_fullMaterial[ibin2][ibin1];
152}
153
154MsgStream& Trk::BinnedLayerMaterial::dump(MsgStream& sl) const {
155 sl << "Trk::BinnedLayerMaterial : " << std::endl;
156 sl << " - Number of Material bins (1/2) : " << m_binUtility->max(0) + 1
157 << " / " << m_binUtility->max(1) + 1 << std::endl;
158 sl << " - Parse full update material : " << std::endl;
159 // output the full material
160 unsigned int imat2 = 0;
161 for (const auto& matMatrixIter : m_fullMaterial) {
162 unsigned int imat1 = 0;
163 // the vector iterator
164 for (const auto& matIter : matMatrixIter) {
165 if (matIter)
166 sl << " Bin [" << imat2 << "][" << imat1 << "] - " << (*matIter)
167 << std::endl;
168 else
169 sl << " Bin [" << imat2 << "][" << imat1 << "] - empty " << std::endl;
170 ++imat1;
171 }
172 ++imat2;
173 }
174 return sl;
175}
176
177std::ostream& Trk::BinnedLayerMaterial::dump(std::ostream& sl) const {
178 sl << "Trk::BinnedLayerMaterial : " << std::endl;
179 sl << " - Number of Material bins (1/2) : " << m_binUtility->max(0) + 1
180 << " / " << m_binUtility->max(1) + 1 << std::endl;
181 sl << " - Parse full update material : " << std::endl; //
182 // output the full material
183 unsigned int imat2 = 0;
184 for (const auto& matMatrixIter : m_fullMaterial) {
185 unsigned int imat1 = 0;
186 // the vector iterator
187 for (const auto& matIter : matMatrixIter) {
188 if (matIter)
189 sl << " Bin [" << imat2 << "][" << imat1 << "] - " << (*matIter)
190 << std::endl;
191 else
192 sl << " Bin [" << imat2 << "][" << imat1 << "] - empty " << std::endl;
193 ++imat1;
194 }
195 ++imat2;
196 }
197 return sl;
198}
A generic symmetric BinUtility, for fully symmetric binning in terms of binning grid and binning type...
Definition BinUtility.h:39
size_t max(size_t ba=0) const
First bin maximal value.
Definition BinUtility.h:210
BinUtility * clone() const
Implicit Constructor.
Definition BinUtility.h:120
It extends the LayerMaterialProperties base class.
BinnedLayerMaterial & operator=(const BinnedLayerMaterial &lmp)
Assignment operator.
virtual ~BinnedLayerMaterial() override
Destructor.
void fillMaterial(const MaterialPropertiesMatrix &matMatrix)
helper method - to refill the material
virtual BinnedLayerMaterial * clone() const override
Pseudo-Constructor clone().
virtual const BinUtility * binUtility() const override
Return the BinUtility.
void clearMaterial()
helper method - to clear the material
MaterialPropertiesMatrix m_fullMaterial
The five different MaterialProperties.
virtual BinnedLayerMaterial & operator*=(double scale) override
Scale operator.
const MaterialPropertiesMatrix & fullMaterial() const
Return method for full material description of the Layer - for all bins.
virtual MsgStream & dump(MsgStream &sl) const override
Output Method for MsgStream, to be overloaded by child classes.
BinUtility * m_binUtility
the helper for the bin finding
BinnedLayerMaterial()
Default Constructor - needed by POOL.
LayerMaterialProperties()=default
Constructor.
LayerMaterialProperties & operator=(const LayerMaterialProperties &)=default
Material with information about thickness of material.
MaterialProperties * clone() const
Pseudo-Constructor clone().
Eigen::Matrix< double, 3, 1 > Vector3D
Ensure that the ATLAS eigen extensions are properly loaded.
std::vector< const MaterialProperties * > MaterialPropertiesVector
Useful typedefs.
std::vector< std::vector< const MaterialProperties * > > MaterialPropertiesMatrix