22 return tdcId <
other.tdcId;
42 return StatusCode::SUCCESS;
46 const EventContext& ctx = Gaudi::Hive::currentContext();
47 ATH_MSG_INFO(
"Dump cabling & mezzanines into JSON file");
50 if (!detectorMgr.isValid()){
52 return StatusCode::FAILURE;
58 return StatusCode::FAILURE;
62 std::vector<MdtMezzanineCard> cached_cards{};
63 std::set<MdtCablingData> cached_chnls{};
76 std::map<TdcIdentifier, Mapping> chamber_mezz{};
78 for (
int tubeInLayer = 1 ; tubeInLayer <= readEle->
getNtubesperlayer(); ++tubeInLayer) {
81 layer, tubeInLayer, is_valid);
92 return StatusCode::FAILURE;
95 if (chamber_mezz.find(tdc_id) == chamber_mezz.end()) {
102 for (
auto&[tdc, mezz_mapping] : chamber_mezz) {
107 mezzCablingId.tdcId = tdc.tdcId;
113 mezzCablingId.tube = chipInCab->
tubeZero();
120 for (
size_t chan = 0 ;
chan < mezz_mapping.size(); ++
chan) {
121 const OfflineCh tube_lay =
remap.offlineTube(
chan, msgStream());
122 if (!tube_lay.isValid)
continue;
123 uint8_t tubeNumber = tube_lay.tube + tubeOffSet + 1;
124 mezz_mapping[
chan] =
remap.tubeNumber(tube_lay.layer, tubeNumber);
128 Mapping& mtmp = mezz_mapping;
129 std::vector<MdtMezzanineCard>::const_iterator itr = std::find_if(cached_cards.begin(), cached_cards.end(),
131 if (dummy_card.numTubeLayers() != card.numTubeLayers()) return false;
132 for (size_t ch =0; ch < mtmp.size(); ++ch) {
133 if (mtmp[ch] != card.tdcToTubeMap()[ch]) return false;
137 if (itr != cached_cards.end()) {
138 mezzCablingId.mezzanine_type = itr->id();
140 cached_cards.emplace_back(mezz_mapping, dummy_card.
numTubeLayers(), cached_cards.size() + 10);
141 if (!cached_cards.back().checkConsistency(msgStream())) {
143 return StatusCode::FAILURE;
145 mezzCablingId.mezzanine_type = cached_cards.back().id();
147 cached_chnls.insert(std::move(mezzCablingId));
155 std::ofstream
summary{m_summaryTxt};
158 return StatusCode::FAILURE;
160 summary<<
"Extracted "<<cached_cards.size()<<
" mezzanine card layouts and "
161 <<cached_chnls.size()<<
" chamber channels. "<<std::endl<<std::endl<<std::endl;
169 summary<<std::endl<<
" *** "<<idHelper.stationNameString(chamb.stationIndex);
170 summary<<static_cast<int>(std::abs(chamb.eta));
171 summary<<(chamb.eta > 0 ?
"A" :
"C");
172 summary<<static_cast<int>(chamb.phi);
173 summary<<
"M"<<
static_cast<int>(chamb.multilayer);
176 summary<<static_cast<int>(
cabling.tdcId)<<
", ";
179 <<
"##############################################################"<<std::endl;
184 std::ofstream mezz_json{m_mezzJSON};
185 if (!mezz_json.good()) {
187 return StatusCode::FAILURE;
189 mezz_json<<
"["<<std::endl;
190 for (
size_t i = 0;
i < cached_cards.size() ; ++
i) {
192 mezz_json<<
" {"<<std::endl;
193 mezz_json<<
" \"mezzId\": "<<
static_cast<int>(
card.id())<<
","<<std::endl;
194 mezz_json<<
" \"nTubeLayer\": "<<
static_cast<int>(
card.numTubeLayers())<<
","<<std::endl;
195 mezz_json<<
" \"tdcToTubeMap\": [";
196 for (
size_t ch = 0 ;
ch <
card.tdcToTubeMap().size(); ++
ch) {
197 mezz_json<<static_cast<int>(
card.tdcToTubeMap()[
ch]);
198 if (
ch + 1 !=
card.tdcToTubeMap().size())mezz_json<<
",";
200 mezz_json<<
"]"<<std::endl;
202 if (
i +1 != cached_cards.size()) mezz_json<<
",";
203 mezz_json<<std::endl;
208 std::ofstream chamb_json{m_cablingJSON};
209 if (!chamb_json.good()) {
211 return StatusCode::FAILURE;
213 chamb_json<<
"["<<std::endl;
216 chamb_json<<
" {"<<std::endl;
217 chamb_json<<
" \"station\": \""<<idHelper.stationNameString(chamb.stationIndex)<<
"\","<<std::endl;
218 chamb_json<<
" \"eta\": "<<
static_cast<int>(chamb.eta)<<
","<<std::endl;
219 chamb_json<<
" \"phi\": "<<
static_cast<int>(chamb.phi)<<
","<<std::endl;
220 chamb_json<<
" \"ml\": "<<
static_cast<int>(chamb.multilayer)<<
","<<std::endl;
221 chamb_json<<
" \"subDet\": "<<
static_cast<int>(chamb.subdetectorId)<<
","<<std::endl;
222 chamb_json<<
" \"csm\": "<<
static_cast<int>(chamb.csm)<<
","<<std::endl;
223 chamb_json<<
" \"mrod\": "<<
static_cast<int>(chamb.mrod)<<
","<<std::endl;
224 chamb_json<<
" \"tdcId\": "<<
static_cast<int>(chamb.tdcId)<<
","<<std::endl;
225 chamb_json<<
" \"mezzId\": "<<
static_cast<int>(chamb.mezzanine_type)<<
","<<std::endl;
226 chamb_json<<
" \"tubeZero\": "<<
static_cast<int>(chamb.tube)<<std::endl;
228 if (
i +1 != cached_chnls.size()) chamb_json<<
",";
229 chamb_json<<std::endl;
232 chamb_json<<
"]"<<std::endl;
236 return StatusCode::SUCCESS;