Skip to content

Commit eab136a

Browse files
authored
Merge pull request #261 from aalkin/update-sliceby
Fix outdated sliceBy usage
2 parents 0c85409 + 64a8480 commit eab136a

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

docs/tutorials/indexTables.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Related information can be contained in different tables. And in order to associ
1818

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

21-
### ProduceEtaPhi, ProduceColExtra, and ConsumeEtaPhi
21+
## ProduceEtaPhi, ProduceColExtra, and ConsumeEtaPhi
2222

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

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

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

66-
### PartitionColExtra
67-
68-
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.
66+
## PartitionColExtra
6967

68+
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.
69+
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.
7070
```cpp
71-
auto groupedTracks = tracks.sliceBy(aod::track::collisionId, col.globalIndex());
71+
struct Task {
72+
Preslice<aod::Tracks> perCol = aod::track::collisionId;
73+
void proces(aod::Collisions const & cols, aod::Tracks const& tracks) {
74+
for (auto& col : cols) {
75+
auto groupedTracks = tracks.sliceBy(perCol, col.globalIndex());
76+
}
77+
}
78+
}
7279
```
7380
7481
<a name="hmpidtask"></a>
7582
76-
### BuildHmpidIndex and ConsumeHmpidIndex
83+
## BuildHmpidIndex and ConsumeHmpidIndex
7784
7885
Builds&lt;T&gt; is used to prepare an index column of type T. This has to be performed
7986
before the index table can be used. Note the declaration of the init() function

0 commit comments

Comments
 (0)