An algorithm is a class, with one or more instances managed by user code, that performs a task or part of it. (Click here for a list of LArSoft algorithms.)  In the context of the art framework, an algorithm is used by an art module class.* The best practice is to make the algorithm itself as independent as possible from the framework and use the module to provide the interface between the two. In other words,

  • algorithm class performs some or all the operations required for a task (e.g., “parametrize the shape of a hit”)
  • framework module (or simply module) class manages and coordinates its algorithms in order to produce and deliver a result to the framework



Since an algorithm is a piece of code that can be a component of many execution paths, it must be thoroughly documented. The documentation should state what it needs, what it does including how and why, its assumptions, what it produces, how to configure it and how to test it completely so it’s easy to detect if it gets broken.

An algorithm should be able to perform its task using only LArSoft data products. It produces LArSoft data products and histograms. A LArSoft algorithm:

  • is implemented as a self-standing class with one header file and one implementation file
  • extracts the parameters to run from a configuration file ( FHiCL file)
  • has an input phase, a running phase and an output phase
  • comes with documentation
  • has a test or tests that exercises all the main features of the algorithm.

Some algorithms in LArSoft are still implemented inside modules, i.e. the factorization scheme has not been applied to them. The best practice is to make the algorithm independent from the framework.

Click here for the list of algorithms documented in LArSoft. If you have one to add to the documentation, there are instructions on the page on how to get started.

For more information, please consult the source for this information Gianluca  Petrillo’s slides for algorithms and services from the 2015 LArSoft class and  LArSoft Wiki on Writing LArSoft Algorithms.