20 #ifdef TRKDETDESCR_MEMUSAGE
31 #include "GaudiKernel/MsgStream.h"
32 #include "GaudiKernel/SystemOfUnits.h"
39 #ifdef TRKDETDESCR_MEMUSAGE
45 m_worldMaterialProperties(),
46 m_trackingVolumeArrayCreator(
"Trk::TrackingVolumeArrayCreator/TrackingVolumeArrayCreator"),
47 m_trackingVolumeHelper(
"Trk::TrackingVolumeHelper/TrackingVolumeHelper"),
48 m_inDetGeometryBuilderCond(
"", this),
50 m_caloGeometryBuilderCond(
"",
this),
52 m_hgtdGeometryBuilderCond(
"",
this),
54 m_muonGeometryBuilderCond(
"",
this),
56 m_synchronizeLayers(
true)
58 declareInterface<IGeometryBuilderCond>(
this);
60 declareProperty(
"CreateWorldManually", m_createWorld);
61 declareProperty(
"NavigationLevel", m_navigationLevel);
63 declareProperty(
"WorldDimension", m_worldDimension);
64 declareProperty(
"WorldMaterialProperties", m_worldMaterialProperties);
66 declareProperty(
"TrackingVolumeArrayCreator", m_trackingVolumeArrayCreator);
67 declareProperty(
"TrackingVolumeHelper", m_trackingVolumeHelper);
68 declareProperty(
"InDetTrackingGeometryBuilder", m_inDetGeometryBuilderCond);
69 declareProperty(
"HGTD_TrackingGeometryBuilder", m_hgtdGeometryBuilderCond);
70 declareProperty(
"CaloTrackingGeometryBuilder", m_caloGeometryBuilderCond);
71 declareProperty(
"MuonTrackingGeometryBuilder", m_muonGeometryBuilderCond);
73 declareProperty(
"Compactify", m_compactify );
74 declareProperty(
"SynchronizeLayers", m_synchronizeLayers );
88 ATH_CHECK(m_trackingVolumeArrayCreator.retrieve());
91 ATH_CHECK (m_trackingVolumeHelper.retrieve());
94 if (!m_inDetGeometryBuilderCond.empty()) {
95 ATH_CHECK(m_inDetGeometryBuilderCond.retrieve());
98 if(!m_hgtdGeometryBuilderCond.empty()) {
99 if (m_hgtdGeometryBuilderCond.retrieve().isFailure()) {
100 ATH_MSG_FATAL(
"Failed to retrieve tool " << m_hgtdGeometryBuilderCond );
101 return StatusCode::FAILURE;
103 ATH_MSG_INFO(
"Retrieved tool " << m_hgtdGeometryBuilderCond );
106 if (!m_caloGeometryBuilderCond.empty()) {
107 ATH_CHECK (m_caloGeometryBuilderCond.retrieve());
110 if (!m_muonGeometryBuilderCond.empty()) {
111 ATH_CHECK(m_muonGeometryBuilderCond.retrieve());
115 if (m_worldDimension.empty())
119 if (m_worldMaterialProperties.size() < 5)
120 m_worldMaterialProperties = std::vector<double>{10.e10,10.e10,1
e-10, 0., 0.};
122 m_worldMaterial =
Trk::Material(m_worldMaterialProperties[0],
123 m_worldMaterialProperties[1],
124 m_worldMaterialProperties[2],
125 m_worldMaterialProperties[3],
126 m_worldMaterialProperties[4]);
130 return StatusCode::SUCCESS;
133 std::unique_ptr< Trk::TrackingGeometry>
140 std::unique_ptr<Trk::TrackingGeometry> tGeometry;
141 if ( m_inDetGeometryBuilderCond.empty() && m_hgtdGeometryBuilderCond.empty() && m_caloGeometryBuilderCond.empty() && m_muonGeometryBuilderCond.empty() ) {
147 m_worldDimension[2]);
156 tGeometry = std::make_unique<Trk::TrackingGeometry>(worldVolume);
158 tGeometry = atlasTrackingGeometry(ctx, whandle);
160 tGeometry->
sign(geometrySignature());
165 std::unique_ptr<Trk::TrackingGeometry>
170 std::unique_ptr<Trk::TrackingGeometry> atlasTrackingGeometry;
183 #ifdef TRKDETDESCR_MEMUSAGE
184 m_memoryLogger.refresh(getpid());
185 ATH_MSG_INFO(
"[ memory usage ] Start of TrackingGeometry building: " );
190 if (!m_inDetGeometryBuilderCond.empty()) {
194 std::unique_ptr<Trk::TrackingGeometry> inDetTrackingGeometry =
195 m_inDetGeometryBuilderCond->trackingGeometry(ctx,
nullptr, whandle);
197 if (inDetTrackingGeometry) {
199 inDetTrackingGeometry->
sign(m_inDetGeometryBuilderCond->geometrySignature());
201 if (m_createWorld || m_hgtdGeometry || m_caloGeometry || m_muonGeometry) {
205 highestVolume = inDetVolume;
207 atlasTrackingGeometry = std::move(inDetTrackingGeometry);
210 #ifdef TRKDETDESCR_MEMUSAGE
211 m_memoryLogger.refresh(getpid());
212 ATH_MSG_INFO(
"[ memory usage ] After InDet TrackingGeometry building: " );
220 if (!m_hgtdGeometryBuilderCond.empty()) {
222 ATH_MSG_VERBOSE(
"HGTD Tracking Geometry is going to be built with enclosed ID." );
224 ATH_MSG_VERBOSE(
"HGTD Tracking Geometry is going to be built stand-alone." );
226 std::unique_ptr<Trk::TrackingGeometry> hgtdTrackingGeometry =
227 m_hgtdGeometryBuilderCond->trackingGeometry(ctx, inDetVolume, whandle);
229 if (hgtdTrackingGeometry) {
231 hgtdTrackingGeometry->
sign(m_hgtdGeometryBuilderCond->geometrySignature());
232 if (m_createWorld || m_caloGeometry || m_muonGeometry){
236 highestVolume = hgtdVolume;
238 atlasTrackingGeometry = std::move(hgtdTrackingGeometry);
241 #ifdef TRKDETDESCR_MEMUSAGE
242 m_memoryLogger.refresh(getpid());
243 ATH_MSG_INFO(
"[ memory usage ] After Calo TrackingGeometry building: " );
251 if (!m_caloGeometryBuilderCond.empty()) {
252 std::string enclosed =
"stand-alone.";
253 if (inDetVolume and hgtdVolume)
254 enclosed =
"with encloded ID/HGTD.";
255 else if (inDetVolume or hgtdVolume)
256 enclosed = (inDetVolume) ?
"with encloded ID." :
"with encloded HGTD.";
257 ATH_MSG_VERBOSE(
"Calorimeter Tracking Geometry is going to be built "<< enclosed );
260 std::unique_ptr<Trk::TrackingGeometry> caloTrackingGeometry;
261 if (inDetVolume and not hgtdVolume)
262 caloTrackingGeometry = m_caloGeometryBuilderCond->trackingGeometry(ctx, inDetVolume, whandle);
264 caloTrackingGeometry = m_caloGeometryBuilderCond->trackingGeometry(ctx, hgtdVolume, whandle);
266 if (caloTrackingGeometry) {
268 caloTrackingGeometry->
sign(m_caloGeometryBuilderCond->geometrySignature());
269 if (m_createWorld || m_muonGeometry){
273 highestVolume = caloVolume;
275 atlasTrackingGeometry = std::move(caloTrackingGeometry);
278 #ifdef TRKDETDESCR_MEMUSAGE
279 m_memoryLogger.refresh(getpid());
280 ATH_MSG_INFO(
"[ memory usage ] After Calo TrackingGeometry building: " );
288 if (!m_muonGeometryBuilderCond.empty()) {
289 std::string enclosed =
"stand-alone.";
290 if (inDetVolume and hgtdVolume and caloVolume )
291 enclosed =
"with encloded ID/HGTD/Calo.";
292 else if (inDetVolume or hgtdVolume or caloVolume) {
295 enclosed =
"with encloded ID/HGTD";
297 enclosed =
"with encloded ID/Calo";
299 enclosed =
"with encloded ID";
300 }
else if (hgtdVolume) {
302 enclosed =
"with encloded HGTD/Calo";
304 enclosed =
"with encloded HGTD";
306 enclosed =
"with encloded Calo";
309 ATH_MSG_VERBOSE(
"Muon System Tracking Geometry is going to be built "<< enclosed );
312 if (inDetVolume and not hgtdVolume and not caloVolume)
313 atlasTrackingGeometry = m_muonGeometryBuilderCond->trackingGeometry(ctx, inDetVolume, whandle);
314 else if (hgtdVolume and not caloVolume)
315 atlasTrackingGeometry = m_muonGeometryBuilderCond->trackingGeometry(ctx, hgtdVolume, whandle);
317 atlasTrackingGeometry = m_muonGeometryBuilderCond->trackingGeometry(ctx, caloVolume, whandle);
320 if (atlasTrackingGeometry)
321 atlasTrackingGeometry->
sign(m_muonGeometryBuilderCond->geometrySignature());
323 #ifdef TRKDETDESCR_MEMUSAGE
324 m_memoryLogger.refresh(getpid());
325 ATH_MSG_INFO(
"[ memory usage ] After Muon TrackingGeometry building: " );
330 }
else if (m_createWorld && highestVolume) {
336 ATH_MSG_VERBOSE(
"Retrieved with following glue volumes: " << innerGlueVolumes );
347 if (!innerVolumeBounds)
ATH_MSG_WARNING(
"atlasTrackingGeometry() ... dynamic cast to innerVolumeBounds failed!" );
348 double innerVolumeOuterR = innerVolumeBounds ? innerVolumeBounds->
outerRadius() : 0;
349 double innerVolumeHalflengthZ = innerVolumeBounds ? innerVolumeBounds->
halflengthZ() : 0;
360 double innerCylinderSectorHalflengthZ = 0.5*(m_worldDimension[2] - innerVolumeHalflengthZ);
364 double innerCylinderSectorPositionZ = fabs(m_worldDimension[2]-innerCylinderSectorHalflengthZ);
368 (*atlasInnerNegativeSectorTransf) =
Amg::Translation3D(0.,0.,-innerCylinderSectorPositionZ);
370 atlasInnerNegativeSectorTransf,
371 innerCylinderSectorBounds,
375 "AtlasInnerNegativeSector");
379 (*atlasInnerPositiveSectorTransf) =
Amg::Translation3D(0.,0.,innerCylinderSectorPositionZ);
381 atlasInnerPositiveSectorTransf,
382 innerCylinderSectorBounds->
clone(),
386 "AtlasInnerPositiveSector");
388 ATH_MSG_VERBOSE(
"Inner Negative/Positive Sectors built successfully." );
391 auto atlasInnerSectorVolumes = std::vector<Trk::TrackingVolume*>{atlasInnerNegativeSector,highestVolume,atlasInnerPositiveSector};
395 m_trackingVolumeArrayCreator->cylinderVolumesArrayInZ(atlasInnerSectorVolumes) :
nullptr;
406 atlasInnerSectorVolumeArray,
422 auto atlasVolumes = std::vector<Trk::TrackingVolume*>{atlasInnerSector, atlasOuterSector};
425 m_trackingVolumeArrayCreator->cylinderVolumesArrayInR(atlasVolumes) :
nullptr;
442 m_trackingVolumeHelper->glueTrackingVolumes( *atlasInnerNegativeSector,
Trk::positiveFaceXY,
445 m_trackingVolumeHelper->glueTrackingVolumes( *atlasInnerPositiveSector,
Trk::negativeFaceXY,
451 auto volIter = innerCentralFaceVolumes.begin();
452 auto volIterEnd = innerCentralFaceVolumes.end();
455 std::vector<Trk::TrackingVolume*> atlasInnerOuterVolumes;
456 atlasInnerOuterVolumes.push_back(atlasInnerNegativeSector);
457 for ( ; volIter != volIterEnd; ++volIter)
458 if (*volIter) atlasInnerOuterVolumes.push_back(*volIter);
459 atlasInnerOuterVolumes.push_back(atlasInnerPositiveSector);
464 ATH_MSG_VERBOSE(
"Atlas Inner/Outer Sector glued successfully together." );
467 atlasTrackingGeometry = std::make_unique<Trk::TrackingGeometry>(atlasVolume);
470 ATH_MSG_VERBOSE(
"Atlas TrackingGeometry built with following parameters : ");
476 #ifdef TRKDETDESCR_MEMUSAGE
477 m_memoryLogger.refresh(getpid());
478 ATH_MSG_INFO(
"[ memory usage ] After Outer Sector TrackingGeometry building: " );
484 if (atlasTrackingGeometry) {
485 if (m_navigationLevel < 3)
488 else ATH_MSG_WARNING(
"atlasTrackingGeometry() ... atlasTrackingGeometry = 0, could not call registerNavigationLevel and propagateMagneticFieldProperties" );
490 #ifdef TRKDETDESCR_MEMUSAGE
491 m_memoryLogger.refresh(getpid());
492 ATH_MSG_INFO(
"[ memory usage ] End of TrackingGeometry building: " );
497 if (atlasTrackingGeometry) {
503 return atlasTrackingGeometry;