ATLAS Offline Software
Loading...
Searching...
No Matches
GeometryAsciiDumper.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// GeometryAsciiDumper.cxx, (c) ATLAS Detector software
8
9// Amg includes
11// Trk include
14#include "TrkGeometry/Layer.h"
15#include "TrkSurfaces/Surface.h"
16// Root
17#include "TTree.h"
18#include "TString.h"
19#include <sstream>
20
21// Gaudi
22#include "GaudiKernel/ITHistSvc.h"
23
24
26{
27 // open the file for writing
28 m_outputFile.open(m_outputFileName.value().c_str());
29 m_outputFile << " ============================= TrackingGeometry ASCII file (BOF) =============================" << std::endl;
30 // return the base::initialize() state
31 return Trk::RecursiveGeometryProcessor::initialize();
32}
33
35{
36 // close the file
37 m_outputFile << " ============================= TrackingGeometry ASCII file (EOF) =============================" << std::endl;
38 m_outputFile.close();
39 // return the base::finalize() state
40 return Trk::RecursiveGeometryProcessor::finalize();
41}
42
43
44
45StatusCode Trk::GeometryAsciiDumper::processNode(const Trk::TrackingVolume& tvol, size_t level) const
46{
47
48 ATH_MSG_VERBOSE("Dumping information for TrackingVolume.");
49 std::stringstream levelBuffer;
50 for (size_t il = 0; il < level; ++il) levelBuffer << " ";
51
52 m_outputFile << levelBuffer.str() << "Trk::TrackingVolume '" << tvol.volumeName() << "'" << std::endl;
53 std::string rotationOffset = levelBuffer.str() +" ";
54 m_outputFile << levelBuffer.str() << " - transform : " << Amg::toString( tvol.transform(),
55 m_outputPrecision, rotationOffset ) << std::endl;
56 m_outputFile << levelBuffer.str() << " - listing Trk::BoundarySurface objects :" << std::endl;
57 const auto& bSurfaces = tvol.boundarySurfaces();
58 for (size_t ib = 0 ; ib < bSurfaces.size(); ++ib ){
59 if ( processNode(bSurfaces[ib]->surfaceRepresentation(), level+4).isFailure() )
60 ATH_MSG_WARNING("Problem to write out the boundary surfaces of TrackingVolume '" << tvol.volumeName() << "'." );
61 }
62
63 // Process the contained layers if they exist
64 const Trk::LayerArray* layerArray = tvol.confinedLayers();
65 if (layerArray) {
66 m_outputFile << levelBuffer.str() << " - contains " << layerArray->arrayObjects().size() << " confined Trk::Layer objects." << std::endl;
67 m_outputFile << levelBuffer.str() << " - listing Trk::Layer objects :" << std::endl;
68 }
69
70 // Process the contained TrackingVolumes (recursively) if they exist
71 const Trk::BinnedArray<Trk::TrackingVolume >* confinedVolumes = tvol.confinedVolumes();
72 if (confinedVolumes){
73 m_outputFile << levelBuffer.str() << " - contains " << confinedVolumes->arrayObjects().size() << " confined Trk::TrackingVolume objects." << std::endl;
74 m_outputFile << levelBuffer.str() << " - stepping down in hierarchy to Trk::TrackingVolume objects :" << std::endl;
75 }
76
77 return StatusCode::SUCCESS;
78}
79
80
81StatusCode Trk::GeometryAsciiDumper::processNode(const Trk::Layer& lay, size_t level) const
82{
83
84 ATH_MSG_VERBOSE("Dumping information for Layer.");
85 std::stringstream levelBuffer;
86 for (size_t il = 0; il < level; ++il) levelBuffer << " ";
87
88 size_t layerIdx = lay.layerIndex().value();
89 if (layerIdx) {
90 m_outputFile << levelBuffer.str() << " Trk::Layer with LayerIndex " << layerIdx << std::endl;
91 m_outputFile << levelBuffer.str() << " - writing surface representation : " << std::endl;
92 if (processNode(lay.surfaceRepresentation(),level).isFailure())
93 ATH_MSG_VERBOSE("Problems to write out surface representation of Trk::Layer with LayerIndex" << layerIdx);
94 const Trk::SurfaceArray* surfArray = lay.surfaceArray();
95 if (surfArray) {
96 m_outputFile << levelBuffer.str() << " - contains " << surfArray->arrayObjects().size() << " confined Trk::Surface objects." << std::endl;
97 m_outputFile << levelBuffer.str() << " - listing Trk::Surface objects :" << std::endl;
98 }
99 } else
100 m_outputFile << levelBuffer.str() << " Trk::NavigationLayer - no geometrical information." << std::endl;
101
102
103 return StatusCode::SUCCESS;
104}
105
106
107StatusCode Trk::GeometryAsciiDumper::processNode(const Trk::Surface& sf, size_t level) const
108{
109 ATH_MSG_VERBOSE("Dumping information for Surfaces.");
110 std::stringstream levelBuffer;
111 for (size_t il = 0; il < level; ++il) levelBuffer << " ";
112
113 m_outputFile << levelBuffer.str() << " Trk::Surface object of type " << static_cast<int>(sf.type()) << std::endl;
114 std::string rotationOffset = levelBuffer.str() +" ";
115 m_outputFile << levelBuffer.str() << " - transform : " << Amg::toString( sf.transform(),
116 m_outputPrecision, rotationOffset ) << std::endl;
117 return StatusCode::SUCCESS;
118}
119
120
121
122
123
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
Binned Array for avoiding map searches/.
Definition BinnedArray.h:36
virtual std::span< T *const > arrayObjects()=0
Return all objects of the Array non-const we can still modify the T.
Gaudi::Property< int > m_outputPrecision
StatusCode initialize()
AlgTool initialize method.
StatusCode processNode(const TrackingVolume &tvol, size_t level=0) const
Current implementation: write root visualization to file stream.
Gaudi::Property< std::string > m_outputFileName
StatusCode finalize()
AlgTool finalize method.
int value() const
layerIndex expressed in an integer
Definition LayerIndex.h:71
Base Class for a Detector Layer in the Tracking realm.
Definition Layer.h:72
virtual const Surface & surfaceRepresentation() const =0
Transforms the layer into a Surface representation for extrapolation.
const SurfaceArray * surfaceArray() const
Return the entire SurfaceArray, returns nullptr if no SurfaceArray.
const LayerIndex & layerIndex() const
get the layerIndex
Abstract Base Class for tracking surfaces.
Definition Surface.h:79
Full Volume description used in Tracking, it inherits from Volume to get the geometrical structure,...
const LayerArray * confinedLayers() const
Return the subLayer array.
const TrackingVolumeArray * confinedVolumes() const
Return the subLayer array.
std::vector< std::shared_ptr< BoundarySurface< TrackingVolume > > > & boundarySurfaces()
Method to return the BoundarySurfaces.
const std::string & volumeName() const
Returns the VolumeName - for debug reason, might be depreciated later.
const Amg::Transform3D & transform() const
Return methods for geometry transform.
Definition Volume.h:83
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
BinnedArray< Layer > LayerArray
simply for the eye
BinnedArray< Surface > SurfaceArray
Definition Layer.h:40