src
FWCore
MessageLogger
src
ELmap.cc
Go to the documentation of this file.
1
// ----------------------------------------------------------------------
2
//
3
// ELmap.cc
4
//
5
// Change History:
6
// 99-06-10 mf correction in sense of comparison between timespan
7
// and diff (now, lastTime)
8
// mf ELcountTRACE made available
9
// 99-06-11 mf Corrected logic for suppressing output when n > limit
10
// but not but a factor of 2**K
11
// 06-05-16 mf Added code to establish interval and to use skipped
12
// and interval when determinine in add() whehter to react
13
// 06-05-19 wmtan Bug fix. skipped = 0, not skipped == 0.
14
// and interval when determinine in add() whehter to react
15
// 09-04-15 wmtan Use smart pointers with new, not bare pointers
16
//
17
// ----------------------------------------------------------------------
18
19
#include "
FWCore/MessageLogger/interface/ELmap.h
"
20
21
#include <ctime>
22
23
// Possible traces
24
//#include <iostream>
25
//#define ELcountTRACE
26
// #define ELmapDumpTRACE
27
28
namespace
edm
{
29
30
// ----------------------------------------------------------------------
31
// LimitAndTimespan:
32
// ----------------------------------------------------------------------
33
34
LimitAndTimespan::LimitAndTimespan
(
int
lim,
int
ts,
int
ivl) :
limit
(lim),
timespan
(ts),
interval
(ivl) {}
35
36
// ----------------------------------------------------------------------
37
// CountAndLimit:
38
// ----------------------------------------------------------------------
39
40
CountAndLimit::CountAndLimit
(
int
lim,
int
ts,
int
ivl)
41
:
n
(0),
42
aggregateN(0),
43
lastTime(
time
(nullptr)),
44
limit
(lim),
45
timespan
(ts),
46
interval
(ivl),
47
skipped
(ivl - 1)
// So that the FIRST of the prescaled messages emerges
48
{}
49
50
bool
CountAndLimit::add
() {
51
time_t
now
=
time
(
nullptr
);
52
53
#ifdef ELcountTRACE
54
std::cerr
<<
"&&&--- CountAndLimit::add \n"
;
55
std::cerr
<<
"&&& Time now is "
<<
now
<<
"\n"
;
56
std::cerr
<<
"&&& Last time is "
<<
lastTime
<<
"\n"
;
57
std::cerr
<<
"&&& timespan is "
<<
timespan
<<
"\n"
;
58
std::cerr
<<
"&&& difftime is "
<< difftime(
now
,
lastTime
) <<
"\n"
<< std::flush;
59
#endif
60
61
// Has it been so long that we should restart counting toward the limit?
62
if
((
timespan
>= 0) && (difftime(
now
,
lastTime
) >=
timespan
)) {
63
n
= 0;
64
if
(
interval
> 0) {
65
skipped
=
interval
- 1;
// So this message will be reacted to
66
}
else
{
67
skipped
= 0;
68
}
69
}
70
71
lastTime
=
now
;
72
73
++
n
;
74
++
aggregateN
;
75
++
skipped
;
76
77
#ifdef ELcountTRACE
78
std::cerr
<<
"&&& n is "
<<
n
<<
"-- limit is "
<<
limit
<<
"\n"
;
79
std::cerr
<<
"&&& skipped is "
<<
skipped
<<
"-- interval is "
<<
interval
<<
"\n"
;
80
#endif
81
82
if
(
skipped
<
interval
)
83
return
false
;
84
85
if
(
limit
== 0)
86
return
false
;
// Zero limit - never react to this
87
if
((
limit
< 0) || (
n
<=
limit
)) {
88
skipped
= 0;
89
return
true
;
90
}
91
92
// Now we are over the limit - have we exceeded limit by 2^N * limit?
93
long
diff
=
n
-
limit
;
94
long
r =
diff
/
limit
;
95
if
(r *
limit
!=
diff
) {
// Not a multiple of limit - don't react
96
return
false
;
97
}
98
if
(r == 1) {
// Exactly twice limit - react
99
skipped
= 0;
100
return
true
;
101
}
102
103
while
(r > 1) {
104
if
((r & 1) != 0)
105
return
false
;
// Not 2**n times limit - don't react
106
r >>= 1;
107
}
108
// If you never get an odd number till one, r is 2**n so react
109
110
skipped
= 0;
111
return
true
;
112
113
}
// add()
114
115
// ----------------------------------------------------------------------
116
// StatsCount:
117
// ----------------------------------------------------------------------
118
119
StatsCount::StatsCount
() :
n
(0), aggregateN(0), ignoredFlag(
false
), context1(
""
), context2(
""
), contextLast(
""
) {}
120
121
void
StatsCount::add
(std::string_view
context
,
bool
reactedTo) {
122
++
n
;
123
++
aggregateN
;
124
125
((1 ==
n
) ?
context1
: (2 ==
n
) ?
context2
:
contextLast
) =
std::string
(
context
, 0, 16);
126
127
if
(!reactedTo)
128
ignoredFlag
=
true
;
129
130
}
// add()
131
132
}
// end of namespace edm */
writeEcalDQMStatus.interval
interval
Definition:
writeEcalDQMStatus.py:27
edm::CountAndLimit::timespan
int timespan
Definition:
ELmap.h:59
edm::CountAndLimit::limit
int limit
Definition:
ELmap.h:58
edm::StatsCount::context2
std::string context2
Definition:
ELmap.h:74
edm::LimitAndTimespan::LimitAndTimespan
LimitAndTimespan(int lim=-1, int ts=-1, int ivl=-1)
Definition:
ELmap.cc:34
edm::CountAndLimit::CountAndLimit
CountAndLimit(int lim=-1, int ts=-1, int ivl=-1)
Definition:
ELmap.cc:40
funct::false
false
Definition:
Factorize.h:29
edm::CountAndLimit::n
int n
Definition:
ELmap.h:55
edm::StatsCount::aggregateN
int aggregateN
Definition:
ELmap.h:71
hcalRecHitTable_cff.time
time
Definition:
hcalRecHitTable_cff.py:14
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
dqmiodumpmetadata.n
n
Definition:
dqmiodumpmetadata.py:28
edm::CountAndLimit::aggregateN
int aggregateN
Definition:
ELmap.h:56
remoteMonitoring_LASER_era2018_cfg.limit
limit
Definition:
remoteMonitoring_LASER_era2018_cfg.py:583
edm::StatsCount::n
int n
Definition:
ELmap.h:70
edm::CountAndLimit::interval
int interval
Definition:
ELmap.h:60
ELmap.h
change_name.diff
diff
Definition:
change_name.py:13
visDQMUpload.context
context
Definition:
visDQMUpload.py:30
edm::CountAndLimit::lastTime
time_t lastTime
Definition:
ELmap.h:57
edm::StatsCount::context1
std::string context1
Definition:
ELmap.h:73
DMR_cfg.cerr
cerr
Definition:
DMR_cfg.py:78
runEdmFileComparison.skipped
skipped
Definition:
runEdmFileComparison.py:224
edm::StatsCount::contextLast
std::string contextLast
Definition:
ELmap.h:75
edm
HLT enums.
Definition:
AlignableModifier.h:19
MessageLogger_ReleaseValidation_cfi.timespan
timespan
Definition:
MessageLogger_ReleaseValidation_cfi.py:6
edm::StatsCount::add
void add(std::string_view context, bool reactedTo)
Definition:
ELmap.cc:121
edm::StatsCount::ignoredFlag
bool ignoredFlag
Definition:
ELmap.h:72
edm::CountAndLimit::add
bool add()
Definition:
ELmap.cc:50
edm::StatsCount::StatsCount
StatsCount()
Definition:
ELmap.cc:119
submitPVValidationJobs.now
now
Definition:
submitPVValidationJobs.py:645
edm::CountAndLimit::skipped
int skipped
Definition:
ELmap.h:61
Generated for CMSSW Reference Manual by
1.8.14