ATLAS Offline Software
Loading...
Searching...
No Matches
ShowerLib::ShowerLibStatistics Class Reference

#include <ShowerLibStatistics.h>

Collaboration diagram for ShowerLib::ShowerLibStatistics:

Public Member Functions

 ShowerLibStatistics (const std::map< int, std::string > &bincaptions, const std::map< int, int > &binsizes)
void recordShowerLibUse (int binkey)
const std::string statistics ()

Private Attributes

int m_counter
std::map< int, int > m_calls
std::map< int, std::string > m_binstrings
std::map< int, int > m_binsizes

Detailed Description

Definition at line 20 of file ShowerLibStatistics.h.

Constructor & Destructor Documentation

◆ ShowerLibStatistics()

ShowerLib::ShowerLibStatistics::ShowerLibStatistics ( const std::map< int, std::string > & bincaptions,
const std::map< int, int > & binsizes )

Definition at line 18 of file ShowerLibStatistics.cxx.

19 : m_counter(0),
20 m_binstrings(bincaptions),
21 m_binsizes(binsizes)
22{
23 for(std::map<int,int>::const_iterator it = m_binsizes.begin(); it != m_binsizes.end(); ++it)
24 m_calls[(*it).first] = 0;
25}
std::map< int, std::string > m_binstrings

Member Function Documentation

◆ recordShowerLibUse()

void ShowerLib::ShowerLibStatistics::recordShowerLibUse ( int binkey)

Definition at line 27 of file ShowerLibStatistics.cxx.

28{
29 m_counter++;
30 m_calls[binkey] += 1;
31}

◆ statistics()

const std::string ShowerLib::ShowerLibStatistics::statistics ( )

Definition at line 33 of file ShowerLibStatistics.cxx.

34{
35 std::stringstream out;
36 out << std::fixed << std::setprecision(2);
37 out << "Number of bins: " << m_binsizes.size() << std::endl;
38 out << "Bin Statistics: " << std::endl;
39 float maxuse = 0;
40 float minuse = -1;
41 int totnum = 0;
42 for(std::map<int,int>::const_iterator it = m_binsizes.begin(); it != m_binsizes.end();++it) {
43 totnum += (*it).second;
44 int curcalls = m_calls.at((*it).first);
45 int curlen = (*it).second;
46 std::string name = m_binstrings.at((*it).first);
47 int use = 0;
48 if (curlen >0) {
49 use = 100 * curcalls/curlen;
50 }
51 if (maxuse < use) maxuse = use;
52 if (minuse == -1) minuse = use;
53 else if (minuse > use) minuse = use;
54
55 out << name << " size " << std::setw(7) << curlen << " / calls " << std::setw(9) << curcalls << " ("<< std::setw(6) << use << "%)" << std::endl;
56 }
57
58 if (totnum == 0) { //i don't believe there ever will be a situation when we'll ask for a statistics for an empty lib, but for coverity to be quiet let it be here
59 return out.str();
60 }
61
62 out << "Total: size " << std::setw(6) << totnum << " / calls " << std::setw(9) << m_counter << " (min " << minuse << "% av " << (100 * m_counter/totnum) << "% max " << maxuse << "%)" << std::endl;
63
64 return out.str();
65}

Member Data Documentation

◆ m_binsizes

std::map<int,int> ShowerLib::ShowerLibStatistics::m_binsizes
private

Definition at line 31 of file ShowerLibStatistics.h.

◆ m_binstrings

std::map<int,std::string> ShowerLib::ShowerLibStatistics::m_binstrings
private

Definition at line 30 of file ShowerLibStatistics.h.

◆ m_calls

std::map<int,int> ShowerLib::ShowerLibStatistics::m_calls
private

Definition at line 29 of file ShowerLibStatistics.h.

◆ m_counter

int ShowerLib::ShowerLibStatistics::m_counter
private

Definition at line 28 of file ShowerLibStatistics.h.


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