ATLAS Offline Software
Loading...
Searching...
No Matches
WriteTrackingGeometry.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
5
6// ATHENA
8
9// PACKAGE
10
11#include "ActsPlugins/Json/TrackingGeometryJsonConverter.hpp"
12
13// STL
14#include <fstream>
15#include <iostream>
16
17namespace ActsTrk{
18
20 ATH_MSG_INFO("initializing");
21
23 ATH_CHECK(m_ctxProvider.initialize());
24
25 return StatusCode::SUCCESS;
26}
27
28StatusCode WriteTrackingGeometry::execute(const EventContext& ctx) {
29
30 if (m_dumped) {
31 return StatusCode::SUCCESS;
32 }
33 std::ofstream outFile{m_outFile};
34 if (!outFile.good()) {
35 ATH_MSG_FATAL("Failed to open "<<m_outFile);
36 return StatusCode::FAILURE;
37 }
38
39
40 m_dumped = true;
41
43 const Acts::GeometryContext tgContext = m_ctxProvider.getGeometryContext(ctx);
44
45 using Config_t = Acts::TrackingGeometryJsonConverter::Config;
46
47 Config_t cfg = Config_t::defaultConfig();
48
49 Acts::TrackingGeometryJsonConverter converter{cfg, makeActsAthenaLogger(this, name())};
50
51
52 nlohmann::json trackGeo = converter.toJson(tgContext, *m_trackingGeometrySvc->trackingGeometry());
53
54
55 outFile<<trackGeo.dump(4);
56
57 ATH_MSG_INFO("Dump tracking geometry JSON: "<<m_outFile);
58
59 return StatusCode::SUCCESS;
60}
61
62
63}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
std::unique_ptr< const Acts::Logger > makeActsAthenaLogger(IMessageSvc *svc, const std::string &name, int level, std::optional< std::string > parent_name)
ServiceHandle< ActsTrk::ITrackingGeometrySvc > m_trackingGeometrySvc
Gaudi::Property< std::string > m_outFile
virtual StatusCode execute(const EventContext &ctx) override
Execute method.
ActsTrk::ContextUtility m_ctxProvider
Context provider for geometry, magnetic field and calibration contexts.
virtual StatusCode initialize() override
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...