3.5.7. Windows¶
Window |
Operators |
Output family length |
---|---|---|
\(y = \window{f}{adj}{label}\ x\) |
\(f: X \times \opt{X} \rightarrow Y\) |
\(|y| = |x|\) |
\(adj: \iset{x} \times \iset{x} \rightarrow \bool\) |
||
\(label: \one \rightarrow L\) |
One of the unique capabilities of Phlex is to execute an algorithm on data products that belong to adjacent data cells (see Section 3.4.1.2). The workflow in Fig. 3.1 shows a such a node \(\textit{window(make\_tracks)}\), which is presented with pairs of \(\textit{GoodHits}\) data products, with each data product in the pair belonging to adjacent APAs. It is the user-provided \(adj\) function which determines whether two data cells are adjacent.
For simplicity, imagine that each APA identifier (i.e. member of the set \(\iset{\text{APA}}\)) can be represented as an integer. A straightforward \(adj\) implementation might be to group the \(\textit{GoodHits}\) data products from APAs with consecutive numbers:
The data products corresponding to windows \(a\) through \(m\) are grouped into pairs and presented to an algorithm \(make\_tracks'\), which has the signature \(\text{Hits} \times \text{Hits} \rightarrow \text{Tracks}\). There are, at most, \(n-1\) unique pairs that can be presented to the function \(make\_tracks'\) such that:
where the index set \(\iset{\text{APA}}'\) is \(\iset{\text{APA}}\) without the last identifier \(n\) [1]. In this example, the identifier of the first \(hs\) object in the pair is used to identify the tracks collection \(ts\). But Phlex does not mandate this choice, and a different data layer could be specified by the \(label\) operator for the data products of the output family.
3.5.7.1. Operator Signatures¶
One limitation of the above formulation is that index sets of the input and output families are not the same. To address this infelicity, the function signature of \(make\_tracks'\) can be adjusted such that the second argument receives an optional type. We call this new algorithm \(make\_tracks\):
thus permitting symmetry between the input and output data-product families:
where \(label\) returns the value of APA, \(\boldsymbol{+}\) is the list-concatenation operator, and \(()\) is the null value. Phlex supports the function signature whose second argument is an optional type \(\opt{X}\).
Operator |
Allowed signature |
---|---|
\(f\) |
|
\(adj\) |
|
\(label\) |
Name of data layer of output data products |
The return_type
must model the created data-product type described in Section 3.3.2.
The algorithm \(f\) may also create multiple data products by returning a std::tuple<T1, ..., Tn>
where each of the types T1, ..., Tn
models a created data-product type.
The second argument Opt<P2>
indicates that an optional type is passed to the algorithm.
It is permitted to use resources (i.e. Rm...
) in the function \(f\).
The data cell identifers of P1
and P2
are used to determine whether two data-products reside in adjacent data cells.
3.5.7.2. Registration Interface¶
The \(\textit{window(make\_tracks)}\) node in Fig. 3.1 would be represented in C++ as:
class hits { ... };
class tracks { ... };
class id { ... };
tracks make_tracks(tracks const& ts, tracks const* next_ts) { ... }
bool are_adjacent(id const& left, id const& right) { ... }
PHLEX_REGISTER_ALGORITHMS(config)
{
products("GoodTracks") =
window(
"track_maker", // <= Node name for framework
make_tracks, // <= Window algorithm (f)
are_adjacent // <= Adjacency criterion
"APA", // <= Output data layer
concurrency::unlimited // <= Allowed concurrency
)
.family("GoodHits"_in("APA"));
}
Note that the second input parameter for make_tracks
is an optional type.
The type id
is a metadata type (possibly defined by the experiment) that enables the comparison of data-product identifiers for establishing adjacency.
Footnotes