ATLAS Offline Software
Loading...
Searching...
No Matches
TrkDetDescrTPCnvTest.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// TrkDetDescrTPCnvTest.cxx, (c) ATLAS Detector software
8
9// Trk includes
11// general Trk & TrkGeometry includes
22#include <climits>
23#include <memory>
24
25
27{
28 ATH_MSG_VERBOSE("Running the TrkDetDescrTPCnvTest Test");
29
30 // ----------------- WRITE MODE -----------------
31 if (m_writeMode){
32
33 ATH_MSG_VERBOSE("Test is running in write mode - writing out a file.");
34
35 // The Material STEP collection
37 for (size_t it = 0; it < TrkDetDescrUnitTestBase::m_numTests; ++it ){
47 }
48
49
50 ATH_MSG_VERBOSE("Recording MaterialStepCollection '" << m_materialStepCollectionName << "'.");
51
52 if (!m_materialStepCollectionName.empty() && (evtStore()->record(msCollection, m_materialStepCollectionName)).isFailure() ) {
53 ATH_MSG_WARNING("Could not record the material collection " << m_materialStepCollectionName);
54 return StatusCode::FAILURE;
55 }
56
57 ATH_MSG_VERBOSE("Recording LayerMaterialMap '" << m_layerMaterialCollectionName << "'.");
58
59 // The LayerMaterialMap
60 std::unique_ptr<Trk::LayerMaterialMap> lmMap(new Trk::LayerMaterialMap);
61
62 // (e) element Table
67 1,
68 TrkDetDescrUnitTestBase::m_flatDist->shoot()),"TestMaterial1");
72 2,
73 TrkDetDescrUnitTestBase::m_flatDist->shoot()),"TestMaterial2");
77 3,
78 TrkDetDescrUnitTestBase::m_flatDist->shoot()),"TestMaterial3");
79
80 if ( !m_elementTableName.empty() && (evtStore()->record(eTable, m_elementTableName)).isFailure() ) {
81 ATH_MSG_WARNING("Could not record the element table " << m_elementTableName);
82 return StatusCode::FAILURE;
83 }
84
85 // (a) homogeneous material
93 (*lmMap)[Trk::LayerIndex(1)] = hml;
94
95 // (b) binned material
96 Trk::BinUtility rPhiZUtility(200,-M_PI, M_PI, Trk::closed, Trk::binRPhi);
97 rPhiZUtility += Trk::BinUtility(300,-250.,250., Trk::open, Trk::binZ);
98 std::vector< std::vector< const Trk::MaterialProperties* > > materialMatrix(300, std::vector<const Trk::MaterialProperties*>(200, (Trk::MaterialProperties*)nullptr) );
99 for (size_t iob = 0; iob < 300; ++iob)
100 for (size_t iib = 0; iib < 200; ++iib)
101 materialMatrix[iob][iib] = new Trk::MaterialProperties(TrkDetDescrUnitTestBase::m_flatDist->shoot(),
107 (*lmMap)[Trk::LayerIndex(2)] = new Trk::BinnedLayerMaterial(rPhiZUtility, materialMatrix, TrkDetDescrUnitTestBase::m_flatDist->shoot()) ;
108
109 // (c) compressed material
110 Trk::BinUtility zUtility(200,-100,100, Trk::open, Trk::binZ);
111
112 std::vector< const Trk::MaterialProperties*> materialVector;
113 std::vector< unsigned short int > materialIndices;
114 materialVector.reserve(200);
115 materialIndices.reserve(200);
116 for (size_t iib = 0; iib < 200; ++iib){
117 materialIndices.push_back(int(TrkDetDescrUnitTestBase::m_flatDist->shoot()*200));
118 materialVector.push_back(new Trk::MaterialProperties(TrkDetDescrUnitTestBase::m_flatDist->shoot(),
124
125 }
126 (*lmMap)[Trk::LayerIndex(3)] = new Trk::CompressedLayerMaterial(zUtility, materialVector, materialIndices);
127
128 // (d) compound material
129 Trk::BinUtility zUtilityC(200,-100,100, Trk::open, Trk::binZ);
130
131
132 Trk::ValueMatrix thicknessMatrix;
133 Trk::ValueMatrix x0Matrix;
134 Trk::ValueMatrix l0Matrix;
135 Trk::ValueMatrix aMatrix;
136 Trk::ValueMatrix zMatrix;
137 Trk::ValueMatrix rhoMatrix;
138 thicknessMatrix.reserve(25);
139 x0Matrix.reserve(25);
140 l0Matrix.reserve(25);
141 aMatrix.reserve(25);
142 zMatrix.reserve(25);
143 rhoMatrix.reserve(25);
144
145 std::vector< std::vector< Trk::MaterialComposition > > materialCompositionMatrix;
146
147 for (size_t iob = 0; iob < 200; ++iob){
148 // the vectors
149 std::vector<unsigned char> thicknessVector; thicknessVector.reserve(25);
150 std::vector<unsigned char> x0Vector; x0Vector.reserve(25);
151 std::vector<unsigned char> l0Vector; l0Vector.reserve(25);
152 std::vector<unsigned char> aVector; aVector.reserve(25);
153 std::vector<unsigned char> zVector; zVector.reserve(25);
154 std::vector<unsigned char> rhoVector; rhoVector.reserve(25);
155 std::vector< Trk::MaterialComposition > materialCompositionVector;
156 materialCompositionVector.reserve(25);
157 for (size_t iib = 0; iib < 25; ++iib){
158 x0Vector.push_back((unsigned char)(TrkDetDescrUnitTestBase::m_flatDist->shoot()*UCHAR_MAX));
159 l0Vector.push_back((unsigned char)(TrkDetDescrUnitTestBase::m_flatDist->shoot()*UCHAR_MAX));
160 aVector.push_back((unsigned char)(TrkDetDescrUnitTestBase::m_flatDist->shoot()*UCHAR_MAX));
161 zVector.push_back((unsigned char)(TrkDetDescrUnitTestBase::m_flatDist->shoot()*UCHAR_MAX));
162 rhoVector.push_back((unsigned char)(TrkDetDescrUnitTestBase::m_flatDist->shoot()*UCHAR_MAX));
163 std::vector< Trk::ElementFraction > elements;
164 elements.reserve(5);
165 for (size_t iic = 0; iic < 5; ++iic){
166 elements.emplace_back((unsigned char)(TrkDetDescrUnitTestBase::m_flatDist->shoot()*UCHAR_MAX),
167 (unsigned char)(TrkDetDescrUnitTestBase::m_flatDist->shoot()*UCHAR_MAX));
168 }
169 materialCompositionVector.emplace_back(elements);
170 }
171 thicknessMatrix.push_back(std::move(thicknessVector));
172 x0Matrix.push_back(std::move(x0Vector));
173 l0Matrix.push_back(std::move(l0Vector));
174 aMatrix.push_back(std::move(aVector));
175 zMatrix.push_back(std::move(zVector));
176 rhoMatrix.push_back(std::move(rhoVector));
177 materialCompositionMatrix.push_back(std::move(materialCompositionVector));
178 }
179
180 Trk::ValueStore thicknessBins;
181 thicknessBins.valueMin = 0.;
182 thicknessBins.valueStep = TrkDetDescrUnitTestBase::m_flatDist->shoot();
183 thicknessBins.valueBinMatrix = std::move(thicknessMatrix);
184
185 Trk::ValueStore x0Bins;
186 x0Bins.valueMin = 0.;
188 x0Bins.valueBinMatrix = std::move(x0Matrix);
189
190
191 Trk::ValueStore l0Bins;
192 l0Bins.valueMin = 0.;
194 l0Bins.valueBinMatrix = std::move(l0Matrix);
195
196 Trk::ValueStore aBins;
197 aBins.valueMin = 0.;
199 aBins.valueBinMatrix = std::move(aMatrix);
200
201 Trk::ValueStore zBins;
202 zBins.valueMin = 0.;
203 zBins.valueStep = TrkDetDescrUnitTestBase::m_flatDist->shoot();
204 zBins.valueBinMatrix = std::move(zMatrix);
205
206 Trk::ValueStore rhoBins;
207 rhoBins.valueMin = 0.;
209 rhoBins.valueBinMatrix = std::move(rhoMatrix);
210
211 (*lmMap)[Trk::LayerIndex(3)] = new Trk::CompoundLayerMaterial(zUtilityC,
212 thicknessBins,
213 x0Bins,
214 l0Bins,
215 aBins,
216 zBins,
217 rhoBins,
218 materialCompositionMatrix);
219
220 auto sharedElementTable = std::make_shared<Trk::ElementTable>(*eTable);
221 lmMap->updateElementTable(sharedElementTable);
222
223 if ( (evtStore()->record(lmMap.release(), m_layerMaterialCollectionName)).isFailure() ) {
224 ATH_MSG_WARNING("Could not record the material collection " << m_layerMaterialCollectionName);
225 return StatusCode::FAILURE;
226 }
227 } else {
228 //
229 ATH_MSG_VERBOSE("Test is running in READ mode, reading in a file.");
230
231 // ----------------- READ MODE -----------------
232 const Trk::LayerMaterialMap* lmMap = nullptr;
233 if ( (evtStore()->retrieve(lmMap, m_layerMaterialCollectionName)).isFailure() ) {
234 ATH_MSG_WARNING("Could not read the material collection " << m_layerMaterialCollectionName);
235 return StatusCode::FAILURE;
236 } else
237 ATH_MSG_INFO("Successfully read a LayerMaterialMap with size " << lmMap->size());
238
239 }
240
241 return StatusCode::SUCCESS;
242}
#define M_PI
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_INFO(x,...)
ServiceHandle< StoreGateSvc > & evtStore()
value_type push_back(value_type pElem)
Add an element to the end of the collection.
A generic symmetric BinUtility, for fully symmetric binning in terms of binning grid and binning type...
Definition BinUtility.h:39
It extends the LayerMaterialProperties base class.
It extends the LayerMaterialProperties base class, and has a intrinsic accuracy of about 0....
It extends the LayerMaterialProperties base class.
void addElement(const Material &mat, const std::string &mname="")
Add material to the Table - if the elment is already filled ignore.
It extends the LayerMaterialProperties base class.
LayerIndex for the identification of layers in a simplified detector geometry of Cylinders and Discs.
Definition LayerIndex.h:37
This class extends the DataVector<Trk::LayerMaterialProperties> by an elementTable;.
Material with information about thickness of material.
is needed for the recording of MaterialProperties from Geant4 and read them in with the mapping algor...
A common object to be contained by.
Definition Material.h:117
Gaudi::Property< std::string > m_elementTableName
Gaudi::Property< std::string > m_materialStepCollectionName
Gaudi::Property< bool > m_writeMode
Gaudi::Property< std::string > m_layerMaterialCollectionName
Gaudi::Property< size_t > m_numTests
number of tests
@ open
Definition BinningType.h:40
@ closed
Definition BinningType.h:41
std::vector< ValueVector > ValueMatrix
DataVector< Trk::MaterialStep > MaterialStepCollection
@ binRPhi
Definition BinningType.h:52
@ binZ
Definition BinningType.h:49