D0 GROUP LEVEL3
ONLINE LESSONS
Gustaaf Brooijmans
Fermilab, MS # 357
Tel: +1 (630) 840 4269 |
|
Episode XIII
Logging of Timing and Statistics for Level 3 Tools
by Gustaaf
Brooijmans
This episode will tell you how you
should set up your tool to log statistics while running. It will
tell you what you have to implement in your tool, and what should
be logged.
Implementation in Tools
The statistics manager has been implemented as a
so-called singleton pattern. To use it (note that all
tools
are required to implement this), your tool should do the following:
-
Have a pointer to the l3StatManager as a private
attribute of your tool: l3StatManager
* _statmanager;
This implies you should #include
"l3fstatmanager/l3StatManager.hpp".
-
In the MakeMe()
method, set the pointer: _statmanager
= l3StatManager::Instance();
-
and register your tool with the manager: _statmanager->createl3ToolStats(_toolid);
Now you're ready to use the manager: we have decided
(but this can be discussed) to log four items: (1) the time it takes for
the tool to make its calculations, (2) its point of exit, which is
useful for timing versus rejection studies(an electron tool could exit
before checking for tracks if no satisfactory calorimeter clusters were
found for example), (3) an integer with meaning left to the tool author
(this could be the number of candidates found for example), and (4) the
number of times a tool gets called in an event.
So, only when your tool has to do some
work (we don't want to time your tool returning cached results, and
we don't want to duplicate exit point etc. in the statistics - so this
call usually comes after if (!HaveIRun())...):
-
_statmanager->startclock(_toolid);
// This starts the clock
And then at every exit point (i.e. not only at the
end of the if (!HaveIRun()) {... block
but also at every intermediate exit point):
-
_statmanager->stopclock(_toolid, exit, n);
// exit is an integer representing the exit point, n an integer
From the statmanager point of view, each startclock-stopclock
interval is treated as one event, so to address the possibility of multiple
calls per event (when regional unpacking is done for example), we have
added the possibility to log the number of calls per event.
To do this, keep an internal counter of the number of times your tool runs
in an event, and in the ToolReset() method, use
-
_statmanager->set_calls(_toolid,
ncalls); //ncalls
counts the number of calls in an event
-
ncalls = 0;
// reset
Note that you should initialize the variable "ncalls"
to 0 in your MakeMe().
That's it!
What Happens Behind My Back?
The information is stored in an instance of class
l3ToolStats (one per tool), and at regular intervals ScriptRunner will
make sure it is shipped to the monitoring tasks.
How Do I Access the Results During Development?
This is pretty easy: at the end of your job, get a pointer to the
development statmanager:
-
l3StatDevel* _l3statdevel = l3StatDevel::Instance();
(Note that you will need to #include "l3fstats_devel/l3StatDevel.hpp"
in your test program)
Then invoke its drawhist method:
-
_l3statdevel->drawhist(_toolid);
-
(do this for every tool you ran)
This will create a file toolstats.root in your working directory
which contains the histograms you're looking for!
As usual: comments, questions? -> Feel free to contact me.