Fork me on GitHub

Changeset 251 in svn for trunk


Ignore:
Timestamp:
Feb 7, 2009, 4:44:02 PM (16 years ago)
Author:
severine ovyn
Message:

add progress bar

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Delphes.cpp

    r249 r251  
    3535#include <vector>
    3636#include <iostream>
     37
     38#include "Utilities/ExRootAnalysis/interface/ExRootProgressBar.h"
    3739
    3840using namespace std;
     
    317319       << right << setw(2) <<"**"<<endl;
    318320
     321  ExRootProgressBar *Progress = new ExRootProgressBar(allEntries);
     322
    319323  loopwatch.Start();
    320324
     
    322326  for(entry = 0; entry < allEntries; ++entry)
    323327    {
     328      Progress->Update(entry);
    324329      TLorentzVector PTmis(0,0,0,0);
    325330      treeReader->ReadEntry(entry);
     
    628633  delete treeReader;
    629634  delete DET;
    630   delete TRIGT;
     635//  delete TRIGT;
    631636  delete TRACP;
    632637  delete JETRUN;
  • trunk/Utilities/ExRootAnalysis/src/ExRootProgressBar.cc

    r220 r251  
    44 *  Class showing progress bar
    55 *
    6  *  $Date: 2009-02-02 11:32:01 $
    7  *  $Revision: 1.2 $
     6 *  $Date: 2009-02-07 15:44:02 $
     7 *  $Revision: 1.3 $
    88 *
    99 *
     
    1515#include "TSystem.h"
    1616#include <cstdio>
     17#include <iostream>
    1718
    1819using namespace std;
     
    3132ExRootProgressBar::~ExRootProgressBar()
    3233{
    33   if(fBar) delete[] fBar;
     34   if(fBar) delete[] fBar;
    3435}
    3536
     
    4041  ULong_t time = gSystem->Now();
    4142
    42   if(time < fTime + 1000 && entry < fEntries - 1) return;
     43  if(time < fTime + 500 && entry < fEntries - 1) return;
    4344
    4445  fTime = time;
     
    4849  if(hashes > fHashes)
    4950  {
    50     memset(fBar + fHashes, '#', hashes - fHashes);
     51    memset(fBar + fHashes, '$', hashes - fHashes);
    5152    fHashes = hashes;
    5253  }
     54 float frac=(entry + 1.0)/fEntries*100.0;
     55 if(frac<10)   fprintf(stdout, "**         [%s] %.2f%% processed             **\r", fBar,(entry + 1.0)/fEntries*100.0);
     56 if(frac==100) fprintf(stdout, "**         [%s] %.2f%% processed           **\r", fBar,(entry + 1.0)/fEntries*100.0);
     57 else          fprintf(stdout, "**         [%s] %.2f%% processed            **\r", fBar,(entry + 1.0)/fEntries*100.0);
     58  fflush(stdout);
    5359
    54 /*
    55   cerr << "[" << fBar << "] (";
    56   cerr.setf(ios::fixed);
    57   cerr.precision(2);
    58   cerr << (entry + 1.0)/fEntries*100.0 << "%) : ";
    59   cerr << entry + 1 << "/" << fEntries;
    60   cerr << " events processed\r" << flush;
    61 */
    62 
    63   fprintf(stderr, "[%s] (%.2f%%) : %lli/%lli entries processed\r", fBar,
    64           (entry + 1.0)/fEntries*100.0, entry + 1, fEntries);
    65   fflush(stderr);
     60  if(entry+1==fEntries)
     61    {
     62       char temp[500];
     63       sprintf(temp, "**         [%s] %.2f%% processed ", fBar,(entry + 1.0)/fEntries*100.0);
     64       string mystringName(temp);
     65       cout << mystringName <<endl;
     66    }
    6667}
    6768
Note: See TracChangeset for help on using the changeset viewer.