ATLAS Offline Software
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
26 Trk::GeometryAsciiDumper::GeometryAsciiDumper(const std::string& t, const std::string& n, const IInterface* p) :
28  m_outputFileName("TrackingGeometryAscii.txt"),
29  m_outputPrecision(6)
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 
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 
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 
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 
PlotCalibFromCool.il
il
Definition: PlotCalibFromCool.py:381
Trk::GeometryAsciiDumper::processNode
StatusCode processNode(const TrackingVolume &tvol, size_t level=0) const
Current implementation: write root visualization to file stream.
Definition: GeometryAsciiDumper.cxx:60
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
Surface.h
Trk::RecursiveGeometryProcessor::initialize
StatusCode initialize()
AlgTool initialize method.
Definition: RecursiveGeometryProcessor.cxx:32
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
Trk::TrackingVolume::boundarySurfaces
std::vector< SharedObject< BoundarySurface< TrackingVolume > > > & boundarySurfaces()
Method to return the BoundarySurfaces.
Definition: TrackingVolume.cxx:982
PlotCalibFromCool.ib
ib
Definition: PlotCalibFromCool.py:419
Layer.h
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
Trk::GeometryAsciiDumper::~GeometryAsciiDumper
virtual ~GeometryAsciiDumper()
Destructor.
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
Trk::GeometryAsciiDumper::finalize
StatusCode finalize()
AlgTool finalize method.
Definition: GeometryAsciiDumper.cxx:49
Trk::TrackingVolume::confinedLayers
const LayerArray * confinedLayers() const
Return the subLayer array.
Trk::Layer::surfaceArray
const SurfaceArray * surfaceArray() const
Return the entire SurfaceArray, returns nullptr if no SurfaceArray.
Trk::RecursiveGeometryProcessor::finalize
StatusCode finalize()
AlgTool finalize method.
Definition: RecursiveGeometryProcessor.cxx:39
Trk::GeometryAsciiDumper::m_outputPrecision
int m_outputPrecision
Definition: GeometryAsciiDumper.h:66
Amg::toString
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Definition: GeoPrimitivesToStringConverter.h:40
Trk::Layer::surfaceRepresentation
virtual const Surface & surfaceRepresentation() const =0
Transforms the layer into a Surface representation for extrapolation.
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
GeometryAsciiDumper.h
Trk::LayerIndex::value
int value() const
layerIndex expressed in an integer
Definition: LayerIndex.h:71
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Trk::TrackingVolume::volumeName
const std::string & volumeName() const
Returns the VolumeName - for debug reason, might be depreciated later.
Trk::BinnedArray::arrayObjects
virtual BinnedArraySpan< T *const > arrayObjects()=0
Return all objects of the Array non-const we can still modify the T.
Trk::RecursiveGeometryProcessor
Definition: RecursiveGeometryProcessor.h:39
Trk::Volume::transform
const Amg::Transform3D & transform() const
Return methods for geometry transform.
Definition: Volume.h:81
mapkey::sf
@ sf
Definition: TElectronEfficiencyCorrectionTool.cxx:38
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Trk::TrackingVolume::confinedVolumes
const TrackingVolumeArray * confinedVolumes() const
Return the subLayer array.
Trk::GeometryAsciiDumper::GeometryAsciiDumper
GeometryAsciiDumper(const std::string &, const std::string &, const IInterface *)
Constructor.
Definition: GeometryAsciiDumper.cxx:26
GeoPrimitivesToStringConverter.h
TrackingGeometry.h
Trk::BinnedArray
Definition: BinnedArray.h:38
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
Trk::TrackingVolume
Definition: TrackingVolume.h:121
Trk::GeometryAsciiDumper::m_outputFileName
std::string m_outputFileName
where the tree is written to
Definition: GeometryAsciiDumper.h:65
Trk::GeometryAsciiDumper::initialize
StatusCode initialize()
AlgTool initialize method.
Definition: GeometryAsciiDumper.cxx:40
Trk::Layer
Definition: Layer.h:73
Trk::Layer::layerIndex
const LayerIndex & layerIndex() const
get the layerIndex