diff --git a/PWGCF/Femto/Core/femtoMath.h b/PWGCF/Femto/Core/femtoMath.h index abeddb9447f..e66de64fda3 100644 --- a/PWGCF/Femto/Core/femtoMath.h +++ b/PWGCF/Femto/Core/femtoMath.h @@ -10,7 +10,7 @@ // or submit itself to any jurisdiction. /// \file femtoMath.h -/// \brief shared kinematic math (kstar, Q3, mt, kt, spherical-harmonics kinematics, ...) +/// \brief shared kinematic math (kstar, Q3, mt, kt, spherical-harmonics and helicity kinematics, ...) /// used by the pair and triplet histogram managers /// \author Anton Riedel, TU München, anton.riedel@tum.de @@ -24,6 +24,7 @@ #include #include +#include #include // IWYU pragma: keep (do not replace with Math/Vector3Dfwd.h) #include #include // IWYU pragma: keep (do not replace with Math/Vector4Dfwd.h) @@ -313,6 +314,23 @@ inline float getQ3(ROOT::Math::PtEtaPhiMVector const& part1, ROOT::Math::PtEtaPh return static_cast(std::sqrt(std::max(0.0, -q))); } +/// Boost particles from LAB Frame to Pair Rest Frame (for helicity analysis in the lambda decay) +template +ROOT::Math::PxPyPzMVector boostPositiveDaughterToRestFrame(T1 const& posDaughter, T2 const& negDaughter, double posMass, double negMass) +{ + const ROOT::Math::PtEtaPhiMVector pos(posDaughter.pt(), posDaughter.eta(), posDaughter.phi(), posMass); + const ROOT::Math::PtEtaPhiMVector neg(negDaughter.pt(), negDaughter.eta(), negDaughter.phi(), negMass); + const ROOT::Math::PtEtaPhiMVector v0Momentum = pos + neg; + const double beta = v0Momentum.Beta(); + const double betax = beta * std::cos(v0Momentum.Phi()) * std::sin(v0Momentum.Theta()); + const double betay = beta * std::sin(v0Momentum.Phi()) * std::sin(v0Momentum.Theta()); + const double betaz = beta * std::cos(v0Momentum.Theta()); + ROOT::Math::PxPyPzMVector posRestFrame(pos); + const ROOT::Math::Boost boost(-betax, -betay, -betaz); + posRestFrame = boost(posRestFrame); + return posRestFrame; +} + } // namespace o2::analysis::femto::femtomath #endif // PWGCF_FEMTO_CORE_FEMTOMATH_H_ diff --git a/PWGCF/Femto/Core/pairBuilder.h b/PWGCF/Femto/Core/pairBuilder.h index 1bcc34dd311..f71cb6d350e 100644 --- a/PWGCF/Femto/Core/pairBuilder.h +++ b/PWGCF/Femto/Core/pairBuilder.h @@ -1319,7 +1319,8 @@ class PairTrackV0Builder std::map>& negDauHistSpec, std::map>& pairHistSpec, std::map>& cprHistSpec, - std::map>& pairCleanerHistSpec) + std::map>& pairCleanerHistSpec, + pairhistmanager::ConfHelicity const* confHelicity = nullptr) { mColHistManagerSe.template init(registry, colHistSpec, confCollisionBinning); mColHistManagerMe.template init(registry, colHistSpec, confCollisionBinning); @@ -1347,12 +1348,12 @@ class PairTrackV0Builder } } - mPairHistManagerSe.template init(registry, pairHistSpec, confPairBinning, confPairCuts, confMixing); + mPairHistManagerSe.template init(registry, pairHistSpec, confPairBinning, confPairCuts, confMixing, confHelicity); mPairHistManagerSe.setMass(confTrackSelection.pdgCodeAbs.value, 0, 0, confV0Selection.pdgCodeAbs.value, pdgCodePosDau, pdgCodeNegDau); mPairHistManagerSe.setCharge(confTrackSelection.chargeAbs.value, 1); mCprSe.init(registry, cprHistSpec, confCpr, confTrackSelection.chargeAbs.value); - mPairHistManagerMe.template init(registry, pairHistSpec, confPairBinning, confPairCuts, confMixing); + mPairHistManagerMe.template init(registry, pairHistSpec, confPairBinning, confPairCuts, confMixing, confHelicity); mPairHistManagerMe.setMass(confTrackSelection.pdgCodeAbs.value, 0, 0, confV0Selection.pdgCodeAbs.value, pdgCodePosDau, pdgCodeNegDau); mPairHistManagerMe.setCharge(confTrackSelection.chargeAbs.value, 1); mCprMe.init(registry, cprHistSpec, confCpr, confTrackSelection.chargeAbs.value); diff --git a/PWGCF/Femto/Core/pairHistManager.h b/PWGCF/Femto/Core/pairHistManager.h index 707411221c9..df3c9c5709a 100644 --- a/PWGCF/Femto/Core/pairHistManager.h +++ b/PWGCF/Femto/Core/pairHistManager.h @@ -33,6 +33,7 @@ #include // IWYU pragma: keep (do not replace with Math/Vector4Dfwd.h) #include #include +#include #include #include @@ -288,6 +289,25 @@ struct ConfPairCuts : o2::framework::ConfigurableGroup { o2::framework::Configurable kinematicVariable{"kinematicVariable", static_cast(modes::KinematicVariable::kKstar), "Type of kinematic variable (0->kstar, 1->kT, 2->mT) reported by the pair-cleaner kinematic plot"}; }; +// Helicity analysis +struct ConfHelicity : o2::framework::ConfigurableGroup { + static constexpr std::array helicityDirs = {"Hel1/", "Hel2/", "Hel3/", "Hel4/"}; + + o2::framework::Configurable mProcessHel1{"mProcessHel1", false, "Process pairs from Range 1 of the helicity angle"}; + o2::framework::Configurable mProcessHel2{"mProcessHel2", false, "Process pairs from Range 2 of the helicity angle"}; + o2::framework::Configurable mProcessHel3{"mProcessHel3", false, "Process pairs from Range 3 of the helicity angle"}; + o2::framework::Configurable mProcessHel4{"mProcessHel4", false, "Process pairs from Range 4 of the helicity angle"}; + + o2::framework::Configurable mHel1Max{"mHel1Max", 1.0, "Maximum cos(theta) for Range 1 of the helicity angle"}; + o2::framework::Configurable mHel1Min{"mHel1Min", 0.1, "Minimum cos(theta) for Range 1 of the helicity angle"}; + o2::framework::Configurable mHel2Max{"mHel2Max", 0.1, "Maximum cos(theta) for Range 2 of the helicity angle"}; + o2::framework::Configurable mHel2Min{"mHel2Min", -0.1, "Minimum cos(theta) for Range 2 of the helicity angle"}; + o2::framework::Configurable mHel3Max{"mHel3Max", -0.1, "Maximum cos(theta) for Range 3 of the helicity angle"}; + o2::framework::Configurable mHel3Min{"mHel3Min", -0.5, "Minimum cos(theta) for Range 3 of the helicity angle"}; + o2::framework::Configurable mHel4Max{"mHel4Max", -0.5, "Maximum cos(theta) for Range 4 of the helicity angle"}; + o2::framework::Configurable mHel4Min{"mHel4Min", -1.0, "Minimum cos(theta) for Range 4 of the helicity angle"}; +}; + // the enum gives the correct index in the array constexpr std::array, kPairHistogramLast> HistTable = { @@ -596,6 +616,12 @@ constexpr std::string_view AnalysisDir = "Analysis/"; constexpr std::string_view MixingQaDir = "MixingQA/"; constexpr std::string_view McDir = "MC/"; +// Helicity analysis +constexpr std::string_view Hel1 = "Hel1/"; +constexpr std::string_view Hel2 = "Hel2/"; +constexpr std::string_view Hel3 = "Hel3/"; +constexpr std::string_view Hel4 = "Hel4/"; + template @@ -610,7 +636,8 @@ class PairHistManager std::map> const& Specs, T1 const& ConfPairBinning, T2 const& ConfPairCuts, - T3 const& ConfMixing) + T3 const& ConfMixing, + ConfHelicity const* ConfHelicityConfig = nullptr) { mHistogramRegistry = registry; @@ -671,6 +698,24 @@ class PairHistManager mShKtSpec = {ConfPairBinning.shKtBins, "k_{T} (GeV/#it{c})"}; } + // Helicity-selected histograms + mProcessHel1 = false; + mProcessHel2 = false; + mProcessHel3 = false; + mProcessHel4 = false; + + if (ConfHelicityConfig) { + mProcessHel1 = ConfHelicityConfig->mProcessHel1.value; + mProcessHel2 = ConfHelicityConfig->mProcessHel2.value; + mProcessHel3 = ConfHelicityConfig->mProcessHel3.value; + mProcessHel4 = ConfHelicityConfig->mProcessHel4.value; + + mHelicityMin = {ConfHelicityConfig->mHel1Min.value, ConfHelicityConfig->mHel2Min.value, ConfHelicityConfig->mHel3Min.value, ConfHelicityConfig->mHel4Min.value}; + mHelicityMax = {ConfHelicityConfig->mHel1Max.value, ConfHelicityConfig->mHel2Max.value, ConfHelicityConfig->mHel3Max.value, ConfHelicityConfig->mHel4Max.value}; + } + + mPlotHelicity = mProcessHel1 || mProcessHel2 || mProcessHel3 || mProcessHel4; + // transverse mass type mMtType = static_cast(ConfPairBinning.transverseMassType.value); @@ -896,6 +941,7 @@ class PairHistManager } if constexpr (isFlagSet(mode, modes::Mode::kReco)) { fillAnalysis(); + fillHelicityAnalysis(); } if constexpr (isFlagSet(mode, modes::Mode::kReco) && isFlagSet(mode, modes::Mode::kMc)) { fillMc(); @@ -979,6 +1025,11 @@ class PairHistManager } private: + std::array, 4> mHelicityHistograms1D; + std::array, 4> mHelicityHistograms2D; + std::array mHelicityMin = {0.1, -0.1, -0.5, -1.0}; + std::array mHelicityMax = {1.0, 0.1, -0.1, -0.5}; + void initAnalysis(std::map> const& Specs) { std::string analysisDir = std::string(prefix) + std::string(AnalysisDir); @@ -987,6 +1038,17 @@ class PairHistManager mHistogramRegistry->add(analysisDir + getHistNameV2(kKt, HistTable), getHistDesc(kKt, HistTable), getHistType(kKt, HistTable), {Specs.at(kKt)}); mHistogramRegistry->add(analysisDir + getHistNameV2(kMt, HistTable), getHistDesc(kMt, HistTable), getHistType(kMt, HistTable), {Specs.at(kMt)}); mHistogramRegistry->add(analysisDir + getHistNameV2(kMinv, HistTable), getHistDesc(kMinv, HistTable), getHistType(kMinv, HistTable), {Specs.at(kMinv)}); + + if (mPlotHelicity) { + for (size_t i = 0; i < ConfHelicity::helicityDirs.size(); ++i) { + std::string helicityDir = analysisDir + ConfHelicity::helicityDirs[i]; + + mHelicityHistograms1D[i][kKstar] = mHistogramRegistry->add(helicityDir + getHistNameV2(kKstar, HistTable), getHistDesc(kKstar, HistTable), getHistType(kKstar, HistTable), {Specs.at(kKstar)}); + mHelicityHistograms1D[i][kKt] = mHistogramRegistry->add(helicityDir + getHistNameV2(kKt, HistTable), getHistDesc(kKt, HistTable), getHistType(kKt, HistTable), {Specs.at(kKt)}); + mHelicityHistograms1D[i][kMt] = mHistogramRegistry->add(helicityDir + getHistNameV2(kMt, HistTable), getHistDesc(kMt, HistTable), getHistType(kMt, HistTable), {Specs.at(kMt)}); + mHelicityHistograms1D[i][kMinv] = mHistogramRegistry->add(helicityDir + getHistNameV2(kMinv, HistTable), getHistDesc(kMinv, HistTable), getHistType(kMinv, HistTable), {Specs.at(kMinv)}); + } + } } if (mPlot2d) { mHistogramRegistry->add(analysisDir + getHistNameV2(kPt1VsPt2, HistTable), getHistDesc(kPt1VsPt2, HistTable), getHistType(kPt1VsPt2, HistTable), {Specs.at(kPt1VsPt2)}); @@ -1008,6 +1070,32 @@ class PairHistManager mHistogramRegistry->add(analysisDir + getHistNameV2(kKstarVsMinv, HistTable), getHistDesc(kKstarVsMinv, HistTable), getHistType(kKstarVsMinv, HistTable), {Specs.at(kKstarVsMinv)}); mHistogramRegistry->add(analysisDir + getHistNameV2(kPt1VsMinv, HistTable), getHistDesc(kPt1VsMinv, HistTable), getHistType(kPt1VsMinv, HistTable), {Specs.at(kPt1VsMinv)}); mHistogramRegistry->add(analysisDir + getHistNameV2(kPt2VsMinv, HistTable), getHistDesc(kPt2VsMinv, HistTable), getHistType(kPt2VsMinv, HistTable), {Specs.at(kPt2VsMinv)}); + + if (mPlotHelicity) { + for (size_t i = 0; i < ConfHelicity::helicityDirs.size(); ++i) { + std::string helicityDir = analysisDir + ConfHelicity::helicityDirs[i]; + + mHelicityHistograms2D[i][kPt1VsPt2] = mHistogramRegistry->add(helicityDir + getHistNameV2(kPt1VsPt2, HistTable), getHistDesc(kPt1VsPt2, HistTable), getHistType(kPt1VsPt2, HistTable), {Specs.at(kPt1VsPt2)}); + mHelicityHistograms2D[i][kPt1VsKstar] = mHistogramRegistry->add(helicityDir + getHistNameV2(kPt1VsKstar, HistTable), getHistDesc(kPt1VsKstar, HistTable), getHistType(kPt1VsKstar, HistTable), {Specs.at(kPt1VsKstar)}); + mHelicityHistograms2D[i][kPt2VsKstar] = mHistogramRegistry->add(helicityDir + getHistNameV2(kPt2VsKstar, HistTable), getHistDesc(kPt2VsKstar, HistTable), getHistType(kPt2VsKstar, HistTable), {Specs.at(kPt2VsKstar)}); + mHelicityHistograms2D[i][kPt1VsKt] = mHistogramRegistry->add(helicityDir + getHistNameV2(kPt1VsKt, HistTable), getHistDesc(kPt1VsKt, HistTable), getHistType(kPt1VsKt, HistTable), {Specs.at(kPt1VsKt)}); + mHelicityHistograms2D[i][kPt2VsKt] = mHistogramRegistry->add(helicityDir + getHistNameV2(kPt2VsKt, HistTable), getHistDesc(kPt2VsKt, HistTable), getHistType(kPt2VsKt, HistTable), {Specs.at(kPt2VsKt)}); + mHelicityHistograms2D[i][kPt1VsMt] = mHistogramRegistry->add(helicityDir + getHistNameV2(kPt1VsMt, HistTable), getHistDesc(kPt1VsMt, HistTable), getHistType(kPt1VsMt, HistTable), {Specs.at(kPt1VsMt)}); + mHelicityHistograms2D[i][kPt2VsMt] = mHistogramRegistry->add(helicityDir + getHistNameV2(kPt2VsMt, HistTable), getHistDesc(kPt2VsMt, HistTable), getHistType(kPt2VsMt, HistTable), {Specs.at(kPt2VsMt)}); + + mHelicityHistograms2D[i][kKstarVsKt] = mHistogramRegistry->add(helicityDir + getHistNameV2(kKstarVsKt, HistTable), getHistDesc(kKstarVsKt, HistTable), getHistType(kKstarVsKt, HistTable), {Specs.at(kKstarVsKt)}); + mHelicityHistograms2D[i][kKstarVsMt] = mHistogramRegistry->add(helicityDir + getHistNameV2(kKstarVsMt, HistTable), getHistDesc(kKstarVsMt, HistTable), getHistType(kKstarVsMt, HistTable), {Specs.at(kKstarVsMt)}); + mHelicityHistograms2D[i][kKstarVsMult] = mHistogramRegistry->add(helicityDir + getHistNameV2(kKstarVsMult, HistTable), getHistDesc(kKstarVsMult, HistTable), getHistType(kKstarVsMult, HistTable), {Specs.at(kKstarVsMult)}); + mHelicityHistograms2D[i][kKstarVsCent] = mHistogramRegistry->add(helicityDir + getHistNameV2(kKstarVsCent, HistTable), getHistDesc(kKstarVsCent, HistTable), getHistType(kKstarVsCent, HistTable), {Specs.at(kKstarVsCent)}); + mHelicityHistograms2D[i][kKstarVsMass1] = mHistogramRegistry->add(helicityDir + getHistNameV2(kKstarVsMass1, HistTable), getHistDesc(kKstarVsMass1, HistTable), getHistType(kKstarVsMass1, HistTable), {Specs.at(kKstarVsMass1)}); + mHelicityHistograms2D[i][kKstarVsMass2] = mHistogramRegistry->add(helicityDir + getHistNameV2(kKstarVsMass2, HistTable), getHistDesc(kKstarVsMass2, HistTable), getHistType(kKstarVsMass2, HistTable), {Specs.at(kKstarVsMass2)}); + mHelicityHistograms2D[i][kMass1VsMass2] = mHistogramRegistry->add(helicityDir + getHistNameV2(kMass1VsMass2, HistTable), getHistDesc(kMass1VsMass2, HistTable), getHistType(kMass1VsMass2, HistTable), {Specs.at(kMass1VsMass2)}); + + mHelicityHistograms2D[i][kKstarVsMinv] = mHistogramRegistry->add(helicityDir + getHistNameV2(kKstarVsMinv, HistTable), getHistDesc(kKstarVsMinv, HistTable), getHistType(kKstarVsMinv, HistTable), {Specs.at(kKstarVsMinv)}); + mHelicityHistograms2D[i][kPt1VsMinv] = mHistogramRegistry->add(helicityDir + getHistNameV2(kPt1VsMinv, HistTable), getHistDesc(kPt1VsMinv, HistTable), getHistType(kPt1VsMinv, HistTable), {Specs.at(kPt1VsMinv)}); + mHelicityHistograms2D[i][kPt2VsMinv] = mHistogramRegistry->add(helicityDir + getHistNameV2(kPt2VsMinv, HistTable), getHistDesc(kPt2VsMinv, HistTable), getHistType(kPt2VsMinv, HistTable), {Specs.at(kPt2VsMinv)}); + } + } } // higher dimensional histograms @@ -1332,6 +1420,16 @@ class PairHistManager mParticle1 = ROOT::Math::PtEtaPhiMVector(mAbsCharge1 * particle1.pt(), particle1.eta(), particle1.phi(), mass1); mParticle2 = ROOT::Math::PtEtaPhiMVector(mAbsCharge2 * particle2.pt(), particle2.eta(), particle2.phi(), mass2); + // Calculate the helicity angle in the lambda decay + if constexpr (requires(T2 p) { p.posDauId(); p.negDauId(); }) { + auto posDaughter = trackTable.rawIteratorAt(particle2.posDauId() - trackTable.offset()); + auto negDaughter = trackTable.rawIteratorAt(particle2.negDauId() - trackTable.offset()); + const auto protonRestFrame = femtomath::boostPositiveDaughterToRestFrame(posDaughter, negDaughter, mPdgMassPosDau2, mPdgMassNegDau2); + const double pLambda = particle2.p(); + const double pProtonRest = protonRestFrame.P(); + mCosTheta = (protonRestFrame.Px() * particle2.px() + protonRestFrame.Py() * particle2.py() + protonRestFrame.Pz() * particle2.pz()) / (pProtonRest * pLambda); + } + // set kT mKt = femtomath::getKt(mParticle1, mParticle2); @@ -1561,6 +1659,52 @@ class PairHistManager } } + int getHelicityRange() const + { + for (size_t i = 0; i < mHelicityMin.size(); ++i) { + if (mCosTheta >= mHelicityMin[i] && (mCosTheta < mHelicityMax[i] || (i == 3 && mCosTheta <= mHelicityMax[i]))) { + return i; + } + } + return -1; + } + + // Helicity analysis + void fillHelicityAnalysis() + { + const int helicityRange = getHelicityRange(); + if (helicityRange < 0) { + return; + } + + if (mPlot1d) { + std::get>(mHelicityHistograms1D[helicityRange].at(kKstar))->Fill(mKstar); + std::get>(mHelicityHistograms1D[helicityRange].at(kKt))->Fill(mKt); + std::get>(mHelicityHistograms1D[helicityRange].at(kMt))->Fill(mMt); + std::get>(mHelicityHistograms1D[helicityRange].at(kMinv))->Fill(mMassInv); + } + + if (mPlot2d) { + std::get>(mHelicityHistograms2D[helicityRange].at(kPt1VsPt2))->Fill(mParticle1.Pt(), mParticle2.Pt()); + std::get>(mHelicityHistograms2D[helicityRange].at(kPt1VsKstar))->Fill(mParticle1.Pt(), mKstar); + std::get>(mHelicityHistograms2D[helicityRange].at(kPt2VsKstar))->Fill(mParticle2.Pt(), mKstar); + std::get>(mHelicityHistograms2D[helicityRange].at(kPt1VsKt))->Fill(mParticle1.Pt(), mKt); + std::get>(mHelicityHistograms2D[helicityRange].at(kPt2VsKt))->Fill(mParticle2.Pt(), mKt); + std::get>(mHelicityHistograms2D[helicityRange].at(kPt1VsMt))->Fill(mParticle1.Pt(), mMt); + std::get>(mHelicityHistograms2D[helicityRange].at(kPt2VsMt))->Fill(mParticle2.Pt(), mMt); + std::get>(mHelicityHistograms2D[helicityRange].at(kKstarVsKt))->Fill(mKstar, mKt); + std::get>(mHelicityHistograms2D[helicityRange].at(kKstarVsMt))->Fill(mKstar, mMt); + std::get>(mHelicityHistograms2D[helicityRange].at(kKstarVsMult))->Fill(mKstar, mMult); + std::get>(mHelicityHistograms2D[helicityRange].at(kKstarVsCent))->Fill(mKstar, mCent); + std::get>(mHelicityHistograms2D[helicityRange].at(kKstarVsMass1))->Fill(mKstar, mRecoMass1); + std::get>(mHelicityHistograms2D[helicityRange].at(kKstarVsMass2))->Fill(mKstar, mRecoMass2); + std::get>(mHelicityHistograms2D[helicityRange].at(kMass1VsMass2))->Fill(mRecoMass1, mRecoMass2); + std::get>(mHelicityHistograms2D[helicityRange].at(kKstarVsMinv))->Fill(mKstar, mMassInv); + std::get>(mHelicityHistograms2D[helicityRange].at(kPt1VsMinv))->Fill(mParticle1.Pt(), mMassInv); + std::get>(mHelicityHistograms2D[helicityRange].at(kPt2VsMinv))->Fill(mParticle2.Pt(), mMassInv); + } + } + // reco-vs-truth correlation fill (kReco and kMc both set) void fillMc() { @@ -1776,6 +1920,14 @@ class PairHistManager o2::analysis::femto::SpherHarMath mYlm{}; + // Helicity analysis + bool mPlotHelicity = false; + bool mProcessHel1 = false; + bool mProcessHel2 = false; + bool mProcessHel3 = false; + bool mProcessHel4 = false; + double mCosTheta = 0.0; + // qa bool mPairCorrelationQa = false; bool mEventMixingQa = false; diff --git a/PWGCF/Femto/Core/v0HistManager.h b/PWGCF/Femto/Core/v0HistManager.h index 058edf2e6c8..c72133a4097 100644 --- a/PWGCF/Femto/Core/v0HistManager.h +++ b/PWGCF/Femto/Core/v0HistManager.h @@ -16,6 +16,7 @@ #ifndef PWGCF_FEMTO_CORE_V0HISTMANAGER_H_ #define PWGCF_FEMTO_CORE_V0HISTMANAGER_H_ +#include "PWGCF/Femto/Core/femtoMath.h" #include "PWGCF/Femto/Core/histManager.h" #include "PWGCF/Femto/Core/modes.h" #include "PWGCF/Femto/Core/trackHistManager.h" @@ -26,6 +27,7 @@ #include #include +#include #include #include @@ -48,6 +50,7 @@ enum V0Hist { kSign, kPtVsMass, // nice to have during analysis kFractionCpa, // fraction estimation: pt vs cosPa, binned independently of the QA cosPa axis + kPVsCosTheta, // for helicity analysis // qa variables kMassLambda, kMassAntiLambda, @@ -101,14 +104,16 @@ enum V0Hist { constexpr std::size_t MaxSecondary = 3; // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define V0_DEFAULT_BINNING(defaultMassMin, defaultMassMax) \ - o2::framework::ConfigurableAxis pt{"pt", {{600, 0, 6}}, "Pt"}; \ - o2::framework::ConfigurableAxis eta{"eta", {{300, -1.5, 1.5}}, "Eta"}; \ - o2::framework::ConfigurableAxis phi{"phi", {{720, 0, 1.f * o2::constants::math::TwoPI}}, "Phi"}; \ - o2::framework::ConfigurableAxis mass{"mass", {{200, (defaultMassMin), (defaultMassMax)}}, "Mass"}; \ - o2::framework::ConfigurableAxis sign{"sign", {{3, -1.5, 1.5}}, "Sign"}; \ - o2::framework::ConfigurableAxis pdgCodes{"pdgCodes", {{8001, -4000.5, 4000.5}}, "MC ONLY: PDG codes of reconstructed V0s"}; \ - o2::framework::ConfigurableAxis fractionCpa{"fractionCpa", {{100, 0.95, 1}}, "Cosine of pointing angle (fraction estimation)"}; +#define V0_DEFAULT_BINNING(defaultMassMin, defaultMassMax) \ + o2::framework::ConfigurableAxis pt{"pt", {{600, 0, 6}}, "Pt"}; \ + o2::framework::ConfigurableAxis eta{"eta", {{300, -1.5, 1.5}}, "Eta"}; \ + o2::framework::ConfigurableAxis phi{"phi", {{720, 0, 1.f * o2::constants::math::TwoPI}}, "Phi"}; \ + o2::framework::ConfigurableAxis mass{"mass", {{200, (defaultMassMin), (defaultMassMax)}}, "Mass"}; \ + o2::framework::ConfigurableAxis sign{"sign", {{3, -1.5, 1.5}}, "Sign"}; \ + o2::framework::ConfigurableAxis pdgCodes{"pdgCodes", {{8001, -4000.5, 4000.5}}, "MC ONLY: PDG codes of reconstructed V0s"}; \ + o2::framework::ConfigurableAxis fractionCpa{"fractionCpa", {{100, 0.95, 1}}, "Cosine of pointing angle (fraction estimation)"}; \ + o2::framework::ConfigurableAxis p{"p", {{600, 0, 6}}, "Momentum"}; \ + o2::framework::ConfigurableAxis cosTheta{"cosTheta", {{110, -1.1, 1.1}}, "CosTheta"}; template struct ConfLambdaBinning : o2::framework::ConfigurableGroup { @@ -167,6 +172,7 @@ constexpr std::array, kV0HistLast> HistTable = { {kSign, o2::framework::HistType::kTH1F, "hSign", "Sign (-1 -> antiparticle, 0 -> self conjugate, +1 -> particle); sign; Entries"}, {kPtVsMass, o2::framework::HistType::kTH2F, "hPtVsMass", "Transverse momentum vs invariant mass; p_{T} (GeV/#it{c}); m_{Inv} (GeV/#it{c}^{2})"}, {kFractionCpa, o2::framework::HistType::kTH2F, "hFractionCpa", "p_{T} vs Cosine of pointing angle (fraction estimation); p_{T} (GeV/#it{c}); cos(#alpha)"}, + {kPVsCosTheta, o2::framework::HistType::kTH2F, "hPVsCosTheta", "Lambda momentum vs cosine of the helicity angle; p (GeV/#it{c}); cos(#theta)"}, {kMassLambda, o2::framework::HistType::kTH1F, "hMassLambda", "#Lambda mass; m_{p#pi^{-}} (GeV/#it{c}^{2}); Entries"}, {kMassAntiLambda, o2::framework::HistType::kTH1F, "hMassAntiLambda", "#bar{#Lambda} mass; m_{#bar{p}#pi^{+}} (GeV/#it{c}^{2}); Entries"}, {kMassK0short, o2::framework::HistType::kTH1F, "hMassK0short", "K^{0}_{s} mass; m_{#pi^{+}#pi^{-}} (GeV/#it{c}^{2}); Entries"}, @@ -212,14 +218,15 @@ constexpr std::array, kV0HistLast> HistTable = { }; // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define V0_HIST_ANALYSIS_MAP(conf) \ - {kPt, {(conf).pt}}, \ - {kEta, {(conf).eta}}, \ - {kPhi, {(conf).phi}}, \ - {kMass, {(conf).mass}}, \ - {kSign, {(conf).sign}}, \ - {kPtVsMass, {(conf).pt, (conf).mass}}, \ - {kFractionCpa, {(conf).pt, (conf).fractionCpa}}, +#define V0_HIST_ANALYSIS_MAP(conf) \ + {kPt, {(conf).pt}}, \ + {kEta, {(conf).eta}}, \ + {kPhi, {(conf).phi}}, \ + {kMass, {(conf).mass}}, \ + {kSign, {(conf).sign}}, \ + {kPtVsMass, {(conf).pt, (conf).mass}}, \ + {kFractionCpa, {(conf).pt, (conf).fractionCpa}}, \ + {kPVsCosTheta, {(conf).p, (conf).cosTheta}}, // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define V0_HIST_MC_MAP(conf) \ @@ -379,6 +386,9 @@ class V0HistManager LOG(fatal) << "PDG code for V0 has to be either Lambda or K0short"; } + mPosDauMass = TDatabasePDG::Instance()->GetParticle(posDauPdgCodeAbs)->Mass(); + mNegDauMass = TDatabasePDG::Instance()->GetParticle(negDauPdgCodeAbs)->Mass(); + mPosDauManager.template init(registry, PosDauSpecs, absCharge, signPlus, posDauPdgCodeAbs); mNegDauManager.template init(registry, NegDauSpecs, absCharge, signMinus, negDauPdgCodeAbs); @@ -456,7 +466,7 @@ class V0HistManager mNegDauManager.template fill(negDaughter, tracks); if constexpr (modes::isFlagSet(mode, modes::Mode::kReco)) { - this->fillAnalysis(v0candidate); + this->fillAnalysis(v0candidate, posDaughter, negDaughter); } if constexpr (modes::isFlagSet(mode, modes::Mode::kQa)) { this->fillQa(v0candidate, posDaughter, negDaughter); @@ -474,7 +484,7 @@ class V0HistManager auto negDaughter = tracks.rawIteratorAt(v0candidate.negDauId() - tracks.offset()); mNegDauManager.template fill(negDaughter, tracks, col, mcParticles, mcMothers, mcPartonicMothers); if constexpr (modes::isFlagSet(mode, modes::Mode::kReco)) { - this->fillAnalysis(v0candidate); + this->fillAnalysis(v0candidate, posDaughter, negDaughter); } if constexpr (modes::isFlagSet(mode, modes::Mode::kQa)) { this->fillQa(v0candidate, posDaughter, negDaughter); @@ -512,6 +522,12 @@ class V0HistManager mHistogramRegistry->add(analysisDir + getHistNameV2(kMass, HistTable), getHistDesc(kMass, HistTable), getHistType(kMass, HistTable), {V0Specs.at(kMass)}); mHistogramRegistry->add(analysisDir + getHistNameV2(kSign, HistTable), getHistDesc(kSign, HistTable), getHistType(kSign, HistTable), {V0Specs.at(kSign)}); mHistogramRegistry->add(analysisDir + getHistNameV2(kPtVsMass, HistTable), getHistDesc(kPtVsMass, HistTable), getHistType(kPtVsMass, HistTable), {V0Specs.at(kPtVsMass)}); + + if constexpr (modes::isEqual(v0, modes::V0::kLambda)) { + if (mPdgCode > 0) { + mHistogramRegistry->add(analysisDir + getHistNameV2(kPVsCosTheta, HistTable), getHistDesc(kPVsCosTheta, HistTable), getHistType(kPVsCosTheta, HistTable), {V0Specs.at(kPVsCosTheta)}); + } + } } void initQa(std::map> const& V0Specs) @@ -603,8 +619,8 @@ class V0HistManager } } - template - void fillAnalysis(T const& v0candidate) + template + void fillAnalysis(T1 const& v0candidate, T2 const& posDaughter, T3 const& negDaughter) { mHistogramRegistry->fill(HIST(v0Prefix) + HIST(AnalysisDir) + HIST(getHistName(kPt, HistTable)), v0candidate.pt()); mHistogramRegistry->fill(HIST(v0Prefix) + HIST(AnalysisDir) + HIST(getHistName(kEta, HistTable)), v0candidate.eta()); @@ -612,6 +628,20 @@ class V0HistManager mHistogramRegistry->fill(HIST(v0Prefix) + HIST(AnalysisDir) + HIST(getHistName(kMass, HistTable)), v0candidate.mass()); mHistogramRegistry->fill(HIST(v0Prefix) + HIST(AnalysisDir) + HIST(getHistName(kPtVsMass, HistTable)), v0candidate.pt(), v0candidate.mass()); + if constexpr (modes::isEqual(v0, modes::V0::kLambda)) { + if (mPdgCode > 0) { + const auto protonRestFrame = femtomath::boostPositiveDaughterToRestFrame(posDaughter, negDaughter, mPosDauMass, mNegDauMass); + + const double pLambda = v0candidate.p(); + const double pProtonRest = protonRestFrame.P(); + + if (pLambda > 0.0 && pProtonRest > 0.0) { + double cosTheta = (protonRestFrame.Px() * v0candidate.px() + protonRestFrame.Py() * v0candidate.py() + protonRestFrame.Pz() * v0candidate.pz()) / (pProtonRest * pLambda); + mHistogramRegistry->fill(HIST(v0Prefix) + HIST(AnalysisDir) + HIST(getHistName(kPVsCosTheta, HistTable)), pLambda, cosTheta); + } + } + } + if constexpr (modes::isEqual(v0, modes::V0::kLambda) || modes::isEqual(v0, modes::V0::kAntiLambda)) { mHistogramRegistry->fill(HIST(v0Prefix) + HIST(AnalysisDir) + HIST(getHistName(kSign, HistTable)), v0candidate.sign()); } @@ -796,6 +826,9 @@ class V0HistManager trackhistmanager::TrackHistManager mPosDauManager; trackhistmanager::TrackHistManager mNegDauManager; + + double mPosDauMass = 0.0; + double mNegDauMass = 0.0; }; }; // namespace o2::analysis::femto::v0histmanager #endif // PWGCF_FEMTO_CORE_V0HISTMANAGER_H_ diff --git a/PWGCF/Femto/Tasks/CMakeLists.txt b/PWGCF/Femto/Tasks/CMakeLists.txt index 1f9647bd7b2..c72918fa888 100644 --- a/PWGCF/Femto/Tasks/CMakeLists.txt +++ b/PWGCF/Femto/Tasks/CMakeLists.txt @@ -64,6 +64,11 @@ o2physics_add_dpl_workflow(femto-pair-track-v0 PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(femto-pair-track-v0-helicity + SOURCES femtoPairTrackV0Helicity.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(femto-pair-track-charm-hadron SOURCES femtoPairTrackCharmHadron.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore @@ -98,7 +103,7 @@ o2physics_add_dpl_workflow(femto-pair-track-cascade SOURCES femtoPairTrackCascade.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) -# + o2physics_add_dpl_workflow(femto-pair-track-kink SOURCES femtoPairTrackKink.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore diff --git a/PWGCF/Femto/Tasks/femtoPairTrackV0Helicity.cxx b/PWGCF/Femto/Tasks/femtoPairTrackV0Helicity.cxx new file mode 100644 index 00000000000..16f962d5606 --- /dev/null +++ b/PWGCF/Femto/Tasks/femtoPairTrackV0Helicity.cxx @@ -0,0 +1,427 @@ +// Copyright 2019-2025 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file femtoPairTrackV0Helicity.cxx +/// \brief Tasks that computes correlation between tracks and v0s +/// \author Anton Riedel, TU München, anton.riedel@cern.ch +/// \author Anna-Mariia Andrushko, Warsaw University of Technology, anna-mariia.andrushko@cern.ch + +#include "PWGCF/Femto/Core/closePairRejection.h" +#include "PWGCF/Femto/Core/collisionBuilder.h" +#include "PWGCF/Femto/Core/collisionHistManager.h" +#include "PWGCF/Femto/Core/collisionTagger.h" +#include "PWGCF/Femto/Core/dataTypes.h" +#include "PWGCF/Femto/Core/modes.h" +#include "PWGCF/Femto/Core/pairBuilder.h" +#include "PWGCF/Femto/Core/pairCleaner.h" +#include "PWGCF/Femto/Core/pairHistManager.h" +#include "PWGCF/Femto/Core/particleCleaner.h" +#include "PWGCF/Femto/Core/partitions.h" +#include "PWGCF/Femto/Core/trackBuilder.h" +#include "PWGCF/Femto/Core/trackHistManager.h" +#include "PWGCF/Femto/Core/v0Builder.h" +#include "PWGCF/Femto/Core/v0HistManager.h" +#include "PWGCF/Femto/DataModel/FemtoTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +using namespace o2::analysis::femto; + +struct FemtoPairTrackV0Helicity { + + // setup tables + using FemtoCollisions = o2::soa::Join; + using FilteredFemtoCollisions = o2::soa::Filtered; + using FilteredFemtoCollision = FilteredFemtoCollisions::iterator; + + using FemtoCollisionsWithLabel = o2::soa::Join; + using FilteredFemtoCollisionsWithLabel = o2::soa::Filtered; + using FilteredFemtoCollisionWithLabel = FilteredFemtoCollisionsWithLabel::iterator; + + // opt-in: carries FColTags (see TableProducer/femtoProducerCollisionTagger.cxx), only needed by + // processLambdaMixedEventWithTagging/processK0shortMixedEventWithTagging -- same + // collisionFilter auto-apply reasoning as in femtoPairTrackTrack.cxx. + using FemtoCollisionsWithTags = o2::soa::Join; + using FilteredFemtoCollisionsWithTags = o2::soa::Filtered; + + // opt-in: carries both FColLabels and FColTags, for the processXxxMixedEventMcWithTagging + // functions below -- same collisionFilter auto-apply reasoning as FemtoCollisionsWithTags above. + using FemtoCollisionsWithLabelAndTags = o2::soa::Join; + using FilteredFemtoCollisionsWithLabelAndTags = o2::soa::Filtered; + + using FemtoTracks = o2::soa::Join; + using FemtoLambdas = o2::soa::Join; + using FemtoK0shorts = o2::soa::Join; + + using FemtoTracksWithLabel = o2::soa::Join; + using FemtoLambdasWithLabel = o2::soa::Join; + using FemtoK0shortsWithLabel = o2::soa::Join; + + // reco-only + FitVars (no MC labels, but carries the opt-in purity/fraction tables) + using FemtoTracksWithFitVars = o2::soa::Join; + using FemtoLambdasWithFitVars = o2::soa::Join; + using FemtoK0shortsWithFitVars = o2::soa::Join; + + using FemtoMcParticlesWithLabel = o2::soa::Join; + + o2::framework::SliceCache cache; + + // setup collisions + collisionbuilder::ConfCollisionSelection collisionSelection; + o2::framework::expressions::Filter collisionFilter = MAKE_COLLISION_FILTER(collisionSelection); + colhistmanager::ConfCollisionBinning confCollisionBinning; + + // opt-in, only needed by processLambdaMixedEventWithTagging/processK0shortMixedEventWithTagging + // -- two separate instances since Lambda and K0short are tagged independently (see init()) and + // each gets its own tag bit. + collisiontagger::ConfTagging confTaggingLambda; + collisiontagger::ConfTagging confTaggingK0short; + + // setup tracks + trackbuilder::ConfTrackSelection1 confTrackSelection; + trackhistmanager::ConfTrackBinning1 confTrackBinning; + particlecleaner::ConfTrackCleaner1 confTrackCleaner; + + o2::framework::Partition trackPartition = MAKE_TRACK_PARTITION(confTrackSelection); + o2::framework::Preslice perColTracks = o2::aod::femtobase::stored::fColId; + + o2::framework::Partition trackWithLabelPartition = MAKE_TRACK_PARTITION(confTrackSelection); + o2::framework::Preslice perColtracksWithLabel = o2::aod::femtobase::stored::fColId; + + o2::framework::Partition trackWithFitVarsPartition = MAKE_TRACK_PARTITION(confTrackSelection); + o2::framework::Preslice perColTracksWithFitVars = o2::aod::femtobase::stored::fColId; + + // setup for daughters + trackhistmanager::ConfV01PosDauBinning confPosDauBinning; + trackhistmanager::ConfV01NegDauBinning confNegDauBinning; + + // setup lambdas + v0builder::ConfLambdaSelection1 lambdaSelection; + v0histmanager::ConfLambdaBinning1 confLambdaBinning; + particlecleaner::ConfLambdaCleaner1 confLambdaCleaner; + + o2::framework::Partition lambdaPartition = MAKE_LAMBDA_PARTITION(lambdaSelection); + o2::framework::Preslice perColLambdas = o2::aod::femtobase::stored::fColId; + + o2::framework::Partition lambdaWithLabelPartition = MAKE_LAMBDA_PARTITION(lambdaSelection); + o2::framework::Preslice perColLambdasWithLabel = o2::aod::femtobase::stored::fColId; + + o2::framework::Partition lambdaWithFitVarsPartition = MAKE_LAMBDA_PARTITION(lambdaSelection); + o2::framework::Preslice perColLambdasWithFitVars = o2::aod::femtobase::stored::fColId; + + // setup k0shorts + v0builder::ConfK0shortSelection1 k0shortSelection; + v0histmanager::ConfK0shortBinning1 confK0shortBinning; + particlecleaner::ConfK0shortCleaner1 confK0shortCleaner; + + o2::framework::Partition k0shortPartition = MAKE_K0SHORT_PARTITION(k0shortSelection); + o2::framework::Preslice perColk0shorts = o2::aod::femtobase::stored::fColId; + + o2::framework::Partition k0shortWithLabelPartition = MAKE_K0SHORT_PARTITION(k0shortSelection); + o2::framework::Preslice perColk0shortsWithLabel = o2::aod::femtobase::stored::fColId; + + o2::framework::Partition k0shortWithFitVarsPartition = MAKE_K0SHORT_PARTITION(k0shortSelection); + o2::framework::Preslice perColk0shortsWithFitVars = o2::aod::femtobase::stored::fColId; + + // setup pairs + pairhistmanager::ConfPairBinning confPairBinning; + pairhistmanager::ConfPairCuts confPairCuts; + pairhistmanager::ConfHelicity confHelicity; + paircleaner::ConfPairCleanerBinning confPairCleaner; + + pairbuilder::PairTrackV0Builder< + trackhistmanager::PrefixTrack1Se, + v0histmanager::PrefixLambda1Se, + trackhistmanager::PrefixV01PosDaughterSe, + trackhistmanager::PrefixV01NegDaughterSe, + trackhistmanager::PrefixTrack1Me, + v0histmanager::PrefixLambda1Me, + trackhistmanager::PrefixV01PosDaughterMe, + trackhistmanager::PrefixV01NegDaughterMe, + pairhistmanager::PrefixTrackV0Se, + pairhistmanager::PrefixTrackV0Me, + closepairrejection::PrefixTrackV0DaughterSe, + closepairrejection::PrefixTrackV0DaughterMe, + modes::V0::kLambda> + pairTrackLambdaBuilder; + + pairbuilder::PairTrackV0Builder< + trackhistmanager::PrefixTrack1Se, + v0histmanager::PrefixK0short1Se, + trackhistmanager::PrefixV01PosDaughterSe, + trackhistmanager::PrefixV01NegDaughterSe, + trackhistmanager::PrefixTrack1Me, + v0histmanager::PrefixK0short1Me, + trackhistmanager::PrefixV01PosDaughterMe, + trackhistmanager::PrefixV01NegDaughterMe, + pairhistmanager::PrefixTrackV0Se, + pairhistmanager::PrefixTrackV0Me, + closepairrejection::PrefixTrackV0DaughterSe, + closepairrejection::PrefixTrackV0DaughterMe, + modes::V0::kK0short> + pairTrackK0shortBuilder; + + // setup mixing + std::vector defaultVtxBins{10, -10, 10}; + std::vector defaultMultBins{50, 0, 200}; + std::vector defaultCentBins{10, 0, 100}; + o2::framework::ColumnBinningPolicy mixBinsVtxMult{{defaultVtxBins, defaultMultBins}}; + o2::framework::ColumnBinningPolicy mixBinsVtxCent{{defaultVtxBins, defaultCentBins}}; + o2::framework::ColumnBinningPolicy mixBinsVtxMultCent{{defaultVtxBins, defaultMultBins, defaultCentBins}}; + pairhistmanager::ConfMixing confMixing; + + o2::framework::HistogramRegistry hRegistry{"FemtoTrackV0", {}, o2::framework::OutputObjHandlingPolicy::AnalysisObject}; + + // setup cpr + closepairrejection::ConfCprTrackV0Daughter confCpr; + + void init(o2::framework::InitContext& context) + { + bool processData = doprocessLambdaSameEvent || doprocessLambdaMixedEvent || doprocessK0shortSameEvent || doprocessK0shortMixedEvent || doprocessLambdaMixedEventWithTagging || doprocessK0shortMixedEventWithTagging; + bool processFitVars = doprocessLambdaSameEventWithFitVars || doprocessLambdaMixedEventWithFitVars || doprocessK0shortSameEventWithFitVars || doprocessK0shortMixedEventWithFitVars; + bool processMc = doprocessLambdaSameEventMc || doprocessLambdaMixedEventMc || doprocessK0shortSameEventMc || doprocessK0shortMixedEventMc || doprocessLambdaMixedEventMcWithTagging || doprocessK0shortMixedEventMcWithTagging; + + if (static_cast(processData) + static_cast(processFitVars) + static_cast(processMc) > 1) { + LOG(fatal) << "More than one of data, FitVars or mc processing is activated. Breaking..."; + } + + bool processLambda = doprocessLambdaSameEvent || doprocessLambdaSameEventWithFitVars || doprocessLambdaSameEventMc || doprocessLambdaMixedEvent || doprocessLambdaMixedEventWithFitVars || doprocessLambdaMixedEventMc || doprocessLambdaMixedEventWithTagging || doprocessLambdaMixedEventMcWithTagging; + bool processK0short = doprocessK0shortSameEvent || doprocessK0shortSameEventWithFitVars || doprocessK0shortSameEventMc || doprocessK0shortMixedEvent || doprocessK0shortMixedEventWithFitVars || doprocessK0shortMixedEventMc || doprocessK0shortMixedEventWithTagging || doprocessK0shortMixedEventMcWithTagging; + + if (processLambda && processK0short) { + LOG(fatal) << "Both lambda-track and k0short-track processing is enabled. Breaking..."; + } + + // Each species discovers its own tag bit independently (see Core/collisionTagger.h): + // same-event-only for one species and tagged-mixed-event for the other is a legitimate + // combination, so neither discovery is gated on the other's process switch. + if (doprocessLambdaMixedEventWithTagging || doprocessK0shortMixedEventWithTagging || doprocessLambdaMixedEventMcWithTagging || doprocessK0shortMixedEventMcWithTagging) { + auto const& workflows = context.services().get(); + auto const& ownDevice = context.services().get(); + auto roles = collisiontagger::discoverTaggedRoles(workflows); + if (doprocessLambdaMixedEventWithTagging || doprocessLambdaMixedEventMcWithTagging) { + int bit = collisiontagger::findOwnBit(roles, ownDevice.name, confTaggingLambda.Role); + if (bit < 0) { + LOG(fatal) << "A processLambdaMixedEventWithTagging* function is enabled, but no femto-collision-tagger " + << "device (with processTrackV0 enabled) tagging this device (" << ownDevice.name + << ") was found in this workflow."; + } + confTaggingLambda.internalTagMask.value = static_cast(1) << bit; + LOG(info) << "Collision tagger bit for " << ownDevice.name << " (Lambda): " << bit; + } + if (doprocessK0shortMixedEventWithTagging || doprocessK0shortMixedEventMcWithTagging) { + int bit = collisiontagger::findOwnBit(roles, ownDevice.name, confTaggingK0short.Role); + if (bit < 0) { + LOG(fatal) << "A processK0shortMixedEventWithTagging* function is enabled, but no femto-collision-tagger " + << "device (with processTrackV0 enabled) tagging this device (" << ownDevice.name + << ") was found in this workflow."; + } + confTaggingK0short.internalTagMask.value = static_cast(1) << bit; + LOG(info) << "Collision tagger bit for " << ownDevice.name << " (K0short): " << bit; + } + } + + // setup columnpolicy for binning + // default values are used during instantiation, so we need to explicity update them here + mixBinsVtxMult = {{confMixing.vtxBins.value, confMixing.multBins.value}}; + mixBinsVtxCent = {{confMixing.vtxBins.value, confMixing.centBins.value}}; + mixBinsVtxMultCent = {{confMixing.vtxBins.value, confMixing.multBins.value, confMixing.centBins.value}}; + + std::map> colHistSpec; + std::map> trackHistSpec; + std::map> posDauSpec; + std::map> negDauSpec; + std::map> lambdaHistSpec; + std::map> k0shortHistSpec; + std::map> pairTrackV0HistSpec; + std::map> cprHistSpec = closepairrejection::makeCprHistSpecMap(confCpr); + std::map> pairCleanerHistSpec = paircleaner::makePairCleanerHistSpecMap(confPairCleaner); + + if (processFitVars) { + colHistSpec = colhistmanager::makeColHistSpecMap(confCollisionBinning); + trackHistSpec = trackhistmanager::makeTrackHistSpecMap(confTrackBinning); + posDauSpec = trackhistmanager::makeTrackHistSpecMap(confPosDauBinning); + negDauSpec = trackhistmanager::makeTrackHistSpecMap(confNegDauBinning); + pairTrackV0HistSpec = pairhistmanager::makePairHistSpecMap(confPairBinning, confMixing); + if (processLambda) { + lambdaHistSpec = v0histmanager::makeV0HistSpecMap(confLambdaBinning); + pairTrackLambdaBuilder.init(&hRegistry, confCollisionBinning, confTrackSelection, confTrackCleaner, lambdaSelection, confLambdaCleaner, confCpr, confMixing, confPairBinning, confPairCuts, colHistSpec, trackHistSpec, lambdaHistSpec, posDauSpec, negDauSpec, pairTrackV0HistSpec, cprHistSpec, pairCleanerHistSpec); + } else { + k0shortHistSpec = v0histmanager::makeV0HistSpecMap(confK0shortBinning); + pairTrackK0shortBuilder.init(&hRegistry, confCollisionBinning, confTrackSelection, confTrackCleaner, k0shortSelection, confK0shortCleaner, confCpr, confMixing, confPairBinning, confPairCuts, colHistSpec, trackHistSpec, k0shortHistSpec, posDauSpec, negDauSpec, pairTrackV0HistSpec, cprHistSpec, pairCleanerHistSpec); + } + } else if (processData) { + colHistSpec = colhistmanager::makeColHistSpecMap(confCollisionBinning); + trackHistSpec = trackhistmanager::makeTrackHistSpecMap(confTrackBinning); + posDauSpec = trackhistmanager::makeTrackHistSpecMap(confPosDauBinning); + negDauSpec = trackhistmanager::makeTrackHistSpecMap(confNegDauBinning); + pairTrackV0HistSpec = pairhistmanager::makePairHistSpecMap(confPairBinning, confMixing); + if (processLambda) { + lambdaHistSpec = v0histmanager::makeV0HistSpecMap(confLambdaBinning); + pairTrackLambdaBuilder.init(&hRegistry, confCollisionBinning, confTrackSelection, confTrackCleaner, lambdaSelection, confLambdaCleaner, confCpr, confMixing, confPairBinning, confPairCuts, colHistSpec, trackHistSpec, lambdaHistSpec, posDauSpec, negDauSpec, pairTrackV0HistSpec, cprHistSpec, pairCleanerHistSpec, &confHelicity); + } else { + k0shortHistSpec = v0histmanager::makeV0HistSpecMap(confK0shortBinning); + pairTrackK0shortBuilder.init(&hRegistry, confCollisionBinning, confTrackSelection, confTrackCleaner, k0shortSelection, confK0shortCleaner, confCpr, confMixing, confPairBinning, confPairCuts, colHistSpec, trackHistSpec, k0shortHistSpec, posDauSpec, negDauSpec, pairTrackV0HistSpec, cprHistSpec, pairCleanerHistSpec); + } + } else { + colHistSpec = colhistmanager::makeColMcHistSpecMap(confCollisionBinning); + trackHistSpec = trackhistmanager::makeTrackMcHistSpecMap(confTrackBinning); + posDauSpec = trackhistmanager::makeTrackMcHistSpecMap(confPosDauBinning); + negDauSpec = trackhistmanager::makeTrackMcHistSpecMap(confNegDauBinning); + pairTrackV0HistSpec = pairhistmanager::makePairMcHistSpecMap(confPairBinning, confMixing); + if (processLambda) { + lambdaHistSpec = v0histmanager::makeV0McHistSpecMap(confLambdaBinning); + pairTrackLambdaBuilder.init(&hRegistry, confCollisionBinning, confTrackSelection, confTrackCleaner, lambdaSelection, confLambdaCleaner, confCpr, confMixing, confPairBinning, confPairCuts, colHistSpec, trackHistSpec, lambdaHistSpec, posDauSpec, negDauSpec, pairTrackV0HistSpec, cprHistSpec, pairCleanerHistSpec, &confHelicity); + } else { + k0shortHistSpec = v0histmanager::makeV0McHistSpecMap(confK0shortBinning); + pairTrackK0shortBuilder.init(&hRegistry, confCollisionBinning, confTrackSelection, confTrackCleaner, k0shortSelection, confK0shortCleaner, confCpr, confMixing, confPairBinning, confPairCuts, colHistSpec, trackHistSpec, k0shortHistSpec, posDauSpec, negDauSpec, pairTrackV0HistSpec, cprHistSpec, pairCleanerHistSpec); + } + } + hRegistry.print(); + }; + + void processLambdaSameEvent(FilteredFemtoCollision const& col, FemtoTracks const& tracks, FemtoLambdas const& lambdas) + { + pairTrackLambdaBuilder.processSameEvent(col, tracks, trackPartition, lambdas, lambdaPartition, cache); + } + PROCESS_SWITCH(FemtoPairTrackV0Helicity, processLambdaSameEvent, "Enable processing same event processing for tracks and lambdas", true); + + void processLambdaSameEventMc(FilteredFemtoCollisionWithLabel const& col, o2::aod::FMcCols const& mcCols, FemtoTracksWithLabel const& tracks, FemtoLambdasWithLabel const& lambdas, FemtoMcParticlesWithLabel const& mcParticles, o2::aod::FMcMothers const& mcMothers, o2::aod::FMcPartMoths const& mcPartonicMothers) + { + pairTrackLambdaBuilder.processSameEvent(col, mcCols, tracks, trackWithLabelPartition, lambdas, lambdaWithLabelPartition, mcParticles, mcMothers, mcPartonicMothers, cache); + } + PROCESS_SWITCH(FemtoPairTrackV0Helicity, processLambdaSameEventMc, "Enable processing same event processing for tracks and lambdas with MC information", false); + + // Opt-in counterpart of processLambdaMixedEvent() below -- same "Partition declared and bound + // inside process()" idiom as femtoPairTrackTrack.cxx's processMixedEventWithTagging. Requires a + // femto-collision-tagger device (processTrackV0 enabled) in the same workflow -- see init(). + void processLambdaMixedEventWithTagging(FilteredFemtoCollisionsWithTags const& cols, FemtoTracks const& tracks, FemtoLambdas const& /*lambas*/) + { + o2::framework::Partition taggedCollisions = ncheckbit(o2::aod::femtocollisions::collisionTag, confTaggingLambda.internalTagMask); + taggedCollisions.bindTable(cols); + pairTrackLambdaBuilder.processMixedEvent(taggedCollisions, tracks, trackPartition, lambdaPartition, cache, mixBinsVtxMult, mixBinsVtxCent, mixBinsVtxMultCent); + } + PROCESS_SWITCH(FemtoPairTrackV0Helicity, processLambdaMixedEventWithTagging, "Enable processing mixed event processing for tracks and lambdas, pre-filtered using the collision tagger", false); + + void processLambdaMixedEvent(FilteredFemtoCollisions const& cols, FemtoTracks const& tracks, FemtoLambdas const& /*lambas*/) + { + pairTrackLambdaBuilder.processMixedEvent(cols, tracks, trackPartition, lambdaPartition, cache, mixBinsVtxMult, mixBinsVtxCent, mixBinsVtxMultCent); + } + PROCESS_SWITCH(FemtoPairTrackV0Helicity, processLambdaMixedEvent, "Enable processing mixed event processing for tracks and lambdas", true); + + void processLambdaMixedEventMc(FilteredFemtoCollisionsWithLabel const& cols, o2::aod::FMcCols const& mcCols, FemtoTracksWithLabel const& tracks, FemtoLambdasWithLabel const& /*lambas*/, FemtoMcParticlesWithLabel const& mcParticles, o2::aod::FMcMothers const& mcMothers, o2::aod::FMcPartMoths const& mcPartonicMothers) + { + pairTrackLambdaBuilder.processMixedEvent(cols, mcCols, tracks, trackWithLabelPartition, lambdaWithLabelPartition, mcParticles, mcMothers, mcPartonicMothers, cache, mixBinsVtxMult, mixBinsVtxCent, mixBinsVtxMultCent); + } + PROCESS_SWITCH(FemtoPairTrackV0Helicity, processLambdaMixedEventMc, "Enable processing mixed event processing for tracks and lambdas with MC information", false); + + void processLambdaSameEventWithFitVars(FilteredFemtoCollision const& col, FemtoTracksWithFitVars const& tracks, FemtoLambdasWithFitVars const& lambdas) + { + pairTrackLambdaBuilder.processSameEvent(col, tracks, trackWithFitVarsPartition, lambdas, lambdaWithFitVarsPartition, cache); + } + PROCESS_SWITCH(FemtoPairTrackV0Helicity, processLambdaSameEventWithFitVars, "Enable processing same event processing for tracks and lambdas, carrying through FitVars tables", false); + + void processLambdaMixedEventWithFitVars(FilteredFemtoCollisions const& cols, FemtoTracksWithFitVars const& tracks, FemtoLambdasWithFitVars const& /*lambas*/) + { + pairTrackLambdaBuilder.processMixedEvent(cols, tracks, trackWithFitVarsPartition, lambdaWithFitVarsPartition, cache, mixBinsVtxMult, mixBinsVtxCent, mixBinsVtxMultCent); + } + PROCESS_SWITCH(FemtoPairTrackV0Helicity, processLambdaMixedEventWithFitVars, "Enable processing mixed event processing for tracks and lambdas, carrying through FitVars tables", false); + + // Same tagging filter as processLambdaMixedEventWithTagging above, on a collision table that + // also carries FColLabels, and the MC-aware processMixedEvent overload (same as processLambdaMixedEventMc). + void processLambdaMixedEventMcWithTagging(FilteredFemtoCollisionsWithLabelAndTags const& cols, o2::aod::FMcCols const& mcCols, FemtoTracksWithLabel const& tracks, FemtoLambdasWithLabel const& /*lambas*/, FemtoMcParticlesWithLabel const& mcParticles, o2::aod::FMcMothers const& mcMothers, o2::aod::FMcPartMoths const& mcPartonicMothers) + { + o2::framework::Partition taggedCollisions = ncheckbit(o2::aod::femtocollisions::collisionTag, confTaggingLambda.internalTagMask); + taggedCollisions.bindTable(cols); + pairTrackLambdaBuilder.processMixedEvent(taggedCollisions, mcCols, tracks, trackWithLabelPartition, lambdaWithLabelPartition, mcParticles, mcMothers, mcPartonicMothers, cache, mixBinsVtxMult, mixBinsVtxCent, mixBinsVtxMultCent); + } + PROCESS_SWITCH(FemtoPairTrackV0Helicity, processLambdaMixedEventMcWithTagging, "Enable processing mixed event processing for tracks and lambdas, pre-filtered using the collision tagger, with mc information", false); + + void processK0shortSameEvent(FilteredFemtoCollision const& col, FemtoTracks const& tracks, FemtoK0shorts const& k0shorts) + { + pairTrackK0shortBuilder.processSameEvent(col, tracks, trackPartition, k0shorts, k0shortPartition, cache); + } + PROCESS_SWITCH(FemtoPairTrackV0Helicity, processK0shortSameEvent, "Enable processing same event processing for tracks and k0shorts", false); + + void processK0shortSameEventMc(FilteredFemtoCollisionWithLabel const& col, o2::aod::FMcCols const& mcCols, FemtoTracksWithLabel const& tracks, FemtoK0shortsWithLabel const& k0shorts, FemtoMcParticlesWithLabel const& mcParticles, o2::aod::FMcMothers const& mcMothers, o2::aod::FMcPartMoths const& mcPartonicMothers) + { + pairTrackK0shortBuilder.processSameEvent(col, mcCols, tracks, trackWithLabelPartition, k0shorts, k0shortWithLabelPartition, mcParticles, mcMothers, mcPartonicMothers, cache); + } + PROCESS_SWITCH(FemtoPairTrackV0Helicity, processK0shortSameEventMc, "Enable processing same event processing for tracks and k0shorts with MC information", false); + + // Opt-in counterpart of processK0shortMixedEvent() below -- same "Partition declared and bound + // inside process()" idiom as femtoPairTrackTrack.cxx's processMixedEventWithTagging. Requires a + // femto-collision-tagger device (processTrackV0 enabled) in the same workflow -- see init(). + void processK0shortMixedEventWithTagging(FilteredFemtoCollisionsWithTags const& cols, FemtoTracks const& tracks, FemtoK0shorts const& /*k0shorts*/) + { + o2::framework::Partition taggedCollisions = ncheckbit(o2::aod::femtocollisions::collisionTag, confTaggingK0short.internalTagMask); + taggedCollisions.bindTable(cols); + pairTrackK0shortBuilder.processMixedEvent(taggedCollisions, tracks, trackPartition, k0shortPartition, cache, mixBinsVtxMult, mixBinsVtxCent, mixBinsVtxMultCent); + } + PROCESS_SWITCH(FemtoPairTrackV0Helicity, processK0shortMixedEventWithTagging, "Enable processing mixed event processing for tracks and k0shorts, pre-filtered using the collision tagger", false); + + void processK0shortMixedEvent(FilteredFemtoCollisions const& cols, FemtoTracks const& tracks, FemtoK0shorts const& /*k0shorts*/) + { + pairTrackK0shortBuilder.processMixedEvent(cols, tracks, trackPartition, k0shortPartition, cache, mixBinsVtxMult, mixBinsVtxCent, mixBinsVtxMultCent); + } + PROCESS_SWITCH(FemtoPairTrackV0Helicity, processK0shortMixedEvent, "Enable processing mixed event processing for tracks and k0shorts", false); + + void processK0shortMixedEventMc(FilteredFemtoCollisionsWithLabel const& cols, o2::aod::FMcCols const& mcCols, FemtoTracksWithLabel const& tracks, FemtoK0shortsWithLabel const& /*k0shorts*/, FemtoMcParticlesWithLabel const& mcParticles, o2::aod::FMcMothers const& mcMothers, o2::aod::FMcPartMoths const& mcPartonicMothers) + { + pairTrackK0shortBuilder.processMixedEvent(cols, mcCols, tracks, trackWithLabelPartition, k0shortWithLabelPartition, mcParticles, mcMothers, mcPartonicMothers, cache, mixBinsVtxMult, mixBinsVtxCent, mixBinsVtxMultCent); + } + PROCESS_SWITCH(FemtoPairTrackV0Helicity, processK0shortMixedEventMc, "Enable processing mixed event processing for tracks and k0shorts with mc information", false); + + void processK0shortSameEventWithFitVars(FilteredFemtoCollision const& col, FemtoTracksWithFitVars const& tracks, FemtoK0shortsWithFitVars const& k0shorts) + { + pairTrackK0shortBuilder.processSameEvent(col, tracks, trackWithFitVarsPartition, k0shorts, k0shortWithFitVarsPartition, cache); + } + PROCESS_SWITCH(FemtoPairTrackV0Helicity, processK0shortSameEventWithFitVars, "Enable processing same event processing for tracks and k0shorts, carrying through FitVars tables", false); + + void processK0shortMixedEventWithFitVars(FilteredFemtoCollisions const& cols, FemtoTracksWithFitVars const& tracks, FemtoK0shortsWithFitVars const& /*k0shorts*/) + { + pairTrackK0shortBuilder.processMixedEvent(cols, tracks, trackWithFitVarsPartition, k0shortWithFitVarsPartition, cache, mixBinsVtxMult, mixBinsVtxCent, mixBinsVtxMultCent); + } + PROCESS_SWITCH(FemtoPairTrackV0Helicity, processK0shortMixedEventWithFitVars, "Enable processing mixed event processing for tracks and k0shorts, carrying through FitVars tables", false); + + // Same tagging filter as processK0shortMixedEventWithTagging above, on a collision table that + // also carries FColLabels, and the MC-aware processMixedEvent overload (same as processK0shortMixedEventMc). + void processK0shortMixedEventMcWithTagging(FilteredFemtoCollisionsWithLabelAndTags const& cols, o2::aod::FMcCols const& mcCols, FemtoTracksWithLabel const& tracks, FemtoK0shortsWithLabel const& /*k0shorts*/, FemtoMcParticlesWithLabel const& mcParticles, o2::aod::FMcMothers const& mcMothers, o2::aod::FMcPartMoths const& mcPartonicMothers) + { + o2::framework::Partition taggedCollisions = ncheckbit(o2::aod::femtocollisions::collisionTag, confTaggingK0short.internalTagMask); + taggedCollisions.bindTable(cols); + pairTrackK0shortBuilder.processMixedEvent(taggedCollisions, mcCols, tracks, trackWithLabelPartition, k0shortWithLabelPartition, mcParticles, mcMothers, mcPartonicMothers, cache, mixBinsVtxMult, mixBinsVtxCent, mixBinsVtxMultCent); + } + PROCESS_SWITCH(FemtoPairTrackV0Helicity, processK0shortMixedEventMcWithTagging, "Enable processing mixed event processing for tracks and k0shorts, pre-filtered using the collision tagger, with mc information", false); +}; + +o2::framework::WorkflowSpec defineDataProcessing(o2::framework::ConfigContext const& context) +{ + o2::framework::WorkflowSpec workflow{ + adaptAnalysisTask(context), + }; + return workflow; +}