ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
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 }

◆ ~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 }

◆ 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 }

◆ 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:
ProgressBar::ElapsedSeconds
Double_t ElapsedSeconds()
Definition: iLumiCalc.h:85
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
ProgressBar::Ncounts
Int_t Ncounts
Definition: iLumiCalc.h:62
FullCPAlgorithmsTest_eljob.flush
flush
Definition: FullCPAlgorithmsTest_eljob.py:168
skel.it
it
Definition: skel.GENtoEVGEN.py:423
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
ProgressBar::Prefix
TString Prefix
Definition: iLumiCalc.h:63
ProgressBar::Reset
void Reset()
Definition: iLumiCalc.h:79
SCT_CalibAlgs::nbins
@ nbins
Definition: SCT_CalibNumbers.h:10
lumiFormat.i
int i
Definition: lumiFormat.py:92
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
python.LArCalib_HVCorrConfig.seconds
seconds
Definition: LArCalib_HVCorrConfig.py:86
grepfile.ic
int ic
Definition: grepfile.py:33
ProgressBar::SecToText
TString SecToText(Double_t)
Definition: iLumiCalc.h:111
h
ProgressBar::GetLeftTime
TString GetLeftTime(Int_t)
Definition: iLumiCalc.h:100
ProgressBar::pbNbins
Int_t pbNbins
Definition: iLumiCalc.h:61