ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tracking
TrkDetDescr
TrkDetDescrTestTools
src
GeometryJsonDumper.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
// GeometryJsonDumper.cxx, (c) ATLAS Detector software
8
9
// Amg includes
10
#include "
GeoPrimitives/GeoPrimitivesToStringConverter.h
"
11
// Trk include
12
#include "
TrkDetDescrTestTools/GeometryJsonDumper.h
"
13
#include "
TrkGeometry/TrackingGeometry.h
"
14
#include "
TrkGeometry/Layer.h
"
15
#include "
TrkSurfaces/Surface.h
"
16
#include "
TrkSurfaces/RectangleBounds.h
"
17
// output stream
18
#include <sstream>
19
20
// Gaudi
21
#include "GaudiKernel/ITHistSvc.h"
22
23
24
StatusCode
Trk::GeometryJsonDumper::initialize
()
25
{
26
// open the file for writing
27
m_outputFile
.open(
m_outputFileName
.value().c_str());
28
m_outputFile
<<
"["
;
29
m_outputFile
<< std::setiosflags(std::ios::fixed);
30
m_outputFile
<< std::setprecision(3);
31
// return the base::initialize() state
32
return
Trk::RecursiveGeometryProcessor::initialize();
33
}
34
35
StatusCode
Trk::GeometryJsonDumper::finalize
()
36
{
37
// close the file
38
m_outputFile
<<
"]"
<< std::endl;
39
m_outputFile
.close();
40
// return the base::finalize() state
41
return
Trk::RecursiveGeometryProcessor::finalize();
42
}
43
44
45
46
StatusCode
Trk::GeometryJsonDumper::processNode
(
const
Trk::TrackingVolume
&
/*tvol*/
,
size_t
/*level*/
)
const
47
{
48
return
StatusCode::SUCCESS;
49
}
50
51
52
StatusCode
Trk::GeometryJsonDumper::processNode
(
const
Trk::Layer
& lay,
size_t
/*level*/
)
const
53
{
54
55
ATH_MSG_VERBOSE
(
"Dumping information for Layer with index "
<< lay.
layerIndex
().
value
());
56
57
if
(lay.
surfaceArray
()){
58
size_t
nSurfaces = lay.
surfaceArray
()->
arrayObjects
().size();
59
// the layer has a surface Array - go for it
60
// get the dimensions
61
const
Trk::Surface
* referenceSurface = lay.
subSurfaceReference
();
62
// the reference Surface exists
63
if
(referenceSurface){
64
// dynamic_cast to RectangleBounds
65
const
Trk::RectangleBounds
* rBounds =
dynamic_cast<
const
Trk::RectangleBounds
*
>
(&(referenceSurface->
bounds
()));
66
// we have rBounds - go on for the moment
67
if
(rBounds){
68
if
(
m_firstLayerWritten
)
m_outputFile
<<
","
;
69
// the layer is defined
70
m_outputFile
<<
"{\"Name\" : \"Layer "
<< lay.
layerIndex
().
value
() <<
"\", "
;
71
m_outputFile
<<
"\"Dimensions\" : ["
<< 2*rBounds->
halflengthX
() <<
","
<< 2.*rBounds->
halflengthY
() <<
", 1.0 ], "
;
72
// count the surfaces
73
size_t
is = 1;
74
// now loop of the surfaces and dumpt their position
75
m_outputFile
<<
"\"Coords\": ["
;
76
for
(
const
auto
& sf : lay.
surfaceArray
()->
arrayObjects
()){
77
// get x,y,z
78
double
cx = sf->center().x();
79
double
cy = sf->center().y();
80
double
cz = sf->center().z();
81
// get the euler angles
82
auto
ea = sf->transform().rotation().eulerAngles(0, 1, 2);
83
double
e0 = ea[0];
84
double
e1 = ea[1];
85
double
e2 = ea[2];
86
m_outputFile
<<
"["
<< cx <<
","
<< cy <<
","
<< cz <<
"],["
<< e0 <<
","
<< e1 <<
","
<< e2 <<
"]"
;
87
if
(is < nSurfaces)
m_outputFile
<<
","
;
88
++is;
89
}
90
m_outputFile
<<
"]}"
;
91
m_firstLayerWritten
=
true
;
92
}
93
}
94
}
95
return
StatusCode::SUCCESS;
96
}
97
98
99
StatusCode
Trk::GeometryJsonDumper::processNode
(
const
Trk::Surface
&
/*sf*/
,
size_t
/*level*/
)
const
100
{
101
ATH_MSG_VERBOSE
(
"Dumping information for Surfaces."
);
102
103
return
StatusCode::SUCCESS;
104
}
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x,...)
Definition
AthMsgStreamMacros.h:42
GeoPrimitivesToStringConverter.h
GeometryJsonDumper.h
Layer.h
RectangleBounds.h
Surface.h
TrackingGeometry.h
Trk::BinnedArray::arrayObjects
virtual std::span< T *const > arrayObjects()=0
Return all objects of the Array non-const we can still modify the T.
Trk::GeometryJsonDumper::m_outputFile
std::ofstream m_outputFile
Definition
GeometryJsonDumper.h:62
Trk::GeometryJsonDumper::m_outputFileName
Gaudi::Property< std::string > m_outputFileName
Definition
GeometryJsonDumper.h:64
Trk::GeometryJsonDumper::m_firstLayerWritten
bool m_firstLayerWritten
Definition
GeometryJsonDumper.h:65
Trk::GeometryJsonDumper::finalize
StatusCode finalize()
AlgTool finalize method.
Definition
GeometryJsonDumper.cxx:35
Trk::GeometryJsonDumper::initialize
StatusCode initialize()
AlgTool initialize method.
Definition
GeometryJsonDumper.cxx:24
Trk::GeometryJsonDumper::processNode
StatusCode processNode(const TrackingVolume &tvol, size_t level=0) const
Current implementation: write root visualization to file stream.
Definition
GeometryJsonDumper.cxx:46
Trk::LayerIndex::value
int value() const
layerIndex expressed in an integer
Definition
LayerIndex.h:71
Trk::Layer
Base Class for a Detector Layer in the Tracking realm.
Definition
Layer.h:72
Trk::Layer::surfaceArray
const SurfaceArray * surfaceArray() const
Return the entire SurfaceArray, returns nullptr if no SurfaceArray.
Trk::Layer::layerIndex
const LayerIndex & layerIndex() const
get the layerIndex
Trk::Layer::subSurfaceReference
const Surface * subSurfaceReference(unsigned int idx=0) const
Return a reference sub surface of the layer, usually the first one in the array.
Definition
Layer.cxx:117
Trk::RectangleBounds
Bounds for a rectangular, planar surface.
Definition
RectangleBounds.h:38
Trk::RectangleBounds::halflengthX
double halflengthX() const
for consistant naming
Trk::RectangleBounds::halflengthY
double halflengthY() const
for consitant naming
Trk::Surface
Abstract Base Class for tracking surfaces.
Definition
Surface.h:79
Trk::Surface::bounds
virtual const SurfaceBounds & bounds() const =0
Surface Bounds method.
Trk::TrackingVolume
Full Volume description used in Tracking, it inherits from Volume to get the geometrical structure,...
Definition
TrackingVolume.h:119
Generated on
for ATLAS Offline Software by
1.17.0