ATLAS Offline Software
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 
8 void 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 
26 int 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 
36 std::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 
45 std::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 
54 std::string CostROSData::getROBName(uint32_t robId) const {
55  std::stringstream robName;
56  robName << "0x" << std::hex << robId;
57  return robName.str();
58 }
59 
60 MsgStream& CostROSData::msg() const {
61  return *m_msgStream;
62 }
63 
64 MsgStream& CostROSData::msg(const MSG::Level lvl) const {
65  return *m_msgStream << lvl;
66 }
67 
68 bool CostROSData::msgLvl(const MSG::Level lvl) const {
69  return lvl >= m_msgStream->level();
70 }
CostROSData::m_rosIdToBin
std::map< std::string, int > m_rosIdToBin
Cached mapping of ros id to bin in ROS histograms.
Definition: CostROSData.h:101
CostROSData.h
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
CostROSData::initialize
void initialize(const std::map< std::string, std::vector< uint32_t >> &rosToRobMap)
Create object based on ROS to ROB mapping.
Definition: CostROSData.cxx:8
CostROSData::getBinForROS
int getBinForROS(const std::string &rosName) const
Return cached bin for given ROS name.
Definition: CostROSData.cxx:26
CostROSData::m_rosToRob
std::map< std::string, std::vector< uint32_t > > m_rosToRob
Mapping of ROS corresponding to ROB requests.
Definition: CostROSData.h:99
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
CostROSData::getROBForROS
std::vector< uint32_t > getROBForROS(const std::string &rosName) const
Return list of ROBs name for given ROS.
Definition: CostROSData.cxx:45
CostROSData::getROBName
std::string getROBName(uint32_t robId) const
Create ROB name in hex string format.
Definition: CostROSData.cxx:54
CostROSData::msg
MsgStream & msg() const
Logging.
Definition: CostROSData.cxx:60
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
CostROSData::m_msgStream
boost::thread_specific_ptr< MsgStream > m_msgStream
Definition: CostROSData.h:103
CostROSData::msgLvl
bool msgLvl(const MSG::Level lvl) const
Returns if requested level is same or higher than logging level.
Definition: CostROSData.cxx:68
CostROSData::m_robToRos
std::map< uint32_t, std::string > m_robToRos
Mapping of ROB corresponding to ROS.
Definition: CostROSData.h:100
CostROSData::getROSForROB
std::string getROSForROB(uint32_t robId) const
Return ROS name for given ROB.
Definition: CostROSData.cxx:36