ATLAS Offline Software
DetectorAlignCondAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 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 DetectorAlignCondAlg::DetectorAlignCondAlg(const std::string& name, ISvcLocator* pSvcLocator) :
14  AthReentrantAlgorithm(name, pSvcLocator) {}
15 
17 
20  ATH_CHECK(m_outputKey.initialize());
23  if(m_loadTrkGeoSvc) {
24  ATH_CHECK(m_trackingGeoSvc.retrieve());
25  }
26  if (m_loadDetVolSvc) {
27  ATH_CHECK(m_detVolSvc.retrieve());
28  }
29  }
30 
31  try {
32  m_Type = static_cast<DetectorType>(m_detType.value());
33  } catch (const std::exception& what) {
34  ATH_MSG_FATAL("Invalid detType is configured " << m_detType);
35  return StatusCode::FAILURE;
36  }
38  ATH_MSG_FATAL("Please configure the deType " << m_detType << " to be something not undefined");
39  return StatusCode::FAILURE;
40  }
41  return StatusCode::SUCCESS;
42 }
43 
44 StatusCode DetectorAlignCondAlg::execute(const EventContext& ctx) const {
46  if (writeHandle.isValid()) {
47  ATH_MSG_DEBUG("Nothing needs to be done for " << ctx.eventID().event_number());
48  return StatusCode::SUCCESS;
49  }
51  if (!readHandle.isValid()) {
52  ATH_MSG_FATAL("Failed to retrieve " << m_inputKey.fullKey());
53  return StatusCode::FAILURE;
54  }
55  writeHandle.addDependency(readHandle);
57  std::unique_ptr<DetectorAlignStore> newAlignment = std::make_unique<DetectorAlignStore>(m_Type);
58  newAlignment->geoModelAlignment = std::make_unique<GeoAlignmentStore>(**readHandle);
59  newAlignment->geoModelAlignment->clearPosCache();
62 
63  if(m_loadTrkGeoSvc && !m_trackingGeoSvc->populateAlignmentStore(*newAlignment)) {
64  ATH_MSG_WARNING("No detector elements of " << to_string(m_Type) << " are part of the tracking geometry");
65  }
66  if (m_loadDetVolSvc && !m_detVolSvc->populateAlignmentStore(*newAlignment)) {
67  ATH_MSG_WARNING("No detector elements of " << to_string(m_Type) << " are part of the detector tracking volumes");
68  }
70  newAlignment->geoModelAlignment.reset();
71  }
72  ATH_CHECK(writeHandle.record(std::move(newAlignment)));
73  return StatusCode::SUCCESS;
74 }
ActsTrk::DetectorAlignCondAlg::m_loadTrkGeoSvc
Gaudi::Property< bool > m_loadTrkGeoSvc
Definition: DetectorAlignCondAlg.h:51
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ActsTrk::DetectorAlignStore::geoModelAlignment
std::shared_ptr< GeoAlignmentStore > geoModelAlignment
Store containing the aligned GeoModel nodes.
Definition: DetectorAlignStore.h:31
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:47
ActsTrk::DetectorType::UnDefined
@ UnDefined
Small Thing Gap chambers (NSW)
ActsTrk::DetectorAlignCondAlg::m_trackingGeoSvc
ServiceHandle< IActsTrackingGeometrySvc > m_trackingGeoSvc
ServiceHandle to the ActsTrackingGeometry.
Definition: DetectorAlignCondAlg.h:41
ActsTrk::DetectorAlignCondAlg::execute
StatusCode execute(const EventContext &ctx) const override final
Definition: DetectorAlignCondAlg.cxx:44
ActsTrk::DetectorAlignCondAlg::m_detType
Gaudi::Property< int > m_detType
Flag determining the subdetector. Needs to be static castable to DetectorType.
Definition: DetectorAlignCondAlg.h:45
ReadCondHandle.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
ActsTrk::DetectorAlignCondAlg::initialize
StatusCode initialize() override final
Definition: DetectorAlignCondAlg.cxx:18
ActsTrk::DetectorAlignCondAlg::DetectorAlignCondAlg
DetectorAlignCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Standard constructor.
Definition: DetectorAlignCondAlg.cxx:13
ActsTrk::DetectorAlignCondAlg::m_detVolSvc
ServiceHandle< ActsTrk::IDetectorVolumeSvc > m_detVolSvc
ServiceHandle to the IDetectorVolumeSvc.
Definition: DetectorAlignCondAlg.h:43
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:496
ActsTrk::DetectorAlignCondAlg::m_Type
DetectorType m_Type
Static cast of >DetectorType< property.
Definition: DetectorAlignCondAlg.h:49
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:37
python.ExitCodes.what
def what(code)
Definition: ExitCodes.py:73
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
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:39
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: MuonDetectorBuilderTool.cxx:34
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
ActsTrk::DetectorAlignCondAlg::m_loadDetVolSvc
Gaudi::Property< bool > m_loadDetVolSvc
Definition: DetectorAlignCondAlg.h:54
ActsTrk::DetectorAlignCondAlg::~DetectorAlignCondAlg
virtual ~DetectorAlignCondAlg()