Coding Guidelines for Level 3 Tools

Please try to stick to the D0 coding guidelines, and in addition to those use the following, meant to avoid waste of cpu time.

Use of ctest

All level 3 code will use ctest to interface to SRT (the probable move from ctest to ctbuild should be fairly easy).  This is non-negotiable.  In addition, the component and integrated tests should be performed (i.e. no dummy tests, except for abstract classes).

Directory Structure

Each level 3 package will have (at least) the following directories:

General Language Considerations

Aside from standard issues like multiple embedded loops which are fairly obvious and can often be circumvented, some commonly used features of c++ are known major cpu consumers.
Dynamic memory allocation is the prime example, so please minimize the number of new and delete instructions  in the event processing (DoThisTool method and methods called - directly or indirectly - in DoThisTool).  Instead, reserve this memory at start of run (by using the new in the MakeMe method), and reuse it for each event.  The delete instruction then belongs in the destructor.
Note: a (dangerous) consequence of this is that if these objects are inserted in a container and
the container is deleted they may be unexpectely deleted too.  I therefore recommend to be very careful when using containers outside of the MakeMe method.
If you're using l3vectors (see below), please create them with sufficient space at start of run and avoid increasing their size often.

Please avoid global using directives, i.e. don't use statements like "using namespace std;", or "using std::string;" in header files, unless it's inside a class or structure declaration.

Use of string and containers

The standard library containers (and string) make extensive use of dynamic memory
allocation (through the use of new, delete or equivalent instructions).  This can be very
cpu intensive, so we ask that you use the following instead: They can be used just like std::string, std::vector and std::map but we plan to implement
them in a different way.  Any class that inherits from bTool  will know about these (they
are defined in "l3ftoolbase/l3types.hpp").
The use of any other container, and in particular  std::list, is deprecated.  Should you
wish to use any of these, please discuss it with Amber and Gustaaf first.

Recommendations from benchmark tests (provided by Charles Leggett):

And finally

If you have any questions, feel free to contact Amber or Gustaaf.


GB/Dec. 10 1998