Loading [MathJax]/extensions/tex2jax.js
hej
is hosted by
Hepforge
,
IPPP Durham
HEJ
2.3.0
High energy resummation for hadron colliders
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
z
Functions
a
c
d
f
g
h
i
j
l
m
n
o
p
r
s
t
Variables
Typedefs
Enumerations
Enumerator
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
s
t
u
w
z
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
z
~
Functions
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
z
~
Variables
a
b
c
d
e
f
h
i
j
l
m
n
o
p
r
s
t
u
v
w
Typedefs
Related Functions
Files
File List
File Members
All
Macros
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
include
HEJ
ProgressBar.hh
Go to the documentation of this file.
1
8
#pragma once
9
10
#include <algorithm>
11
#include <functional>
12
#include <ostream>
13
#include <stdexcept>
14
15
namespace
HEJ
{
16
18
template
<
typename
T>
19
class
ProgressBar
{
20
public
:
22
28
ProgressBar
(std::ostream &
out
, T max) :
29
out_{
out
}, max_{max}
30
{
31
if
(max < 0) {
32
throw
std::invalid_argument{
33
"Maximum in progress bar has to be positive"
34
};
35
}
36
if
(max != 0) {
37
print_bar();
38
}
39
}
40
42
49
ProgressBar
&
increment
(T count) {
50
counter_ += count;
51
update_progress();
52
return
*
this
;
53
}
54
56
61
ProgressBar
&
operator++
() {
62
++counter_;
63
update_progress();
64
return
*
this
;
65
}
66
67
private
:
68
void
update_progress() {
69
counter_ = std::min(counter_, max_);
70
const
int
ndots = (100*counter_)/max_;
71
const
int
new_dots = ndots - ndots_;
72
if
(new_dots > 0) {
73
for
(
int
dot
= 0;
dot
< new_dots; ++
dot
) out_.get() <<
'.'
;
74
out_.get().flush();
75
ndots_ = ndots;
76
}
77
}
78
79
void
print_bar()
const
{
80
out_.get() <<
"0% "
;
81
for
(
int
i = 10; i <= 100; i+= 10){
82
out_.get() <<
" "
+
std::to_string
(i) +
"%"
;
83
}
84
out_.get() <<
"\n|"
;
85
for
(
int
i = 10; i <= 100; i+= 10){
86
out_.get() <<
"---------|"
;
87
}
88
out_.get() <<
'\n'
;
89
}
90
91
std::reference_wrapper<std::ostream> out_;
92
T counter_ = 0;
93
T ndots_ = 0;
94
T max_;
95
};
96
}
// namespace HEJ
HEJ::ProgressBar
Class representing (and printing) a progress bar.
Definition:
ProgressBar.hh:19
HEJ::ProgressBar::operator++
ProgressBar & operator++()
Increase progress by one unit.
Definition:
ProgressBar.hh:61
HEJ::ProgressBar::increment
ProgressBar & increment(T count)
Increment progress.
Definition:
ProgressBar.hh:49
HEJ::ProgressBar::ProgressBar
ProgressBar(std::ostream &out, T max)
Constructor.
Definition:
ProgressBar.hh:28
HEJ::detail_HepMC::status_codes::out
@ out
Final outgoing.
Definition:
HepMCInterface_common.hh:24
HEJ
Main HEJ 2 Namespace.
Definition:
mainpage.dox:1
HEJ::to_string
std::string to_string(Event const &ev)
HEJ::dot
auto dot(CLHEP::HepLorentzVector const &pi, CLHEP::HepLorentzVector const &pj)
"dot" product
Definition:
LorentzVector.hh:20
Generated by
1.9.1