ATLAS Offline Software
Loading...
Searching...
No Matches
ProgressBar Class Reference

#include <iLumiCalc.h>

Inheritance diagram for ProgressBar:
Collaboration diagram for ProgressBar:

Public Member Functions

 ProgressBar (Int_t, Int_t, const char *prefix="")
 ~ProgressBar ()
void Reset ()
void DrawProgressBar (Int_t)
TString SecToText (Double_t)
Double_t ElapsedSeconds ()
TString GetElapsedTime ()
TString GetLeftTime (Int_t)

Public Attributes

Int_t pbNbins
Int_t Ncounts
TString Prefix

Detailed Description

Definition at line 48 of file iLumiCalc.h.

Constructor & Destructor Documentation

◆ ProgressBar()

ProgressBar::ProgressBar ( Int_t ncounts,
Int_t nbins,
const char * prefix = "" )

Definition at line 68 of file iLumiCalc.h.

69 : pbNbins(nbins), Ncounts(ncounts), Prefix(TString(prefix))
70{
71 Reset();
72}
Int_t Ncounts
Definition iLumiCalc.h:62
Int_t pbNbins
Definition iLumiCalc.h:61
void Reset()
Definition iLumiCalc.h:79
TString Prefix
Definition iLumiCalc.h:63

◆ ~ProgressBar()

ProgressBar::~ProgressBar ( )

Definition at line 75 of file iLumiCalc.h.

76{}

Member Function Documentation

◆ DrawProgressBar()

void ProgressBar::DrawProgressBar ( Int_t i)

Definition at line 134 of file iLumiCalc.h.

135{
136
137 // check for consistency:
138 if (i > Ncounts-1) i = Ncounts-1;
139 if (i < 0 ) i = 0;
140 Int_t ic = Int_t(Float_t(i)/Float_t(Ncounts)*pbNbins);
141
142 std::clog << Prefix << " ";
143
144 // re-print the actual bar
145 std::clog << "[";
146 for (Int_t it = 0; it<ic; it++){
147 std::clog << ">";
148 }
149
150 for (Int_t it = ic+1; it<pbNbins; it++){
151 std::clog << " ";
152 }
153 std::clog << "]";
154
155 // print timing information
156 std::clog << "(" << Int_t((100*(i+1))/Float_t(Ncounts)) << "%"
157 << ", " << "time left: " << this->GetLeftTime( i ) << ") ";
158 std::clog << "\r" << std::flush;
159}
TString GetLeftTime(Int_t)
Definition iLumiCalc.h:100
int ic
Definition grepfile.py:33

◆ ElapsedSeconds()

Double_t ProgressBar::ElapsedSeconds ( )

Definition at line 85 of file iLumiCalc.h.

86{
87 // computes elapsed time in seconds
88 Double_t rt = TStopwatch::RealTime(); TStopwatch::Start( kFALSE );
89 return rt;
90}

◆ GetElapsedTime()

TString ProgressBar::GetElapsedTime ( )

Definition at line 93 of file iLumiCalc.h.

94{
95 // returns string with elapsed time
96 return SecToText( ElapsedSeconds());
97}
Double_t ElapsedSeconds()
Definition iLumiCalc.h:85
TString SecToText(Double_t)
Definition iLumiCalc.h:111

◆ GetLeftTime()

TString ProgressBar::GetLeftTime ( Int_t icounts)

Definition at line 100 of file iLumiCalc.h.

101{
102 // returns pretty string with time left
103 Double_t leftTime = ( icounts <= 0 ? -1 :
104 icounts > Ncounts ? -1 :
105 Double_t(Ncounts - icounts)/Double_t(icounts)*ElapsedSeconds() );
106
107 return SecToText( leftTime );
108}

◆ Reset()

void ProgressBar::Reset ( )

Definition at line 79 of file iLumiCalc.h.

80{
81 TStopwatch::Start( kTRUE );
82}

◆ SecToText()

TString ProgressBar::SecToText ( Double_t seconds)

Definition at line 111 of file iLumiCalc.h.

112{
113
114 TString out = "";
115 if (seconds < 0 ) out = "unknown";
116 else if (seconds <= 300) out = Form( "%i sec", Int_t(seconds) );
117 else {
118 if (seconds > 3600) {
119 Int_t h = Int_t(seconds/3600);
120 if (h <= 1) out = Form( "%i hr : ", h );
121 else out = Form( "%i hrs : ", h );
122
123 seconds = Int_t(seconds)%3600;
124 }
125 Int_t m = Int_t(seconds/60);
126 if (m <= 1) out += Form( "%i min", m );
127 else out += Form( "%i mins", m );
128 }
129
130 return out;
131}

Member Data Documentation

◆ Ncounts

Int_t ProgressBar::Ncounts

Definition at line 62 of file iLumiCalc.h.

◆ pbNbins

Int_t ProgressBar::pbNbins

Definition at line 61 of file iLumiCalc.h.

◆ Prefix

TString ProgressBar::Prefix

Definition at line 63 of file iLumiCalc.h.


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