ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonConditions
MuonCondGeneral
MuonCondAlg
src
TgcDigitTimeOffsetCondAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
TgcDigitTimeOffsetCondAlg.h
"
6
#include "
CxxUtils/StringUtils.h
"
7
#include "
StoreGate/ReadCondHandle.h
"
8
#include "
StoreGate/WriteCondHandle.h
"
9
#include "CoralBase/Blob.h"
10
#include <string_view>
11
12
namespace
Muon
{
13
StatusCode
TgcDigitTimeOffsetCondAlg::initialize
() {
14
ATH_MSG_DEBUG
(
"initialize "
<< name());
15
ATH_CHECK
(
m_readKey
.initialize());
16
ATH_CHECK
(
m_writeKey
.initialize());
17
return
StatusCode::SUCCESS;
18
}
19
20
StatusCode
TgcDigitTimeOffsetCondAlg::execute
(
const
EventContext& ctx)
const
{
21
SG::WriteCondHandle
writeHandle{
m_writeKey
, ctx};
22
if
(writeHandle.
isValid
()) {
23
ATH_MSG_DEBUG
(
"CondHandle "
<< writeHandle.
fullKey
() <<
" is already valid."
24
<<
". In theory this should not be called, but may happen"
25
<<
" if multiple concurrent events are being processed out of order."
);
26
return
StatusCode::SUCCESS;
27
}
28
SG::ReadCondHandle
readHandle_TOffset{
m_readKey
, ctx};
29
if
(readHandle_TOffset.
cptr
() ==
nullptr
) {
30
ATH_MSG_ERROR
(
"Null pointer to the read conditions object"
);
31
return
StatusCode::FAILURE;
32
}
33
ATH_MSG_DEBUG
(
"Size of CondAttrListCollection"
<< readHandle_TOffset.
fullKey
() <<
" = "
<< readHandle_TOffset->size());
34
EventIDRange rangeW_TOffset;
35
if
(!readHandle_TOffset.
range
(rangeW_TOffset)) {
36
ATH_MSG_ERROR
(
"Failed to retrieve validity range for "
<< readHandle_TOffset.
key
());
37
return
StatusCode::FAILURE;
38
}
39
ATH_MSG_DEBUG
(
"Range of input is "
<< rangeW_TOffset);
40
41
// write condition object
42
EventIDRange rangeIntersection = EventIDRange::intersect(rangeW_TOffset);
43
if
(rangeIntersection.start()>rangeIntersection.stop()) {
44
ATH_MSG_ERROR
(
"Invalid intersection range: "
<< rangeIntersection);
45
return
StatusCode::FAILURE;
46
}
47
// Fill
48
auto
outputCdo = std::make_unique<TgcDigitTimeOffsetData>();
49
constexpr
std::string_view
delimiter
{
";"
};
50
for
(
const
auto
&[channel, attribute] : *readHandle_TOffset.
cptr
()) {
51
const
coral::Blob& blob_strip = attribute[
"bTimeOffset_strip"
].data<coral::Blob>();
52
const
std::string strstrip{
static_cast<
const
char
*
>
(blob_strip.startingAddress())};
53
54
std::vector<std::string> tokens =
CxxUtils::tokenize
(strstrip,
delimiter
);
55
auto
it = std::begin(tokens);
56
uint16_t station_number =
CxxUtils::atoi
(*it);
57
++it;
58
uint16_t station_eta =
CxxUtils::atoi
(*it);
59
++it;
60
float
offset_strip =
CxxUtils::atof
(*it);
61
++it;
62
uint16_t chamberId = (station_number << 3) + station_eta;
63
outputCdo->stripOffset.emplace(chamberId, offset_strip);
64
65
const
coral::Blob& blob_wire = attribute[
"bTimeOffset_wire"
].data<coral::Blob>();
66
const
std::string strwire{
static_cast<
const
char
*
>
(blob_wire.startingAddress())};
67
68
tokens.clear();
69
tokens =
CxxUtils::tokenize
(strwire,
delimiter
);
70
it = std::begin(tokens);
71
station_number =
CxxUtils::atoi
(*it);
72
++it;
73
station_eta =
CxxUtils::atoi
(*it);
74
++it;
75
float
offset_wire =
CxxUtils::atof
(*it);
76
++it;
77
chamberId = (station_number << 3) + station_eta;
78
outputCdo->wireOffset.emplace(chamberId, offset_wire);
79
}
// end of for(attrmap)
80
81
// Record
82
if
(writeHandle.
record
(rangeIntersection, std::move(outputCdo)).isFailure()) {
83
ATH_MSG_FATAL
(
"Could not record TgcDigitTimeOffsetData "
<< writeHandle.
key
()
84
<<
" with EventRange "
<< rangeIntersection
85
<<
" into Conditions Store"
);
86
return
StatusCode::FAILURE;
87
}
88
ATH_MSG_DEBUG
(
"recorded new "
<< writeHandle.
key
() <<
" with range "
<< rangeIntersection <<
" into Conditions Store"
);
89
90
return
StatusCode::SUCCESS;
91
}
92
}
93
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_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
StringUtils.h
ReadCondHandle.h
TgcDigitTimeOffsetCondAlg.h
WriteCondHandle.h
Muon::TgcDigitTimeOffsetCondAlg::initialize
virtual StatusCode initialize() override
Definition
TgcDigitTimeOffsetCondAlg.cxx:13
Muon::TgcDigitTimeOffsetCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
TgcDigitTimeOffsetCondAlg.cxx:20
Muon::TgcDigitTimeOffsetCondAlg::m_readKey
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey
Definition
TgcDigitTimeOffsetCondAlg.h:25
Muon::TgcDigitTimeOffsetCondAlg::m_writeKey
SG::WriteCondHandleKey< TgcDigitTimeOffsetData > m_writeKey
Definition
TgcDigitTimeOffsetCondAlg.h:26
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::ReadCondHandle::cptr
const_pointer_type cptr()
Definition
ReadCondHandle.h:67
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
delimiter
static const std::string delimiter("/")
CxxUtils::atof
double atof(std::string_view str)
Converts a string into a double / float.
Definition
Control/CxxUtils/Root/StringUtils.cxx:46
CxxUtils::tokenize
std::vector< std::string > tokenize(std::string_view the_str, std::string_view delimiters)
Splits the string into smaller substrings.
Definition
Control/CxxUtils/Root/StringUtils.cxx:12
CxxUtils::atoi
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
Definition
Control/CxxUtils/Root/StringUtils.cxx:40
Muon
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
Definition
TrackSystemController.h:46
Generated on
for ATLAS Offline Software by
1.17.0