ATLAS Offline Software
Loading...
Searching...
No Matches
ServiceVolumeMaker.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4
5#include <utility>
6
7
8
12
14
17#include "GaudiKernel/SystemOfUnits.h"
18
19namespace InDetDD {
23
24 void
26 m_rmin = "RIN";
27 m_rmax = "ROUT";
28 m_rmin2 = "RIN2";
29 m_rmax2 = "ROUT2";
30 m_zmin = "ZIN";
31 m_zmax = "ZOUT";
32 m_zsymm = "ZSYMM";
33 m_materialName = "MATERIALNAME";
34 m_repeat = "REPEAT";
35 m_phiStart = "PHI";
36 m_phiDelta = "WIDTH";
37 m_width = "WIDTH";
38 m_shapeType = "SHAPE";
39 m_volName = "VOLNAME";
40 m_radialDiv = "";
41 m_phiStep = "";
42 m_volId = "FRAMENUM";
43 m_shiftFlag = "SHIFT";
44 }
45
46 void
48 m_rmin = "RMIN";
49 m_rmax = "RMAX";
50 m_rmin2 = "RMIN2";
51 m_rmax2 = "RMAX2";
52 m_zmin = "ZMIN";
53 m_zmax = "ZMAX";
54 m_zsymm = "ZSYMM";
55 m_materialName = "MATERIAL";
56 m_repeat = "NREPEAT";
57 m_phiStart = "PHISTART";
58 m_phiDelta = "PHIDELTA";
59 m_width = "";
60 m_shapeType = "";
61 m_volName = "NAME";
62 m_radialDiv = "RADIAL";
63 m_phiStep = "PHISTEP";
64 m_volId = "";
65 m_shiftFlag = "SHIFT";
66 }
67
68 void
70 m_rmin = "RMIN";
71 m_rmax = "RMAX";
72 m_rmin2 = "";
73 m_rmax2 = "";
74 m_zmin = "ZMIN";
75 m_zmax = "ZMAX";
76 m_zsymm = "ZSYMM";
77 m_materialName = "MATERIAL";
78 m_repeat = "";
79 m_phiStart = "";
80 m_phiDelta = "";
81 m_width = "";
82 m_shapeType = "";
83 m_volName = "NAME";
84 m_radialDiv = "";
85 m_phiStep = "";
86 m_volId = "";
87 m_shiftFlag = "SHIFT";
88 }
89
96
97 const IGeometryDBSvc*
99 return std::as_const(*m_athenaComps).geomDB();
100 }
101
102 double
104 return db()->getDouble(m_table, m_schema.rmin(), index) * Gaudi::Units::mm;
105 }
106
107 double
109 return db()->getDouble(m_table, m_schema.rmax(), index) * Gaudi::Units::mm;
110 }
111
112 double
114 return db()->getDouble(m_table, m_schema.rmin2(), index) * Gaudi::Units::mm;
115 }
116
117 double
119 return db()->getDouble(m_table, m_schema.rmax2(), index) * Gaudi::Units::mm;
120 }
121
122 double
124 return db()->getDouble(m_table, m_schema.zmin(), index) * Gaudi::Units::mm;
125 }
126
127 double
129 return db()->getDouble(m_table, m_schema.zmax(), index) * Gaudi::Units::mm;
130 }
131
132 double
134 return db()->getDouble(m_table, m_schema.phiDelta(), index) * Gaudi::Units::deg;
135 }
136
137 double
139 if (m_schema.has_width()) {
140 return db()->getDouble(m_table, m_schema.width(), index) * Gaudi::Units::mm;
141 }
142 return 0;
143 }
144
145 double
147 return db()->getDouble(m_table, m_schema.phiStart(), index) * Gaudi::Units::deg;
148 }
149
150 double
152 if (m_schema.has_phiStep()) {
153 return db()->getDouble(m_table, m_schema.phiStep(), index) * Gaudi::Units::deg;
154 }
155 return 0;
156 }
157
158 bool
160 return db()->getInt(m_table, m_schema.zsymm(), index);
161 }
162
163 int
165 return db()->getInt(m_table, m_schema.repeat(), index);
166 }
167
168 int
170 if (m_schema.has_radial()) {
171 return db()->getInt(m_table, m_schema.radialDiv(), index);
172 } else {
173 return 0;
174 }
175 }
176
177 std::string
179 if (m_schema.has_shapeType()) {
180 if (db()->testField(m_table, m_schema.shapeType(), index)) {
181 return db()->getString(m_table, m_schema.shapeType(), index);
182 } else {
183 return "TUBE";
184 }
185 }
186 return "UNKNOWN";
187 }
188
189 std::string
191 if (db()->testField(m_table, m_schema.volName(), index)) {
192 return db()->getString(m_table, m_schema.volName(), index);
193 }
194 return "";
195 }
196
197 std::string
199 return db()->getString(m_table, m_schema.materialName(), index);
200 }
201
202 unsigned int
206
207 int
209 if (m_schema.has_volId()) {
210 return db()->getInt(m_table, m_schema.volId(), index);
211 }
212 return 0;
213 }
214
215 int
217 if (m_schema.has_shiftFlag()) {
218 if (db()->testField(m_table, m_schema.shiftFlag(), index)) return db()->getInt(m_table,
219 m_schema.shiftFlag(), index);
220 }
221 return 0;
222 }
223
224 std::vector<double>
226 std::vector<double> layerShift;
227
228 IRDBAccessSvc* rdbSvc = m_athenaComps->rdbAccessSvc();
229 const IGeoDbTagSvc* geoDbTag = m_athenaComps->geoDbTagSvc();
230
231 DecodeVersionKey versionKey(geoDbTag, "Pixel");
232 const std::string& detectorKey = versionKey.tag();
233 const std::string& detectorNode = versionKey.node();
234
235 IRDBRecordset_ptr PixelBarrelGeneral = rdbSvc->getRecordsetPtr("PixelBarrelGeneral", detectorKey, detectorNode);
236 IRDBRecordset_ptr PixelLayer = rdbSvc->getRecordsetPtr("PixelLayer", detectorKey, detectorNode);
237
238 int numLayers = db()->getInt(std::move(PixelBarrelGeneral), "NLAYER");
239 layerShift.reserve(numLayers);
240 for (int iLayer = 0; iLayer < numLayers; iLayer++) {
241 double shift = 0;
242 if (db()->testField(PixelLayer, "GBLSHIFT", iLayer)) shift = db()->getDouble(PixelLayer, "GBLSHIFT", iLayer);
243 layerShift.push_back(shift);
244 }
245
246 return layerShift;
247 }
248
250 IRDBRecordset_ptr table, const ServiceVolumeSchema& schema,
251 InDetDD::AthenaComps* athenaComps)
252 : m_label(label) {
253 m_mgr = new ServiceVolumeMakerMgr(std::move(table), schema, athenaComps);
254 m_layerShift = m_mgr->readLayerShift();
255 // std::cout<<"LAYER SHIFT "<<m_layerShift[0]<<" "<<m_layerShift[1]<<" "<<m_layerShift[2]<<"
256 // "<<m_layerShift[3]<<std::endl;
257 }
258
260 for (unsigned int i = 0; i < m_services.size(); i++) {
261 delete m_services[i];
262 }
263 delete m_mgr;
264 }
265
266 const std::vector<const ServiceVolume*>&
268 for (unsigned int ii = 0; ii < numElements(); ++ii) {
269 m_services.push_back(make(ii));
270 }
271 return m_services;
272 }
273
274 unsigned int
276 return m_mgr->numElements();
277 }
278
281 //
282 // Retrieve/calculate the parameters for the volume.
283 //
284 ServiceVolume* param = new ServiceVolume;
285
286 param->setMaterial(m_mgr->materialName(ii));
287 param->setRmin(m_mgr->rmin(ii));
288 param->setRmax(m_mgr->rmax(ii));
289 param->setZmin(m_mgr->zmin(ii));
290 param->setZmax(m_mgr->zmax(ii));
291 param->setZsymm(m_mgr->zsymm(ii));
292 param->setVolName(m_mgr->volName(ii));
293
294 double zShift = 0.; // the famous IBL Z shift
295 if (m_mgr->shiftFlag(ii) > 0) zShift = m_layerShift[m_mgr->shiftFlag(ii) - 100];
296 param->setZShift(zShift);
297
298 int volId = m_mgr->volId(ii);
299 if (volId == 0) volId = ii + 1;
300
301 bool needsRotation = false;
302
303 // For TUBE there is no need to read the rest
304 std::string shapeType = m_mgr->shapeType(ii);
305 if (!m_mgr->schema().simple() && !shapeType.empty() && shapeType != "TUBE") {
306 double rmin2 = m_mgr->rmin2(ii);
307 double rmax2 = m_mgr->rmax2(ii);
308
309 if (rmin2 <= 0) rmin2 = param->rmin();
310 if (rmax2 <= 0) rmax2 = param->rmax();
311
312 int radialDiv = m_mgr->radialDiv(ii);
313
314 double phiDelta = m_mgr->phiDelta(ii);
315
316 bool fullPhiSector = false;
317 if (phiDelta == 0 || phiDelta >= 359.9 * Gaudi::Units::degree) {
318 phiDelta = 360 * Gaudi::Units::degree;
319 fullPhiSector = true;
320 }
321 //else {
322 //phiDelta -= 2*phiepsilon;
323 //phiStart += phiepsilon;
324 // }
325
326 if (shapeType == "UNKNOWN") {
327 if (radialDiv > 0) {
328 shapeType = "RADIAL";
329 } else if (param->rmin() == rmin2 && param->rmax() == rmax2) {
330 if (fullPhiSector) {
331 shapeType = "TUBE";
332 } else {
333 shapeType = "TUBS";
334 }
335 } else {
336 shapeType = "CONS";
337 }
338 }
339
340
341 int repeat = m_mgr->repeat(ii);
342 if (repeat == 0) repeat = 1;
343
344 double phiStart = m_mgr->phiStart(ii);
345 double phiWidth = phiDelta;
346
347 if (shapeType == "CONS" || shapeType == "TUBS") {
348 const double phiepsilon = 0.001 * Gaudi::Units::degree;
349 phiWidth -= 2 * phiepsilon;
350 phiStart += phiepsilon;
351 }
352
353 // Can be in degree or mm. Usually it is deg expect for BOX, TRAP and ROD shape
354 // Geometry manager makes no assumptions about units. So we must interpret here.
355 if (shapeType == "BOX" || shapeType == "ROD" || shapeType == "ROD2" || shapeType == "TRAP") {
356 phiWidth = m_mgr->width(ii); // in mm
357 }
358
359 if (shapeType == "PGON" || shapeType == "PGON2" ||
360 shapeType == "CONE" || shapeType == "CONS" ||
361 shapeType == "PGON3" || shapeType == "PGON4") {
362 if ((rmin2 != param->rmin()) || (rmax2 != param->rmax())) {
363 needsRotation = true;
364 }
365 }
366
367 int sides = 0;
368 int nCopies = 1;
369 if (shapeType == "PGON" || shapeType == "PGON2" ||
370 shapeType == "PGON3" || shapeType == "PGON4") {
371 sides = repeat;
372 } else {
373 nCopies = repeat;
374 }
375
376 // Force nCopies to 1 for TUBE and CONE
377 if (shapeType.empty() || shapeType == "TUBE" || shapeType == "CONE") {
378 nCopies = 1;
379 }
380
381 param->setShapeType(shapeType);
382 param->setRmin2(rmin2);
383 param->setRmax2(rmax2);
384 param->setPhiLoc(phiStart);
385 param->setPhiWidth(phiWidth);
386 param->setSides(sides);
387 param->setNCopies(nCopies);
388 //param->setRadialDiv(radialDiv);
389 //param->setPhiStep(phiStep);
390 }
391
392 param->setNeedsRotation(needsRotation);
393
394
395 //
396 // If zin is 0... (within 10^-5) this is a volume symmetric around
397 // the origin
398 //
399 if (std::abs(param->zmin()) < 0.000001) {
400 param->setZmin(-param->zmax());
401 param->setZsymm(false);
402 }
403
404 param->setLabel(m_label, volId);
405
406 return param;
407 }
408} // end namespace
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition of the abstract IRDBRecordset interface.
This is a helper class to query the version tags from GeoModelSvc and determine the appropriate tag a...
const std::string & tag() const
Return version tag.
const std::string & node() const
Return the version node.
Interface class to access geometry database with possibility to override parameters from a text file.
virtual std::string getString(IRDBRecordset_ptr recordSet, const std::string &name, int index=0) const =0
virtual int getInt(IRDBRecordset_ptr recordSet, const std::string &name, int index=0) const =0
virtual double getDouble(IRDBRecordset_ptr recordSet, const std::string &name, int index=0) const =0
The following methods will first look in the text file if provided and then look in the database.
virtual unsigned int getTableSize(IRDBRecordset_ptr recordSet) const =0
IRDBAccessSvc is an abstract interface to the athena service that provides the following functionalit...
virtual IRDBRecordset_ptr getRecordsetPtr(const std::string &node, const std::string &tag, const std::string &tag2node="", const std::string &connName="ATLASDD")=0
Provides access to the Recordset object containing HVS-tagged data.
Class to hold various Athena components.
std::vector< double > readLayerShift()
const ServiceVolumeSchema & schema() const
ServiceVolumeMakerMgr(IRDBRecordset_ptr table, const ServiceVolumeSchema &schema, InDetDD::AthenaComps *athenaComps)
InDetDD::AthenaComps * m_athenaComps
std::string volName(int index) const
const IGeometryDBSvc * db() const
std::string shapeType(int index) const
std::string materialName(int index) const
std::vector< const ServiceVolume * > m_services
std::vector< double > m_layerShift
ServiceVolumeMakerMgr * m_mgr
ServiceVolumeMaker(const std::string &label, IRDBRecordset_ptr table, const ServiceVolumeSchema &schema, InDetDD::AthenaComps *)
const std::vector< const ServiceVolume * > & makeAll()
ServiceVolume * make(int index)
void setLabel(const std::string &name, int volId)
std::string label(const std::string &format, int i)
Definition label.h:19
Message Stream Member.
Definition index.py:1
STL namespace.