20 return tdcId <
other.tdcId;
40 return StatusCode::SUCCESS;
44 const EventContext& ctx = Gaudi::Hive::currentContext();
45 ATH_MSG_INFO(
"Dump cabling & mezzanines into JSON file");
48 if (!detectorMgr.isValid()){
50 return StatusCode::FAILURE;
56 return StatusCode::FAILURE;
60 std::vector<MdtMezzanineCard> cached_cards{};
61 std::set<MdtCablingData> cached_chnls{};
73 std::map<TdcIdentifier, Mapping> chamber_mezz{};
78 for (
int tubeInLayer = 1 ; tubeInLayer <= nTubes; ++tubeInLayer) {
81 layer, tubeInLayer, is_valid);
92 return StatusCode::FAILURE;
95 chamber_mezz.try_emplace(tdc_id,unsetArray);
100 for (
auto&[tdc, mezz_mapping] : chamber_mezz) {
105 mezzCablingId.tdcId = tdc.tdcId;
111 mezzCablingId.tube = chipInCab->
tubeZero();
118 for (
size_t chan = 0 ;
chan < mezz_mapping.size(); ++
chan) {
119 const OfflineCh tube_lay =
remap.offlineTube(
chan, msgStream());
120 if (!tube_lay.isValid)
continue;
121 uint8_t tubeNumber = tube_lay.tube + tubeOffSet + 1;
122 mezz_mapping[
chan] =
remap.tubeNumber(tube_lay.layer, tubeNumber);
126 Mapping& mtmp = mezz_mapping;
127 std::vector<MdtMezzanineCard>::const_iterator itr = std::find_if(cached_cards.begin(), cached_cards.end(),
129 if (dummy_card.numTubeLayers() != card.numTubeLayers()) return false;
130 for (size_t ch =0; ch < mtmp.size(); ++ch) {
131 if (mtmp[ch] != card.tdcToTubeMap()[ch]) return false;
135 if (itr != cached_cards.end()) {
136 mezzCablingId.mezzanine_type = itr->id();
138 cached_cards.emplace_back(mezz_mapping, dummy_card.
numTubeLayers(), cached_cards.size() + 10);
139 if (!cached_cards.back().checkConsistency(msgStream())) {
141 return StatusCode::FAILURE;
143 mezzCablingId.mezzanine_type = cached_cards.back().id();
145 cached_chnls.insert(std::move(mezzCablingId));
153 std::ofstream
summary{m_summaryTxt};
156 return StatusCode::FAILURE;
158 summary<<
"Extracted "<<cached_cards.size()<<
" mezzanine card layouts and "
159 <<cached_chnls.size()<<
" chamber channels. \n\n\n";
167 summary<<std::endl<<
" *** "<<idHelper.stationNameString(chamb.stationIndex);
168 summary<<static_cast<int>(std::abs(chamb.eta));
169 summary<<(chamb.eta > 0 ?
"A" :
"C");
170 summary<<static_cast<int>(chamb.phi);
171 summary<<
"M"<<
static_cast<int>(chamb.multilayer);
174 summary<<static_cast<int>(
cabling.tdcId)<<
", ";
177 <<
"##############################################################\n";
182 std::ofstream mezz_json{m_mezzJSON};
183 if (!mezz_json.good()) {
185 return StatusCode::FAILURE;
187 mezz_json<<
"["<<std::endl;
188 for (
size_t i = 0;
i < cached_cards.size() ; ++
i) {
191 mezz_json<<
" \"mezzId\": "<<
static_cast<int>(
card.id())<<
",\n";
192 mezz_json<<
" \"nTubeLayer\": "<<
static_cast<int>(
card.numTubeLayers())<<
",\n";
193 mezz_json<<
" \"tdcToTubeMap\": [";
194 for (
size_t ch = 0 ;
ch <
card.tdcToTubeMap().size(); ++
ch) {
195 mezz_json<<static_cast<int>(
card.tdcToTubeMap()[
ch]);
196 if (
ch + 1 !=
card.tdcToTubeMap().size())mezz_json<<
",";
200 if (
i +1 != cached_cards.size()) mezz_json<<
",";
206 std::ofstream chamb_json{m_cablingJSON};
207 if (!chamb_json.good()) {
209 return StatusCode::FAILURE;
215 chamb_json<<
" \"station\": \""<<idHelper.stationNameString(chamb.stationIndex)<<
"\",\n";
216 chamb_json<<
" \"eta\": "<<
static_cast<int>(chamb.eta)<<
",\n";
217 chamb_json<<
" \"phi\": "<<
static_cast<int>(chamb.phi)<<
",\n";
218 chamb_json<<
" \"ml\": "<<
static_cast<int>(chamb.multilayer)<<
",\n";
219 chamb_json<<
" \"subDet\": "<<
static_cast<int>(chamb.subdetectorId)<<
",\n";
220 chamb_json<<
" \"csm\": "<<
static_cast<int>(chamb.csm)<<
",\n";
221 chamb_json<<
" \"mrod\": "<<
static_cast<int>(chamb.mrod)<<
",\n";
222 chamb_json<<
" \"tdcId\": "<<
static_cast<int>(chamb.tdcId)<<
",\n";
223 chamb_json<<
" \"mezzId\": "<<
static_cast<int>(chamb.mezzanine_type)<<
",\n";
224 chamb_json<<
" \"tubeZero\": "<<
static_cast<int>(chamb.tube)<<
"\n";
226 if (
i +1 != cached_chnls.size()) chamb_json<<
",";
230 chamb_json<<
"]"<<std::endl;
234 return StatusCode::SUCCESS;