CMS 3D CMS Logo

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() [1/3]

RooGKCounter::RooGKCounter ( )

Definition at line 12 of file RooGKCounter.cc.

12 { init(); }

References init().

◆ RooGKCounter() [2/3]

RooGKCounter::RooGKCounter ( const char *  message)

Definition at line 14 of file RooGKCounter.cc.

14  {
15  init();
16  _message = message;
17  if (_message.length() == 0)
18  printCount = false;
19 }

References _message, init(), and printCount.

◆ RooGKCounter() [3/3]

RooGKCounter::RooGKCounter ( unsigned long int  theFirst,
unsigned long int  theDivider 
)

Definition at line 21 of file RooGKCounter.cc.

21  {
22  init();
23  _count = theFirst;
24  _firstCount = theFirst;
25  _divider = theDivider;
26  printCount = true;
27 }

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

◆ ~RooGKCounter()

RooGKCounter::~RooGKCounter ( )

Definition at line 99 of file RooGKCounter.cc.

99 {}

Member Function Documentation

◆ count()

void RooGKCounter::count ( void  )

Definition at line 54 of file RooGKCounter.cc.

54  {
55  _count++;
56 
57  double _number;
58  double _freq;
59  double _limit = 1. / (double)_divider;
60 
61  _number = (double)_count;
62  _freq = (double)_divider;
63 
64  if (firstCountEntry) {
65  if (printCount)
66  std::cout << "Counter is on:" << std::endl;
67  firstCountEntry = false;
68  firstTickTime = time(nullptr);
69  }
70 
71  if (printCount) {
72  if (fmod(_number, _freq) < _limit) {
73  double averageTimeSinceFirstTick = 0.0;
74  if (_count > _firstCount) {
75  averageTimeSinceFirstTick = (time(nullptr) - firstTickTime) / (double)(_count - _firstCount);
76  }
77  if (!_newLine) {
78  std::cout << char(13) << _message.c_str() << _count;
79  if (_count > _firstCount)
80  std::cout << ", average time per count, sec: " << averageTimeSinceFirstTick;
81  fflush(stdout);
82  } else {
83  std::cout << _message.c_str() << _count;
84  if (_count > _firstCount)
85  std::cout << ", average time per count, sec: " << averageTimeSinceFirstTick;
86  std::cout << std::endl;
87  }
88  lastPrintTime = time(nullptr);
89  }
90  }
91 
92  lastTickTime = time(nullptr);
93 }

References _count, _divider, _firstCount, _message, _newLine, gather_cfg::cout, firstCountEntry, firstTickTime, lastPrintTime, lastTickTime, printCount, mps_setup::stdout, and ntuplemaker::time.

Referenced by HcalLutManager::getCompressionLutXmlFromAsciiMaster(), HcalLutManager::getCompressionLutXmlFromCoder(), HcalLutManager::getHEFineGrainLUTs(), HcalQIEManager::getHfQieTable(), HcalLutManager::getLinearizationLutXmlFromAsciiMasterEmap(), HcalLutManager::getLinearizationLutXmlFromAsciiMasterEmap_new(), HcalLutManager::getLinearizationLutXmlFromCoder(), HcalLutManager::getLinearizationLutXmlFromCoderEmap(), HcalLutManager::getLutXmlFromAsciiMaster(), HcalLutManager::getMasks(), HcalQIEManager::getTableFromDb(), and HcalLutManager::getZdcLutXml().

◆ getCount()

unsigned long int RooGKCounter::getCount ( void  )

◆ increment()

void RooGKCounter::increment ( long int  _incr)

Definition at line 97 of file RooGKCounter.cc.

97 { _count += _incr; }

References _count.

◆ init()

void RooGKCounter::init ( void  )
private

Definition at line 39 of file RooGKCounter.cc.

39  {
40  _count = 0;
41  _firstCount = 0;
42  _divider = 1;
43  printCount = false;
44  firstCountEntry = true;
45  _message = "processing entry #";
46  _newLine = true;
47 
48  initTime = time(nullptr);
49  firstTickTime = 1;
50  lastTickTime = 1;
51  lastPrintTime = 1;
52 }

