![]() |
Iguana 0.0.0
Implementation Guardian of Analysis Algorithms
|
This documentation shows how to use the Iguana algorithms. For more documentation, see the Documentation Front Page
Quick Links | |
---|---|
List of Algorithms | Examples of Code |
List of Action Functions | Configuring Algorithms |
To see Iguana algorithms used in the context of analysis code, with various languages and use cases, see:
Examples | |
---|---|
C++ Examples | For users of ROOT , clas12root , etc. |
Includes guidance on how to build Iguana with your C++ code | |
Python examples | For users of Python tools, such as PyROOT |
Fortran examples | See also the Fortran usage guide |
In summary, the general way to use an Iguana algorithm is as follows; see examples and documentation below for more details.
iguana::AlgorithmSequence
to help run a sequence of algorithmsStart(banklist)
if you use the HIPO API and Common FunctionsStart()
otherwise, i.e., if you use Action FunctionsRun(...)
if you use Common FunctionsRun(...)
, the banks will be filtered, transformed, and/or createdStop()
Please let the maintainers know if your use case is not covered in any examples or if you need any help.
An Iguana algorithm is a function that maps input HIPO bank data to output data. There are a few different types of algorithms, based on how they act on HIPO data:
Type | Description | Example |
---|---|---|
Filter | Filters rows of a bank based on a Boolean condition | iguana::clas12::FiducialFilter : filter particles with fiducial cuts |
Transformer | Transform (mutate) elements of a bank | iguana::clas12::MomentumCorrection : correct particle momenta |
Creator | Create a new bank | iguana::physics::InclusiveKinematics : calculate inclusive kinematics \(x\), \(Q^2\), etc. |
The available algorithms are:
Algorithms may be run using either:
clas12root
The next sections describe each of these.
All algorithms have the following Common Functions, which may be used in analysis code that uses the HIPO API. These functions act on hipo::bank
objects, and are designed to be called at certain points in an analysis of HIPO data:
Common Functions | |
---|---|
iguana::Algorithm::Start | To be called before event processing |
iguana::Algorithm::Run | To be called for every event |
iguana::Algorithm::Stop | To be called after event processing |
The algorithms are implemented in C++ classes which inherit from the base class iguana::Algorithm
; these three class methods are overridden in each algorithm.
The iguana::Algorithm::Run
function should be called on every event; the general consequence, that is, how the user should handle the algorithm's results, depends on the algorithm type:
Type | How to handle the results |
---|---|
Filter | The involved banks will be filtered. To iterate over filtered bank rows, use the function hipo::bank::getRowList , rather than iterating from 0 up to hipo::bank::getRows() ; for example, given a bank object named particle_bank : for(auto const& row : particle_bank.getRowList()) {
// loops over only the rows which pass the filter
}
for(int row = 0; row < particle_bank.getRows(); row++) {
// loops over ALL rows, regardless of whether they pass the filter
}
|
Transformer | The transformed hipo::bank will simply have the relevant bank elements changed. For example, momentum correction algorithms typically change the particle momentum components. |
Creator | Creator-type algorithms will simply create a new hipo::bank object, appending it to the end of the input hipo::banklist . An initial version is created upon calling iguana::Algorithm::Start , so that you may begin to reference it; it is helpful to use hipo::getBanklistIndex (see the examples for details). |
Internally, iguana::Algorithm::Run
calls Action Functions, which are described in the next section.
The action functions do the real work of the algorithm, and are meant to be easily callable from any analysis, even if HIPO banks are not directly used. These functions are unique to each algorithm, so view the algorithm documentation for details, or browse the full list:
Action function parameters are supposed to be simple: numbers or lists of numbers, preferably obtainable directly from HIPO bank rows. The return type of an action function depends on the algorithm type:
Algorithm Type | Action Function Output |
---|---|
Filter | Returns bool whether or not the filter passes |
Transformer | Returns the transformed parameters |
Creator | Returns a simple struct of parameters (corresponding to a created bank row) |
Some algorithms have action functions which require a number from all of the rows of a bank; this distinction motivates further classification of action functions:
Action Function Type | Description |
---|---|
Scalar | All inputs and outputs are scalar quantities (single values). This type of function may be used on a single bank row. |
Vector | All inputs and outputs are vector quantities (lists of values). This type of action function needs values from all of the bank rows. |
Mixed | Inputs and outputs are scalar or vector quantities. |
To maximize compatibility with user analysis code, these functions are overloaded:
Finally, it is important to note when to call action functions in the analysis code. For example, some action functions should be called once every event, while others should be called for every particle of the REC::Particle
bank. Some algorithms have both of these types of functions, for example:
iguana::clas12::ZVertexFilter::PrepareEvent
, which must be called first, at the beginning of an event's analysisiguana::clas12::ZVertexFilter::Filter
, which must be called on every particle, using the output of PrepareEvent
in one of its input parametersIt is highly recommended to read an algorithm's documentation carefully before using it, especially if you use action functions.
Many algorithms are configurable. An algorithm's configuration parameters and their default values are found in the algorithm's documentation.
Iguana provides a few ways to configure algorithms; in general, you may either:
iguana::Algorithm::SetOption
to configure an algorithm more directly, which may require recompilation, depending on how you use Iguana algorithmsThe default configuration YAML files are installed in the etc/
subdirectory of the Iguana installation. If you have set the Iguana environment variables using, e.g. source this_iguana.sh
, or if you are using the version of Iguana installed on ifarm
, you will have the environment variable $IGUANA_CONFIG_PATH
set to include this etc/
directory.
There are a few ways to configure the algorithms with YAML; see the sections below for the options
Start your own YAML file by first copying the default YAML configurations from each algorithm that you want to use. See algorithm documentation or the Config.yaml
files installed in $IGUANA_CONFIG_PATH
for the algorithms' default YAML configurations.
For example, suppose you want to use algorithms which have the following YAML configurations:
Custom YAML file, with some changes such as widening AlgorithmA
's cuts
:
Once you have a YAML file, you just need to tell each algorithm to use it:
iguana::Algorithm::SetConfigFile
on each algorithmiguana::AlgorithmSequence
, use iguana::AlgorithmSequence::SetConfigFileForEachAlgorithm
to use this file for each algorithm in the algorithm sequenceFirst, copy the default configuration directory to your work area, or to your analysis source code; we'll call the copied directory my_iguana_config
, as an example. If $IGUANA_CONFIG_PATH
is the default configuration directory (i.e. you have not set or modified this variable yourself), you may run:
You may then freely modify any configuration file within my_iguana_config/
.
To use this directory in your algorithms, you may do any one of the following:
$IGUANA_CONFIG_PATH
allows multiple paths, delimited by colons (:
), prepend my_iguana_config/
to $IGUANA_CONFIG_PATH
; the safest way is to use an absolute path: my_iguana_config
for the configuration before searching the default paths. You may add multiple paths, if needed. Paths which appear first in $IGUANA_CONFIG_PATH
will be prioritized when the algorithm searches for configuration parameters; this behavior is similar to that of $PATH
or $LD_LIBRARY_PATH
.iguana::Algorithm::SetConfigDirectory
instead of prepending $IGUANA_CONFIG_PATH
(and if you use an algorithm sequence, use iguana::AlgorithmSequence::SetConfigDirectoryForEachAlgorithm
)