3.5.1. Transforms¶
Transform |
Operator |
Output sequence length |
---|---|---|
\(b = \transform{f}\ a\) |
\(f: A \rightarrow B\) |
\(|b| = |a|\) |
The transform is the simplest HOF whose algorithms create data products. Specifically, the algorithm \(f\) is applied to each element of the input sequence \(a\), creating a corresponding data product in the output sequence \(b\):
where \(b_i = f\ a_i\). Note that the index set of the output sequence is the same as the index set of the input sequence.
Todo
Allow for transforms where the output sequence is indexed by a different set—i.e. the number of elements remains the same as the input sequence, but the label of those elements changes.
Operator |
Allowed signature |
---|---|
\(f\) |
|
Return type: A transform algorithm may create multiple data products by returning an std::tuple<T1, ..., Tn>
where each of the types T1, ..., Tn
models a data-product created type.
3.5.1.1. Registration interface¶
To illustrate the different ways a transform’s algorithm can be registered with Phlex, we use the following classes and functions, which are presumably defined in some experiment libraries.
class geometry { ... };
class hits { ... };
class tracks { ... };
class vertices { ... };
tracks make_tracks(hits const&) { ... }
vertices make_vertices(geometry const&, tracks const&) { ... }
Transform with one argument (default output product name)
PHLEX_REGISTER_ALGORITHMS(m, config)
{
transform("track_maker", make_tracks, concurrency::unlimited)
.sequence("good_hits"_in("spill"));
}
Transform with one argument (user-specified output product name)
PHLEX_REGISTER_ALGORITHMS(m, config)
{
products("good_tracks") =
transform("track_maker", make_tracks, concurrency::unlimited)
.sequence("good_hits"_in("spill"));
}
Transform with two arguments (default output product name)
PHLEX_REGISTER_ALGORITHMS(m, config)
{
transform("vertex_maker", make_vertices, concurrency::unlimited)
.sequence("geometry"_in("job"), "good_hits"_in("spill"));
}