ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/LJMet/MultivariateAnalysis/src/RooGKCounter.cc
Revision: 1.1
Committed: Tue Nov 11 23:01:22 2008 UTC (16 years, 5 months ago) by kukartse
Content type: text/plain
Branch: MAIN
CVS Tags: V00-03-01, ZMorph_BASE_20100408, gak040610_morphing, V00-02-02, gak011410, gak010310, ejterm2010_25nov2009, V00-02-01, V00-02-00, gak112409, CMSSW_22X_branch_base, segala101609, V00-01-15, V00-01-14, V00-01-13, V00-01-12, V00-01-11, V00-01-10, gak031009, gak030509, gak022309, gak021209, gak040209, gak012809, V00-01-09, V00-01-08, V00-01-07, V00-01-06, V00-01-05, V00-01-04, V00-00-07, V00-00-06, V00-00-05, V00-00-04, V00-01-03, V00-00-02, V00-00-01, HEAD
Branch point for: ZMorph-V00-03-01, CMSSW_22X_branch
Error occurred while calculating annotation data.
Log Message:
initial creation of a package for LJMET multivariate analysis

File Contents

# Content
1 //
2 #include "LJMet/MultivariateAnalysis/interface/RooGKCounter.h"
3
4 #include <iostream>
5 #include <math.h>
6 using std::cout;
7 using std::endl;
8 using std::ostream;
9
10 //ClassImp(RooGKCounter)
11
12 RooGKCounter::RooGKCounter(){
13 init();
14 }
15
16 RooGKCounter::RooGKCounter( const char *message ){
17 init();
18 _message = message;
19 if ( _message . length() == 0 ) printCount = false;
20 }
21
22 RooGKCounter::RooGKCounter( unsigned long int theFirst, unsigned long int theDivider ){
23 init();
24 _count = theFirst;
25 _firstCount = theFirst;
26 _divider = theDivider;
27 printCount = true;
28 }
29
30 void RooGKCounter::setCounter( unsigned long int theCount ){
31 _count = theCount;
32 }
33
34 void RooGKCounter::setDivider( unsigned int theDivider ){
35 _divider = theDivider;
36 }
37
38 void RooGKCounter::setPrintCount( bool _printCount ){
39 printCount = _printCount;
40 }
41
42 void RooGKCounter::setNewLine( bool newLine ){
43 _newLine = newLine;
44 }
45
46 void RooGKCounter::setMessage( const char *message ){
47 _message = message;
48 }
49
50 void RooGKCounter::init( void ){
51 _count = 0;
52 _count_double_type = 0.0;
53 _firstCount = 0;
54 _divider = 1;
55 printCount = false;
56 firstCountEntry = true;
57 _message = "processing entry #";
58 _newLine = true;
59
60 initTime = time( NULL );
61 firstTickTime = 1;
62 lastTickTime = 1;
63 lastPrintTime = 1;
64
65 }
66
67 void RooGKCounter::count( void ){
68
69 _count++;
70
71 double _number;
72 double _freq;
73 double _limit = 1./(double)_divider;
74
75 _number = (double)_count;
76 _freq = (double)_divider;
77
78 if (firstCountEntry){
79 if ( printCount ) cout << "Counter is on:" << endl;
80 firstCountEntry = false;
81 firstTickTime = time( NULL );
82 }
83
84 if ( printCount ){
85 if ( fmod( _number, _freq ) < _limit ){
86 double averageTimeSinceLastPrint = 0.0;
87 double averageTimeSinceFirstTick = 0.0;
88 if ( lastPrintTime > 1 )
89 {
90 averageTimeSinceLastPrint = ( time( NULL ) - lastPrintTime ) / (double)_divider;
91 }
92 if ( _count > _firstCount )
93 {
94 averageTimeSinceFirstTick = ( time( NULL ) - firstTickTime ) / (double)( _count - _firstCount );
95 }
96 if ( !_newLine )
97 {
98 cout << char(13) << _message . c_str() << _count;
99 if ( _count > _firstCount ) cout << ", average time per count, sec: " << averageTimeSinceFirstTick;
100 fflush(stdout);
101 }
102 else
103 {
104 cout << _message . c_str() << _count;
105 if ( _count > _firstCount ) cout << ", average time per count, sec: " << averageTimeSinceFirstTick;
106 cout << endl;
107 }
108 lastPrintTime = time( NULL );
109 }
110 }
111
112 lastTickTime = time( NULL );
113 }
114
115 unsigned long int RooGKCounter::getCount( void ){
116 return _count;
117 }
118
119 double RooGKCounter::getCountDouble( void ){
120 return _count_double_type;
121 }
122
123 void RooGKCounter::increment( long int _incr ){
124 _count += _incr;
125 }
126
127 void RooGKCounter::incrementDouble( double _incr ){
128 _count_double_type += _incr;
129 }
130
131 RooGKCounter::~RooGKCounter(){
132 }