ATLAS Offline Software
TrigOperationalInfo.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include <sstream>
7 #include <cmath>
8 
9 
11 
12 }
13 
14 TrigOperationalInfo::TrigOperationalInfo(const std::vector<std::string>& keys,
15  const std::vector<float>& values)
16  : m_infoName (keys),
17  m_infoValue (values)
18 {
19 }
20 
21 unsigned int TrigOperationalInfo::defined(const std::string& name) const {
22  return count( m_infoName.begin(), m_infoName.end(), name );
23 }
24 
25 float TrigOperationalInfo::get(const std::string& name) const {
26  std::vector<std::string>::const_iterator it;
27  it = find ( m_infoName.begin(), m_infoName.end(), name );
28  return m_infoValue[it - m_infoName.begin()];
29 }
30 
31 void TrigOperationalInfo::set(const std::string& name, float value) {
32  // Tim Martin - April 2016. Removed code which enforces unique names. Rquired by use in Cost Monitoring.
33  m_infoName.push_back(name);
34  m_infoValue.push_back(value);
35 }
36 
37 std::pair<std::vector<std::string>, std::vector<float> > TrigOperationalInfo::infos() const {
38  return std::make_pair(m_infoName, m_infoValue);
39 }
40 
41 const std::vector<std::string>& TrigOperationalInfo::getKeys() const {
42  return m_infoName;
43 }
44 
45 const std::vector<float>& TrigOperationalInfo::getValues() const {
46  return m_infoValue;
47 }
48 
49 void TrigOperationalInfo::updateAtLocation(unsigned int location, float value) {
50  m_infoValue.at(location) = value;
51 }
52 
54 // helper operators
55 
56 
57 std::string str ( const TrigOperationalInfo& d ) {
58  std::stringstream ss;
59  std::pair<std::vector<std::string>, std::vector<float> > quantities = d.infos();
60  std::vector<std::string>::const_iterator keyIt = quantities.first.begin();
61  std::vector<float>::const_iterator valueIt = quantities.second.begin();
62  for (unsigned int i = 0; i < quantities.first.size(); i++ ) {
63  ss << " " << *keyIt << ": " << *valueIt;
64  ++keyIt;
65  ++valueIt;
66  }
67  return ss.str();
68 }
69 
70 MsgStream& operator<< ( MsgStream& m, const TrigOperationalInfo& d ) {
71  m << str(d);
72  return m;
73 }
74 
75 
77 
78  std::pair<std::vector<std::string>, std::vector<float> > a_infos = a.infos();
79  std::pair<std::vector<std::string>, std::vector<float> > b_infos = b.infos();
80  if ( a_infos.first.size() != b_infos.first.size())
81  return false;
82  if ( ! (a_infos.first == b_infos.first))
83  return false;
84 
85  if ( ! (a_infos.second == b_infos.second))
86  return false;
87 
88  return true;
89 }
90 void diff( const TrigOperationalInfo& a, const TrigOperationalInfo& b, std::map<std::string, double>& variableChange ) {
91  std::pair<std::vector<std::string>, std::vector<float> > a_infos = a.infos();
92  std::pair<std::vector<std::string>, std::vector<float> > b_infos = b.infos();
93 
94  if ( a_infos.first.size() != b_infos.first.size())
95  variableChange["size"] = a_infos.first.size() - b_infos.first.size();
96 
97  std::vector<std::string>::const_iterator a_keyIt = a_infos.first.begin();
98  std::vector<float>::const_iterator a_valueIt = a_infos.second.begin();
99  for ( unsigned i = 0; i < a_infos.first.size(); i++ ) {
100  if ( b.defined(*a_keyIt) ) {
101  float b_val = b.get(*a_keyIt);
102  variableChange[*a_keyIt] = *a_valueIt - b_val;
103  } else {
104  variableChange[*a_keyIt+"_abs"] = *a_valueIt;
105  }
106 
107  ++a_keyIt;
108  ++a_valueIt;
109  }
110 }
TrigOperationalInfo::get
float get(const std::string &name) const
Definition: TrigOperationalInfo.cxx:25
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
TrigOperationalInfo.h
hist_file_dump.d
d
Definition: hist_file_dump.py:137
skel.it
it
Definition: skel.GENtoEVGEN.py:396
athena.value
value
Definition: athena.py:124
operator==
bool operator==(const TrigOperationalInfo &a, const TrigOperationalInfo &b)
Definition: TrigOperationalInfo.cxx:76
TrigOperationalInfo::TrigOperationalInfo
TrigOperationalInfo()
Definition: TrigOperationalInfo.cxx:10
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
python.Bindings.values
values
Definition: Control/AthenaPython/python/Bindings.py:805
TrigOperationalInfo::getValues
const std::vector< float > & getValues() const
Definition: TrigOperationalInfo.cxx:45
str
std::string str(const TrigOperationalInfo &d)
Definition: TrigOperationalInfo.cxx:57
lumiFormat.i
int i
Definition: lumiFormat.py:85
TrigOperationalInfo::m_infoName
std::vector< std::string > m_infoName
Definition: TrigOperationalInfo.h:42
TrigOperationalInfo::updateAtLocation
void updateAtLocation(unsigned int location, float value)
Definition: TrigOperationalInfo.cxx:49
operator<<
MsgStream & operator<<(MsgStream &m, const TrigOperationalInfo &d)
Definition: TrigOperationalInfo.cxx:70
TrigOperationalInfo::infos
std::pair< std::vector< std::string >, std::vector< float > > infos() const
Definition: TrigOperationalInfo.cxx:37
TrigOperationalInfo::set
void set(const std::string &name, float value)
Definition: TrigOperationalInfo.cxx:31
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
TrigOperationalInfo::defined
unsigned int defined(const std::string &name) const
Definition: TrigOperationalInfo.cxx:21
a
TList * a
Definition: liststreamerinfos.cxx:10
TrigOperationalInfo
This class defined generic object to store operational info available during triggering online i....
Definition: TrigOperationalInfo.h:27
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
diff
void diff(const TrigOperationalInfo &a, const TrigOperationalInfo &b, std::map< std::string, double > &variableChange)
Definition: TrigOperationalInfo.cxx:90
TrigOperationalInfo::getKeys
const std::vector< std::string > & getKeys() const
Definition: TrigOperationalInfo.cxx:41
TrigOperationalInfo::m_infoValue
std::vector< float > m_infoValue
Definition: TrigOperationalInfo.h:43