CMS 3D CMS Logo

edm::CountAndLimit Class Reference

#include <FWCore/MessageLogger/interface/ELmap.h>

List of all members.

Public Member Functions

bool add ()
 CountAndLimit (int lim=-1, int ts=-1, int ivl=-1)

Public Attributes

int aggregateN
int interval
time_t lastTime
int limit
int n
int skipped
int timespan


Detailed Description

Definition at line 61 of file ELmap.h.


Constructor & Destructor Documentation

edm::CountAndLimit::CountAndLimit ( int  lim = -1,
int  ts = -1,
int  ivl = -1 
)

Definition at line 44 of file ELmap.cc.

00045 : n         ( 0 )
00046 , aggregateN( 0 )
00047 , lastTime  ( time(0) )
00048 , limit     ( lim )
00049 , timespan  ( ts  )
00050 , interval  ( ivl )
00051 , skipped   ( ivl-1 )  // So that the FIRST of the prescaled messages emerges
00052 { }


Member Function Documentation

bool edm::CountAndLimit::add (  ) 

Definition at line 55 of file ELmap.cc.

References aggregateN, TestMuL1L2Filter_cff::cerr, diff, flush(), interval, lastTime, limit, n, r, skipped, and timespan.

00055                           {
00056 
00057   time_t  now = time(0);
00058 
00059 #ifdef ELcountTRACE
00060   std::cerr << "&&&--- CountAndLimit::add \n";
00061   std::cerr << "&&&    Time now  is " << now << "\n";
00062   std::cerr << "&&&    Last time is " << lastTime << "\n";
00063   std::cerr << "&&&    timespan  is " << timespan << "\n";
00064   std::cerr << "&&&    difftime  is " << difftime( now, lastTime ) << "\n"
00065                                 << std::flush;
00066 #endif
00067 
00068   // Has it been so long that we should restart counting toward the limit?
00069   if ( (timespan >= 0)
00070             &&
00071         (difftime(now, lastTime) >= timespan) )  {
00072      n = 0;
00073      if ( interval > 0 ) {
00074        skipped = interval - 1; // So this message will be reacted to
00075      } else {
00076        skipped = 0;
00077      }
00078   }
00079 
00080   lastTime = now;
00081 
00082   ++n;  
00083   ++aggregateN;
00084   ++skipped;  
00085 
00086 #ifdef ELcountTRACE
00087   std::cerr << "&&&       n is " << n << "-- limit is    " << limit    << "\n";
00088   std::cerr << "&&& skipped is " << skipped 
00089                                       << "-- interval is " << interval << "\n";
00090 #endif
00091   
00092   if (skipped < interval) return false;
00093 
00094   if ( limit == 0 ) return false;        // Zero limit - never react to this
00095   if ( (limit < 0)  || ( n <= limit )) {
00096     skipped = 0;
00097     return true;
00098   }
00099   
00100   // Now we are over the limit - have we exceeded limit by 2^N * limit?
00101   long  diff = n - limit;
00102   long  r = diff/limit;
00103   if ( r*limit != diff ) { // Not a multiple of limit - don't react
00104     return false;
00105   }  
00106   if ( r == 1 )   {     // Exactly twice limit - react
00107     skipped = 0;
00108     return true;
00109   }
00110 
00111   while ( r > 1 )  {
00112     if ( (r & 1) != 0 )  return false;  // Not 2**n times limit - don't react
00113     r >>= 1;
00114   }
00115   // If you never get an odd number till one, r is 2**n so react
00116   
00117   skipped = 0;
00118   return true;
00119 
00120 }  // add()


Member Data Documentation

int edm::CountAndLimit::aggregateN

Definition at line 66 of file ELmap.h.

Referenced by add().

int edm::CountAndLimit::interval

Definition at line 70 of file ELmap.h.

Referenced by add().

time_t edm::CountAndLimit::lastTime

Definition at line 67 of file ELmap.h.

Referenced by add().

int edm::CountAndLimit::limit

Definition at line 68 of file ELmap.h.

Referenced by add().

int edm::CountAndLimit::n

Definition at line 65 of file ELmap.h.

Referenced by add().

int edm::CountAndLimit::skipped

Definition at line 71 of file ELmap.h.

Referenced by add().

int edm::CountAndLimit::timespan

Definition at line 69 of file ELmap.h.

Referenced by add().


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