ATLAS Offline Software
GeometryTTreeDumper.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 // 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
25 Trk::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  ITHistSvc* tHistSvc = nullptr;
45  if (service("THistSvc",tHistSvc).isFailure()) {
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 
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 
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 
Trk::SurfaceNtupleBranch::fill
void fill(const Trk::Surface &surface)
fill a vector
Definition: SurfaceNtupleBranch.cxx:30
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
Surface.h
Trk::TrackingVolume::boundarySurfaces
std::vector< SharedObject< BoundarySurface< TrackingVolume > > > & boundarySurfaces()
Method to return the BoundarySurfaces.
Definition: TrackingVolume.cxx:982
SurfaceNtupleBranch.h
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
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
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
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.
GeometryTTreeDumper.h
Trk::RecursiveGeometryProcessor
Definition: RecursiveGeometryProcessor.h:39
Trk::SurfaceNtupleBranch::initForWrite
void initForWrite(TTree &tree, const std::string &prefix="")
initialize class for writing
Definition: SurfaceNtupleBranch.cxx:11
Trk::GeometryTTreeDumper::processNode
StatusCode processNode(const TrackingVolume &tvol, size_t level=0) const
Current implementation: write root visualization to file stream.
Definition: GeometryTTreeDumper.cxx:36
Trk::SurfaceNtupleBranch
This class provides a simple interface to write Surfaces to a root tree.
Definition: SurfaceNtupleBranch.h:36
Trk::GeometryTTreeDumper::~GeometryTTreeDumper
virtual ~GeometryTTreeDumper()
Destructor.
Trk::GeometryTTreeDumper::GeometryTTreeDumper
GeometryTTreeDumper(const std::string &, const std::string &, const IInterface *)
Constructor.
Definition: GeometryTTreeDumper.cxx:25
mapkey::sf
@ sf
Definition: TElectronEfficiencyCorrectionTool.cxx:38
TrackingGeometry.h
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
Trk::TrackingVolume
Definition: TrackingVolume.h:121
Trk::Layer
Definition: Layer.h:73
Trk::Layer::layerIndex
const LayerIndex & layerIndex() const
get the layerIndex