DAS
3.0
Das Analysis System
|
test/example0?.cc
).test/*.cc
).Most headers may be included via darwin.h
.
The main
function of every executable should exclusively contain:
Darwin::Tools::Options
;boost::exceptions
.A typical main function will look like this:
where myFunction
would typically be a function from the Darwin::Physics
namespace (but defined in the same file, and by convention with the same name as the final executable) and contain the modification of the meta information, the loading of the dedicated corrections, and the event loop (if applicable):
DT::Flow
takes care of setting up the branches in the input and output n-tuples. DT::Looper
takes care of finding the right interval of event in the input n-tuple. A priori, an exception may be thrown from anywhere without explicitly using try ... catch
(see dedicated section below). Whenever possible, it is recommended to follow this structure, but exceptions (for good reasons) may be allowed.
Config files may be used to provide options, typically to avoid lengthy command lines, but also to improve the reproducibility. The basic ideas of these config file are:
flags
, corrections
, preseed
, git
), but the user is free to add new sections;Use Darwin::Tools::Options
and Darwin::Tools::MetaInfo
to respectively parse the command line and store generic information in the ROOT files. The usage of these classes is explained in their dedicated pages and not repeated here.
Whenever creating a ROOT file, use the following syntax:
where output
should correspond to the path to the destination file. This approach allows the direct comparison (e.g. with diff
, even if the ROOT file format is not human-readable) to compare two ROOT files directly with one another. After the event loop, don't forget to set the following flag to true:
This safety is to intended to detect early interruptions in the event loop.
To get an element from the metainfo, use
To set an element in to the metainfo, use
BOOST_THROW_EXCEPTION
(instead of throw
) to throw an exception: this provides additional information on the origin of the exception.std::filesystem::filesystem_error
).example0?
), use Darwin::Exception::BadInput
for problematic input (e.g. bad ROOT files, bad config, etc.) and Darwin::Exception::AnomalousEvent
for issues within the event loop.Anywhere in the code, one may write, for instance:
then this will be caught in the main
function (see above for minimal template).
Whenever the code is pushed to the GitLab repository, the doxygen documentation is produced and uploaded to GitLab Pages. Take example on existing executables and adopt the same style, e.g.
//!< blah
) to comment the arguments;\return
to describe the output of the function or method, \todo
for suggestions of improvements, and \note
for important things to know.Run the following command to produce the documentation locally with the local changes:
To preview the documentation, open build/doc/html/index.html
in your browser.
Tests are essential for long-term development. They improve the robustness of the code on the long run. They force to tests not only the desired but also the non-desired behaviour. Finally, they simplify debugging, since they provide many simple examples that are tested very regularly.
Each library has its own unit test using Boost, which is run whenever compiling. The executables have one common unit test using Boost (test.cc
), which tests the whole sequence of executables and the closure. Furthermore, the call of the consecutive executables is also performed directly from the shell, also testing closure and reproducibility.
Boost tests are implemented and compiled separately. They consist of a series of short pieces of code (a "test"), possibly gathered in a series (a "suite"):
(Note: there may be several test suites in a single file.) One should not define any main
function in a test unit; Boost makes one automatically, including a powerful command line. A typical call resembles ./testExecName -l all
.
We use CMake to build Darwin. This involves multiple steps:
cmake -B build -DCMAKE_INSTALL_PREFIX=install
. At this stage, CMake finds all the needed libraries and tools and writes the information it found to a "cache" file (build/CMakeCache.txt
). One can also customize details of the build such as the optimization level; refer to the CMake documentation for more information.cmake --build build
. This compiles all the libraries and executables. You may use -j
to run in parallel.cmake --build build --target test
.cmake --build build --target install
.Note that on certain systems, the proper CMake command is cmake3
and not cmake
.