ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonConditions
MuonCondGeneral
MuonCondAlg
src
TgcDigitCrosstalkCondAlg.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 "
TgcDigitCrosstalkCondAlg.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
TgcDigitCrosstalkCondAlg::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
TgcDigitCrosstalkCondAlg::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_XTalk{
m_readKey
, ctx};
29
if
(readHandle_XTalk.
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_XTalk.
fullKey
() <<
" = "
<< readHandle_XTalk->size());
34
EventIDRange rangeW_XTalk;
35
if
(!readHandle_XTalk.
range
(rangeW_XTalk)) {
36
ATH_MSG_ERROR
(
"Failed to retrieve validity range for "
<< readHandle_XTalk.
key
());
37
return
StatusCode::FAILURE;
38
}
39
ATH_MSG_DEBUG
(
"Range of input is "
<< rangeW_XTalk);
40
41
// write condition object
42
EventIDRange rangeIntersection = EventIDRange::intersect(rangeW_XTalk);
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<TgcDigitCrosstalkData>();
49
constexpr
std::string_view
delimiter
{
";"
};
50
for
(
const
auto
&[channel, attribute] : *readHandle_XTalk.
cptr
()) {
51
const
coral::Blob& blob_strip = attribute[
"bXTalk_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
uint16_t layer =
CxxUtils::atoi
(*it);
61
++it;
62
float
prob10 =
CxxUtils::atof
(*it);
63
++it;
64
float
prob11 =
CxxUtils::atof
(*it);
65
++it;
66
float
prob20 =
CxxUtils::atof
(*it);
67
++it;
68
float
prob21 =
CxxUtils::atof
(*it);
69
++it;
70
uint16_t layerId = (station_number << 5) + (station_eta << 2) + layer;
71
std::array<float, TgcDigitCrosstalkData::N_PROB> prob_strip{prob10, prob11, prob20, prob21};
72
outputCdo->setStripProbability(layerId, prob_strip);
73
74
const
coral::Blob& blob_wire = attribute[
"bXTalk_wire"
].data<coral::Blob>();
75
const
std::string strwire {
static_cast<
const
char
*
>
(blob_wire.startingAddress())};
76
tokens.clear();
77
tokens =
CxxUtils::tokenize
(strwire,
delimiter
);
78
it = std::begin(tokens);
79
station_number =
CxxUtils::atoi
(*it);
80
++it;
81
station_eta =
CxxUtils::atoi
(*it);
82
++it;
83
layer =
CxxUtils::atoi
(*it);
84
++it;
85
prob10 =
CxxUtils::atof
(*it);
86
++it;
87
prob11 =
CxxUtils::atof
(*it);
88
++it;
89
prob20 =
CxxUtils::atof
(*it);
90
++it;
91
prob21 =
CxxUtils::atof
(*it);
92
++it;
93
layerId = (station_number << 5) + (station_eta << 2) + layer;
94
std::array<float, TgcDigitCrosstalkData::N_PROB> prob_wire{prob10, prob11, prob20, prob21};
95
outputCdo->setWireProbability(layerId, prob_wire);
96
}
// end of for(attrmap)
97
98
// Record
99
if
(writeHandle.
record
(rangeIntersection, std::move(outputCdo)).isFailure()) {
100
ATH_MSG_FATAL
(
"Could not record TgcDigitCrosstalkData "
<< writeHandle.
key
()
101
<<
" with EventRange "
<< rangeIntersection
102
<<
" into Conditions Store"
);
103
return
StatusCode::FAILURE;
104
}
105
ATH_MSG_DEBUG
(
"recorded new "
<< writeHandle.
key
() <<
" with range "
<< rangeIntersection <<
" into Conditions Store"
);
106
107
return
StatusCode::SUCCESS;
108
}
109
}
110
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
TgcDigitCrosstalkCondAlg.h
WriteCondHandle.h
Muon::TgcDigitCrosstalkCondAlg::m_writeKey
SG::WriteCondHandleKey< TgcDigitCrosstalkData > m_writeKey
Definition
TgcDigitCrosstalkCondAlg.h:25
Muon::TgcDigitCrosstalkCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
TgcDigitCrosstalkCondAlg.cxx:20
Muon::TgcDigitCrosstalkCondAlg::initialize
virtual StatusCode initialize() override
Definition
TgcDigitCrosstalkCondAlg.cxx:13
Muon::TgcDigitCrosstalkCondAlg::m_readKey
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey
Definition
TgcDigitCrosstalkCondAlg.h:24
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