ATLAS Offline Software
DetectorAlignCondAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 #include "DetectorAlignCondAlg.h"
5 
8 #include "GeoModelHelpers/TransformToStringConverter.h"
9 
10 #include "GeoModelKernel/GeoClearAbsPosAction.h"
11 
12 using namespace ActsTrk;
13 
15 
18  ATH_CHECK(m_outputKey.initialize());
21  ATH_CHECK(m_trackingGeoSvc.retrieve());
22  }
23 
24  try {
25  m_Type = static_cast<DetectorType>(m_detType.value());
26  } catch (const std::exception& what) {
27  ATH_MSG_FATAL("Invalid detType is configured " << m_detType);
28  return StatusCode::FAILURE;
29  }
31  ATH_MSG_FATAL("Please configure the deType " << m_detType << " to be something not undefined");
32  return StatusCode::FAILURE;
33  }
34  return StatusCode::SUCCESS;
35 }
36 
37 StatusCode DetectorAlignCondAlg::execute(const EventContext& ctx) const {
38  SG::WriteCondHandle writeHandle{m_outputKey, ctx};
39  if (writeHandle.isValid()) {
40  ATH_MSG_DEBUG("Nothing needs to be done for " << ctx.eventID().event_number());
41  return StatusCode::SUCCESS;
42  }
43  SG::ReadCondHandle readHandle{m_inputKey, ctx};
44  if (!readHandle.isValid()) {
45  ATH_MSG_FATAL("Failed to retrieve " << m_inputKey.fullKey());
46  return StatusCode::FAILURE;
47  }
48  writeHandle.addDependency(readHandle);
50  auto newAlignment = std::make_unique<DetectorAlignStore>(m_Type);
51  newAlignment->geoModelAlignment = std::make_unique<GeoAlignmentStore>(**readHandle);
52  newAlignment->geoModelAlignment->clearPosCache();
54  if (m_fillAlignStoreCache) {
55  if(!m_trackingGeoSvc->populateAlignmentStore(*newAlignment)) {
56  ATH_MSG_WARNING("No detector elements of " << to_string(m_Type) << " are part of the tracking geometry");
57  }
59  newAlignment->geoModelAlignment.reset();
60  }
61  ATH_CHECK(writeHandle.record(std::move(newAlignment)));
62  return StatusCode::SUCCESS;
63 }
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ActsTrk::DetectorType
DetectorType
Simple enum to Identify the Type of the ACTS sub detector.
Definition: GeometryDefs.h:17
ActsTrk::DetectorAlignCondAlg::m_fillAlignStoreCache
Gaudi::Property< bool > m_fillAlignStoreCache
Flag toggling whether the alignment store shall be filled with the transforms or not.
Definition: DetectorAlignCondAlg.h:44
ActsTrk::DetectorType::UnDefined
@ UnDefined
Small Thing Gap chambers (NSW)
ActsTrk::DetectorAlignCondAlg::execute
StatusCode execute(const EventContext &ctx) const override final
Definition: DetectorAlignCondAlg.cxx:37
ActsTrk::DetectorAlignCondAlg::m_detType
Gaudi::Property< int > m_detType
Flag determining the subdetector. Needs to be static castable to DetectorType.
Definition: DetectorAlignCondAlg.h:42
ActsTrk::DetectorAlignCondAlg::m_trackingGeoSvc
ServiceHandle< ActsTrk::ITrackingGeometrySvc > m_trackingGeoSvc
ServiceHandle to the ActsTrackingGeometry.
Definition: DetectorAlignCondAlg.h:40
ReadCondHandle.h
ActsTrk::DetectorAlignCondAlg::initialize
StatusCode initialize() override final
Definition: DetectorAlignCondAlg.cxx:16
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
WriteCondHandle.h
DetectorAlignCondAlg.h
calibdata.exception
exception
Definition: calibdata.py:495
ActsTrk::DetectorAlignCondAlg::m_Type
DetectorType m_Type
Static cast of >DetectorType< property.
Definition: DetectorAlignCondAlg.h:46
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ActsTrk::DetectorAlignCondAlg::m_inputKey
SG::ReadCondHandleKey< GeoAlignmentStore > m_inputKey
Key to the alignment transformations for the detector volumes.
Definition: DetectorAlignCondAlg.h:36
python.ExitCodes.what
def what(code)
Definition: ExitCodes.py:73
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
ActsTrk::DetectorAlignCondAlg::m_outputKey
SG::WriteCondHandleKey< DetectorAlignStore > m_outputKey
Key to the alignment transformations written by the alg.
Definition: DetectorAlignCondAlg.h:38
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition: MdtCalibInput.h:31
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
ActsTrk::DetectorAlignCondAlg::~DetectorAlignCondAlg
virtual ~DetectorAlignCondAlg()