diff --git a/PWGCF/Femto/Core/closePairRejection.h b/PWGCF/Femto/Core/closePairRejection.h index d7d8b320171..2748f4e4c81 100644 --- a/PWGCF/Femto/Core/closePairRejection.h +++ b/PWGCF/Femto/Core/closePairRejection.h @@ -750,6 +750,44 @@ class ClosePairRejectionTrackKink CloseTrackRejection mCtr; }; +// photon legs are not in the Track table so Sigma0 pairs only need to cross-check aganist dau lambda +template +class ClosePairRejectionTrackSigma0 +{ + public: + template + void init(o2::framework::HistogramRegistry* registry, + std::map> const& specsV0Daughter, + T1 const& confCprV0Daughter, + int absChargeTrack) + { + mCtrV0Daughter.init(registry, specsV0Daughter, confCprV0Daughter, absChargeTrack, 1); + } + + void setMagField(float magField) + { + mCtrV0Daughter.setMagField(magField); + } + + template + [[nodiscard]] bool isClosePair(T1 const& track, T2 const& sigma0, T3 const& trackTable, T4 const& pairHistManager) + { + bool isCloseV0Daughter = false; + if (track.sign() > 0) { + auto posDau = trackTable.rawIteratorAt(sigma0.posDauId() - trackTable.offset()); + isCloseV0Daughter = mCtrV0Daughter.isClosePair(track, posDau, pairHistManager); + } else { + auto negDau = trackTable.rawIteratorAt(sigma0.negDauId() - trackTable.offset()); + isCloseV0Daughter = mCtrV0Daughter.isClosePair(track, negDau, pairHistManager); + } + + return isCloseV0Daughter; + } + + private: + CloseTrackRejection mCtrV0Daughter; +}; + // PCM photon daughters are, for now, not indexed into the track table (see photonBuilder.h): // they are TPC-only tracks, so they cannot be confused for a global track the way two V0 // daughters or a track and a V0 daughter can -- there is no detector-overlap effect to correct diff --git a/PWGCF/Femto/Core/closeTripletRejection.h b/PWGCF/Femto/Core/closeTripletRejection.h index a3e2f1b8cc7..ece3024343b 100644 --- a/PWGCF/Femto/Core/closeTripletRejection.h +++ b/PWGCF/Femto/Core/closeTripletRejection.h @@ -30,12 +30,14 @@ namespace o2::analysis::femto::closetripletrejection constexpr const char PrefixCtrTrackTrackTrack[] = "CtrTrackTrackTrack"; constexpr const char PrefixCtrTrackTrackV0[] = "CtrTrackTrackV0"; constexpr const char PrefixCtrTrackTrackCascade[] = "CtrTrackTrackCascade"; +constexpr const char PrefixCtrTrackTrackSigma0[] = "CtrTrackTrackSigma0"; constexpr const char PrefixCtrMcParticleMcParticleMcParticle[] = "CtrMcParticleMcParticleMcParticle"; // Q3 (not kstar) is the natural kinematic variable for triplets, so it is the default here using ConfCtrTrackTrackTrack = closepairrejection::ConfCpr; using ConfCtrTrackTrackV0 = closepairrejection::ConfCpr; using ConfCtrTrackTrackCascade = closepairrejection::ConfCpr; +using ConfCtrTrackTrackSigma0 = closepairrejection::ConfCpr; // generated particles, no cut by default (close triplet rejection corrects a detector effect) using ConfCtrMcParticleMcParticleMcParticle = closepairrejection::ConfCpr; @@ -74,6 +76,11 @@ constexpr char PrefixTrack2CascadeBachelorSe[] = "CPR_Track2CascadeBachelor/SE/" constexpr char PrefixTrack1CascadeBachelorMe[] = "CPR_Track1CascadeBachelor/ME/"; constexpr char PrefixTrack2CascadeBachelorMe[] = "CPR_Track2CascadeBachelor/ME/"; +constexpr char PrefixTrack1Sigma0Se[] = "CPR_Track1Sigma0/SE/"; +constexpr char PrefixTrack2Sigma0Se[] = "CPR_Track2Sigma0/SE/"; +constexpr char PrefixTrack1Sigma0Me[] = "CPR_Track1Sigma0/ME/"; +constexpr char PrefixTrack2Sigma0Me[] = "CPR_Track2Sigma0/ME/"; + template @@ -217,6 +224,49 @@ class CloseTripletRejectionTrackTrackCascade closepairrejection::ClosePairRejectionTrackCascade mCtrTrack2Cascade; }; +template +class CloseTripletRejectionTrackTrackSigma0 +{ + public: + CloseTripletRejectionTrackTrackSigma0() = default; + ~CloseTripletRejectionTrackTrackSigma0() = default; + + template + void init(o2::framework::HistogramRegistry* registry, + std::map> const& specs, + T1 const& confCpr, + int absChargeTrack1, + int absChargeTrack2) + { + mCtrTrack12.init(registry, specs, confCpr, absChargeTrack1, absChargeTrack2); + mCtrTrack1Sigma0.init(registry, specs, confCpr, absChargeTrack1); + mCtrTrack2Sigma0.init(registry, specs, confCpr, absChargeTrack2); + } + + void setMagField(float magField) + { + mCtrTrack12.setMagField(magField); + mCtrTrack1Sigma0.setMagField(magField); + mCtrTrack2Sigma0.setMagField(magField); + } + + // checks track1-track2, track1-v0 and track2-v0 (from sigma0); fills the deta-dphi/kinematic + // histograms of each pair internally and returns whether the triplet is rejected. + template + [[nodiscard]] bool isCloseTriplet(T1 const& track1, T2 const& track2, T3 const& sigma0, T4 const& trackTable, T5 const& tripletHistManager) + { + bool isClose12 = mCtrTrack12.isClosePair(track1, track2, trackTable, tripletHistManager); + bool isClose1Sigma0 = mCtrTrack1Sigma0.isClosePair(track1, sigma0, trackTable, tripletHistManager); + bool isClose2Sigma0 = mCtrTrack2Sigma0.isClosePair(track2, sigma0, trackTable, tripletHistManager); + return isClose12 || isClose1Sigma0 || isClose2Sigma0; + } + + private: + closepairrejection::ClosePairRejectionTrackTrack mCtrTrack12; + closepairrejection::ClosePairRejectionTrackSigma0 mCtrTrack1Sigma0; + closepairrejection::ClosePairRejectionTrackSigma0 mCtrTrack2Sigma0; +}; + // close triplet rejection for triplets of generated particles; checks all three constituent pairs template ; using ConfSigmaPlusPcmCleaner2 = ConfParticleCleaner; +constexpr const char PrefixSigma0Cleaner[] = "Sigma0Cleaner"; +using ConfSigma0Cleaner = ConfParticleCleaner; + constexpr const char PrefixXiCleaner1[] = "XiCleaner1"; constexpr const char PrefixXiCleaner2[] = "XiCleaner2"; using ConfXiCleaner1 = ConfParticleCleaner; diff --git a/PWGCF/Femto/Core/partitions.h b/PWGCF/Femto/Core/partitions.h index 6a3a473ecf9..d0bbba99015 100644 --- a/PWGCF/Femto/Core/partitions.h +++ b/PWGCF/Femto/Core/partitions.h @@ -259,6 +259,21 @@ (o2::aod::femtokinks::mlScore >= (selection).mlScoreMin) && \ ncheckbit(o2::aod::femtokinks::mask, (selection).mask) +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) +#define MAKE_SIGMA0_PARTITION(selection) \ + ifnode((selection).sign.node() != 0, \ + ifnode((selection).sign.node() > 0, o2::aod::femtobase::stored::signedPt > 0.f, o2::aod::femtobase::stored::signedPt < 0.f), true) && \ + (nabs(o2::aod::femtobase::stored::signedPt) > (selection).ptMin) && \ + (nabs(o2::aod::femtobase::stored::signedPt) < (selection).ptMax) && \ + (o2::aod::femtobase::stored::eta > (selection).etaMin) && \ + (o2::aod::femtobase::stored::eta < (selection).etaMax) && \ + (o2::aod::femtobase::stored::phi > (selection).phiMin) && \ + (o2::aod::femtobase::stored::phi < (selection).phiMax) && \ + (o2::aod::femtobase::stored::mass > (selection).massMin) && \ + (o2::aod::femtobase::stored::mass < (selection).massMax) && \ + ncheckbit(o2::aod::femtosigma0s::maskLambda, (selection).lambdaMask) && \ + ncheckbit(o2::aod::femtosigma0s::maskPhoton, (selection).photonMask) + // partition for D0 // sign of signedPt encodes the hypothesis: D0 (+) / D0bar (-) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) diff --git a/PWGCF/Femto/Core/sigma0Builder.h b/PWGCF/Femto/Core/sigma0Builder.h new file mode 100644 index 00000000000..a6a8cc77fcd --- /dev/null +++ b/PWGCF/Femto/Core/sigma0Builder.h @@ -0,0 +1,258 @@ +// 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 sigma0Builder.h +/// \brief Sigma0 <- Lambda + gamma builder for femto +/// \author Yakiv Paroviak, CTU in Prague, yakiv.paroviak@cern.ch + +#ifndef PWGCF_FEMTO_CORE_SIGMA0BUILDER_H_ +#define PWGCF_FEMTO_CORE_SIGMA0BUILDER_H_ + +#include "PWGCF/Femto/Core/dataTypes.h" +#include "PWGCF/Femto/Core/femtoUtils.h" +#include "PWGCF/Femto/Core/photonBuilder.h" +#include "PWGCF/Femto/Core/v0Builder.h" +#include "PWGCF/Femto/DataModel/FemtoTables.h" + +#include "Common/Core/RecoDecay.h" + +#include +#include +#include +#include +#include +#include + +#include +#include // IWYU pragma: keep (do not replace with Math/Vector4Dfwd.h) +#include + +#include + +namespace o2::analysis::femto::sigma0builder +{ + +// Selection of the Lambda and photon daughters. Applied with partitions in the producer, before the builder. +constexpr const char PrefixSigma0LambdaSelection[] = "Sigma0LambdaSelection"; +using ConfSigma0LambdaSelection = v0builder::ConfLambdaSelection; +constexpr const char PrefixSigma0PhotonSelection[] = "Sigma0PhotonSelection"; +using ConfSigma0PhotonSelection = photonbuilder::ConfPhotonSelection; + +// Loose kinematic filters on the reconstructed Lambda-photon pair +struct ConfSigma0Filters : o2::framework::ConfigurableGroup { + std::string prefix = std::string("Sigma0Filters"); + o2::framework::Configurable ptMin{"ptMin", 0.f, "Minimum pT"}; + o2::framework::Configurable ptMax{"ptMax", 999.f, "Maximum pT"}; + o2::framework::Configurable etaMin{"etaMin", -0.9f, "Minimum eta"}; + o2::framework::Configurable etaMax{"etaMax", 0.9f, "Maximum eta"}; + o2::framework::Configurable phiMin{"phiMin", 0.f, "Minimum phi"}; + o2::framework::Configurable phiMax{"phiMax", 1.f * o2::constants::math::TwoPI, "Maximum phi"}; + o2::framework::Configurable massMin{"massMin", 1.1f, "Minimum invariant mass"}; + o2::framework::Configurable massMax{"massMax", 1.3f, "Maximum invariant mass"}; +}; + +// Base selection configuration for downstream analysis tasks. +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) +#define SIGMA0_DEFAULT_SELECTIONS(defaultMassMin, defaultMassMax, defaultPdgCode) \ + o2::framework::Configurable pdgCodeAbs{"pdgCodeAbs", (defaultPdgCode), "PDG code. Set sign to -1 for antiparticle"}; \ + o2::framework::Configurable ptMin{"ptMin", 0.f, "Minimum pT"}; \ + o2::framework::Configurable ptMax{"ptMax", 999.f, "Maximum pT"}; \ + o2::framework::Configurable etaMin{"etaMin", -10.f, "Minimum eta"}; \ + o2::framework::Configurable etaMax{"etaMax", 10.f, "Maximum eta"}; \ + o2::framework::Configurable phiMin{"phiMin", 0.f, "Minimum phi"}; \ + o2::framework::Configurable phiMax{"phiMax", 1.f * o2::constants::math::TwoPI, "Maximum phi"}; \ + o2::framework::Configurable massMin{"massMin", (defaultMassMin), "Minimum invariant mass"}; \ + o2::framework::Configurable massMax{"massMax", (defaultMassMax), "Maximum invariant mass"}; \ + o2::framework::Configurable lambdaMask{"lambdaMask", 0, "Bitmask required for the Lambda daughter"}; \ + o2::framework::Configurable photonMask{"photonMask", 0, "Bitmask required for the photon daughter"}; + +template +struct ConfSigma0Selection : o2::framework::ConfigurableGroup { + std::string prefix = Prefix; + SIGMA0_DEFAULT_SELECTIONS(1.1, 1.3, 3212) + o2::framework::Configurable sign{"sign", DefaultSign, "Sign of the Sigma0 (+1: Sigma0; -1: AntiSigma0; 0: both)"}; +}; + +#undef SIGMA0_DEFAULT_SELECTIONS + +constexpr const char PrefixSigma0Selection[] = "Sigma0Selection"; +using ConfSigma0SelectionDefault = ConfSigma0Selection; +constexpr const char PrefixSigma0SelectionStrangeness[] = "Sigma0SelectionStrangeness"; +using ConfSigma0SelectionStrangeness = ConfSigma0Selection; + +struct Sigma0BuilderProducts : o2::framework::ProducesGroup { + o2::framework::Produces producedSigma0s; + o2::framework::Produces producedLiteSigma0s; + o2::framework::Produces producedSigma0Masks; + o2::framework::Produces producedSigma0Extras; +}; + +struct ConfSigma0Tables : o2::framework::ConfigurableGroup { + std::string prefix = std::string("Sigma0Tables"); + o2::framework::Configurable produceSigma0s{"produceSigma0s", -1, "Produce Sigma0s (-1: auto; 0 off; 1 on)"}; + o2::framework::Configurable produceLiteSigma0s{"produceLiteSigma0s", -1, "Produce LiteSigma0s (-1: auto; 0 off; 1 on)"}; + o2::framework::Configurable produceSigma0Masks{"produceSigma0Masks", -1, "Produce Sigma0Masks (-1: auto; 0 off; 1 on)"}; + o2::framework::Configurable produceSigma0Extras{"produceSigma0Extras", -1, "Produce Sigma0Extras (-1: auto; 0 off; 1 on). Needs FLambdaExtras and FPhotonExtras as input"}; +}; + +/// \brief Builder for Sigma0 <- Lambda + PCM gamma candidates +/// Pairs daughters within the collision and applies loose kinematic cuts +class Sigma0Builder +{ + public: + Sigma0Builder() = default; + ~Sigma0Builder() = default; + + template + void init(T1& confFilter, T2& confTable, T3& initContext) + { + LOG(info) << "Initialize femto Sigma0 builder..."; + mMassMin = confFilter.massMin.value; + mMassMax = confFilter.massMax.value; + mPtMin = confFilter.ptMin.value; + mPtMax = confFilter.ptMax.value; + mEtaMin = confFilter.etaMin.value; + mEtaMax = confFilter.etaMax.value; + mPhiMin = confFilter.phiMin.value; + mPhiMax = confFilter.phiMax.value; + + mProduceSigma0s = utils::enableTable("FSigma0s_001", confTable.produceSigma0s.value, initContext); + mProduceLiteSigma0s = utils::enableTable("FLiteSigma0s_001", confTable.produceLiteSigma0s.value, initContext); + mProduceSigma0Masks = utils::enableTable("FSigma0Masks_001", confTable.produceSigma0Masks.value, initContext); + mProduceSigma0Extras = utils::enableTable("FSigma0Extras_001", confTable.produceSigma0Extras.value, initContext); + + if (mProduceSigma0s && mProduceLiteSigma0s) { + LOG(fatal) << "FSigma0s and FLiteSigma0s are mutually exclusive -- enable only one. " + << "FLiteSigma0s is meant to replace FSigma0s at the producer stage for better compression in derived data."; + } + + mFillAnyTable = mProduceSigma0s || mProduceLiteSigma0s || mProduceSigma0Masks || mProduceSigma0Extras; + if (!mFillAnyTable) { + LOG(info) << "No tables configured..."; + } + LOG(info) << "Initialization done..."; + } + + /// Pair all Lambdas with all photons of one collision + template + void fillSigma0s(T1 const& col, T2& products, T3& lambdaPartition, T4& photonPartition, T5& cache) + { + if (!mFillAnyTable) { + return; + } + auto lambdaSlice = lambdaPartition->sliceByCached(o2::aod::femtobase::stored::fColId, col.globalIndex(), cache); + auto photonSlice = photonPartition->sliceByCached(o2::aod::femtobase::stored::fColId, col.globalIndex(), cache); + for (auto const& [lambda, photon] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(lambdaSlice, photonSlice))) { + this->fillSigma0(col, lambda, photon, products); + } + } + + private: + template + void reconstructSigma0(T1 const& lambda, T2 const& photon) + { + // use the PDG Lambda mass to improve the Sigma0 mass resolution + mVecLambda = ROOT::Math::PtEtaPhiMVector{lambda.pt(), lambda.eta(), lambda.phi(), o2::constants::physics::MassLambda0}; + mVecPhoton = ROOT::Math::PtEtaPhiMVector{photon.pt(), photon.eta(), photon.phi(), o2::constants::physics::MassPhoton}; + ROOT::Math::PtEtaPhiMVector vecSigma0 = mVecLambda + mVecPhoton; + + mPt = vecSigma0.Pt(); + mEta = vecSigma0.Eta(); + mPhi = RecoDecay::constrainAngle(vecSigma0.Phi()); + mMass = vecSigma0.M(); + } + + [[nodiscard]] bool checkFilters() const + { + return ((mMass > mMassMin && mMass < mMassMax) && + (mPt > mPtMin && mPt < mPtMax) && + (mEta > mEtaMin && mEta < mEtaMax) && + (mPhi >= mPhiMin && mPhi < mPhiMax)); + } + + template + void fillSigma0(T1 const& col, T2 const& lambda, T3 const& photon, T4& products) + { + reconstructSigma0(lambda, photon); + if (!checkFilters()) { + return; + } + + // the Sigma0 inherits the sign of the Lambda (Sigma0 -> Lambda gamma, AntiSigma0 -> AntiLambda gamma) + const float signedPt = lambda.sign() * mPt; + + if (mProduceSigma0s) { + products.producedSigma0s(col.globalIndex(), + signedPt, + mEta, + mPhi, + mMass, + lambda.posDauId(), + lambda.negDauId(), + photon.globalIndex()); + } + if (mProduceLiteSigma0s) { + products.producedLiteSigma0s(col.globalIndex(), + o2::aod::femtobase::lite::binSignedPt(signedPt), + o2::aod::femtobase::lite::binEta(mEta), + o2::aod::femtobase::lite::binPhi(mPhi), + o2::aod::femtosigma0s::lite::binSigma0Mass(mMass), + lambda.posDauId(), + lambda.negDauId(), + photon.globalIndex()); + } + if (mProduceSigma0Masks) { + products.producedSigma0Masks(lambda.mask(), photon.mask()); + } + if (mProduceSigma0Extras) { + if constexpr (requires { lambda.cosPa(); lambda.dauDca(); lambda.transRadius(); photon.cosPa(); photon.v0Radius(); photon.chi2Ndf(); }) { + products.producedSigma0Extras(lambda.mass(), + lambda.pt(), + lambda.cosPa(), + lambda.dauDca(), + lambda.transRadius(), + photon.pt(), + photon.cosPa(), + photon.v0Radius(), + photon.chi2Ndf(), + ROOT::Math::VectorUtil::Angle(mVecLambda, mVecPhoton)); + } else { + LOG(fatal) << "FSigma0Extras requested, but FLambdaExtras/FPhotonExtras are not joined to the input Lambda/photon tables"; + } + } + } + + // cached kinematics of the daughters and the Sigma0 + ROOT::Math::PtEtaPhiMVector mVecLambda; + ROOT::Math::PtEtaPhiMVector mVecPhoton; + float mPt = 0.f; + float mEta = 0.f; + float mPhi = 0.f; + float mMass = 0.f; + + float mMassMin = 0.f; + float mMassMax = 0.f; + float mPtMin = 0.f; + float mPtMax = 0.f; + float mEtaMin = 0.f; + float mEtaMax = 0.f; + float mPhiMin = 0.f; + float mPhiMax = 0.f; + + bool mFillAnyTable = false; + bool mProduceSigma0s = false; + bool mProduceLiteSigma0s = false; + bool mProduceSigma0Masks = false; + bool mProduceSigma0Extras = false; +}; + +} // namespace o2::analysis::femto::sigma0builder +#endif // PWGCF_FEMTO_CORE_SIGMA0BUILDER_H_ diff --git a/PWGCF/Femto/Core/sigma0HistManager.h b/PWGCF/Femto/Core/sigma0HistManager.h new file mode 100644 index 00000000000..1541a7c1635 --- /dev/null +++ b/PWGCF/Femto/Core/sigma0HistManager.h @@ -0,0 +1,500 @@ +// 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 sigma0HistManager.h +/// \brief histogram manager for Sigma0 histograms +/// \author Yakiv Paroviak, CTU in Prague, yakiv.paroviak@cern.ch + +#ifndef PWGCF_FEMTO_CORE_SIGMA0HISTMANAGER_H_ +#define PWGCF_FEMTO_CORE_SIGMA0HISTMANAGER_H_ + +#include "PWGCF/Femto/Core/histManager.h" +#include "PWGCF/Femto/Core/modes.h" +#include "PWGCF/Femto/Core/trackHistManager.h" + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +namespace o2::analysis::femto::sigma0histmanager +{ +// enum for Sigma0 histograms +enum Sigma0Hist { + // analysis + kPt, + kEta, + kPhi, + kMass, + kSign, + kPtVsMass, + // qa variables (from FSigma0Extras) + kLambdaMass, + kLambdaPt, + kLambdaCosPa, + kLambdaDauDca, + kLambdaTransRadius, + kPhotonPt, + kPhotonCosPa, + kPhotonTransRadius, + kPhotonChi2Ndf, + kOpeningAngle, + // 2d qa + kPtVsEta, + kPtVsPhi, + kPhiVsEta, + kPtVsLambdaMass, + kPtVsOpeningAngle, + kLambdaPtVsPhotonPt, + // mc + kOrigin, + kPdg, + kPdgMother, + kPdgPartonicMother, + kTruePtVsPt, + kTrueEtaVsEta, + kTruePhiVsPhi, + kSigma0HistLast +}; + +template +struct ConfSigma0Binning : o2::framework::ConfigurableGroup { + std::string prefix = Prefix; + 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, 1.1, 1.3}}, "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 Sigma0s"}; +}; + +constexpr const char PrefixSigma0Binning[] = "Sigma0Binning"; +using ConfSigma0BinningDefault = ConfSigma0Binning; + +template +struct ConfSigma0QaBinning : o2::framework::ConfigurableGroup { + std::string prefix = Prefix; + o2::framework::Configurable plot2d{"plot2d", true, "Enable 2d QA histograms"}; + o2::framework::ConfigurableAxis lambdaMass{"lambdaMass", {{200, 1., 1.2}}, "Mass of daughter Lambda"}; + o2::framework::ConfigurableAxis lambdaPt{"lambdaPt", {{600, 0, 6}}, "Pt of daughter Lambda"}; + o2::framework::ConfigurableAxis lambdaCosPa{"lambdaCosPa", {{100, 0.9, 1}}, "Cosine of pointing angle of daughter Lambda"}; + o2::framework::ConfigurableAxis lambdaDauDca{"lambdaDauDca", {{150, 0, 1.5}}, "DCA of Lambda daughters at Lambda decay vertex"}; + o2::framework::ConfigurableAxis lambdaTransRadius{"lambdaTransRadius", {{100, 0, 100}}, "Transverse radius of daughter Lambda decay vertex"}; + o2::framework::ConfigurableAxis photonPt{"photonPt", {{600, 0, 6}}, "Pt of daughter photon"}; + o2::framework::ConfigurableAxis photonCosPa{"photonCosPa", {{100, 0.9, 1}}, "Cosine of pointing angle of daughter photon"}; + o2::framework::ConfigurableAxis photonTransRadius{"photonTransRadius", {{180, 0, 90}}, "Transverse radius of photon conversion point"}; + o2::framework::ConfigurableAxis photonChi2Ndf{"photonChi2Ndf", {{100, 0, 50}}, "Chi2/NDF of photon conversion vertex"}; + o2::framework::ConfigurableAxis openingAngle{"openingAngle", {{180, 0, 1.f * o2::constants::math::PI}}, "Opening angle between Lambda and photon"}; +}; + +constexpr const char PrefixSigma0QaBinning[] = "Sigma0QaBinning"; +using ConfSigma0QaBinningDefault = ConfSigma0QaBinning; + +// must be in sync with enum Sigma0Hist +// the enum gives the correct index in the array +constexpr std::array, kSigma0HistLast> HistTable = { + {{kPt, o2::framework::HistType::kTH1F, "hPt", "Transverse Momentum; p_{T} (GeV/#it{c}); Entries"}, + {kEta, o2::framework::HistType::kTH1F, "hEta", "Pseudorapdity; #eta; Entries"}, + {kPhi, o2::framework::HistType::kTH1F, "hPhi", "Azimuthal angle; #varphi; Entries"}, + {kMass, o2::framework::HistType::kTH1F, "hMass", "Invariant Mass; m_{#Lambda#gamma} (GeV/#it{c}^{2}); Entries"}, + {kSign, o2::framework::HistType::kTH1F, "hSign", "Sign (-1 -> antiparticle, +1 -> particle); sign; Entries"}, + {kPtVsMass, o2::framework::HistType::kTH2F, "hPtVsMass", "Transverse momentum vs invariant mass; p_{T} (GeV/#it{c}); m_{#Lambda#gamma} (GeV/#it{c}^{2})"}, + {kLambdaMass, o2::framework::HistType::kTH1F, "hLambdaMass", "Invariant mass of daughter #Lambda; m_{#Lambda dau} (GeV/#it{c}^{2}); Entries"}, + {kLambdaPt, o2::framework::HistType::kTH1F, "hLambdaPt", "Transverse momentum of daughter #Lambda; p_{T,#Lambda dau} (GeV/#it{c}); Entries"}, + {kLambdaCosPa, o2::framework::HistType::kTH1F, "hLambdaCosPa", "Cosine of pointing angle of daughter #Lambda; cos_{#Lambda dau}(#alpha); Entries"}, + {kLambdaDauDca, o2::framework::HistType::kTH1F, "hLambdaDauDca", "Daughter DCA at #Lambda decay vertex; DCA_{#Lambda dau decay vertex} (cm); Entries"}, + {kLambdaTransRadius, o2::framework::HistType::kTH1F, "hLambdaTransRadius", "Transverse radius of daughter #Lambda; r_{xy,#Lambda dau} (cm); Entries"}, + {kPhotonPt, o2::framework::HistType::kTH1F, "hPhotonPt", "Transverse momentum of daughter #gamma; p_{T,#gamma dau} (GeV/#it{c}); Entries"}, + {kPhotonCosPa, o2::framework::HistType::kTH1F, "hPhotonCosPa", "Cosine of pointing angle of daughter #gamma; cos_{#gamma dau}(#alpha); Entries"}, + {kPhotonTransRadius, o2::framework::HistType::kTH1F, "hPhotonTransRadius", "Transverse radius of #gamma conversion point; r_{xy,#gamma dau} (cm); Entries"}, + {kPhotonChi2Ndf, o2::framework::HistType::kTH1F, "hPhotonChi2Ndf", "#chi^{2}/NDF of #gamma conversion vertex; #chi^{2}/NDF; Entries"}, + {kOpeningAngle, o2::framework::HistType::kTH1F, "hOpeningAngle", "Opening angle between #Lambda and #gamma; #theta_{#Lambda#gamma}; Entries"}, + {kPtVsEta, o2::framework::HistType::kTH2F, "hPtVsEta", "p_{T} vs #eta; p_{T} (GeV/#it{c}) ; #eta"}, + {kPtVsPhi, o2::framework::HistType::kTH2F, "hPtVsPhi", "p_{T} vs #varphi; p_{T} (GeV/#it{c}) ; #varphi"}, + {kPhiVsEta, o2::framework::HistType::kTH2F, "hPhiVsEta", "#varphi vs #eta; #varphi ; #eta"}, + {kPtVsLambdaMass, o2::framework::HistType::kTH2F, "hPtVsLambdaMass", "p_{T} vs mass of daughter #Lambda; p_{T} (GeV/#it{c}); m_{#Lambda dau} (GeV/#it{c}^{2})"}, + {kPtVsOpeningAngle, o2::framework::HistType::kTH2F, "hPtVsOpeningAngle", "p_{T} vs opening angle; p_{T} (GeV/#it{c}); #theta_{#Lambda#gamma}"}, + {kLambdaPtVsPhotonPt, o2::framework::HistType::kTH2F, "hLambdaPtVsPhotonPt", "p_{T} of daughter #Lambda vs p_{T} of daughter #gamma; p_{T,#Lambda dau} (GeV/#it{c}); p_{T,#gamma dau} (GeV/#it{c})"}, + {kOrigin, o2::framework::HistType::kTH1F, "hOrigin", "Status Codes (=Origin); Status Code; Entries"}, + {kPdg, o2::framework::HistType::kTH1F, "hPdg", "PDG Codes of reconstructed #Sigma^{0}; PDG Code; Entries"}, + {kPdgMother, o2::framework::HistType::kTH1F, "hPdgMother", "PDG Codes of mother of reconstructed #Sigma^{0}; PDG Code; Entries"}, + {kPdgPartonicMother, o2::framework::HistType::kTH1F, "hPdgPartonicMother", "PDG Codes of partonic mother of reconstructed #Sigma^{0}; PDG Code; Entries"}, + {kTruePtVsPt, o2::framework::HistType::kTH2F, "hTruePtVsPt", "True transverse momentum vs transverse momentum; p_{T,True} (GeV/#it{c}); p_{T} (GeV/#it{c})"}, + {kTrueEtaVsEta, o2::framework::HistType::kTH2F, "hTrueEtaVsEta", "True pseudorapdity vs pseudorapdity; #eta_{True}; #eta"}, + {kTruePhiVsPhi, o2::framework::HistType::kTH2F, "hTruePhiVsPhi", "True azimuthal angle vs azimuthal angle; #varphi_{True}; #varphi"}}, +}; + +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) +#define SIGMA0_HIST_ANALYSIS_MAP(conf) \ + {kPt, {(conf).pt}}, \ + {kEta, {(conf).eta}}, \ + {kPhi, {(conf).phi}}, \ + {kMass, {(conf).mass}}, \ + {kSign, {(conf).sign}}, \ + {kPtVsMass, {(conf).pt, (conf).mass}}, + +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) +#define SIGMA0_HIST_MC_MAP(conf) \ + {kTruePtVsPt, {(conf).pt, (conf).pt}}, \ + {kTrueEtaVsEta, {(conf).eta, (conf).eta}}, \ + {kTruePhiVsPhi, {(conf).phi, (conf).phi}}, \ + {kPdg, {(conf).pdgCodes}}, \ + {kPdgMother, {(conf).pdgCodes}}, \ + {kPdgPartonicMother, {(conf).pdgCodes}}, + +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) +#define SIGMA0_HIST_QA_MAP(confAnalysis, confQa) \ + {kLambdaMass, {(confQa).lambdaMass}}, \ + {kLambdaPt, {(confQa).lambdaPt}}, \ + {kLambdaCosPa, {(confQa).lambdaCosPa}}, \ + {kLambdaDauDca, {(confQa).lambdaDauDca}}, \ + {kLambdaTransRadius, {(confQa).lambdaTransRadius}}, \ + {kPhotonPt, {(confQa).photonPt}}, \ + {kPhotonCosPa, {(confQa).photonCosPa}}, \ + {kPhotonTransRadius, {(confQa).photonTransRadius}}, \ + {kPhotonChi2Ndf, {(confQa).photonChi2Ndf}}, \ + {kOpeningAngle, {(confQa).openingAngle}}, \ + {kPtVsEta, {(confAnalysis).pt, (confAnalysis).eta}}, \ + {kPtVsPhi, {(confAnalysis).pt, (confAnalysis).phi}}, \ + {kPhiVsEta, {(confAnalysis).phi, (confAnalysis).eta}}, \ + {kPtVsLambdaMass, {(confAnalysis).pt, (confQa).lambdaMass}}, \ + {kPtVsOpeningAngle, {(confAnalysis).pt, (confQa).openingAngle}}, \ + {kLambdaPtVsPhotonPt, {(confQa).lambdaPt, (confQa).photonPt}}, + +template +auto makeSigma0HistSpecMap(const T& confBinningAnalysis) +{ + return std::map>{ + SIGMA0_HIST_ANALYSIS_MAP(confBinningAnalysis)}; +} + +template +auto makeSigma0McHistSpecMap(const T& confBinningAnalysis) +{ + return std::map>{ + SIGMA0_HIST_ANALYSIS_MAP(confBinningAnalysis) + SIGMA0_HIST_MC_MAP(confBinningAnalysis)}; +} + +template +std::map> makeSigma0QaHistSpecMap(T1 const& confBinningAnalysis, T2 const& confBinningQa) +{ + return std::map>{ + SIGMA0_HIST_ANALYSIS_MAP(confBinningAnalysis) + SIGMA0_HIST_QA_MAP(confBinningAnalysis, confBinningQa)}; +} + +template +std::map> makeSigma0McQaHistSpecMap(T1 const& confBinningAnalysis, T2 const& confBinningQa) +{ + return std::map>{ + SIGMA0_HIST_ANALYSIS_MAP(confBinningAnalysis) + SIGMA0_HIST_QA_MAP(confBinningAnalysis, confBinningQa) + SIGMA0_HIST_MC_MAP(confBinningAnalysis)}; +} + +#undef SIGMA0_HIST_ANALYSIS_MAP +#undef SIGMA0_HIST_MC_MAP +#undef SIGMA0_HIST_QA_MAP + +constexpr char PrefixSigma0Qa[] = "Sigma0QA/"; +constexpr char PrefixSigma0Se[] = "Sigma0/SE/"; +constexpr char PrefixSigma0Me[] = "Sigma0/ME/"; + +constexpr std::string_view AnalysisDir = "Analysis/"; +constexpr std::string_view QaDir = "QA/"; +constexpr std::string_view McDir = "MC/"; + +/// \class Sigma0HistManager +/// \brief Class for Sigma0 and its dau track histogramming +/// +/// The Sigma0 tables store only the indices of the Lambda daughter tracks (and of the photon), so the +/// daughter tracks are histogrammed with track histogram managers. QA of the Lambda and photon +/// daughters is read from FSigma0Extras, which needs to be joined to the Sigma0 table for QA modes. +template +class Sigma0HistManager +{ + public: + Sigma0HistManager() = default; + ~Sigma0HistManager() = default; + + template + void init(o2::framework::HistogramRegistry* registry, + std::map> const& sigma0Specs, + T const& ConfSigma0Selection, + std::map> const& PosDauSpecs, + std::map> const& NegDauSpecs) + { + mHistogramRegistry = registry; + this->setPdgCodes(ConfSigma0Selection); + + mPosDauManager.template init(registry, PosDauSpecs, AbsCharge, SignPlus, mPosDauPdgCodeAbs); + mNegDauManager.template init(registry, NegDauSpecs, AbsCharge, SignMinus, mNegDauPdgCodeAbs); + + if constexpr (modes::isFlagSet(mode, modes::Mode::kReco)) { + this->initAnalysis(sigma0Specs); + } + if constexpr (modes::isFlagSet(mode, modes::Mode::kMc)) { + this->initMc(sigma0Specs); + } + } + + template + void init(o2::framework::HistogramRegistry* registry, + std::map> const& sigma0Specs, + T1 const& ConfSigma0Selection, + T2 const& ConfSigma0BinningQa, + std::map> const& PosDauSpecs, + T3 const& ConfPosDauQaBinning, + std::map> const& NegDauSpecs, + T4 const& ConfNegDauQaBinning) + { + mHistogramRegistry = registry; + this->setPdgCodes(ConfSigma0Selection); + mPlot2d = ConfSigma0BinningQa.plot2d.value; + + mPosDauManager.template init(registry, PosDauSpecs, AbsCharge, SignPlus, mPosDauPdgCodeAbs, ConfPosDauQaBinning); + mNegDauManager.template init(registry, NegDauSpecs, AbsCharge, SignMinus, mNegDauPdgCodeAbs, ConfNegDauQaBinning); + + if constexpr (modes::isFlagSet(mode, modes::Mode::kReco)) { + this->initAnalysis(sigma0Specs); + } + if constexpr (modes::isFlagSet(mode, modes::Mode::kQa)) { + this->initQa(sigma0Specs); + } + if constexpr (modes::isFlagSet(mode, modes::Mode::kMc)) { + this->initMc(sigma0Specs); + } + } + + template + void fill(T1 const& sigma0Candidate, T2 const& tracks) + { + auto posDaughter = tracks.rawIteratorAt(sigma0Candidate.posDauId() - tracks.offset()); + mPosDauManager.template fill(posDaughter, tracks); + auto negDaughter = tracks.rawIteratorAt(sigma0Candidate.negDauId() - tracks.offset()); + mNegDauManager.template fill(negDaughter, tracks); + + if constexpr (modes::isFlagSet(mode, modes::Mode::kReco)) { + this->fillAnalysis(sigma0Candidate); + } + if constexpr (modes::isFlagSet(mode, modes::Mode::kQa)) { + this->fillQa(sigma0Candidate); + } + } + + template + void fill(T1 const& sigma0Candidate, T2 const& tracks, T3 const& col, T4 const& mcParticles, T5 const& mcMothers, T6 const& mcPartonicMothers) + { + auto posDaughter = tracks.rawIteratorAt(sigma0Candidate.posDauId() - tracks.offset()); + mPosDauManager.template fill(posDaughter, tracks, col, mcParticles, mcMothers, mcPartonicMothers); + auto negDaughter = tracks.rawIteratorAt(sigma0Candidate.negDauId() - tracks.offset()); + mNegDauManager.template fill(negDaughter, tracks, col, mcParticles, mcMothers, mcPartonicMothers); + + if constexpr (modes::isFlagSet(mode, modes::Mode::kReco)) { + this->fillAnalysis(sigma0Candidate); + } + if constexpr (modes::isFlagSet(mode, modes::Mode::kQa)) { + this->fillQa(sigma0Candidate); + } + if constexpr (modes::isFlagSet(mode, modes::Mode::kMc)) { + this->template fillMc(sigma0Candidate, col); + } + } + + private: + static constexpr int AbsCharge = 1; + static constexpr int SignPlus = 1; + static constexpr int SignMinus = -1; + + // Sigma0 -> Lambda (p pi-) gamma; AntiSigma0 -> AntiLambda (pbar pi+) gamma + template + void setPdgCodes(T const& ConfSigma0Selection) + { + mPdgCode = std::abs(ConfSigma0Selection.pdgCodeAbs.value); + if (mPdgCode != PDG_t::kSigma0) { + LOG(fatal) << "PDG code for Sigma0 has to be " << PDG_t::kSigma0; + } + if (ConfSigma0Selection.sign.value > 0) { + mPosDauPdgCodeAbs = std::abs(PDG_t::kProton); + mNegDauPdgCodeAbs = std::abs(PDG_t::kPiMinus); + } else { + mPdgCode = -1 * mPdgCode; // switch sign for AntiSigma0 + mPosDauPdgCodeAbs = std::abs(PDG_t::kPiPlus); + mNegDauPdgCodeAbs = std::abs(PDG_t::kProtonBar); + } + } + + void initAnalysis(std::map> const& sigma0Specs) + { + std::string analysisDir = std::string(sigma0Prefix) + std::string(AnalysisDir); + mHistogramRegistry->add(analysisDir + getHistNameV2(kPt, HistTable), getHistDesc(kPt, HistTable), getHistType(kPt, HistTable), {sigma0Specs.at(kPt)}); + mHistogramRegistry->add(analysisDir + getHistNameV2(kEta, HistTable), getHistDesc(kEta, HistTable), getHistType(kEta, HistTable), {sigma0Specs.at(kEta)}); + mHistogramRegistry->add(analysisDir + getHistNameV2(kPhi, HistTable), getHistDesc(kPhi, HistTable), getHistType(kPhi, HistTable), {sigma0Specs.at(kPhi)}); + mHistogramRegistry->add(analysisDir + getHistNameV2(kMass, HistTable), getHistDesc(kMass, HistTable), getHistType(kMass, HistTable), {sigma0Specs.at(kMass)}); + mHistogramRegistry->add(analysisDir + getHistNameV2(kSign, HistTable), getHistDesc(kSign, HistTable), getHistType(kSign, HistTable), {sigma0Specs.at(kSign)}); + mHistogramRegistry->add(analysisDir + getHistNameV2(kPtVsMass, HistTable), getHistDesc(kPtVsMass, HistTable), getHistType(kPtVsMass, HistTable), {sigma0Specs.at(kPtVsMass)}); + } + + void initQa(std::map> const& sigma0Specs) + { + std::string qaDir = std::string(sigma0Prefix) + std::string(QaDir); + mHistogramRegistry->add(qaDir + getHistNameV2(kLambdaMass, HistTable), getHistDesc(kLambdaMass, HistTable), getHistType(kLambdaMass, HistTable), {sigma0Specs.at(kLambdaMass)}); + mHistogramRegistry->add(qaDir + getHistNameV2(kLambdaPt, HistTable), getHistDesc(kLambdaPt, HistTable), getHistType(kLambdaPt, HistTable), {sigma0Specs.at(kLambdaPt)}); + mHistogramRegistry->add(qaDir + getHistNameV2(kLambdaCosPa, HistTable), getHistDesc(kLambdaCosPa, HistTable), getHistType(kLambdaCosPa, HistTable), {sigma0Specs.at(kLambdaCosPa)}); + mHistogramRegistry->add(qaDir + getHistNameV2(kLambdaDauDca, HistTable), getHistDesc(kLambdaDauDca, HistTable), getHistType(kLambdaDauDca, HistTable), {sigma0Specs.at(kLambdaDauDca)}); + mHistogramRegistry->add(qaDir + getHistNameV2(kLambdaTransRadius, HistTable), getHistDesc(kLambdaTransRadius, HistTable), getHistType(kLambdaTransRadius, HistTable), {sigma0Specs.at(kLambdaTransRadius)}); + mHistogramRegistry->add(qaDir + getHistNameV2(kPhotonPt, HistTable), getHistDesc(kPhotonPt, HistTable), getHistType(kPhotonPt, HistTable), {sigma0Specs.at(kPhotonPt)}); + mHistogramRegistry->add(qaDir + getHistNameV2(kPhotonCosPa, HistTable), getHistDesc(kPhotonCosPa, HistTable), getHistType(kPhotonCosPa, HistTable), {sigma0Specs.at(kPhotonCosPa)}); + mHistogramRegistry->add(qaDir + getHistNameV2(kPhotonTransRadius, HistTable), getHistDesc(kPhotonTransRadius, HistTable), getHistType(kPhotonTransRadius, HistTable), {sigma0Specs.at(kPhotonTransRadius)}); + mHistogramRegistry->add(qaDir + getHistNameV2(kPhotonChi2Ndf, HistTable), getHistDesc(kPhotonChi2Ndf, HistTable), getHistType(kPhotonChi2Ndf, HistTable), {sigma0Specs.at(kPhotonChi2Ndf)}); + mHistogramRegistry->add(qaDir + getHistNameV2(kOpeningAngle, HistTable), getHistDesc(kOpeningAngle, HistTable), getHistType(kOpeningAngle, HistTable), {sigma0Specs.at(kOpeningAngle)}); + + if (mPlot2d) { + mHistogramRegistry->add(qaDir + getHistNameV2(kPtVsEta, HistTable), getHistDesc(kPtVsEta, HistTable), getHistType(kPtVsEta, HistTable), {sigma0Specs.at(kPtVsEta)}); + mHistogramRegistry->add(qaDir + getHistNameV2(kPtVsPhi, HistTable), getHistDesc(kPtVsPhi, HistTable), getHistType(kPtVsPhi, HistTable), {sigma0Specs.at(kPtVsPhi)}); + mHistogramRegistry->add(qaDir + getHistNameV2(kPhiVsEta, HistTable), getHistDesc(kPhiVsEta, HistTable), getHistType(kPhiVsEta, HistTable), {sigma0Specs.at(kPhiVsEta)}); + mHistogramRegistry->add(qaDir + getHistNameV2(kPtVsLambdaMass, HistTable), getHistDesc(kPtVsLambdaMass, HistTable), getHistType(kPtVsLambdaMass, HistTable), {sigma0Specs.at(kPtVsLambdaMass)}); + mHistogramRegistry->add(qaDir + getHistNameV2(kPtVsOpeningAngle, HistTable), getHistDesc(kPtVsOpeningAngle, HistTable), getHistType(kPtVsOpeningAngle, HistTable), {sigma0Specs.at(kPtVsOpeningAngle)}); + mHistogramRegistry->add(qaDir + getHistNameV2(kLambdaPtVsPhotonPt, HistTable), getHistDesc(kLambdaPtVsPhotonPt, HistTable), getHistType(kLambdaPtVsPhotonPt, HistTable), {sigma0Specs.at(kLambdaPtVsPhotonPt)}); + } + } + + void initMc(std::map> const& sigma0Specs) + { + std::string mcDir = std::string(sigma0Prefix) + std::string(McDir); + mHistogramRegistry->add(mcDir + getHistNameV2(kTruePtVsPt, HistTable), getHistDesc(kTruePtVsPt, HistTable), getHistType(kTruePtVsPt, HistTable), {sigma0Specs.at(kTruePtVsPt)}); + mHistogramRegistry->add(mcDir + getHistNameV2(kTrueEtaVsEta, HistTable), getHistDesc(kTrueEtaVsEta, HistTable), getHistType(kTrueEtaVsEta, HistTable), {sigma0Specs.at(kTrueEtaVsEta)}); + mHistogramRegistry->add(mcDir + getHistNameV2(kTruePhiVsPhi, HistTable), getHistDesc(kTruePhiVsPhi, HistTable), getHistType(kTruePhiVsPhi, HistTable), {sigma0Specs.at(kTruePhiVsPhi)}); + + // mc origin can be configured here + const o2::framework::AxisSpec axisOrigin = {static_cast(modes::McOrigin::kMcOriginLast), -0.5, static_cast(modes::McOrigin::kMcOriginLast) - 0.5}; + mHistogramRegistry->add(mcDir + getHistNameV2(kOrigin, HistTable), getHistDesc(kOrigin, HistTable), getHistType(kOrigin, HistTable), {axisOrigin}); + mHistogramRegistry->get(HIST(sigma0Prefix) + HIST(McDir) + HIST(histmanager::getHistName(kOrigin, HistTable)))->GetXaxis()->SetBinLabel(1 + static_cast(modes::McOrigin::kNoMcParticle), modes::mcOriginToString(modes::McOrigin::kNoMcParticle)); + mHistogramRegistry->get(HIST(sigma0Prefix) + HIST(McDir) + HIST(histmanager::getHistName(kOrigin, HistTable)))->GetXaxis()->SetBinLabel(1 + static_cast(modes::McOrigin::kFromWrongCollision), modes::mcOriginToString(modes::McOrigin::kFromWrongCollision)); + mHistogramRegistry->get(HIST(sigma0Prefix) + HIST(McDir) + HIST(histmanager::getHistName(kOrigin, HistTable)))->GetXaxis()->SetBinLabel(1 + static_cast(modes::McOrigin::kPhysicalPrimary), modes::mcOriginToString(modes::McOrigin::kPhysicalPrimary)); + mHistogramRegistry->get(HIST(sigma0Prefix) + HIST(McDir) + HIST(histmanager::getHistName(kOrigin, HistTable)))->GetXaxis()->SetBinLabel(1 + static_cast(modes::McOrigin::kFromSecondaryDecay), modes::mcOriginToString(modes::McOrigin::kFromSecondaryDecay)); + mHistogramRegistry->get(HIST(sigma0Prefix) + HIST(McDir) + HIST(histmanager::getHistName(kOrigin, HistTable)))->GetXaxis()->SetBinLabel(1 + static_cast(modes::McOrigin::kFromMaterial), modes::mcOriginToString(modes::McOrigin::kFromMaterial)); + mHistogramRegistry->get(HIST(sigma0Prefix) + HIST(McDir) + HIST(histmanager::getHistName(kOrigin, HistTable)))->GetXaxis()->SetBinLabel(1 + static_cast(modes::McOrigin::kMissidentified), modes::mcOriginToString(modes::McOrigin::kMissidentified)); + + mHistogramRegistry->add(mcDir + getHistNameV2(kPdg, HistTable), getHistDesc(kPdg, HistTable), getHistType(kPdg, HistTable), {sigma0Specs.at(kPdg)}); + mHistogramRegistry->add(mcDir + getHistNameV2(kPdgMother, HistTable), getHistDesc(kPdgMother, HistTable), getHistType(kPdgMother, HistTable), {sigma0Specs.at(kPdgMother)}); + mHistogramRegistry->add(mcDir + getHistNameV2(kPdgPartonicMother, HistTable), getHistDesc(kPdgPartonicMother, HistTable), getHistType(kPdgPartonicMother, HistTable), {sigma0Specs.at(kPdgPartonicMother)}); + } + + template + void fillAnalysis(T const& sigma0Candidate) + { + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(AnalysisDir) + HIST(getHistName(kPt, HistTable)), sigma0Candidate.pt()); + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(AnalysisDir) + HIST(getHistName(kEta, HistTable)), sigma0Candidate.eta()); + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(AnalysisDir) + HIST(getHistName(kPhi, HistTable)), sigma0Candidate.phi()); + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(AnalysisDir) + HIST(getHistName(kMass, HistTable)), sigma0Candidate.mass()); + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(AnalysisDir) + HIST(getHistName(kSign, HistTable)), sigma0Candidate.sign()); + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(AnalysisDir) + HIST(getHistName(kPtVsMass, HistTable)), sigma0Candidate.pt(), sigma0Candidate.mass()); + } + + // needs FSigma0Extras joined to the Sigma0 table + template + void fillQa(T const& sigma0Candidate) + { + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(QaDir) + HIST(getHistName(kLambdaMass, HistTable)), sigma0Candidate.lambdaMass()); + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(QaDir) + HIST(getHistName(kLambdaPt, HistTable)), sigma0Candidate.lambdaPt()); + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(QaDir) + HIST(getHistName(kLambdaCosPa, HistTable)), sigma0Candidate.lambdaCosPa()); + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(QaDir) + HIST(getHistName(kLambdaDauDca, HistTable)), sigma0Candidate.lambdaDauDca()); + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(QaDir) + HIST(getHistName(kLambdaTransRadius, HistTable)), sigma0Candidate.lambdaTransRadius()); + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(QaDir) + HIST(getHistName(kPhotonPt, HistTable)), sigma0Candidate.photonPt()); + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(QaDir) + HIST(getHistName(kPhotonCosPa, HistTable)), sigma0Candidate.photonCosPa()); + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(QaDir) + HIST(getHistName(kPhotonTransRadius, HistTable)), sigma0Candidate.photonTransRadius()); + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(QaDir) + HIST(getHistName(kPhotonChi2Ndf, HistTable)), sigma0Candidate.photonChi2Ndf()); + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(QaDir) + HIST(getHistName(kOpeningAngle, HistTable)), sigma0Candidate.openingAngle()); + + if (mPlot2d) { + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(QaDir) + HIST(getHistName(kPtVsEta, HistTable)), sigma0Candidate.pt(), sigma0Candidate.eta()); + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(QaDir) + HIST(getHistName(kPtVsPhi, HistTable)), sigma0Candidate.pt(), sigma0Candidate.phi()); + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(QaDir) + HIST(getHistName(kPhiVsEta, HistTable)), sigma0Candidate.phi(), sigma0Candidate.eta()); + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(QaDir) + HIST(getHistName(kPtVsLambdaMass, HistTable)), sigma0Candidate.pt(), sigma0Candidate.lambdaMass()); + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(QaDir) + HIST(getHistName(kPtVsOpeningAngle, HistTable)), sigma0Candidate.pt(), sigma0Candidate.openingAngle()); + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(QaDir) + HIST(getHistName(kLambdaPtVsPhotonPt, HistTable)), sigma0Candidate.lambdaPt(), sigma0Candidate.photonPt()); + } + } + + template + void fillMc(T1 const& sigma0Candidate, T2 const& col) + { + // No MC Particle + if (!sigma0Candidate.has_fMcParticle()) { + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(McDir) + HIST(getHistName(kPdg, HistTable)), 0); + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(McDir) + HIST(getHistName(kOrigin, HistTable)), static_cast(modes::McOrigin::kNoMcParticle)); + return; + } + + // Retrieve MC particle + auto mcParticle = sigma0Candidate.template fMcParticle_as(); + + // whether a particle is associated to a wrong collision or not cannot be known by the producer so we check it here + bool fromWrongCollision = mcParticle.fMcColId() != col.fMcColId(); + + // whether a particle is missidentfied or not cannot be known by the producer so we check it here + bool isMissidentified = mcParticle.pdgCode() != mPdgCode; + + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(McDir) + HIST(getHistName(kTruePtVsPt, HistTable)), mcParticle.pt(), sigma0Candidate.pt()); + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(McDir) + HIST(getHistName(kTrueEtaVsEta, HistTable)), mcParticle.eta(), sigma0Candidate.eta()); + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(McDir) + HIST(getHistName(kTruePhiVsPhi, HistTable)), mcParticle.phi(), sigma0Candidate.phi()); + if (fromWrongCollision) { + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(McDir) + HIST(getHistName(kOrigin, HistTable)), static_cast(modes::McOrigin::kFromWrongCollision)); + } else if (isMissidentified) { + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(McDir) + HIST(getHistName(kOrigin, HistTable)), static_cast(modes::McOrigin::kMissidentified)); + } else { + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(McDir) + HIST(getHistName(kOrigin, HistTable)), mcParticle.origin()); + } + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(McDir) + HIST(getHistName(kPdg, HistTable)), mcParticle.pdgCode()); + + // get mother + if (mcParticle.has_fMcMother()) { + auto mother = mcParticle.template fMcMother_as(); + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(McDir) + HIST(getHistName(kPdgMother, HistTable)), mother.pdgCode()); + } else { + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(McDir) + HIST(getHistName(kPdgMother, HistTable)), 0); + } + + // get partonic mother + if (mcParticle.has_fMcPartMoth()) { + auto partonicMother = mcParticle.template fMcPartMoth_as(); + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(McDir) + HIST(getHistName(kPdgPartonicMother, HistTable)), partonicMother.pdgCode()); + } else { + mHistogramRegistry->fill(HIST(sigma0Prefix) + HIST(McDir) + HIST(getHistName(kPdgPartonicMother, HistTable)), 0); + } + } + + o2::framework::HistogramRegistry* mHistogramRegistry = nullptr; + int mPdgCode = 0; + int mPosDauPdgCodeAbs = 0; + int mNegDauPdgCodeAbs = 0; + bool mPlot2d = false; + + trackhistmanager::TrackHistManager mPosDauManager; + trackhistmanager::TrackHistManager mNegDauManager; +}; +} // namespace o2::analysis::femto::sigma0histmanager +#endif // PWGCF_FEMTO_CORE_SIGMA0HISTMANAGER_H_ diff --git a/PWGCF/Femto/Core/trackHistManager.h b/PWGCF/Femto/Core/trackHistManager.h index be224cf6b95..d820c4b8fb4 100644 --- a/PWGCF/Femto/Core/trackHistManager.h +++ b/PWGCF/Femto/Core/trackHistManager.h @@ -200,6 +200,8 @@ constexpr const char PrefixLc1PionDauBinning[] = "Lc1PionDauBinning"; constexpr const char PrefixCascadePosDauBinning[] = "CascadePosDauBinning"; constexpr const char PrefixCascadeNegDauBinning[] = "CascadeNegDauBinning"; constexpr const char PrefixCascadeBachelorBinning[] = "CascadeBachelorBinning"; +constexpr const char PrefixSigma0PosDauBinning[] = "Sigma0PosDauBinning"; +constexpr const char PrefixSigma0NegDauBinning[] = "Sigma0NegDauBinning"; constexpr const char PrefixKinkChaDauBinning[] = "KinkChaDauBinning"; constexpr const char PrefixResonancePosDauBinning[] = "ResonancePosDauBinning"; constexpr const char PrefixResonanceNegDauBinning[] = "ResonanceNegDauBinning"; @@ -225,6 +227,8 @@ using ConfLc1PionDauBinning = ConfTrackBinning; using ConfCascadePosDauBinning = ConfTrackBinning; using ConfCascadeNegDauBinning = ConfTrackBinning; using ConfCascadeBachelorBinning = ConfTrackBinning; +using ConfSigma0PosDauBinning = ConfTrackBinning; +using ConfSigma0NegDauBinning = ConfTrackBinning; // for dN/deta tracks constexpr const char PrefixDndetaTrackGlobalBinning[] = "DndetaTrackGlobalBinning"; constexpr const char PrefixDndetaTrackItsOnlyBinning[] = "DndetaTrackItsOnlyBinning"; @@ -690,6 +694,13 @@ constexpr char PrefixCascadePosDaughterQa[] = "CascadePosDauQa/"; constexpr char PrefixCascadeNegDaughterQa[] = "CascadeNegDauQa/"; constexpr char PrefixCascadeBachelorQa[] = "CascadeBachelorQa/"; +constexpr char PrefixSigma0PosDaughterSe[] = "Sigma0PosDau/SE/"; +constexpr char PrefixSigma0NegDaughterSe[] = "Sigma0NegDau/SE/"; +constexpr char PrefixSigma0PosDaughterMe[] = "Sigma0PosDau/ME/"; +constexpr char PrefixSigma0NegDaughterMe[] = "Sigma0NegDau/ME/"; +constexpr char PrefixSigma0PosDaughterQa[] = "Sigma0PosDauQa/"; +constexpr char PrefixSigma0NegDaughterQa[] = "Sigma0NegDauQa/"; + constexpr char PrefixKinkChaDaughterSe[] = "KinkChaDau/SE/"; constexpr char PrefixKinkChaDaughterMe[] = "KinkChaDau/ME/"; constexpr char PrefixKinkChaDaughterQa[] = "KinkChaDauQa/"; diff --git a/PWGCF/Femto/Core/tripletBuilder.h b/PWGCF/Femto/Core/tripletBuilder.h index 177ab5236dc..f569d118039 100644 --- a/PWGCF/Femto/Core/tripletBuilder.h +++ b/PWGCF/Femto/Core/tripletBuilder.h @@ -23,6 +23,7 @@ #include "PWGCF/Femto/Core/modes.h" #include "PWGCF/Femto/Core/pairHistManager.h" #include "PWGCF/Femto/Core/particleCleaner.h" +#include "PWGCF/Femto/Core/sigma0HistManager.h" #include "PWGCF/Femto/Core/trackHistManager.h" #include "PWGCF/Femto/Core/tripletCleaner.h" #include "PWGCF/Femto/Core/tripletHistManager.h" @@ -1008,6 +1009,282 @@ class TripletTrackTrackCascadeBuilder std::uniform_int_distribution<> mDist; }; +class TripletTrackTrackSigma0Builder +{ + public: + TripletTrackTrackSigma0Builder() = default; + ~TripletTrackTrackSigma0Builder() = default; + + template + void init(o2::framework::HistogramRegistry* registry, + T1 const& confCollisionBinning, + T2 const& confTrackSelection1, + T3 const& confTrackSelection2, + T4 const& confSigma0Selection, + T5 const& confCleaner1, + T6 const& confCleaner2, + T7 const& confSigma0Cleaner, + T8 const& confCtr, + T9 const& confMixing, + T10 const& confTripletBinning, + T11 const& confTripletCuts, + std::map> const& colHistSpec, + std::map> const& trackHistSpec1, + std::map> const& trackHistSpec2, + std::map> const& sigma0histSpec, + std::map> const& posDauHistSpec, + std::map> const& negDauHistSpec, + std::map> const& tripletHistSpec, + std::map> const& ctrHistSpec, + std::map> const& tripletCleanerHistSpec) + { + // check if correlating the same track species/selections or not + mTrack1Track2AreSameSpecies = confMixing.particle12AreSameSpecies.value; + + mColHistManagerSe.template init(registry, colHistSpec, confCollisionBinning); + mTripletHistManagerSe.template init(registry, tripletHistSpec, confTripletBinning, confTripletCuts, confMixing); + mColHistManagerMe.template init(registry, colHistSpec, confCollisionBinning); + mTripletHistManagerMe.template init(registry, tripletHistSpec, confTripletBinning, confTripletCuts, confMixing); + + mTcSe.template init(registry, tripletCleanerHistSpec, confTripletCuts); + mTcMe.template init(registry, tripletCleanerHistSpec, confTripletCuts); + + mSigma0Cleaner.init(confSigma0Cleaner); + + if (mTrack1Track2AreSameSpecies) { + // Track1 & Track2 are the same species and track 3 is Sigma0 + mCleaner1.init(confCleaner1); + mTrackHistManager1Se.template init(registry, trackHistSpec1, confTrackSelection1); + mSigma0HistManagerSe.template init(registry, sigma0histSpec, confSigma0Selection, posDauHistSpec, negDauHistSpec); + + mTripletHistManagerSe.setMass(confTrackSelection1.pdgCodeAbs.value, confTrackSelection1.pdgCodeAbs.value, confSigma0Selection.pdgCodeAbs.value); + mTripletHistManagerSe.setCharge(confTrackSelection1.chargeAbs.value, confTrackSelection1.chargeAbs.value, 1); + mCtrSe.init(registry, ctrHistSpec, confCtr, confTrackSelection1.chargeAbs.value, confTrackSelection1.chargeAbs.value); + + mTrackHistManager1Me.template init(registry, trackHistSpec1, confTrackSelection1); + mSigma0HistManagerMe.template init(registry, sigma0histSpec, confSigma0Selection, posDauHistSpec, negDauHistSpec); + + mTripletHistManagerMe.setMass(confTrackSelection1.pdgCodeAbs.value, confTrackSelection1.pdgCodeAbs.value, confSigma0Selection.pdgCodeAbs.value); + mTripletHistManagerMe.setCharge(confTrackSelection1.chargeAbs.value, confTrackSelection1.chargeAbs.value, 1); + mCtrMe.init(registry, ctrHistSpec, confCtr, confTrackSelection1.chargeAbs.value, confTrackSelection1.chargeAbs.value); + } else { + // all three tracks are different + mCleaner1.init(confCleaner1); + mCleaner2.init(confCleaner2); + mTrackHistManager1Se.template init(registry, trackHistSpec1, confTrackSelection1); + mTrackHistManager2Se.template init(registry, trackHistSpec2, confTrackSelection2); + mSigma0HistManagerSe.template init(registry, sigma0histSpec, confSigma0Selection, posDauHistSpec, negDauHistSpec); + + mTripletHistManagerSe.setMass(confTrackSelection1.pdgCodeAbs.value, confTrackSelection2.pdgCodeAbs.value, confSigma0Selection.pdgCodeAbs.value); + mTripletHistManagerSe.setCharge(confTrackSelection1.chargeAbs.value, confTrackSelection2.chargeAbs.value, 1); + mCtrSe.init(registry, ctrHistSpec, confCtr, confTrackSelection1.chargeAbs.value, confTrackSelection2.chargeAbs.value); + + mTrackHistManager1Me.template init(registry, trackHistSpec1, confTrackSelection1); + mSigma0HistManagerMe.template init(registry, sigma0histSpec, confSigma0Selection, posDauHistSpec, negDauHistSpec); + mTrackHistManager2Me.template init(registry, trackHistSpec2, confTrackSelection2); + + mTripletHistManagerMe.setMass(confTrackSelection1.pdgCodeAbs.value, confTrackSelection2.pdgCodeAbs.value, confSigma0Selection.pdgCodeAbs.value); + mTripletHistManagerMe.setCharge(confTrackSelection1.chargeAbs.value, confTrackSelection2.chargeAbs.value, 1); + mCtrMe.init(registry, ctrHistSpec, confCtr, confTrackSelection1.chargeAbs.value, confTrackSelection2.chargeAbs.value); + } + + // setup mixing + mMixingPolicy = static_cast(confMixing.policy.value); + mMixingDepth = confMixing.depth.value; + + // setup rng if necessary + if (confMixing.seed.value >= 0) { + uint64_t randomSeed = 0; + mMixIdenticalParticles = true; + if (confMixing.seed.value == 0) { + randomSeed = static_cast(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); + } else { + randomSeed = static_cast(confMixing.seed.value); + } + mRng = std::mt19937(randomSeed); + mDist = std::uniform_int_distribution<>(tripletprocesshelpers::kOrder123, tripletprocesshelpers::kOrder213); + } + } + + // data + /// \return true if at least one triplet passed all triplet selections (usable as triplet trigger) + template + bool processSameEvent(T1 const& col, T2& trackTable, T3& partition1, T4& partition2, T5& partition3, T6& cache) + { + tripletprocesshelpers::TripletOrder tripletOrder = tripletprocesshelpers::kOrder123; + if (mTrack1Track2AreSameSpecies) { + auto trackSlice1 = partition1->sliceByCached(o2::aod::femtobase::stored::fColId, col.globalIndex(), cache); + auto sigma0Slice = partition3->sliceByCached(o2::aod::femtobase::stored::fColId, col.globalIndex(), cache); + if (trackSlice1.size() < nLimitPartitionIdenticalParticles12 || sigma0Slice.size() < nLimitPartitionParticles) { + return false; + } + mCtrSe.setMagField(col.magField()); + if (mMixIdenticalParticles) { + tripletOrder = static_cast(mDist(mRng)); + } + return tripletprocesshelpers::processSameEvent(trackSlice1, sigma0Slice, trackTable, col, mTrackHistManager1Se, mSigma0HistManagerSe, mTripletHistManagerSe, mCtrSe, mTcSe, tripletOrder, mColHistManagerSe); + } + + auto trackSlice1 = partition1->sliceByCached(o2::aod::femtobase::stored::fColId, col.globalIndex(), cache); + auto trackSlice2 = partition2->sliceByCached(o2::aod::femtobase::stored::fColId, col.globalIndex(), cache); + auto sigma0Slice = partition3->sliceByCached(o2::aod::femtobase::stored::fColId, col.globalIndex(), cache); + if (trackSlice1.size() < nLimitPartitionParticles || trackSlice2.size() < nLimitPartitionParticles || sigma0Slice.size() < nLimitPartitionParticles) { + return false; + } + mCtrSe.setMagField(col.magField()); + return tripletprocesshelpers::processSameEvent(trackSlice1, trackSlice2, sigma0Slice, trackTable, col, mTrackHistManager1Se, mTrackHistManager2Se, mSigma0HistManagerSe, mTripletHistManagerSe, mCtrSe, mTcSe, mColHistManagerSe); + } + + // mc + /// \return true if at least one triplet passed all triplet selections (usable as triplet trigger) + template + bool processSameEvent(T1 const& col, T2 const& mcCols, T3& trackTable, T4& partition1, T5& partition2, T6& partition3, T7 const& mcParticles, T8 const& mcMothers, T9 const& mcPartonicMothers, T10& cache) + { + tripletprocesshelpers::TripletOrder tripletOrder = tripletprocesshelpers::kOrder123; + if (mTrack1Track2AreSameSpecies) { + auto trackSlice1 = partition1->sliceByCached(o2::aod::femtobase::stored::fColId, col.globalIndex(), cache); + auto sigma0Slice = partition3->sliceByCached(o2::aod::femtobase::stored::fColId, col.globalIndex(), cache); + if (trackSlice1.size() < nLimitPartitionIdenticalParticles12 || sigma0Slice.size() < nLimitPartitionParticles) { + return false; + } + mCtrSe.setMagField(col.magField()); + if (mMixIdenticalParticles) { + tripletOrder = static_cast(mDist(mRng)); + } + return tripletprocesshelpers::processSameEvent(trackSlice1, sigma0Slice, trackTable, mcParticles, mcMothers, mcPartonicMothers, col, mcCols, mTrackHistManager1Se, mSigma0HistManagerSe, mTripletHistManagerSe, mCleaner1, mSigma0Cleaner, mCtrSe, mTcSe, tripletOrder, mColHistManagerSe); + } + + auto trackSlice1 = partition1->sliceByCached(o2::aod::femtobase::stored::fColId, col.globalIndex(), cache); + auto trackSlice2 = partition2->sliceByCached(o2::aod::femtobase::stored::fColId, col.globalIndex(), cache); + auto sigma0Slice = partition3->sliceByCached(o2::aod::femtobase::stored::fColId, col.globalIndex(), cache); + if (trackSlice1.size() < nLimitPartitionParticles || trackSlice2.size() < nLimitPartitionParticles || sigma0Slice.size() < nLimitPartitionParticles) { + return false; + } + mCtrSe.setMagField(col.magField()); + return tripletprocesshelpers::processSameEvent(trackSlice1, trackSlice2, sigma0Slice, trackTable, mcParticles, mcMothers, mcPartonicMothers, col, mcCols, mTrackHistManager1Se, mTrackHistManager2Se, mSigma0HistManagerSe, mTripletHistManagerSe, mCleaner1, mCleaner2, mSigma0Cleaner, mCtrSe, mTcSe, mColHistManagerSe); + } + + // data + template + void processMixedEvent(T1 const& cols, T2& trackTable, T3& partition1, T4& partition2, T5& partition3, T6& cache, T7& binsVtxMult, T8& binsVtxCent, T9& binsVtxMultCent) + { + if (mTrack1Track2AreSameSpecies) { + switch (mMixingPolicy) { + case static_cast(pairhistmanager::kVtxMult): + tripletprocesshelpers::processMixedEvent(cols, partition1, partition1, partition3, trackTable, cache, binsVtxMult, mMixingDepth, mTripletHistManagerMe, mCtrMe, mTcMe, mEventStride, mTrackHistManager1Me, mTrackHistManager1Me, mSigma0HistManagerMe, mColHistManagerMe); + break; + case static_cast(pairhistmanager::kVtxCent): + tripletprocesshelpers::processMixedEvent(cols, partition1, partition1, partition3, trackTable, cache, binsVtxCent, mMixingDepth, mTripletHistManagerMe, mCtrMe, mTcMe, mEventStride, mTrackHistManager1Me, mTrackHistManager1Me, mSigma0HistManagerMe, mColHistManagerMe); + break; + case static_cast(pairhistmanager::kVtxMultCent): + tripletprocesshelpers::processMixedEvent(cols, partition1, partition1, partition3, trackTable, cache, binsVtxMultCent, mMixingDepth, mTripletHistManagerMe, mCtrMe, mTcMe, mEventStride, mTrackHistManager1Me, mTrackHistManager1Me, mSigma0HistManagerMe, mColHistManagerMe); + break; + default: + LOG(fatal) << "Invalid binning policy specifed. Breaking..."; + } + } else { + switch (mMixingPolicy) { + case static_cast(pairhistmanager::kVtxMult): + tripletprocesshelpers::processMixedEvent(cols, partition1, partition2, partition3, trackTable, cache, binsVtxMult, mMixingDepth, mTripletHistManagerMe, mCtrMe, mTcMe, mEventStride, mTrackHistManager1Me, mTrackHistManager2Me, mSigma0HistManagerMe, mColHistManagerMe); + break; + case static_cast(pairhistmanager::kVtxCent): + tripletprocesshelpers::processMixedEvent(cols, partition1, partition2, partition3, trackTable, cache, binsVtxCent, mMixingDepth, mTripletHistManagerMe, mCtrMe, mTcMe, mEventStride, mTrackHistManager1Me, mTrackHistManager2Me, mSigma0HistManagerMe, mColHistManagerMe); + break; + case static_cast(pairhistmanager::kVtxMultCent): + tripletprocesshelpers::processMixedEvent(cols, partition1, partition2, partition3, trackTable, cache, binsVtxMultCent, mMixingDepth, mTripletHistManagerMe, mCtrMe, mTcMe, mEventStride, mTrackHistManager1Me, mTrackHistManager2Me, mSigma0HistManagerMe, mColHistManagerMe); + break; + default: + LOG(fatal) << "Invalid binning policy specifed. Breaking..."; + } + } + } + + // mc — NOTE: now takes mcMothers, mcPartonicMothers (required by the fixed tripletprocesshelpers mc overload) + template + void processMixedEvent(T1 const& cols, T2 const& mcCols, T3& trackTable, T4& partition1, T5& partition2, T6& partition3, T7 const& mcParticles, T8 const& mcMothers, T9 const& mcPartonicMothers, T10& cache, T11& binsVtxMult, T12& binsVtxCent, T13& binsVtxMultCent) + { + if (mTrack1Track2AreSameSpecies) { + switch (mMixingPolicy) { + case static_cast(pairhistmanager::kVtxMult): + tripletprocesshelpers::processMixedEvent(cols, mcCols, partition1, partition1, partition3, trackTable, mcParticles, mcMothers, mcPartonicMothers, cache, binsVtxMult, mMixingDepth, mTripletHistManagerMe, mCleaner1, mCleaner1, mSigma0Cleaner, mCtrMe, mTcMe, mEventStride, mTrackHistManager1Me, mTrackHistManager1Me, mSigma0HistManagerMe, mColHistManagerMe); + break; + case static_cast(pairhistmanager::kVtxCent): + tripletprocesshelpers::processMixedEvent(cols, mcCols, partition1, partition1, partition3, trackTable, mcParticles, mcMothers, mcPartonicMothers, cache, binsVtxCent, mMixingDepth, mTripletHistManagerMe, mCleaner1, mCleaner1, mSigma0Cleaner, mCtrMe, mTcMe, mEventStride, mTrackHistManager1Me, mTrackHistManager1Me, mSigma0HistManagerMe, mColHistManagerMe); + break; + case static_cast(pairhistmanager::kVtxMultCent): + tripletprocesshelpers::processMixedEvent(cols, mcCols, partition1, partition1, partition3, trackTable, mcParticles, mcMothers, mcPartonicMothers, cache, binsVtxMultCent, mMixingDepth, mTripletHistManagerMe, mCleaner1, mCleaner1, mSigma0Cleaner, mCtrMe, mTcMe, mEventStride, mTrackHistManager1Me, mTrackHistManager1Me, mSigma0HistManagerMe, mColHistManagerMe); + break; + default: + LOG(fatal) << "Invalid binning policy specifed. Breaking..."; + } + } else { + switch (mMixingPolicy) { + case static_cast(pairhistmanager::kVtxMult): + tripletprocesshelpers::processMixedEvent(cols, mcCols, partition1, partition2, partition3, trackTable, mcParticles, mcMothers, mcPartonicMothers, cache, binsVtxMult, mMixingDepth, mTripletHistManagerMe, mCleaner1, mCleaner2, mSigma0Cleaner, mCtrMe, mTcMe, mEventStride, mTrackHistManager1Me, mTrackHistManager2Me, mSigma0HistManagerMe, mColHistManagerMe); + break; + case static_cast(pairhistmanager::kVtxCent): + tripletprocesshelpers::processMixedEvent(cols, mcCols, partition1, partition2, partition3, trackTable, mcParticles, mcMothers, mcPartonicMothers, cache, binsVtxCent, mMixingDepth, mTripletHistManagerMe, mCleaner1, mCleaner2, mSigma0Cleaner, mCtrMe, mTcMe, mEventStride, mTrackHistManager2Me, mTrackHistManager1Me, mSigma0HistManagerMe, mColHistManagerMe); + break; + case static_cast(pairhistmanager::kVtxMultCent): + tripletprocesshelpers::processMixedEvent(cols, mcCols, partition1, partition2, partition3, trackTable, mcParticles, mcMothers, mcPartonicMothers, cache, binsVtxMultCent, mMixingDepth, mTripletHistManagerMe, mCleaner1, mCleaner2, mSigma0Cleaner, mCtrMe, mTcMe, mEventStride, mTrackHistManager1Me, mTrackHistManager2Me, mSigma0HistManagerMe, mColHistManagerMe); + break; + default: + LOG(fatal) << "Invalid binning policy specifed. Breaking..."; + } + } + } + + private: + // SE triplets + colhistmanager::CollisionHistManager mColHistManagerSe; + trackhistmanager::TrackHistManager mTrackHistManager1Se; + trackhistmanager::TrackHistManager mTrackHistManager2Se; + sigma0histmanager::Sigma0HistManager mSigma0HistManagerSe; + // ME triplets + colhistmanager::CollisionHistManager mColHistManagerMe; + trackhistmanager::TrackHistManager mTrackHistManager1Me; + trackhistmanager::TrackHistManager mTrackHistManager2Me; + sigma0histmanager::Sigma0HistManager mSigma0HistManagerMe; + particlecleaner::ParticleCleaner mCleaner1; + particlecleaner::ParticleCleaner mCleaner2; + particlecleaner::ParticleCleaner mSigma0Cleaner; + triplethistmanager::TripletHistManager mTripletHistManagerSe; + triplethistmanager::TripletHistManager mTripletHistManagerMe; + + closetripletrejection::CloseTripletRejectionTrackTrackSigma0 mCtrSe; + closetripletrejection::CloseTripletRejectionTrackTrackSigma0 mCtrMe; + tripletcleaner::TrackTrackSigma0TripletCleaner mTcSe; + tripletcleaner::TrackTrackSigma0TripletCleaner mTcMe; + triplethistmanager::MixingPolicy mMixingPolicy = triplethistmanager::MixingPolicy::kVtxMult; + bool mTrack1Track2AreSameSpecies = false; + int mEventStride = 1; + int mMixingDepth = 5; + bool mMixIdenticalParticles = false; + std::mt19937 mRng; + std::uniform_int_distribution<> mDist; +}; + // builder for triplets of generated particles (mc truth only, kMc without kReco) // covers all triplet types, since e.g. a lambda is just another mc particle template +class TrackTrackSigma0TripletCleaner : public paircleaner::BasePairCleaner +{ + public: + TrackTrackSigma0TripletCleaner() = default; + ~TrackTrackSigma0TripletCleaner() override = default; + + template + bool isCleanTriplet(T1 const& track1, T2 const& track2, T3 const& sigma0, T4 const& trackTable, T5 const& tripletHistManager) const + { + this->fillAll(); + auto posDaughter = trackTable.rawIteratorAt(sigma0.posDauId() - trackTable.offset()); + auto negDaughter = trackTable.rawIteratorAt(sigma0.negDauId() - trackTable.offset()); + bool isClean = this->isCleanParticlePair(track1, track2) && + this->isCleanParticlePair(track1, posDaughter) && + this->isCleanParticlePair(track1, negDaughter) && + this->isCleanParticlePair(track2, posDaughter) && + this->isCleanParticlePair(track2, negDaughter); + if (!isClean) { + this->fillBlocked(tripletHistManager.getKinematic(this->mKinematicVariable)); + } + return isClean; + } + + template + bool isCleanTriplet(T1 const& track1, T2 const& track2, T3 const& sigma0, T4 const& trackTable, T5 const& mcParticles, T6 const& partonicMothers, T7 const& tripletHistManager) const + { + if (!this->isCleanTriplet(track1, track2, sigma0, trackTable, tripletHistManager)) { + return false; + } + // pair is clean + // no check if we require common or non-common ancestry + auto posDaughter = trackTable.rawIteratorAt(sigma0.posDauId() - trackTable.offset()); + auto negDaughter = trackTable.rawIteratorAt(sigma0.negDauId() - trackTable.offset()); + if (this->mMixPairsWithCommonAncestor) { + return this->pairHasCommonAncestor(track1, track2, mcParticles, partonicMothers) && + this->pairHasCommonAncestor(track1, posDaughter, mcParticles, partonicMothers) && + this->pairHasCommonAncestor(track1, negDaughter, mcParticles, partonicMothers) && + this->pairHasCommonAncestor(track2, posDaughter, mcParticles, partonicMothers) && + this->pairHasCommonAncestor(track2, negDaughter, mcParticles, partonicMothers); + } + if (this->mMixPairsWithNonCommonAncestor) { + return this->pairHasNonCommonAncestor(track1, track2, mcParticles, partonicMothers) && + this->pairHasNonCommonAncestor(track1, posDaughter, mcParticles, partonicMothers) && + this->pairHasNonCommonAncestor(track1, negDaughter, mcParticles, partonicMothers) && + this->pairHasNonCommonAncestor(track2, posDaughter, mcParticles, partonicMothers) && + this->pairHasNonCommonAncestor(track2, negDaughter, mcParticles, partonicMothers); + } + return true; + } +}; + // triplet of generated particles; there are no daughters to share, so only the // (non-)common ancestry requirement can reject a triplet template diff --git a/PWGCF/Femto/Core/tripletHistManager.h b/PWGCF/Femto/Core/tripletHistManager.h index 5b7f42a69b3..cb2b4d027f9 100644 --- a/PWGCF/Femto/Core/tripletHistManager.h +++ b/PWGCF/Femto/Core/tripletHistManager.h @@ -52,6 +52,9 @@ enum TripletHist { kPt1VsQ3, kPt2VsQ3, kPt3VsQ3, + kM1VsQ3, + kM2VsQ3, + kM3VsQ3, kQ3VsMt, kQ3VsMult, kQ3VsCent, @@ -177,6 +180,9 @@ constexpr std::array, kTripletHistogramLast> {kPt1VsQ3, o2::framework::HistType::kTH2F, "hPt1VsQ3", "p_{T,1} vs Q_{3}; p_{T,1} (GeV/#it{c}); Q_{3} (GeV/#it{c})"}, {kPt2VsQ3, o2::framework::HistType::kTH2F, "hPt2VsQ3", "p_{T,2} vs Q_{3}; p_{T,2} (GeV/#it{c}); Q_{3} (GeV/#it{c})"}, {kPt3VsQ3, o2::framework::HistType::kTH2F, "hPt3VsQ3", "p_{T,3} vs Q_{3}; p_{T,3} (GeV/#it{c}); Q_{3} (GeV/#it{c})"}, + {kM1VsQ3, o2::framework::HistType::kTH2F, "hM1VsQ3", "mass_{1} vs Q_{3}; m_{1} (GeV/#it{c}^{2}); Q_{3} (GeV/#it{c})"}, + {kM2VsQ3, o2::framework::HistType::kTH2F, "hM2VsQ3", "mass_{2} vs Q_{3}; m_{2} (GeV/#it{c}^{2}); Q_{3} (GeV/#it{c})"}, + {kM3VsQ3, o2::framework::HistType::kTH2F, "hM3VsQ3", "mass_{3} vs Q_{3}; m_{3} (GeV/#it{c}^{2}); Q_{3} (GeV/#it{c})"}, {kQ3VsMt, o2::framework::HistType::kTH2F, "hQ3VsMt", "Q_{3} vs m_{T}; Q_{3} (GeV/#it{c}); m_{T} (GeV/#it{c}^{2})"}, {kQ3VsMult, o2::framework::HistType::kTH2F, "hQ3VsMult", "Q_{3} vs Multiplicity; Q_{3} (GeV/#it{c}); Multiplicity"}, {kQ3VsCent, o2::framework::HistType::kTH2F, "hQ3VsCent", "Q_{3} vs Centrality; Q_{3} (GeV/#it{c}); Centrality"}, @@ -223,6 +229,9 @@ constexpr std::array, kTripletHistogramLast> {kPt1VsQ3, {(conf).pt1, (conf).q3}}, \ {kPt2VsQ3, {(conf).pt2, (conf).q3}}, \ {kPt3VsQ3, {(conf).pt3, (conf).q3}}, \ + {kM1VsQ3, {(conf).mass1, (conf).q3}}, \ + {kM2VsQ3, {(conf).mass2, (conf).q3}}, \ + {kM3VsQ3, {(conf).mass3, (conf).q3}}, \ {kQ3VsMt, {(conf).q3, (conf).mt}}, \ {kQ3VsMult, {(conf).q3, (conf).multiplicity}}, \ {kQ3VsCent, {(conf).q3, (conf).centrality}}, \ @@ -306,6 +315,9 @@ constexpr char PrefixMcParticleMcParticleMcParticleMe[] = "McParticleMcParticleM constexpr char PrefixTrackTrackCascadeSe[] = "TrackTrackCascade/SE/"; constexpr char PrefixTrackTrackCascadeMe[] = "TrackTrackCascade/ME/"; +constexpr char PrefixTrackTrackSigma0Se[] = "TrackTrackSigma0/SE/"; +constexpr char PrefixTrackTrackSigma0Me[] = "TrackTrackSigma0/ME/"; + constexpr std::string_view AnalysisDir = "Analysis/"; constexpr std::string_view QaDir = "QA/"; constexpr std::string_view McDir = "MC/"; @@ -682,6 +694,15 @@ class TripletHistManager mHistogramRegistry->add(analysisDir + getHistNameV2(kPt1VsQ3, HistTable), getHistDesc(kPt1VsQ3, HistTable), getHistType(kPt1VsQ3, HistTable), {Specs.at(kPt1VsQ3)}); mHistogramRegistry->add(analysisDir + getHistNameV2(kPt2VsQ3, HistTable), getHistDesc(kPt2VsQ3, HistTable), getHistType(kPt2VsQ3, HistTable), {Specs.at(kPt2VsQ3)}); mHistogramRegistry->add(analysisDir + getHistNameV2(kPt3VsQ3, HistTable), getHistDesc(kPt3VsQ3, HistTable), getHistType(kPt3VsQ3, HistTable), {Specs.at(kPt3VsQ3)}); + if (mPlotMass1VsQ3) { + mHistogramRegistry->add(analysisDir + getHistNameV2(kM1VsQ3, HistTable), getHistDesc(kM1VsQ3, HistTable), getHistType(kM1VsQ3, HistTable), {Specs.at(kM1VsQ3)}); + } + if (mPlotMass2VsQ3) { + mHistogramRegistry->add(analysisDir + getHistNameV2(kM2VsQ3, HistTable), getHistDesc(kM2VsQ3, HistTable), getHistType(kM2VsQ3, HistTable), {Specs.at(kM2VsQ3)}); + } + if (mPlotMass3VsQ3) { + mHistogramRegistry->add(analysisDir + getHistNameV2(kM3VsQ3, HistTable), getHistDesc(kM3VsQ3, HistTable), getHistType(kM3VsQ3, HistTable), {Specs.at(kM3VsQ3)}); + } mHistogramRegistry->add(analysisDir + getHistNameV2(kQ3VsMt, HistTable), getHistDesc(kQ3VsMt, HistTable), getHistType(kQ3VsMt, HistTable), {Specs.at(kQ3VsMt)}); mHistogramRegistry->add(analysisDir + getHistNameV2(kQ3VsMult, HistTable), getHistDesc(kQ3VsMult, HistTable), getHistType(kQ3VsMult, HistTable), {Specs.at(kQ3VsMult)}); mHistogramRegistry->add(analysisDir + getHistNameV2(kQ3VsCent, HistTable), getHistDesc(kQ3VsCent, HistTable), getHistType(kQ3VsCent, HistTable), {Specs.at(kQ3VsCent)}); @@ -795,6 +816,15 @@ class TripletHistManager mHistogramRegistry->fill(HIST(prefix) + HIST(AnalysisDir) + HIST(getHistName(kPt1VsQ3, HistTable)), mParticle1.Pt(), mQ3); mHistogramRegistry->fill(HIST(prefix) + HIST(AnalysisDir) + HIST(getHistName(kPt2VsQ3, HistTable)), mParticle2.Pt(), mQ3); mHistogramRegistry->fill(HIST(prefix) + HIST(AnalysisDir) + HIST(getHistName(kPt3VsQ3, HistTable)), mParticle3.Pt(), mQ3); + if (mPlotMass1VsQ3) { + mHistogramRegistry->fill(HIST(prefix) + HIST(AnalysisDir) + HIST(getHistName(kM1VsQ3, HistTable)), mMass1, mQ3); + } + if (mPlotMass2VsQ3) { + mHistogramRegistry->fill(HIST(prefix) + HIST(AnalysisDir) + HIST(getHistName(kM2VsQ3, HistTable)), mMass2, mQ3); + } + if (mPlotMass3VsQ3) { + mHistogramRegistry->fill(HIST(prefix) + HIST(AnalysisDir) + HIST(getHistName(kM3VsQ3, HistTable)), mMass3, mQ3); + } mHistogramRegistry->fill(HIST(prefix) + HIST(AnalysisDir) + HIST(getHistName(kQ3VsMt, HistTable)), mQ3, mMt); mHistogramRegistry->fill(HIST(prefix) + HIST(AnalysisDir) + HIST(getHistName(kQ3VsMult, HistTable)), mQ3, mMult); mHistogramRegistry->fill(HIST(prefix) + HIST(AnalysisDir) + HIST(getHistName(kQ3VsCent, HistTable)), mQ3, mCent); @@ -897,6 +927,15 @@ class TripletHistManager bool mPlot1d = true; bool mPlot2d = true; + // initialize mass vs Q3 histograms only if table has mass column + static constexpr bool hasMassColumn(modes::Particle p) + { + return p == modes::Particle::kSigma0 || p == modes::Particle::kCascade; + } + bool mPlotMass1VsQ3 = hasMassColumn(particleType1); + bool mPlotMass2VsQ3 = hasMassColumn(particleType2); + bool mPlotMass3VsQ3 = hasMassColumn(particleType3); + bool mPlotPt1VsPt2VsPt3 = false; bool mPlotQ3VsPt1VsPt2VsPt3 = false; bool mPlotQ3VsMtVsMult = false; diff --git a/PWGCF/Femto/DataModel/FemtoTables.h b/PWGCF/Femto/DataModel/FemtoTables.h index 1419010f224..3b85dc68552 100644 --- a/PWGCF/Femto/DataModel/FemtoTables.h +++ b/PWGCF/Femto/DataModel/FemtoTables.h @@ -1362,6 +1362,123 @@ DECLARE_SOA_TABLE_STAGED_VERSIONED(FSigmaPlusPcmExtras_001, "FSIGMAPCMEXTRA", 1, using FSigmaPlusPcmExtras = FSigmaPlusPcmExtras_001; using StoredFSigmaPlusPcmExtras = StoredFSigmaPlusPcmExtras_001; +namespace femtosigma0s +{ +// columns for daughter bit masks, copied at build time +DECLARE_SOA_COLUMN(MaskLambda, maskLambda, o2::analysis::femto::datatypes::V0MaskType); //! Bitmask of the Lambda daughter +DECLARE_SOA_COLUMN(MaskPhoton, maskPhoton, o2::analysis::femto::datatypes::PhotonMaskType); //! Bitmask of the photon daughter + +// columns for QA on dau info +DECLARE_SOA_COLUMN(LambdaMass, lambdaMass, float); //! Invariant mass of the Lambda daughter +DECLARE_SOA_COLUMN(LambdaPt, lambdaPt, float); //! pT of the Lambda daughter +DECLARE_SOA_COLUMN(LambdaCosPa, lambdaCosPa, float); //! Cosine of the pointing angle of the Lambda daughter +DECLARE_SOA_COLUMN(LambdaDauDca, lambdaDauDca, float); //! DCA between the Lambda daughter tracks at the decay vertex +DECLARE_SOA_COLUMN(LambdaTransRadius, lambdaTransRadius, float); //! Transverse radius of the Lambda decay vertex +DECLARE_SOA_COLUMN(PhotonPt, photonPt, float); //! pT of the photon daughter +DECLARE_SOA_COLUMN(PhotonCosPa, photonCosPa, float); //! Cosine of the pointing angle of the photon daughter +DECLARE_SOA_COLUMN(PhotonTransRadius, photonTransRadius, float); //! Transverse radius of the photon conversion point +DECLARE_SOA_COLUMN(PhotonChi2Ndf, photonChi2Ndf, float); //! Chi2 / NDF of the photon conversion vertex +DECLARE_SOA_COLUMN(OpeningAngle, openingAngle, float); //! 3D opening angle between Lambda and photon +DECLARE_SOA_DYNAMIC_COLUMN(LambdaPa, lambdaPa, //! pointing angle of the Lambda daughter + [](float cosPa) -> float { + return std::acos(cosPa); + }); +DECLARE_SOA_DYNAMIC_COLUMN(PhotonPa, photonPa, //! pointing angle of the photon daughter + [](float cosPa) -> float { + return std::acos(cosPa); + }); + +// id column for the photon daughter +// following the cascades, the Lambda daughter is not stored, only its daughter tracks (femtov0s::PosDauId/NegDauId) +DECLARE_SOA_INDEX_COLUMN_FULL(Photon, photon, int32_t, FPhotons, "_Photon"); //! index column for the photon daughter + +namespace lite +{ +// Sigma0: PDG mass 1.192642 GeV, roughly +-100 MeV window +constexpr float Sigma0MassMin = 1.1f; +constexpr float Sigma0MassMax = 1.3f; +constexpr float Sigma0MassStep = (Sigma0MassMax - Sigma0MassMin) / 65536.f; + +inline uint16_t binSigma0Mass(float mass) { return o2::analysis::femto::utils::binLinear(mass, Sigma0MassMin, Sigma0MassMax, Sigma0MassStep); } +inline float unBinSigma0Mass(uint16_t binned) { return o2::analysis::femto::utils::unBinLinear(binned, Sigma0MassMin, Sigma0MassStep); } + +DECLARE_SOA_COLUMN(BinnedSigma0Mass, binnedSigma0Mass, uint16_t); + +DECLARE_SOA_DYNAMIC_COLUMN(Sigma0Mass, sigma0Mass, + [](uint16_t binnedSigma0Mass) -> float { + return unBinSigma0Mass(binnedSigma0Mass); + }); + +// index for lite photon table +DECLARE_SOA_INDEX_COLUMN_FULL(Photon, photon, int32_t, FLitePhotons, "_Photon"); //! photon daughter index, into FLitePhotons +} // namespace lite +} // namespace femtosigma0s + +// table for basic sigma0 information +DECLARE_SOA_TABLE_STAGED_VERSIONED(FSigma0s_001, "FSIGMA0", 1, //! femto sigma0s + o2::soa::Index<>, + femtobase::stored::FColId, + femtobase::stored::SignedPt, // use sign to differentiate between sigma0 (+1) and anti sigma0 (-1) + femtobase::stored::Eta, + femtobase::stored::Phi, + femtobase::stored::Mass, + femtov0s::PosDauId, + femtov0s::NegDauId, + femtosigma0s::PhotonId, + femtobase::dynamic::Sign, + femtobase::dynamic::Pt, + femtobase::dynamic::P, + femtobase::dynamic::Px, + femtobase::dynamic::Py, + femtobase::dynamic::Pz, + femtobase::dynamic::Theta); +using FSigma0s = FSigma0s_001; +using FSigma0 = FSigma0s::iterator; +using StoredFSigma0s = StoredFSigma0s_001; + +// table for basic sigma0 information, compressed/binned kinematics +DECLARE_SOA_TABLE_STAGED_VERSIONED(FLiteSigma0s_001, "FLITESIGMA0", 1, //! femto sigma0s, binned kinematics + o2::soa::Index<>, + femtobase::stored::FLiteColId, + femtobase::lite::SignedBinnedPt, + femtobase::lite::BinnedEta, + femtobase::lite::BinnedPhi, + femtosigma0s::lite::BinnedSigma0Mass, + femtov0s::lite::PosDauId, + femtov0s::lite::NegDauId, + femtosigma0s::lite::PhotonId, + femtobase::lite::Sign, + femtobase::lite::SignedPt, + femtobase::lite::signedpt::Pt, + femtobase::lite::Eta, + femtobase::lite::Phi, + femtosigma0s::lite::Sigma0Mass); +using FLiteSigma0s = FLiteSigma0s_001; +using FLiteSigma0 = FLiteSigma0s::iterator; +using StoredFLiteSigma0s = StoredFLiteSigma0s_001; + +DECLARE_SOA_TABLE_STAGED_VERSIONED(FSigma0Masks_001, "FSIGMA0MASK", 1, //! sigma0 masks (masks of the Lambda and photon daughters) + femtosigma0s::MaskLambda, + femtosigma0s::MaskPhoton); +using FSigma0Masks = FSigma0Masks_001; +using StoredFSigma0Masks = StoredFSigma0Masks_001; + +DECLARE_SOA_TABLE_STAGED_VERSIONED(FSigma0Extras_001, "FSIGMA0EXTRA", 1, //! sigma0 extra information (daughter QA) + femtosigma0s::LambdaMass, + femtosigma0s::LambdaPt, + femtosigma0s::LambdaCosPa, + femtosigma0s::LambdaDauDca, + femtosigma0s::LambdaTransRadius, + femtosigma0s::PhotonPt, + femtosigma0s::PhotonCosPa, + femtosigma0s::PhotonTransRadius, + femtosigma0s::PhotonChi2Ndf, + femtosigma0s::OpeningAngle, + femtosigma0s::LambdaPa, + femtosigma0s::PhotonPa); +using FSigma0Extras = FSigma0Extras_001; +using StoredFSigma0Extras = StoredFSigma0Extras_001; + namespace femtocascades { // columns for cascade bit masks @@ -1851,6 +1968,13 @@ using FSigmaPlusLabel = FSigmaPlusLabels::iterator; using StoredFSigmaPlusLabels = StoredFSigmaPlusLabels_001; using StoredFSigmaPlusLabel = StoredFSigmaPlusLabels::iterator; +DECLARE_SOA_TABLE_STAGED_VERSIONED(FSigma0Labels_001, "FSIGMA0LABEL", 1, //! label from femto sigma0 to femto mc particle + femtolabels::FMcParticleId); +using FSigma0Labels = FSigma0Labels_001; +using FSigma0Label = FSigma0Labels::iterator; +using StoredFSigma0Labels = StoredFSigma0Labels_001; +using StoredFSigma0Label = StoredFSigma0Labels::iterator; + DECLARE_SOA_TABLE_STAGED_VERSIONED(FSigmaPlusPcmLabels_001, "FSIGMAPCMLABEL", 1, //! label from femto sigma plus (PCM) to femto mc particle femtolabels::FMcParticleId); using FSigmaPlusPcmLabels = FSigmaPlusPcmLabels_001; diff --git a/PWGCF/Femto/TableProducer/CMakeLists.txt b/PWGCF/Femto/TableProducer/CMakeLists.txt index d804d6e39fa..b1b2a156c02 100644 --- a/PWGCF/Femto/TableProducer/CMakeLists.txt +++ b/PWGCF/Femto/TableProducer/CMakeLists.txt @@ -53,3 +53,8 @@ o2physics_add_dpl_workflow(femto-producer-track-track-two-photon-resonances SOURCES ./femtoProducerTrackTrackTwoPhotonResonances.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(femto-producer-sigma0 + SOURCES ./femtoProducerSigma0.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) diff --git a/PWGCF/Femto/TableProducer/femtoProducerSigma0.cxx b/PWGCF/Femto/TableProducer/femtoProducerSigma0.cxx new file mode 100644 index 00000000000..8f90d4d065c --- /dev/null +++ b/PWGCF/Femto/TableProducer/femtoProducerSigma0.cxx @@ -0,0 +1,98 @@ +// 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 femtoProducerSigma0.cxx +/// \brief Derived-to-derived task: builds femto Sigma0 -> Lambda + gamma candidates from FLambdas and FPhotons +/// +/// Needs the full-precision FLambdas, FLambdaMasks, FPhotons and FPhotonMasks as input (i.e. the +/// producer ran with LambdaTables.produceLambdas and PhotonTables.producePhotons, not the Lite variants, +/// or the Lite tables were converted back before running this task). +/// FSigma0Extras additionally needs FLambdaExtras and FPhotonExtras (processWithExtras). +/// \author Yakiv Paroviak, CTU in Prague, yakiv.paroviak@cern.ch + +#include "PWGCF/Femto/Core/collisionBuilder.h" +#include "PWGCF/Femto/Core/partitions.h" +#include "PWGCF/Femto/Core/sigma0Builder.h" +#include "PWGCF/Femto/DataModel/FemtoTables.h" + +#include +#include +#include +#include +#include +#include + +using namespace o2::analysis::femto; + +struct FemtoProducerSigma0 { + + using FemtoCollisions = o2::soa::Join; + using FilteredFemtoCollisions = o2::soa::Filtered; + using FilteredFemtoCollision = FilteredFemtoCollisions::iterator; + + using FemtoLambdas = o2::soa::Join; + using FemtoPhotons = o2::soa::Join; + using FemtoLambdasWithExtras = o2::soa::Join; + using FemtoPhotonsWithExtras = o2::soa::Join; + + o2::framework::SliceCache cache; + + // setup collisions + collisionbuilder::ConfCollisionSelection collisionSelection; + o2::framework::expressions::Filter collisionFilter = MAKE_COLLISION_FILTER(collisionSelection); + + // setup for Lambda daughters + sigma0builder::ConfSigma0LambdaSelection confLambdaSelection; + o2::framework::Partition lambdaPartition = MAKE_LAMBDA_PARTITION(confLambdaSelection); + o2::framework::Partition lambdaWithExtrasPartition = MAKE_LAMBDA_PARTITION(confLambdaSelection); + o2::framework::Preslice perColLambdas = o2::aod::femtobase::stored::fColId; + o2::framework::Preslice perColLambdasWithExtras = o2::aod::femtobase::stored::fColId; + + // setup for photon daughters + sigma0builder::ConfSigma0PhotonSelection confPhotonSelection; + o2::framework::Partition photonPartition = MAKE_PHOTON_PARTITION(confPhotonSelection); + o2::framework::Partition photonWithExtrasPartition = MAKE_PHOTON_PARTITION(confPhotonSelection); + o2::framework::Preslice perColPhotons = o2::aod::femtobase::stored::fColId; + o2::framework::Preslice perColPhotonsWithExtras = o2::aod::femtobase::stored::fColId; + + // Sigma0 builder + sigma0builder::ConfSigma0Filters confSigma0Filter; + sigma0builder::ConfSigma0Tables confSigma0Tables; + sigma0builder::Sigma0BuilderProducts sigma0BuilderProducts; + sigma0builder::Sigma0Builder sigma0Builder; + + void init(o2::framework::InitContext& context) + { + if (doprocess && doprocessWithExtras) { + LOG(fatal) << "Enable only one of process and processWithExtras"; + } + sigma0Builder.init(confSigma0Filter, confSigma0Tables, context); + } + + void process(FilteredFemtoCollision const& col, FemtoLambdas const& /*lambdas*/, FemtoPhotons const& /*photons*/) + { + sigma0Builder.fillSigma0s(col, sigma0BuilderProducts, lambdaPartition, photonPartition, cache); + } + PROCESS_SWITCH(FemtoProducerSigma0, process, "Build Sigma0 candidates", true); + + // needed to fill FSigma0Extras, which copies QA information of the Lambda and photon daughters + void processWithExtras(FilteredFemtoCollision const& col, FemtoLambdasWithExtras const& /*lambdas*/, FemtoPhotonsWithExtras const& /*photons*/) + { + sigma0Builder.fillSigma0s(col, sigma0BuilderProducts, lambdaWithExtrasPartition, photonWithExtrasPartition, cache); + } + PROCESS_SWITCH(FemtoProducerSigma0, processWithExtras, "Build Sigma0 candidates and fill FSigma0Extras (needs FLambdaExtras and FPhotonExtras)", false); +}; + +o2::framework::WorkflowSpec defineDataProcessing(o2::framework::ConfigContext const& context) +{ + o2::framework::WorkflowSpec workflow{adaptAnalysisTask(context)}; + return workflow; +} diff --git a/PWGCF/Femto/Tasks/CMakeLists.txt b/PWGCF/Femto/Tasks/CMakeLists.txt index 1f9647bd7b2..7ade497aa96 100644 --- a/PWGCF/Femto/Tasks/CMakeLists.txt +++ b/PWGCF/Femto/Tasks/CMakeLists.txt @@ -129,6 +129,11 @@ o2physics_add_dpl_workflow(femto-triplet-track-track-cascade PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(femto-triplet-track-track-sigma0 + SOURCES femtoTripletTrackTrackSigma0.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(femto-triplet-mc-particle-mc-particle-mc-particle SOURCES femtoTripletMcParticleMcParticleMcParticle.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore diff --git a/PWGCF/Femto/Tasks/femtoTripletTrackTrackSigma0.cxx b/PWGCF/Femto/Tasks/femtoTripletTrackTrackSigma0.cxx new file mode 100644 index 00000000000..197ddaad0fd --- /dev/null +++ b/PWGCF/Femto/Tasks/femtoTripletTrackTrackSigma0.cxx @@ -0,0 +1,208 @@ +// 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 femtoTripletTrackTrackSigma0.cxx +/// \brief Tasks that computes correlation between two tracks and a sigma0 +/// \author Yakiv Paroviak, CTU Prague, yakiv.paroviak@cern.ch + +#include "PWGCF/Femto/Core/closePairRejection.h" +#include "PWGCF/Femto/Core/closeTripletRejection.h" +#include "PWGCF/Femto/Core/collisionBuilder.h" +#include "PWGCF/Femto/Core/collisionHistManager.h" +#include "PWGCF/Femto/Core/modes.h" +#include "PWGCF/Femto/Core/pairCleaner.h" +#include "PWGCF/Femto/Core/particleCleaner.h" +#include "PWGCF/Femto/Core/partitions.h" +#include "PWGCF/Femto/Core/sigma0Builder.h" +#include "PWGCF/Femto/Core/sigma0HistManager.h" +#include "PWGCF/Femto/Core/trackBuilder.h" +#include "PWGCF/Femto/Core/trackHistManager.h" +#include "PWGCF/Femto/Core/tripletBuilder.h" +#include "PWGCF/Femto/Core/tripletHistManager.h" +#include "PWGCF/Femto/DataModel/FemtoTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +using namespace o2::analysis::femto; + +struct FemtoTripletTrackTrackSigma0 { + + // 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; + + using FemtoTracks = o2::soa::Join; + using FemtoSigma0s = o2::soa::Join; + + using FemtoTracksWithLabel = o2::soa::Join; + using FemtoSigma0sWithLabel = 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; + + // setup tracks + trackbuilder::ConfTrackSelection1 confTrackSelections1; + trackhistmanager::ConfTrackBinning1 confTrackBinning1; + trackbuilder::ConfTrackSelection2 confTrackSelections2; + trackhistmanager::ConfTrackBinning2 confTrackBinning2; + + // particle cleaners (mc only) + particlecleaner::ConfTrackCleaner1 confTrackCleaner1; + particlecleaner::ConfTrackCleaner2 confTrackCleaner2; + particlecleaner::ConfSigma0Cleaner confSigma0Cleaner; + + o2::framework::Partition trackPartition1 = MAKE_TRACK_PARTITION(confTrackSelections1); + o2::framework::Partition trackPartition2 = MAKE_TRACK_PARTITION(confTrackSelections2); + o2::framework::Preslice perColtracks = o2::aod::femtobase::stored::fColId; + + o2::framework::Partition trackWithLabelPartition1 = MAKE_TRACK_PARTITION(confTrackSelections1); + o2::framework::Partition trackWithLabelPartition2 = MAKE_TRACK_PARTITION(confTrackSelections2); + o2::framework::Preslice perColtracksWithLabel = o2::aod::femtobase::stored::fColId; + + // setup sigma0s + sigma0builder::ConfSigma0SelectionDefault confSigma0Selection; + sigma0histmanager::ConfSigma0BinningDefault confSigma0Binning; + trackhistmanager::ConfSigma0PosDauBinning confPosDauBinning; + trackhistmanager::ConfSigma0NegDauBinning confNegDauBinning; + + o2::framework::Partition sigma0Partition = MAKE_SIGMA0_PARTITION(confSigma0Selection); + o2::framework::Preslice perColSigma0s = o2::aod::femtobase::stored::fColId; + + o2::framework::Partition sigma0WithLabelPartition = MAKE_SIGMA0_PARTITION(confSigma0Selection); + o2::framework::Preslice perColSigma0sWithLabel = o2::aod::femtobase::stored::fColId; + + // setup triplets + triplethistmanager::ConfTripletBinning confTripletBinning; + triplethistmanager::ConfTripletCuts confTripletCuts; + paircleaner::ConfPairCleanerBinning confTripletCleanerBinning; + + closetripletrejection::ConfCtrTrackTrackSigma0 confCtr; + + tripletbuilder::TripletTrackTrackSigma0Builder tripletTrackTrackSigma0Builder; + + // 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}}; + triplethistmanager::ConfMixing confMixing; + + o2::framework::HistogramRegistry hRegistry{"FemtoTrackTrackSigma0", {}, o2::framework::OutputObjHandlingPolicy::AnalysisObject}; + + void init(o2::framework::InitContext&) + { + if ((static_cast(doprocessSameEvent) + static_cast(doprocessSameEventMc)) > 1 || (static_cast(doprocessMixedEvent) + static_cast(doprocessMixedEventMc)) > 1) { + LOG(fatal) << "More than 1 same or mixed event process function is activated. Breaking..."; + } + bool processData = doprocessSameEvent || doprocessMixedEvent; + bool processMc = doprocessSameEventMc || doprocessMixedEventMc; + if (processData && processMc) { + LOG(fatal) << "Both data and mc processing is activated. Breaking..."; + } + + // 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}}; + + // setup histogram specs + std::map> colHistSpec; + std::map> trackHistSpec1; + std::map> trackHistSpec2; + std::map> sigma0HistSpec; + std::map> posDauHistSpec; + std::map> negDauHistSpec; + std::map> tripletHistSpec; + std::map> ctrHistSpec = closepairrejection::makeCprHistSpecMap(confCtr); + std::map> tripletCleanerHistSpec = paircleaner::makePairCleanerHistSpecMap(confTripletCleanerBinning); + + if (processData) { + colHistSpec = colhistmanager::makeColHistSpecMap(confCollisionBinning); + trackHistSpec1 = trackhistmanager::makeTrackHistSpecMap(confTrackBinning1); + trackHistSpec2 = trackhistmanager::makeTrackHistSpecMap(confTrackBinning2); + sigma0HistSpec = sigma0histmanager::makeSigma0HistSpecMap(confSigma0Binning); + posDauHistSpec = trackhistmanager::makeTrackHistSpecMap(confPosDauBinning); + negDauHistSpec = trackhistmanager::makeTrackHistSpecMap(confNegDauBinning); + tripletHistSpec = triplethistmanager::makeTripletHistSpecMap(confTripletBinning, confMixing); + tripletTrackTrackSigma0Builder.init(&hRegistry, confCollisionBinning, confTrackSelections1, confTrackSelections2, confSigma0Selection, confTrackCleaner1, confTrackCleaner2, confSigma0Cleaner, confCtr, confMixing, confTripletBinning, confTripletCuts, colHistSpec, trackHistSpec1, trackHistSpec2, sigma0HistSpec, posDauHistSpec, negDauHistSpec, tripletHistSpec, ctrHistSpec, tripletCleanerHistSpec); + } else if (processMc) { + colHistSpec = colhistmanager::makeColMcHistSpecMap(confCollisionBinning); + trackHistSpec1 = trackhistmanager::makeTrackMcHistSpecMap(confTrackBinning1); + trackHistSpec2 = trackhistmanager::makeTrackMcHistSpecMap(confTrackBinning2); + sigma0HistSpec = sigma0histmanager::makeSigma0McHistSpecMap(confSigma0Binning); + posDauHistSpec = trackhistmanager::makeTrackMcHistSpecMap(confPosDauBinning); + negDauHistSpec = trackhistmanager::makeTrackMcHistSpecMap(confNegDauBinning); + tripletHistSpec = triplethistmanager::makeTripletMcHistSpecMap(confTripletBinning, confMixing); + tripletTrackTrackSigma0Builder.init(&hRegistry, confCollisionBinning, confTrackSelections1, confTrackSelections2, confSigma0Selection, confTrackCleaner1, confTrackCleaner2, confSigma0Cleaner, confCtr, confMixing, confTripletBinning, confTripletCuts, colHistSpec, trackHistSpec1, trackHistSpec2, sigma0HistSpec, posDauHistSpec, negDauHistSpec, tripletHistSpec, ctrHistSpec, tripletCleanerHistSpec); + } + hRegistry.print(); + }; + + void processSameEvent(FilteredFemtoCollision const& col, FemtoTracks const& tracks, FemtoSigma0s const& /*sigmas*/) + { + tripletTrackTrackSigma0Builder.processSameEvent(col, tracks, trackPartition1, trackPartition2, sigma0Partition, cache); + } + PROCESS_SWITCH(FemtoTripletTrackTrackSigma0, processSameEvent, "Enable processing same event processing", true); + + void processSameEventMc(FilteredFemtoCollisionWithLabel const& col, o2::aod::FMcCols const& mcCols, FemtoTracksWithLabel const& tracks, FemtoSigma0sWithLabel const& /*sigmas*/, FemtoMcParticlesWithLabel const& mcParticles, o2::aod::FMcMothers const& mcMothers, o2::aod::FMcPartMoths const& mcPartonicMothers) + { + tripletTrackTrackSigma0Builder.processSameEvent(col, mcCols, tracks, trackWithLabelPartition1, trackWithLabelPartition2, sigma0WithLabelPartition, mcParticles, mcMothers, mcPartonicMothers, cache); + } + PROCESS_SWITCH(FemtoTripletTrackTrackSigma0, processSameEventMc, "Enable processing same event processing", false); + + void processMixedEvent(FilteredFemtoCollisions const& cols, FemtoTracks const& tracks, FemtoSigma0s const& /*sigmas*/) + { + tripletTrackTrackSigma0Builder.processMixedEvent(cols, tracks, trackPartition1, trackPartition2, sigma0Partition, cache, mixBinsVtxMult, mixBinsVtxCent, mixBinsVtxMultCent); + } + PROCESS_SWITCH(FemtoTripletTrackTrackSigma0, processMixedEvent, "Enable processing mixed event processing", true); + + void processMixedEventMc(FilteredFemtoCollisionsWithLabel const& cols, o2::aod::FMcCols const& mcCols, FemtoTracksWithLabel const& tracks, FemtoSigma0sWithLabel const& /*sigmas*/, FemtoMcParticlesWithLabel const& mcParticles, o2::aod::FMcMothers const& mcMothers, o2::aod::FMcPartMoths const& mcPartonicMothers) + { + tripletTrackTrackSigma0Builder.processMixedEvent(cols, mcCols, tracks, trackWithLabelPartition1, trackWithLabelPartition2, sigma0WithLabelPartition, mcParticles, mcMothers, mcPartonicMothers, cache, mixBinsVtxMult, mixBinsVtxCent, mixBinsVtxMultCent); + } + PROCESS_SWITCH(FemtoTripletTrackTrackSigma0, processMixedEventMc, "Enable processing mixed event processing", false); +}; + +o2::framework::WorkflowSpec defineDataProcessing(o2::framework::ConfigContext const& context) +{ + o2::framework::WorkflowSpec workflow{ + adaptAnalysisTask(context), + }; + return workflow; +}