From af93fc11823f487aa20bd47948bd3e67b9e4891f Mon Sep 17 00:00:00 2001 From: saganatt <8majak8@gmail.com> Date: Wed, 8 May 2024 17:09:10 +0200 Subject: [PATCH 1/3] Add getBin() calls to tutorials --- Tutorials/src/eventMixing.cxx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Tutorials/src/eventMixing.cxx b/Tutorials/src/eventMixing.cxx index 79abe008e85..eee3506d708 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(getTrackSize(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; From 61120d4cbf0748047a3313ea357a56901f1e4fcd Mon Sep 17 00:00:00 2001 From: saganatt <8majak8@gmail.com> Date: Thu, 9 May 2024 21:09:45 +0200 Subject: [PATCH 2/3] Fix getBin. Move weighted example to the main tutorial --- Tutorials/src/eventMixing.cxx | 26 +++++++++++++++++++++-- Tutorials/src/eventMixingValidation.cxx | 28 ------------------------- 2 files changed, 24 insertions(+), 30 deletions(-) diff --git a/Tutorials/src/eventMixing.cxx b/Tutorials/src/eventMixing.cxx index eee3506d708..2f14bbef665 100644 --- a/Tutorials/src/eventMixing.cxx +++ b/Tutorials/src/eventMixing.cxx @@ -51,7 +51,7 @@ struct MixedEvents { for (auto& [c1, tracks1, c2, tracks2] : pair) { // 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()); + int bin = binningOnPositions.getBin({c1.posX(), c1.posY()}); LOGF(info, "Mixed event collisions: (%d, %d) from bin %d", c1.globalIndex(), c2.globalIndex(), bin); count++; @@ -439,7 +439,7 @@ struct MixedEventsLambdaBinning { int count = 0; for (auto& [c1, tracks1, c2, tracks2] : pair) { // NOTE that getBin() with FlexibleBinningPolicy needs explicit tuple construction - int bin = binningWithLambda.getBin(std::tuple(getTrackSize(c1), c1.posZ())); + 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++; @@ -458,6 +458,27 @@ struct MixedEventsLambdaBinning { } }; +struct 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{ @@ -473,5 +494,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), }; } From 452832ef490cd95d6b384b38174eaf711c8155c0 Mon Sep 17 00:00:00 2001 From: saganatt <8majak8@gmail.com> Date: Thu, 9 May 2024 21:13:50 +0200 Subject: [PATCH 3/3] Refer to the docs --- Tutorials/src/eventMixing.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Tutorials/src/eventMixing.cxx b/Tutorials/src/eventMixing.cxx index 2f14bbef665..ff5c55da865 100644 --- a/Tutorials/src/eventMixing.cxx +++ b/Tutorials/src/eventMixing.cxx @@ -459,6 +459,9 @@ 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};