99 std::vector<unsigned short int> feedPadThresholds;
100 std::map<std::string, std::string> trigroads;
107 const coral::AttributeList& atr_map = readCdoMap->
attributeList(1);
114 const coral::AttributeList& atr_map_corr = readCdoCorr->
attributeList(1);
121 std::string etaCM_File;
124 for (itr_eta = readCdoEta->
begin(); itr_eta != readCdoEta->
end(); ++itr_eta) {
125 const coral::AttributeList& atr = itr_eta->second;
126 etaCM_File = *(
static_cast<const std::string*
>((atr[
"CM_File"]).addressOfData()));
127 etaTh0 = *(
static_cast<const std::string*
>((atr[
"Th0"]).addressOfData()));
128 trigroads[etaCM_File] = etaTh0;
135 std::string phiCM_File;
138 for (itr = readCdoPhi->
begin(); itr != readCdoPhi->
end(); ++itr) {
139 const coral::AttributeList& atr = itr->second;
140 phiCM_File = *(
static_cast<const std::string*
>((atr[
"CM_File"]).addressOfData()));
141 phiTh0 = *(
static_cast<const std::string*
>((atr[
"Th0"]).addressOfData()));
142 trigroads[phiCM_File] = phiTh0;
148 std::string version,
setup, layout;
151 unsigned int nlines = 0;
157 ATH_MSG_DEBUG(
"setup() - Reading routine. nlines = " << nlines);
159 data(
"Version") >> version >>
setup >> layout;
164 if (
data(
"SECTOR TYPES (") >> start >>
"-" >> stop >>
"):") {
165 for (
int i = start; i <= stop; ++i) {
data >> sectorMap[i]; }
169 if (stop == 63 || stop == 8) {
170 for (
int i = 0; i < 64; ++i) { maxType = std::max(sectorMap[i], maxType); }
173 ATH_MSG_DEBUG(
"setup() - Loop over " << maxType <<
" sector-types");
175 for (
int i = 1; i <= maxType; ++i) {
179 for (
int j = 0; j < 64; ++j) {
180 if (sectorMap[j] == i) {
182 sectorLogic.insert(SLmap_t::value_type(j, &sec));
183 ATH_MSG_DEBUG(
"setup() - filling sectorLogicSetup Map for type " << i <<
" sector " << j);
190 for (
int i = 1; i <= maxType; ++i) {
192 if (
data(
"RPC GEOM # :", i)) {
194 if (!(sectorType[i - 1] +=
RPCdata))
return StatusCode::FAILURE;
197 if (
data(
"WIRED OR # :", i)) {
199 if (!(sectorType[i - 1] += WORdata))
return StatusCode::FAILURE;
202 if (
data(
"CMAs # : pivot segmentation", i)) {
204 if (!(sectorType[i - 1] +=
CMAdata))
return StatusCode::FAILURE;
207 if (
data(
"CMAs # : eta cabling", i)) {
209 if (!(sectorType[i - 1] +=
CMAdata))
return StatusCode::FAILURE;
213 ATH_MSG_DEBUG(
"setup() - map n. of lines read is " << nlines);
216 for (
int i = 1; i <= maxType; ++i) {
217 if (!sectorType[i - 1].
setup(
msg()))
return StatusCode::FAILURE;
218 if (!sectorType[i - 1].check())
return StatusCode::FAILURE;
222 for (
const auto& cma : CMAs) {
223 unsigned int cabling = UINT_MAX;
235 for (
int sector = 0; sector < 64; ++sector) {
236 unsigned int nRDOentries = 0;
237 int side = (sector < 32) ? 0 : 1;
238 int logic_sector = sector % 32;
240 if (sectorMap[sector]) {
246 RPC_CondCabling::SectorLogicSetup::EtaCMAmap::const_iterator it = CMAs.begin();
248 bool isFirst =
false;
251 while (it != CMAs.end()) {
253 unsigned int ID = (*it).second.id().Ixx_index();
254 bool inversion = (*it).second.inversion();
255 isFirst = (
ID == 1 && inversion) || (
ID == 0 && !inversion);
256 unsigned int PADid = (*it).first.PAD_index();
257 unsigned int cabling = UINT_MAX;
259 unsigned int RPC_strip = cabling % 100;
260 unsigned int RPC_chamber = (cabling / 100) % 100;
261 unsigned int RPC_layer = 0;
262 unsigned int RPC_station = (*it).second.whichCMAstation(
CMAinput::Pivot);
263 unsigned int lvl1_sector = sector;
268 int sPhi = (logic_sector == 31) ? 1 : (logic_sector + 1) / 4 + 1;
274 RPCdecoder decode(Eta, lvl1_sector, RPC_station, RPC_layer, RPC_chamber, RPC_strip);
280 int key = side * 10000 + logic_sector * 100 + PADid;
282 std::pair<RpcCablingCondData::RDOmap::iterator, bool> ins =
283 writeCdo->
m_RDOs.insert(RpcCablingCondData::RDOmap::value_type(key, rdo));
286 ATH_MSG_ERROR(
"RpcCablingCondData::RDOmap is false for stationName="
287 << name <<
", stationEta=" << sEta <<
", stationPhi=" << sPhi <<
", doubletR=" << dR
288 <<
", doubletZ=" << dZ <<
", doubletPhi=" << dP);
289 return StatusCode::FAILURE;
295 else if (!(*it).second.get_cabling(
CMAinput::Pivot, 0, 0, 0, cabling) && isFirst) {
297 bool existLow =
false;
298 bool existHigh =
false;
300 if (!(existLow = (*it).second.get_cabling(
CMAinput::LowPt, 0, 0, 0, cabling)))
303 if (!existLow && !existHigh) {
305 return StatusCode::FAILURE;
308 unsigned int RPC_strip = cabling % 100;
309 unsigned int RPC_chamber = (cabling / 100) % 100;
310 unsigned int RPC_layer = 0;
311 unsigned int RPC_station = 0;
316 unsigned int lvl1_sector = sector;
321 int sPhi = (logic_sector == 31) ? 1 : (logic_sector + 1) / 4 + 1;
327 RPCdecoder decode(Eta, lvl1_sector, RPC_station, RPC_layer, RPC_chamber, RPC_strip);
333 int key = side * 10000 + logic_sector * 100 + PADid;
336 std::pair<RpcCablingCondData::RDOmap::iterator, bool> ins =
337 writeCdo->
m_RDOs.insert(RpcCablingCondData::RDOmap::value_type(key, rdo));
340 ATH_MSG_ERROR(
"RpcCablingCondData::RDOmap is false for stationName="
341 << name <<
", stationEta=" << sEta <<
", stationPhi=" << sPhi <<
", doubletR=" << dR
342 <<
", doubletZ=" << dZ <<
", doubletPhi=" << dP);
343 return StatusCode::FAILURE;
350 while (it != CMAs.end() && (
unsigned int)(*it).first.PAD_index() == PADid) { ++it; }
353 ATH_MSG_DEBUG(
"setup() - sector " << sector <<
", number of associated RDO (i.e. Pads) = " << nRDOentries);
356 DBline data_corr(MAP_corr);
358 while (++data_corr) {
360 unsigned short int SubId;
361 unsigned short int SecId;
362 unsigned short int PADId;
363 unsigned short int CMAId;
364 unsigned short int ijk;
365 unsigned short int inputType;
368 unsigned short int Channel1;
369 unsigned short int Channel2;
372 if (data_corr(
"CABLE") >> data_corr.
dbhex() >> SubId >> SecId >> PADId >> CMAId >> ijk >> data_corr.
dbdec() >>
type >> Channel1 >>
373 Channel2 >> Number) {
374 bool ok =
CableParamCheck(SubId, SecId, PADId, CMAId, ijk,
type, Channel1, Channel2, Number);
376 layer = (ijk == 0 || ijk == 2 || ijk == 3) ? 0 : 1;
379 Channel1 += 32 * (ijk % 2);
380 Channel2 += 32 * (ijk % 2);
383 unsigned short int lh = (CMAId >> 2) & 1;
385 if (ijk == 0 || ijk == 1)
388 inputType = (lh) ? 2 : 0;
390 if (ijk > 5) inputType = 3;
393 if (ok && !
correct(SubId, SecId, PADId, CMAId,
static_cast<CMAinput>(inputType), layer, Channel1, Channel2, Number,
396 << std::hex << std::setw(4) << std::showbase << SubId <<
" " << std::setw(4) << std::showbase << SecId
397 <<
" " << std::setw(3) << std::showbase << PADId <<
" " << std::setw(3) << std::showbase << CMAId <<
" "
398 << std::setw(3) << std::showbase << ijk <<
" " << std::dec << std::setw(1) << std::showbase <<
type <<
" "
399 << std::setw(2) << std::showbase << Channel1 <<
" " << std::setw(2) << std::showbase << Channel2 <<
" "
400 << std::setw(2) << std::showbase << Number);
403 if (data_corr(
"BOARD") >> data_corr.
dbhex() >> SubId >> SecId >> PADId >> CMAId >> data_corr.
dbdec() >> inputType >> layer >>
404 type >> Channel1 >> Channel2 >> Number) {
405 bool ok =
BoardParamCheck(SubId, SecId, PADId, CMAId, inputType, layer,
type, Channel1, Channel2, Number);
407 if (inputType > 2) inputType = 3;
410 if (ok && !
correct(SubId, SecId, PADId, CMAId,
static_cast<CMAinput>(inputType), layer, Channel1, Channel2, Number,
413 << std::hex << std::setw(4) << std::showbase << SubId <<
" " << std::setw(4) << std::showbase << SecId
414 <<
" " << std::setw(3) << std::showbase << PADId <<
" " << std::setw(3) << std::showbase << CMAId <<
" "
415 << std::dec << std::setw(1) << inputType <<
" " << std::setw(1) << layer <<
" " << std::dec << std::setw(1)
416 << std::showbase <<
type <<
" " << std::setw(2) << std::showbase << Channel1 <<
" " << std::setw(2)
417 << std::showbase << Channel2 <<
" " << std::setw(2) << std::showbase << Number);
421 ATH_MSG_DEBUG(
"setup() - corrected map n. of lines read is " << nlines);
424 for (
int side = 0; side < 2; ++side) {
425 for (
int rod = 0; rod < 16; ++rod) { (writeCdo->
m_rod2hash[side][rod]).clear(); }
429 std::set<uint32_t> ROBid;
435 ATH_MSG_INFO(
"setup() - start building OfflineOnlineMap for " << writeCdo->
m_RDOs.size() <<
" RDOs");
437 RpcCablingCondData::RDOmap::iterator pad_beg = writeCdo->
m_RDOs.begin();
438 RpcCablingCondData::RDOmap::iterator pad_end = writeCdo->
m_RDOs.end();
439 for (; pad_beg != pad_end; ++pad_beg) {
440 const RDOindex* pRDOindex = &((*pad_beg).second);
444 writeCdo->
m_HashVec.push_back(pRDOindex);
447 ATH_MSG_ERROR(
"Size of hash vector and RDO hash does not match");
448 return StatusCode::FAILURE;
452 const unsigned short int rob_id = pRDOindex->
ROBid();
453 const unsigned short int rod_id = pRDOindex->
RODid();
454 const unsigned short int sub_id = pRDOindex->
side();
455 const unsigned short int sec_id = pRDOindex->
SLid();
456 const unsigned short int pad_id = pRDOindex->
PADid();
458 uint32_t ROD_ID = (sub_id << 16) | rod_id;
459 uint32_t ROB_ID = (sub_id << 16) | rob_id;
461 ROBid.insert(ROB_ID);
462 unsigned short int sub_id_index = ((sub_id == 0x65) ? 1 : 0);
467 ATH_MSG_DEBUG(hashID <<
"-th entry has sub_id_index=" << sub_id_index <<
", ROBid=" << rob_id <<
", RODid=" << rod_id <<
", side="
468 << sub_id <<
", SLid=" << sec_id <<
", PADid=" << pad_id <<
", pad_identifier=" <<
id.get_compact());
471 writeCdo->
m_offline_id[sub_id_index][sec_id][pad_id] = id;
474 std::pair<RpcCablingCondData::OfflineOnlineMap::iterator, bool> ins =
475 writeCdo->
m_RDOmap.insert(RpcCablingCondData::OfflineOnlineMap::value_type(
id, pRDOindex));
476 ATH_MSG_DEBUG(
"OfflineOnlineMap new entry: Identifier with technology="
478 <<
", stationEta=" <<
m_idHelperSvc->rpcIdHelper().stationEta(
id) <<
", stationPhi="
480 <<
", doubletZ=" <<
m_idHelperSvc->rpcIdHelper().doubletZ(
id) <<
", doubletPhi="
481 <<
m_idHelperSvc->rpcIdHelper().doubletPhi(
id) <<
" and hash of the RDOindex(key)= " << pRDOindex->
hash());
483 ATH_MSG_ERROR(
"RpcCablingCondData::OfflineOnlineMap is false for technology="
485 <<
", stationEta=" <<
m_idHelperSvc->rpcIdHelper().stationEta(
id) <<
", stationPhi="
487 <<
", doubletZ=" <<
m_idHelperSvc->rpcIdHelper().doubletZ(
id) <<
", doubletPhi="
488 <<
m_idHelperSvc->rpcIdHelper().doubletPhi(
id) <<
" and hash of the RDOindex(key)= " << pRDOindex->
hash());
489 return StatusCode::FAILURE;
493 std::pair<std::set<IdentifierHash>::iterator,
bool> insert_ROB_RDO_returnVal =
495 if (insert_ROB_RDO_returnVal.second)
496 ATH_MSG_DEBUG(
"A new RDO HashId = " << pRDOindex->
hash() <<
" registered for ROB Id = " << ROB_ID);
498 ATH_MSG_VERBOSE(
"The RDO HashId = " << pRDOindex->
hash() <<
" was already registered for ROB Id = " << ROB_ID);
502 std::list<Identifier> strip_id_list;
504 ATH_MSG_DEBUG(
"RDO HashId = " << (
int)rdoHashId <<
" RDO Id = " <<
id.get_compact() <<
" ROB Id = " << MSG::hex << ROB_ID
505 << MSG::dec <<
" ROD Id = " << MSG::hex << ROD_ID << MSG::dec);
507 for (
unsigned short int CMAId : {2, 3, 6, 7}) {
508 for (
unsigned short int ijk : {1, 2, 3}) {
509 strip_id_list.clear();
510 for (
unsigned short int channel : {0, 31}) {
511 strip_id_list.splice(strip_id_list.end(),
512 give_strip_id(sub_id_index, sec_id, pad_id, CMAId, ijk, channel, sectorMap, sectorType));
517 int gethash_code =
m_idHelperSvc->rpcIdHelper().get_hash(idp, prdHashId, &rpcModuleContext);
518 if (gethash_code != 0) {
524 std::pair<std::set<IdentifierHash>::iterator,
bool> insertRDO_returnVal =
526 if (insertRDO_returnVal.second) {
527 ATH_MSG_DEBUG(
"A new RDO HashId = " << (
int)rdoHashId <<
" registered for PRD HashId = " << (
int)prdHashId);
530 <<
" was already registered for PRD HashId = " << (
int)prdHashId);
534 std::pair<std::set<uint32_t>::iterator,
bool> insertROB_returnVal = writeCdo->
m_PRD_ROB_map[prdHashId].insert(ROB_ID);
535 if (insertROB_returnVal.second) {
536 ATH_MSG_DEBUG(
"A new ROB Id = " << MSG::hex << ROB_ID << MSG::dec
537 <<
" registered for PRD HashId = " << (
int)prdHashId);
540 <<
" was already registered for PRD HashId = " << (
int)prdHashId);
547 std::map<std::string, std::string>::const_iterator it;
548 it = trigroads.find(
"infos.txt");
549 if (it == trigroads.end()) {
552 ATH_MSG_VERBOSE(
"======== RPC Trigger Roads from COOL - Header infos ========");
556 std::stringstream
ss;
560 if (word ==
"FeetPadThresholds") {
561 feedPadThresholds.assign(3, 0);
562 ss >> feedPadThresholds.at(0);
563 ss >> feedPadThresholds.at(1);
564 ss >> feedPadThresholds.at(2);
565 ATH_MSG_VERBOSE(
"FeetPadThresholds set from COOL to: " << feedPadThresholds.at(0) <<
"," << feedPadThresholds.at(1)
566 <<
"," << feedPadThresholds.at(2));
574 index.pad_identifier(
id);
579 ATH_MSG_ERROR(
"Inconsistence between PAD hash and RpcPadIdHash");
582 return StatusCode::FAILURE;
585 unsigned short int side =
index.side();
586 unsigned short int rod =
index.RODid();
590 return StatusCode::FAILURE;
595 (writeCdo->
m_rod2hash[(side == 0x66) ? 0 : 1][rod]).push_back(HashID);
602 ATH_MSG_DEBUG(
"setup() - start recording RpcCablingCondData");
607 if (feedPadThresholds.size() != 3) {
609 feedPadThresholds.assign(3, 0);
610 feedPadThresholds.at(0) = 0;
611 feedPadThresholds.at(1) = 2;
612 feedPadThresholds.at(2) = 5;
614 ATH_MSG_INFO(
"Applying FeetPadThresholds : " << feedPadThresholds.at(0) <<
"," << feedPadThresholds.at(1) <<
","
615 << feedPadThresholds.at(2));
617 const unsigned int NumFeetSectors = 8;
618 unsigned int FeetSectors[NumFeetSectors] = {21, 22, 25, 26, 53, 54, 57, 58};
619 const unsigned int NumSpecialFeetPads = 4;
620 unsigned int SpecialFeetPads[NumSpecialFeetPads] = {2, 4, 5, 7};
622 for (
unsigned int is = 0; is < NumFeetSectors; is++) {
623 for (
unsigned int it = 0; it < NumSpecialFeetPads; it++) {
625 for (
unsigned int th = 0; th < 3; th++) {
627 feedPadThresholds.at(th));
639 for (
int i = 0; i < 64; i++) writeCdo->
m_SectorMap[i] = sectorMap[i];
644 std::stringstream ss1;
645 ss1 <<
"Level-1 configuration database " << std::endl;
646 ss1 <<
"Contains " << maxType <<
" Trigger Sector Types:" << std::endl;
647 ss1 <<
"negative sectors 0 - 15 ==> ";
648 for (
int i = 0; i < 16; i++) ss1 << std::setw(2) << sectorMap[i] <<
" ";
649 ss1 << std::endl <<
"negative sectors 16 - 31 ==> ";
650 for (
int i = 16; i < 32; i++) ss1 << std::setw(2) << sectorMap[i] <<
" ";
651 ss1 << std::endl <<
"positive sectors 32 - 47 ==> ";
652 for (
int i = 32; i < 48; i++) ss1 << std::setw(2) << sectorMap[i] <<
" ";
653 ss1 << std::endl <<
"positive sectors 48 - 63 ==> ";
654 for (
int i = 48; i < 64; i++) ss1 << std::setw(2) << sectorMap[i] <<
" ";
660 if (writeCdo->
m_RDOs.empty()) {
662 return StatusCode::FAILURE;
666 return StatusCode::FAILURE;
670 return StatusCode::FAILURE;
674 return StatusCode::FAILURE;
678 return StatusCode::FAILURE;
682 return StatusCode::FAILURE;
685 return StatusCode::SUCCESS;