ATLAS Offline Software
DebugInfoCollector.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "./DebugInfoCollector.h"
6 #include <sstream>
7 #include <fstream>
8 #include <cmath>
9 
11  bool byTime):
12  m_name(name),
13  m_byTime(byTime),
14  m_timer(false) // false: units are us
15 {
16  m_timer.start();
17 }
18 
20 
21 void DebugInfoCollector::collect(const std::string& key,
22  const std::string& info){
23  m_info[key].emplace_back(m_timer.elapsed_to_now(), info);
24 }
25 
27  /* print out messages in msg key order */
28 
29  std::stringstream ss;
30  ss << "DEBUGInfoCollector: "
31  << m_name << " no of msgs: " << m_info.size() << "\n\n";
32 
33  std::size_t msg_i {0};
34  for(const auto& i: m_info){
35  ss << "msg " << msg_i << ": " << i.first << '\n';
36  ++msg_i;
37  for(const auto& m : i.second){
38  // msg time followe by msg
39  ss << int(m.first) << " " << m.second << '\n';}
40  }
41  return ss.str();
42 }
43 
45  /* print out messages in time order */
46 
47  std::map<unsigned long, std::string> by_time;
48 
49  for(const auto& p : m_info){
50  for(const auto& tm : p.second){
51  // tm.first = time from vector of (time, msg)
52  // p.first = msg key
53  // tm.second = msg at time tm.first
54 
55  auto timestamp = static_cast<unsigned long>(tm.first);
56  by_time[timestamp] = p.first + " " + tm.second;
57  }
58  }
59 
60  std::stringstream ss;
61  ss << "DEBUGInfoCollector: "
62  << m_name << " no of msgs: " << m_info.size() << "\n\n";
63 
64  for(const auto& i: by_time){
65  ss << i.first << " " << i.second << '\n';
66  }
67  return ss.str();
68 }
69 
70 std::string DebugInfoCollector::toString() const {
72 }
73 
74 
76  auto report = this->toString();
77  std::ofstream out(m_name+".log");
78  out << report;
79  out.close();
80 }
81 
grepfile.info
info
Definition: grepfile.py:38
DebugInfoCollector::toString
virtual std::string toString() const override
Definition: DebugInfoCollector.cxx:70
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
DebugInfoCollector::write
virtual void write() const override
Definition: DebugInfoCollector.cxx:75
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
DebugInfoCollector::m_timer
JetTrigTimer m_timer
Definition: DebugInfoCollector.h:35
DebugInfoCollector::collect
virtual void collect(const std::string &, const std::string &) override
Definition: DebugInfoCollector.cxx:21
DebugInfoCollector::m_info
std::map< std::string, std::vector< std::pair< double, std::string > > > m_info
Definition: DebugInfoCollector.h:31
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
checkTP.report
report
Definition: checkTP.py:127
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
DebugInfoCollector::~DebugInfoCollector
~DebugInfoCollector()
Definition: DebugInfoCollector.cxx:19
DebugInfoCollector::toStringByTime
std::string toStringByTime() const
Definition: DebugInfoCollector.cxx:44
lumiFormat.i
int i
Definition: lumiFormat.py:85
DebugInfoCollector.h
JetTrigTimer::elapsed_to_now
double elapsed_to_now()
Definition: JetTrigTimer.cxx:74
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
DebugInfoCollector::toStringByMsgKey
std::string toStringByMsgKey() const
Definition: DebugInfoCollector.cxx:26
DebugInfoCollector::m_name
std::string m_name
Definition: DebugInfoCollector.h:32
DebugInfoCollector::DebugInfoCollector
DebugInfoCollector(const std::string &name="Unknown", bool byTime=true)
Definition: DebugInfoCollector.cxx:10
JetTrigTimer::start
void start()
Definition: JetTrigTimer.cxx:15
DebugInfoCollector::m_byTime
bool m_byTime
Definition: DebugInfoCollector.h:33
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37