diff --git a/Tutorials/src/eventMixing.cxx b/Tutorials/src/eventMixing.cxx index 79abe008e85..ff5c55da865 100644 --- a/Tutorials/src/eventMixing.cxx +++ b/Tutorials/src/eventMixing.cxx @@ -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; @@ -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; @@ -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 xBins{VARIABLE_WIDTH, -0.064, -0.062, -0.060, 0.066, 0.068, 0.070, 0.072}; + std::vector yBins{VARIABLE_WIDTH, -0.320, -0.301, -0.300, 0.330, 0.340, 0.350, 0.360}; + using BinningType = ColumnBinningPolicy; + BinningType binningOnPositions{{xBins, yBins}, true}; + // true is for 'ignore overflows' (true by default) + SameKindPair 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{ @@ -466,5 +497,6 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) adaptAnalysisTask(cfgc), adaptAnalysisTask(cfgc), adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), }; } diff --git a/Tutorials/src/eventMixingValidation.cxx b/Tutorials/src/eventMixingValidation.cxx index eb5b27f798b..2db94b1d082 100644 --- a/Tutorials/src/eventMixingValidation.cxx +++ b/Tutorials/src/eventMixingValidation.cxx @@ -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 xBins{VARIABLE_WIDTH, -0.064, -0.062, -0.060, 0.066, 0.068, 0.070, 0.072}; - std::vector yBins{VARIABLE_WIDTH, -0.320, -0.301, -0.300, 0.330, 0.340, 0.350, 0.360}; - using BinningType = ColumnBinningPolicy; - BinningType binningOnPositions{{xBins, yBins}, true}; - // true is for 'ignore overflows' (true by default) - SameKindPair 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(cfgc), adaptAnalysisTask(cfgc), // adaptAnalysisTask(cfgc), // Should not compile - adaptAnalysisTask(cfgc), }; }