ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonConditions
MuonCondGeneral
MuonCondAlg
src
NswAsBuiltCondAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
#include "
NswAsBuiltCondAlg.h
"
5
#include "
StoreGate/ReadCondHandle.h
"
6
#include "
StoreGate/WriteCondHandle.h
"
7
#include "
AthenaKernel/IOVInfiniteRange.h
"
8
#include "
PathResolver/PathResolver.h
"
9
#include <iostream>
10
#include <fstream>
11
12
namespace
Muon
{
13
StatusCode
NswAsBuiltCondAlg::initialize
() {
14
ATH_CHECK
(
m_readMmAsBuiltParamsKey
.initialize(
m_MmJsonPath
.value().empty() && !
m_readMmAsBuiltParamsKey
.empty()));
15
ATH_CHECK
(
m_writeNswAsBuiltKey
.initialize());
16
if
(!
m_MmJsonPath
.value().empty())
ATH_MSG_INFO
(
"Load MicroMega as-built from external JSON "
<<
m_MmJsonPath
);
17
else
if
(!
m_readMmAsBuiltParamsKey
.empty())
ATH_MSG_INFO
(
"Load MicroMega as-built from COOL <"
<<
m_readMmAsBuiltParamsKey
.key()<<
">"
);
18
else
ATH_MSG_INFO
(
"MicroMega as-built is deactiviated"
);
19
return
StatusCode::SUCCESS;
20
}
21
22
StatusCode
NswAsBuiltCondAlg::execute
(
const
EventContext& ctx)
const
{
23
SG::WriteCondHandle
writeHandle{
m_writeNswAsBuiltKey
, ctx};
24
if
(writeHandle.
isValid
()) {
25
ATH_MSG_DEBUG
(
"CondHandle "
<< writeHandle.
fullKey
() <<
" is already valid."
26
<<
". In theory this should not be called, but may happen"
27
<<
" if multiple concurrent events are being processed out of order."
);
28
return
StatusCode::SUCCESS;
29
}
30
writeHandle.
addDependency
(EventIDRange(
IOVInfiniteRange::infiniteRunLB
()));
31
32
auto
writeCdo{std::make_unique<NswAsBuiltDbData>()};
33
34
if
(!
m_readMmAsBuiltParamsKey
.empty()) {
35
SG::ReadCondHandle
readHandle{
m_readMmAsBuiltParamsKey
, ctx};
36
if
(!readHandle.
isValid
()) {
37
ATH_MSG_ERROR
(
"Null pointer to the read MM/ASBUILTPARAMS conditions object"
);
38
return
StatusCode::FAILURE;
39
}
40
writeHandle.
addDependency
(readHandle);
41
ATH_MSG_INFO
(
"Size of MM/ASBUILTPARAMS CondAttrListCollection "
<< readHandle.
fullKey
()
42
<<
" ->size()= "
<< readHandle->size());
43
unsigned
int
nLines{0};
44
for
(
CondAttrListCollection::const_iterator
itr = readHandle->begin(); itr != readHandle->end(); ++itr) {
45
const
coral::AttributeList& atr = itr->second;
46
const
std::string data{*(
static_cast<
const
std::string*
>
((atr[
"data"
]).addressOfData()))};
47
ATH_MSG_DEBUG
(__FILE__<<
":"
<<__LINE__<<
" data load is "
<< data <<
" FINISHED HERE "
);
48
writeCdo->microMegaData = std::make_unique<NswAsBuilt::StripCalculator>();
49
writeCdo->microMegaData->parseJSON(data);
50
++nLines;
51
}
52
if
(nLines>1) {
53
ATH_MSG_FATAL
(nLines <<
" data objects were loaded for MM/ASBUILTPARAMS! Expected only one for this validity range!"
);
54
return
StatusCode::FAILURE;
55
}
56
}
57
if
(!
m_MmJsonPath
.value().empty()){
58
ATH_MSG_INFO
(
"Load micromega as-built constants from a JSON file"
);
59
std::ifstream thefile{
PathResolverFindCalibFile
(
m_MmJsonPath
)};
60
if
(!thefile.good()) {
61
ATH_MSG_FATAL
(
"No such file or directory "
<<
m_MmJsonPath
);
62
return
StatusCode::FAILURE;
63
}
64
std::stringstream buffer;
65
buffer << thefile.rdbuf();
66
writeCdo->microMegaData = std::make_unique<NswAsBuilt::StripCalculator>();
67
writeCdo->microMegaData->parseJSON(buffer.str());
68
}
69
70
if
(!writeCdo->microMegaData) {
71
ATH_MSG_ERROR
(
"No AsBuilt constants were loaded. Please check the algorithm configucration"
);
72
return
StatusCode::FAILURE;
73
}
74
ATH_CHECK
(writeHandle.
record
(std::move(writeCdo)));
75
return
StatusCode::SUCCESS;
76
}
77
}
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_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
IOVInfiniteRange.h
NswAsBuiltCondAlg.h
PathResolver.h
PathResolverFindCalibFile
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Definition
PathResolver.cxx:325
ReadCondHandle.h
WriteCondHandle.h
CondAttrListCollection::const_iterator
ChanAttrListMap::const_iterator const_iterator
Definition
CondAttrListCollection.h:62
IOVInfiniteRange::infiniteRunLB
static EventIDRange infiniteRunLB()
Produces an EventIDRange that is infinite in RunLumi and invalid in Time.
Definition
IOVInfiniteRange.h:39
Muon::NswAsBuiltCondAlg::m_MmJsonPath
Gaudi::Property< std::string > m_MmJsonPath
Definition
NswAsBuiltCondAlg.h:28
Muon::NswAsBuiltCondAlg::m_readMmAsBuiltParamsKey
SG::ReadCondHandleKey< CondAttrListCollection > m_readMmAsBuiltParamsKey
Definition
NswAsBuiltCondAlg.h:25
Muon::NswAsBuiltCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
NswAsBuiltCondAlg.cxx:22
Muon::NswAsBuiltCondAlg::initialize
virtual StatusCode initialize() override
Definition
NswAsBuiltCondAlg.cxx:13
Muon::NswAsBuiltCondAlg::m_writeNswAsBuiltKey
SG::WriteCondHandleKey< NswAsBuiltDbData > m_writeNswAsBuiltKey
Definition
NswAsBuiltCondAlg.h:30
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
SG::ReadCondHandle::isValid
bool isValid()
Definition
ReadCondHandle.h:205
SG::ReadCondHandle::fullKey
const DataObjID & fullKey() const
Definition
ReadCondHandle.h:60
SG::WriteCondHandle
Definition
WriteCondHandle.h:26
SG::WriteCondHandle::addDependency
void addDependency(const EventIDRange &range)
Definition
WriteCondHandle.h:279
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
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