ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tracking
TrkDetDescr
TrkGeometry
src
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
9
#include "
TrkGeometry/BinnedLayerMaterial.h
"
10
11
#include "
TrkGeometry/MaterialProperties.h
"
12
13
#include "GaudiKernel/MsgStream.h"
14
15
16
Trk::BinnedLayerMaterial::BinnedLayerMaterial
()
17
:
Trk
::
LayerMaterialProperties
(),
m_binUtility
(nullptr) {}
18
19
Trk::BinnedLayerMaterial::BinnedLayerMaterial
(
Trk::BinUtility
& binutility)
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
26
Trk::MaterialPropertiesVector
matVec;
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
35
Trk::BinnedLayerMaterial::BinnedLayerMaterial
(
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
41
clearMaterial
();
42
// fill the material with deep copy
43
m_fullMaterial
.push_back(fullProperties);
44
}
45
46
Trk::BinnedLayerMaterial::BinnedLayerMaterial
(
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
53
Trk::BinnedLayerMaterial::~BinnedLayerMaterial
() {
54
delete
m_binUtility
;
55
clearMaterial
();
56
}
57
58
Trk::BinnedLayerMaterial::BinnedLayerMaterial
(
59
const
Trk::BinnedLayerMaterial
& lmp)
60
:
Trk
::
LayerMaterialProperties
(lmp),
61
m_binUtility
(lmp.
m_binUtility
->
clone
()) {
62
// clear the material
63
clearMaterial
();
64
// and fill the material
65
fillMaterial
(lmp.
m_fullMaterial
);
66
}
67
68
Trk::BinnedLayerMaterial
&
Trk::BinnedLayerMaterial::operator=
(
69
const
Trk::BinnedLayerMaterial
& lmp) {
70
if
(
this
!= &lmp) {
71
Trk::LayerMaterialProperties::operator=
(lmp);
72
// first delete everything
73
delete
m_binUtility
;
74
// reassign
75
m_binUtility
= lmp.
binUtility
()->
clone
();
76
clearMaterial
();
77
// reassign the material
78
fillMaterial
(lmp.
m_fullMaterial
);
79
}
80
return
(*
this
);
81
}
82
83
Trk::BinnedLayerMaterial
&
84
Trk::BinnedLayerMaterial::operator=
(
Trk::BinnedLayerMaterial
&& lmp)
noexcept
{
85
if
(
this
!= &lmp) {
86
87
// first delete everything
88
delete
m_binUtility
;
89
clearMaterial
();
90
m_binUtility
= std::exchange(lmp.m_binUtility,
nullptr
);
91
// reassign the material
92
m_fullMaterial
= std::move(lmp.m_fullMaterial);
93
Trk::LayerMaterialProperties::operator=
(std::move(lmp));
94
}
95
return
(*
this
);
96
}
97
98
Trk::BinnedLayerMaterial
*
Trk::BinnedLayerMaterial::clone
()
const
{
99
return
new
Trk::BinnedLayerMaterial
(*
this
);
100
}
101
102
void
Trk::BinnedLayerMaterial::clearMaterial
() {
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
111
void
Trk::BinnedLayerMaterial::fillMaterial
(
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
116
Trk::MaterialPropertiesVector
matVector;
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
125
Trk::BinnedLayerMaterial
&
Trk::BinnedLayerMaterial::operator*=
(
double
scale) {
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
145
const
Trk::MaterialProperties
*
Trk::BinnedLayerMaterial::fullMaterial
(
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
154
MsgStream&
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
177
std::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
}
BinnedLayerMaterial.h
MaterialProperties.h
Trk::BinUtility
A generic symmetric BinUtility, for fully symmetric binning in terms of binning grid and binning type...
Definition
BinUtility.h:39
Trk::BinUtility::max
size_t max(size_t ba=0) const
First bin maximal value.
Definition
BinUtility.h:210
Trk::BinUtility::clone
BinUtility * clone() const
Implicit Constructor.
Definition
BinUtility.h:120
Trk::BinnedLayerMaterial
It extends the LayerMaterialProperties base class.
Definition
BinnedLayerMaterial.h:34
Trk::BinnedLayerMaterial::operator=
BinnedLayerMaterial & operator=(const BinnedLayerMaterial &lmp)
Assignment operator.
Definition
BinnedLayerMaterial.cxx:68
Trk::BinnedLayerMaterial::~BinnedLayerMaterial
virtual ~BinnedLayerMaterial() override
Destructor.
Definition
BinnedLayerMaterial.cxx:53
Trk::BinnedLayerMaterial::fillMaterial
void fillMaterial(const MaterialPropertiesMatrix &matMatrix)
helper method - to refill the material
Definition
BinnedLayerMaterial.cxx:111
Trk::BinnedLayerMaterial::clone
virtual BinnedLayerMaterial * clone() const override
Pseudo-Constructor clone().
Definition
BinnedLayerMaterial.cxx:98
Trk::BinnedLayerMaterial::binUtility
virtual const BinUtility * binUtility() const override
Return the BinUtility.
Definition
BinnedLayerMaterial.h:123
Trk::BinnedLayerMaterial::clearMaterial
void clearMaterial()
helper method - to clear the material
Definition
BinnedLayerMaterial.cxx:102
Trk::BinnedLayerMaterial::m_fullMaterial
MaterialPropertiesMatrix m_fullMaterial
The five different MaterialProperties.
Definition
BinnedLayerMaterial.h:112
Trk::BinnedLayerMaterial::operator*=
virtual BinnedLayerMaterial & operator*=(double scale) override
Scale operator.
Definition
BinnedLayerMaterial.cxx:125
Trk::BinnedLayerMaterial::fullMaterial
const MaterialPropertiesMatrix & fullMaterial() const
Return method for full material description of the Layer - for all bins.
Definition
BinnedLayerMaterial.h:126
Trk::BinnedLayerMaterial::dump
virtual MsgStream & dump(MsgStream &sl) const override
Output Method for MsgStream, to be overloaded by child classes.
Definition
BinnedLayerMaterial.cxx:154
Trk::BinnedLayerMaterial::m_binUtility
BinUtility * m_binUtility
the helper for the bin finding
Definition
BinnedLayerMaterial.h:109
Trk::BinnedLayerMaterial::BinnedLayerMaterial
BinnedLayerMaterial()
Default Constructor - needed by POOL.
Definition
BinnedLayerMaterial.cxx:16
Trk::LayerMaterialProperties::LayerMaterialProperties
LayerMaterialProperties()=default
Constructor.
Trk::LayerMaterialProperties::operator=
LayerMaterialProperties & operator=(const LayerMaterialProperties &)=default
Trk::MaterialProperties
Material with information about thickness of material.
Definition
MaterialProperties.h:40
Trk::MaterialProperties::clone
MaterialProperties * clone() const
Pseudo-Constructor clone().
Definition
MaterialProperties.cxx:33
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition
GeoPrimitives.h:47
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition
FakeTrackBuilder.h:9
Trk::MaterialPropertiesVector
std::vector< const MaterialProperties * > MaterialPropertiesVector
Useful typedefs.
Definition
MaterialProperties.h:133
Trk::MaterialPropertiesMatrix
std::vector< std::vector< const MaterialProperties * > > MaterialPropertiesMatrix
Definition
ILayerMaterialAnalyser.h:25
Generated on
for ATLAS Offline Software by
1.17.0