CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

RooGKCounter Class Reference

#include <RooGKCounter.h>

List of all members.

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().

                          {
  init();
} 
RooGKCounter::RooGKCounter ( const char *  message)

Definition at line 16 of file RooGKCounter.cc.

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

                                               {
  init();
  _message = message;
  if ( _message . length() == 0 ) printCount = false;
} 
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.

                                                                                    {
  init();
  _count = theFirst;
  _firstCount = theFirst;
  _divider = theDivider;
  printCount = true;
} 
RooGKCounter::~RooGKCounter ( )

Definition at line 122 of file RooGKCounter.cc.

                           {
}

Member Function Documentation

void RooGKCounter::count ( void  )

Definition at line 66 of file RooGKCounter.cc.

References _count, _divider, _firstCount, _message, _newLine, gather_cfg::cout, firstCountEntry, firstTickTime, lastPrintTime, lastTickTime, NULL, printCount, and cond::rpcobgas::time.

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

                              {

  _count++;

  double _number;
  double _freq;
  double _limit = 1./(double)_divider;

  _number = (double)_count;
  _freq = (double)_divider;

  if (firstCountEntry){
    if ( printCount ) std::cout << "Counter is on:" << std::endl;
    firstCountEntry = false;
    firstTickTime = time( NULL );
  }

  if ( printCount ){
    if ( fmod( _number, _freq ) < _limit ){
      double averageTimeSinceLastPrint = 0.0;
      double averageTimeSinceFirstTick = 0.0;
      if ( lastPrintTime > 1 )
        {
          averageTimeSinceLastPrint = ( time( NULL ) - lastPrintTime ) / (double)_divider;
        }
      if ( _count > _firstCount )
        {
          averageTimeSinceFirstTick = ( time( NULL ) - firstTickTime ) / (double)( _count - _firstCount );
        }
      if ( !_newLine )
        {
          std::cout << char(13) << _message . c_str() << _count;
          if ( _count > _firstCount ) std::cout << ", average time per count, sec: " << averageTimeSinceFirstTick;
          fflush(stdout);
        }
      else
        {
          std::cout << _message . c_str() << _count;
          if ( _count > _firstCount ) std::cout << ", average time per count, sec: " << averageTimeSinceFirstTick;
          std::cout << std::endl;
        }
      lastPrintTime = time( NULL );
    }
  }
  
  lastTickTime = time( NULL );
}
unsigned long int RooGKCounter::getCount ( void  )
void RooGKCounter::increment ( long int  _incr)

Definition at line 118 of file RooGKCounter.cc.

References _count.

                                            {
  _count += _incr;
}
void RooGKCounter::init ( void  ) [private]
void RooGKCounter::setCounter ( unsigned long int  theCount)

Definition at line 30 of file RooGKCounter.cc.

References _count.

                                                         {
  _count = theCount;
}
void RooGKCounter::setDivider ( unsigned int  theDivider)

Definition at line 34 of file RooGKCounter.cc.

References _divider.

                                                      {
  _divider = theDivider;
}
void RooGKCounter::setMessage ( const char *  message)

Definition at line 46 of file RooGKCounter.cc.

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

                                                  {
  _message = message;
}
void RooGKCounter::setNewLine ( bool  newLine)

Definition at line 42 of file RooGKCounter.cc.

References _newLine.

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

Definition at line 38 of file RooGKCounter.cc.

References printCount.

                                                  {
  printCount = _printCount;
}

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]

Definition at line 33 of file RooGKCounter.h.

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

bool RooGKCounter::_newLine [private]

Definition at line 34 of file RooGKCounter.h.

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

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().