ATLAS Offline Software
Loading...
Searching...
No Matches
AlignStoreProviderAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
5
8
10namespace {
14 unsigned countPopulated(const TrackStore& store, const ActsTrk::DetectorType detType) {
15 unsigned n{0};
16 for (unsigned ticket = 0; ticket < TrackStore::distributedTickets(detType); ++ticket) {
17 n += store.getTransform(ticket) != nullptr;
18 }
19 return n;
20 }
21}
22
23namespace ActsTrk{
24
26
27
28
30 ATH_CHECK(m_inputKey.initialize(!m_inputKey.empty()));
31 ATH_CHECK(m_outputKey.initialize());
34 ATH_MSG_DEBUG("Setup the tracking geometry service");
35 ATH_CHECK(m_trackingGeoSvc.retrieve());
36 }
39 ATH_MSG_DEBUG("Configuration: "<<m_detType<<" ("<<to_string(static_cast<DetectorType>(m_detType.value()))
40 <<"), "<<m_fillAlignStoreCache<<", "<<m_splitPhysVolCache<<", "
41 <<m_splitActsTrfCache<<", inKey: "<<m_inputKey.fullKey()<<", outKey: "<<m_outputKey.fullKey());
42
43 if (!m_inputKey.empty()) {
44 return StatusCode::SUCCESS;
45 }
46
47 try {
48 m_Type = static_cast<DetectorType>(m_detType.value());
49 } catch (const std::exception& what) {
50 ATH_MSG_FATAL("Invalid detType is configured " << m_detType);
51 return StatusCode::FAILURE;
52 }
54 ATH_MSG_FATAL("Please configure the detType " << m_detType << " to be something not undefined");
55 return StatusCode::FAILURE;
56 }
57 return StatusCode::SUCCESS;
58}
59
60StatusCode AlignStoreProviderAlg::execute(const EventContext& ctx) const {
61 std::unique_ptr<DetectorAlignStore> newAlignment{};
62
63 if (!m_inputKey.empty()) {
64 const DetectorAlignStore* inStore{};
65 ATH_CHECK(SG::get(inStore, m_inputKey, ctx));
66 newAlignment = std::make_unique<DetectorAlignStore>(*inStore);
68 if (m_splitPhysVolCache && newAlignment->geoModelAlignment) {
69 newAlignment->geoModelAlignment = std::make_unique<GeoAlignmentStore>(*newAlignment->geoModelAlignment);
70 newAlignment->geoModelAlignment->clearPosCache();
71 }
72 if (m_splitActsTrfCache && newAlignment->geoModelAlignment) {
73 using TrackingStore = DetectorAlignStore::TrackingAlignStore;
74 newAlignment->trackingAlignment = std::make_unique<TrackingStore>(newAlignment->detType);
75 }
76 } else {
77 newAlignment = std::make_unique<DetectorAlignStore>(m_Type);
78 }
82 if (m_fillAlignStoreCache && newAlignment->geoModelAlignment) {
83 if(!m_trackingGeoSvc->populateAlignmentStore(*newAlignment)) {
84 ATH_MSG_WARNING("No detector elements of " << to_string(m_Type) << " are part of the tracking geometry");
85 }
87 newAlignment->geoModelAlignment.reset();
88 }
89 SG::WriteHandle writeHandle{m_outputKey, ctx};
90 ATH_MSG_DEBUG("Record alignment store for detector technology "<<to_string(newAlignment->detType)
91 <<" with a capacity of "<<TrackStore::distributedTickets(newAlignment->detType)<<". Already populated: "
92 <<countPopulated(*newAlignment->trackingAlignment, newAlignment->detType));
93 ATH_CHECK(writeHandle.record(std::move(newAlignment)));
94
95 return StatusCode::SUCCESS;
96}
97}
ActsTrk::DetectorAlignStore::TrackingAlignStore TrackStore
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Handle class for recording to StoreGate.
Gaudi::Property< bool > m_fillAlignStoreCache
Flag toggling whether the alignment store shall be filled with the transforms or not.
Gaudi::Property< int > m_detType
Flag determining the subdetector. Needs to be static castable to DetectorType.
SG::ReadCondHandleKey< DetectorAlignStore > m_inputKey
Key to the alignment transformations for the detector volumes.
DetectorType m_Type
Static cast of >DetectorType< property.
SG::WriteHandleKey< DetectorAlignStore > m_outputKey
Key to the alignment transformations written by the alg.
StatusCode execute(const EventContext &ctx) const override final
StatusCode initialize() override final
Gaudi::Property< bool > m_splitPhysVolCache
Flag toggling whether the full GeoAlignmentStore shall be written to store gate or whether the absolu...
ServiceHandle< ITrackingGeometrySvc > m_trackingGeoSvc
ServiceHandle to the ActsTrackingGeometry.
Gaudi::Property< bool > m_splitActsTrfCache
Flag toggline whether the final transforms of the ActsDet volumes shall be split per event.
Store holding the transfomations used by the Acts algorithms.
static unsigned int distributedTickets(const DetectorType detType)
Returns the number of all distributed tickets.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
std::string to_string(const DetectorType &type)
DetectorType
Simple enum to Identify the Type of the ACTS sub detector.
@ UnDefined
Small Thing Gap chambers (NSW)
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.