source: HiSusy/trunk/Delphes-3.0.0/external/ExRootAnalysis/ExRootProgressBar.cc @ 1

Last change on this file since 1 was 1, checked in by zerwas, 11 years ago

first import of structure, PYTHIA8 and DELPHES

File size: 1.7 KB
Line 
1
2/** \class ExRootProgressBar
3 *
4 *  Class showing progress bar
5 *
6 *  $Date: 2008-06-04 13:57:55 $
7 *  $Revision: 1.1 $
8 *
9 *
10 *  \author P. Demin - UCL, Louvain-la-Neuve
11 *
12 */
13
14#include "ExRootAnalysis/ExRootProgressBar.h"
15
16#include "TSystem.h"
17
18#include <iostream>
19
20#include <string.h>
21#include <stdio.h>
22
23using namespace std;
24
25ExRootProgressBar::ExRootProgressBar(Long64_t entries, Int_t width) :
26  fEntries(entries), fEventCounter(0), fWidth(width), fTime(0), fHashes(0), fBar(0)
27{
28  fBar = new char[width + 1];
29  memset(fBar, '-', width);
30  fBar[width] = 0;
31
32}
33
34//------------------------------------------------------------------------------
35
36ExRootProgressBar::~ExRootProgressBar()
37{
38  if(fBar) delete[] fBar;
39}
40
41//------------------------------------------------------------------------------
42
43void ExRootProgressBar::Update(Long64_t entry, Long64_t eventCounter, Bool_t last)
44{
45  ULong64_t time = gSystem->Now();
46
47  if(time < fTime + 500 && entry < fEntries && !last) return;
48
49  fTime = time;
50
51  if(fEntries > 0)
52  {
53    Int_t hashes = Int_t(Float_t(entry)/fEntries*fWidth);
54
55    if(hashes > fHashes)
56    {
57      memset(fBar + fHashes, '#', hashes - fHashes);
58      fHashes = hashes;
59      fprintf(stderr, "** [%s] (%.2f%%)\r", fBar, Float_t(entry)/fEntries*100.0);
60    }
61  }
62  else
63  {
64    if(eventCounter > fEventCounter)
65    {
66      fEventCounter = eventCounter;
67      fprintf(stderr, "** %lld events processed\r", eventCounter);
68    }
69  }
70
71  fflush(stderr);
72}
73
74//------------------------------------------------------------------------------
75
76void ExRootProgressBar::Finish()
77{
78  fprintf(stderr, "\n");
79  fflush(stderr);
80}
81
82//------------------------------------------------------------------------------
83
Note: See TracBrowser for help on using the repository browser.