Skip to content

Commit b95648a

Browse files
authored
Merge branch 'AliceO2Group:master' into NetChargeFluctuations3
2 parents 32e84b7 + 0ee8d9f commit b95648a

24 files changed

Lines changed: 337 additions & 197 deletions

‎DPG/Tasks/AOTTrack/qaEfficiency.cxx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,10 +1802,10 @@ struct QaEfficiency {
18021802
}
18031803
float centrality = -1.;
18041804
float occupancy = -1.;
1805-
if (doOccupancy) {
1806-
centrality = getCentralityColl(groupedCollisions);
1807-
occupancy = getOccupancyColl(groupedCollisions);
1808-
}
1805+
// if (doOccupancy) {
1806+
// centrality = getCentralityColl(groupedCollisions); // FIXME: unused
1807+
// occupancy = getOccupancyColl(groupedCollisions); // FIXME: unused
1808+
// }
18091809
histos.fill(HIST("MC/generatedCollisions"), 2);
18101810
if (skipEventsWithoutTPCTracks) {
18111811
int nTPCTracks = 0;

‎PWGCF/Femto/Core/particleCleaner.h‎

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#ifndef PWGCF_FEMTO_CORE_PARTICLECLEANER_H_
1717
#define PWGCF_FEMTO_CORE_PARTICLECLEANER_H_
1818

19+
#include <CommonConstants/MathConstants.h>
1920
#include <Framework/Configurable.h>
2021

2122
#include <string>
@@ -34,6 +35,18 @@ struct ConfParticleCleaner : o2::framework::ConfigurableGroup {
3435
o2::framework::Configurable<bool> rejectParticleWithoutMcPartonicMother{"rejectParticleWithoutMcPartonicMother", false, "If true, particles which have no associated partonic mother are rejected"};
3536
o2::framework::Configurable<std::vector<int>> requiredMotherPdgCodes{"requiredMotherPdgCodes", {}, "Only consider particles whose mothers have one of the supplied pdg codes (including the sign!)"};
3637
o2::framework::Configurable<std::vector<int>> rejectMotherPdgCodes{"rejectMotherPdgCodes", {}, "Only consider particles whose mothers do not have one of the supplied pdg codes (including the sign!)"};
38+
// Kinematic window on the mother itself (e.g. to select on the Delta++'s own pt/eta/phi, not
39+
// just its pdg code). There is only ONE window here, not one per entry in
40+
// requiredMotherPdgCodes/rejectMotherPdgCodes above: whichever mother pdg code ends up being
41+
// allowed by those two lists, this same pt/eta/phi range is what its kinematics are checked
42+
// against -- the window does not vary per pdg code. Defaults are wide open (no-op) like every
43+
// other kinematic window in this codebase, so setting these has no effect unless narrowed.
44+
o2::framework::Configurable<float> motherPtMin{"motherPtMin", 0.f, "Minimum pT of the mother. One shared window applies regardless of which requiredMotherPdgCodes/rejectMotherPdgCodes entry the mother's own pdg code matched"};
45+
o2::framework::Configurable<float> motherPtMax{"motherPtMax", 1e6f, "Maximum pT of the mother. One shared window applies regardless of which requiredMotherPdgCodes/rejectMotherPdgCodes entry the mother's own pdg code matched"};
46+
o2::framework::Configurable<float> motherEtaMin{"motherEtaMin", -1e6f, "Minimum eta of the mother. One shared window applies regardless of which requiredMotherPdgCodes/rejectMotherPdgCodes entry the mother's own pdg code matched"};
47+
o2::framework::Configurable<float> motherEtaMax{"motherEtaMax", 1e6f, "Maximum eta of the mother. One shared window applies regardless of which requiredMotherPdgCodes/rejectMotherPdgCodes entry the mother's own pdg code matched"};
48+
o2::framework::Configurable<float> motherPhiMin{"motherPhiMin", 0.f, "Minimum phi of the mother. One shared window applies regardless of which requiredMotherPdgCodes/rejectMotherPdgCodes entry the mother's own pdg code matched"};
49+
o2::framework::Configurable<float> motherPhiMax{"motherPhiMax", 1.f * o2::constants::math::TwoPI, "Maximum phi of the mother. One shared window applies regardless of which requiredMotherPdgCodes/rejectMotherPdgCodes entry the mother's own pdg code matched -- not one window per pdg code."};
3750
o2::framework::Configurable<std::vector<int>> requiredPartonicMotherPdgCodes{"requiredPartonicMotherPdgCodes", {}, "Only consider particles whose partonic mothers have one of the supplied pdg codes (including the sign!)"};
3851
o2::framework::Configurable<std::vector<int>> rejectPartonicMotherPdgCodes{"rejectPartonicMotherPdgCodes", {}, "Only consider particles whose partonic mothers do not have one of the supplied pdg codes (including the sign!)"};
3952
};
@@ -116,6 +129,13 @@ class ParticleCleaner
116129
mRequiredMotherPdgCodes = confMpc.requiredMotherPdgCodes.value;
117130
mRejectedMotherPdgCodes = confMpc.rejectMotherPdgCodes.value;
118131

132+
mMotherPtMin = confMpc.motherPtMin.value;
133+
mMotherPtMax = confMpc.motherPtMax.value;
134+
mMotherEtaMin = confMpc.motherEtaMin.value;
135+
mMotherEtaMax = confMpc.motherEtaMax.value;
136+
mMotherPhiMin = confMpc.motherPhiMin.value;
137+
mMotherPhiMax = confMpc.motherPhiMax.value;
138+
119139
mRequiredPartonicMotherPdgCodes = confMpc.requiredPartonicMotherPdgCodes.value;
120140
mRejectedPartonicMotherPdgCodes = confMpc.rejectPartonicMotherPdgCodes.value;
121141
}
@@ -159,6 +179,7 @@ class ParticleCleaner
159179