References _count, _divider, _firstCount, _message, _newLine, firstCountEntry, firstTickTime, initTime, lastPrintTime, lastTickTime, printCount, and ntuplemaker::time.

Referenced by RooGKCounter().

◆ setCounter()

void RooGKCounter::setCounter ( unsigned long int  theCount)

Definition at line 29 of file RooGKCounter.cc.

29 { _count = theCount; }

References _count.

◆ setDivider()

void RooGKCounter::setDivider ( unsigned int  theDivider)

Definition at line 31 of file RooGKCounter.cc.

31 { _divider = theDivider; }

References _divider.

◆ setMessage()

void RooGKCounter::setMessage ( const char *  message)

Definition at line 37 of file RooGKCounter.cc.

37 { _message = message; }

References _message.

◆ setNewLine()

void RooGKCounter::setNewLine ( bool  newLine)

Definition at line 35 of file RooGKCounter.cc.

35 { _newLine = newLine; }

References _newLine.

◆ setPrintCount()

void RooGKCounter::setPrintCount ( bool  _printCount)

Definition at line 33 of file RooGKCounter.cc.

33 { printCount = _printCount; }

References printCount.

Member Data Documentation

◆ _count

unsigned long int RooGKCounter::_count
private

Definition at line 27 of file RooGKCounter.h.

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

◆ _divider

unsigned int RooGKCounter::_divider
private

Definition at line 29 of file RooGKCounter.h.

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

◆ _firstCount

unsigned long int RooGKCounter::_firstCount
private

Definition at line 28 of file RooGKCounter.h.

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

◆ _message

std::string RooGKCounter::_message
private

Definition at line 32 of file RooGKCounter.h.

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

◆ _newLine

bool RooGKCounter::_newLine
private

Definition at line 33 of file RooGKCounter.h.

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

◆ firstCountEntry

bool RooGKCounter::firstCountEntry
private

Definition at line 31 of file RooGKCounter.h.

Referenced by count(), and init().

◆ firstTickTime

time_t RooGKCounter::firstTickTime
private

Definition at line 35 of file RooGKCounter.h.

Referenced by count(), and init().

◆ initTime

time_t RooGKCounter::initTime
private

Definition at line 35 of file RooGKCounter.h.

Referenced by init().

◆ lastPrintTime

time_t RooGKCounter::lastPrintTime
private

Definition at line 35 of file RooGKCounter.h.

Referenced by count(), and init().

◆ lastTickTime

time_t RooGKCounter::lastTickTime
private

Definition at line 35 of file RooGKCounter.h.

Referenced by count(), and init().

◆ printCount

bool RooGKCounter::printCount
private

Definition at line 30 of file RooGKCounter.h.

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

RooGKCounter::firstCountEntry
bool firstCountEntry
Definition: RooGKCounter.h:31
gather_cfg.cout
cout
Definition: gather_cfg.py:144
RooGKCounter::printCount
bool printCount
Definition: RooGKCounter.h:30
RooGKCounter::firstTickTime
time_t firstTickTime
Definition: RooGKCounter.h:35
RooGKCounter::_message
std::string _message
Definition: RooGKCounter.h:32
RooGKCounter::init
void init(void)
Definition: RooGKCounter.cc:39
RooGKCounter::lastTickTime
time_t lastTickTime
Definition: RooGKCounter.h:35
RooGKCounter::lastPrintTime
time_t lastPrintTime
Definition: RooGKCounter.h:35
RooGKCounter::_divider
unsigned int _divider
Definition: RooGKCounter.h:29
mps_setup.stdout
stdout
Definition: mps_setup.py:250
RooGKCounter::initTime
time_t initTime
Definition: RooGKCounter.h:35
RooGKCounter::_newLine
bool _newLine
Definition: RooGKCounter.h:33
RooGKCounter::_firstCount
unsigned long int _firstCount
Definition: RooGKCounter.h:28
ntuplemaker.time
time
Definition: ntuplemaker.py:310
RooGKCounter::_count
unsigned long int _count
Definition: RooGKCounter.h:27