CMS 3D CMS Logo

RooGKCounter Class Reference

#include <CaloOnlineTools/HcalOnlineDb/interface/RooGKCounter.h>

List of all members.

Public Member Functions

void count (void)
unsigned long int getCount (void)
void increment (long int _incr)
 RooGKCounter (unsigned long int theFirst, unsigned long int theDivider)
 RooGKCounter (const char *message)
 RooGKCounter ()
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
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 11 of file RooGKCounter.h.


Constructor & Destructor Documentation

RooGKCounter::RooGKCounter (  ) 

Definition at line 11 of file RooGKCounter.cc.

References init().

00011                           {
00012   init();
00013 } 

RooGKCounter::RooGKCounter ( const char *  message  ) 

Definition at line 15 of file RooGKCounter.cc.

References _message, init(), and printCount.

00015                                                {
00016   init();
00017   _message = message;
00018   if ( _message . length() == 0 ) printCount = false;
00019 } 

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.

00021                                                                                     {
00022   init();
00023   _count = theFirst;
00024   _firstCount = theFirst;
00025   _divider = theDivider;
00026   printCount = true;
00027 } 

RooGKCounter::~RooGKCounter (  ) 

Definition at line 121 of file RooGKCounter.cc.

00121                            {
00122 }


Member Function Documentation

void RooGKCounter::count ( void   ) 

Definition at line 65 of file RooGKCounter.cc.

References _count, _divider, _firstCount, _message, _newLine, GenMuonPlsPt100GeV_cfg::cout, lat::endl(), firstCountEntry, firstTickTime, lastPrintTime, lastTickTime, NULL, and printCount.

00065                               {
00066 
00067   _count++;
00068 
00069   double _number;
00070   double _freq;
00071   double _limit = 1./(double)_divider;
00072 
00073   _number = (double)_count;
00074   _freq = (double)_divider;
00075 
00076   if (firstCountEntry){
00077     if ( printCount ) cout << "Counter is on:" << endl;
00078     firstCountEntry = false;
00079     firstTickTime = time( NULL );
00080   }
00081 
00082   if ( printCount ){
00083     if ( fmod( _number, _freq ) < _limit ){
00084       double averageTimeSinceLastPrint = 0.0;
00085       double averageTimeSinceFirstTick = 0.0;
00086       if ( lastPrintTime > 1 )
00087         {
00088           averageTimeSinceLastPrint = ( time( NULL ) - lastPrintTime ) / (double)_divider;
00089         }
00090       if ( _count > _firstCount )
00091         {
00092           averageTimeSinceFirstTick = ( time( NULL ) - firstTickTime ) / (double)( _count - _firstCount );
00093         }
00094       if ( !_newLine )
00095         {
00096           cout << char(13) << _message . c_str() << _count;
00097           if ( _count > _firstCount ) cout << ", average time per count, sec: " << averageTimeSinceFirstTick;
00098           fflush(stdout);
00099         }
00100       else
00101         {
00102           cout << _message . c_str() << _count;
00103           if ( _count > _firstCount ) cout << ", average time per count, sec: " << averageTimeSinceFirstTick;
00104           cout << endl;
00105         }
00106       lastPrintTime = time( NULL );
00107     }
00108   }
00109   
00110   lastTickTime = time( NULL );
00111 }

unsigned long int RooGKCounter::getCount ( void   ) 

Definition at line 113 of file RooGKCounter.cc.

References _count.

00113                                               {
00114   return _count;
00115 }

void RooGKCounter::increment ( long int  _incr  ) 

Definition at line 117 of file RooGKCounter.cc.

References _count.

00117                                             {
00118   _count += _incr;
00119 }

void RooGKCounter::init ( void   )  [private]

Definition at line 49 of file RooGKCounter.cc.

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

Referenced by RooGKCounter().

00049                              {
00050   _count = 0;
00051   _firstCount = 0;
00052   _divider = 1;
00053   printCount = false;
00054   firstCountEntry = true;
00055   _message = "processing entry #";
00056   _newLine = true;
00057 
00058   initTime = time( NULL );
00059   firstTickTime = 1;
00060   lastTickTime = 1;
00061   lastPrintTime = 1;
00062 
00063 }

void RooGKCounter::setCounter ( unsigned long int  theCount  ) 

Definition at line 29 of file RooGKCounter.cc.

References _count.

00029                                                          {
00030   _count = theCount;
00031 }

void RooGKCounter::setDivider ( unsigned int  theDivider  ) 

Definition at line 33 of file RooGKCounter.cc.

References _divider.

00033                                                       {
00034   _divider = theDivider;
00035 }

void RooGKCounter::setMessage ( const char *  message  ) 

Definition at line 45 of file RooGKCounter.cc.

References _message.

00045                                                   {
00046   _message = message;
00047 }

void RooGKCounter::setNewLine ( bool  newLine  ) 

Definition at line 41 of file RooGKCounter.cc.

References _newLine.

00041                                            {
00042   _newLine = newLine;
00043 }

void RooGKCounter::setPrintCount ( bool  _printCount  ) 

Definition at line 37 of file RooGKCounter.cc.

References printCount.

00037                                                   {
00038   printCount = _printCount;
00039 }


Member Data Documentation

unsigned long int RooGKCounter::_count [private]

Definition at line 29 of file RooGKCounter.h.

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

unsigned int RooGKCounter::_divider [private]

Definition at line 31 of file RooGKCounter.h.

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

unsigned long int RooGKCounter::_firstCount [private]

Definition at line 30 of file RooGKCounter.h.

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

string RooGKCounter::_message [private]

Definition at line 34 of file RooGKCounter.h.

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

bool RooGKCounter::_newLine [private]

Definition at line 35 of file RooGKCounter.h.

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

bool RooGKCounter::firstCountEntry [private]

Definition at line 33 of file RooGKCounter.h.

Referenced by count(), and init().

time_t RooGKCounter::firstTickTime [private]

Definition at line 37 of file RooGKCounter.h.

Referenced by count(), and init().

time_t RooGKCounter::initTime [private]

Definition at line 37 of file RooGKCounter.h.

Referenced by init().

time_t RooGKCounter::lastPrintTime [private]

Definition at line 37 of file RooGKCounter.h.

Referenced by count(), and init().

time_t RooGKCounter::lastTickTime [private]

Definition at line 37 of file RooGKCounter.h.

Referenced by count(), and init().

bool RooGKCounter::printCount [private]

Definition at line 32 of file RooGKCounter.h.

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


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:30:53 2009 for CMSSW by  doxygen 1.5.4