Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions Tutorials/src/eventMixing.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ struct MixedEvents {

int count = 0;
for (auto& [c1, tracks1, c2, tracks2] : pair) {
LOGF(info, "Mixed event collisions: (%d, %d)", c1.globalIndex(), c2.globalIndex());
// Example of using getBin() to check collisions bin
// NOTE that it is a bit different for FlexibleBinning -- check in respective example
int bin = binningOnPositions.getBin({c1.posX(), c1.posY()});

LOGF(info, "Mixed event collisions: (%d, %d) from bin %d", c1.globalIndex(), c2.globalIndex(), bin);
count++;
if (count == 100)
break;
Expand Down Expand Up @@ -434,7 +438,10 @@ struct MixedEventsLambdaBinning {

int count = 0;
for (auto& [c1, tracks1, c2, tracks2] : pair) {
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());
// NOTE that getBin() with FlexibleBinningPolicy needs explicit tuple construction
int bin = binningWithLambda.getBin(std::tuple(getTracksSize(c1), c1.posZ()));

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());
count++;
if (count == 100)
break;
Expand All @@ -451,6 +458,30 @@ struct MixedEventsLambdaBinning {
}
};

struct MixedEventsCounters {
// Please read carefully the tutorial description in O2 documentation to understand the behaviour of currentWindowNeighbours().
// https://aliceo2group.github.io/analysis-framework/docs/tutorials/eventMixing.html#mixedeventscounters

SliceCache cache;

std::vector<double> xBins{VARIABLE_WIDTH, -0.064, -0.062, -0.060, 0.066, 0.068, 0.070, 0.072};
std::vector<double> yBins{VARIABLE_WIDTH, -0.320, -0.301, -0.300, 0.330, 0.340, 0.350, 0.360};
using BinningType = ColumnBinningPolicy<aod::collision::PosX, aod::collision::PosY>;
BinningType binningOnPositions{{xBins, yBins}, true};
// true is for 'ignore overflows' (true by default)
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

void process(aod::Collisions const& collisions, aod::Tracks const& tracks)
{
LOGF(info, "Input data Collisions %d, Tracks %d ", collisions.size(), tracks.size());

for (auto it = pair.begin(); it != pair.end(); it++) {
auto& [c1, tracks1, c2, tracks2] = *it;
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());
}
}
};

WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
{
return WorkflowSpec{
Expand All @@ -466,5 +497,6 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
adaptAnalysisTask<MixedEventsWithHashTask>(cfgc),
adaptAnalysisTask<MixedEventsPartitionedTracks>(cfgc),
adaptAnalysisTask<MixedEventsLambdaBinning>(cfgc),
adaptAnalysisTask<MixedEventsCounters>(cfgc),
};
}
28 changes: 0 additions & 28 deletions Tutorials/src/eventMixingValidation.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -121,39 +121,11 @@ struct MixedEventsJoinedTracks {
// }
//};

struct MixedEventsCounters {
SliceCache cache;
// This task shows how to extract variables needed for weighted correlations.
// NOTE: The same number of currentWindowNeighbours is returned for all kinds of block combinations.
// Strictly upper: the first collision will is paired with exactly currentWindowNeighbours other collisions.
// Upper: the first collision is paired with (currentWindowNeighbours + 1) collisions, including itself.
// Full: (currentWindowNeighbours + 1) pairs with the first collision in the first position (c1)
// + there are other combinations with the first collision at other positions.

std::vector<double> xBins{VARIABLE_WIDTH, -0.064, -0.062, -0.060, 0.066, 0.068, 0.070, 0.072};
std::vector<double> yBins{VARIABLE_WIDTH, -0.320, -0.301, -0.300, 0.330, 0.340, 0.350, 0.360};
using BinningType = ColumnBinningPolicy<aod::collision::PosX, aod::collision::PosY>;
BinningType binningOnPositions{{xBins, yBins}, true};
// true is for 'ignore overflows' (true by default)
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

void process(aod::Collisions const& collisions, aod::Tracks const& tracks)
{
LOGF(info, "Input data Collisions %d, Tracks %d ", collisions.size(), tracks.size());

for (auto it = pair.begin(); it != pair.end(); it++) {
auto& [c1, tracks1, c2, tracks2] = *it;
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());
}
}
};

WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
{
return WorkflowSpec{
adaptAnalysisTask<MixedEventsEmptyTables>(cfgc),
adaptAnalysisTask<MixedEventsJoinedTracks>(cfgc),
// adaptAnalysisTask<MixedEventsBadSubscription>(cfgc), // Should not compile
adaptAnalysisTask<MixedEventsCounters>(cfgc),
};
}