12 #include "CoralBase/Attribute.h"
13 #include "CoralBase/AttributeListSpecification.h"
19 #include <CoralBase/Blob.h>
33 return StatusCode::SUCCESS;
40 if (writeHandle.isValid()) {
41 ATH_MSG_DEBUG(
"CondHandle " << writeHandle.fullKey() <<
" is already valid."
42 <<
". In theory this should not be called, but may happen"
43 <<
" if multiple concurrent events are being processed out of order.");
44 return StatusCode::SUCCESS;
48 std::unique_ptr<MuonMDT_CablingMap> writeCdo{std::make_unique<MuonMDT_CablingMap>()};
52 if (!writeCdo->finalize_init(msgStream()))
return StatusCode::FAILURE;
54 ATH_CHECK(writeHandle.record(std::move(writeCdo)));
55 ATH_MSG_INFO(
"recorded new " << writeHandle.key() <<
" with range " << writeHandle.getRange() <<
" into Conditions Store");
56 return StatusCode::SUCCESS;
61 itr != readHandle->
end(); ++itr) {
69 return StatusCode::FAILURE;
72 data = *(
static_cast<const std::string*
>((atr[
"data"]).addressOfData()));
76 return StatusCode::SUCCESS;
84 if (!in_json.good()) {
86 return StatusCode::FAILURE;
91 return StatusCode::SUCCESS;
94 if (!readHandleMap.isValid()) {
95 ATH_MSG_ERROR(
"Null pointer to the read conditions object "<<readHandleMap.fullKey());
96 return StatusCode::FAILURE;
100 ATH_MSG_INFO(
"Size of CondAttrListCollection " << readHandleMap.fullKey()
101 <<
" readCdoMap->size()= " << readHandleMap->size());
103 ATH_MSG_VERBOSE(
"Collection CondAttrListCollection CLID " << readHandleMap->clID());
108 return StatusCode::SUCCESS;
112 for (itrMap = readHandleMap->begin(); itrMap != readHandleMap->end(); ++itrMap) {
118 constexpr std::string_view
delimiter{
","};
119 const std::string map = *(
static_cast<const std::string*
>((atr[
"Map"]).addressOfData()));
128 return StatusCode::FAILURE;
135 ATH_MSG_INFO(
"Found a round 3 setup. Will add the cabling for BIS78 manually");
136 const int BIS_stat =
m_idHelperSvc->mdtIdHelper().stationNameIndex(
"BIS");
138 for (
unsigned int sector = 1; sector <= 8; ++sector) {
139 int is_biy{0}, tdcId{0};
140 auto increment_tdc = [&is_biy, &tdcId]() {
142 constexpr
int tdcMax = 17;
143 if (tdcId > tdcMax) {
148 constexpr
int tubesPerCsm = 54;
149 bool added_tdc =
true;
152 for (
int ml = 1; ml <= 2; ++ml) {
154 const int tubes_per_layer =
m_idHelperSvc->mdtIdHelper().tubeMax(layer_id);
156 const int first_tube = 6 * (1 + tdcId / 2) + tubesPerCsm * is_biy;
157 const bool valid_tube = (first_tube <= tubes_per_layer);
158 added_tdc |= valid_tube;
166 bis78_data.stationIndex = BIS_stat;
168 bis78_data.phi = sector;
171 bis78_data.mrod = (is_biy ? -1 : 7) + sector;
172 bis78_data.csm = is_biy ? 5 : 0;
173 bis78_data.subdetectorId = 99;
175 bis78_data.mezzanine_type = sector != 6 ? 61 : 71;
176 const unsigned int tube_coding = first_tube + bis78_data.tubes_per_layer * (4 + bis78_data.layer_block * ml);
178 <<
m_idHelperSvc->mdtIdHelper().tubeMax(layer_id) <<
" tdcId: "
179 << tdcId <<
" is_Biy: " << is_biy <<
" first_tube: " << first_tube);
184 <<
m_idHelperSvc->mdtIdHelper().stationNameString(bis78_data.stationIndex) <<
" " << bis78_data);
186 ATH_MSG_ERROR(
"Failed to add mezzanine card " << bis78_data);
187 return StatusCode::FAILURE;
190 if (bis78_data.tube != first_tube) {
191 ATH_MSG_ERROR(
"BIS78 data tube encoding failed. Expected " << first_tube <<
" got " << bis78_data.tube <<
".");
192 return StatusCode::FAILURE;
193 }
else if (bis78_data.multilayer != ml) {
194 ATH_MSG_ERROR(
"BIS78 data ml encoding failed. Expected " << ml <<
" got " << bis78_data.multilayer <<
".");
195 return StatusCode::FAILURE;
202 return StatusCode::SUCCESS;
206 map_data.
eta = *(
static_cast<const int*
>((atr[
"Eta"]).addressOfData()));
207 map_data.
phi = *(
static_cast<const int*
>((atr[
"Phi"]).addressOfData()));
208 map_data.
mrod = *(
static_cast<const int*
>((atr[
"MROD"]).addressOfData()));
209 map_data.
csm = *(
static_cast<const int*
>((atr[
"CSM"]).addressOfData()));
210 map_data.
channelId = *(
static_cast<const int*
>((atr[
"Chan"]).addressOfData()));
211 map_data.
mezzanine_type = *(
static_cast<const int*
>((atr[
"Mezzanine_Type"]).addressOfData()));
213 const std::string
chamber_name = *(
static_cast<const std::string*
>((atr[
"Chamber_Name"]).addressOfData()));
214 const std::string subdetector_id = *(
static_cast<const std::string*
>((atr[
"SubDet_Id"]).addressOfData()));
217 std::string stationNameString =
chamber_name.substr(0, 3);
219 if (stationNameString ==
"BOE") { stationNameString =
"BOL"; }
221 if (stationNameString ==
"BIX" || stationNameString ==
"BIY") {
222 stationNameString =
"BIS";
223 static std::atomic<bool> sInfoPrinted{
false};
225 ATH_MSG_INFO(
"Found an entry concerning the new BIS78 chambers. Will increase the number of tube per layer to "
248 static std::atomic<bool> stWarningPrinted{
false};
249 if (!stWarningPrinted) {
251 <<
" which is not reasonable, maybe related to ATLASRECTS-5961, continuing...");
252 stWarningPrinted =
true;
261 constexpr
unsigned int coding_block_size = 3;
262 const unsigned int n = info_map.size() >= coding_block_size ? coding_block_size : info_map.size();
263 bool decoded_full_block{
false};
264 for (
unsigned int i = 0;
i <
n; ++
i) {
281 decoded_full_block =
true;
286 if (decoded_full_block) info_map.erase(info_map.begin(), info_map.begin() + coding_block_size);
287 return decoded_full_block;
294 if (!in_json.good()) {
296 return StatusCode::FAILURE;
301 return StatusCode::SUCCESS;
306 if (!readHandleMez.isValid()) {
308 return StatusCode::FAILURE;
312 ATH_MSG_INFO(
"Size of CondAttrListCollection " << readHandleMez.fullKey()
313 <<
" readCdoMez->size()= " << readHandleMez->size());
319 return StatusCode::SUCCESS;
322 for (itrMez = readHandleMez->begin(); itrMez != readHandleMez->end(); ++itrMez) {
324 int sequence{0},
layer{0}, mezzanine_type{0};
326 mezzanine_type = *(
static_cast<const int*
>((atr[
"Mezzanine_Type"]).addressOfData()));
327 layer = *(
static_cast<const int*
>((atr[
"Layer"]).addressOfData()));
328 sequence = *(
static_cast<const int*
>((atr[
"Sequence"]).addressOfData()));
329 ATH_MSG_VERBOSE(
"Sequence load is " << sequence <<
" for the mezzanine type = " << mezzanine_type
330 <<
" for the layer number = " <<
layer);
334 ATH_MSG_ERROR(
"Could not add the mezzanine sequence to the map ");
335 return StatusCode::FAILURE;
340 return StatusCode::SUCCESS;
344 for (
const auto &cabl_chan :
payload.items()) {
346 const uint8_t id = mezz_payload[
"mezzId"];
347 const uint8_t nLay = mezz_payload[
"nTubeLayer"];
348 const MezzMapping
mapping = mezz_payload[
"tdcToTubeMap"];
350 msgStream()))
return StatusCode::FAILURE;
352 return StatusCode::SUCCESS;
356 for (
const auto &db_channel :
payload.items()) {
360 ms_channel.eta = ms_payload[
"eta"];
361 ms_channel.phi = ms_payload[
"phi"];
362 ms_channel.multilayer = ms_payload[
"ml"];
364 ms_channel.subdetectorId = ms_payload[
"subDet"];
365 ms_channel.csm = ms_payload[
"csm"];
366 ms_channel.mrod = ms_payload[
"mrod"];
368 ms_channel.mezzanine_type = ms_payload[
"mezzId"];
369 ms_channel.tdcId = ms_payload[
"tdcId"];
370 ms_channel.tube = ms_payload[
"tubeZero"];
372 ms_channel.layer = 1;
374 ms_channel.channelId = hedgeHogCard ? (*std::min_element(
375 hedgeHogCard->tubeToTdcMap().begin(),
376 hedgeHogCard->tubeToTdcMap().end())) : 0;
379 return StatusCode::SUCCESS;