test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
RooGKCounter Class Reference

#include <RooGKCounter.h>

Public Member Functions

void count (void)
 
unsigned long int getCount (void)
 
void increment (long int _incr)
 
 RooGKCounter ()
 
 RooGKCounter (const char *message)
 
 RooGKCounter (unsigned long int theFirst, unsigned long int theDivider)
 
void setCounter (unsigned long int)
 
void setDivider (unsigned int)
 
void setMessage (const char *)
 
void setNewLine (bool newLine)
 
void setPrintCount (bool _printCount)
 
 ~RooGKCounter ()
 

Private Member Functions

void init (void)
 

Private Attributes

unsigned long int _count
 
unsigned int _divider
 
unsigned long int _firstCount
 
std::string _message
 
bool _newLine
 
bool firstCountEntry
 
time_t firstTickTime
 
time_t initTime
 
time_t lastPrintTime
 
time_t lastTickTime
 
bool printCount
 

Detailed Description

Definition at line 10 of file RooGKCounter.h.

Constructor & Destructor Documentation

RooGKCounter::RooGKCounter ( )

Definition at line 12 of file RooGKCounter.cc.

References init().

12  {
13  init();
14 }
void init(void)
Definition: RooGKCounter.cc:50
RooGKCounter::RooGKCounter ( const char *  message)

Definition at line 16 of file RooGKCounter.cc.

References _message, init(), python.rootplot.argparse::message, and printCount.

16  {
17  init();
18  _message = message;
19  if ( _message . length() == 0 ) printCount = false;
20 }
void init(void)
Definition: RooGKCounter.cc:50
std::string _message
Definition: RooGKCounter.h:33
RooGKCounter::RooGKCounter ( unsigned long int  theFirst,
unsigned long int  theDivider 
)

Definition at line 22 of file RooGKCounter.cc.

References _count, _divider, _firstCount, init(), and printCount.

22  {
23  init();
24  _count = theFirst;
25  _firstCount = theFirst;
26  _divider = theDivider;
27  printCount = true;
28 }
unsigned int _divider
Definition: RooGKCounter.h:30
unsigned long int _firstCount
Definition: RooGKCounter.h:29
unsigned long int _count
Definition: RooGKCounter.h:28
void init(void)
Definition: RooGKCounter.cc:50
RooGKCounter::~RooGKCounter ( )

Definition at line 117 of file RooGKCounter.cc.

117  {
118 }

Member Function Documentation

void RooGKCounter::count ( void  )

Definition at line 66 of file RooGKCounter.cc.

References _count, _divider, _firstCount, _message, _newLine, hitfit::char, gather_cfg::cout, firstCountEntry, firstTickTime, lastPrintTime, lastTickTime, NULL, and printCount.

Referenced by HcalLutManager::getCompressionLutXmlFromAsciiMaster(), HcalLutManager::getCompressionLutXmlFromCoder(), HcalLutManager::getLinearizationLutXmlFromAsciiMasterEmap(), HcalLutManager::getLinearizationLutXmlFromAsciiMasterEmap_new(), HcalLutManager::getLinearizationLutXmlFromCoder(), HcalLutManager::getLinearizationLutXmlFromCoderEmap(), HcalLutManager::getLutXmlFromAsciiMaster(), and HcalLutManager::getZdcLutXml().

66  {
67 
68  _count++;
69 
70  double _number;
71  double _freq;
72  double _limit = 1./(double)_divider;
73 
74  _number = (double)_count;
75  _freq = (double)_divider;
76 
77  if (firstCountEntry){
78  if ( printCount ) std::cout << "Counter is on:" << std::endl;
79  firstCountEntry = false;
80  firstTickTime = time( NULL );
81  }
82 
83  if ( printCount ){
84  if ( fmod( _number, _freq ) < _limit ){
85  double averageTimeSinceFirstTick = 0.0;
86  if ( _count > _firstCount )
87  {
88  averageTimeSinceFirstTick = ( time( NULL ) - firstTickTime ) / (double)( _count - _firstCount );
89  }
90  if ( !_newLine )
91  {
92  std::cout << char(13) << _message . c_str() << _count;
93  if ( _count > _firstCount ) std::cout << ", average time per count, sec: " << averageTimeSinceFirstTick;
94  fflush(stdout);
95  }
96  else
97  {
98  std::cout << _message . c_str() << _count;
99  if ( _count > _firstCount ) std::cout << ", average time per count, sec: " << averageTimeSinceFirstTick;
100  std::cout << std::endl;
101  }
102  lastPrintTime = time( NULL );
103  }
104  }
105 
106  lastTickTime = time( NULL );
107 }
unsigned int _divider
Definition: RooGKCounter.h:30
unsigned long int _firstCount
Definition: RooGKCounter.h:29
#define NULL
Definition: scimark2.h:8
time_t firstTickTime
Definition: RooGKCounter.h:36
bool firstCountEntry
Definition: RooGKCounter.h:32
time_t lastTickTime
Definition: RooGKCounter.h:36
unsigned long int _count
Definition: RooGKCounter.h:28
std::string _message
Definition: RooGKCounter.h:33
tuple cout
Definition: gather_cfg.py:145
time_t lastPrintTime
Definition: RooGKCounter.h:36
unsigned long int RooGKCounter::getCount ( void  )
void RooGKCounter::increment ( long int  _incr)

