ATLAS Offline Software
Loading...
Searching...
No Matches
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
15
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
42
53
56 if (this != &lmp) {
57 Trk::LayerMaterialProperties::operator=(lmp);
58 // first delete everything
59 delete m_binUtility;
61 // reassign the material
63 // reassign the binutility and the material bins
64 m_binUtility = lmp.binUtility()->clone();
66 }
67 return (*this);
68}
69
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
118MsgStream& 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
135std::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}
A generic symmetric BinUtility, for fully symmetric binning in terms of binning grid and binning type...
Definition BinUtility.h:39
BinUtility * clone() const
Implizit Constructor.
Definition BinUtility.h:120
It extends the LayerMaterialProperties base class.
const MaterialPropertiesVector & fullMaterial() const
Return method for full material description of the Layer - for all bins.
virtual MsgStream & dump(MsgStream &sl) const override final
Output Method for MsgStream, to be overloaded by child classes.
virtual const MaterialProperties * material(size_t bin0, size_t bin1) const override final
Access the single bin.
virtual ~CompressedLayerMaterial() override
Destructor.
CompressedLayerMaterial & operator=(const CompressedLayerMaterial &lmp)
Assignment operator.
BinUtility * m_binUtility
the helper for the bin finding
void fillMaterial(const MaterialPropertiesVector &matVector)
helper method - to refill the material
std::vector< unsigned short int > m_materialBins
virtual const BinUtility * binUtility() const override final
Return the BinUtility.
MaterialPropertiesVector m_fullMaterial
The five different MaterialProperties.
virtual CompressedLayerMaterial & operator*=(double scale) override final
Scale operator.
CompressedLayerMaterial()
Default Constructor - needed by POOL.
void clearMaterial()
helper method - to clear the material
virtual CompressedLayerMaterial * clone() const override final
Pseudo-Constructor clone()
Material with information about thickness of material.
static std::string release
Definition computils.h:50
Eigen::Matrix< double, 3, 1 > Vector3D
Ensure that the ATLAS eigen extensions are properly loaded.
std::vector< const MaterialProperties * > MaterialPropertiesVector
Useful typedefs.