ATLAS Offline Software
Loading...
Searching...
No Matches
ContextUtility.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
5
7
10
12
13#include "GeoModelKernel/throwExcept.h"
14
15namespace ActsTrk{
16 StatusCode ContextUtility::initialize(const bool enable) {
17 ATH_CHECK(m_geoCtxKey.initialize(enable && !m_geoCtxKey.empty()));
18 ATH_CHECK(m_magCtxKey.initialize(enable && !m_magCtxKey.empty()));
19 return StatusCode::SUCCESS;
20 }
21
22 MsgStream& ContextUtility::msg(const MSG::Level lvl) const {
23 return m_msgPrinter(lvl);
24 }
25
26 bool ContextUtility::msgLvl(const MSG::Level lvl) const {
27 return m_msgLevel(lvl);
28 }
29
30 Acts::GeometryContext ContextUtility::getGeometryContext(const EventContext& ctx) const {
31 const ActsTrk::GeometryContext* gctx{nullptr};
32 if (!SG::get(gctx, m_geoCtxKey, ctx).isSuccess()) {
33 THROW_EXCEPTION("Failed to retrieve the geometry context "<<m_geoCtxKey.fullKey());
34
35 }
36 if (!gctx) {
37 ATH_MSG_WARNING(__func__<<"() "<<__LINE__<<" - No geometry context passed");
38 return Acts::GeometryContext{gctx};
39 }
40 return gctx->context();
41 }
42
43 Acts::CalibrationContext ContextUtility::getCalibrationContext(const EventContext& ctx) const {
45 }
46
47 Acts::MagneticFieldContext ContextUtility::getMagneticFieldContext(const EventContext& ctx) const {
48 const AtlasFieldCacheCondObj* mctx{nullptr};
49 if (!SG::get(mctx, m_magCtxKey, ctx).isSuccess()) {
50 THROW_EXCEPTION("Failed to retrieve the magnetic field context "<<m_magCtxKey.fullKey());
51
52 }
53 if (!mctx) {
54 ATH_MSG_WARNING(__func__<<"() "<<__LINE__<<" - No magentic field context passed");
55 }
56 return Acts::MagneticFieldContext{mctx};
57 }
58}
59
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
Handle class for reading from StoreGate.
SG::ReadCondHandleKey< AtlasFieldCacheCondObj > m_magCtxKey
Data dependency on the magnetic field map.
Acts::MagneticFieldContext getMagneticFieldContext(const EventContext &ctx) const
Retrieves the current magnetic field context from StoreGate.
bool msgLvl(const MSG::Level lvl) const
Returns whether the stream satisfies the logging level.
Acts::GeometryContext getGeometryContext(const EventContext &ctx) const
Retrieves the current geometry context from StoreGate.
Acts::CalibrationContext getCalibrationContext(const EventContext &ctx) const
Retrieves the current calibration context from StoreGate.
std::function< bool(const MSG::Level)> m_msgLevel
Lambda to return the msg level from the parent's msg stream.
GeoContextReadKey_t m_geoCtxKey
Data dependency on the aligned geometry transforms.
StatusCode initialize(const bool enable=true)
Initializes the ReadHandleKeys held by the utility class.
MsgStream & msg(const MSG::Level lvl) const
Return the reference to the msg logging stream.
std::function< MsgStream &(const MSG::Level)> m_msgPrinter
Lambda to access the parent's msg stream.
Acts::GeometryContext context() const
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Acts::CalibrationContext getCalibrationContext(const EventContext &ctx)
The Acts::Calibration context is piped through the Acts fitters to (re)calibrate the Acts::SourceLink...
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
#define THROW_EXCEPTION(MESSAGE)
Definition throwExcept.h:10