ATLAS Offline Software
Loading...
Searching...
No Matches
GeometryTTreeDumper.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 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
24// constructor
25Trk::GeometryTTreeDumper::GeometryTTreeDumper(const std::string& t, const std::string& n, const IInterface* p) :
27 m_currentTree(nullptr),
28 m_treeFolder("/val/")
29{}
30
31// destructor
33= default;
34
35
37{
38 ATH_MSG_VERBOSE("Dumping information for TrackingVolume.");
39 // clean up from the previous event
40 if (m_currentTree) m_currentTree->Fill();
41
42 // create the Tree for this TrackingVolume
43 m_currentTree = new TTree(tvol.volumeName().c_str(),"Geometrical information");
44 SmartIF<ITHistSvc> tHistSvc{service("THistSvc")};
45 if (!tHistSvc) {
46 ATH_MSG_FATAL( "initialize() Could not find Hist Service! Aborting." );
47 delete m_currentTree;
48 return StatusCode::FAILURE;
49 }
50 // create the name under which the tree is registered
51 std::string fullTreeName = m_treeFolder+tvol.volumeName();
52 if (tHistSvc->regTree(fullTreeName.c_str(), m_currentTree).isFailure()) {
53 ATH_MSG_ERROR( "initialize() Could not register the validation Tree!Aborting." );
54 delete m_currentTree;
55 return StatusCode::FAILURE;
56 }
57
58 // make the boundary surface branch
59 Trk::SurfaceNtupleBranch boundarySurfaceBranch;
60
61 const auto& bSurfaces = tvol.boundarySurfaces();
62 for (size_t ib = 0 ; ib < bSurfaces.size(); ++ib ){
63 TString bSurfId = "bsurf_";
64 bSurfId += ib;
65 // initialize
66 boundarySurfaceBranch.initForWrite(*m_currentTree,bSurfId.Data());
67 boundarySurfaceBranch.fill(bSurfaces[ib]->surfaceRepresentation());
68 }
69
70 return StatusCode::SUCCESS;
71}
72
73
74StatusCode Trk::GeometryTTreeDumper::processNode(const Trk::Layer& lay, size_t) const
75{
76
77 ATH_MSG_VERBOSE("Dumping information for Layer.");
78
79 // make the layer branch
80 Trk::SurfaceNtupleBranch layerBranch;
81 TString layerId = "lay_";
82 layerId += lay.layerIndex().value();
83 // initialize
84 layerBranch.initForWrite(*m_currentTree,layerId.Data());
85 layerBranch.fill(lay.surfaceRepresentation());
86
87 return StatusCode::SUCCESS;
88}
89
90
91StatusCode Trk::GeometryTTreeDumper::processNode(const Trk::Surface& sf, size_t) const
92{
93 ATH_MSG_VERBOSE("Dumping information for Surfaces.");
94
95 // make the surface branch
96 Trk::SurfaceNtupleBranch surfaceBranch;
97 TString surfaceId = "surf";
98 // initialize
99 surfaceBranch.initForWrite(*m_currentTree,surfaceId.Data());
100 surfaceBranch.fill(sf);
101
102 return StatusCode::SUCCESS;
103}
104
105
106
107
108
#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.
virtual ~GeometryTTreeDumper()
Destructor.
GeometryTTreeDumper(const std::string &, const std::string &, const IInterface *)
Constructor.
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
RecursiveGeometryProcessor(const std::string &, const std::string &, const IInterface *)
Constructor.
Abstract Base Class for tracking surfaces.
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.
Ensure that the ATLAS eigen extensions are properly loaded.
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