Definition at line 113 of file RooGKCounter.cc.

References _count.

113  {
114  _count += _incr;
115 }
unsigned long int _count
Definition: RooGKCounter.h:28
void RooGKCounter::init ( void  )
private

Definition at line 50 of file RooGKCounter.cc.

References _count, _divider, _firstCount, _message, _newLine, firstCountEntry, firstTickTime, initTime, lastPrintTime, lastTickTime, NULL, and printCount.

Referenced by RooGKCounter().

50  {
51  _count = 0;
52  _firstCount = 0;
53  _divider = 1;
54  printCount = false;
55  firstCountEntry = true;
56  _message = "processing entry #";
57  _newLine = true;
58 
59  initTime = time( NULL );
60  firstTickTime = 1;
61  lastTickTime = 1;
62  lastPrintTime = 1;
63 
64 }
unsigned int _divider
Definition: RooGKCounter.h:30
unsigned long int _firstCount
Definition: RooGKCounter.h:29
#define NULL
Definition: scimark2.h:8
time_t firstTickTime
Definition: RooGKCounter.h:36
bool firstCountEntry
Definition: RooGKCounter.h:32
time_t lastTickTime
Definition: RooGKCounter.h:36
unsigned long int _count
Definition: RooGKCounter.h:28
std::string _message
Definition: RooGKCounter.h:33
time_t initTime
Definition: RooGKCounter.h:36
time_t lastPrintTime
Definition: RooGKCounter.h:36
void RooGKCounter::setCounter ( unsigned long int  theCount)

Definition at line 30 of file RooGKCounter.cc.

References _count.

30  {
31  _count = theCount;
32 }
unsigned long int _count
Definition: RooGKCounter.h:28
void RooGKCounter::setDivider ( unsigned int  theDivider)

Definition at line 34 of file RooGKCounter.cc.

References _divider.

34  {
35  _divider = theDivider;
36 }
unsigned int _divider
Definition: RooGKCounter.h:30
void RooGKCounter::setMessage ( const char *  message)

Definition at line 46 of file RooGKCounter.cc.

References _message, and python.rootplot.argparse::message.

46  {
47  _message = message;
48 }
std::string _message
Definition: RooGKCounter.h:33
void RooGKCounter::setNewLine ( bool  newLine)

Definition at line 42 of file RooGKCounter.cc.

References _newLine.

42  {
43  _newLine = newLine;
44 }
void RooGKCounter::setPrintCount ( bool  _printCount)

Definition at line 38 of file RooGKCounter.cc.

References printCount.

38  {
39  printCount = _printCount;
40 }

Member Data Documentation

unsigned long int RooGKCounter::_count
private

Definition at line 28 of file RooGKCounter.h.

Referenced by count(), getCount(), increment(), init(), RooGKCounter(), and setCounter().

unsigned int RooGKCounter::_divider
private

Definition at line 30 of file RooGKCounter.h.

Referenced by count(), init(), RooGKCounter(), and setDivider().

unsigned long int RooGKCounter::_firstCount
private

Definition at line 29 of file RooGKCounter.h.

Referenced by count(), init(), and RooGKCounter().

std::string RooGKCounter::_message
private
bool RooGKCounter::_newLine
private

Definition at line 34 of file RooGKCounter.h.

Referenced by count(), init(), and setNewLine().

bool RooGKCounter::firstCountEntry
private

Definition at line 32 of file RooGKCounter.h.

Referenced by count(), and init().

time_t RooGKCounter::firstTickTime
private

Definition at line 36 of file RooGKCounter.h.

Referenced by count(), and init().

time_t RooGKCounter::initTime
private

Definition at line 36 of file RooGKCounter.h.

Referenced by init().

time_t RooGKCounter::lastPrintTime
private

Definition at line 36 of file RooGKCounter.h.

Referenced by count(), and init().

time_t RooGKCounter::lastTickTime
private

Definition at line 36 of file RooGKCounter.h.

Referenced by count(), and init().

bool RooGKCounter::printCount
private

Definition at line 31 of file RooGKCounter.h.

Referenced by count(), init(), RooGKCounter(), and setPrintCount().