160180
bool hasMotherWithRequiredPdgCode = true;
161181
bool hasMotherWithRejectedPdgCode = false;
182+
bool motherKinematicsOk = true;
162183

163184
bool hasPartonicMotherWithRequiredPdgCode = true;
164185
bool hasPartonicMotherWithRejectedPdgCode = false;
@@ -209,6 +230,15 @@ class ParticleCleaner
209230
}
210231
}
211232
}
233+
234+
// One shared pt/eta/phi window, applied to the mother regardless of which (if any)
235+
// requiredMotherPdgCodes/rejectMotherPdgCodes entry it matched above -- see the comment on
236+
// ConfParticleCleaner's motherPtMin et al.
237+
if (!(mother.pt() > mMotherPtMin && mother.pt() < mMotherPtMax &&
238+
mother.eta() > mMotherEtaMin && mother.eta() < mMotherEtaMax &&
239+
mother.phi() > mMotherPhiMin && mother.phi() < mMotherPhiMax)) {
240+
motherKinematicsOk = false;
241+
}
212242
}
213243

214244
// MC partonic mother — same idea, via mcParticle
@@ -240,7 +270,8 @@ class ParticleCleaner
240270
}
241271
}
242272

243-
return hasRequiredPdgCode && !hasRejectedPdgCode &&
273+
return motherKinematicsOk &&
274+
hasRequiredPdgCode && !hasRejectedPdgCode &&
244275
hasMotherWithRequiredPdgCode && !hasMotherWithRejectedPdgCode &&
245276
hasPartonicMotherWithRequiredPdgCode && !hasPartonicMotherWithRejectedPdgCode;
246277
}
@@ -254,6 +285,12 @@ class ParticleCleaner
254285
std::vector<int> mRejectedPdgCodes;
255286
std::vector<int> mRequiredMotherPdgCodes;
256287
std::vector<int> mRejectedMotherPdgCodes;
288+
float mMotherPtMin = 0.f;
289+
float mMotherPtMax = 1e6f;
290+
float mMotherEtaMin = -1e6f;
291+
float mMotherEtaMax = 1e6f;
292+
float mMotherPhiMin = 0.f;
293+
float mMotherPhiMax = 1.f * o2::constants::math::TwoPI;
257294
std::vector<int> mRequiredPartonicMotherPdgCodes;
258295
std::vector<int> mRejectedPartonicMotherPdgCodes;
259296
};

