ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
HighGranularityTimingDetector
HGTD_Conditions
HGTD_ConditionsAlgorithms
src
HGTD_DetectorElementCondAlg.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 "
HGTD_DetectorElementCondAlg.h
"
6
7
#include "
HGTD_ReadoutGeometry/HGTD_DetectorManager.h
"
8
#include "
HGTD_ReadoutGeometry/HGTD_DetectorElement.h
"
9
#include "
TrkGeometry/Layer.h
"
10
#include "
TrkSurfaces/Surface.h
"
11
#include "
AthenaKernel/IOVInfiniteRange.h
"
12
13
#include <map>
14
15
HGTD_DetectorElementCondAlg::HGTD_DetectorElementCondAlg
(
const
std::string& name, ISvcLocator* pSvcLocator)
16
: ::
AthCondAlgorithm
(name, pSvcLocator)
17
{
18
}
19
20
StatusCode
HGTD_DetectorElementCondAlg::initialize
()
21
{
22
ATH_MSG_DEBUG
(
"initialize "
<< name());
23
24
// Write Handle
25
ATH_CHECK
(
m_writeKey
.initialize());
26
27
// We need the detector manager
28
ATH_CHECK
(
detStore
()->retrieve(
m_detManager
,
m_detManagerName
));
29
30
return
StatusCode::SUCCESS;
31
}
32
33
StatusCode
HGTD_DetectorElementCondAlg::execute
(
const
EventContext& ctx)
const
34
{
35
ATH_MSG_DEBUG
(
"execute "
<< name());
36
37
// ____________ Construct Write Cond Handle and check its validity ____________
38
SG::WriteCondHandle<InDetDD::HGTD_DetectorElementCollection>
writeHandle{
m_writeKey
, ctx};
39
40
// Do we have a valid Write Cond Handle for current time?
41
if
(writeHandle.
isValid
()) {
42
ATH_MSG_DEBUG
(
"CondHandle "
<< writeHandle.
fullKey
() <<
" is already valid."
43
<<
". In theory this should not be called, but may happen"
44
<<
" if multiple concurrent events are being processed out of order."
);
45
return
StatusCode::SUCCESS;
46
}
47
48
const
InDetDD::HGTD_DetectorElementCollection
* oldColl{
m_detManager
->getDetectorElementCollection()};
49
if
(oldColl==
nullptr
) {
50
ATH_MSG_FATAL
(
"Null pointer is returned by getDetectorElementCollection()"
);
51
return
StatusCode::FAILURE;
52
}
53
54
// ____________ Construct new Write Cond Object ____________
55
std::unique_ptr<InDetDD::HGTD_DetectorElementCollection> writeCdo{std::make_unique<InDetDD::HGTD_DetectorElementCollection>()};
56
57
// Make sure we make a mixed IOV.
58
writeHandle.
addDependency
(
IOVInfiniteRange::infiniteMixed
());
59
60
// ____________ Update writeCdo ____________
61
std::map<const InDetDD::HGTD_DetectorElement*, const InDetDD::HGTD_DetectorElement*> oldToNewMap;
62
oldToNewMap[
nullptr
] =
nullptr
;
63
writeCdo->resize(oldColl->
size
());
64
InDetDD::HGTD_DetectorElementCollection::iterator
newEl{writeCdo->begin()};
65
for
(
const
InDetDD::HGTD_DetectorElement
* oldEl: *oldColl) {
66
*newEl =
new
InDetDD::HGTD_DetectorElement
(oldEl->identify(),
67
&(oldEl->design()),
68
oldEl->GeoVDetectorElement::getMaterialGeom(),
69
oldEl->getCommonItems());
70
oldToNewMap[oldEl] = *newEl;
71
++newEl;
72
}
73
74
// Set layer to surface
75
InDetDD::HGTD_DetectorElementCollection::const_iterator
oldIt{oldColl->
begin
()};
76
for
(
InDetDD::HGTD_DetectorElement
* newEl: *writeCdo) {
77
if
(oldToNewMap[(*oldIt)]!=newEl) {
78
ATH_MSG_ERROR
(
"Old and new elements are not synchronized!"
);
79
}
80
const
Trk::Layer
* layer{(*oldIt)->surface().associatedLayer()};
81
if
(layer) {
82
//NOTE!!! associateLayer occurs here but it also occurs
83
//later in the layer builder
84
newEl->surface().associateLayer(*layer);
85
}
86
++oldIt;
87
}
88
89
// Apply alignment using readCdo passed to HGTD_DetectorElement
90
for
(
InDetDD::HGTD_DetectorElement
* newEl: *writeCdo) {
91
newEl->updateCache();
92
}
93
94
// Record WriteCondHandle
95
const
std::size_t
size
{writeCdo->size()};
96
if
(writeHandle.
record
(std::move(writeCdo)).isFailure()) {
97
ATH_MSG_FATAL
(
"Could not record "
<< writeHandle.
key
()
98
<<
" with EventRange "
<< writeHandle.
getRange
()
99
<<
" into Conditions Store"
);
100
return
StatusCode::FAILURE;
101
}
102
ATH_MSG_INFO
(
"recorded new CDO "
<< writeHandle.
key
() <<
" with range "
<< writeHandle.
getRange
()
103
<<
" with size of "
<<
size
<<
" into Conditions Store"
);
104
105
return
StatusCode::SUCCESS;
106
}
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
HGTD_DetectorElementCondAlg.h
HGTD_DetectorElement.h
HGTD_DetectorManager.h
IOVInfiniteRange.h
Layer.h
size
size_t size() const
Number of registered mappings.
Surface.h
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
AthCondAlgorithm
Base class for conditions algorithms.
Definition
AthCondAlgorithm.h:22
DataVector< HGTD_DetectorElement >::const_iterator
DataModel_detail::const_iterator< DataVector > const_iterator
Definition
DataVector.h:838
DataVector< HGTD_DetectorElement >::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.
HGTD_DetectorElementCondAlg::m_writeKey
SG::WriteCondHandleKey< InDetDD::HGTD_DetectorElementCollection > m_writeKey
Definition
HGTD_DetectorElementCondAlg.h:31
HGTD_DetectorElementCondAlg::initialize
virtual StatusCode initialize() override final
Definition
HGTD_DetectorElementCondAlg.cxx:20
HGTD_DetectorElementCondAlg::m_detManager
const HGTD_DetectorManager * m_detManager
Definition
HGTD_DetectorElementCondAlg.h:34
HGTD_DetectorElementCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition
HGTD_DetectorElementCondAlg.cxx:33
HGTD_DetectorElementCondAlg::HGTD_DetectorElementCondAlg
HGTD_DetectorElementCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
HGTD_DetectorElementCondAlg.cxx:15
HGTD_DetectorElementCondAlg::m_detManagerName
StringProperty m_detManagerName
Definition
HGTD_DetectorElementCondAlg.h:33
IOVInfiniteRange::infiniteMixed
static EventIDRange infiniteMixed()
Produces an mixed EventIDRange that is infinite in Time and RunLumi.
Definition
IOVInfiniteRange.h:55
InDetDD::HGTD_DetectorElement
Class to hold geometrical description of an HGTD detector element.
Definition
HGTD_DetectorElement.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
InDetDD::HGTD_DetectorElementCollection
DataVector< HGTD_DetectorElement > HGTD_DetectorElementCollection
Definition
HGTD_DetectorElementCollection.h:20
Generated on
for ATLAS Offline Software by
1.17.0