ATLAS Offline Software
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 
14  : Trk::LayerMaterialProperties(), m_binUtility(nullptr) {}
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
38  clearMaterial();
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 
51  delete m_binUtility;
52  clearMaterial();
53 }
54 
56  const Trk::BinnedLayerMaterial& lmp)
58  m_binUtility(lmp.m_binUtility->clone()) {
59  // clear the material
60  clearMaterial();
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();
73  clearMaterial();
74  // reassign teh material
75  fillMaterial(lmp.m_fullMaterial);
76  }
77  return (*this);
78 }
79 
81  return new Trk::BinnedLayerMaterial(*this);
82 }
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 
136 MsgStream& 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 
159 std::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 }
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
MaterialProperties.h
Trk::BinUtility::max
size_t max(size_t ba=0) const
First bin maximal value.
Definition: BinUtility.h:215
Trk::BinnedLayerMaterial::fillMaterial
void fillMaterial(const MaterialPropertiesMatrix &matMatrix)
helper method - to refill the material
Definition: BinnedLayerMaterial.cxx:93
Trk::BinnedLayerMaterial::clone
virtual BinnedLayerMaterial * clone() const override
Pseudo-Constructor clone()
Definition: BinnedLayerMaterial.cxx:80
Trk::BinnedLayerMaterial::operator=
BinnedLayerMaterial & operator=(const BinnedLayerMaterial &lmp)
Assignment operator.
Definition: BinnedLayerMaterial.cxx:65
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
python.Utilities.clone
clone
Definition: Utilities.py:134
Trk::MaterialPropertiesVector
std::vector< const MaterialProperties * > MaterialPropertiesVector
Useful typedefs.
Definition: MaterialProperties.h:133
Trk::BinnedLayerMaterial::BinnedLayerMaterial
BinnedLayerMaterial()
Default Constructor - needed by POOL.
Definition: BinnedLayerMaterial.cxx:13
Trk::BinnedLayerMaterial::dump
virtual MsgStream & dump(MsgStream &sl) const override
Output Method for MsgStream, to be overloaded by child classes.
Definition: BinnedLayerMaterial.cxx:136
Trk::LayerMaterialProperties
Definition: LayerMaterialProperties.h:62
Trk::MaterialProperties::clone
MaterialProperties * clone() const
Pseudo-Constructor clone()
Definition: MaterialProperties.cxx:33
BinnedLayerMaterial.h
Trk::BinnedLayerMaterial
Definition: BinnedLayerMaterial.h:33
Trk::BinnedLayerMaterial::m_fullMaterial
MaterialPropertiesMatrix m_fullMaterial
The five different MaterialProperties.
Definition: BinnedLayerMaterial.h:110
Trk::BinUtility
Definition: BinUtility.h:39
Trk::BinnedLayerMaterial::fullMaterial
const MaterialPropertiesMatrix & fullMaterial() const
Return method for full material description of the Layer - for all bins.
Definition: BinnedLayerMaterial.h:124
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Trk::BinnedLayerMaterial::clearMaterial
void clearMaterial()
helper method - to clear the material
Definition: BinnedLayerMaterial.cxx:84
Trk::MaterialPropertiesMatrix
std::vector< std::vector< const MaterialProperties * > > MaterialPropertiesMatrix
Definition: ILayerMaterialAnalyser.h:23
Trk::BinnedLayerMaterial::binUtility
virtual const BinUtility * binUtility() const override
Return the BinUtility.
Definition: BinnedLayerMaterial.h:121
Trk::MaterialProperties
Definition: MaterialProperties.h:40
Trk::BinnedLayerMaterial::~BinnedLayerMaterial
virtual ~BinnedLayerMaterial() override
Destructor.
Definition: BinnedLayerMaterial.cxx:50
Trk::BinUtility::clone
BinUtility * clone() const
Implizit Constructor.
Definition: BinUtility.h:130
Trk::BinnedLayerMaterial::operator*=
virtual BinnedLayerMaterial & operator*=(double scale) override
Scale operator.
Definition: BinnedLayerMaterial.cxx:107