ATLAS Offline Software
AlignStoreProviderAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
5 
8 
9 using namespace ActsTrk;
10 AlignStoreProviderAlg::AlignStoreProviderAlg(const std::string& name, ISvcLocator* pSvcLocator) :
11  AthReentrantAlgorithm(name, pSvcLocator) {}
12 
14 
16  ATH_CHECK(m_inputKey.initialize(!m_inputKey.empty()));
17  ATH_CHECK(m_outputKey.initialize());
20  if(m_loadTrkGeoSvc) {
21  ATH_CHECK(m_trackingGeoSvc.retrieve());
22  }
23  if (m_loadDetVolSvc) {
24  ATH_CHECK(m_detVolSvc.retrieve());
25  }
26  }
29  if (!m_inputKey.empty()) {
30  return StatusCode::SUCCESS;
31  }
32 
33  try {
34  m_Type = static_cast<DetectorType>(m_detType.value());
35  } catch (const std::exception& what) {
36  ATH_MSG_FATAL("Invalid detType is configured " << m_detType);
37  return StatusCode::FAILURE;
38  }
40  ATH_MSG_FATAL("Please configure the detType " << m_detType << " to be something not undefined");
41  return StatusCode::FAILURE;
42  }
43  return StatusCode::SUCCESS;
44 }
45 
46 StatusCode AlignStoreProviderAlg::execute(const EventContext& ctx) const {
47 
48  std::unique_ptr<DetectorAlignStore> newAlignment{};
49 
50  if (!m_inputKey.empty()) {
52  if (!readHandle.isValid()) {
53  ATH_MSG_FATAL("Failed to retrieve " << m_inputKey.fullKey());
54  return StatusCode::FAILURE;
55  }
56  newAlignment = std::make_unique<DetectorAlignStore>(**readHandle);
58  if (m_splitPhysVolCache) {
59  if (newAlignment->geoModelAlignment) {
60  newAlignment->geoModelAlignment = std::make_unique<GeoAlignmentStore>(*newAlignment->geoModelAlignment);
61  newAlignment->geoModelAlignment->clearPosCache();
62  }
63  }
64  if (m_splitActsTrfCache) {
65  using TrackingStore = DetectorAlignStore::TrackingAlignStore;
66  newAlignment->trackingAlignment = std::make_unique<TrackingStore>(newAlignment->detType);
67  }
68  } else {
69  newAlignment = std::make_unique<DetectorAlignStore>(m_Type);
70  }
74  if (m_fillAlignStoreCache && newAlignment->geoModelAlignment) {
75  if(m_loadTrkGeoSvc && !m_trackingGeoSvc->populateAlignmentStore(*newAlignment)) {
76  ATH_MSG_WARNING("No detector elements of " << to_string(m_Type) << " are part of the tracking geometry");
77  }
78  if (m_loadDetVolSvc && !m_detVolSvc->populateAlignmentStore(*newAlignment)) {
79  ATH_MSG_WARNING("No detector elements of " << to_string(m_Type) << " are part of the detector tracking volumes");
80  }
82  newAlignment->geoModelAlignment.reset();
83  }
85  ATH_MSG_DEBUG("Record alignment store for detector technology "<<to_string(newAlignment->detType)
86  <<" with a capacity of "<<DetectorAlignStore::TrackingAlignStore::distributedTickets(newAlignment->detType)<<".");
87  ATH_CHECK(writeHandle.record(std::move(newAlignment)));
88  return StatusCode::SUCCESS;
89 }
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ActsTrk::AlignStoreProviderAlg::m_splitActsTrfCache
Gaudi::Property< bool > m_splitActsTrfCache
Flag toggline whether the final transforms of the ActsDet volumes shall be split per event.
Definition: AlignStoreProviderAlg.h:48
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::AlignStoreProviderAlg::m_inputKey
SG::ReadCondHandleKey< DetectorAlignStore > m_inputKey
Key to the alignment transformations for the detector volumes.
Definition: AlignStoreProviderAlg.h:35
ActsTrk::DetectorAlignStore::TrackingAlignStore
Store holding the transfomations used by the Acts algorithms.
Definition: DetectorAlignStore.h:33
ActsTrk::AlignStoreProviderAlg::execute
StatusCode execute(const EventContext &ctx) const override final
Definition: AlignStoreProviderAlg.cxx:46
ActsTrk::DetectorType::UnDefined
@ UnDefined
Small Thing Gap chambers (NSW)
ActsTrk::AlignStoreProviderAlg::m_loadTrkGeoSvc
Gaudi::Property< bool > m_loadTrkGeoSvc
Definition: AlignStoreProviderAlg.h:54
ActsTrk::AlignStoreProviderAlg::m_Type
DetectorType m_Type
Static cast of >DetectorType< property.
Definition: AlignStoreProviderAlg.h:52
ReadCondHandle.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
ActsTrk::AlignStoreProviderAlg::AlignStoreProviderAlg
AlignStoreProviderAlg(const std::string &name, ISvcLocator *pSvcLocator)
Standard constructor.
Definition: AlignStoreProviderAlg.cxx:10
WriteHandle.h
Handle class for recording to StoreGate.
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
calibdata.exception
exception
Definition: calibdata.py:496
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ActsTrk::AlignStoreProviderAlg::~AlignStoreProviderAlg
virtual ~AlignStoreProviderAlg()
ActsTrk::AlignStoreProviderAlg::m_detVolSvc
ServiceHandle< ActsTrk::IDetectorVolumeSvc > m_detVolSvc
ServiceHandle to the IDetectorVolumeSvc.
Definition: AlignStoreProviderAlg.h:41
ActsTrk::AlignStoreProviderAlg::m_outputKey
SG::WriteHandleKey< DetectorAlignStore > m_outputKey
Key to the alignment transformations written by the alg.
Definition: AlignStoreProviderAlg.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
ActsTrk::DetectorAlignStore::TrackingAlignStore::distributedTickets
static unsigned int distributedTickets(const DetectorType detType)
Returns the number of all distributed tickets.
Definition: DetectorAlignStore.cxx:57
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
ActsTrk::AlignStoreProviderAlg::m_fillAlignStoreCache
Gaudi::Property< bool > m_fillAlignStoreCache
Flag toggling whether the alignment store shall be filled with the transforms or not.
Definition: AlignStoreProviderAlg.h:50
ActsTrk::AlignStoreProviderAlg::m_trackingGeoSvc
ServiceHandle< IActsTrackingGeometrySvc > m_trackingGeoSvc
ServiceHandle to the ActsTrackingGeometry.
Definition: AlignStoreProviderAlg.h:39
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
ActsTrk::AlignStoreProviderAlg::initialize
StatusCode initialize() override final
Definition: AlignStoreProviderAlg.cxx:15
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition: MuonDetectorBuilderTool.cxx:34
ActsTrk::AlignStoreProviderAlg::m_detType
Gaudi::Property< int > m_detType
Flag determining the subdetector. Needs to be static castable to DetectorType.
Definition: AlignStoreProviderAlg.h:43
AlignStoreProviderAlg.h
ActsTrk::AlignStoreProviderAlg::m_splitPhysVolCache
Gaudi::Property< bool > m_splitPhysVolCache
Flag toggling whether the full GeoAlignmentStore shall be written to store gate or whether the absolu...
Definition: AlignStoreProviderAlg.h:46
ActsTrk::AlignStoreProviderAlg::m_loadDetVolSvc
Gaudi::Property< bool > m_loadDetVolSvc
Definition: AlignStoreProviderAlg.h:57