Skip to content

Commit

Permalink
Merge pull request #261 from aalkin/update-sliceby
Browse files Browse the repository at this point in the history
Fix outdated sliceBy usage
  • Loading branch information
aalkin authored Jul 9, 2024
2 parents 0c85409 + 64a8480 commit eab136a
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions docs/tutorials/indexTables.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Related information can be contained in different tables. And in order to associ

<a name="ProduceEtaPhi"></a>

### ProduceEtaPhi, ProduceColExtra, and ConsumeEtaPhi
## ProduceEtaPhi, ProduceColExtra, and ConsumeEtaPhi

The tutorial example starts with the declaration and production of three tables, EtaPhi and CollisionsExtra, which are normal tables, and HMPIDTracksIndex, an index table.

Expand All @@ -30,7 +30,7 @@ DECLARE_SOA_INDEX_TABLE_USER(HMPIDTracksIndex, Tracks, "HMPIDTRKIDX", indices::T
<a name="consumecolextra"></a>
### ConsumeColExtra
## ConsumeColExtra
In task ConsumeColExtra the basic usage of indices is demonstrated. Tracks are
associated to collisions via the index column o2::aod::track::CollisionId (see
Expand Down Expand Up @@ -63,17 +63,24 @@ struct ConsumeColExtra {

<a name="partitioncolextra"></a>

### PartitionColExtra

Index columns allow to easily select e.g. all tracks belonging to a given collision using the sliceBy() method (see also [DECLARE_SOA_TABLE](creatingTables.md#declareTables)). groupedTracks contains only tracks which belong to Collision col.
## PartitionColExtra

Index columns allow to easily select e.g. all tracks belonging to a given collision using the `sliceBy()` method (see also [DECLARE_SOA_TABLE](creatingTables.md#declareTables)). groupedTracks contains only tracks which belong to Collision col.
The slicing needs to be pre-declared using `Preslice` (or `PresliceUnsorted` if the index is not sorted) so that the framework can prepare and add it to the internal cache.
```cpp
auto groupedTracks = tracks.sliceBy(aod::track::collisionId, col.globalIndex());
struct Task {
Preslice<aod::Tracks> perCol = aod::track::collisionId;
void proces(aod::Collisions const & cols, aod::Tracks const& tracks) {
for (auto& col : cols) {
auto groupedTracks = tracks.sliceBy(perCol, col.globalIndex());
}
}
}
```
<a name="hmpidtask"></a>
### BuildHmpidIndex and ConsumeHmpidIndex
## BuildHmpidIndex and ConsumeHmpidIndex
Builds&lt;T&gt; is used to prepare an index column of type T. This has to be performed
before the index table can be used. Note the declaration of the init() function
Expand Down

0 comments on commit eab136a

Please sign in to comment.