ATLAS Offline Software
Loading...
Searching...
No Matches
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
12SCT_AlignCondAlg::SCT_AlignCondAlg(const std::string& name, ISvcLocator* pSvcLocator)
13 : ::AthCondAlgorithm(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
34 ATH_CHECK(m_writeKey.initialize());
35
37
38 return StatusCode::SUCCESS;
39}
40
41StatusCode SCT_AlignCondAlg::execute(const EventContext& ctx) const
42{
43 ATH_MSG_DEBUG("execute " << name());
44
45 // ____________ Construct Write Cond Handle and check its validity ____________
47
48 // Do we have a valid Write Cond Handle for current time?
49 if (writeHandle.isValid()) {
50 ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid."
51 << ". In theory this should not be called, but may happen"
52 << " if multiple concurrent events are being processed out of order.");
53 return StatusCode::SUCCESS;
54 }
55
56 // Get SiDetectorElements
57 const InDetDD::SiDetectorElementCollection* oldColl{m_detManager->getDetectorElementCollection()};
58 if (oldColl==nullptr) {
59 ATH_MSG_FATAL("Null pointer is returned by getDetectorElementCollection()");
60 return StatusCode::FAILURE;
61 }
62
63 // ____________ Construct new Write Cond Object ____________
64 std::unique_ptr<GeoAlignmentStore> writeCdo{std::make_unique<GeoAlignmentStore>()};
65
66 if (not m_useDynamicAlignFolders) { // Static
67 // ____________ Get Read Cond Object ____________
69 const AlignableTransformContainer* readCdoStatic{*readHandleStatic};
70 if (readCdoStatic==nullptr) {
71 ATH_MSG_FATAL("Null pointer to the read conditions object of " << m_readKeyStatic.key());
72 return StatusCode::FAILURE;
73 }
74 // ____________ Apply alignments to SCT 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 // Add dependency
81 writeHandle.addDependency(readHandleStatic);
82 } else { // Dynamic
83 // ____________ Get Read Cond Object ____________
85 const CondAttrListCollection* readCdoDynamicL1{*readHandleDynamicL1};
86 if (readCdoDynamicL1==nullptr) {
87 ATH_MSG_FATAL("Null pointer to the read conditions object of " << m_readKeyDynamicL1.key());
88 return StatusCode::FAILURE;
89 }
91 const CondAttrListCollection* readCdoDynamicL2{*readHandleDynamicL2};
92 if (readCdoDynamicL2==nullptr) {
93 ATH_MSG_FATAL("Null pointer to the read conditions object of " << readHandleDynamicL2.key());
94 return StatusCode::FAILURE;
95 }
97 const AlignableTransformContainer* readCdoDynamicL3{*readHandleDynamicL3};
98 if (readCdoDynamicL3==nullptr) {
99 ATH_MSG_FATAL("Null pointer to the read conditions object of " << readHandleDynamicL3.key());
100 return StatusCode::FAILURE;
101 }
102 // ____________ Apply alignments to SCT GeoModel ____________
103 // Construct Container for read CDO-s.
104 InDetDD::RawAlignmentObjects readCdoContainerDynamicL1;
105 readCdoContainerDynamicL1.emplace(m_readKeyDynamicL1.key(), readCdoDynamicL1);
106 ATH_CHECK(m_detManager->align(readCdoContainerDynamicL1, writeCdo.get()));
107 InDetDD::RawAlignmentObjects readCdoContainerDynamicL2;
108 readCdoContainerDynamicL2.emplace(m_readKeyDynamicL2.key(), readCdoDynamicL2);
109 ATH_CHECK(m_detManager->align(readCdoContainerDynamicL2, writeCdo.get()));
110 InDetDD::RawAlignmentObjects readCdoContainerDynamicL3;
111 readCdoContainerDynamicL3.emplace(m_readKeyDynamicL3.key(), readCdoDynamicL3);
112 ATH_CHECK(m_detManager->align(readCdoContainerDynamicL3, writeCdo.get()));
113
114 // Add dependency
115 writeHandle.addDependency(readHandleDynamicL1);
116 writeHandle.addDependency(readHandleDynamicL2);
117 writeHandle.addDependency(readHandleDynamicL3);
118 }
119
120 // Set (default) absolute transforms in alignment store by calling them.
121 for (const InDetDD::SiDetectorElement* oldEl: *oldColl) {
122 oldEl->getMaterialGeom()->getAbsoluteTransform(writeCdo.get());
123 oldEl->getMaterialGeom()->getDefAbsoluteTransform(writeCdo.get());
124 }
125
126 writeCdo->lockDelta();
127 writeCdo->lockPosCache();
128
129
130 if (writeHandle.record(std::move(writeCdo)).isFailure()) {
131 ATH_MSG_FATAL("Could not record GeoAlignmentStore " << writeHandle.key()
132 << " with EventRange " << writeHandle.getRange()
133 << " into Conditions Store");
134 return StatusCode::FAILURE;
135 }
136 ATH_MSG_INFO("recorded new CDO " << writeHandle.key() << " with range " << writeHandle.getRange() << " into Conditions Store");
137
138 return StatusCode::SUCCESS;
139}
140
142{
143 ATH_MSG_DEBUG("finalize " << name());
144 return StatusCode::SUCCESS;
145}
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)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
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.
SG::ReadCondHandleKey< CondAttrListCollection > m_readKeyDynamicL2
SG::ReadCondHandleKey< AlignableTransformContainer > m_readKeyDynamicL3
BooleanProperty m_useDynamicAlignFolders
const InDetDD::SCT_DetectorManager * m_detManager
virtual StatusCode execute(const EventContext &ctx) const override
std::string m_DetManagerName
virtual StatusCode finalize() override
SG::ReadCondHandleKey< CondAttrListCollection > m_readKeyDynamicL1
SG::WriteCondHandleKey< GeoAlignmentStore > m_writeKey
SCT_AlignCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize() override
SG::ReadCondHandleKey< AlignableTransformContainer > m_readKeyStatic
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