9 #include "GeoModelKernel/throwExcept.h"
10 #include "nlohmann/json.hpp"
18 ATH_MSG_FATAL(
"You can't write rpc cablings without rpc detectors? ");
19 return StatusCode::FAILURE;
24 return StatusCode::SUCCESS;
28 if (!outStream.good()) {
30 return StatusCode::FAILURE;
33 std::vector<const MuonGMR4::RpcReadoutElement *> reEles{
m_detMgr->getAllRpcReadoutElements()};
36 constexpr
int subDetA{0x65}, subDetB{0x66};
39 unsigned int tdcSecA{0}, tdcSecC{0};
42 std::vector<std::unique_ptr<RpcFlatCableTranslator>> flatTranslators{};
44 auto connectFlatCable = [&flatCableJSON, &flatTranslators,
this](
const unsigned coveredStrips) ->
unsigned{
45 for (std::unique_ptr<RpcFlatCableTranslator>& translator : flatTranslators){
46 if (
static_cast<unsigned>(translator->connectedChannels()) == coveredStrips){
47 return translator->id();
50 auto& translator = flatTranslators.emplace_back(std::make_unique<RpcFlatCableTranslator>(flatTranslators.size()));
57 chipJSON[
"flatCableId"] = translator->id();
58 std::vector<std::pair<unsigned,unsigned>> pins{};
62 chipJSON[
"pinAssignment"] = pins;
64 flatCableJSON.push_back(chipJSON);
65 return translator->id();
71 const unsigned int subDet = reEle->stationEta() > 0 ? subDetA : subDetB;
72 const unsigned int tdcSec = reEle->stationEta() > 0 ? (++tdcSecA) : (++tdcSecC);
76 for (
bool measPhi : {
false,
true}) {
78 if (!reEle->nStrips(layHash))
80 const unsigned int nStrips = reEle->nStrips(layHash);
81 const unsigned int nTdcChips = (
nStrips % nStripsPerTdc > 0) +
84 for (
bool side : {
false,
true}) {
85 bool run4_BIS = ((reEle->stationName() ==
m_BIS_stIdx) && (std::abs(reEle->stationEta()) < 7));
90 unsigned int measPhiSide = (
side * stripSideBit) | (measPhi * measPhiBit);
91 for (
unsigned int chip = 0; chip < nTdcChips; ++chip) {
95 cablingChannel[
"station"] =
m_idHelperSvc->stationNameString(reEle->identify());
96 cablingChannel[
"eta"] = reEle->stationEta();
97 cablingChannel[
"phi"] = reEle->stationPhi();
98 cablingChannel[
"doubletR"] = reEle->doubletR();
99 cablingChannel[
"doubletZ"] = reEle->doubletZ();
101 cablingChannel[
"gasGap"] =
gasGap;
102 cablingChannel[
"measPhi"] = measPhiSide;
104 cablingChannel[
"subDetector"] = subDet;
105 cablingChannel[
"tdcSector"] = tdcSec;
107 cablingChannel[
"tdc"] = (++tdc);
108 cablingChannel[
"flatCableId"] = connectFlatCable(coveredStrips);
110 <<
"nStrips: "<<
nStrips<<
", stripsPerTdc"
111 <<nStripsPerTdc<<
", nChips: "<<nTdcChips<<
", covered: "<<coveredStrips);
112 chamberJSON.push_back(cablingChannel);
120 finalJSON[
"chamberMap"] = chamberJSON;
121 finalJSON[
"readoutCards"] = flatCableJSON;
122 outStream << finalJSON.dump(2) << std::endl;
123 return StatusCode::SUCCESS;