ATLAS Offline Software
Loading...
Searching...
No Matches
GeometryTTreeDumper.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// GeometryTTreeDumper.cxx, (c) ATLAS Detector software
8
9// Trk include
13#include "TrkGeometry/Layer.h"
14#include "TrkSurfaces/Surface.h"
15// Root
16#include "TTree.h"
17#include "TString.h"
18#include <sstream>
19
20// Gaudi
21#include "GaudiKernel/ITHistSvc.h"
22
23
25{
26 ATH_MSG_VERBOSE("Dumping information for TrackingVolume.");
27 // clean up from the previous event
28 if (m_currentTree) m_currentTree->Fill();
29
30 // create the Tree for this TrackingVolume
31 m_currentTree = new TTree(tvol.volumeName().c_str(),"Geometrical information");
32 SmartIF<ITHistSvc> tHistSvc{service("THistSvc")};
33 if (!tHistSvc) {
34 ATH_MSG_FATAL( "initialize() Could not find Hist Service! Aborting." );
35 delete m_currentTree;
36 return StatusCode::FAILURE;
37 }
38 // create the name under which the tree is registered
39 std::string fullTreeName = m_treeFolder+tvol.volumeName();
40 if (tHistSvc->regTree(fullTreeName.c_str(), m_currentTree).isFailure()) {
41 ATH_MSG_ERROR( "initialize() Could not register the validation Tree!Aborting." );
42 delete m_currentTree;
43 return StatusCode::FAILURE;
44 }
45
46 // make the boundary surface branch
47 Trk::SurfaceNtupleBranch boundarySurfaceBranch;
48
49 const auto& bSurfaces = tvol.boundarySurfaces();
50 for (size_t ib = 0 ; ib < bSurfaces.size(); ++ib ){
51 TString bSurfId = "bsurf_";
52 bSurfId += ib;
53 // initialize
54 boundarySurfaceBranch.initForWrite(*m_currentTree,bSurfId.Data());
55 boundarySurfaceBranch.fill(bSurfaces[ib]->surfaceRepresentation());
56 }
57
58 return StatusCode::SUCCESS;
59}
60
61
62StatusCode Trk::GeometryTTreeDumper::processNode(const Trk::Layer& lay, size_t) const
63{
64
65 ATH_MSG_VERBOSE("Dumping information for Layer.");
66
67 // make the layer branch
68 Trk::SurfaceNtupleBranch layerBranch;
69 TString layerId = "lay_";
70 layerId += lay.layerIndex().value();
71 // initialize
72 layerBranch.initForWrite(*m_currentTree,layerId.Data());
73 layerBranch.fill(lay.surfaceRepresentation());
74
75 return StatusCode::SUCCESS;
76}
77
78
79StatusCode Trk::GeometryTTreeDumper::processNode(const Trk::Surface& sf, size_t) const
80{
81 ATH_MSG_VERBOSE("Dumping information for Surfaces.");
82
83 // make the surface branch
84 Trk::SurfaceNtupleBranch surfaceBranch;
85 TString surfaceId = "surf";
86 // initialize
87 surfaceBranch.initForWrite(*m_currentTree,surfaceId.Data());
88 surfaceBranch.fill(sf);
89
90 return StatusCode::SUCCESS;
91}
92
93
94
95
96
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_VERBOSE(x)
StatusCode processNode(const TrackingVolume &tvol, size_t level=0) const
Current implementation: write root visualization to file stream.
TTree * m_currentTree
the tree for the currently processed tracking Volume
std::string m_treeFolder
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 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,...
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.
This class provides a simple interface to write Surfaces to a root tree.
void initForWrite(TTree &tree, const std::string &prefix="")
initialize class for writing
void fill(const Trk::Surface &surface)
fill a vector