Skip to content

Commit b751cda

Browse files
authored
Add getBin() calls and example of counters to the mixing event tutorial. (#6092)
1 parent 44b8c83 commit b751cda

2 files changed

Lines changed: 34 additions & 30 deletions

File tree

Tutorials/src/eventMixing.cxx

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ struct MixedEvents {
4949

5050
int count = 0;
5151
for (auto& [c1, tracks1, c2, tracks2] : pair) {
52-
LOGF(info, "Mixed event collisions: (%d, %d)", c1.globalIndex(), c2.globalIndex());
52+
// Example of using getBin() to check collisions bin
53+
// NOTE that it is a bit different for FlexibleBinning -- check in respective example
54+
int bin = binningOnPositions.getBin({c1.posX(), c1.posY()});
55+
56+
LOGF(info, "Mixed event collisions: (%d, %d) from bin %d", c1.globalIndex(), c2.globalIndex(), bin);
5357
count++;
5458
if (count == 100)
5559
break;
@@ -434,7 +438,10 @@ struct MixedEventsLambdaBinning {
434438

435439
int count = 0;
436440
for (auto& [c1, tracks1, c2, tracks2] : pair) {
437-
LOGF(info, "Mixed event collisions: (%d, %d) z: (%.3f, %.3f), tracks size (%d, %d)", c1.globalIndex(), c2.globalIndex(), c1.posZ(), c2.posZ(), tracks1.size(), tracks2.size());
441+
// NOTE that getBin() with FlexibleBinningPolicy needs explicit tuple construction
442+
int bin = binningWithLambda.getBin(std::tuple(getTracksSize(c1), c1.posZ()));
443+
444+
LOGF(info, "Mixed event collisions: (%d, %d) from bin %d z: (%.3f, %.3f), tracks size (%d, %d)", c1.globalIndex(), c2.globalIndex(), bin, c1.posZ(), c2.posZ(), tracks1.size(), tracks2.size());
438445
count++;
439446
if (count == 100)
440447
break;
@@ -451,6 +458,30 @@ struct MixedEventsLambdaBinning {
451458
}
452459
};
453460

461+
struct MixedEventsCounters {
462+
// Please read carefully the tutorial description in O2 documentation to understand the behaviour of currentWindowNeighbours().
463+
// https://aliceo2group.github.io/analysis-framework/docs/tutorials/eventMixing.html#mixedeventscounters
464+
465+
SliceCache cache;
466+
467+
std::vector<double> xBins{VARIABLE_WIDTH, -0.064, -0.062, -0.060, 0.066, 0.068, 0.070, 0.072};
468+
std::vector<double> yBins{VARIABLE_WIDTH, -0.320, -0.301, -0.300, 0.330, 0.340, 0.350, 0.360};
469+
using BinningType = ColumnBinningPolicy<aod::collision::PosX, aod::collision::PosY>;
470+
BinningType binningOnPositions{{xBins, yBins}, true};
471+
// true is for 'ignore overflows' (true by default)
472+
SameKindPair<aod::Collisions, aod::Tracks, BinningType> pair{binningOnPositions, 5, -1, &cache}; // indicates that 5 events should be mixed and under / overflow(-1) to be ignored
473+
474+
void process(aod::Collisions const& collisions, aod::Tracks const& tracks)
475+
{
476+
LOGF(info, "Input data Collisions %d, Tracks %d ", collisions.size(), tracks.size());
477+
478+
for (auto it = pair.begin(); it != pair.end(); it++) {
479+
auto& [c1, tracks1, c2, tracks2] = *it;
480+
LOGF(info, "Mixed event collisions: (%d, %d), is it first pair with %d: %d, number of collisions mixed with the first: %d", c1.globalIndex(), c2.globalIndex(), c1.globalIndex(), it.isNewWindow(), it.currentWindowNeighbours());
481+
}
482+
}
483+
};
484+
454485
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
455486
{
456487
return WorkflowSpec{
@@ -466,5 +497,6 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
466497
adaptAnalysisTask<MixedEventsWithHashTask>(cfgc),
467498
adaptAnalysisTask<MixedEventsPartitionedTracks>(cfgc),
468499
adaptAnalysisTask<MixedEventsLambdaBinning>(cfgc),
500+
adaptAnalysisTask<MixedEventsCounters>(cfgc),
469501
};
470502
}

Tutorials/src/eventMixingValidation.cxx

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -121,39 +121,11 @@ struct MixedEventsJoinedTracks {
121121
// }
122122
//};
123123

124-
struct MixedEventsCounters {
125-
SliceCache cache;
126-
// This task shows how to extract variables needed for weighted correlations.
127-
// NOTE: The same number of currentWindowNeighbours is returned for all kinds of block combinations.
128-
// Strictly upper: the first collision will is paired with exactly currentWindowNeighbours other collisions.
129-
// Upper: the first collision is paired with (currentWindowNeighbours + 1) collisions, including itself.
130-
// Full: (currentWindowNeighbours + 1) pairs with the first collision in the first position (c1)
131-
// + there are other combinations with the first collision at other positions.
132-
133-
std::vector<double> xBins{VARIABLE_WIDTH, -0.064, -0.062, -0.060, 0.066, 0.068, 0.070, 0.072};
134-
std::vector<double> yBins{VARIABLE_WIDTH, -0.320, -0.301, -0.300, 0.330, 0.340, 0.350, 0.360};
135-
using BinningType = ColumnBinningPolicy<aod::collision::PosX, aod::collision::PosY>;
136-
BinningType binningOnPositions{{xBins, yBins}, true};
137-
// true is for 'ignore overflows' (true by default)
138-
SameKindPair<aod::Collisions, aod::Tracks, BinningType> pair{binningOnPositions, 5, -1, &cache}; // indicates that 5 events should be mixed and under / overflow(-1) to be ignored
139-
140-
void process(aod::Collisions const& collisions, aod::Tracks const& tracks)
141-
{
142-
LOGF(info, "Input data Collisions %d, Tracks %d ", collisions.size(), tracks.size());
143-
144-
for (auto it = pair.begin(); it != pair.end(); it++) {
145-
auto& [c1, tracks1, c2, tracks2] = *it;
146-
LOGF(info, "Mixed event collisions: (%d, %d), is it first pair with %d: %d, number of collisions mixed with the first: %d", c1.globalIndex(), c2.globalIndex(), c1.globalIndex(), it.isNewWindow(), it.currentWindowNeighbours());
147-
}
148-
}
149-
};
150-
151124
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
152125
{
153126
return WorkflowSpec{
154127
adaptAnalysisTask<MixedEventsEmptyTables>(cfgc),
155128
adaptAnalysisTask<MixedEventsJoinedTracks>(cfgc),
156129
// adaptAnalysisTask<MixedEventsBadSubscription>(cfgc), // Should not compile
157-
adaptAnalysisTask<MixedEventsCounters>(cfgc),
158130
};
159131
}

0 commit comments

Comments
 (0)