ATLAS Offline Software
Loading...
Searching...
No Matches
TrkDetDescrTPCnvTest.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 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
25Trk::TrkDetDescrTPCnvTest::TrkDetDescrTPCnvTest(const std::string& name, ISvcLocator* pSvcLocator) :
26 Trk::TrkDetDescrUnitTestBase(name, pSvcLocator),
27 m_writeMode(true),
28 m_materialStepCollectionName("RandomMaterialSteps"),
29 m_layerMaterialCollectionName("RandomLayerMaterialMap"),
30 m_elementTableName("RandomElementTable")
31{
32
33 declareProperty("WriteMode", m_writeMode);
34 // collection names
35 declareProperty("MaterialStepCollection", m_materialStepCollectionName);
37 declareProperty("ElementTable", m_elementTableName);
38}
39
41{
42 ATH_MSG_VERBOSE("Running the TrkDetDescrTPCnvTest Test");
43
44 // ----------------- WRITE MODE -----------------
45 if (m_writeMode){
46
47 ATH_MSG_VERBOSE("Test is running in write mode - writing out a file.");
48
49 // The Material STEP collection
51 for (size_t it = 0; it < TrkDetDescrUnitTestBase::m_numTests; ++it ){
61 }
62
63
64 ATH_MSG_VERBOSE("Recording MaterialStepCollection '" << m_materialStepCollectionName << "'.");
65
66 if (!m_materialStepCollectionName.empty() && (evtStore()->record(msCollection, m_materialStepCollectionName)).isFailure() ) {
67 ATH_MSG_WARNING("Could not record the material collection " << m_materialStepCollectionName);
68 return StatusCode::FAILURE;
69 }
70
71 ATH_MSG_VERBOSE("Recording LayerMaterialMap '" << m_layerMaterialCollectionName << "'.");
72
73 // The LayerMaterialMap
74 std::unique_ptr<Trk::LayerMaterialMap> lmMap(new Trk::LayerMaterialMap);
75
76 // (e) element Table
81 1,
82 TrkDetDescrUnitTestBase::m_flatDist->shoot()),"TestMaterial1");
86 2,
87 TrkDetDescrUnitTestBase::m_flatDist->shoot()),"TestMaterial2");
91 3,
92 TrkDetDescrUnitTestBase::m_flatDist->shoot()),"TestMaterial3");
93
94 if ( !m_elementTableName.empty() && (evtStore()->record(eTable, m_elementTableName)).isFailure() ) {
95 ATH_MSG_WARNING("Could not record the element table " << m_elementTableName);
96 return StatusCode::FAILURE;
97 }
98
99 // (a) homogeneous material
107 (*lmMap)[Trk::LayerIndex(1)] = hml;
108
109 // (b) binned material
110 Trk::BinUtility rPhiZUtility(200,-M_PI, M_PI, Trk::closed, Trk::binRPhi);
111 rPhiZUtility += Trk::BinUtility(300,-250.,250., Trk::open, Trk::binZ);
112 std::vector< std::vector< const Trk::MaterialProperties* > > materialMatrix(300, std::vector<const Trk::MaterialProperties*>(200, (Trk::MaterialProperties*)nullptr) );
113 for (size_t iob = 0; iob < 300; ++iob)
114 for (size_t iib = 0; iib < 200; ++iib)
115 materialMatrix[iob][iib] = new Trk::MaterialProperties(TrkDetDescrUnitTestBase::m_flatDist->shoot(),
121 (*lmMap)[Trk::LayerIndex(2)] = new Trk::BinnedLayerMaterial(rPhiZUtility, materialMatrix, TrkDetDescrUnitTestBase::m_flatDist->shoot()) ;
122
123 // (c) compressed material
124 Trk::BinUtility zUtility(200,-100,100, Trk::open, Trk::binZ);
125
126 std::vector< const Trk::MaterialProperties*> materialVector;
127 std::vector< unsigned short int > materialIndices;
128 materialVector.reserve(200);
129 materialIndices.reserve(200);
130 for (size_t iib = 0; iib < 200; ++iib){
131 materialIndices.push_back(int(TrkDetDescrUnitTestBase::m_flatDist->shoot()*200));
132 materialVector.push_back(new Trk::MaterialProperties(TrkDetDescrUnitTestBase::m_flatDist->shoot(),
138
139 }
140 (*lmMap)[Trk::LayerIndex(3)] = new Trk::CompressedLayerMaterial(zUtility, materialVector, materialIndices);
141
142 // (d) compound material
143 Trk::BinUtility zUtilityC(200,-100,100, Trk::open, Trk::binZ);
144
145
146 Trk::ValueMatrix thicknessMatrix;
147 Trk::ValueMatrix x0Matrix;
148 Trk::ValueMatrix l0Matrix;
149 Trk::ValueMatrix aMatrix;
150 Trk::ValueMatrix zMatrix;
151 Trk::ValueMatrix rhoMatrix;
152 thicknessMatrix.reserve(25);
153 x0Matrix.reserve(25);
154 l0Matrix.reserve(25);
155 aMatrix.reserve(25);
156 zMatrix.reserve(25);
157 rhoMatrix.reserve(25);
158
159 std::vector< std::vector< Trk::MaterialComposition > > materialCompositionMatrix;
160
161 for (size_t iob = 0; iob < 200; ++iob){
162 // the vectors
163 std::vector<unsigned char> thicknessVector; thicknessVector.reserve(25);
164 std::vector<unsigned char> x0Vector; x0Vector.reserve(25);
165 std::vector<unsigned char> l0Vector; l0Vector.reserve(25);
166 std::vector<unsigned char> aVector; aVector.reserve(25);
167 std::vector<unsigned char> zVector; zVector.reserve(25);
168 std::vector<unsigned char> rhoVector; rhoVector.reserve(25);
169 std::vector< Trk::MaterialComposition > materialCompositionVector;
170 materialCompositionVector.reserve(25);
171 for (size_t iib = 0; iib < 25; ++iib){
172 x0Vector.push_back((unsigned char)(TrkDetDescrUnitTestBase::m_flatDist->shoot()*UCHAR_MAX));
173 l0Vector.push_back((unsigned char)(TrkDetDescrUnitTestBase::m_flatDist->shoot()*UCHAR_MAX));
174 aVector.push_back((unsigned char)(TrkDetDescrUnitTestBase::m_flatDist->shoot()*UCHAR_MAX));
175 zVector.push_back((unsigned char)(TrkDetDescrUnitTestBase::m_flatDist->shoot()*UCHAR_MAX));
176 rhoVector.push_back((unsigned char)(TrkDetDescrUnitTestBase::m_flatDist->shoot()*UCHAR_MAX));
177 std::vector< Trk::ElementFraction > elements;
178 elements.reserve(5);
179 for (size_t iic = 0; iic < 5; ++iic){
180 elements.emplace_back((unsigned char)(TrkDetDescrUnitTestBase::m_flatDist->shoot()*UCHAR_MAX),
181 (unsigned char)(TrkDetDescrUnitTestBase::m_flatDist->shoot()*UCHAR_MAX));
182 }
183 materialCompositionVector.emplace_back(elements);
184 }
185 thicknessMatrix.push_back(thicknessVector);
186 x0Matrix.push_back(x0Vector);
187 l0Matrix.push_back(l0Vector);
188 aMatrix.push_back(aVector);
189 zMatrix.push_back(zVector);
190 rhoMatrix.push_back(rhoVector);
191 materialCompositionMatrix.push_back(materialCompositionVector);
192 }
193
194 Trk::ValueStore thicknessBins;
195 thicknessBins.valueMin = 0.;
196 thicknessBins.valueStep = TrkDetDescrUnitTestBase::m_flatDist->shoot();
197 thicknessBins.valueBinMatrix = thicknessMatrix;
198
199 Trk::ValueStore x0Bins;
200 x0Bins.valueMin = 0.;
202 x0Bins.valueBinMatrix = x0Matrix;
203
204
205 Trk::ValueStore l0Bins;
206 l0Bins.valueMin = 0.;
208 l0Bins.valueBinMatrix = l0Matrix;
209
210 Trk::ValueStore aBins;
211 aBins.valueMin = 0.;
213 aBins.valueBinMatrix = aMatrix;
214
215 Trk::ValueStore zBins;
216 zBins.valueMin = 0.;
217 zBins.valueStep = TrkDetDescrUnitTestBase::m_flatDist->shoot();
218 zBins.valueBinMatrix = zMatrix;
219
220 Trk::ValueStore rhoBins;
221 rhoBins.valueMin = 0.;
223 rhoBins.valueBinMatrix = rhoMatrix;
224
225 (*lmMap)[Trk::LayerIndex(3)] = new Trk::CompoundLayerMaterial(zUtilityC,
226 thicknessBins,
227 x0Bins,
228 l0Bins,
229 aBins,
230 zBins,
231 rhoBins,
232 materialCompositionMatrix);
233
234 auto sharedElementTable = std::make_shared<Trk::ElementTable>(*eTable);
235 lmMap->updateElementTable(sharedElementTable);
236
237 if ( (evtStore()->record(lmMap.release(), m_layerMaterialCollectionName)).isFailure() ) {
238 ATH_MSG_WARNING("Could not record the material collection " << m_layerMaterialCollectionName);
239 return StatusCode::FAILURE;
240 }
241 } else {
242 //
243 ATH_MSG_VERBOSE("Test is running in READ mode, reading in a file.");
244
245 // ----------------- READ MODE -----------------
246 const Trk::LayerMaterialMap* lmMap = nullptr;
247 if ( (evtStore()->retrieve(lmMap, m_layerMaterialCollectionName)).isFailure() ) {
248 ATH_MSG_WARNING("Could not read the material collection " << m_layerMaterialCollectionName);
249 return StatusCode::FAILURE;
250 } else
251 ATH_MSG_INFO("Successfully read a LayerMaterialMap with size " << lmMap->size());
252
253 }
254
255 return StatusCode::SUCCESS;
256}
#define M_PI
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
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
TrkDetDescrTPCnvTest(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
TrkDetDescrUnitTestBase(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
Ensure that the ATLAS eigen extensions are properly loaded.
@ 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