|
AnalysisTree
|
Current version is development version!
Last tested version: v2.3.2
Last release version: v.2.3.2
Different MAJOR version means incompatible API changes. Neither API nor data compatibility is preserved between MAJOR versions.
Since v2.2.1 old infra implementation is kept for the sake of code compatibility until the next MAJOR infra release.
https://heavyionanalysis.github.io/AnalysisTree/
This is a dataformat to store information in configurable objects. Basic objects are:
Additionally to mandatory information specified in round brackets (a.k.a. "default fields"), each object can contain any number of integer, floating or boolean fields (a.k.a. "user-defined fields"). Information about all fields in all branches is stored in Configuration object.
ROOT6 is needed for installation. Follow CERN ROOT instructions to install it. Version compiled with c++17 flag is preferred, otherwise CMAKE_CXX_STANDARD flag needs to be explicitly specified (see below).
path-to-root-installation must be replaced with your actual location of Root install directory.
To apply the flag use -D{Name}={value}, for example, if you want to compile using c++11:
| Name | Default value | Possible values |
|---|---|---|
| CMAKE_BUILD_TYPE | RELEASE | RELEASE/DEBUG |
| CMAKE_CXX_STANDARD | 17 | 11/14/17 |
| AnalysisTree_BUILD_TESTS | OFF | ON/OFF |
| AnalysisTree_BUILD_EXAMPLES | OFF | ON/OFF |
| AnalysisTree_BUILD_INFRA_1 | OFF | ON/OFF |
Whatever you are going to do with AnalysisTree - read the file, perform analysis based on information stored in it or create your own file, first of all you need to set up environment variables. It can be done in a single command:
An example of AnalysisTree ROOT file can be downloaded by this link
Open a ROOT-file
Check its content
.ls
You will obtain something like this:
TFile** 1.analysistree.root TFile* 1.analysistree.root KEY: TTree rTree;1 AnalysisTree KEY: AnalysisTree::Configuration Configuration;1 KEY: AnalysisTree::DataHeader DataHeader;1
So, file contains ROOT::TTree object named rTree, AnalysisTree::Configuration object named Configuration describing the structure and hierarchy of the tree and thus needed for proper reading the tree and, finally, AnalysisTree::DataHeader object named DataHeader containing information common for all events.
In order to know the structure of the tree, perform following command:
An output will contain plenty of branches and matchings between them. Let us look at one of them:

There are listed integer, floating and boolean fields of this branch (boolean are empty in this particular case). In the left column there is a unique id of the field. Pay attention that the numeration of fields is separate for integers, floats and bools. Negative ids belong to default fields of branches while positive ids and 0 - to user-defined fields. Middle column contains string name of the field, and right column - a description of it.
Moreover, for default fields which are explicitly present in Container (i.e. px is OK, but not pt, which is not stored but calculated on fly) there is a possibility to draw them using TTree::Draw syntax:
Also you can open a ROOT interactive session and create an AnalysisTree::Chain:
and then build any fields including user-defined and implicitly present fields (such as phi or pt):
Building of distributions in interactive mode is a good approach only if the commands are simple, and the number of events to be analized is not so big. However it is not common to do it interactively if formulae you want to use are complicated, and you can easely introduce a typo. Or if your logic includes a matching between branches - then interactive building distributions is totally impossible. For this case a good solution is usage of macros. A comprehensive example of reading the AnalysisTree ROOT file is shown in examples/ReadingMacro.C.
A comprehensive example of creating the AnalysisTree ROOT file is shown in examples/WritingMacro.C.
Usage of compiled code instead of macros has some advantachges, in first turn computation speed, and also syntax check in compile time. Macros can be re-qritten into executables. For this purpose one needs:
1. Put necessary headers with #include command 2. Create an int main() function - an entry point of any C++ program 3. Add an executable into CMakeLists
An example how to do it is shown with examples/UserTaskRead.cpp and examples/UserTaskWrite.cpp.
Note: these examples use a little bit different syntax from one shown in examples above. It is a so-called syntax sugar - attempt to make syntax more user-friendly. However it has its own price in terms of performance - it is slower by factor of few units than one shown above.
For a QA of the file(s) please use the dedicated package AnalysisTreeQA:
https://github.com/HeavyIonAnalysis/AnalysisTreeQA