ATLAS Offline Software
Loading...
Searching...
No Matches
DebugInfoCollector Class Reference

#include <DebugInfoCollector.h>

Inheritance diagram for DebugInfoCollector:
Collaboration diagram for DebugInfoCollector:

Public Member Functions

 DebugInfoCollector (const std::string &name="Unknown", bool byTime=true)
 ~DebugInfoCollector ()
virtual void collect (const std::string &, const std::string &) override
virtual std::string toString () const override
virtual void write () const override

Private Member Functions

std::string toStringByMsgKey () const
std::string toStringByTime () const

Private Attributes

std::map< std::string, std::vector< std::pair< double, std::string > > > m_info
std::string m_name
bool m_byTime
JetTrigTimer m_timer

Detailed Description

Definition at line 13 of file DebugInfoCollector.h.

Constructor & Destructor Documentation

◆ DebugInfoCollector()

DebugInfoCollector::DebugInfoCollector ( const std::string & name = "Unknown",
bool byTime = true )

Definition at line 10 of file DebugInfoCollector.cxx.

11 :
12 m_name(name),
13 m_byTime(byTime),
14 m_timer(false) // false: units are us
15{
16 m_timer.start();
17}

◆ ~DebugInfoCollector()

DebugInfoCollector::~DebugInfoCollector ( )

Definition at line 19 of file DebugInfoCollector.cxx.

virtual void write() const override

Member Function Documentation

◆ collect()

void DebugInfoCollector::collect ( const std::string & key,
const std::string & info )
overridevirtual

Implements ITrigJetHypoInfoCollector.

Definition at line 21 of file DebugInfoCollector.cxx.

22 {
23 m_info[key].emplace_back(m_timer.elapsed_to_now(), info);
24}
std::map< std::string, std::vector< std::pair< double, std::string > > > m_info

◆ toString()

std::string DebugInfoCollector::toString ( ) const
overridevirtual

Implements ITrigJetHypoInfoCollector.

Definition at line 70 of file DebugInfoCollector.cxx.

70 {
72}
std::string toStringByMsgKey() const
std::string toStringByTime() const

◆ toStringByMsgKey()

std::string DebugInfoCollector::toStringByMsgKey ( ) const
private

Definition at line 26 of file DebugInfoCollector.cxx.

26 {
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}
static Double_t ss

◆ toStringByTime()

std::string DebugInfoCollector::toStringByTime ( ) const
private

Definition at line 44 of file DebugInfoCollector.cxx.

44 {
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}

◆ write()

void DebugInfoCollector::write ( ) const
overridevirtual

Implements ITrigJetHypoInfoCollector.

Definition at line 75 of file DebugInfoCollector.cxx.

75 {
76 auto report = this->toString();
77 std::ofstream out(m_name+".log");
78 out << report;
79 out.close();
80}
virtual std::string toString() const override
list report
Definition checkTP.py:125

Member Data Documentation

◆ m_byTime

bool DebugInfoCollector::m_byTime
private

Definition at line 33 of file DebugInfoCollector.h.

◆ m_info

std::map<std::string, std::vector<std::pair<double, std::string> > > DebugInfoCollector::m_info
private

Definition at line 31 of file DebugInfoCollector.h.

◆ m_name

std::string DebugInfoCollector::m_name
private

Definition at line 32 of file DebugInfoCollector.h.

◆ m_timer

JetTrigTimer DebugInfoCollector::m_timer
private

Definition at line 35 of file DebugInfoCollector.h.


The documentation for this class was generated from the following files: