ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArG4
LArG4ShowerLib
src
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
12
#include "
LArG4ShowerLib/ShowerLibStatistics.h
"
13
#include <sstream>
14
#include "G4Track.hh"
15
16
namespace
ShowerLib
{
17
18
ShowerLibStatistics::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
27
void
ShowerLibStatistics::recordShowerLibUse
(
int
binkey)
28
{
29
m_counter
++;
30
m_calls
[binkey] += 1;
31
}
32
33
const
std::string
ShowerLibStatistics::statistics
()
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 */
ShowerLibStatistics.h
ShowerLib::ShowerLibStatistics::statistics
const std::string statistics()
Definition
ShowerLibStatistics.cxx:33
ShowerLib::ShowerLibStatistics::m_counter
int m_counter
Definition
ShowerLibStatistics.h:28
ShowerLib::ShowerLibStatistics::recordShowerLibUse
void recordShowerLibUse(int binkey)
Definition
ShowerLibStatistics.cxx:27
ShowerLib::ShowerLibStatistics::m_binsizes
std::map< int, int > m_binsizes
Definition
ShowerLibStatistics.h:31
ShowerLib::ShowerLibStatistics::m_binstrings
std::map< int, std::string > m_binstrings
Definition
ShowerLibStatistics.h:30
ShowerLib::ShowerLibStatistics::ShowerLibStatistics
ShowerLibStatistics(const std::map< int, std::string > &bincaptions, const std::map< int, int > &binsizes)
Definition
ShowerLibStatistics.cxx:18
ShowerLib::ShowerLibStatistics::m_calls
std::map< int, int > m_calls
Definition
ShowerLibStatistics.h:29
ShowerLib
Namespace for the ShowerLib related classes.
Definition
StepInfo.h:17
Generated on
for ATLAS Offline Software by
1.17.0