ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigHypothesis
TrigHLTJetHypo
src
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
10
DebugInfoCollector::DebugInfoCollector
(
const
std::string& name,
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
19
DebugInfoCollector::~DebugInfoCollector
(){
DebugInfoCollector::write
();}
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
26
std::string
DebugInfoCollector::toStringByMsgKey
()
const
{
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
44
std::string
DebugInfoCollector::toStringByTime
()
const
{
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
{
71
return
m_byTime
?
toStringByTime
() :
toStringByMsgKey
();
72
}
73
74
75
void
DebugInfoCollector::write
()
const
{
76
auto
report = this->
toString
();
77
std::ofstream out(
m_name
+
".log"
);
78
out << report;
79
out.close();
80
}
81
DebugInfoCollector.h
ss
static Double_t ss
Definition
LArPhysWaveHECTool.cxx:37
DebugInfoCollector::collect
virtual void collect(const std::string &, const std::string &) override
Definition
DebugInfoCollector.cxx:21
DebugInfoCollector::~DebugInfoCollector
~DebugInfoCollector()
Definition
DebugInfoCollector.cxx:19
DebugInfoCollector::m_info
std::map< std::string, std::vector< std::pair< double, std::string > > > m_info
Definition
DebugInfoCollector.h:31
DebugInfoCollector::DebugInfoCollector
DebugInfoCollector(const std::string &name="Unknown", bool byTime=true)
Definition
DebugInfoCollector.cxx:10
DebugInfoCollector::toString
virtual std::string toString() const override
Definition
DebugInfoCollector.cxx:70
DebugInfoCollector::m_name
std::string m_name
Definition
DebugInfoCollector.h:32
DebugInfoCollector::m_byTime
bool m_byTime
Definition
DebugInfoCollector.h:33
DebugInfoCollector::toStringByMsgKey
std::string toStringByMsgKey() const
Definition
DebugInfoCollector.cxx:26
DebugInfoCollector::toStringByTime
std::string toStringByTime() const
Definition
DebugInfoCollector.cxx:44
DebugInfoCollector::m_timer
JetTrigTimer m_timer
Definition
DebugInfoCollector.h:35
DebugInfoCollector::write
virtual void write() const override
Definition
DebugInfoCollector.cxx:75
Generated on
for ATLAS Offline Software by
1.17.0