ATLAS Offline Software
ObjTrackingGeometryWriter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // This file was largely imported from the Acts testing framework
6 
7 
9 
10 #include "Acts/Geometry/TrackingVolume.hpp"
11 #include "Acts/Geometry/TrackingGeometry.hpp"
12 
13 #include "Acts/Surfaces/Surface.hpp"
14 #include "Acts/Geometry/GeometryContext.hpp"
15 
18  : m_cfg(cfg)
19 {
20 }
21 
22 std::string
24 {
25  return m_cfg.name;
26 }
27 
28 void
29 Acts::ObjTrackingGeometryWriter::write(const Acts::GeometryContext& gctx, const Acts::TrackingGeometry& tGeometry)
30 {
31  ACTS_DEBUG(">>Obj: Writer for TrackingGeometry object called.");
32  // get the world volume
33  auto world = tGeometry.highestTrackingVolume();
34  if (world) write(gctx, *world);
35  // return the success code
36 }
37 
39 void
40 Acts::ObjTrackingGeometryWriter::write(const Acts::GeometryContext& gctx, const Acts::TrackingVolume& tVolume)
41 {
42  ACTS_DEBUG(">>Obj: Writer for TrackingVolume object called.");
43  // get the confined layers and process them
44  if (tVolume.confinedLayers()) {
45  ACTS_VERBOSE(">>Obj: Layers are present, process them.");
46  // loop over the layers
47  for (auto layer : tVolume.confinedLayers()->arrayObjects()) {
48  // we jump navigation layers
49  if (layer->layerType() == Acts::navigation) continue;
50  // get the volume name
51  const std::string& volumeName = tVolume.volumeName();
52  // find the right surfacewriter
53  std::shared_ptr<ObjSurfaceWriter> surfaceWriter = nullptr;
54  for (auto writer : m_cfg.surfaceWriters) {
55  // get name and writer
56  auto writerName = writer->name();
57  if (volumeName.find(writerName) != std::string::npos) {
58  // asign the writer
59  surfaceWriter = std::move(writer);
60  // and break
61  break;
62  }
63  }
64  // bail out if you have no surface writer
65  if (!surfaceWriter) return;
66  // layer prefix
67  surfaceWriter->write(m_cfg.layerPrefix);
68  // check for sensitive surfaces
69  if (layer->surfaceArray() && surfaceWriter) {
70  // surfaces
71  surfaceWriter->write(m_cfg.sensitiveGroupPrefix);
72  // loop over the surface
73  for (auto surface : layer->surfaceArray()->surfaces()) {
74  if (surface) surfaceWriter->write(gctx, *surface);
75  }
76  }
77  }
78  }
79  // get the confined volumes and step down the hierarchy
80  if (tVolume.confinedVolumes()) {
81  // loop over the volumes and write what they have
82  for (auto volume : tVolume.confinedVolumes()->arrayObjects()) {
83  write(gctx, *volume.get());
84  }
85  }
86 }
Acts::ObjTrackingGeometryWriter::Config
Definition: ObjTrackingGeometryWriter.h:32
Acts::ObjTrackingGeometryWriter::name
std::string name() const
Framework name() method.
Definition: ObjTrackingGeometryWriter.cxx:23
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
python.ByteStreamConfig.write
def write
Definition: Event/ByteStreamCnvSvc/python/ByteStreamConfig.py:248
Acts::ObjSurfaceWriter::write
void write(const Acts::GeometryContext &gctx, const Acts::Surface &surface)
The write interface.
Definition: ObjSurfaceWriter.cxx:83
ObjTrackingGeometryWriter.h
WriteCaloSwCorrections.cfg
cfg
Definition: WriteCaloSwCorrections.py:23
Acts::ObjTrackingGeometryWriter::write
void write(const Acts::GeometryContext &gctx, const Acts::TrackingGeometry &tGeometry)
The write interface.
Definition: ObjTrackingGeometryWriter.cxx:29
Acts::ObjTrackingGeometryWriter::ObjTrackingGeometryWriter
ObjTrackingGeometryWriter(const Config &cfg)
Constructor.
Definition: ObjTrackingGeometryWriter.cxx:16
example.writer
writer
show summary of content
Definition: example.py:36