ATLAS Offline Software
Loading...
Searching...
No Matches
CostROSData.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "CostROSData.h"
6
7
8void CostROSData::initialize(const std::map<std::string, std::vector<uint32_t>>& rosToRobMap) {
9
10 unsigned rosCounter = 0;
11
12 for (const auto& rosRequest : rosToRobMap) {
13 for (uint32_t robId : rosRequest.second) {
14 m_robToRos[robId] = rosRequest.first;
15 }
16 m_rosIdToBin[rosRequest.first] = rosCounter;
17 ++rosCounter;
18 }
19
20 m_rosToRob = rosToRobMap;
21
22 m_msgStream.reset(new MsgStream(nullptr, "CostROSData"));
23}
24
25
26int CostROSData::getBinForROS(const std::string& rosName) const {
27 try {
28 return m_rosIdToBin.at(rosName);
29 } catch (const std::out_of_range& e) {
30 ATH_MSG_DEBUG("Bin for ROS " << rosName << " not found");
31 return -1;
32 }
33}
34
35
36std::string CostROSData::getROSForROB(uint32_t robId) const {
37 try {
38 return m_robToRos.at(robId);
39 } catch (const std::out_of_range& e) {
40 ATH_MSG_DEBUG("ROS for ROB " << getROBName(robId) << " not found");
41 return "";
42 }
43}
44
45std::vector<uint32_t> CostROSData::getROBForROS(const std::string& rosName) const {
46 try {
47 return m_rosToRob.at(rosName);
48 } catch (const std::out_of_range& e) {
49 ATH_MSG_DEBUG("ROBs for ROS " << rosName << " not found");
50 return std::vector<uint32_t>();
51 }
52}
53
54std::string CostROSData::getROBName(uint32_t robId) const {
55 std::stringstream robName;
56 robName << "0x" << std::hex << robId;
57 return robName.str();
58}
59
60MsgStream& CostROSData::msg() const {
61 return *m_msgStream;
62}
63
64MsgStream& CostROSData::msg(const MSG::Level lvl) const {
65 return *m_msgStream << lvl;
66}
67
68bool CostROSData::msgLvl(const MSG::Level lvl) const {
69 return lvl >= m_msgStream->level();
70}
#define ATH_MSG_DEBUG(x)
std::map< uint32_t, std::string > m_robToRos
Mapping of ROB corresponding to ROS.
int getBinForROS(const std::string &rosName) const
Return cached bin for given ROS name.
boost::thread_specific_ptr< MsgStream > m_msgStream
bool msgLvl(const MSG::Level lvl) const
Returns if requested level is same or higher than logging level.
std::string getROBName(uint32_t robId) const
Create ROB name in hex string format.
std::map< std::string, int > m_rosIdToBin
Cached mapping of ros id to bin in ROS histograms.
void initialize(const std::map< std::string, std::vector< uint32_t > > &rosToRobMap)
Create object based on ROS to ROB mapping.
std::vector< uint32_t > getROBForROS(const std::string &rosName) const
Return list of ROBs name for given ROS.
std::string getROSForROB(uint32_t robId) const
Return ROS name for given ROB.
std::map< std::string, std::vector< uint32_t > > m_rosToRob
Mapping of ROS corresponding to ROB requests.
Definition CostROSData.h:99
MsgStream & msg() const
Logging.