Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<BODY bgcolor="FFFFFF">
<title>
          CMS MessageLogger: Obtaining Message Statistics
</title>

<center>
<h1> <img src="header-public.gif" align="center"> </h1>

<font color=red>
<h1>CMS MessageLogger Service
<br> 
Obtaining Message Statistics</h1>
</font>
</center>

The MessageLogger service can provide statistics about the message issued
during the course of a job.  The information is placed in tables either at the
end of a log file or in an individual file.  The user code can also 
trigger statistics summaries of messages issued thus far -- 
<br> see <a href="#LogStatistics"> The edm::LogStatistics() Function</a>
<p>
These statistics tables, written when the MessageLogger service encounters its
postEndJob callback, include:
<ul>
<li>
Counts of how many times a message with each combination of category, 
severity and module has been issued.  (That is, if messages in the
identical category are issued by two different modules, or one by LogWarning
and another by LogInfo, these will be counted distinctly in the statistics.)
<li>
Samples of the run/event contexts for the first two and the last one message
of each type that were issued.
<li>
Indications of whether there were any messages of a given type which were 
issued but were not reported (due to limits) by any destination.
</ul>

<pre>
process TEST = 
  service = MessageLogger {
    vstring destinations = { "error_messages.txt" }
    vstring statistics   = { "statistics.txt"
			   , "another_stats" 
			   , "error_messages.txt" 
			   }
    PSet statistics.txt       = { string threshold  = "WARNING"   }
    PSet anotherStats         = { string output = "more_stats.txt" }
    PSet error_messages.txt   = { string threshold  = "ERROR" }
  }
  untracked PSet maxEvents = {untracked int32 input = 5}
  path p = { myAnalysisModule }
  module myAnalysisModule = ModuleThatIssuesMessages { }
  source = EmptySource { }
}
</pre>

The <font color=red>vstring statistics = { "statistics.txt"
			   , "another_stats" 
			   , "error_messages.txt" 
			   }</font> directs the system to 
attach a three statistics destinations, to be controlled by parameter sets
named statistics.txt, another_stats, and error_messages.txt.  (Normally, 
only one statistics destination is desired; here we use three to illustrate 
various control options.)
<p>
<font color=red> 
PSet statistics.txt = { string threshold  = "WARNING" } </font>
directs statistics.txt to respond to (and keep track of) only 
LogError and LogWarning messages.  Statistics destinations do not
impose limits for each category (they only count the messages anyway)
but they are sensitive to thresholds of which severities to report about.
<p>
<font color=red> 
PSet anotherStats = { string output = "more_stats.txt" }
</font>
directs the statistics destination controlled by the anotherStats PSet
to write its output to the file more_stats.txt.  If no output were specified,
then the statistics destination would write its summary to a file with the
name listed in the <code>statistics</code> vstring.  For example, with the
above .cfg file, the statistics.txt destination would write to 
statistics.txt.  
<p>
<font color=red> 
PSet error_messages.txt   = { string threshold  = "ERROR" }
</font>
controls both the error_messages.txt output destination, and the
error_messages.txt statistics destination.  Thus that statistics destination
will respond with a threshold of LogError, and will write its end-of-job
summary to the end of the file error_messages.txt.
<p>
In general, any statistics destination whose output file name (as determined
either by an explicit <code>output</code> string or implicitly as the
same name used to control the destination) matches the file of an ordinary
destination, will write its summary output at the end of that ordinary
destination's file.
<p><hr><p>
Here is a sample statistics summary output:
<pre>
Process
 type     category        sev    module        subroutine        count    total
 ---- -------------------- -- ---------------- ----------------  -----    -----
    1 cat_A                -w UnitTestClient_A                       3*       3
    2 cat_B                -w UnitTestClient_A                       3*       3
    3 cat_A                -e UnitTestClient_A                       3        3
    4 cat_B                -e UnitTestClient_A                       3        3
 
* Some occurrences of this message were suppressed in all logs, due to limits.
 
 type    category    Examples: run/evt        run/evt          run/evt
 ---- -------------------- ---------------- ---------------- ----------------
    1 cat_A                1/1              1/2              1/3
    2 cat_B                1/1              1/2              1/3
    3 cat_A                1/1              1/2              1/3
    4 cat_B                1/1              1/2              1/3
 
Severity    # Occurrences   Total Occurrences
--------    -------------   -----------------
Warning                 6                   6
Error                   6                   6
</pre>

<p><hr><p>
<a name="LogStatistics">
<h2>The edm::LogStatistics() Function</h2>

The user program can force each statistics destination to write its current
message counts and summary to its file or stream, before the end of job 
automatically causes that writing.  To do this, invoke the function
<font color=blue>
<pre>
edm::LogStatistics();
</pre>
</font>
(Just as for edm::LogError() and the other message commands, this function
is defined by including <code>MessageLogger.h</code>).
<p>
While ordinary analysis code probably has no need to invoke this, 
one can use the framework's features to set up a sensible schedule of
outputting statistics.
For example, one can place a call to 
<font color=blue>edm::LogStatistics()</font>
in a postRun callback.
<p>
The default behavior is to output the statistics thus far accumulated,
and then to continue collecting statistics.  
If, for some statistics destination, it is preferable that the statistics
be reset to zero after each summary output, this can be directed in the 
PSet for that statistics destination:
<pre>
process TEST = 
  service = MessageLogger {
    vstring destinations = { "error_messages.txt" }
    vstring statistics   = { "statistics.txt", "runstats.txt" }
    PSet statistics.txt  = { string threshold  = "WARNING"   }
    <font color=red>PSet runstats.txt    = { bool reset = true }</font>
  }
  untracked PSet maxEvents = {untracked int32 input = 5}
  path p = { myAnalysisModule }
  module myAnalysisModule = ModuleThatIssuesMessages { }
  source = EmptySource { }
}
</pre>

In this example, the statistics kept by 
<code>runstats.txt</code> will be reset after each statistics output
triggered by <code>edm::LogStatistics()</code>.
<p>
Of course, the <code>bool reset</code> parameter is moot if the  
program never explicitly invokes <code>edm::LogStatistics()</code>, since
it is immaterial whether the statistics are reset after the final automatic
end-of-job summary is output.
 




<p><center>
<img src="bar.gif"></center>

<p><center>
<a href="http://www.uscms.org/SoftwareComputing/index.html">
USCMS Software and Computing Home Page </a> - 
<a href="MessageLogger.html"> CMS MessageLogger Service Page </a> -
<a href="parameters.html#example"> Configuration File </a>
</center>

<p>
      <hr>
      <address><a href="mailto:mf@fnal.gov">Mark Fischler</a></address>
<!-- hhmts start -->
Last modified: November 29, 2005
<!-- hhmts end -->
</body>