ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonConditions
MuonCondGeneral
MuonCondDump
src
MuonABLineJsonDumpAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
#include "
MuonABLineJsonDumpAlg.h
"
5
#include "
StoreGate/ReadCondHandle.h
"
6
#include "nlohmann/json.hpp"
7
#include <fstream>
8
9
MuonABLineJsonDumpAlg::MuonABLineJsonDumpAlg
(
const
std::string& name, ISvcLocator* pSvcLocator):
10
AthAlgorithm
{name, pSvcLocator} {}
11
12
StatusCode
MuonABLineJsonDumpAlg::initialize
() {
13
ATH_CHECK
(
m_readALineKey
.initialize());
14
ATH_CHECK
(
m_readBLineKey
.initialize());
15
ATH_CHECK
(
m_idHelperSvc
.retrieve());
16
return
StatusCode::SUCCESS;
17
}
18
StatusCode
MuonABLineJsonDumpAlg::execute
(
const
EventContext& ctx){
19
SG::ReadCondHandle<ALineContainer>
aLineContainer{
m_readALineKey
, ctx};
20
if
(!aLineContainer.
isValid
()){
21
ATH_MSG_FATAL
(
"Failed to load ALine container "
<<
m_readALineKey
.fullKey());
22
return
StatusCode::FAILURE;
23
}
24
SG::ReadCondHandle<BLineContainer>
bLineContainer{
m_readBLineKey
, ctx};
25
if
(!aLineContainer.
isValid
()){
26
ATH_MSG_FATAL
(
"Failed to load BLine container "
<<
m_readBLineKey
.fullKey());
27
return
StatusCode::FAILURE;
28
}
29
30
std::ofstream ostr{
m_jsonFile
};
31
if
(!ostr.good()) {
32
ATH_MSG_FATAL
(
"Failed to create output file "
<<
m_jsonFile
);
33
return
StatusCode::FAILURE;
34
}
35
ostr<<
"[\n"
;
36
unsigned
int
nLines{0};
37
for
(
const
ALinePar
& aLine : **aLineContainer) {
38
++nLines;
39
ostr<<
" {\n"
;
41
ostr<<
" \"typ\": \""
<<aLine.AmdbStation()<<
"\",\n"
;
42
ostr<<
" \"jzz\": "
<<aLine.AmdbEta()<<
", \n"
;
43
ostr<<
" \"jff\": "
<<aLine.AmdbPhi()<<
", \n"
;
44
ostr<<
" \"job\": "
<<aLine.AmdbJob()<<
", \n"
;
46
using
APar =
ALinePar::Parameter
;
47
ostr<<
" \"svalue\": "
<<aLine.getParameter(APar::transS)<<
", \n"
;
48
ostr<<
" \"zvalue\": "
<<aLine.getParameter(APar::transZ)<<
", \n"
;
49
ostr<<
" \"tvalue\": "
<<aLine.getParameter(APar::transT)<<
", \n"
;
50
ostr<<
" \"tsv\": "
<<aLine.getParameter(APar::rotS)<<
", \n"
;
51
ostr<<
" \"tzv\": "
<<aLine.getParameter(APar::rotZ)<<
", \n"
;
52
ostr<<
" \"ttv\": "
<<aLine.getParameter(APar::rotT);
54
BLineContainer::const_iterator itr = bLineContainer->find(aLine.identify());
55
if
(itr == bLineContainer->end()) {
57
ostr<<
"\n }"
<< (nLines != aLineContainer->size() ?
","
:
""
)<<
"\n"
;
58
continue
;
59
}
60
ostr<<
",\n"
;
61
using
BPar =
BLinePar::Parameter
;
62
const
BLinePar
& bLine = (*itr);
63
ostr<<
" \"bz\": "
<<bLine.
getParameter
(BPar::bz)<<
",\n"
;
64
ostr<<
" \"bp\": "
<<bLine.
getParameter
(BPar::bp)<<
",\n"
;
65
ostr<<
" \"bn\": "
<<bLine.
getParameter
(BPar::bn)<<
",\n"
;
66
ostr<<
" \"sp\": "
<<bLine.
getParameter
(BPar::sp)<<
",\n"
;
67
ostr<<
" \"sn\": "
<<bLine.
getParameter
(BPar::sn)<<
",\n"
;
68
ostr<<
" \"tw\": "
<<bLine.
getParameter
(BPar::tw)<<
",\n"
;
69
ostr<<
" \"pg\": "
<<bLine.
getParameter
(BPar::pg)<<
",\n"
;
70
ostr<<
" \"tr\": "
<<bLine.
getParameter
(BPar::tr)<<
",\n"
;
71
ostr<<
" \"eg\": "
<<bLine.
getParameter
(BPar::eg)<<
",\n"
;
72
ostr<<
" \"ep\": "
<<bLine.
getParameter
(BPar::ep)<<
",\n"
;
73
ostr<<
" \"en\": "
<<bLine.
getParameter
(BPar::en)<<
",\n"
;
75
ostr<<
" \"xAtlas\": 0 ,\n"
;
76
ostr<<
" \"yAtlas\": 0 ,\n"
;
77
ostr<<
" \"hwElement\": \""
;
78
ostr<<
m_idHelperSvc
->stationNameString(bLine.
identify
());
79
const
int
stEta =
m_idHelperSvc
->stationEta(bLine.
identify
());
80
ostr<<std::abs(stEta)<<(stEta > 0 ?
"A"
:
"C"
);
81
ostr<<
m_idHelperSvc
->stationPhi(bLine.
identify
());
82
ostr<<
"\"\n"
;
83
ostr<<
" }"
<< (nLines != aLineContainer->size() ?
","
:
""
)<<
"\n"
;
84
}
85
ostr<<
"]"
<<std::endl;
86
ostr.close();
87
88
89
return
StatusCode::SUCCESS;
90
}
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
MuonABLineJsonDumpAlg.h
ReadCondHandle.h
ALinePar
Definition
ALinePar.h:15
ALinePar::Parameter
Parameter
amdb frame (s, z, t) = chamber frame (y, z, x)
Definition
ALinePar.h:23
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
BLinePar
Definition
BLinePar.h:14
BLinePar::getParameter
float getParameter(const Parameter p) const
Returns a given parameter.
Definition
BLinePar.h:40
BLinePar::Parameter
Parameter
Definition
BLinePar.h:21
MuonABLineJsonDumpAlg::execute
virtual StatusCode execute(const EventContext &ctx) override
Execute method.
Definition
MuonABLineJsonDumpAlg.cxx:18
MuonABLineJsonDumpAlg::MuonABLineJsonDumpAlg
MuonABLineJsonDumpAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
MuonABLineJsonDumpAlg.cxx:9
MuonABLineJsonDumpAlg::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition
MuonABLineJsonDumpAlg.h:29
MuonABLineJsonDumpAlg::m_jsonFile
Gaudi::Property< std::string > m_jsonFile
Definition
MuonABLineJsonDumpAlg.h:32
MuonABLineJsonDumpAlg::m_readBLineKey
SG::ReadCondHandleKey< BLineContainer > m_readBLineKey
Definition
MuonABLineJsonDumpAlg.h:27
MuonABLineJsonDumpAlg::initialize
virtual StatusCode initialize() override
Definition
MuonABLineJsonDumpAlg.cxx:12
MuonABLineJsonDumpAlg::m_readALineKey
SG::ReadCondHandleKey< ALineContainer > m_readALineKey
Definition
MuonABLineJsonDumpAlg.h:26
MuonAlignmentPar::identify
const Identifier & identify() const
Definition
MuonAlignmentPar.cxx:11
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
SG::ReadCondHandle::isValid
bool isValid()
Definition
ReadCondHandle.h:205
Generated on
for ATLAS Offline Software by
1.17.0