Skip to content

Core Components for the Gaudi-based Key4hep Framework

License

Notifications You must be signed in to change notification settings

jmcarcell/k4FWCore

 
 

Repository files navigation

k4FWCore (key4hep FrameWork Core)

k4FWCore is a Gaudi package that provides the PodioDataService, which allows to use podio-based event data models like EDM4hep in Gaudi workflows.

k4FWCore also provides the k4run script used to run Gaudi steering files.

Components

Basic I/O

k4DataSvc

Component wrapping the PodioDataService to handle PODIO types and collections.

PodioInput

Algorithm to read data from one or multiple input file(s) on disk.

PodioOutput

Algorithm to write data to an output file on disk.

k4run

$ k4run --help
usage: k4run [-h] [--dry-run] [-v] [-n NUM_EVENTS] [-l] [--gdb] [--ncpus NCPUS] [config_files ...]

Run job in the Key4HEP framework

positional arguments:
  config_files          Gaudi config (python) files describing the job

options:
  -h, --help            show this help message and exit
  --dry-run             Do not actually run the job, just parse the config files
  -v, --verbose         Run job with verbose output
  -n NUM_EVENTS, --num-events NUM_EVENTS
                        Number of events to run
  -l, --list            Print all the configurable components available in the framework and exit
  --gdb                 Attach gdb debugger
  --ncpus NCPUS         Start Gaudi in parallel mode using NCPUS processes. 0 => serial mode (default), -1 => use all CPUs

When supplied with a Gaudi steering file k4run --help file.py also shows the settable properties of the Gaudi algorithms used in the file. Additionally, it is possible to add further arguments and use them in the steering file by using the Python argparse.ArgumentParser shared by k4run.

from k4FWCore.parseArgs import parser
parser.add_argument("-f", "--foo", type=int, help="hello world")
my_opts = parser.parse_known_args()
print(my_opts[0].foo)

Dependencies

  • ROOT

  • PODIO

  • Gaudi

Installation and downstream usage.

k4FWCore is a CMake project. After setting up the dependencies (use for example source /cvmfs/sw.hsf.org/key4hep/setup.sh)

mkdir build
cd build
cmake ..
make install

Implementing algorithms

k4FWCore uses Gaudi::Functional for executing algorithms. There are several types of algorithms, depending on your use case:

  • The Consumer takes inputs but no outputs; can be used for reading
  • The Producer takes outputs but no inputs; can be used for generating collections or events
  • The Transformer is the more general one (both the Consumer and the Producer are a particular case of this one) and takes both inputs and outputs

A more complete list of algorithms can be found in https://lhcb.github.io/DevelopKit/03a-gaudi/, in the Gaudi::Functional section.

In all cases the implementation process is the same: we'll create a new class that will inherit from one of the previous algorithms. Then, we implement operator(), where our algorithm will be. This operator() will return either a single type (including void) or a tuple with multiple types. It will take one parameter per input. Simple examples can be found in the test folder for each one of the above-mentioned algorithms. In addition, there are tests that have either multiple inputs and / or multiple outputs (like ExampleFunctionalProducerMultiple) that can be used as a template for the more typical case when working with multiple inputs or outputs.

GaudiAlg is deprecated and will be removed in future versions of Gaudi.

About

Core Components for the Gaudi-based Key4hep Framework

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 70.5%
  • Python 21.5%
  • CMake 7.4%
  • Shell 0.6%