39{
41
42
43 SG::WriteCondHandle<InDetDD::TRT_DetElementContainer> writeHandleDetElCont{
m_writeKeyDetElCont, ctx};
44 if (writeHandleDetElCont.
isValid()) {
46 << ". In theory this should not be called, but may happen"
47 << " if multiple concurrent events are being processed out of order.");
48 return StatusCode::SUCCESS;
49 }
50
51 std::unique_ptr<SG::WriteCondHandle<GeoAlignmentStore>> writeHandleAlignStore{};
53 writeHandleAlignStore = std::make_unique<SG::WriteCondHandle<GeoAlignmentStore>>(
m_writeKeyAlignStore, ctx);
54 if (writeHandleAlignStore->isValid()) {
55 ATH_MSG_DEBUG(
"CondHandle " << writeHandleAlignStore->fullKey() <<
" is already valid."
56 << ". In theory this should not be called, but may happen"
57 << " if multiple concurrent events are being processed out of order.");
58 return StatusCode::SUCCESS;
59 }
60 }
61
62
63 std::unique_ptr<GeoAlignmentStore> writeCdoAlignStore{std::make_unique<GeoAlignmentStore>()};
64
65
66
68
69 const InDetDD::TRT_DetElementCollection* unAlignedColl{
m_detManager->getDetectorElementCollection()};
70 if (unAlignedColl==nullptr) {
71 ATH_MSG_FATAL(
"Null pointer is returned by getDetectorElementCollection()");
72 return StatusCode::FAILURE;
73 }
74
76
77
78
80
81 const CondAttrListCollection* readCdoDynamicGlobal{*readHandleDynamicGlobal};
82 if(readCdoDynamicGlobal==nullptr) {
83 ATH_MSG_ERROR(
"Null pointer to the read conditions object: Dynamic Global");
84 return StatusCode::FAILURE;
85 }
87
88 if (writeHandleAlignStore) writeHandleAlignStore->addDependency(readHandleDynamicGlobal);
90
91
93
95 if(readCdoDynamicRegular==nullptr) {
96 ATH_MSG_ERROR(
"Null pointer to the read conditions object: Dynamic Regular");
97 return StatusCode::FAILURE;
98 }
100
101 if (writeHandleAlignStore) writeHandleAlignStore->addDependency(readHandleDynamicRegular);
102 writeHandleDetElCont.
addDependency(readHandleDynamicRegular);
103 }
104 else {
105
106 SG::ReadCondHandle<AlignableTransformContainer> readHandleRegular{
m_readKeyRegular,ctx};
107
109 if(readCdoRegular==nullptr) {
110 ATH_MSG_ERROR(
"Null pointer to the read conditions object: Regular");
111 return StatusCode::FAILURE;
112 }
114
115 if (writeHandleAlignStore) writeHandleAlignStore->addDependency(readHandleRegular);
117 }
118
119 {
120
121 SG::ReadCondHandle<TRTCond::StrawDxContainer> readHandleSpecial{
m_readKeySpecial,ctx};
122
123 const TRTCond::StrawDxContainer* readCdoSpecial{*readHandleSpecial};
124 if(!readCdoSpecial) {
125 ATH_MSG_ERROR(
"Null pointer to the read conditions object: Special");
126 return StatusCode::FAILURE;
127 }
129
130 if (writeHandleAlignStore) writeHandleAlignStore->addDependency(readHandleSpecial);
132 }
133
134
135 if(
m_detManager->align(readCdoContainer, writeCdoAlignStore.get()).isFailure()) {
137 return StatusCode::FAILURE;
138 }
139
140 const InDetDD::TRT_DetElementCollection* alignedColl{
m_detManager->getDetectorElementCollection()};
141 if (alignedColl==nullptr) {
142 ATH_MSG_FATAL(
"Null pointer is returned by getDetectorElementCollection()");
143 return StatusCode::FAILURE;
144 }
145
146
147 std::unique_ptr<InDetDD::TRT_DetElementContainer> writeCdoDetElCont{std::make_unique<InDetDD::TRT_DetElementContainer>()};
148
149
150 std::map<const InDetDD::TRT_EndcapElement*, InDetDD::TRT_EndcapElement*> oldToNewECMap;
151 std::map<const InDetDD::TRT_BarrelElement*, InDetDD::TRT_BarrelElement*> oldToNewBAMap;
152
153 oldToNewECMap[nullptr] = nullptr;
154 oldToNewBAMap[nullptr] = nullptr;
155
156
157 for (const InDetDD::TRT_BaseElement* oldEl : *alignedColl) {
159
161 const InDetDD::TRT_EndcapElement* oldEl_Endcap = static_cast<const InDetDD::TRT_EndcapElement*>(oldEl);
162
163 InDetDD::TRT_EndcapElement* newEl = new InDetDD::TRT_EndcapElement(*oldEl_Endcap);
164 oldToNewECMap[oldEl_Endcap] = newEl;
165 writeCdoDetElCont->addEndcapElement(newEl);
167 const InDetDD::TRT_BarrelElement* oldEl_Barrel = static_cast<const InDetDD::TRT_BarrelElement*>(oldEl);
168
169 InDetDD::TRT_BarrelElement* newEl = new InDetDD::TRT_BarrelElement(*oldEl_Barrel);
170 oldToNewBAMap[oldEl_Barrel] = newEl;
171 writeCdoDetElCont->addBarrelElement(newEl);
172 } else {
174 return StatusCode::FAILURE;
175 }
176 }
177
178
179 for (auto pairOfEl : oldToNewECMap) {
180 if (!pairOfEl.first) continue;
181 pairOfEl.second->setNextInZ(oldToNewECMap[pairOfEl.first->nextInZ()]);
182 pairOfEl.second->setPreviousInZ(oldToNewECMap[pairOfEl.first->previousInZ()]);
183 }
184 for (auto pairOfEl : oldToNewBAMap) {
185 if (!pairOfEl.first) continue;
186 pairOfEl.second->setNextInR(oldToNewBAMap[pairOfEl.first->nextInR()]);
187 pairOfEl.second->setPreviousInR(oldToNewBAMap[pairOfEl.first->previousInR()]);
188 pairOfEl.second->setNextInPhi(oldToNewBAMap[pairOfEl.first->nextInPhi()]);
189 pairOfEl.second->setPreviousInPhi(oldToNewBAMap[pairOfEl.first->previousInPhi()]);
190 }
191
192
193 for (InDetDD::TRT_BaseElement* newEl : *(writeCdoDetElCont->getElements())) {
195 }
196
197
198 const std::size_t writeHandleDetElContSize{writeCdoDetElCont->getElements()->size()};
199
200 writeCdoDetElCont->setNumerology(
m_detManager->getNumerology());
201
202
203 if (writeHandleAlignStore != nullptr) {
204 if(writeHandleAlignStore->record(std::move(writeCdoAlignStore)).isFailure()) {
205 ATH_MSG_ERROR(
"Could not record GeoAlignmentStore " << writeHandleAlignStore->key()
206 << " with EventRange " << writeHandleAlignStore->getRange()
207 << " into Conditions Store");
208 return StatusCode::FAILURE;
209 }
210 ATH_MSG_INFO(
"recorded new CDO " << writeHandleAlignStore->key() <<
" with range "
211 << writeHandleAlignStore->getRange() << " into Conditions Store");
212 }
213
214 if (writeHandleDetElCont.
record(std::move(writeCdoDetElCont)).isFailure()) {
216 <<
" with EventRange " << writeHandleDetElCont.
getRange()
217 << " into Conditions Store");
218 return StatusCode::FAILURE;
219 }
220 ATH_MSG_INFO(
"recorded new CDO " << writeHandleDetElCont.
key() <<
" with range "
221 << writeHandleDetElCont.
getRange() <<
" with size of " << writeHandleDetElContSize <<
" into Conditions Store");
222
223 return StatusCode::SUCCESS;
224}
void updateAllCaches(GeoAlignmentStore *alignStore=nullptr) const
Update all caches.
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
SG::ReadCondHandleKey< AlignableTransformContainer > m_readKeyDynamicRegular
SG::ReadCondHandleKey< TRTCond::StrawDxContainer > m_readKeySpecial
SG::ReadCondHandleKey< AlignableTransformContainer > m_readKeyRegular
SG::WriteCondHandleKey< InDetDD::TRT_DetElementContainer > m_writeKeyDetElCont
SG::WriteCondHandleKey< GeoAlignmentStore > m_writeKeyAlignStore
const InDetDD::TRT_DetectorManager * m_detManager
Gaudi::Property< bool > m_useDynamicFolders
SG::ReadCondHandleKey< CondAttrListCollection > m_readKeyDynamicGlobal
std::map< std::string, const void * > RawAlignmentObjects