ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetConditions
PixelConditionsAlgorithms
src
PixelReadoutSpeedAlg.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 "
PixelReadoutSpeedAlg.h
"
6
#include "GaudiKernel/EventIDRange.h"
7
8
#include "CoralBase/Blob.h"
9
10
#include <cstdint>
11
#include <istream>
12
#include <map>
13
#include <string>
14
15
PixelReadoutSpeedAlg::PixelReadoutSpeedAlg
(
const
std::string& name, ISvcLocator* pSvcLocator):
16
::
AthCondAlgorithm
(name, pSvcLocator)
17
{
18
}
19
20
StatusCode
PixelReadoutSpeedAlg::initialize
() {
21
ATH_MSG_DEBUG
(
"PixelReadoutSpeedAlg::initialize()"
);
22
23
ATH_CHECK
(
m_readKey
.initialize());
24
ATH_CHECK
(
m_writeKey
.initialize());
25
26
return
StatusCode::SUCCESS;
27
}
28
29
StatusCode
PixelReadoutSpeedAlg::execute
(
const
EventContext& ctx)
const
{
30
ATH_MSG_DEBUG
(
"PixelReadoutSpeedAlg::execute()"
);
31
32
SG::WriteCondHandle<PixelReadoutSpeedData>
writeHandle(
m_writeKey
, ctx);
33
if
(writeHandle.
isValid
()) {
34
ATH_MSG_DEBUG
(
"CondHandle "
<< writeHandle.
fullKey
() <<
" is already valid.. In theory this should not be called, but may happen if multiple concurrent events are being processed out of order."
);
35
return
StatusCode::SUCCESS;
36
}
37
38
SG::ReadCondHandle<AthenaAttributeList>
readHandle(
m_readKey
, ctx);
39
const
AthenaAttributeList
* readCdo = *readHandle;
40
if
(readCdo==
nullptr
) {
41
ATH_MSG_FATAL
(
"Null pointer to the read conditions object"
);
42
return
StatusCode::FAILURE;
43
}
44
// Get the validitiy range
45
EventIDRange rangeW;
46
if
(not readHandle.
range
(rangeW)) {
47
ATH_MSG_FATAL
(
"Failed to retrieve validity range for "
<< readHandle.
key
());
48
return
StatusCode::FAILURE;
49
}
50
ATH_MSG_INFO
(
"Size of AthenaAttributeList "
<< readHandle.
fullKey
() <<
" readCdo->size()= "
<< readCdo->size());
51
ATH_MSG_INFO
(
"Range of input is "
<< rangeW);
52
53
// Construct the output Cond Object and fill it in
54
std::unique_ptr<PixelReadoutSpeedData> writeCdo(std::make_unique<PixelReadoutSpeedData>());
55
56
const
coral::Blob& blob=(*readCdo)[
"readoutspeed_per_ROD"
].data<coral::Blob>();
57
const
char
* p =
static_cast<
const
char
*
>
(blob.startingAddress());
58
unsigned
int
len = blob.size();
59
std::map<uint32_t,bool> rodReadoutMap;
// save readout speed for each ROD. Is set to 40 MBit (false) by default
60
std::string dataString;
61
dataString.resize(len);
62
for
(
unsigned
int
i=0; i!=len; ++i) { dataString[i]=*p++; }
63
64
int
pos=0;
65
while
(dataString.find(
','
,pos)!=std::string::npos) {
66
std::istringstream iss(dataString.substr(pos,dataString.find(
','
,pos)));
67
uint32_t rod;
68
iss >> std::hex >> rod;
69
70
const
std::string speed = dataString.substr(dataString.find(
','
,pos)+1,dataString.find(
'\n'
,pos)-dataString.find(
','
,pos)-1);
71
72
if
(speed!=
"SINGLE_40"
) { rodReadoutMap[rod]=
true
; }
73
else
{ rodReadoutMap[rod]=
false
; }
74
75
pos = dataString.find(
'\n'
,pos)+1;
76
}
77
writeCdo -> setReadoutMap(rodReadoutMap);
78
79
if
(writeHandle.
record
(rangeW, std::move(writeCdo)).isFailure()) {
80
ATH_MSG_FATAL
(
"Could not record PixelReadoutSpeedData "
<< writeHandle.
key
() <<
" with EventRange "
<< rangeW <<
" into Conditions Store"
);
81
return
StatusCode::FAILURE;
82
}
83
ATH_MSG_INFO
(
"recorded new CDO "
<< writeHandle.
key
() <<
" with range "
<< rangeW <<
" into Conditions Store"
);
84
85
return
StatusCode::SUCCESS;
86
}
87
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
PixelReadoutSpeedAlg.h
AthCondAlgorithm
Base class for conditions algorithms.
Definition
AthCondAlgorithm.h:22
AthenaAttributeList
An AttributeList represents a logical row of attributes in a metadata table.
Definition
PersistentDataModel/PersistentDataModel/AthenaAttributeList.h:46
PixelReadoutSpeedAlg::m_writeKey
SG::WriteCondHandleKey< PixelReadoutSpeedData > m_writeKey
Definition
PixelReadoutSpeedAlg.h:37
PixelReadoutSpeedAlg::initialize
virtual StatusCode initialize() override
Definition
PixelReadoutSpeedAlg.cxx:20
PixelReadoutSpeedAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
PixelReadoutSpeedAlg.cxx:29
PixelReadoutSpeedAlg::m_readKey
SG::ReadCondHandleKey< AthenaAttributeList > m_readKey
Definition
PixelReadoutSpeedAlg.h:34
PixelReadoutSpeedAlg::PixelReadoutSpeedAlg
PixelReadoutSpeedAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
PixelReadoutSpeedAlg.cxx:15
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
SG::ReadCondHandle::range
bool range(EventIDRange &r)
Definition
ReadCondHandle.h:223
SG::ReadCondHandle::key
const std::string & key() const
Definition
ReadCondHandle.h:59
SG::ReadCondHandle::fullKey
const DataObjID & fullKey() const
Definition
ReadCondHandle.h:60
SG::WriteCondHandle
Definition
WriteCondHandle.h:26
SG::WriteCondHandle::key
const std::string & key() const
Definition
WriteCondHandle.h:44
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
Generated on
for ATLAS Offline Software by
1.17.0