‎PWGCF/TableProducer/filterCorrelations.cxx‎

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#include <experimental/type_traits> // required for is_detected
5656
#include <limits>
5757
#include <memory>
58+
#include <random>
5859
#include <string>
5960
#include <type_traits>
6061
#include <vector>
@@ -120,14 +121,16 @@ struct FilterCF {
120121
O2_DEFINE_CONFIGURABLE(cfgEfficiencyMultiplicity, std::string, "", "Multiplicity efficiency (RecoAll / MC): CCDB path or local ROOT file with a 4D ccdb_object (eta, pT, multiplicity, z-vtx); empty disables CFCollisionsExtra output");
121122
O2_DEFINE_CONFIGURABLE(cfgLocalEfficiency, int, 0, "0 = CCDB efficiency, 1 = local ROOT efficiency");
122123
O2_DEFINE_CONFIGURABLE(cfgMultiplicityTrackBitMask, uint16_t, 0, "Required track-type bits for corrected multiplicity; match cfgTrackBitMask used to produce the efficiency (0 = all stored tracks)");
124+
O2_DEFINE_CONFIGURABLE(cfgMultiplicityPoisson, bool, false, "Use reproducibly seeded Nvalid + Poisson(sum(1/eff - 1)) for multiplicity correction; skips eff > 1 tracks");
125+
O2_DEFINE_CONFIGURABLE(cfgMultiplicityPoissonSeed, uint32_t, 1, "Base seed for reproducible per-dataframe Poisson multiplicity sampling");
123126

124127
// Filters and input definitions
125128
Filter collisionZVtxFilter = nabs(aod::collision::posZ) < cfgCutVertex;
126129
Filter collisionVertexTypeFilter = (cfgCollisionFlags == 0) || ((aod::collision::flags & cfgCollisionFlags) == cfgCollisionFlags);
127130

128131
// TODO how to have this in the second task? For now they are copied
129132
Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPt);
130-
Filter trackSelection = (requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t)true);
133+
Filter trackSelection = (requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == static_cast<uint8_t>(true));
131134

132135
Filter mcCollisionFilter = nabs(aod::mccollision::posZ) < cfgCutVertex;
133136

