ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ObjTrackingGeometryWriter.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ObjTrackingGeometryWriter.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
10 
11 #include <Acts/Geometry/Layer.hpp>
15 #include <iostream>
16 
19  : m_cfg(cfg) {}
20 
22  return m_cfg.name;
23 }
24 
27  ACTS_DEBUG(">>Obj: Writer for TrackingGeometry object called.");
28  // get the world volume
29  auto world = tGeometry.highestTrackingVolume();
30  if (world)
31  write(context, *world);
32  // return the success code
34 }
35 
38  const AlgorithmContext& context, const Acts::TrackingVolume& tVolume) {
39  ACTS_DEBUG(">>Obj: Writer for TrackingVolume object called.");
40  // get the confined layers and process them
41  if (tVolume.confinedLayers()) {
42  ACTS_VERBOSE(">>Obj: Layers are present, process them.");
43  // loop over the layers
44  for (auto layer : tVolume.confinedLayers()->arrayObjects()) {
45  // we jump navigation layers
46  if (layer->layerType() == Acts::navigation)
47  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  // and break
56  ACTS_VERBOSE(">>Obj: The writer name is: " << writerName);
57  ACTS_VERBOSE(">>Obj: The volume name is: " << volumeName);
58  if (volumeName.find(writerName) != std::string::npos) {
59  // asign the writer
60  surfaceWriter = writer;
61  // break the loop
62  break;
63  }
64  }
65  // bail out if you have no surface writer
66  if (!surfaceWriter)
67  return;
68  // layer prefix
69  surfaceWriter->write(m_cfg.layerPrefix);
70  // try to write the material surface as well
71  if (layer->surfaceRepresentation().surfaceMaterial()) {
72  surfaceWriter->write(context, layer->surfaceRepresentation());
73  }
74  // the the approaching surfaces and check if they have material
75  if (layer->approachDescriptor()) {
76  // loop over the contained Surfaces
77  for (auto& cSurface : layer->approachDescriptor()->containedSurfaces())
78  if (cSurface->surfaceMaterial()) {
79  surfaceWriter->write(context, *cSurface);
80  }
81  }
82  // check for sensitive surfaces
83  if (layer->surfaceArray() && surfaceWriter) {
84  ACTS_VERBOSE(">>Obj: There are "
85  << layer->surfaceArray()->surfaces().size()
86  << " surfaces.");
87  // surfaces
88  // surfaceWriter->write(m_cfg.sensitiveGroupPrefix);
89  // loop over the surface
90  for (auto& surface : layer->surfaceArray()->surfaces()) {
91  if (surface && (surfaceWriter->write(context, *surface)) ==
92  FW::ProcessCode::ABORT)
93  return;
94  }
95  }
96  }
97  }
98  // Recursive self call
99  // get the confined volumes and step down the hierarchy
100  if (tVolume.confinedVolumes()) {
101  // loop over the volumes and write what they have
102  for (auto volume : tVolume.confinedVolumes()->arrayObjects()) {
103  write(context, *volume.get());
104  }
105  }
106 }