5 #include "GaudiKernel/MsgStream.h"
11 , ISvcLocator* pSvcLocator )
35 return StatusCode::SUCCESS;
42 const EventContext& ctx = Gaudi::Hive::currentContext();
45 if (writeHandleDetElCont.isValid()) {
46 ATH_MSG_DEBUG(
"CondHandle " << writeHandleDetElCont.fullKey() <<
" is already valid."
47 <<
". In theory this should not be called, but may happen"
48 <<
" if multiple concurrent events are being processed out of order.");
49 return StatusCode::SUCCESS;
52 std::unique_ptr<SG::WriteCondHandle<GeoAlignmentStore>> writeHandleAlignStore{};
54 writeHandleAlignStore = std::make_unique<SG::WriteCondHandle<GeoAlignmentStore>>(
m_writeKeyAlignStore, ctx);
55 if (writeHandleAlignStore->isValid()) {
56 ATH_MSG_DEBUG(
"CondHandle " << writeHandleAlignStore->fullKey() <<
" is already valid."
57 <<
". In theory this should not be called, but may happen"
58 <<
" if multiple concurrent events are being processed out of order.");
59 return StatusCode::SUCCESS;
64 std::unique_ptr<GeoAlignmentStore> writeCdoAlignStore{std::make_unique<GeoAlignmentStore>()};
71 if (unAlignedColl==
nullptr) {
72 ATH_MSG_FATAL(
"Null pointer is returned by getDetectorElementCollection()");
73 return StatusCode::FAILURE;
83 if(readCdoDynamicGlobal==
nullptr) {
84 ATH_MSG_ERROR(
"Null pointer to the read conditions object: Dynamic Global");
85 return StatusCode::FAILURE;
89 if (writeHandleAlignStore) writeHandleAlignStore->addDependency(readHandleDynamicGlobal);
90 writeHandleDetElCont.addDependency(readHandleDynamicGlobal);
96 if(readCdoDynamicRegular==
nullptr) {
97 ATH_MSG_ERROR(
"Null pointer to the read conditions object: Dynamic Regular");
98 return StatusCode::FAILURE;
102 if (writeHandleAlignStore) writeHandleAlignStore->addDependency(readHandleDynamicRegular);
103 writeHandleDetElCont.addDependency(readHandleDynamicRegular);
110 if(readCdoRegular==
nullptr) {
111 ATH_MSG_ERROR(
"Null pointer to the read conditions object: Regular");
112 return StatusCode::FAILURE;
116 if (writeHandleAlignStore) writeHandleAlignStore->addDependency(readHandleRegular);
117 writeHandleDetElCont.addDependency(readHandleRegular);
125 if(!readCdoSpecial) {
126 ATH_MSG_ERROR(
"Null pointer to the read conditions object: Special");
127 return StatusCode::FAILURE;
131 if (writeHandleAlignStore) writeHandleAlignStore->addDependency(readHandleSpecial);
132 writeHandleDetElCont.addDependency(readHandleSpecial);
136 if(
m_detManager->
align(readCdoContainer, writeCdoAlignStore.get()).isFailure()) {
138 return StatusCode::FAILURE;
142 if (alignedColl==
nullptr) {
143 ATH_MSG_FATAL(
"Null pointer is returned by getDetectorElementCollection()");
144 return StatusCode::FAILURE;
148 std::unique_ptr<InDetDD::TRT_DetElementContainer> writeCdoDetElCont{std::make_unique<InDetDD::TRT_DetElementContainer>()};
151 std::map<const InDetDD::TRT_EndcapElement*, InDetDD::TRT_EndcapElement*> oldToNewECMap;
152 std::map<const InDetDD::TRT_BarrelElement*, InDetDD::TRT_BarrelElement*> oldToNewBAMap;
154 oldToNewECMap[
nullptr] =
nullptr;
155 oldToNewBAMap[
nullptr] =
nullptr;
165 oldToNewECMap[oldEl_Endcap] = newEl;
166 writeCdoDetElCont->addEndcapElement(newEl);
171 oldToNewBAMap[oldEl_Barrel] = newEl;
172 writeCdoDetElCont->addBarrelElement(newEl);
175 return StatusCode::FAILURE;
180 for (
auto pairOfEl : oldToNewECMap) {
181 if (!pairOfEl.first)
continue;
182 pairOfEl.second->setNextInZ(oldToNewECMap[pairOfEl.first->nextInZ()]);
183 pairOfEl.second->setPreviousInZ(oldToNewECMap[pairOfEl.first->previousInZ()]);
185 for (
auto pairOfEl : oldToNewBAMap) {
186 if (!pairOfEl.first)
continue;
187 pairOfEl.second->setNextInR(oldToNewBAMap[pairOfEl.first->nextInR()]);
188 pairOfEl.second->setPreviousInR(oldToNewBAMap[pairOfEl.first->previousInR()]);
189 pairOfEl.second->setNextInPhi(oldToNewBAMap[pairOfEl.first->nextInPhi()]);
190 pairOfEl.second->setPreviousInPhi(oldToNewBAMap[pairOfEl.first->previousInPhi()]);
195 newEl->updateAllCaches(writeCdoAlignStore.get());
199 const std::size_t writeHandleDetElContSize{writeCdoDetElCont->getElements()->size()};
204 if (writeHandleAlignStore !=
nullptr) {
205 if(writeHandleAlignStore->record(std::move(writeCdoAlignStore)).isFailure()) {
206 ATH_MSG_ERROR(
"Could not record GeoAlignmentStore " << writeHandleAlignStore->key()
207 <<
" with EventRange " << writeHandleAlignStore->getRange()
208 <<
" into Conditions Store");
209 return StatusCode::FAILURE;
211 ATH_MSG_INFO(
"recorded new CDO " << writeHandleAlignStore->key() <<
" with range "
212 << writeHandleAlignStore->getRange() <<
" into Conditions Store");
215 if (writeHandleDetElCont.record(std::move(writeCdoDetElCont)).isFailure()) {
216 ATH_MSG_FATAL(
"Could not record " << writeHandleDetElCont.key()
217 <<
" with EventRange " << writeHandleDetElCont.getRange()
218 <<
" into Conditions Store");
219 return StatusCode::FAILURE;
221 ATH_MSG_INFO(
"recorded new CDO " << writeHandleDetElCont.key() <<
" with range "
222 << writeHandleDetElCont.getRange() <<
" with size of " << writeHandleDetElContSize <<
" into Conditions Store");
224 return StatusCode::SUCCESS;