ATLAS Offline Software
CompressedLayerMaterial.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 // CompressedLayerMaterial.cxx, (c) ATLAS Detector software
8 
10 
12 
14  : Trk::LayerMaterialProperties(), m_binUtility(nullptr) {}
15 
17  Trk::BinUtility& binutility)
18  : Trk::LayerMaterialProperties(), m_binUtility(binutility.clone()) {}
19 
21  const Trk::BinUtility& binutility,
22  const MaterialPropertiesVector& fullProperties,
23  const std::vector<unsigned short int>& materialIndices, double splitFactor)
24  : Trk::LayerMaterialProperties(splitFactor),
25  m_binUtility(binutility.clone()),
26  m_fullMaterial(fullProperties),
27  m_materialBins(materialIndices) {}
28 
30  std::unique_ptr<Trk::BinUtility> binutility,
31  const MaterialPropertiesVector&& fullProperties,
32  const std::vector<unsigned short int>& materialIndices, double splitFactor)
33  : Trk::LayerMaterialProperties(splitFactor),
34  m_binUtility(binutility.release()),
35  m_fullMaterial(fullProperties),
36  m_materialBins(materialIndices) {}
37 
39  delete m_binUtility;
40  clearMaterial();
41 }
42 
46  m_binUtility(lmp.m_binUtility->clone()),
47  m_materialBins(lmp.m_materialBins) {
48  // clear the material
49  clearMaterial();
50  // and fill the material
52 }
53 
55  const Trk::CompressedLayerMaterial& lmp) {
56  if (this != &lmp) {
57  Trk::LayerMaterialProperties::operator=(lmp);
58  // first delete everything
59  delete m_binUtility;
60  clearMaterial();
61  // reassign the material
62  fillMaterial(lmp.m_fullMaterial);
63  // reassign the binutility and the material bins
64  m_binUtility = lmp.binUtility()->clone();
65  m_materialBins = lmp.m_materialBins;
66  }
67  return (*this);
68 }
69 
71  return new Trk::CompressedLayerMaterial(*this);
72 }
73 
75  // loop over the matrix
76  for (auto& matIter : m_fullMaterial) delete matIter;
77  m_fullMaterial.clear();
78 }
79 
81  const Trk::MaterialPropertiesVector& matVector) {
82  // reassign
83  m_fullMaterial.clear();
84  m_fullMaterial.reserve(matVector.size());
85  for (const auto& matIter : matVector)
86  m_fullMaterial.push_back(matIter ? matIter->clone() : nullptr);
87 }
88 
90  double scale) {
91  size_t imat1 = 0;
92  // the vector iterator
93  for (auto& matIter : m_fullMaterial) {
94  if (matIter) {
95  // clone needed for const correctness
96  Trk::MaterialProperties* mprop = (matIter)->clone();
97  (*mprop) *= scale;
98  delete matIter;
99  m_fullMaterial[imat1] = mprop;
100  }
101  }
102 
103  // scale the reference material
104  return (*this);
105 }
106 
108  const Amg::Vector3D& gp) const {
109  if (m_fullMaterial.empty() || !m_binUtility) return nullptr;
110  // first bin
111  size_t ibin1 = m_binUtility->bin(gp, 0);
112  // second bin
113  size_t ibin2 = (m_binUtility->max(1) == 0) ? 0 : m_binUtility->bin(gp, 1);
114  // out of bounds check and return
115  return (ibin2 > m_binUtility->max(1)) ? nullptr : material(ibin1, ibin2);
116 }
117 
118 MsgStream& Trk::CompressedLayerMaterial::dump(MsgStream& sl) const {
119  sl << "Trk::CompressedLayerMaterial : " << std::endl;
120  sl << " - Number of Material bins (1/2) : " << m_binUtility->max(0) + 1
121  << " / " << m_binUtility->max(1) + 1 << std::endl;
122  sl << " - Parse full update material : " << std::endl;
123  // -------------------------
124  size_t imat1 = 0;
125  for (const auto& matIter : m_fullMaterial) {
126  if (matIter)
127  sl << " Bin [" << imat1 << "] - " << matIter << std::endl;
128  else
129  sl << " Bin [" << imat1 << "] - empty " << std::endl;
130  ++imat1;
131  }
132  return sl;
133 }
134 
135 std::ostream& Trk::CompressedLayerMaterial::dump(std::ostream& sl) const {
136  sl << "Trk::CompressedLayerMaterial : " << std::endl;
137  sl << " - Number of Material bins (1/2) : " << m_binUtility->max(0) + 1
138  << " / " << m_binUtility->max(1) + 1 << std::endl;
139  sl << " - Parse full update material : " << std::endl; //
140  size_t imat1 = 0;
141  for (const auto& matIter : m_fullMaterial) {
142  if (matIter)
143  sl << " Bin [" << imat1 << "] - " << matIter << std::endl;
144  else
145  sl << " Bin [" << imat1 << "] - empty " << std::endl;
146  ++imat1;
147  }
148  return sl;
149 }
Trk::CompressedLayerMaterial::operator*=
virtual CompressedLayerMaterial & operator*=(double scale) override final
Scale operator.
Definition: CompressedLayerMaterial.cxx:89
Trk::CompressedLayerMaterial::operator=
CompressedLayerMaterial & operator=(const CompressedLayerMaterial &lmp)
Assignment operator.
Definition: CompressedLayerMaterial.cxx:54
MaterialProperties.h
Trk::CompressedLayerMaterial::m_fullMaterial
MaterialPropertiesVector m_fullMaterial
The five different MaterialProperties.
Definition: CompressedLayerMaterial.h:106
Trk::CompressedLayerMaterial::fullMaterial
const MaterialPropertiesVector & fullMaterial() const
Return method for full material description of the Layer - for all bins.
Definition: CompressedLayerMaterial.h:120
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
Trk::CompressedLayerMaterial::~CompressedLayerMaterial
virtual ~CompressedLayerMaterial() override
Destructor.
Definition: CompressedLayerMaterial.cxx:38
python.Utilities.clone
clone
Definition: Utilities.py:134
Trk::MaterialPropertiesVector
std::vector< const MaterialProperties * > MaterialPropertiesVector
Useful typedefs.
Definition: MaterialProperties.h:133
Trk::CompressedLayerMaterial::dump
virtual MsgStream & dump(MsgStream &sl) const override final
Output Method for MsgStream, to be overloaded by child classes.
Definition: CompressedLayerMaterial.cxx:118
Trk::CompressedLayerMaterial
Definition: CompressedLayerMaterial.h:31
Trk::LayerMaterialProperties
Definition: LayerMaterialProperties.h:62
Trk::CompressedLayerMaterial::CompressedLayerMaterial
CompressedLayerMaterial()
Default Constructor - needed by POOL.
Definition: CompressedLayerMaterial.cxx:13
Trk::CompressedLayerMaterial::binUtility
virtual const BinUtility * binUtility() const override final
Return the BinUtility.
Definition: CompressedLayerMaterial.h:116
Trk::BinUtility
Definition: BinUtility.h:39
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Trk::CompressedLayerMaterial::clearMaterial
void clearMaterial()
helper method - to clear the material
Definition: CompressedLayerMaterial.cxx:74
python.EventInfoMgtInit.release
release
Definition: EventInfoMgtInit.py:24
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Trk::CompressedLayerMaterial::m_materialBins
std::vector< unsigned short int > m_materialBins
Definition: CompressedLayerMaterial.h:107
Trk::MaterialProperties
Definition: MaterialProperties.h:40
Trk::CompressedLayerMaterial::clone
virtual CompressedLayerMaterial * clone() const override final
Pseudo-Constructor clone()
Definition: CompressedLayerMaterial.cxx:70
Trk::BinUtility::clone
BinUtility * clone() const
Implizit Constructor.
Definition: BinUtility.h:130
Trk::CompressedLayerMaterial::fillMaterial
void fillMaterial(const MaterialPropertiesVector &matVector)
helper method - to refill the material
Definition: CompressedLayerMaterial.cxx:80
CompressedLayerMaterial.h