ATLAS Offline Software
Loading...
Searching...
No Matches
JSONDeviceMagFieldProviderSvc.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
6
8
9#include "traccc/io/read_magnetic_field.hpp"
10
11#include <string>
12
13namespace ActsTrk {
14
16{
17 ATH_MSG_DEBUG("Initializing device magnetic field provider service ");
18
20 ATH_CHECK(m_detStore.retrieve());
21
22 traccc::magnetic_field hostMagField;
23
24 if (m_magFieldFile.value().empty()) {
25 ATH_MSG_FATAL("MagFieldFile is empty!");
26 return StatusCode::FAILURE;
27 }
28
29 ATH_MSG_INFO("Reading mag field from file: " << PathResolverFindCalibFile(m_magFieldFile.value()));
30
31 // Construct host magnetic field
32 ATH_MSG_INFO("Loading traccc magnetic field");
33 traccc::io::read_magnetic_field(
34 hostMagField,
36
37 ATH_MSG_INFO("Magnetic field built from file");
38
39 // Construct device field
40 traccc::magnetic_field deviceMagField = m_deviceFieldProviderTool->getDeviceMagneticField(hostMagField);
41
42 // Record host and device objects
43 constexpr bool allowMods = false;
44 ATH_CHECK(m_detStore->record(
45 std::make_unique<traccc::magnetic_field>(std::move(hostMagField)),
46 m_hostMagFieldObjectName.value(), allowMods));
47
48 ATH_CHECK(m_detStore->record(
49 std::make_unique<traccc::magnetic_field>(std::move(deviceMagField)),
50 m_deviceMagFieldObjectName.value(), allowMods));
51
52
53 ATH_MSG_DEBUG("Successfully initialized");
54 return StatusCode::SUCCESS;
55}
56
57
58} // namespace ActsTrk
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
virtual StatusCode initialize() override
Function initializing and executing the file loading.
ToolHandle< ActsTrk::IDeviceMagFieldProviderTool > m_deviceFieldProviderTool
The device magnetic field provider tool.
Gaudi::Property< std::string > m_hostMagFieldObjectName
Gaudi::Property< std::string > m_deviceMagFieldObjectName
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...