ATLAS Offline Software
ActsObjWriterTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 // std
8 #include <iostream>
9 #include <vector>
10 
11 // Gaudi / Athena
12 #include "GaudiKernel/IInterface.h"
13 
15 // ACTS
16 #include "Acts/Geometry/TrackingGeometry.hpp"
17 
18 // PRIVATE
19 #include "util/ObjSurfaceWriter.h"
21 
22 
23 ActsObjWriterTool::ActsObjWriterTool(const std::string& type, const std::string& name,
24  const IInterface* parent)
26 {
27  // declareProperty("OutputDirectory", m_outputDirectory = "");
28  // declareProperty("SubDetectors", m_subDetectors = {});
29 }
30 
33 {
34 
35 
36  return StatusCode::SUCCESS;
37 }
38 
39 void
40 ActsObjWriterTool::write(const ActsGeometryContext& gctx, const Acts::TrackingGeometry& tg) const
41 {
42  const auto& ctx = Gaudi::Hive::currentContext();
43  std::stringstream ss;
44  ss << ctx.eventID().run_number() << "_" << ctx.eventID().event_number();
45 
46  using namespace std::string_literals;
47 
48  std::vector<std::shared_ptr<Acts::ObjSurfaceWriter>> subWriters;
49  std::vector<std::shared_ptr<std::ofstream>> subStreams;
50 
51  for (const auto& sdet : m_subDetectors) {
52  auto sdStream = std::shared_ptr<std::ofstream>(new std::ofstream);
53  std::string sdOutputName = m_outputDirectory + "/"s + sdet + "_" + ss.str() + ".obj"s;
54  sdStream->open(sdOutputName);
55  // object surface writers
56  Acts::ObjSurfaceWriter::Config sdObjWriterConfig(sdet,
58  sdObjWriterConfig.filePrefix = "";
59  sdObjWriterConfig.outputPhiSegments = 10;
60  sdObjWriterConfig.outputPrecision = 6;
61  sdObjWriterConfig.outputScalor = 1.;
62  sdObjWriterConfig.outputThickness = 1.;
63  sdObjWriterConfig.outputSensitive = true;
64  sdObjWriterConfig.outputLayerSurface = false;
65  sdObjWriterConfig.outputStream = sdStream;
66  auto sdObjWriter
67  = std::make_shared<Acts::ObjSurfaceWriter>(sdObjWriterConfig);
68  // push back
69  subWriters.push_back(sdObjWriter);
70  subStreams.push_back(sdStream);
71  }
72 
73 
74  // configure the tracking geometry writer
76  "ObjTrackingGeometryWriter", Acts::Logging::INFO);
77  tgObjWriterConfig.surfaceWriters = subWriters;
78  tgObjWriterConfig.filePrefix = "";
79  tgObjWriterConfig.sensitiveGroupPrefix = "";
80  tgObjWriterConfig.layerPrefix = "";
81  // the tracking geometry writers
82  auto tgObjWriter
83  = std::make_shared<Acts::ObjTrackingGeometryWriter>(tgObjWriterConfig);
84 
85  tgObjWriter->write(gctx.context(), tg);
86 }
ActsObjWriterTool::m_subDetectors
Gaudi::Property< std::vector< std::string > > m_subDetectors
Definition: ActsObjWriterTool.h:44
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
Acts::ObjTrackingGeometryWriter::Config
Definition: ObjTrackingGeometryWriter.h:32
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
ActsObjWriterTool::m_outputDirectory
Gaudi::Property< std::string > m_outputDirectory
Definition: ActsObjWriterTool.h:43
ActsGeometryContext.h
Acts::ObjSurfaceWriter::Config::outputScalor
double outputScalor
output scalor
Definition: ObjSurfaceWriter.h:45
Acts::ObjSurfaceWriter::Config::filePrefix
std::string filePrefix
file prefix to be written out
Definition: ObjSurfaceWriter.h:49
ActsObjWriterTool.h
Acts::ObjTrackingGeometryWriter::Config::layerPrefix
std::string layerPrefix
Definition: ObjTrackingGeometryWriter.h:42
ActsObjWriterTool::initialize
StatusCode initialize() override
Definition: ActsObjWriterTool.cxx:32
Acts::ObjSurfaceWriter::Config::outputLayerSurface
bool outputLayerSurface
write the layer surface out
Definition: ObjSurfaceWriter.h:43
ActsGeometryContext::context
Acts::GeometryContext context() const
Definition: ActsGeometryContext.h:45
Acts::ObjSurfaceWriter::Config::outputPrecision
unsigned int outputPrecision
precision for out
Definition: ObjSurfaceWriter.h:47
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Acts::ObjSurfaceWriter::Config::outputThickness
double outputThickness
write thickness if available
Definition: ObjSurfaceWriter.h:39
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ActsObjWriterTool::write
void write(const ActsGeometryContext &gctx, const Acts::TrackingGeometry &) const
Definition: ActsObjWriterTool.cxx:40
ActsGeometryContext
Include the GeoPrimitives which need to be put first.
Definition: ActsGeometryContext.h:27
Acts::ObjTrackingGeometryWriter::Config::sensitiveGroupPrefix
std::string sensitiveGroupPrefix
Definition: ObjTrackingGeometryWriter.h:41
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
Acts::ObjSurfaceWriter::Config::outputPhiSegments
unsigned int outputPhiSegments
approximate cyinders by that
Definition: ObjSurfaceWriter.h:37
ObjTrackingGeometryWriter.h
Acts::ObjSurfaceWriter::Config::outputSensitive
bool outputSensitive
write sensitive surfaces
Definition: ObjSurfaceWriter.h:41
Acts::ObjSurfaceWriter::Config::outputStream
std::shared_ptr< std::ofstream > outputStream
the output stream
Definition: ObjSurfaceWriter.h:56
ActsObjWriterTool::ActsObjWriterTool
ActsObjWriterTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: ActsObjWriterTool.cxx:23
python.Constants.INFO
int INFO
Definition: Control/AthenaCommon/python/Constants.py:16
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
Acts::ObjSurfaceWriter::Config
Definition: ObjSurfaceWriter.h:30
Acts::ObjTrackingGeometryWriter::Config::filePrefix
std::string filePrefix
Definition: ObjTrackingGeometryWriter.h:40
AthAlgTool
Definition: AthAlgTool.h:26
ObjSurfaceWriter.h
Acts::ObjTrackingGeometryWriter::Config::surfaceWriters
std::vector< std::shared_ptr< ObjSurfaceWriter > > surfaceWriters
surfaceWriters
Definition: ObjTrackingGeometryWriter.h:39