102 std::vector<unsigned short int> feedPadThresholds;
110 const coral::AttributeList& atr_map = readCdoMap->
attributeList(1);
117 const coral::AttributeList& atr_map_corr = readCdoCorr->
attributeList(1);
124 std::string etaCM_File;
127 for (itr_eta = readCdoEta->
begin(); itr_eta != readCdoEta->
end(); ++itr_eta) {
128 const coral::AttributeList& atr = itr_eta->second;
129 etaCM_File = *(
static_cast<const std::string*
>((atr[
"CM_File"]).addressOfData()));
130 etaTh0 = *(
static_cast<const std::string*
>((atr[
"Th0"]).addressOfData()));
131 trigroads[etaCM_File] = etaTh0;
138 std::string phiCM_File;
141 for (itr = readCdoPhi->
begin(); itr != readCdoPhi->
end(); ++itr) {
142 const coral::AttributeList& atr = itr->second;
143 phiCM_File = *(
static_cast<const std::string*
>((atr[
"CM_File"]).addressOfData()));
144 phiTh0 = *(
static_cast<const std::string*
>((atr[
"Th0"]).addressOfData()));
145 trigroads[phiCM_File] = phiTh0;
151 std::string version,
setup, layout;
154 unsigned int nlines = 0;
160 ATH_MSG_DEBUG(
"setup() - Reading routine. nlines = " << nlines);
162 data(
"Version") >> version >>
setup >> layout;
167 if (
data(
"SECTOR TYPES (") >> start >>
"-" >> stop >>
"):") {
168 for (
int i = start; i <= stop; ++i) {
data >> sectorMap[i]; }
172 if (stop == 63 || stop == 8) {
173 for (
int i = 0; i < 64; ++i) { maxType = std::max(sectorMap[i], maxType); }
176 ATH_MSG_DEBUG(
"setup() - Loop over " << maxType <<
" sector-types");
178 for (
int i = 1; i <= maxType; ++i) {
182 for (
int j = 0; j < 64; ++j) {
183 if (sectorMap[j] == i) {
185 sectorLogic.insert(SLmap_t::value_type(j, &sec));
186 ATH_MSG_DEBUG(
"setup() - filling sectorLogicSetup Map for type " << i <<
" sector " << j);
193 for (
int i = 1; i <= maxType; ++i) {
195 if (
data(
"RPC GEOM # :", i)) {
197 if (!(sectorType[i - 1] +=
RPCdata))
return StatusCode::FAILURE;
200 if (
data(
"WIRED OR # :", i)) {
202 if (!(sectorType[i - 1] += WORdata))
return StatusCode::FAILURE;
205 if (
data(
"CMAs # : pivot segmentation", i)) {
207 if (!(sectorType[i - 1] +=
CMAdata))
return StatusCode::FAILURE;
210 if (
data(
"CMAs # : eta cabling", i)) {
212 if (!(sectorType[i - 1] +=
CMAdata))
return StatusCode::FAILURE;
216 ATH_MSG_DEBUG(
"setup() - map n. of lines read is " << nlines);
219 for (
int i = 1; i <= maxType; ++i) {
220 if (!sectorType[i - 1].
setup(
msg()))
return StatusCode::FAILURE;
221 if (!sectorType[i - 1].check())
return StatusCode::FAILURE;
225 for (
const auto& cma : CMAs) {
226 unsigned int cabling = UINT_MAX;
238 for (
int sector = 0; sector < 64; ++sector) {
239 unsigned int nRDOentries = 0;
240 int side = (sector < 32) ? 0 : 1;
241 int logic_sector = sector % 32;
243 if (sectorMap[sector]) {
249 RPC_CondCabling::SectorLogicSetup::EtaCMAmap::const_iterator it = CMAs.begin();
251 bool isFirst =
false;
254 while (it != CMAs.end()) {
256 unsigned int ID = (*it).second.id().Ixx_index();
257 bool inversion = (*it).second.inversion();
258 isFirst = (ID == 1 && inversion) || (ID == 0 && !inversion);
259 unsigned int PADid = (*it).first.PAD_index();
260 unsigned int cabling = UINT_MAX;
262 unsigned int RPC_strip = cabling % 100;
263 unsigned int RPC_chamber = (cabling / 100) % 100;
264 unsigned int RPC_layer = 0;
265 unsigned int RPC_station = (*it).second.whichCMAstation(
CMAinput::Pivot);
266 unsigned int lvl1_sector = sector;
271 int sPhi = (logic_sector == 31) ? 1 : (logic_sector + 1) / 4 + 1;
277 RPCdecoder decode(Eta, lvl1_sector, RPC_station, RPC_layer, RPC_chamber, RPC_strip);
283 int key = side * 10000 + logic_sector * 100 + PADid;
285 std::pair<RpcCablingCondData::RDOmap::iterator, bool> ins =
286 writeCdo->
m_RDOs.insert(RpcCablingCondData::RDOmap::value_type(key, rdo));
289 ATH_MSG_ERROR(
"RpcCablingCondData::RDOmap is false for stationName="
290 << name <<
", stationEta=" << sEta <<
", stationPhi=" << sPhi <<
", doubletR=" << dR
291 <<
", doubletZ=" << dZ <<
", doubletPhi=" << dP);
292 return StatusCode::FAILURE;
298 else if (!(*it).second.get_cabling(
CMAinput::Pivot, 0, 0, 0, cabling) && isFirst) {
300 bool existLow =
false;
301 bool existHigh =
false;
303 if (!(existLow = (*it).second.get_cabling(
CMAinput::LowPt, 0, 0, 0, cabling)))
306 if (!existLow && !existHigh) {
308 return StatusCode::FAILURE;
311 unsigned int RPC_strip = cabling % 100;
312 unsigned int RPC_chamber = (cabling / 100) % 100;
313 unsigned int RPC_layer = 0;
314 unsigned int RPC_station = 0;
319 unsigned int lvl1_sector = sector;
324 int sPhi = (logic_sector == 31) ? 1 : (logic_sector + 1) / 4 + 1;
330 RPCdecoder decode(Eta, lvl1_sector, RPC_station, RPC_layer, RPC_chamber, RPC_strip);
336 int key = side * 10000 + logic_sector * 100 + PADid;
339 std::pair<RpcCablingCondData::RDOmap::iterator, bool> ins =
340 writeCdo->
m_RDOs.insert(RpcCablingCondData::RDOmap::value_type(key, rdo));
343 ATH_MSG_ERROR(
"RpcCablingCondData::RDOmap is false for stationName="
344 << name <<
", stationEta=" << sEta <<
", stationPhi=" << sPhi <<
", doubletR=" << dR
345 <<
", doubletZ=" << dZ <<
", doubletPhi=" << dP);
346 return StatusCode::FAILURE;
353 while (it != CMAs.end() && (
unsigned int)(*it).first.PAD_index() == PADid) { ++it; }
356 ATH_MSG_DEBUG(
"setup() - sector " << sector <<
", number of associated RDO (i.e. Pads) = " << nRDOentries);
359 DBline data_corr(MAP_corr);
361 while (++data_corr) {
363 unsigned short int SubId;
364 unsigned short int SecId;
365 unsigned short int PADId;
366 unsigned short int CMAId;
367 unsigned short int ijk;
368 unsigned short int inputType;
371 unsigned short int Channel1;
372 unsigned short int Channel2;
375 if (data_corr(
"CABLE") >> data_corr.
dbhex() >> SubId >> SecId >> PADId >> CMAId >> ijk >> data_corr.
dbdec() >>
type >> Channel1 >>
376 Channel2 >> Number) {
377 bool ok =
CableParamCheck(SubId, SecId, PADId, CMAId, ijk,
type, Channel1, Channel2, Number);
379 layer = (ijk == 0 || ijk == 2 || ijk == 3) ? 0 : 1;
382 Channel1 += 32 * (ijk % 2);
383 Channel2 += 32 * (ijk % 2);
386 unsigned short int lh = (CMAId >> 2) & 1;
388 if (ijk == 0 || ijk == 1)
391 inputType = (lh) ? 2 : 0;
393 if (ijk > 5) inputType = 3;
396 if (ok && !
correct(SubId, SecId, PADId, CMAId,
static_cast<CMAinput>(inputType), layer, Channel1, Channel2, Number,
399 << std::hex << std::setw(4) << std::showbase << SubId <<
" " << std::setw(4) << std::showbase << SecId
400 <<
" " << std::setw(3) << std::showbase << PADId <<
" " << std::setw(3) << std::showbase << CMAId <<
" "
401 << std::setw(3) << std::showbase << ijk <<
" " << std::dec << std::setw(1) << std::showbase <<
type <<
" "
402 << std::setw(2) << std::showbase << Channel1 <<
" " << std::setw(2) << std::showbase << Channel2 <<
" "
403 << std::setw(2) << std::showbase << Number);
406 if (data_corr(
"BOARD") >> data_corr.
dbhex() >> SubId >> SecId >> PADId >> CMAId >> data_corr.
dbdec() >> inputType >> layer >>
407 type >> Channel1 >> Channel2 >> Number) {
408 bool ok =
BoardParamCheck(SubId, SecId, PADId, CMAId, inputType, layer,
type, Channel1, Channel2, Number);
410 if (inputType > 2) inputType = 3;
413 if (ok && !
correct(SubId, SecId, PADId, CMAId,
static_cast<CMAinput>(inputType), layer, Channel1, Channel2, Number,
416 << std::hex << std::setw(4) << std::showbase << SubId <<
" " << std::setw(4) << std::showbase << SecId
417 <<
" " << std::setw(3) << std::showbase << PADId <<
" " << std::setw(3) << std::showbase << CMAId <<
" "
418 << std::dec << std::setw(1) << inputType <<
" " << std::setw(1) << layer <<
" " << std::dec << std::setw(1)
419 << std::showbase <<
type <<
" " << std::setw(2) << std::showbase << Channel1 <<
" " << std::setw(2)
420 << std::showbase << Channel2 <<
" " << std::setw(2) << std::showbase << Number);
424 ATH_MSG_DEBUG(
"setup() - corrected map n. of lines read is " << nlines);
427 for (
int side = 0; side < 2; ++side) {
428 for (
int rod = 0; rod < 16; ++rod) { (writeCdo->
m_rod2hash[side][rod]).
clear(); }
432 std::set<uint32_t> ROBid;
438 ATH_MSG_INFO(
"setup() - start building OfflineOnlineMap for " << writeCdo->
m_RDOs.size() <<
" RDOs");
440 RpcCablingCondData::RDOmap::iterator pad_beg = writeCdo->
m_RDOs.begin();
441 RpcCablingCondData::RDOmap::iterator pad_end = writeCdo->
m_RDOs.end();
442 for (; pad_beg != pad_end; ++pad_beg) {
443 const RDOindex* pRDOindex = &((*pad_beg).second);
447 writeCdo->
m_HashVec.push_back(pRDOindex);
450 ATH_MSG_ERROR(
"Size of hash vector and RDO hash does not match");
451 return StatusCode::FAILURE;
455 const unsigned short int rob_id = pRDOindex->
ROBid();
456 const unsigned short int rod_id = pRDOindex->
RODid();
457 const unsigned short int sub_id = pRDOindex->
side();
458 const unsigned short int sec_id = pRDOindex->
SLid();
459 const unsigned short int pad_id = pRDOindex->
PADid();
461 uint32_t ROD_ID = (sub_id << 16) | rod_id;
462 uint32_t ROB_ID = (sub_id << 16) | rob_id;
464 ROBid.insert(ROB_ID);
465 unsigned short int sub_id_index = ((sub_id == 0x65) ? 1 : 0);
470 ATH_MSG_DEBUG(hashID <<
"-th entry has sub_id_index=" << sub_id_index <<
", ROBid=" << rob_id <<
", RODid=" << rod_id <<
", side="
471 << sub_id <<
", SLid=" << sec_id <<
", PADid=" << pad_id <<
", pad_identifier=" <<
id.get_compact());
474 writeCdo->
m_offline_id[sub_id_index][sec_id][pad_id] = id;
477 std::pair<RpcCablingCondData::OfflineOnlineMap::iterator, bool> ins =
478 writeCdo->
m_RDOmap.insert(RpcCablingCondData::OfflineOnlineMap::value_type(
id, pRDOindex));
479 ATH_MSG_DEBUG(
"OfflineOnlineMap new entry: Identifier with technology="
481 <<
", stationEta=" <<
m_idHelperSvc->rpcIdHelper().stationEta(
id) <<
", stationPhi="
483 <<
", doubletZ=" <<
m_idHelperSvc->rpcIdHelper().doubletZ(
id) <<
", doubletPhi="
484 <<
m_idHelperSvc->rpcIdHelper().doubletPhi(
id) <<
" and hash of the RDOindex(key)= " << pRDOindex->
hash());
486 ATH_MSG_ERROR(
"RpcCablingCondData::OfflineOnlineMap is false for technology="
488 <<
", stationEta=" <<
m_idHelperSvc->rpcIdHelper().stationEta(
id) <<
", stationPhi="
490 <<
", doubletZ=" <<
m_idHelperSvc->rpcIdHelper().doubletZ(
id) <<
", doubletPhi="
491 <<
m_idHelperSvc->rpcIdHelper().doubletPhi(
id) <<
" and hash of the RDOindex(key)= " << pRDOindex->
hash());
492 return StatusCode::FAILURE;
496 std::pair<std::set<IdentifierHash>::iterator,
bool> insert_ROB_RDO_returnVal =
498 if (insert_ROB_RDO_returnVal.second)
499 ATH_MSG_DEBUG(
"A new RDO HashId = " << pRDOindex->
hash() <<
" registered for ROB Id = " << ROB_ID);
501 ATH_MSG_VERBOSE(
"The RDO HashId = " << pRDOindex->
hash() <<
" was already registered for ROB Id = " << ROB_ID);
505 std::list<Identifier> strip_id_list;
507 ATH_MSG_DEBUG(
"RDO HashId = " << (
int)rdoHashId <<
" RDO Id = " <<
id.get_compact() <<
" ROB Id = " << MSG::hex << ROB_ID
508 << MSG::dec <<
" ROD Id = " << MSG::hex << ROD_ID << MSG::dec);
510 for (
unsigned short int CMAId : {2, 3, 6, 7}) {
511 for (
unsigned short int ijk : {1, 2, 3}) {
512 strip_id_list.clear();
513 for (
unsigned short int channel : {0, 31}) {
514 strip_id_list.splice(strip_id_list.end(),
515 give_strip_id(sub_id_index, sec_id, pad_id, CMAId, ijk, channel, sectorMap, sectorType));
520 int gethash_code =
m_idHelperSvc->rpcIdHelper().get_hash(idp, prdHashId, &rpcModuleContext);
521 if (gethash_code != 0) {
527 std::pair<std::set<IdentifierHash>::iterator,
bool> insertRDO_returnVal =
529 if (insertRDO_returnVal.second) {
530 ATH_MSG_DEBUG(
"A new RDO HashId = " << (
int)rdoHashId <<
" registered for PRD HashId = " << (
int)prdHashId);
533 <<
" was already registered for PRD HashId = " << (
int)prdHashId);
537 std::pair<std::set<uint32_t>::iterator,
bool> insertROB_returnVal = writeCdo->
m_PRD_ROB_map[prdHashId].insert(ROB_ID);
538 if (insertROB_returnVal.second) {
539 ATH_MSG_DEBUG(
"A new ROB Id = " << MSG::hex << ROB_ID << MSG::dec
540 <<
" registered for PRD HashId = " << (
int)prdHashId);
543 <<
" was already registered for PRD HashId = " << (
int)prdHashId);
550 TrigRoadsMap::const_iterator it;
551 it = trigroads.find(
"infos.txt");
552 if (it == trigroads.end()) {
555 ATH_MSG_VERBOSE(
"======== RPC Trigger Roads from COOL - Header infos ========");
559 std::stringstream
ss;
563 if (word ==
"FeetPadThresholds") {
564 feedPadThresholds.assign(3, 0);
565 ss >> feedPadThresholds.at(0);
566 ss >> feedPadThresholds.at(1);
567 ss >> feedPadThresholds.at(2);
568 ATH_MSG_VERBOSE(
"FeetPadThresholds set from COOL to: " << feedPadThresholds.at(0) <<
"," << feedPadThresholds.at(1)
569 <<
"," << feedPadThresholds.at(2));
577 index.pad_identifier(
id);
582 ATH_MSG_ERROR(
"Inconsistence between PAD hash and RpcPadIdHash");
585 return StatusCode::FAILURE;
588 unsigned short int side =
index.side();
589 unsigned short int rod =
index.RODid();
593 return StatusCode::FAILURE;
598 (writeCdo->
m_rod2hash[(side == 0x66) ? 0 : 1][rod]).push_back(HashID);
605 ATH_MSG_DEBUG(
"setup() - start recording RpcCablingCondData");
610 if (feedPadThresholds.size() != 3) {
612 feedPadThresholds.assign(3, 0);
613 feedPadThresholds.at(0) = 0;
614 feedPadThresholds.at(1) = 2;
615 feedPadThresholds.at(2) = 5;
617 ATH_MSG_INFO(
"Applying FeetPadThresholds : " << feedPadThresholds.at(0) <<
"," << feedPadThresholds.at(1) <<
","
618 << feedPadThresholds.at(2));
620 const unsigned int NumFeetSectors = 8;
621 unsigned int FeetSectors[NumFeetSectors] = {21, 22, 25, 26, 53, 54, 57, 58};
622 const unsigned int NumSpecialFeetPads = 4;
623 unsigned int SpecialFeetPads[NumSpecialFeetPads] = {2, 4, 5, 7};
625 for (
unsigned int is = 0; is < NumFeetSectors; is++) {
626 for (
unsigned int it = 0; it < NumSpecialFeetPads; it++) {
628 for (
unsigned int th = 0; th < 3; th++) {
630 feedPadThresholds.at(th));
642 for (
int i = 0; i < 64; i++) writeCdo->
m_SectorMap[i] = sectorMap[i];
647 std::stringstream ss1;
648 ss1 <<
"Level-1 configuration database " << std::endl;
649 ss1 <<
"Contains " << maxType <<
" Trigger Sector Types:" << std::endl;
650 ss1 <<
"negative sectors 0 - 15 ==> ";
651 for (
int i = 0; i < 16; i++) ss1 << std::setw(2) << sectorMap[i] <<
" ";
652 ss1 << std::endl <<
"negative sectors 16 - 31 ==> ";
653 for (
int i = 16; i < 32; i++) ss1 << std::setw(2) << sectorMap[i] <<
" ";
654 ss1 << std::endl <<
"positive sectors 32 - 47 ==> ";
655 for (
int i = 32; i < 48; i++) ss1 << std::setw(2) << sectorMap[i] <<
" ";
656 ss1 << std::endl <<
"positive sectors 48 - 63 ==> ";
657 for (
int i = 48; i < 64; i++) ss1 << std::setw(2) << sectorMap[i] <<
" ";
663 if (writeCdo->
m_RDOs.empty()) {
665 return StatusCode::FAILURE;
669 return StatusCode::FAILURE;
673 return StatusCode::FAILURE;
677 return StatusCode::FAILURE;
681 return StatusCode::FAILURE;
685 return StatusCode::FAILURE;
688 return StatusCode::SUCCESS;