ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetRecAlgs
InDetPrepRawDataFormation
src
SiDetectorElementStatusCondAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
SiDetectorElementStatusCondAlg.h
"
6
7
#include "
InDetReadoutGeometry/SiDetectorElementCollection.h
"
8
#include "
InDetReadoutGeometry/SiDetectorElement.h
"
9
#include "
StoreGate/WriteHandle.h
"
10
#include "
AthenaKernel/IOVInfiniteRange.h
"
11
12
#include <map>
13
14
namespace
{
15
unsigned
int
computeSize(
const
std::vector<std::vector<unsigned short> > &vec2d) {
16
unsigned
int
total_size =
sizeof
(vec2d);
17
for
(
const
std::vector<unsigned short> &
vec
: vec2d) {
18
total_size +=
sizeof
(
vec
) +
vec
.size()*
sizeof
(
unsigned
short
);
19
}
20
return
total_size;
21
}
22
}
23
24
namespace
InDet
{
25
SiDetectorElementStatusCondAlg::SiDetectorElementStatusCondAlg
(
const
std::string& name, ISvcLocator* pSvcLocator)
26
: ::
AthCondAlgorithm
(name, pSvcLocator)
27
{
28
}
29
30
StatusCode
SiDetectorElementStatusCondAlg::initialize
()
31
{
32
ATH_CHECK
(
m_condSummaryTool
.empty() ? StatusCode::FAILURE : StatusCode::SUCCESS);
33
ATH_CHECK
(
m_condSummaryTool
.retrieve());
34
ATH_CHECK
(
m_writeKey
.initialize());
35
return
StatusCode::SUCCESS;
36
}
37
38
StatusCode
SiDetectorElementStatusCondAlg::execute
(
const
EventContext& ctx)
const
39
{
40
SG::WriteCondHandle<InDet::SiDetectorElementStatus>
writeHandle{
m_writeKey
, ctx};
41
if
(writeHandle.
isValid
()) {
42
return
StatusCode::SUCCESS;
43
}
44
45
// Start with infinite range and let the tool narrow it down.
46
writeHandle.
addDependency
(
IOVInfiniteRange::infiniteMixed
());
47
48
auto
detector_element_status=
m_condSummaryTool
->getDetectorElementStatus(ctx, &writeHandle);
49
const
EventIDRange& range = writeHandle.
getRange
();
50
if
(!range.start().isValid() || !range.stop().isValid()) {
51
ATH_MSG_FATAL
(
"Invalid range for "
<< writeHandle.
key
() <<
" : "
<< range.start() <<
".."
<< range.stop());
52
}
53
unsigned
int
total_size = computeSize(
static_cast<
const
InDet::SiDetectorElementStatus
*
>
(detector_element_status.get())->
getBadCells
() );
54
{
55
unsigned
int
expected;
56
do
{
57
expected =
m_maxSize
;
58
}
while
(total_size > expected && !
m_maxSize
.compare_exchange_weak(expected, total_size,std::memory_order_release,std::memory_order_relaxed));
59
}
60
if
(writeHandle.
record
( std::move(detector_element_status) ).isFailure()) {
61
ATH_MSG_FATAL
(
"Could not record "
<< writeHandle.
key
() );
62
}
63
ATH_MSG_DEBUG
(
"SiDetectorElementStatus Recorded "
<< writeHandle.
key
() <<
" with Range : "
<< range );
64
return
StatusCode::SUCCESS;
65
}
66
67
StatusCode
SiDetectorElementStatusCondAlg::finalize
()
68
{
69
ATH_MSG_DEBUG
(
"Max badCell size "
<<
m_maxSize
);
70
return
StatusCode::SUCCESS;
71
}
72
}
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_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
vec
std::vector< size_t > vec
Definition
CombinationsGeneratorTest.cxx:9
IOVInfiniteRange.h
SiDetectorElementCollection.h
SiDetectorElementStatusCondAlg.h
SiDetectorElement.h
WriteHandle.h
Handle class for recording to StoreGate.
AthCondAlgorithm
Base class for conditions algorithms.
Definition
AthCondAlgorithm.h:22
IOVInfiniteRange::infiniteMixed
static EventIDRange infiniteMixed()
Produces an mixed EventIDRange that is infinite in Time and RunLumi.
Definition
IOVInfiniteRange.h:55
InDet::SiDetectorElementStatusCondAlg::initialize
virtual StatusCode initialize() override final
Definition
SiDetectorElementStatusCondAlg.cxx:30
InDet::SiDetectorElementStatusCondAlg::m_maxSize
std::atomic< unsigned int > m_maxSize
Definition
SiDetectorElementStatusCondAlg.h:34
InDet::SiDetectorElementStatusCondAlg::finalize
virtual StatusCode finalize() override final
Definition
SiDetectorElementStatusCondAlg.cxx:67
InDet::SiDetectorElementStatusCondAlg::SiDetectorElementStatusCondAlg
SiDetectorElementStatusCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
SiDetectorElementStatusCondAlg.cxx:25
InDet::SiDetectorElementStatusCondAlg::m_writeKey
SG::WriteCondHandleKey< InDet::SiDetectorElementStatus > m_writeKey
Definition
SiDetectorElementStatusCondAlg.h:33
InDet::SiDetectorElementStatusCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition
SiDetectorElementStatusCondAlg.cxx:38
InDet::SiDetectorElementStatusCondAlg::m_condSummaryTool
ToolHandle< IDetectorElementStatusTool > m_condSummaryTool
Definition
SiDetectorElementStatusCondAlg.h:31
InDet::SiDetectorElementStatus
Definition
SiDetectorElementStatus.h:62
InDet::SiDetectorElementStatus::getBadCells
const std::vector< std::vector< unsigned short > > & getBadCells() const
Definition
SiDetectorElementStatus.h:120
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
InDet
Primary Vertex Finder.
Definition
VP1ErrorUtils.h:36
xAOD::short
short
Definition
Vertex_v1.cxx:187
Generated on
for ATLAS Offline Software by
1.17.0