ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetConditions
PixelConditionsAlgorithms
src
PixelDetectorElementCondAlg.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 "
PixelDetectorElementCondAlg.h
"
6
7
#include "
PixelReadoutGeometry/PixelDetectorManager.h
"
8
#include "
InDetReadoutGeometry/SiDetectorElement.h
"
9
#include "
TrkGeometry/Layer.h
"
10
#include "
TrkSurfaces/Surface.h
"
11
#include "
AthenaKernel/IOVInfiniteRange.h
"
12
13
#include <map>
14
15
PixelDetectorElementCondAlg::PixelDetectorElementCondAlg
(
const
std::string& name, ISvcLocator* pSvcLocator)
16
: ::
AthCondAlgorithm
(name, pSvcLocator)
17
{
18
declareProperty
(
"ReadKey"
,
m_readKey
);
19
}
20
21
StatusCode
PixelDetectorElementCondAlg::initialize
()
22
{
23
ATH_MSG_DEBUG
(
"initialize "
<< name());
24
25
// Read Handle
26
ATH_CHECK
(
m_readKey
.initialize());
27
28
// Write Handle
29
ATH_CHECK
(
m_writeKey
.initialize());
30
31
// We need the detector manager
32
ATH_CHECK
(
detStore
()->retrieve(
m_detManager
,
m_detManagerName
));
33
34
// used only if they exist
35
ATH_CHECK
(
m_trtDetElContKey
.initialize(
SG::AllowEmpty
));
36
ATH_CHECK
(
m_muonManagerKey
.initialize(
SG::AllowEmpty
));
37
ATH_CHECK
(
m_SCT_readKey
.initialize(
SG::AllowEmpty
));
38
39
return
StatusCode::SUCCESS;
40
}
41
42
StatusCode
PixelDetectorElementCondAlg::execute
(
const
EventContext& ctx)
const
43
{
44
ATH_MSG_DEBUG
(
"execute "
<< name());
45
46
// ____________ Construct Write Cond Handle and check its validity ____________
47
SG::WriteCondHandle<InDetDD::SiDetectorElementCollection>
writeHandle{
m_writeKey
, ctx};
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
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<InDetDD::SiDetectorElementCollection> writeCdo{std::make_unique<InDetDD::SiDetectorElementCollection>()};
65
66
// ____________ Get Read Cond Object ____________
67
SG::ReadCondHandle<GeoAlignmentStore>
readHandle{
m_readKey
, ctx};
68
const
GeoAlignmentStore
* readCdo{*readHandle};
69
if
(readCdo==
nullptr
) {
70
ATH_MSG_FATAL
(
"Null pointer to the read conditions object of "
<<
m_readKey
.key());
71
return
StatusCode::FAILURE;
72
}
73
74
// Make sure we make a mixed IOV.
75
writeHandle.
addDependency
(
IOVInfiniteRange::infiniteMixed
());
76
77
// Add dependency for IOV range
78
writeHandle.
addDependency
(readHandle);
79
// Additional dependencies for IOV range to limit lifetime to TrackingGeometry lifetime
80
if
(!
m_muonManagerKey
.empty()) {
81
SG::ReadCondHandle<MuonGM::MuonDetectorManager>
muonDependency{
m_muonManagerKey
, ctx};
82
if
(*muonDependency !=
nullptr
) {
83
writeHandle.
addDependency
(muonDependency);
84
}
else
{
85
ATH_MSG_ERROR
(
"MuonManager not found but configured"
);
86
return
StatusCode::FAILURE;
87
}
88
}
89
if
(!
m_trtDetElContKey
.empty()) {
90
SG::ReadCondHandle<InDetDD::TRT_DetElementContainer>
trtDependency{
m_trtDetElContKey
, ctx};
91
if
(*trtDependency !=
nullptr
) {
92
writeHandle.
addDependency
(trtDependency);
93
}
else
{
94
ATH_MSG_ERROR
(
"TRT DetEls not found but configured"
);
95
return
StatusCode::FAILURE;
96
}
97
}
98
if
(!
m_SCT_readKey
.empty()) {
99
SG::ReadCondHandle<GeoAlignmentStore>
sctDependency{
m_SCT_readKey
, ctx};
100
if
(*sctDependency !=
nullptr
) {
101
writeHandle.
addDependency
(sctDependency);
102
}
else
{
103
ATH_MSG_ERROR
(
"SCT AlignmentStore not found but configured"
);
104
return
StatusCode::FAILURE;
105
}
106
}
107
108
// ____________ Update writeCdo using readCdo ____________
109
std::map<const InDetDD::SiDetectorElement*, const InDetDD::SiDetectorElement*> oldToNewMap;
110
oldToNewMap[
nullptr
] =
nullptr
;
111
writeCdo->resize(oldColl->
size
());
112
InDetDD::SiDetectorElementCollection::iterator
newEl{writeCdo->begin()};
113
for
(
const
InDetDD::SiDetectorElement
* oldEl: *oldColl) {
114
*newEl =
new
InDetDD::SiDetectorElement
(oldEl->identify(),
115
&(oldEl->design()),
116
oldEl->GeoVDetectorElement::getMaterialGeom(),
117
oldEl->getCommonItems(),
118
readCdo);
119
oldToNewMap[oldEl] = *newEl;
120
++newEl;
121
}
122
123
// Set neighbours and other side
124
// Set layer to surface
125
InDetDD::SiDetectorElementCollection::const_iterator
oldIt{oldColl->
begin
()};
126
for
(
InDetDD::SiDetectorElement
* newEl: *writeCdo) {
127
if
(oldToNewMap[(*oldIt)]!=newEl) {
128
ATH_MSG_ERROR
(
"Old and new elements are not synchronized!"
);
129
}
130
newEl->setNextInEta(oldToNewMap[(*oldIt)->nextInEta()]);
131
newEl->setPrevInEta(oldToNewMap[(*oldIt)->prevInEta()]);
132
newEl->setNextInPhi(oldToNewMap[(*oldIt)->nextInPhi()]);
133
newEl->setPrevInPhi(oldToNewMap[(*oldIt)->prevInPhi()]);
134
135
//Note here we set the Layer but then is redo in
136
//Tracking Geometry which should be the last MT const correctness issue
137
const
Trk::Layer
* layer{(*oldIt)->surface().associatedLayer()};
138
if
(layer) {
139
newEl->surface().associateLayer(*layer);
140
}
141
++oldIt;
142
}
143
144
// Apply alignment using readCdo passed to SiDetectorElement
145
for
(
InDetDD::SiDetectorElement
* newEl: *writeCdo) {
146
newEl->updateCache();
147
}
148
149
// Record WriteCondHandle
150
const
std::size_t
size
{writeCdo->size()};
151
if
(writeHandle.
record
(std::move(writeCdo)).isFailure()) {
152
ATH_MSG_FATAL
(
"Could not record "
<< writeHandle.
key
()
153
<<
" with EventRange "
<< writeHandle.
getRange
()
154
<<
" into Conditions Store"
);
155
return
StatusCode::FAILURE;
156
}
157
ATH_MSG_INFO
(
"recorded new CDO "
<< writeHandle.
key
() <<
" with range "
<< writeHandle.
getRange
()
158
<<
" with size of "
<<
size
<<
" into Conditions Store"
);
159
160
return
StatusCode::SUCCESS;
161
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
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
IOVInfiniteRange.h
Layer.h
PixelDetectorElementCondAlg.h
PixelDetectorManager.h
SiDetectorElement.h
size
size_t size() const
Number of registered mappings.
Surface.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
DataVector< SiDetectorElement >::const_iterator
DataModel_detail::const_iterator< DataVector > const_iterator
Definition
DataVector.h:838
DataVector< SiDetectorElement >::iterator
DataModel_detail::iterator< DataVector > iterator
Definition
DataVector.h:842
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
GeoAlignmentStore
Ensure that the extensions for the Vector3D are properly loaded.
Definition
GeoAlignmentStore.h:24
IOVInfiniteRange::infiniteMixed
static EventIDRange infiniteMixed()
Produces an mixed EventIDRange that is infinite in Time and RunLumi.
Definition
IOVInfiniteRange.h:55
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
PixelDetectorElementCondAlg::m_detManagerName
StringProperty m_detManagerName
Definition
PixelDetectorElementCondAlg.h:52
PixelDetectorElementCondAlg::m_readKey
SG::ReadCondHandleKey< GeoAlignmentStore > m_readKey
Definition
PixelDetectorElementCondAlg.h:38
PixelDetectorElementCondAlg::PixelDetectorElementCondAlg
PixelDetectorElementCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
PixelDetectorElementCondAlg.cxx:15
PixelDetectorElementCondAlg::m_writeKey
SG::WriteCondHandleKey< InDetDD::SiDetectorElementCollection > m_writeKey
Definition
PixelDetectorElementCondAlg.h:41
PixelDetectorElementCondAlg::m_trtDetElContKey
SG::ReadCondHandleKey< InDetDD::TRT_DetElementContainer > m_trtDetElContKey
Definition
PixelDetectorElementCondAlg.h:48
PixelDetectorElementCondAlg::m_detManager
const InDetDD::PixelDetectorManager * m_detManager
Definition
PixelDetectorElementCondAlg.h:53
PixelDetectorElementCondAlg::m_muonManagerKey
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_muonManagerKey
Definition
PixelDetectorElementCondAlg.h:46
PixelDetectorElementCondAlg::initialize
virtual StatusCode initialize() override final
Definition
PixelDetectorElementCondAlg.cxx:21
PixelDetectorElementCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition
PixelDetectorElementCondAlg.cxx:42
PixelDetectorElementCondAlg::m_SCT_readKey
SG::ReadCondHandleKey< GeoAlignmentStore > m_SCT_readKey
Definition
PixelDetectorElementCondAlg.h:50
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
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
Trk::Layer
Base Class for a Detector Layer in the Tracking realm.
Definition
Layer.h:72
SG::AllowEmpty
@ AllowEmpty
Definition
StoreGate/StoreGate/VarHandleKey.h:27
Generated on
for ATLAS Offline Software by
1.17.0