ATLAS Offline Software
SCT_AlignCondAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "SCT_AlignCondAlg.h"
6 
9 
10 #include <memory>
11 
12 SCT_AlignCondAlg::SCT_AlignCondAlg(const std::string& name, ISvcLocator* pSvcLocator)
13  : ::AthAlgorithm(name, pSvcLocator)
14  , m_writeKey{"SCTAlignmentStore", "SCTAlignmentStore"}
15  , m_DetManagerName("SCT")
16 {
17  declareProperty("WriteKey", m_writeKey);
18  declareProperty("DetManagerName", m_DetManagerName);
19 }
20 
22 {
23  ATH_MSG_DEBUG("initialize " << name());
24 
25  // Read Handles
26  // Static
28  // Dynamic
32 
33  // Write Handles
35 
37 
38  return StatusCode::SUCCESS;
39 }
40 
42 {
43  ATH_MSG_DEBUG("execute " << name());
44 
45  const EventContext& ctx = Gaudi::Hive::currentContext();
46  // ____________ Construct Write Cond Handle and check its validity ____________
48 
49  // Do we have a valid Write Cond Handle for current time?
50  if (writeHandle.isValid()) {
51  ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid."
52  << ". In theory this should not be called, but may happen"
53  << " if multiple concurrent events are being processed out of order.");
54  return StatusCode::SUCCESS;
55  }
56 
57  // Get SiDetectorElements
59  if (oldColl==nullptr) {
60  ATH_MSG_FATAL("Null pointer is returned by getDetectorElementCollection()");
61  return StatusCode::FAILURE;
62  }
63 
64  // ____________ Construct new Write Cond Object ____________
65  std::unique_ptr<GeoAlignmentStore> writeCdo{std::make_unique<GeoAlignmentStore>()};
66 
67  if (not m_useDynamicAlignFolders) { // Static
68  // ____________ Get Read Cond Object ____________
70  const AlignableTransformContainer* readCdoStatic{*readHandleStatic};
71  if (readCdoStatic==nullptr) {
72  ATH_MSG_FATAL("Null pointer to the read conditions object of " << m_readKeyStatic.key());
73  return StatusCode::FAILURE;
74  }
75  // ____________ Apply alignments to SCT GeoModel ____________
76  // Construct Container for read CDO.
77  InDetDD::RawAlignmentObjects readCdoContainerStatic;
78  readCdoContainerStatic.emplace(m_readKeyStatic.key(), readCdoStatic);
79  ATH_CHECK(m_detManager->align(readCdoContainerStatic, writeCdo.get()));
80 
81  // Add dependency
82  writeHandle.addDependency(readHandleStatic);
83  } else { // Dynamic
84  // ____________ Get Read Cond Object ____________
86  const CondAttrListCollection* readCdoDynamicL1{*readHandleDynamicL1};
87  if (readCdoDynamicL1==nullptr) {
88  ATH_MSG_FATAL("Null pointer to the read conditions object of " << m_readKeyDynamicL1.key());
89  return StatusCode::FAILURE;
90  }
92  const CondAttrListCollection* readCdoDynamicL2{*readHandleDynamicL2};
93  if (readCdoDynamicL2==nullptr) {
94  ATH_MSG_FATAL("Null pointer to the read conditions object of " << readHandleDynamicL2.key());
95  return StatusCode::FAILURE;
96  }
98  const AlignableTransformContainer* readCdoDynamicL3{*readHandleDynamicL3};
99  if (readCdoDynamicL3==nullptr) {
100  ATH_MSG_FATAL("Null pointer to the read conditions object of " << readHandleDynamicL3.key());
101  return StatusCode::FAILURE;
102  }
103  // ____________ Apply alignments to SCT GeoModel ____________
104  // Construct Container for read CDO-s.
105  InDetDD::RawAlignmentObjects readCdoContainerDynamicL1;
106  readCdoContainerDynamicL1.emplace(m_readKeyDynamicL1.key(), readCdoDynamicL1);
107  ATH_CHECK(m_detManager->align(readCdoContainerDynamicL1, writeCdo.get()));
108  InDetDD::RawAlignmentObjects readCdoContainerDynamicL2;
109  readCdoContainerDynamicL2.emplace(m_readKeyDynamicL2.key(), readCdoDynamicL2);
110  ATH_CHECK(m_detManager->align(readCdoContainerDynamicL2, writeCdo.get()));
111  InDetDD::RawAlignmentObjects readCdoContainerDynamicL3;
112  readCdoContainerDynamicL3.emplace(m_readKeyDynamicL3.key(), readCdoDynamicL3);
113  ATH_CHECK(m_detManager->align(readCdoContainerDynamicL3, writeCdo.get()));
114 
115  // Add dependency
116  writeHandle.addDependency(readHandleDynamicL1);
117  writeHandle.addDependency(readHandleDynamicL2);
118  writeHandle.addDependency(readHandleDynamicL3);
119  }
120 
121  // Set (default) absolute transforms in alignment store by calling them.
122  for (const InDetDD::SiDetectorElement* oldEl: *oldColl) {
123  oldEl->getMaterialGeom()->getAbsoluteTransform(writeCdo.get());
124  oldEl->getMaterialGeom()->getDefAbsoluteTransform(writeCdo.get());
125  }
126 
127  writeCdo->lockDelta();
128  writeCdo->lockPosCache();
129 
130 
131  if (writeHandle.record(std::move(writeCdo)).isFailure()) {
132  ATH_MSG_FATAL("Could not record GeoAlignmentStore " << writeHandle.key()
133  << " with EventRange " << writeHandle.getRange()
134  << " into Conditions Store");
135  return StatusCode::FAILURE;
136  }
137  ATH_MSG_INFO("recorded new CDO " << writeHandle.key() << " with range " << writeHandle.getRange() << " into Conditions Store");
138 
139  return StatusCode::SUCCESS;
140 }
141 
143 {
144  ATH_MSG_DEBUG("finalize " << name());
145  return StatusCode::SUCCESS;
146 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SCT_AlignCondAlg::finalize
virtual StatusCode finalize() override
Definition: SCT_AlignCondAlg.cxx:142
InDetDD::SiDetectorElementCollection
Definition: SiDetectorElementCollection.h:30
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CondMultChanCollection
A CondMultChanCollection is a template class which can hold a collection of T* objects which are inte...
Definition: CondMultChanCollection.h:52
SCT_AlignCondAlg::m_readKeyDynamicL2
SG::ReadCondHandleKey< CondAttrListCollection > m_readKeyDynamicL2
Definition: SCT_AlignCondAlg.h:51
InDetDD::RawAlignmentObjects
std::map< std::string, const void * > RawAlignmentObjects
Definition: InDetDetectorManager.h:43
SCT_AlignCondAlg::m_readKeyDynamicL3
SG::ReadCondHandleKey< AlignableTransformContainer > m_readKeyDynamicL3
Definition: SCT_AlignCondAlg.h:52
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
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
SCT_AlignCondAlg::m_DetManagerName
std::string m_DetManagerName
Definition: SCT_AlignCondAlg.h:56
InDetDD::SCT_DetectorManager::getDetectorElementCollection
virtual const SiDetectorElementCollection * getDetectorElementCollection() const override
access to whole collectiom
Definition: SCT_DetectorManager.cxx:88
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
SCT_AlignCondAlg::m_useDynamicAlignFolders
BooleanProperty m_useDynamicAlignFolders
Definition: SCT_AlignCondAlg.h:48
SCT_AlignCondAlg::SCT_AlignCondAlg
SCT_AlignCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: SCT_AlignCondAlg.cxx:12
AthAlgorithm
Definition: AthAlgorithm.h:47
SCT_AlignCondAlg.h
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)
SCT_AlignCondAlg::m_readKeyDynamicL1
SG::ReadCondHandleKey< CondAttrListCollection > m_readKeyDynamicL1
Definition: SCT_AlignCondAlg.h:50
SiDetectorElement.h
SCT_AlignCondAlg::m_writeKey
SG::WriteCondHandleKey< GeoAlignmentStore > m_writeKey
Definition: SCT_AlignCondAlg.h:53
SCT_DetectorManager.h
SCT_AlignCondAlg::execute
virtual StatusCode execute() override
Definition: SCT_AlignCondAlg.cxx:41
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
SCT_AlignCondAlg::initialize
virtual StatusCode initialize() override
Definition: SCT_AlignCondAlg.cxx:21
SCT_AlignCondAlg::m_readKeyStatic
SG::ReadCondHandleKey< AlignableTransformContainer > m_readKeyStatic
Definition: SCT_AlignCondAlg.h:49
SCT_AlignCondAlg::m_detManager
const InDetDD::SCT_DetectorManager * m_detManager
Definition: SCT_AlignCondAlg.h:55