CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 { init(); }
void init(void)
Definition: RooGKCounter.cc:39
RooGKCounter::RooGKCounter ( const char *  message)

Definition at line 14 of file RooGKCounter.cc.

References _message, init(), and printCount.

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

Definition at line 21 of file RooGKCounter.cc.

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

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

Definition at line 99 of file RooGKCounter.cc.

99 {}

Member Function Documentation

void RooGKCounter::count ( void  )

Definition at line 54 of file RooGKCounter.cc.

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

Referenced by HcalChannelIterator::addListFromLmapAscii(), HcalLutManager::getCompressionLutXmlFromAsciiMaster(), HcalLutManager::getCompressionLutXmlFromCoder(), HcalLutManager::getHEFineGrainLUTs(), HcalQIEManager::getHfQieTable(), HcalLutManager::getLinearizationLutXmlFromAsciiMasterEmap(), HcalLutManager::getLinearizationLutXmlFromAsciiMasterEmap_new(), HcalLutManager::getLinearizationLutXmlFromCoder(), HcalLutManager::getLinearizationLutXmlFromCoderEmap(), HcalLutManager::getLutXmlFromAsciiMaster(), HcalLutManager::getMasks(), HcalQIEManager::getTableFromDb(), HcalLutManager::getZdcLutXml(), LMap::impl::read(), and EMap::read_map().

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 }
unsigned int _divider
Definition: RooGKCounter.h:29
unsigned long int _firstCount
Definition: RooGKCounter.h:28
time_t firstTickTime
Definition: RooGKCounter.h:35
bool firstCountEntry
Definition: RooGKCounter.h:31
time_t lastTickTime
Definition: RooGKCounter.h:35
unsigned long int _count
Definition: RooGKCounter.h:27
std::string _message
Definition: RooGKCounter.h:32
tuple cout
Definition: gather_cfg.py:144
time_t lastPrintTime
Definition: RooGKCounter.h:35
unsigned long int RooGKCounter::getCount ( void  )
void RooGKCounter::increment ( long int  _incr)

Definition at line 97 of file RooGKCounter.cc.

References _count.

97 { _count += _incr; }
unsigned long int _count
Definition: RooGKCounter.h:27
void RooGKCounter::init ( void  )
private

Definition at line 39 of file RooGKCounter.cc.

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

Referenced by RooGKCounter().

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 }
unsigned int _divider
Definition: RooGKCounter.h:29
unsigned long int _firstCount
Definition: RooGKCounter.h:28
time_t firstTickTime
Definition: RooGKCounter.h:35
bool firstCountEntry
Definition: RooGKCounter.h:31
time_t lastTickTime
Definition: RooGKCounter.h:35
unsigned long int _count
Definition: RooGKCounter.h:27
std::string _message
Definition: RooGKCounter.h:32
time_t initTime
Definition: RooGKCounter.h:35
time_t lastPrintTime
Definition: RooGKCounter.h:35
void RooGKCounter::setCounter ( unsigned long int  theCount)

Definition at line 29 of file RooGKCounter.cc.

References _count.

29 { _count = theCount; }
unsigned long int _count
Definition: RooGKCounter.h:27
void RooGKCounter::setDivider ( unsigned int  theDivider)

Definition at line 31 of file RooGKCounter.cc.

References _divider.

31 { _divider = theDivider; }
unsigned int _divider
Definition: RooGKCounter.h:29
void RooGKCounter::setMessage ( const char *  message)

Definition at line 37 of file RooGKCounter.cc.

References _message.

37 { _message = message; }
std::string _message
Definition: RooGKCounter.h:32
void RooGKCounter::setNewLine ( bool  newLine)

Definition at line 35 of file RooGKCounter.cc.

References _newLine.

35 { _newLine = newLine; }
void RooGKCounter::setPrintCount ( bool  _printCount)

Definition at line 33 of file RooGKCounter.cc.

References printCount.

33 { printCount = _printCount; }

Member Data Documentation

unsigned long int RooGKCounter::_count
private

Definition at line 27 of file RooGKCounter.h.

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

unsigned int RooGKCounter::_divider
private

Definition at line 29 of file RooGKCounter.h.

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

unsigned long int RooGKCounter::_firstCount
private

Definition at line 28 of file RooGKCounter.h.

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

std::string RooGKCounter::_message
private

Definition at line 32 of file RooGKCounter.h.

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

bool RooGKCounter::_newLine
private

Definition at line 33 of file RooGKCounter.h.

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

bool RooGKCounter::firstCountEntry
private

Definition at line 31 of file RooGKCounter.h.

Referenced by count(), and init().

time_t RooGKCounter::firstTickTime
private

Definition at line 35 of file RooGKCounter.h.

Referenced by count(), and init().

time_t RooGKCounter::initTime
private

Definition at line 35 of file RooGKCounter.h.

Referenced by init().

time_t RooGKCounter::lastPrintTime
private

Definition at line 35 of file RooGKCounter.h.

Referenced by count(), and init().

time_t RooGKCounter::lastTickTime
private

Definition at line 35 of file RooGKCounter.h.

Referenced by count(), and init().

bool RooGKCounter::printCount
private

Definition at line 30 of file RooGKCounter.h.

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