ATLAS Offline Software
Loading...
Searching...
No Matches
DeviceDetectorDescriptionCondAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
7
8namespace ActsTrk {
9
11{
12 ATH_MSG_DEBUG("Initializing device detector conditions description algorithm ");
13
14 ATH_CHECK(m_MRs.retrieve());
15 ATH_CHECK(m_copy.retrieve());
16
19
20 ATH_CHECK(m_writeHostCondKey.initialize());
21 ATH_CHECK(m_writeDeviceCondKey.initialize());
22
25
26 // The static part of the detector description (id maps, module designs,
27 // device detector) is built by the service during its initialization.
28 ATH_CHECK(m_detDescSvc.retrieve());
29
30 return StatusCode::SUCCESS;
31}
32
33StatusCode DeviceDetectorDescriptionCondAlg::execute(const EventContext& ctx) const
34{
37
38 if (writeHostHandle.isValid() && writeDeviceHandle.isValid()) {
39 ATH_MSG_DEBUG("CondHandles " << writeHostHandle.fullKey() << " and "
40 << writeDeviceHandle.fullKey() << " are already valid.");
41 return StatusCode::SUCCESS;
42 }
43
44 const std::vector<StaticCondEntry>& staticCondEntries = m_detDescSvc->staticCondEntries();
45
46 auto hostCond = std::make_unique<traccc::detector_conditions_description::host>(*m_MRs->hostMR());
47 hostCond->resize(staticCondEntries.size());
48
49 // ---- 5. Write detector conditions object ----
50 // This object basically stores any information that we need per-module
51 // like: detray id, acts id, index to module design, lorentz shift etc.
52 // since lorentz shift is conditional, we need a valid event context
53 // all the static info (like the id maps) have been pre-filled by the service,
54 // here we just populate anything that might be conditions dependant
55
56 for (std::size_t condIndex = 0; condIndex < staticCondEntries.size(); ++condIndex) {
57 const auto& entry = staticCondEntries[condIndex];
58
59 hostCond->module_to_design_id()[condIndex] = entry.designId;
60 hostCond->geometry_id()[condIndex] = entry.detrayGeometryId;
61 hostCond->acts_geometry_id()[condIndex] = entry.actsGeometryId;
62
63 float shiftX = 0.f, shiftY = 0.f;
64 if (entry.hasAthenaModule) {
65 if (entry.isPixel) {
66 const IdentifierHash pixelHash = m_pixelID->wafer_hash(entry.athenaId);
67 shiftX = m_pixelLorentzAngleTool->getLorentzShift(pixelHash, ctx);
68 } else {
69 const IdentifierHash waferHash = m_stripID->wafer_hash(entry.athenaId);
70 shiftX = m_stripLorentzAngleTool->getLorentzShift(waferHash, ctx);
71 }
72 }
73
74 hostCond->measurement_translation()[condIndex] =
75 traccc::vector2{static_cast<traccc::scalar>(shiftX), static_cast<traccc::scalar>(shiftY)};
76 }
77
78 auto copy = m_copy->copy(ctx);
79 auto deviceCond = std::make_unique<traccc::detector_conditions_description::buffer>(
80 static_cast<traccc::detector_conditions_description::buffer::size_type>(hostCond->size()),
81 m_MRs->mainMR());
82 (*copy).setup(*deviceCond)->wait();
83 (*copy)(vecmem::get_data(*hostCond), *deviceCond)->wait();
84
85 // PLACEHOLDER: no real conditions dependency yet (e.g. alignment tag),
86 // so mark this object as valid for all run/lumi. Replace with a proper
87 // addDependency(ReadCondHandle<...>&) once this depends on something
88 // that actually changes over the run.
89
92
93 ATH_CHECK(writeHostHandle.record(std::move(hostCond)));
94 ATH_CHECK(writeDeviceHandle.record(std::move(deviceCond)));
95
96 ATH_MSG_DEBUG("Recorded host and device detector conditions description: " << m_writeHostCondKey.key() << ", " << m_writeDeviceCondKey.key());
97
98 return StatusCode::SUCCESS;
99}
100
101} // namespace ActsTrk
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
virtual StatusCode execute(const EventContext &ctx) const override
SG::WriteCondHandleKey< traccc::detector_conditions_description::host > m_writeHostCondKey
SG::WriteCondHandleKey< traccc::detector_conditions_description::buffer > m_writeDeviceCondKey
ToolHandle< AthDevice::IMemoryResourcesTool > m_MRs
ServiceHandle< ActsTrk::IDeviceDetectorDescriptionSvc > m_detDescSvc
The service providing the static part of the detector description.
ToolHandle< AthDevice::ICopyTool > m_copy
The copy tool used for copying data to device.
const PixelID * m_pixelID
Conversion helpers (to retrieve module design, hash, etc.) {.
const ServiceHandle< StoreGateSvc > & detStore() const
static EventIDRange infiniteRunLB()
Produces an EventIDRange that is infinite in RunLumi and invalid in Time.
This is a "hash" representation of an Identifier.
void addDependency(const EventIDRange &range)
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
const DataObjID & fullKey() const
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...