Skip to content

Commit e979285

Browse files
authored
Tutorials: extendedColumns.cxx now correctly uses soa::Extend<> (#272)
1 parent f7e0e21 commit e979285

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

Tutorials/src/extendedColumns.cxx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,20 @@ using namespace o2;
2828
using namespace o2::framework;
2929

3030
struct ExtendTable {
31-
void process(aod::Collision const&, aod::Tracks const& tracks)
31+
void process(aod::Collisions const& collisions, aod::Tracks const& tracks)
3232
{
33+
// note that this needs to be done only once, as it is done for the whole table
34+
// the extension is temporary and is lost when the variable it is assigned to
35+
// goes out of scope
3336
auto table_extension = soa::Extend<aod::Tracks, aod::extension::P2>(tracks);
34-
for (auto& row : table_extension) {
35-
if (row.trackType() != 3) {
36-
if (row.index() % 100 == 0) {
37-
LOGF(info, "P^2 = %.3f", row.p2());
37+
for (auto& collision : collisions) {
38+
auto trackSlice = table_extension.sliceBy(aod::track::collisionId, collision.globalIndex());
39+
LOGP(info, "Collision {}", collision.globalIndex());
40+
for (auto& row : trackSlice) {
41+
if (row.trackType() != 3) {
42+
if (row.index() % 100 == 0) {
43+
LOGP(info, "P^2 = {}", row.p2());
44+
}
3845
}
3946
}
4047
}

0 commit comments

Comments
 (0)