ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonConditions
MuonCondGeneral
MuonCondAlg
src
TgcDigitJitterCondAlg.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 "
TgcDigitJitterCondAlg.h
"
6
#include <
StoreGate/WriteCondHandle.h
>
7
#include <
AthenaKernel/IOVInfiniteRange.h
>
8
#include <
PathResolver/PathResolver.h
>
9
#include <fstream>
10
11
namespace
Muon
{
12
// Initialize
13
StatusCode
TgcDigitJitterCondAlg::initialize
() {
14
ATH_MSG_DEBUG
(
"initializing "
<< name());
15
ATH_CHECK
(
m_writeKey
.initialize());
16
ATH_CHECK
(
m_readKeyDb
.initialize(!
m_readKeyDb
.empty()));
17
if
(
m_readKeyDb
.empty() &&
m_readFromJSON
.value().empty()){
18
ATH_MSG_FATAL
(
"No data source is given to load the jitter constants from. Please provide either a COOL folder or a json file"
);
19
return
StatusCode::FAILURE;
20
}
else
if
(
m_readKeyDb
.empty()) {
21
ATH_MSG_INFO
(
"Load jitter constants from a JSON file "
<<
m_readFromJSON
);
22
}
else
{
23
ATH_MSG_INFO
(
"Load the jitter constants list from COOL "
<<
m_readKeyDb
.fullKey());
24
}
25
return
StatusCode::SUCCESS;
26
}
27
28
// execute
29
StatusCode
TgcDigitJitterCondAlg::execute
(
const
EventContext& ctx)
const
{
30
ATH_MSG_DEBUG
(
"execute "
<< name());
31
// launching Write Cond Handle
32
SG::WriteCondHandle
writeHandle{
m_writeKey
, ctx};
33
if
(writeHandle.
isValid
()) {
34
ATH_MSG_DEBUG
(
"CondHandle "
<< writeHandle.
fullKey
() <<
" is already valid."
35
<<
" In theory this should not be called, but may happen"
36
<<
" if multiple concurrent events are being processed out of order."
);
37
return
StatusCode::SUCCESS;
38
}
39
writeHandle.
addDependency
(EventIDRange(
IOVInfiniteRange::infiniteTime
()));
40
auto
writeCdo{std::make_unique<TgcDigitJitterData>()};
41
if
(!
m_readKeyDb
.empty()) {
42
SG::ReadCondHandle
readHandle{
m_readKeyDb
, ctx};
43
if
(!readHandle.
isValid
()) {
44
ATH_MSG_FATAL
(
"Failed to initialize the COOL folder "
<<
m_readKeyDb
.fullKey());
45
return
StatusCode::FAILURE;
46
}
47
writeHandle.
addDependency
(readHandle);
48
for
(
CondAttrListCollection::const_iterator
itr = readHandle->begin(); itr != readHandle->end(); ++itr) {
49
const
coral::AttributeList& atr = itr->second;
50
const
std::string& data{*(
static_cast<
const
std::string*
>
((atr[
"data"
]).addressOfData()))};
51
nlohmann::json lines = nlohmann::json::parse(data);
52
ATH_CHECK
(
parseDataFromJSON
(lines, *writeCdo));
53
}
54
}
else
{
55
std::ifstream inStream{
PathResolverFindCalibFile
(
m_readFromJSON
)};
56
if
(!inStream.good()) {
57
ATH_MSG_FATAL
(
"No such file or directory"
);
58
return
StatusCode::FAILURE;
59
}
60
nlohmann::json lines;
61
inStream >> lines;
62
ATH_CHECK
(
parseDataFromJSON
(lines, *writeCdo));
63
}
64
ATH_CHECK
(writeCdo->initialize());
65
ATH_CHECK
(writeHandle.
record
(std::move(writeCdo)));
66
ATH_MSG_DEBUG
(
"Recorded new "
<< writeHandle.
key
() <<
" with range "
<< writeHandle.
getRange
() <<
" into Conditions Store"
);
67
return
StatusCode::SUCCESS;
68
}
69
70
StatusCode
TgcDigitJitterCondAlg::parseDataFromJSON
(
const
nlohmann::json& lines,
71
TgcDigitJitterData
& jitterData)
const
{
72
for
(
auto
& corr : lines.items()) {
73
nlohmann::json line = corr.value();
74
const
double
angle
= line[
"angle"
];
75
std::vector<double> values = line[
"values"
];
76
jitterData.
cacheAngleInterval
(
angle
, std::move(values));
77
}
78
return
StatusCode::SUCCESS;
79
}
80
}
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
IOVInfiniteRange.h
PathResolver.h
PathResolverFindCalibFile
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Definition
PathResolver.cxx:325
angle
double angle(const GeoTrf::Vector2D &a, const GeoTrf::Vector2D &b)
Definition
TRTDetectorFactory_Full.cxx:71
TgcDigitJitterCondAlg.h
WriteCondHandle.h
CondAttrListCollection::const_iterator
ChanAttrListMap::const_iterator const_iterator
Definition
CondAttrListCollection.h:62
IOVInfiniteRange::infiniteTime
static EventIDRange infiniteTime()
Produces an EventIDRange that is inifinite in Time and invalid in RunLumi.
Definition
IOVInfiniteRange.h:47
Muon::TgcDigitJitterCondAlg::m_readKeyDb
SG::ReadCondHandleKey< CondAttrListCollection > m_readKeyDb
Definition
TgcDigitJitterCondAlg.h:36
Muon::TgcDigitJitterCondAlg::m_writeKey
SG::WriteCondHandleKey< TgcDigitJitterData > m_writeKey
Definition
TgcDigitJitterCondAlg.h:35
Muon::TgcDigitJitterCondAlg::initialize
virtual StatusCode initialize() override
Definition
TgcDigitJitterCondAlg.cxx:13
Muon::TgcDigitJitterCondAlg::parseDataFromJSON
StatusCode parseDataFromJSON(const nlohmann::json &lines, TgcDigitJitterData &jitterChannels) const
Load the Jitter constants from the JSON format.
Definition
TgcDigitJitterCondAlg.cxx:70
Muon::TgcDigitJitterCondAlg::m_readFromJSON
Gaudi::Property< std::string > m_readFromJSON
Use an external JSON file to load the Jitter constants from.
Definition
TgcDigitJitterCondAlg.h:33
Muon::TgcDigitJitterCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
TgcDigitJitterCondAlg.cxx:29
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
SG::ReadCondHandle::isValid
bool isValid()
Definition
ReadCondHandle.h:205
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
TgcDigitJitterData
Definition
TgcDigitJitterData.h:24
TgcDigitJitterData::cacheAngleInterval
void cacheAngleInterval(const double minAngle, std::vector< double > &&timeProbs)
Definition
TgcDigitJitterData.cxx:41
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