ATLAS Offline Software
Loading...
Searching...
No Matches
PixelAlignCondAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "PixelAlignCondAlg.h"
6
9
10#include <memory>
11
12PixelAlignCondAlg::PixelAlignCondAlg(const std::string& name, ISvcLocator* pSvcLocator)
13 : ::AthCondAlgorithm(name, pSvcLocator)
14{
15}
16
18{
19 ATH_MSG_DEBUG("initialize " << name());
20
21 // Read Handles
22 // Static
24 // Dynamic
28 ATH_CHECK(m_readKeyIBLDist.initialize(!m_readKeyIBLDist.empty()));
29
30 // Write Handles
31 ATH_CHECK(m_writeKey.initialize());
32
34
35 return StatusCode::SUCCESS;
36}
37
38StatusCode PixelAlignCondAlg::execute(const EventContext& ctx) const
39{
40 ATH_MSG_DEBUG("execute " << name());
41
42 // ____________ Construct Write Cond Handle and check its validity ____________
44
45 // Do we have a valid Write Cond Handle for current time?
46 if (writeHandle.isValid()) {
47 ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid."
48 << ". In theory this should not be called, but may happen"
49 << " if multiple concurrent events are being processed out of order.");
50 return StatusCode::SUCCESS;
51 }
52
53 // Get SiDetectorElements
54 const InDetDD::SiDetectorElementCollection* oldColl{m_detManager->getDetectorElementCollection()};
55 if (oldColl==nullptr) {
56 ATH_MSG_FATAL("Null pointer is returned by getDetectorElementCollection()");
57 return StatusCode::FAILURE;
58 }
59
60 // ____________ Construct new Write Cond Object ____________
61 std::unique_ptr<GeoAlignmentStore> writeCdo{std::make_unique<GeoAlignmentStore>()};
62
63 if (not m_useDynamicAlignFolders.value()) { // Static
64 // ____________ Get Read Cond Object ____________
66 const AlignableTransformContainer* readCdoStatic{*readHandleStatic};
67 if (readCdoStatic==nullptr) {
68 ATH_MSG_FATAL("Null pointer to the read conditions object of " << m_readKeyStatic.key());
69 return StatusCode::FAILURE;
70 }
71 writeHandle.addDependency(readHandleStatic);
72
73 // ____________ Apply alignments to Pixel GeoModel ____________
74 // Construct Container for read CDO.
75 InDetDD::RawAlignmentObjects readCdoContainerStatic;
76 readCdoContainerStatic.emplace(m_readKeyStatic.key(), readCdoStatic);
77 ATH_CHECK(m_detManager->align(readCdoContainerStatic, writeCdo.get()));
78
79 // IBL
80 if (!m_readKeyIBLDist.empty()) {
81 // This absolutely needs to go last, since it relies on deltas from other alignment
82 // already be set in the alignment store!!!
84 const CondAttrListCollection* readCdoIBLDist{*readHandleIBLDist};
85 if (readCdoIBLDist==nullptr) {
86 ATH_MSG_FATAL("Null pointer to the read conditions object of " << readHandleIBLDist.key());
87 return StatusCode::FAILURE;
88 }
89 writeHandle.addDependency(readHandleIBLDist);
90
91 InDetDD::RawAlignmentObjects readCdoContainerIBLDist;
92 readCdoContainerIBLDist.emplace(m_readKeyIBLDist.key(), readCdoIBLDist);
93 ATH_CHECK(m_detManager->align(readCdoContainerIBLDist, writeCdo.get()));
94
95 }
96 } else { // Dynamic
97 // ____________ Get Read Cond Object ____________
99 const CondAttrListCollection* readCdoDynamicL1{*readHandleDynamicL1};
100 if (readCdoDynamicL1==nullptr) {
101 ATH_MSG_FATAL("Null pointer to the read conditions object of " << m_readKeyDynamicL1.key());
102 return StatusCode::FAILURE;
103 }
104 writeHandle.addDependency(readHandleDynamicL1);
105
107 const CondAttrListCollection* readCdoDynamicL2{*readHandleDynamicL2};
108 if (readCdoDynamicL2==nullptr) {
109 ATH_MSG_FATAL("Null pointer to the read conditions object of " << readHandleDynamicL2.key());
110 return StatusCode::FAILURE;
111 }
112 writeHandle.addDependency(readHandleDynamicL2);
113
115 const AlignableTransformContainer* readCdoDynamicL3{*readHandleDynamicL3};
116 if (readCdoDynamicL3==nullptr) {
117 ATH_MSG_FATAL("Null pointer to the read conditions object of " << readHandleDynamicL3.key());
118 return StatusCode::FAILURE;
119 }
120 writeHandle.addDependency(readHandleDynamicL3);
121
122 // ____________ Apply alignments to Pixel GeoModel ____________
123 // Construct Container for read CDO-s.
124 InDetDD::RawAlignmentObjects readCdoContainerDynamicL1;
125 readCdoContainerDynamicL1.emplace(m_readKeyDynamicL1.key(), readCdoDynamicL1);
126 ATH_CHECK(m_detManager->align(readCdoContainerDynamicL1, writeCdo.get()));
127
128 InDetDD::RawAlignmentObjects readCdoContainerDynamicL2;
129 readCdoContainerDynamicL2.emplace(m_readKeyDynamicL2.key(), readCdoDynamicL2);
130 ATH_CHECK(m_detManager->align(readCdoContainerDynamicL2, writeCdo.get()));
131
132 InDetDD::RawAlignmentObjects readCdoContainerDynamicL3;
133 readCdoContainerDynamicL3.emplace(m_readKeyDynamicL3.key(), readCdoDynamicL3);
134 ATH_CHECK(m_detManager->align(readCdoContainerDynamicL3, writeCdo.get()));
135
136
137 // IBL
138 if (!m_readKeyIBLDist.empty()) {
139 // This absolutely needs to go last, since it relies on deltas from other alignment
140 // already be set in the alignment store!!!
142 const CondAttrListCollection* readCdoIBLDist{*readHandleIBLDist};
143 if (readCdoIBLDist==nullptr) {
144 ATH_MSG_FATAL("Null pointer to the read conditions object of " << readHandleIBLDist.key());
145 return StatusCode::FAILURE;
146 }
147 writeHandle.addDependency(readHandleIBLDist);
148 InDetDD::RawAlignmentObjects readCdoContainerIBLDist;
149 readCdoContainerIBLDist.emplace(m_readKeyIBLDist.key(), readCdoIBLDist);
150 ATH_CHECK(m_detManager->align(readCdoContainerIBLDist, writeCdo.get()));
151 }
152
153 }
154
155 // Set (default) absolute transforms in alignment store by calling them.
156 for (const InDetDD::SiDetectorElement* oldEl: *oldColl) {
157 oldEl->getMaterialGeom()->getAbsoluteTransform(writeCdo.get());
158 oldEl->getMaterialGeom()->getDefAbsoluteTransform(writeCdo.get());
159 }
160 writeCdo->lockDelta();
161 writeCdo->lockPosCache();
162
163 if (writeHandle.record(std::move(writeCdo)).isFailure()) {
164 ATH_MSG_FATAL("Could not record GeoAlignmentStore " << writeHandle.key()
165 << " with EventRange " << writeHandle.getRange()
166 << " into Conditions Store");
167 return StatusCode::FAILURE;
168 }
169 ATH_MSG_INFO("recorded new CDO " << writeHandle.key() << " with range " << writeHandle.getRange() << " into Conditions Store");
170
171 return StatusCode::SUCCESS;
172}
CondMultChanCollection< AlignableTransform > AlignableTransformContainer
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
const ServiceHandle< StoreGateSvc > & detStore() const
Base class for conditions algorithms.
This class is a collection of AttributeLists where each one is associated with a channel number.
Class to hold the SiDetectorElement objects to be put in the detector store.
Class to hold geometrical description of a silicon detector element.
virtual StatusCode execute(const EventContext &ctx) const override
StringProperty m_detManagerName
SG::ReadCondHandleKey< CondAttrListCollection > m_readKeyIBLDist
const InDetDD::PixelDetectorManager * m_detManager
SG::ReadCondHandleKey< AlignableTransformContainer > m_readKeyDynamicL3
PixelAlignCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadCondHandleKey< CondAttrListCollection > m_readKeyDynamicL2
SG::ReadCondHandleKey< AlignableTransformContainer > m_readKeyStatic
SG::ReadCondHandleKey< CondAttrListCollection > m_readKeyDynamicL1
BooleanProperty m_useDynamicAlignFolders
SG::WriteCondHandleKey< GeoAlignmentStore > m_writeKey
virtual StatusCode initialize() override
const std::string & key() const
const std::string & key() const
void addDependency(const EventIDRange &range)
const EventIDRange & getRange() const
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
const DataObjID & fullKey() const
std::map< std::string, const void * > RawAlignmentObjects