ATLAS Offline Software
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 
12 PixelAlignCondAlg::PixelAlignCondAlg(const std::string& name, ISvcLocator* pSvcLocator)
13  : ::AthAlgorithm(name, pSvcLocator)
14 {
15 }
16 
18 {
19  ATH_MSG_DEBUG("initialize " << name());
20 
21  // Read Handles
22  // Static
24  // Dynamic
29 
30  // Write Handles
32 
34 
35  return StatusCode::SUCCESS;
36 }
37 
39 {
40  ATH_MSG_DEBUG("execute " << name());
41 
42  const EventContext& ctx = Gaudi::Hive::currentContext();
43  // ____________ Construct Write Cond Handle and check its validity ____________
45 
46  // Do we have a valid Write Cond Handle for current time?
47  if (writeHandle.isValid()) {
48  ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid."
49  << ". In theory this should not be called, but may happen"
50  << " if multiple concurrent events are being processed out of order.");
51  return StatusCode::SUCCESS;
52  }
53 
54  // Get SiDetectorElements
56  if (oldColl==nullptr) {
57  ATH_MSG_FATAL("Null pointer is returned by getDetectorElementCollection()");
58  return StatusCode::FAILURE;
59  }
60 
61  // ____________ Construct new Write Cond Object ____________
62  std::unique_ptr<GeoAlignmentStore> writeCdo{std::make_unique<GeoAlignmentStore>()};
63 
64  if (not m_useDynamicAlignFolders.value()) { // Static
65  // ____________ Get Read Cond Object ____________
67  const AlignableTransformContainer* readCdoStatic{*readHandleStatic};
68  if (readCdoStatic==nullptr) {
69  ATH_MSG_FATAL("Null pointer to the read conditions object of " << m_readKeyStatic.key());
70  return StatusCode::FAILURE;
71  }
72  writeHandle.addDependency(readHandleStatic);
73 
74  // ____________ Apply alignments to Pixel GeoModel ____________
75  // Construct Container for read CDO.
76  InDetDD::RawAlignmentObjects readCdoContainerStatic;
77  readCdoContainerStatic.emplace(m_readKeyStatic.key(), readCdoStatic);
78  ATH_CHECK(m_detManager->align(readCdoContainerStatic, writeCdo.get()));
79 
80  // IBL
81  if (!m_readKeyIBLDist.empty()) {
82  // This absolutely needs to go last, since it relies on deltas from other alignment
83  // already be set in the alignment store!!!
85  const CondAttrListCollection* readCdoIBLDist{*readHandleIBLDist};
86  if (readCdoIBLDist==nullptr) {
87  ATH_MSG_FATAL("Null pointer to the read conditions object of " << readHandleIBLDist.key());
88  return StatusCode::FAILURE;
89  }
90  writeHandle.addDependency(readHandleIBLDist);
91 
92  InDetDD::RawAlignmentObjects readCdoContainerIBLDist;
93  readCdoContainerIBLDist.emplace(m_readKeyIBLDist.key(), readCdoIBLDist);
94  ATH_CHECK(m_detManager->align(readCdoContainerIBLDist, writeCdo.get()));
95 
96  }
97  } else { // Dynamic
98  // ____________ Get Read Cond Object ____________
100  const CondAttrListCollection* readCdoDynamicL1{*readHandleDynamicL1};
101  if (readCdoDynamicL1==nullptr) {
102  ATH_MSG_FATAL("Null pointer to the read conditions object of " << m_readKeyDynamicL1.key());
103  return StatusCode::FAILURE;
104  }
105  writeHandle.addDependency(readHandleDynamicL1);
106 
108  const CondAttrListCollection* readCdoDynamicL2{*readHandleDynamicL2};
109  if (readCdoDynamicL2==nullptr) {
110  ATH_MSG_FATAL("Null pointer to the read conditions object of " << readHandleDynamicL2.key());
111  return StatusCode::FAILURE;
112  }
113  writeHandle.addDependency(readHandleDynamicL2);
114 
116  const AlignableTransformContainer* readCdoDynamicL3{*readHandleDynamicL3};
117  if (readCdoDynamicL3==nullptr) {
118  ATH_MSG_FATAL("Null pointer to the read conditions object of " << readHandleDynamicL3.key());
119  return StatusCode::FAILURE;
120  }
121  writeHandle.addDependency(readHandleDynamicL3);
122 
123  // ____________ Apply alignments to Pixel GeoModel ____________
124  // Construct Container for read CDO-s.
125  InDetDD::RawAlignmentObjects readCdoContainerDynamicL1;
126  readCdoContainerDynamicL1.emplace(m_readKeyDynamicL1.key(), readCdoDynamicL1);
127  ATH_CHECK(m_detManager->align(readCdoContainerDynamicL1, writeCdo.get()));
128 
129  InDetDD::RawAlignmentObjects readCdoContainerDynamicL2;
130  readCdoContainerDynamicL2.emplace(m_readKeyDynamicL2.key(), readCdoDynamicL2);
131  ATH_CHECK(m_detManager->align(readCdoContainerDynamicL2, writeCdo.get()));
132 
133  InDetDD::RawAlignmentObjects readCdoContainerDynamicL3;
134  readCdoContainerDynamicL3.emplace(m_readKeyDynamicL3.key(), readCdoDynamicL3);
135  ATH_CHECK(m_detManager->align(readCdoContainerDynamicL3, writeCdo.get()));
136 
137 
138  // IBL
139  if (!m_readKeyIBLDist.empty()) {
140  // This absolutely needs to go last, since it relies on deltas from other alignment
141  // already be set in the alignment store!!!
143  const CondAttrListCollection* readCdoIBLDist{*readHandleIBLDist};
144  if (readCdoIBLDist==nullptr) {
145  ATH_MSG_FATAL("Null pointer to the read conditions object of " << readHandleIBLDist.key());
146  return StatusCode::FAILURE;
147  }
148  writeHandle.addDependency(readHandleIBLDist);
149  InDetDD::RawAlignmentObjects readCdoContainerIBLDist;
150  readCdoContainerIBLDist.emplace(m_readKeyIBLDist.key(), readCdoIBLDist);
151  ATH_CHECK(m_detManager->align(readCdoContainerIBLDist, writeCdo.get()));
152  }
153 
154  }
155 
156  // Set (default) absolute transforms in alignment store by calling them.
157  for (const InDetDD::SiDetectorElement* oldEl: *oldColl) {
158  oldEl->getMaterialGeom()->getAbsoluteTransform(writeCdo.get());
159  oldEl->getMaterialGeom()->getDefAbsoluteTransform(writeCdo.get());
160  }
161  writeCdo->lockDelta();
162  writeCdo->lockPosCache();
163 
164  if (writeHandle.record(std::move(writeCdo)).isFailure()) {
165  ATH_MSG_FATAL("Could not record GeoAlignmentStore " << writeHandle.key()
166  << " with EventRange " << writeHandle.getRange()
167  << " into Conditions Store");
168  return StatusCode::FAILURE;
169  }
170  ATH_MSG_INFO("recorded new CDO " << writeHandle.key() << " with range " << writeHandle.getRange() << " into Conditions Store");
171 
172  return StatusCode::SUCCESS;
173 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
InDetDD::SiDetectorElementCollection
Definition: SiDetectorElementCollection.h:30
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
PixelAlignCondAlg::initialize
virtual StatusCode initialize() override
Definition: PixelAlignCondAlg.cxx:17
PixelAlignCondAlg::PixelAlignCondAlg
PixelAlignCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: PixelAlignCondAlg.cxx:12
CondMultChanCollection
A CondMultChanCollection is a template class which can hold a collection of T* objects which are inte...
Definition: CondMultChanCollection.h:52
PixelAlignCondAlg::execute
virtual StatusCode execute() override
Definition: PixelAlignCondAlg.cxx:38
InDetDD::RawAlignmentObjects
std::map< std::string, const void * > RawAlignmentObjects
Definition: InDetDetectorManager.h:43
PixelAlignCondAlg::m_useDynamicAlignFolders
BooleanProperty m_useDynamicAlignFolders
Definition: PixelAlignCondAlg.h:32
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
PixelAlignCondAlg::m_detManagerName
StringProperty m_detManagerName
Definition: PixelAlignCondAlg.h:48
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
PixelAlignCondAlg::m_readKeyDynamicL3
SG::ReadCondHandleKey< AlignableTransformContainer > m_readKeyDynamicL3
Definition: PixelAlignCondAlg.h:40
InDetDD::PixelDetectorManager::getDetectorElementCollection
virtual const SiDetectorElementCollection * getDetectorElementCollection() const override
access to whole collection via Iterators
Definition: PixelDetectorManager.cxx:105
PixelDetectorManager.h
PixelAlignCondAlg.h
PixelAlignCondAlg::m_readKeyDynamicL2
SG::ReadCondHandleKey< CondAttrListCollection > m_readKeyDynamicL2
Definition: PixelAlignCondAlg.h:38
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
AthAlgorithm
Definition: AthAlgorithm.h:47
PixelAlignCondAlg::m_readKeyStatic
SG::ReadCondHandleKey< AlignableTransformContainer > m_readKeyStatic
Definition: PixelAlignCondAlg.h:34
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
InDetDD::InDetDetectorManager::align
StatusCode align(IOVSVC_CALLBACK_ARGS) const
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
PixelAlignCondAlg::m_readKeyDynamicL1
SG::ReadCondHandleKey< CondAttrListCollection > m_readKeyDynamicL1
Definition: PixelAlignCondAlg.h:36
SiDetectorElement.h
PixelAlignCondAlg::m_readKeyIBLDist
SG::ReadCondHandleKey< CondAttrListCollection > m_readKeyIBLDist
Definition: PixelAlignCondAlg.h:42
PixelAlignCondAlg::m_detManager
const InDetDD::PixelDetectorManager * m_detManager
Definition: PixelAlignCondAlg.h:49
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
PixelAlignCondAlg::m_writeKey
SG::WriteCondHandleKey< GeoAlignmentStore > m_writeKey
Definition: PixelAlignCondAlg.h:45