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