@@ -160,6 +163,7 @@ struct FilterCF {
160163
// Own local histograms independently of their input file. CCDB owns its objects.
161164
std::unique_ptr<THn> localMultiplicityEfficiency;
162165
THn* mEfficiency = nullptr;
166+
std::mt19937_64 mMultiplicityGenerator;
163167
static constexpr int MultiplicityEfficiencyDimensions = 4;
164168

165169
// persistent caches
@@ -168,6 +172,9 @@ struct FilterCF {
168172

169173
void init(InitContext& initContext)
170174
{
175+
if (cfgMultiplicityPoisson && !doprocessDataframeSeed) {
176+
LOGF(fatal, "Poisson multiplicity sampling requires processDataframeSeed");
177+
}
171178
if (!cfgEfficiencyMultiplicity.value.empty()) {
172179
bool processTracksEnabled = false;
173180
if (!o2::common::core::getTaskOptionValue(initContext, "multiplicity-selector", "processTracks", processTracksEnabled, false)) {
@@ -394,6 +401,7 @@ struct FilterCF {
394401
auto* efficiency = loadMultiplicityEfficiency(timestamp);
395402
double correctedMultiplicity = 0.;
396403
size_t skippedTracks = 0;
404+
double totalMeanMissing = 0.;
397405
for (const auto& track : tracks) {
398406
// Match the tracks written by the corresponding data/MC producer path.
399407
if (!isTrackSelected(track, true)) {
@@ -403,14 +411,29 @@ struct FilterCF {
403411
// Keep the original estimator as the map coordinate, including for centrality.
404412
const std::array<double, MultiplicityEfficiencyDimensions> values{track.eta(), track.pt(), collision.multiplicity(), collision.posZ()};
405413
const double eff = efficiency->GetBinContent(efficiency->GetBin(values.data()));
406-
if (!std::isfinite(eff) || eff <= 0.) {
414+
if (!std::isfinite(eff) || eff <= 0. || (cfgMultiplicityPoisson && eff > 1.)) {
407415
++skippedTracks;
408416
continue;
409417
}
410-
correctedMultiplicity += 1. / eff;
418+
if (cfgMultiplicityPoisson) {
419+
correctedMultiplicity += 1.;
420+
totalMeanMissing += 1. / eff - 1.;
421+
} else {
422+
correctedMultiplicity += 1. / eff;
423+
}
424+
}
425+
if (cfgMultiplicityPoisson) {
426+
if (!std::isfinite(totalMeanMissing) || totalMeanMissing >= static_cast<double>(std::numeric_limits<uint64_t>::max())) {
427+
LOGF(fatal, "Poisson multiplicity mean exceeds the sampling range: %g", totalMeanMissing);
428+
return 0.f;
429+
}
430+
// Sample from sum of missing count (Poisson sum rule)
431+
if (totalMeanMissing > 0.) {
432+
correctedMultiplicity += std::poisson_distribution<uint64_t>(totalMeanMissing)(mMultiplicityGenerator);
433+
}
411434
}
412435
if (cfgVerbosity > 0 && skippedTracks > 0) {
413-
LOGF(warning, "Skipped %zu tracks with invalid efficiency while correcting collision %lld", skippedTracks, static_cast<int64_t>(collision.globalIndex()));
436+
LOGF(warning, "Skipped %zu tracks with invalid or unsupported efficiency while correcting collision %lld", skippedTracks, static_cast<int64_t>(collision.globalIndex()));
414437
}
415438
if (!std::isfinite(correctedMultiplicity) || correctedMultiplicity > std::numeric_limits<float>::max()) {
416439
LOGF(fatal, "Corrected multiplicity cannot be represented as a float: %g", correctedMultiplicity);
@@ -434,6 +457,27 @@ struct FilterCF {
434457
return true;
435458
}
436459

460+
// This process must run before the collision processes below.
461+
void processDataframeSeed(aod::Origins const& origins)
462+
{
463+
if (!cfgMultiplicityPoisson) {
464+
return;
465+
}
466+
if (origins.size() == 0) {
467+
LOGF(fatal, "Cannot seed Poisson multiplicity sampling without a dataframe ID");
468+
return;
469+
}
470+
const uint64_t dataframeId = origins.iteratorAt(0).dataframeID();
471+
std::seed_seq seed{cfgMultiplicityPoissonSeed.value, static_cast<uint32_t>(dataframeId),
472+
static_cast<uint32_t>(dataframeId >> std::numeric_limits<uint32_t>::digits)};
473+
std::array<uint32_t, 2> seedWords{};
474+
seed.generate(seedWords.begin(), seedWords.end());
475+
// Speed up seeding by creating one 64-bit seed from the dataframe information.
476+
const uint64_t dataframeSeed = (static_cast<uint64_t>(seedWords[0]) << std::numeric_limits<uint32_t>::digits) | seedWords[1];
477+
mMultiplicityGenerator.seed(dataframeSeed);
478+
}
479+
PROCESS_SWITCH(FilterCF, processDataframeSeed, "Seed Poisson multiplicity sampling for each dataframe", false);
480+
437481
template <class T>
438482
using HasMultTables = decltype(std::declval<T&>().multNTracksPV());
439483

@@ -815,7 +859,7 @@ struct MultiplicitySelector {
815859
O2_DEFINE_CONFIGURABLE(cfgCutEta, float, 0.8f, "Eta range for tracks");
816860

817861
Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPt);
818-
Filter trackSelection = (requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t)true);
862+
Filter trackSelection = (requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == static_cast<uint8_t>(true));
819863

820864
void init(InitContext&)
821865
{

‎PWGCF/TwoParticleCorrelations/Tasks/CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ o2physics_add_dpl_workflow(lambda-or-anti-lambda-producer-with-spin
144144
COMPONENT_NAME Analysis)
145145

146146
o2physics_add_dpl_workflow(fox-wolfram-correlation
147-
SOURCES FoxWolframCorrelation.cxx
147+
SOURCES foxWolframCorrelation.cxx
148148
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
149149
COMPONENT_NAME Analysis)
150150

0 commit comments

Comments
 (0)