ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetConditions
SCT_ConditionsAlgorithms
src
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
7
#include "
SCT_ReadoutGeometry/SCT_DetectorManager.h
"
8
#include "
InDetReadoutGeometry/SiDetectorElement.h
"
9
10
#include <memory>
11
12
SCT_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
21
StatusCode
SCT_AlignCondAlg::initialize
()
22
{
23
ATH_MSG_DEBUG
(
"initialize "
<< name());
24
25
// Read Handles
26
// Static
27
ATH_CHECK
(
m_readKeyStatic
.initialize(not
m_useDynamicAlignFolders
));
28
// Dynamic
29
ATH_CHECK
(
m_readKeyDynamicL1
.initialize(
m_useDynamicAlignFolders
));
30
ATH_CHECK
(
m_readKeyDynamicL2
.initialize(
m_useDynamicAlignFolders
));
31
ATH_CHECK
(
m_readKeyDynamicL3
.initialize(
m_useDynamicAlignFolders
));
32
33
// Write Handles
34
ATH_CHECK
(
m_writeKey
.initialize());
35
36
ATH_CHECK
(
detStore
()->retrieve(
m_detManager
,
m_DetManagerName
));
37
38
return
StatusCode::SUCCESS;
39
}
40
41
StatusCode
SCT_AlignCondAlg::execute
(
const
EventContext& ctx)
const
42
{
43
ATH_MSG_DEBUG
(
"execute "
<< name());
44
45
// ____________ Construct Write Cond Handle and check its validity ____________
46
SG::WriteCondHandle<GeoAlignmentStore>
writeHandle{
m_writeKey
, ctx};
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 ____________
68
SG::ReadCondHandle<AlignableTransformContainer>
readHandleStatic{
m_readKeyStatic
, ctx};
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 ____________
84
SG::ReadCondHandle<CondAttrListCollection>
readHandleDynamicL1{
m_readKeyDynamicL1
, ctx};
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
}
90
SG::ReadCondHandle<CondAttrListCollection>
readHandleDynamicL2{
m_readKeyDynamicL2
, ctx};
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
}
96
SG::ReadCondHandle<AlignableTransformContainer>
readHandleDynamicL3{
m_readKeyDynamicL3
, ctx};
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
141
StatusCode
SCT_AlignCondAlg::finalize
()
142
{
143
ATH_MSG_DEBUG
(
"finalize "
<< name());
144
return
StatusCode::SUCCESS;
145
}
AlignableTransformContainer
CondMultChanCollection< AlignableTransform > AlignableTransformContainer
Definition
AlignableTransformContainer.h:17
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition
AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
SCT_AlignCondAlg.h
SCT_DetectorManager.h
SiDetectorElement.h
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
AthCondAlgorithm
Base class for conditions algorithms.
Definition
AthCondAlgorithm.h:22
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number.
Definition
CondAttrListCollection.h:51
InDetDD::SiDetectorElementCollection
Class to hold the SiDetectorElement objects to be put in the detector store.
Definition
SiDetectorElementCollection.h:27
InDetDD::SiDetectorElement
Class to hold geometrical description of a silicon detector element.
Definition
SiDetectorElement.h:109
SCT_AlignCondAlg::m_readKeyDynamicL2
SG::ReadCondHandleKey< CondAttrListCollection > m_readKeyDynamicL2
Definition
SCT_AlignCondAlg.h:51
SCT_AlignCondAlg::m_readKeyDynamicL3
SG::ReadCondHandleKey< AlignableTransformContainer > m_readKeyDynamicL3
Definition
SCT_AlignCondAlg.h:52
SCT_AlignCondAlg::m_useDynamicAlignFolders
BooleanProperty m_useDynamicAlignFolders
Definition
SCT_AlignCondAlg.h:48
SCT_AlignCondAlg::m_detManager
const InDetDD::SCT_DetectorManager * m_detManager
Definition
SCT_AlignCondAlg.h:55
SCT_AlignCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
SCT_AlignCondAlg.cxx:41
SCT_AlignCondAlg::m_DetManagerName
std::string m_DetManagerName
Definition
SCT_AlignCondAlg.h:56
SCT_AlignCondAlg::finalize
virtual StatusCode finalize() override
Definition
SCT_AlignCondAlg.cxx:141
SCT_AlignCondAlg::m_readKeyDynamicL1
SG::ReadCondHandleKey< CondAttrListCollection > m_readKeyDynamicL1
Definition
SCT_AlignCondAlg.h:50
SCT_AlignCondAlg::m_writeKey
SG::WriteCondHandleKey< GeoAlignmentStore > m_writeKey
Definition
SCT_AlignCondAlg.h:53
SCT_AlignCondAlg::SCT_AlignCondAlg
SCT_AlignCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
SCT_AlignCondAlg.cxx:12
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
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
SG::ReadCondHandle::key
const std::string & key() const
Definition
ReadCondHandle.h:59
SG::WriteCondHandle
Definition
WriteCondHandle.h:26
SG::WriteCondHandle::key
const std::string & key() const
Definition
WriteCondHandle.h:44
SG::WriteCondHandle::addDependency
void addDependency(const EventIDRange &range)
Definition
WriteCondHandle.h:279
SG::WriteCondHandle::getRange
const EventIDRange & getRange() const
Definition
WriteCondHandle.h:93
SG::WriteCondHandle::record
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
Definition
WriteCondHandle.h:161
SG::WriteCondHandle::isValid
bool isValid() const
Definition
WriteCondHandle.h:252
SG::WriteCondHandle::fullKey
const DataObjID & fullKey() const
Definition
WriteCondHandle.h:45
InDetDD::RawAlignmentObjects
std::map< std::string, const void * > RawAlignmentObjects
Definition
InDetDetectorManager.h:40
Generated on
for ATLAS Offline Software by
1.17.0