Skip to content
This repository was archived by the owner on Feb 11, 2026. It is now read-only.

Commit 9ce2c47

Browse files
authored
feat: example subclass algorithm (#422)
1 parent f04c12a commit 9ce2c47

7 files changed

Lines changed: 55 additions & 0 deletions

File tree

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ src/iguana/algorithms/clas12/rga/FiducialFilterPass1/* @Gregtom3
2121
src/iguana/algorithms/clas12/rga/FiducialFilterPass2/* @tbhayward
2222
src/iguana/algorithms/clas12/rga/MomentumCorrection/* @RichCap @c-dilks
2323
src/iguana/algorithms/example/ExampleAlgorithm/* @c-dilks
24+
src/iguana/algorithms/example/ExampleSubclassAlgorithm/* @c-dilks
2425
src/iguana/algorithms/physics/Depolarization/* @c-dilks
2526
src/iguana/algorithms/physics/DihadronKinematics/* @c-dilks
2627
src/iguana/algorithms/physics/InclusiveKinematics/* @c-dilks

src/iguana/algorithms/example/ExampleAlgorithm/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,9 @@ Once you have generated your new algorithm:
4040
> errors, and will allow you to _see_ the documentation before it's deployed
4141
> online.
4242
43+
> [!TIP]
44+
> If you are writing an algorithm that is very similar to another algorithm, consider inheriting from it;
45+
> see [`ExampleSubclassAlgorithm`](../ExampleSubclassAlgorithm) for an example.
46+
4347
> [!TIP]
4448
> Enable debugging symbols when building by setting the Iguana build option `buildtype` to `debug`.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
algorithm:
2+
name: 'example::ExampleSubclassAlgorithm'
3+
include:
4+
- '../../clas12/rga/FiducialFilterPass1/Action.yaml' # include these action functions
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#include "Algorithm.h"
2+
namespace iguana::example {
3+
REGISTER_IGUANA_ALGORITHM(ExampleSubclassAlgorithm);
4+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#pragma once
2+
3+
#include "iguana/algorithms/clas12/rga/FiducialFilterPass1/Algorithm.h"
4+
5+
namespace iguana::example {
6+
7+
/// @algo_brief{example demonstrating inheritance from another algorithm}
8+
/// @algo_type_filter
9+
class ExampleSubclassAlgorithm : public clas12::rga::FiducialFilterPass1
10+
{
11+
// use `DEFINE_IGUANA_SUBALGORITHM` rather than the usual `DEFINE_IGUANA_ALGORITHM`;
12+
// include the base-class algorithm as an argument
13+
DEFINE_IGUANA_SUBALGORITHM(ExampleSubclassAlgorithm, example::ExampleSubclassAlgorithm, clas12::rga::FiducialFilterPass1)
14+
15+
public:
16+
17+
// make sure base-class specialized `Run` functions (overloads) are not shadowed by any `Run` function overrides here
18+
using clas12::rga::FiducialFilterPass1::Run;
19+
};
20+
21+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
example::ExampleSubclassAlgorithm:
2+
3+
###################################################################################
4+
# NOTE: config is the same as `rga::FiducialFilterPass1`, but with value changes
5+
###################################################################################
6+
7+
# cut levels for PCAL homogeneous cuts; one of 'loose', 'medium', or 'tight'
8+
pcal_electron_cut_level: tight # for electrons and positrons
9+
pcal_photon_cut_level: tight # for photons
10+
11+
# enable/disable certain cuts for more fine-grained control
12+
enable_pcal_cuts: 1
13+
enable_dc_cuts: 1

src/iguana/algorithms/meson.build

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ algo_dict = [
2828
'has_action_yaml': false,
2929
'test_args': {'banks': [ 'REC::Particle' ]},
3030
},
31+
{
32+
'name': 'example::ExampleSubclassAlgorithm',
33+
'has_validator': false,
34+
'test_args': {
35+
'banks': [ 'REC::Particle', 'RUN::config', 'REC::Traj', 'REC::Calorimeter' ],
36+
'prerequisites': [ 'clas12::CalorimeterLinker', 'clas12::TrajLinker' ],
37+
},
38+
},
3139
{
3240
'name': 'clas12::EventBuilderFilter',
3341
'has_validator': false,

0 commit comments

Comments
 (0)