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