ATLAS Offline Software
Loading...
Searching...
No Matches
BasicDataCollector.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include <algorithm>
8#include <sstream>
9
10namespace GlobalSim {
11
12 using namespace std::chrono;
13
15 m_t0{high_resolution_clock::now()}{
16 }
17
18 void BasicDataCollector::collect(const IAlgTool& tool,
19 const std::string& msg){
20 const auto& label = tool.name();
21 auto iter =
22 std::find_if(m_msgs.begin(),
23 m_msgs.end(),
24 [&label](const std::pair<std::string,
25 std::vector<std::string>>& p){
26 return label == p.first;
27 });
28 auto d = high_resolution_clock::now() - m_t0;
29
30 auto ss = std::stringstream();
31 ss << duration_cast<microseconds>(d).count() << " (us): " << msg;
32
33 if (iter == m_msgs.cend()){
34 m_msgs.push_back(std::pair(label, std::vector<std::string>{ss.str()}));
35 } else {
36 (iter->second).push_back(ss.str());
37 }
38 }
39
40
41 std::string BasicDataCollector::to_string() const{
42 auto result = std::string();
43 for (const auto& p : m_msgs){
44 result += p.first + '\n';;
45 for (const auto& m : p.second){
46 result += " " + m + '\n';
47 }
48 }
49 return result;
50 }
51
52 std::ostream& operator << (std::ostream& os, const BasicDataCollector& bdc){
53 os << bdc.to_string();
54 return os;
55 }
56}
static Double_t ss
virtual void collect(const IAlgTool &, const std::string &msg)
std::vector< std::pair< std::string, std::vector< std::string > > > m_msgs
std::chrono::high_resolution_clock::time_point m_t0
virtual std::string to_string() const
std::string label(const std::string &format, int i)
Definition label.h:19
AlgTool to read in LArStripNeighborhoods, and run the BDT Algorithm.
std::ostream & operator<<(std::ostream &os, const BasicDataCollector &bdc)
MsgStream & msg
Definition testRead.cxx:32