20 #ifdef TRKDETDESCR_MEMUSAGE
29 #include "GaudiKernel/MsgStream.h"
30 #include "GaudiKernel/SystemOfUnits.h"
37 #ifdef TRKDETDESCR_MEMUSAGE
43 m_worldMaterialProperties(),
44 m_trackingVolumeArrayCreator(
"Trk::TrackingVolumeArrayCreator/TrackingVolumeArrayCreator"),
45 m_trackingVolumeHelper(
"Trk::TrackingVolumeHelper/TrackingVolumeHelper"),
46 m_inDetGeometryBuilder(
"", this),
48 m_caloGeometryBuilder(
"",
this),
50 m_muonGeometryBuilder(
"",
this),
52 m_synchronizeLayers(
true)
54 declareInterface<IGeometryBuilder>(
this);
56 declareProperty(
"CreateWorldManually", m_createWorld);
57 declareProperty(
"NavigationLevel", m_navigationLevel);
59 declareProperty(
"WorldDimension", m_worldDimension);
60 declareProperty(
"WorldMaterialProperties", m_worldMaterialProperties);
62 declareProperty(
"TrackingVolumeArrayCreator", m_trackingVolumeArrayCreator);
63 declareProperty(
"TrackingVolumeHelper", m_trackingVolumeHelper);
64 declareProperty(
"InDetTrackingGeometryBuilder", m_inDetGeometryBuilder);
65 declareProperty(
"CaloTrackingGeometryBuilder", m_caloGeometryBuilder);
66 declareProperty(
"MuonTrackingGeometryBuilder", m_muonGeometryBuilder);
68 declareProperty(
"Compactify", m_compactify );
69 declareProperty(
"SynchronizeLayers", m_synchronizeLayers );
83 ATH_CHECK(m_trackingVolumeArrayCreator.retrieve());
86 ATH_CHECK (m_trackingVolumeHelper.retrieve());
89 if (!m_inDetGeometryBuilder.empty()) {
90 ATH_CHECK(m_inDetGeometryBuilder.retrieve());
93 if (!m_caloGeometryBuilder.empty()) {
94 ATH_CHECK (m_caloGeometryBuilder.retrieve());
97 if (!m_muonGeometryBuilder.empty()) {
98 ATH_CHECK(m_muonGeometryBuilder.retrieve());
102 if (m_worldDimension.empty())
106 if (m_worldMaterialProperties.size() < 5)
107 m_worldMaterialProperties = std::vector<double>{10.e10,10.e10,0., 0., 0.};
109 m_worldMaterial =
Trk::Material(m_worldMaterialProperties[0],
110 m_worldMaterialProperties[1],
111 m_worldMaterialProperties[2],
112 m_worldMaterialProperties[3],
113 m_worldMaterialProperties[4]);
117 return StatusCode::SUCCESS;
125 std::unique_ptr<Trk::TrackingGeometry> tGeometry =
nullptr;
126 if ( m_inDetGeometryBuilder.empty() && m_caloGeometryBuilder.empty() && m_muonGeometryBuilder.empty() ) {
132 m_worldDimension[2]);
142 tGeometry = std::make_unique<Trk::TrackingGeometry>(worldVolume);
144 tGeometry = atlasTrackingGeometry();
146 tGeometry->
sign(geometrySignature());
155 std::unique_ptr<Trk::TrackingGeometry> atlasTrackingGeometry =
nullptr;
159 std::unique_ptr<Trk::TrackingGeometry> inDetTrackingGeometry =
nullptr;
160 std::unique_ptr<Trk::TrackingGeometry> caloTrackingGeometry =
nullptr;
169 #ifdef TRKDETDESCR_MEMUSAGE
170 m_memoryLogger.refresh(getpid());
171 ATH_MSG_INFO(
"[ memory usage ] Start of TrackingGeometry building: " );
176 if (!m_inDetGeometryBuilder.empty()) {
180 inDetTrackingGeometry = m_inDetGeometryBuilder->trackingGeometry();
182 if (inDetTrackingGeometry) {
184 inDetTrackingGeometry->
sign(m_inDetGeometryBuilder->geometrySignature());
186 if (m_createWorld || m_caloGeometry || m_muonGeometry) {
190 highestVolume = inDetVolume;
192 atlasTrackingGeometry = std::move(inDetTrackingGeometry);
195 #ifdef TRKDETDESCR_MEMUSAGE
196 m_memoryLogger.refresh(getpid());
197 ATH_MSG_INFO(
"[ memory usage ] After InDet TrackingGeometry building: " );
205 if (!m_caloGeometryBuilder.empty()) {
207 ATH_MSG_VERBOSE(
"Calorimeter Tracking Geometry is going to be built with enclosed ID." );
209 ATH_MSG_VERBOSE(
"Calorimeter Tracking Geometry is going to be built stand-alone." );
211 caloTrackingGeometry = m_caloGeometryBuilder->trackingGeometry(inDetVolume);
213 if (caloTrackingGeometry) {
215 caloTrackingGeometry->
sign(m_caloGeometryBuilder->geometrySignature());
216 if (m_createWorld || m_muonGeometry){
220 highestVolume = caloVolume;
222 atlasTrackingGeometry = std::move(caloTrackingGeometry);
225 #ifdef TRKDETDESCR_MEMUSAGE
226 m_memoryLogger.refresh(getpid());
227 ATH_MSG_INFO(
"[ memory usage ] After Calo TrackingGeometry building: " );
235 if (!m_muonGeometryBuilder.empty()) {
237 std::string enclosed =
"stand-alone.";
238 if (inDetVolume && caloVolume)
239 enclosed =
"with encloded ID/Calo.";
240 else if (inDetVolume || caloVolume)
241 enclosed = (inDetVolume) ?
"with encloded ID." :
"with encloded Calo.";
242 ATH_MSG_VERBOSE(
"Muon System Tracking Geometry is going to be built "<< enclosed );
244 if (inDetVolume && !caloVolume)
245 atlasTrackingGeometry = m_muonGeometryBuilder->trackingGeometry( inDetVolume );
247 atlasTrackingGeometry = m_muonGeometryBuilder->trackingGeometry( caloVolume );
250 if (atlasTrackingGeometry)
251 atlasTrackingGeometry->
sign(m_muonGeometryBuilder->geometrySignature());
253 #ifdef TRKDETDESCR_MEMUSAGE
254 m_memoryLogger.refresh(getpid());
255 ATH_MSG_INFO(
"[ memory usage ] After Muon TrackingGeometry building: " );
260 }
else if (m_createWorld && highestVolume) {
266 ATH_MSG_VERBOSE(
"Retrieved with following glue volumes: " << innerGlueVolumes );
277 if (!innerVolumeBounds)
ATH_MSG_WARNING(
"atlasTrackingGeometry() ... dynamic cast to innerVolumeBounds failed!" );
278 double innerVolumeOuterR = innerVolumeBounds ? innerVolumeBounds->
outerRadius() : 0;
279 double innerVolumeHalflengthZ = innerVolumeBounds ? innerVolumeBounds->
halflengthZ() : 0;
290 double innerCylinderSectorHalflengthZ = 0.5*(m_worldDimension[2] - innerVolumeHalflengthZ);
294 double innerCylinderSectorPositionZ = fabs(m_worldDimension[2]-innerCylinderSectorHalflengthZ);
298 (*atlasInnerNegativeSectorTransf) =
Amg::Translation3D(0.,0.,-innerCylinderSectorPositionZ);
300 atlasInnerNegativeSectorTransf,
301 innerCylinderSectorBounds,
305 "AtlasInnerNegativeSector");
309 (*atlasInnerPositiveSectorTransf) =
Amg::Translation3D(0.,0.,innerCylinderSectorPositionZ);
311 atlasInnerPositiveSectorTransf,
312 innerCylinderSectorBounds->
clone(),
316 "AtlasInnerPositiveSector");
318 ATH_MSG_VERBOSE(
"Inner Negative/Positive Sectors built successfully." );
321 auto atlasInnerSectorVolumes = std::vector<Trk::TrackingVolume*>{atlasInnerNegativeSector,highestVolume,atlasInnerPositiveSector};
325 m_trackingVolumeArrayCreator->cylinderVolumesArrayInZ(atlasInnerSectorVolumes) :
nullptr;
336 atlasInnerSectorVolumeArray,
352 auto atlasVolumes = std::vector<Trk::TrackingVolume*>{atlasInnerSector, atlasOuterSector};
355 m_trackingVolumeArrayCreator->cylinderVolumesArrayInR(atlasVolumes) :
nullptr;
372 m_trackingVolumeHelper->glueTrackingVolumes( *atlasInnerNegativeSector,
Trk::positiveFaceXY,
375 m_trackingVolumeHelper->glueTrackingVolumes( *atlasInnerPositiveSector,
Trk::negativeFaceXY,
381 auto volIter = innerCentralFaceVolumes.begin();
382 auto volIterEnd = innerCentralFaceVolumes.end();
385 std::vector<Trk::TrackingVolume*> atlasInnerOuterVolumes;
386 atlasInnerOuterVolumes.push_back(atlasInnerNegativeSector);
387 for ( ; volIter != volIterEnd; ++volIter)
388 if (*volIter) atlasInnerOuterVolumes.push_back(*volIter);
389 atlasInnerOuterVolumes.push_back(atlasInnerPositiveSector);
394 ATH_MSG_VERBOSE(
"Atlas Inner/Outer Sector glued successfully together." );
397 atlasTrackingGeometry = std::make_unique<Trk::TrackingGeometry>(atlasVolume);
400 ATH_MSG_VERBOSE(
"Atlas TrackingGeometry built with following parameters : ");
406 #ifdef TRKDETDESCR_MEMUSAGE
407 m_memoryLogger.refresh(getpid());
408 ATH_MSG_INFO(
"[ memory usage ] After Outer Sector TrackingGeometry building: " );
414 if (atlasTrackingGeometry) {
415 if (m_navigationLevel < 3)
418 else ATH_MSG_WARNING(
"atlasTrackingGeometry() ... atlasTrackingGeometry = 0, could not call registerNavigationLevel and propagateMagneticFieldProperties" );
420 #ifdef TRKDETDESCR_MEMUSAGE
421 m_memoryLogger.refresh(getpid());
422 ATH_MSG_INFO(
"[ memory usage ] End of TrackingGeometry building: " );
427 if (atlasTrackingGeometry) {
433 return atlasTrackingGeometry;