ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonConditions
MuonCondGeneral
MuonCondDump
src
MdtCondJsonDumpAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
MdtCondJsonDumpAlg.h
"
6
7
#include "
StoreGate/ReadCondHandleKey.h
"
8
#include <fstream>
9
10
11
12
MdtCondJsonDumpAlg::MdtCondJsonDumpAlg
(
const
std::string& name, ISvcLocator* pSvcLocator):
13
AthAlgorithm
{name, pSvcLocator} {}
14
15
StatusCode
MdtCondJsonDumpAlg::initialize
() {
16
ATH_CHECK
(
m_idHelperSvc
.retrieve());
17
ATH_CHECK
(
m_readKey
.initialize());
18
return
StatusCode::SUCCESS;
19
}
20
StatusCode
MdtCondJsonDumpAlg::execute
(
const
EventContext& ctx) {
21
SG::ReadCondHandle<MdtCondDbData>
readCondHandle{
m_readKey
, ctx};
22
if
(!readCondHandle.
isValid
()) {
23
ATH_MSG_FATAL
(
"Failed to open chamber load conditions "
<<
m_readKey
.fullKey());
24
return
StatusCode::FAILURE;
25
}
27
{
28
std::ofstream deadChannels{
m_deadChannelJSON
};
29
if
(!deadChannels.good()) {
30
ATH_MSG_ERROR
(
"Failed to write "
<<
m_deadChannelJSON
);
31
return
StatusCode::FAILURE;
32
}
33
deadChannels<<
"{"
<<std::endl;
34
deadChannels<<
" \"Chambers\": "
;
35
dumpDeadChannels
(readCondHandle->getDeadChambersId(), deadChannels);
36
deadChannels<<
","
<<std::endl;
37
deadChannels<<
" \"MultiLayers\": "
;
38
dumpDeadChannels
(readCondHandle->getDeadMultilayersId(), deadChannels,
true
);
39
deadChannels<<
","
<<std::endl;
40
deadChannels<<
" \"TubeLayers:\": "
;
41
dumpDeadChannels
(readCondHandle->getDeadLayersId(), deadChannels,
true
,
true
);
42
deadChannels<<
","
<<std::endl;
43
deadChannels<<
" \"Tubes:\": "
;
44
dumpDeadChannels
(readCondHandle->getDeadTubesId(), deadChannels,
true
,
true
,
true
);
45
deadChannels<<std::endl<<
"}"
<<std::endl;
46
}
48
if
(readCondHandle->getAllHvStates().empty() ||
m_dcsJSON
.value().empty()){
49
return
StatusCode::SUCCESS;
50
}
51
std::ofstream dcsStates{
m_dcsJSON
};
52
if
(!dcsStates.good()) {
53
ATH_MSG_ERROR
(
"Failed to write "
<<
m_dcsJSON
);
54
return
StatusCode::FAILURE;
55
}
56
57
58
dcsStates<<
"["
<<std::endl;
59
60
61
const
MdtIdHelper
& idHelper{
m_idHelperSvc
->mdtIdHelper()};
62
const
MuonIdHelper::const_id_iterator
begin = idHelper.
detectorElement_begin
();
63
const
MuonIdHelper::const_id_iterator
end = idHelper.
detectorElement_end
();
64
65
for
(
MuonIdHelper::const_id_iterator
itr = begin; itr != end; ++itr) {
66
const
Identifier
& detElId{*itr};
67
const
MuonCond::DcsConstants
& dcs{readCondHandle->getHvState(detElId)};
68
dcsStates<<
" {"
<<std::endl;
69
dumpIdentifier
(detElId, dcsStates,
true
,
false
,
false
,
true
);
70
dcsStates<<
" \"state\": \""
<<
MuonCond::getFsmStateStrg
(dcs.
fsmState
)<<
"\","
<<std::endl;
71
dcsStates<<
" \"standByVolt\": "
<<dcs.
standbyVolt
<<
", "
<<std::endl;
72
dcsStates<<
" \"readyVolt\": "
<<dcs.
readyVolt
<<std::endl;
73
dcsStates<<
" }"
;
74
if
((itr +1 ) != end) dcsStates<<
","
;
75
dcsStates<<std::endl;
76
}
77
dcsStates<<
"]"
<<std::endl;
78
79
80
return
StatusCode::SUCCESS;
81
}
82
83
void
MdtCondJsonDumpAlg::dumpIdentifier
(
const
Identifier
&
id
,
84
std::ostream& ostr,
85
bool
dumpMultiLayer,
86
bool
dumpLayer,
87
bool
dumpTube,
88
bool
trailingComma)
const
{
89
ostr<<
" \"station\": \""
<<
m_idHelperSvc
->stationNameString(
id
)<<
"\","
<<std::endl;
90
ostr<<
" \"eta\": "
<<
m_idHelperSvc
->stationEta(
id
)<<
","
<<std::endl;
91
ostr<<
" \"phi\": "
<<
m_idHelperSvc
->stationPhi(
id
);
92
if
(!dumpMultiLayer) {
93
ostr<<(trailingComma ?
","
:
""
)<<std::endl;
94
return
;
95
}
96
ostr<<
","
<<std::endl;
97
const
MdtIdHelper
& idHelper{
m_idHelperSvc
->mdtIdHelper()};
98
ostr<<
" \"ml\": "
<<idHelper.
multilayer
(
id
);
99
if
(!dumpLayer) {
100
ostr<<(trailingComma ?
","
:
""
)<<std::endl;
101
return
;
102
}
103
ostr<<
","
<<std::endl;
104
ostr<<
" \"layer\": "
<<idHelper.
tubeLayer
(
id
);
105
if
(!dumpTube) {
106
ostr<<(trailingComma ?
","
:
""
)<<std::endl;
107
return
;
108
}
109
ostr<<
" \"tube:\": \""
<<idHelper.
tube
(
id
);
110
ostr<<(trailingComma ?
","
:
""
)<<std::endl;
111
}
112
void
MdtCondJsonDumpAlg::dumpDeadChannels
(
const
std::unordered_set<Identifier>& channels,
113
std::ostream& ostr,
114
bool
dumpMultiLayer,
115
bool
dumpLayer,
bool
dumpTube)
const
{
116
unsigned
int
processed{0};
117
ostr<<
"["
<<std::endl;
118
for
(
const
Identifier
&
id
: channels) {
119
ostr<<
" {"
<<std::endl;
120
dumpIdentifier
(
id
, ostr, dumpMultiLayer, dumpLayer, dumpTube,
false
);
121
ostr<<
" }"
;
122
++processed;
123
if
(processed != channels.size()) ostr<<
","
;
124
ostr<<std::endl;
125
}
126
ostr<<
"]"
;
127
}
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
MdtCondJsonDumpAlg.h
ReadCondHandleKey.h
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
MdtCondJsonDumpAlg::m_dcsJSON
Gaudi::Property< std::string > m_dcsJSON
Definition
MdtCondJsonDumpAlg.h:47
MdtCondJsonDumpAlg::dumpIdentifier
void dumpIdentifier(const Identifier &id, std::ostream &ostr, bool dumpMultiLayer, bool dumpLayer, bool dumpTube, bool trailingComma) const
Dumps the Identifier into a json format.
Definition
MdtCondJsonDumpAlg.cxx:83
MdtCondJsonDumpAlg::m_readKey
SG::ReadCondHandleKey< MdtCondDbData > m_readKey
Definition
MdtCondJsonDumpAlg.h:44
MdtCondJsonDumpAlg::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition
MdtCondJsonDumpAlg.h:42
MdtCondJsonDumpAlg::execute
virtual StatusCode execute(const EventContext &ctx) override
Execute method.
Definition
MdtCondJsonDumpAlg.cxx:20
MdtCondJsonDumpAlg::m_deadChannelJSON
Gaudi::Property< std::string > m_deadChannelJSON
Definition
MdtCondJsonDumpAlg.h:46
MdtCondJsonDumpAlg::MdtCondJsonDumpAlg
MdtCondJsonDumpAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
MdtCondJsonDumpAlg.cxx:12
MdtCondJsonDumpAlg::initialize
virtual StatusCode initialize() override
Definition
MdtCondJsonDumpAlg.cxx:15
MdtCondJsonDumpAlg::dumpDeadChannels
void dumpDeadChannels(const std::unordered_set< Identifier > &channels, std::ostream &ostr, bool dumpMultiLayer=false, bool dumpLayer=false, bool dumpTube=false) const
Dumps all channels into a JSON format.
Definition
MdtCondJsonDumpAlg.cxx:112
MdtIdHelper
Definition
MdtIdHelper.h:61
MdtIdHelper::multilayer
int multilayer(const Identifier &id) const
Access to components of the ID.
Definition
MdtIdHelper.cxx:726
MdtIdHelper::tube
int tube(const Identifier &id) const
Definition
MdtIdHelper.cxx:730
MdtIdHelper::tubeLayer
int tubeLayer(const Identifier &id) const
Definition
MdtIdHelper.cxx:728
MuonIdHelper::const_id_iterator
std::vector< Identifier >::const_iterator const_id_iterator
Definition
MuonIdHelper.h:130
MuonIdHelper::detectorElement_begin
const_id_iterator detectorElement_begin() const
Iterators over full set of ids.
Definition
MuonIdHelper.cxx:765
MuonIdHelper::detectorElement_end
const_id_iterator detectorElement_end() const
Definition
MuonIdHelper.cxx:767
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
SG::ReadCondHandle::isValid
bool isValid()
Definition
ReadCondHandle.h:205
Identifier
Definition
IdentifierFieldParser.cxx:14
MuonCond::getFsmStateStrg
std::string getFsmStateStrg(DcsFsmState fsmState)
Definition
Defs.cxx:22
MuonCond::DcsConstants
Helper struct to cache all dcs constants in a common place of the memory.
Definition
MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondData/MuonCondData/Defs.h:31
MuonCond::DcsConstants::fsmState
DcsFsmState fsmState
Definition
MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondData/MuonCondData/Defs.h:34
MuonCond::DcsConstants::standbyVolt
float standbyVolt
Definition
MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondData/MuonCondData/Defs.h:32
MuonCond::DcsConstants::readyVolt
float readyVolt
Definition
MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondData/MuonCondData/Defs.h:33
Generated on
for ATLAS Offline Software by
1.17.0