ATLAS Offline Software
Loading...
Searching...
No Matches
ShowerLibStatistics.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5/*
6 * FCALDistEnergyShowerLibStatistics.cpp
7 *
8 * Created on: Feb 24, 2012
9 * Author: sedov
10 */
11
13#include <sstream>
14#include "G4Track.hh"
15
16namespace ShowerLib {
17
18ShowerLibStatistics::ShowerLibStatistics(const std::map<int,std::string>& bincaptions,
19 const std::map<int,int>& binsizes) : 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}
26
28{
29 m_counter++;
30 m_calls[binkey] += 1;
31}
32
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}
66
67} /* namespace ShowerLib */
std::map< int, std::string > m_binstrings
ShowerLibStatistics(const std::map< int, std::string > &bincaptions, const std::map< int, int > &binsizes)
Namespace for the ShowerLib related classes.
Definition StepInfo.h:17