ATLAS Offline Software
Loading...
Searching...
No Matches
BinnedLayerMaterial.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
6// BinnedLayerMaterial.cxx, (c) ATLAS Detector software
8
10
12
15
17 : Trk::LayerMaterialProperties(), m_binUtility(binutility.clone()) {
18 // reserve
19 m_fullMaterial.reserve(binutility.max(1) + 1);
20 for (unsigned int ibin2 = 0; ibin2 < (unsigned int)binutility.max(1) + 1;
21 ++ibin2) {
22 // create the vector for the push_back
24 matVec.reserve(binutility.max(0) + 1);
25 for (unsigned int ibin = 0; ibin < (unsigned int)binutility.max(0) + 1;
26 ++ibin)
27 matVec.push_back(nullptr);
28 m_fullMaterial.push_back(matVec);
29 }
30}
31
33 const Trk::BinUtility& binutility,
34 const MaterialPropertiesVector& fullProperties, double splitFactor)
35 : Trk::LayerMaterialProperties(splitFactor),
36 m_binUtility(binutility.clone()) {
37 // constructor from a single vector
39 // fill the material with deep copy
40 m_fullMaterial.push_back(fullProperties);
41}
42
44 const Trk::BinUtility& binutility,
45 const MaterialPropertiesMatrix& fullProperties, double splitFactor)
46 : Trk::LayerMaterialProperties(splitFactor),
47 m_binUtility(binutility.clone()),
48 m_fullMaterial(fullProperties) {}
49
54
56 const Trk::BinnedLayerMaterial& lmp)
59 // clear the material
61 // and fill the material
63}
64
66 const Trk::BinnedLayerMaterial& lmp) {
67 if (this != &lmp) {
68 Trk::LayerMaterialProperties::operator=(lmp);
69 // first delete everything
70 delete m_binUtility;
71 // reassign
72 m_binUtility = lmp.binUtility()->clone();
74 // reassign teh material
76 }
77 return (*this);
78}
79
83
85 // clear the full material
86 for (auto& matMatrixIter : m_fullMaterial) {
87 for (auto& matIter : matMatrixIter) delete matIter;
88 }
89
90 m_fullMaterial.clear();
91}
92
94 const Trk::MaterialPropertiesMatrix& matMatrix) {
95 m_fullMaterial.reserve(m_binUtility->max(1) + 1);
96 for (const auto& matMatrixIter : matMatrix) {
97 // the vector to be copied
99 matVector.reserve(m_binUtility->max(0) + 1);
100 // reassign
101 for (const auto& matIter : matMatrixIter)
102 matVector.push_back(matIter ? matIter->clone() : nullptr);
103 m_fullMaterial.push_back(matVector);
104 }
105}
106
108 // scale the full material
109 unsigned int imat2 = 0;
110 for (auto& matMatrixIter : m_fullMaterial) {
111 unsigned int imat1 = 0;
112 // the vector iterator
113 for (auto& matIter : matMatrixIter) {
114 if (matIter) {
115 Trk::MaterialProperties* mprop = matIter->clone();
116 (*mprop) *= scale;
117 delete matIter;
118 m_fullMaterial[imat2][imat1] = mprop;
119 }
120 ++imat1;
121 }
122 ++imat2;
123 }
124 return (*this);
125}
126
128 const Amg::Vector3D& gp) const {
129 if (m_fullMaterial.empty() || !m_binUtility) return nullptr;
130 // the first bin
131 size_t ibin1 = m_binUtility->bin(gp, 0);
132 size_t ibin2 = m_binUtility->max(1) ? m_binUtility->bin(gp, 1) : 0;
133 return m_fullMaterial[ibin2][ibin1];
134}
135
136MsgStream& Trk::BinnedLayerMaterial::dump(MsgStream& sl) const {
137 sl << "Trk::BinnedLayerMaterial : " << std::endl;
138 sl << " - Number of Material bins (1/2) : " << m_binUtility->max(0) + 1
139 << " / " << m_binUtility->max(1) + 1 << std::endl;
140 sl << " - Parse full update material : " << std::endl;
141 // output the full material
142 unsigned int imat2 = 0;
143 for (const auto& matMatrixIter : m_fullMaterial) {
144 unsigned int imat1 = 0;
145 // the vector iterator
146 for (const auto& matIter : matMatrixIter) {
147 if (matIter)
148 sl << " Bin [" << imat2 << "][" << imat1 << "] - " << (*matIter)
149 << std::endl;
150 else
151 sl << " Bin [" << imat2 << "][" << imat1 << "] - empty " << std::endl;
152 ++imat1;
153 }
154 ++imat2;
155 }
156 return sl;
157}
158
159std::ostream& Trk::BinnedLayerMaterial::dump(std::ostream& sl) const {
160 sl << "Trk::BinnedLayerMaterial : " << std::endl;
161 sl << " - Number of Material bins (1/2) : " << m_binUtility->max(0) + 1
162 << " / " << m_binUtility->max(1) + 1 << std::endl;
163 sl << " - Parse full update material : " << std::endl; //
164 // output the full material
165 unsigned int imat2 = 0;
166 for (const auto& matMatrixIter : m_fullMaterial) {
167 unsigned int imat1 = 0;
168 // the vector iterator
169 for (const auto& matIter : matMatrixIter) {
170 if (matIter)
171 sl << " Bin [" << imat2 << "][" << imat1 << "] - " << (*matIter)
172 << std::endl;
173 else
174 sl << " Bin [" << imat2 << "][" << imat1 << "] - empty " << std::endl;
175 ++imat1;
176 }
177 ++imat2;
178 }
179 return sl;
180}
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:212
BinUtility * clone() const
Implizit 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.
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