13 #include "Acts/Geometry/Layer.hpp"
14 #include "Acts/Surfaces/CylinderBounds.hpp"
15 #include "Acts/Surfaces/PlanarBounds.hpp"
16 #include "Acts/Surfaces/RadialBounds.hpp"
17 #include "Acts/Surfaces/SurfaceBounds.hpp"
18 #include "Acts/Geometry/GeometryIdentifier.hpp"
20 #include "Acts/Geometry/Polyhedron.hpp"
21 #include "Acts/Surfaces/CylinderSurface.hpp"
22 #include "Acts/Surfaces/StrawSurface.hpp"
27 std::string objString(
const Acts::Polyhedron& polyhedron,
size_t vtxOffset) {
28 std::stringstream sstr;
30 for (
const auto& vtx : polyhedron.vertices) {
31 sstr <<
"v " << vtx.x() <<
" " << vtx.y() <<
" " << vtx.z() << std::endl;
34 for (
const auto& face : polyhedron.faces) {
36 for (
const auto&
idx : face) {
37 sstr <<
" " << (vtxOffset +
idx + 1);
57 throw std::invalid_argument(
"Missing logger");
59 throw std::invalid_argument(
"Missing algorithm name");
61 throw std::invalid_argument(
"Missing output stream");
77 std::lock_guard<std::mutex> lock(m_write_mutex);
79 (*m_cfg.outputStream) << sinfo;
84 const Acts::Surface &surface)
86 std::lock_guard<std::mutex> lock(m_write_mutex);
89 ACTS_DEBUG(
">>Obj: Writer for Surface object called.");
91 auto scalor = m_cfg.outputScalor;
93 const Acts::SurfaceBounds& surfaceBounds = surface.bounds();
94 auto sTransform = surface.transform(gctx);
97 const Acts::PlanarBounds* planarBounds
98 =
dynamic_cast<const Acts::PlanarBounds*
>(&surfaceBounds);
100 const Acts::CylinderBounds* cylinderBounds
101 =
dynamic_cast<const Acts::CylinderBounds*
>(&surfaceBounds);
103 const Acts::StrawSurface* strawSurface
104 =
dynamic_cast<const Acts::StrawSurface*
>(&surface);
107 if (m_cfg.outputSensitive) {
109 ACTS_VERBOSE(
">>Obj: Writing out a PlaneSurface");
111 (*(m_cfg.outputStream)) <<
'\n';
112 (*(m_cfg.outputStream)) << std::setprecision(m_cfg.outputPrecision);
114 auto planarVertices = planarBounds->vertices();
116 std::vector<Acts::Vector3> vertices;
117 vertices.reserve(planarVertices.size());
118 for (
auto pv : planarVertices) {
120 Acts::Vector3 v3D(sTransform * Acts::Vector3(
pv.x(),
pv.y(), 0.));
121 vertices.push_back(v3D);
124 double thickness = 0.;
125 std::vector<unsigned int> vfaces;
126 if (surface.associatedDetectorElement()) {
128 thickness = surface.associatedDetectorElement()->thickness();
129 vfaces = {1, 1, 1, 1};
138 (*(m_cfg.outputStream)) <<
'\n';
140 else if(cylinderBounds) {
142 auto cylinderSurface =
dynamic_cast<const Acts::CylinderSurface*
>(&surface);
143 if (cylinderSurface ==
nullptr) {
144 ACTS_ERROR(
"Unable to dynamic cast surface to Acts::CylinderSurface");
148 Acts::Polyhedron ph =
149 cylinderSurface->polyhedronRepresentation(gctx, 10);
150 (*(m_cfg.outputStream)) << objString(ph, m_vtnCounter.vcounter);
151 m_vtnCounter.vcounter += ph.vertices.size();
154 else if(strawSurface) {
156 Acts::Polyhedron ph =
157 strawSurface->polyhedronRepresentation(gctx, 10);
158 (*(m_cfg.outputStream)) << objString(ph, m_vtnCounter.vcounter);
159 m_vtnCounter.vcounter += ph.vertices.size();
163 ACTS_ERROR(
"Unable to print this bounds type: " << surfaceBounds.type());
169 if (cylinderBounds && m_cfg.outputLayerSurface) {
170 ACTS_VERBOSE(
">>Obj: Writing out a CylinderSurface with r = "
171 << cylinderBounds->get(Acts::CylinderBounds::eR));
173 auto layerID = surface.geometryId().layer();
174 (*(m_cfg.outputStream))
180 m_cfg.outputPhiSegments,
182 cylinderBounds->get(Acts::CylinderBounds::eR),
183 cylinderBounds->get(Acts::CylinderBounds::eHalfLengthZ),
184 m_cfg.outputThickness);
185 (*(m_cfg.outputStream)) <<
'\n';
189 const Acts::RadialBounds* radialBounds
190 =
dynamic_cast<const Acts::RadialBounds*
>(&surfaceBounds);
191 if (radialBounds && m_cfg.outputLayerSurface) {
192 ACTS_VERBOSE(
">>Obj: Writing out a DiskSurface at z = "
193 << sTransform.translation().z());
195 auto layerID = surface.geometryId().layer();
196 (*(m_cfg.outputStream)) <<
"o Disk_" <<
std::to_string(layerID) <<
'\n';
198 double rMin = radialBounds->rMin();
199 double rMax = radialBounds->rMax();
200 double thickness = rMax - rMin;
205 m_cfg.outputPhiSegments,
208 m_cfg.outputThickness,
210 (*(m_cfg.outputStream)) <<
'\n';