Skip to content
Open
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
80 changes: 43 additions & 37 deletions PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
#include <CommonConstants/PhysicsConstants.h>
#include <Framework/ASoA.h>
#include <Framework/AnalysisDataModel.h>
#include <Framework/AnalysisHelpers.h>
#include <Framework/AnalysisTask.h>
#include <Framework/BinningPolicy.h>
#include <Framework/Configurable.h>
Expand Down Expand Up @@ -86,6 +85,13 @@ const std::array<std::string, NCharges> chargeTags{"P", "M"};
constexpr int chargeIndexOf(int sign) { return sign > 0 ? 0 : 1; }
/// Charge sign (+1, -1) from the accepted id of the dpt-dpt filter (even = positive, odd = negative), as its Sign column
constexpr int8_t signOf(int trackAcceptedId) { return trackAcceptedId % NCharges == 0 ? 1 : -1; }
/// Histogram name prefix + path + tag, appended in place (no temporary strings in the booking loops)
std::string histName(const std::string& prefix, const char* path, const std::string& tag)
{
std::string name{prefix};
name.append(path).append(tag);
return name;
}
enum IdCheckBin {
kIdCheckGood = 1,
kIdCheckNotKaonId,
Expand All @@ -108,12 +114,12 @@ enum PairTruthBin {
kPairSameMcParticle
};
/// PDG codes above this value are hadrons; below are quarks, leptons, gauge bosons and generator-internal codes
static constexpr int KPdgHadronThreshold = 100; // o2-linter: disable=pdg/explicit-code (not a PDG code)
constexpr int KPdgHadronThreshold = 100; // o2-linter: disable=pdg/explicit-code (not a PDG code)
/// Generator status codes of beam and event-setup entries (PYTHIA 11-19) and the HepMC beam status (4).
/// Same criterion as PWGCF/TwoParticleCorrelations/Tasks/particleOriginAnalysis.cxx (V. Gonzalez)
static constexpr int KBeamStatusCodeMin = 11;
static constexpr int KBeamStatusCodeMax = 19;
static constexpr int KHepMCBeamStatusCode = 4;
constexpr int KBeamStatusCodeMin = 11;
constexpr int KBeamStatusCodeMax = 19;
constexpr int KHepMCBeamStatusCode = 4;
/// Mother of a particle: global index (-1 if none) and PDG code (0 if none)
struct MotherInfo {
int64_t index = -1;
Expand Down Expand Up @@ -212,8 +218,8 @@ struct QSpaceBalanceFunction {
PairHistos genHistos; ///< generator level, top-level folders (as before the detector level existed)
PairHistos recHistos; ///< detector level, folder rec/

Filter onlyAcceptedCollisions = (aod::dptdptfilter::collisionaccepted == uint8_t(true));
Filter onlyAcceptedTracks = (aod::dptdptfilter::trackacceptedid >= int8_t(0));
Filter onlyAcceptedCollisions = (aod::dptdptfilter::collisionaccepted == static_cast<uint8_t>(true));
Filter onlyAcceptedTracks = (aod::dptdptfilter::trackacceptedid >= static_cast<int8_t>(0));

/// Books the histograms of one level under the folder prefix ("" or "rec/")
void bookHistos(PairHistos& histos, const std::string& prefix, bool withResolution)
Expand All @@ -239,39 +245,39 @@ struct QSpaceBalanceFunction {
histos.fhIdCheck->GetXaxis()->SetBinLabel(kIdCheckNoMcTruth, "no MC label");
for (int charge1 = 0; charge1 < NCharges; ++charge1) {
const std::string& tag1 = chargeTags[charge1];
histos.fhPtVsCent[charge1] = registry.add<TH2>((prefix + "singles/hPtVsCent_" + tag1).c_str(), "kaon #it{p}_{T}", kTH2D, {axisCent, axisPt});
histos.fhEta[charge1] = registry.add<TH1>((prefix + "singles/hEta_" + tag1).c_str(), "kaon #eta", kTH1D, {axisEta});
histos.fhPhi[charge1] = registry.add<TH1>((prefix + "singles/hPhi_" + tag1).c_str(), "kaon #varphi", kTH1D, {axisPhi});
histos.fhPtFromPhi[charge1] = registry.add<TH1>((prefix + "singles/hPtFromPhi_" + tag1).c_str(), "kaons whose mother is a #phi(1020)", kTH1D, {axisPt});
histos.fhPtVsCent[charge1] = registry.add<TH2>(histName(prefix, "singles/hPtVsCent_", tag1).c_str(), "kaon #it{p}_{T}", kTH2D, {axisCent, axisPt});
histos.fhEta[charge1] = registry.add<TH1>(histName(prefix, "singles/hEta_", tag1).c_str(), "kaon #eta", kTH1D, {axisEta});
histos.fhPhi[charge1] = registry.add<TH1>(histName(prefix, "singles/hPhi_", tag1).c_str(), "kaon #varphi", kTH1D, {axisPhi});
histos.fhPtFromPhi[charge1] = registry.add<TH1>(histName(prefix, "singles/hPtFromPhi_", tag1).c_str(), "kaons whose mother is a #phi(1020)", kTH1D, {axisPt});
for (int charge2 = 0; charge2 < NCharges; ++charge2) {
const std::string tag = tag1 + chargeTags[charge2];
histos.fhQinv[charge1][charge2] = registry.add<TH2>((prefix + "pairs/hQinv_" + tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQinv});
histos.fhQlong[charge1][charge2] = registry.add<TH2>((prefix + "pairs/hQlong_" + tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQlong});
histos.fhQout[charge1][charge2] = registry.add<TH2>((prefix + "pairs/hQout_" + tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQout});
histos.fhQside[charge1][charge2] = registry.add<TH2>((prefix + "pairs/hQside_" + tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQside});
histos.fhMass[charge1][charge2] = registry.add<TH1>((prefix + "pairs/hMass_" + tag).c_str(), "ordered pairs", kTH1F, {axisMass});
histos.fhSumRuleResidual[charge1][charge2] = registry.add<TH1>((prefix + "checks/hSumRuleResidual_" + tag).c_str(), "Q_{long}^{2}+Q_{out}^{2}+Q_{side}^{2}-Q_{inv}^{2}", kTH1D, {axisResidual});
histos.fhMassRuleResidual[charge1][charge2] = registry.add<TH1>((prefix + "checks/hMassRuleResidual_" + tag).c_str(), "M^{2}-4m^{2}-Q_{inv}^{2}", kTH1D, {axisResidual});
histos.fhQinv[charge1][charge2] = registry.add<TH2>(histName(prefix, "pairs/hQinv_", tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQinv});
histos.fhQlong[charge1][charge2] = registry.add<TH2>(histName(prefix, "pairs/hQlong_", tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQlong});
histos.fhQout[charge1][charge2] = registry.add<TH2>(histName(prefix, "pairs/hQout_", tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQout});
histos.fhQside[charge1][charge2] = registry.add<TH2>(histName(prefix, "pairs/hQside_", tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQside});
histos.fhMass[charge1][charge2] = registry.add<TH1>(histName(prefix, "pairs/hMass_", tag).c_str(), "ordered pairs", kTH1F, {axisMass});
histos.fhSumRuleResidual[charge1][charge2] = registry.add<TH1>(histName(prefix, "checks/hSumRuleResidual_", tag).c_str(), "Q_{long}^{2}+Q_{out}^{2}+Q_{side}^{2}-Q_{inv}^{2}", kTH1D, {axisResidual});
histos.fhMassRuleResidual[charge1][charge2] = registry.add<TH1>(histName(prefix, "checks/hMassRuleResidual_", tag).c_str(), "M^{2}-4m^{2}-Q_{inv}^{2}", kTH1D, {axisResidual});
for (int origin = 0; origin < NPairOrigins; ++origin) {
const std::string originTag = tag + "_" + pairOriginTags[origin];
histos.fhQinvOrigin[origin][charge1][charge2] = registry.add<TH2>((prefix + "pairsByOrigin/hQinv_" + originTag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQinv});
histos.fhQlongOrigin[origin][charge1][charge2] = registry.add<TH2>((prefix + "pairsByOrigin/hQlong_" + originTag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQlong});
histos.fhQoutOrigin[origin][charge1][charge2] = registry.add<TH2>((prefix + "pairsByOrigin/hQout_" + originTag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQout});
histos.fhQsideOrigin[origin][charge1][charge2] = registry.add<TH2>((prefix + "pairsByOrigin/hQside_" + originTag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQside});
histos.fhQinvOrigin[origin][charge1][charge2] = registry.add<TH2>(histName(prefix, "pairsByOrigin/hQinv_", originTag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQinv});
histos.fhQlongOrigin[origin][charge1][charge2] = registry.add<TH2>(histName(prefix, "pairsByOrigin/hQlong_", originTag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQlong});
histos.fhQoutOrigin[origin][charge1][charge2] = registry.add<TH2>(histName(prefix, "pairsByOrigin/hQout_", originTag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQout});
histos.fhQsideOrigin[origin][charge1][charge2] = registry.add<TH2>(histName(prefix, "pairsByOrigin/hQside_", originTag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQside});
}
if (withResolution) {
const AxisSpec axisQinvTrue{cfgBinsQinvTrue, "true Q_{inv} (GeV/#it{c})"};
const AxisSpec axisQComponentTrue{cfgBinsQComponentTrue, "true Q component (GeV/#it{c})"};
const AxisSpec axisResolution{cfgBinsQResolution, "Q_{rec} - Q_{true} (GeV/#it{c})"};
histos.fhPairTruth[charge1][charge2] = registry.add<TH1>((prefix + "resolution/hPairTruth_" + tag).c_str(), "ordered pairs by MC truth", kTH1D, {{4, 0.5, 4.5}});
histos.fhPairTruth[charge1][charge2] = registry.add<TH1>(histName(prefix, "resolution/hPairTruth_", tag).c_str(), "ordered pairs by MC truth", kTH1D, {{4, 0.5, 4.5}});
histos.fhPairTruth[charge1][charge2]->GetXaxis()->SetBinLabel(kPairBothTrueKaons, "both true kaons, right charge");
histos.fhPairTruth[charge1][charge2]->GetXaxis()->SetBinLabel(kPairMisidentified, "at least one misidentified");
histos.fhPairTruth[charge1][charge2]->GetXaxis()->SetBinLabel(kPairUnmatched, "at least one without MC label");
histos.fhPairTruth[charge1][charge2]->GetXaxis()->SetBinLabel(kPairSameMcParticle, "both tracks from one MC particle");
histos.fhResQinv[charge1][charge2] = registry.add<TH2>((prefix + "resolution/hResQinv_" + tag).c_str(), "pairs of two true kaons", kTH2F, {axisQinvTrue, axisResolution});
histos.fhResQlong[charge1][charge2] = registry.add<TH2>((prefix + "resolution/hResQlong_" + tag).c_str(), "pairs of two true kaons", kTH2F, {axisQComponentTrue, axisResolution});
histos.fhResQout[charge1][charge2] = registry.add<TH2>((prefix + "resolution/hResQout_" + tag).c_str(), "pairs of two true kaons", kTH2F, {axisQComponentTrue, axisResolution});
histos.fhResQside[charge1][charge2] = registry.add<TH2>((prefix + "resolution/hResQside_" + tag).c_str(), "pairs of two true kaons", kTH2F, {axisQComponentTrue, axisResolution});
histos.fhResQinv[charge1][charge2] = registry.add<TH2>(histName(prefix, "resolution/hResQinv_", tag).c_str(), "pairs of two true kaons", kTH2F, {axisQinvTrue, axisResolution});
histos.fhResQlong[charge1][charge2] = registry.add<TH2>(histName(prefix, "resolution/hResQlong_", tag).c_str(), "pairs of two true kaons", kTH2F, {axisQComponentTrue, axisResolution});
histos.fhResQout[charge1][charge2] = registry.add<TH2>(histName(prefix, "resolution/hResQout_", tag).c_str(), "pairs of two true kaons", kTH2F, {axisQComponentTrue, axisResolution});
histos.fhResQside[charge1][charge2] = registry.add<TH2>(histName(prefix, "resolution/hResQside_", tag).c_str(), "pairs of two true kaons", kTH2F, {axisQComponentTrue, axisResolution});
}
}
}
Expand All @@ -294,14 +300,14 @@ struct QSpaceBalanceFunction {
for (int charge1 = 0; charge1 < NCharges; ++charge1) {
for (int charge2 = 0; charge2 < NCharges; ++charge2) {
const std::string tag = chargeTags[charge1] + chargeTags[charge2];
bf.fhSameQinv[charge1][charge2] = registry.add<TH2>((prefix + "same/hQinv_" + tag).c_str(), "same-event ordered pairs", kTH2F, {axisClass, axisQinv});
bf.fhSameQlong[charge1][charge2] = registry.add<TH2>((prefix + "same/hQlong_" + tag).c_str(), "same-event ordered pairs", kTH2F, {axisClass, axisQlong});
bf.fhSameQout[charge1][charge2] = registry.add<TH2>((prefix + "same/hQout_" + tag).c_str(), "same-event ordered pairs", kTH2F, {axisClass, axisQout});
bf.fhSameQside[charge1][charge2] = registry.add<TH2>((prefix + "same/hQside_" + tag).c_str(), "same-event ordered pairs", kTH2F, {axisClass, axisQside});
bf.fhMixedQinv[charge1][charge2] = registry.add<TH2>((prefix + "mixed/hQinv_" + tag).c_str(), "mixed-event ordered pairs, both orders of each event pair", kTH2F, {axisClass, axisQinv});
bf.fhMixedQlong[charge1][charge2] = registry.add<TH2>((prefix + "mixed/hQlong_" + tag).c_str(), "mixed-event ordered pairs, both orders of each event pair", kTH2F, {axisClass, axisQlong});
bf.fhMixedQout[charge1][charge2] = registry.add<TH2>((prefix + "mixed/hQout_" + tag).c_str(), "mixed-event ordered pairs, both orders of each event pair", kTH2F, {axisClass, axisQout});
bf.fhMixedQside[charge1][charge2] = registry.add<TH2>((prefix + "mixed/hQside_" + tag).c_str(), "mixed-event ordered pairs, both orders of each event pair", kTH2F, {axisClass, axisQside});
bf.fhSameQinv[charge1][charge2] = registry.add<TH2>(histName(prefix, "same/hQinv_", tag).c_str(), "same-event ordered pairs", kTH2F, {axisClass, axisQinv});
bf.fhSameQlong[charge1][charge2] = registry.add<TH2>(histName(prefix, "same/hQlong_", tag).c_str(), "same-event ordered pairs", kTH2F, {axisClass, axisQlong});
bf.fhSameQout[charge1][charge2] = registry.add<TH2>(histName(prefix, "same/hQout_", tag).c_str(), "same-event ordered pairs", kTH2F, {axisClass, axisQout});
bf.fhSameQside[charge1][charge2] = registry.add<TH2>(histName(prefix, "same/hQside_", tag).c_str(), "same-event ordered pairs", kTH2F, {axisClass, axisQside});
bf.fhMixedQinv[charge1][charge2] = registry.add<TH2>(histName(prefix, "mixed/hQinv_", tag).c_str(), "mixed-event ordered pairs, both orders of each event pair", kTH2F, {axisClass, axisQinv});
bf.fhMixedQlong[charge1][charge2] = registry.add<TH2>(histName(prefix, "mixed/hQlong_", tag).c_str(), "mixed-event ordered pairs, both orders of each event pair", kTH2F, {axisClass, axisQlong});
bf.fhMixedQout[charge1][charge2] = registry.add<TH2>(histName(prefix, "mixed/hQout_", tag).c_str(), "mixed-event ordered pairs, both orders of each event pair", kTH2F, {axisClass, axisQout});
bf.fhMixedQside[charge1][charge2] = registry.add<TH2>(histName(prefix, "mixed/hQside_", tag).c_str(), "mixed-event ordered pairs, both orders of each event pair", kTH2F, {axisClass, axisQside});
}
}
if (cfgNSubsamples.value > 0) {
Expand All @@ -315,8 +321,8 @@ struct QSpaceBalanceFunction {
for (int charge1 = 0; charge1 < NCharges; ++charge1) {
for (int charge2 = 0; charge2 < NCharges; ++charge2) {
const std::string tag = chargeTags[charge1] + chargeTags[charge2];
bf.fhSubSameQinv[charge1][charge2] = registry.add<TH3>((prefix + "sub/hSameQinv_" + tag).c_str(), "same-event ordered pairs", kTH3F, {axisClass, axisSub, axisQinvSub});
bf.fhSubMixedQinv[charge1][charge2] = registry.add<TH3>((prefix + "sub/hMixedQinv_" + tag).c_str(), "mixed-event ordered pairs, both orders", kTH3F, {axisClass, axisSub, axisQinvSub});
bf.fhSubSameQinv[charge1][charge2] = registry.add<TH3>(histName(prefix, "sub/hSameQinv_", tag).c_str(), "same-event ordered pairs", kTH3F, {axisClass, axisSub, axisQinvSub});
bf.fhSubMixedQinv[charge1][charge2] = registry.add<TH3>(histName(prefix, "sub/hMixedQinv_", tag).c_str(), "mixed-event ordered pairs, both orders", kTH3F, {axisClass, axisSub, axisQinvSub});
}
}
}
Expand Down
Loading