CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EventProgress.cc
Go to the documentation of this file.
1 #include <time.h>
2 
3 #include <iostream>
4 #include <iomanip>
5 #include <limits>
6 #include <cmath>
7 
8 #include "EventProgress.h"
9 
11  nEvents(0), startTime(time(NULL)), lastUpdate(0), displayWidth(0)
12 {
13 }
14 
15 EventProgress::EventProgress(unsigned long _nEvents) :
16  nEvents(_nEvents), startTime(time(NULL)), lastUpdate(0),
17  displayWidth(int(std::log(nEvents + 0.5) / M_LN10 + 1))
18 {
19 }
20 
22 {
23  std::cout << " \r" << std::flush;
24 }
25 
26 void EventProgress::update(unsigned long event)
27 {
28  time_t currentTime = time(0);
29  if (currentTime == lastUpdate)
30  return;
31 
32  lastUpdate = currentTime;
33 
34  if (displayWidth)
35  std::cout << "Event " << std::setw(displayWidth) << event;
36  else
37  std::cout << "Event " << event;
38 
39  if (nEvents) {
40  unsigned long eta = (event >= 10) ? ((currentTime - startTime) * (nEvents - event) / event)
42 
43  std::cout << " (" << std::setw(2) << (event * 100 / nEvents) << "%), ETA ";
44  if (eta >= 6000)
45  std::cout << "##:##\r";
46  else
47  std::cout << std::setw(2) << (eta / 60) << ":"
48  << std::setfill('0') << std::setw(2) << (eta % 60);
49  }
50 
51  std::cout << std::setfill(' ')
52  << std::resetiosflags(std::ios::fixed)
53  << std::resetiosflags(std::ios::scientific)
54  << std::resetiosflags(std::ios::floatfield)
55  << std::setprecision(8)
56  << "\r" << std::flush;
57 }
void update(unsigned long event)
unsigned long nEvents
Definition: EventProgress.h:15
#define NULL
Definition: scimark2.h:8
T eta() const
unsigned int displayWidth
Definition: EventProgress.h:18
const T & max(const T &a, const T &b)
time_t startTime
Definition: EventProgress.h:16
time_t lastUpdate
Definition: EventProgress.h:17
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
tuple cout
Definition: gather_cfg.py:121
UInt_t nEvents
Definition: hcalCalib.cc:43