ATLAS Offline Software
Loading...
Searching...
No Matches
GeometryAsciiDumper.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 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
25// constructor
26Trk::GeometryAsciiDumper::GeometryAsciiDumper(const std::string& t, const std::string& n, const IInterface* p) :
28 m_outputFileName("TrackingGeometryAscii.txt"),
30{
31 declareProperty("OutputFileName", m_outputFileName);
32 declareProperty("OutputPrecision", m_outputPrecision);
33}
34
35// destructor
37= default;
38
39
41{
42 // open the file for writing
43 m_outputFile.open(m_outputFileName.c_str());
44 m_outputFile << " ============================= TrackingGeometry ASCII file (BOF) =============================" << std::endl;
45 // return the base::initialize() state
47}
48
50{
51 // close the file
52 m_outputFile << " ============================= TrackingGeometry ASCII file (EOF) =============================" << std::endl;
53 m_outputFile.close();
54 // return the base::finalize() state
56}
57
58
59
60StatusCode Trk::GeometryAsciiDumper::processNode(const Trk::TrackingVolume& tvol, size_t level) const
61{
62
63 ATH_MSG_VERBOSE("Dumping information for TrackingVolume.");
64 std::stringstream levelBuffer;
65 for (size_t il = 0; il < level; ++il) levelBuffer << " ";
66
67 m_outputFile << levelBuffer.str() << "Trk::TrackingVolume '" << tvol.volumeName() << "'" << std::endl;
68 std::string rotationOffset = levelBuffer.str() +" ";
69 m_outputFile << levelBuffer.str() << " - transform : " << Amg::toString( tvol.transform(),
70 m_outputPrecision, rotationOffset ) << std::endl;
71 m_outputFile << levelBuffer.str() << " - listing Trk::BoundarySurface objects :" << std::endl;
72 const auto& bSurfaces = tvol.boundarySurfaces();
73 for (size_t ib = 0 ; ib < bSurfaces.size(); ++ib ){
74 if ( processNode(bSurfaces[ib]->surfaceRepresentation(), level+4).isFailure() )
75 ATH_MSG_WARNING("Problem to write out the boundary surfaces of TrackingVolume '" << tvol.volumeName() << "'." );
76 }
77
78 // Process the contained layers if they exist
79 const Trk::LayerArray* layerArray = tvol.confinedLayers();
80 if (layerArray) {
81 m_outputFile << levelBuffer.str() << " - contains " << layerArray->arrayObjects().size() << " confined Trk::Layer objects." << std::endl;
82 m_outputFile << levelBuffer.str() << " - listing Trk::Layer objects :" << std::endl;
83 }
84
85 // Process the contained TrackingVolumes (recursively) if they exist
86 const Trk::BinnedArray<Trk::TrackingVolume >* confinedVolumes = tvol.confinedVolumes();
87 if (confinedVolumes){
88 m_outputFile << levelBuffer.str() << " - contains " << confinedVolumes->arrayObjects().size() << " confined Trk::TrackingVolume objects." << std::endl;
89 m_outputFile << levelBuffer.str() << " - stepping down in hierarchy to Trk::TrackingVolume objects :" << std::endl;
90 }
91
92 return StatusCode::SUCCESS;
93}
94
95
96StatusCode Trk::GeometryAsciiDumper::processNode(const Trk::Layer& lay, size_t level) const
97{
98
99 ATH_MSG_VERBOSE("Dumping information for Layer.");
100 std::stringstream levelBuffer;
101 for (size_t il = 0; il < level; ++il) levelBuffer << " ";
102
103 size_t layerIdx = lay.layerIndex().value();
104 if (layerIdx) {
105 m_outputFile << levelBuffer.str() << " Trk::Layer with LayerIndex " << layerIdx << std::endl;
106 m_outputFile << levelBuffer.str() << " - writing surface representation : " << std::endl;
107 if (processNode(lay.surfaceRepresentation(),level).isFailure())
108 ATH_MSG_VERBOSE("Problems to write out surface representation of Trk::Layer with LayerIndex" << layerIdx);
109 const Trk::SurfaceArray* surfArray = lay.surfaceArray();
110 if (surfArray) {
111 m_outputFile << levelBuffer.str() << " - contains " << surfArray->arrayObjects().size() << " confined Trk::Surface objects." << std::endl;
112 m_outputFile << levelBuffer.str() << " - listing Trk::Surface objects :" << std::endl;
113 }
114 } else
115 m_outputFile << levelBuffer.str() << " Trk::NavigationLayer - no geometrical information." << std::endl;
116
117
118 return StatusCode::SUCCESS;
119}
120
121
122StatusCode Trk::GeometryAsciiDumper::processNode(const Trk::Surface& sf, size_t level) const
123{
124 ATH_MSG_VERBOSE("Dumping information for Surfaces.");
125 std::stringstream levelBuffer;
126 for (size_t il = 0; il < level; ++il) levelBuffer << " ";
127
128 m_outputFile << levelBuffer.str() << " Trk::Surface object of type " << static_cast<int>(sf.type()) << std::endl;
129 std::string rotationOffset = levelBuffer.str() +" ";
130 m_outputFile << levelBuffer.str() << " - transform : " << Amg::toString( sf.transform(),
131 m_outputPrecision, rotationOffset ) << std::endl;
132 return StatusCode::SUCCESS;
133}
134
135
136
137
138
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
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.
GeometryAsciiDumper(const std::string &, const std::string &, const IInterface *)
Constructor.
virtual ~GeometryAsciiDumper()
Destructor.
StatusCode initialize()
AlgTool initialize method.
StatusCode processNode(const TrackingVolume &tvol, size_t level=0) const
Current implementation: write root visualization to file stream.
StatusCode finalize()
AlgTool finalize method.
std::string m_outputFileName
where the tree is written to
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
RecursiveGeometryProcessor(const std::string &, const std::string &, const IInterface *)
Constructor.
StatusCode initialize()
AlgTool initialize method.
StatusCode finalize()
AlgTool finalize method.
Abstract Base Class for tracking surfaces.
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.
Ensure that the ATLAS eigen extensions are properly loaded.
BinnedArray< Layer > LayerArray
simply for the eye
BinnedArray< Surface > SurfaceArray
Definition Layer.h:40