From cb06ad37e520c681afb52c0f4e2d5397304d5166 Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Sat, 1 Nov 2025 00:09:16 +0100 Subject: [PATCH 01/22] DEBUG: allow to run several process functions --- DPG/Tasks/TPC/tpcSkimsTableCreator.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx index 7d2afbfec96..a3aa217482c 100644 --- a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx +++ b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx @@ -383,9 +383,9 @@ struct TreeWriterTpcV0 { void init(o2::framework::InitContext&) { const std::array doprocess{doprocessStandard, doprocessStandardWithCorrecteddEdx, doprocessWithdEdxTrQA, doprocessWithdEdxTrQAWithCorrecteddEdx, doprocessWithTrQA, doprocessWithTrQAWithCorrecteddEdx, doprocessDummy}; - if (std::accumulate(doprocess.begin(), doprocess.end(), 0) != 1) { - LOGP(fatal, "One and only one process function should be enabled"); - } + // if (std::accumulate(doprocess.begin(), doprocess.end(), 0) != 1) { + // LOGP(fatal, "One and only one process function should be enabled"); + // } ccdb->setURL("http://alice-ccdb.cern.ch"); ccdb->setCaching(true); @@ -850,9 +850,9 @@ struct TreeWriterTpcTof { void init(o2::framework::InitContext&) { const std::array doprocess{doprocessStandard, doprocessStandardWithCorrecteddEdx, doprocessWithdEdxTrQA, doprocessWithdEdxTrQAWithCorrecteddEdx, doprocessWithTrQA, doprocessWithTrQAWithCorrecteddEdx, doprocessDummy}; - if (std::accumulate(doprocess.begin(), doprocess.end(), 0) != 1) { - LOGP(fatal, "One and only one process function should be enabled"); - } + // if (std::accumulate(doprocess.begin(), doprocess.end(), 0) != 1) { + // LOGP(fatal, "One and only one process function should be enabled"); + // } ccdb->setURL("http://alice-ccdb.cern.ch"); ccdb->setCaching(true); From ce5861fb399492f659eae261c31dbe2f2d1b0462 Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Sun, 2 Nov 2025 20:02:52 +0100 Subject: [PATCH 02/22] simplify isEventSelected() function --- DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h b/DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h index 99c304959f0..acba9defae7 100644 --- a/DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h +++ b/DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h @@ -43,16 +43,11 @@ enum { template inline bool isEventSelected(const CollisionType& collision, const int applyEvSel) { - if (applyEvSel == EventSelectionRun2) { - if (!collision.sel7()) { - return false; - } - } else if (applyEvSel == EventSelectionRun3) { - if (!collision.sel8()) { - return false; - } + if ((applyEvSel == EventSelectionRun2 && !collision.sel7()) || (applyEvSel == EventSelectionRun3 && !collision.sel8())) { + return false; + } else { + return true; } - return true; }; /// Random downsampling trigger function using Tsalis/Hagedorn spectra fit (sqrt(s) = 62.4 GeV to 13 TeV) From 6d18624540cb26a30e2e90e4773a28aeab63ee6d Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Sun, 2 Nov 2025 20:11:51 +0100 Subject: [PATCH 03/22] define 'no tof' sigma as o2::aod::v0data::kNoTOFValue --- DPG/Tasks/TPC/tpcSkimsTableCreator.cxx | 4 ++-- PWGLF/DataModel/LFStrangenessPIDTables.h | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx index a3aa217482c..8b07a0d7505 100644 --- a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx +++ b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx @@ -81,8 +81,8 @@ struct TreeWriterTpcV0 { constexpr static o2::track::PID::ID PidProton{o2::track::PID::Proton}; // an arbitrary value of N sigma TOF assigned by TOF task to tracks which are not matched to TOF hits - constexpr static float NSigmaTofUnmatched{-1e6f}; - constexpr static float NSigmaTofUnmatchedEqualityTolerance{1000.f}; + constexpr static float NSigmaTofUnmatched{o2::aod::v0data::kNoTOFValue}; + constexpr static float NSigmaTofUnmatchedEqualityTolerance{std::fabs(NSigmaTofUnmatched) / 1e4f}; // an arbitrary value of "N sigma TOF" assigned to electorns (for uniformity reasons) constexpr static float NSigmaTofElectorn{1000.f}; diff --git a/PWGLF/DataModel/LFStrangenessPIDTables.h b/PWGLF/DataModel/LFStrangenessPIDTables.h index c815ece9653..a5ada65c32c 100644 --- a/PWGLF/DataModel/LFStrangenessPIDTables.h +++ b/PWGLF/DataModel/LFStrangenessPIDTables.h @@ -110,10 +110,10 @@ DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaPr, tpcNSigmaPr, //! unpacked TPC nsigma // ==== TOF INFORMATION === DECLARE_SOA_INDEX_COLUMN(DauTrackExtra, dauTrackExtra); //! point to daughter this TOF info belongs to DECLARE_SOA_INDEX_COLUMN(StraCollision, straCollision); //! point to collision associated with this track (not the V0/Casc) -DECLARE_SOA_COLUMN(TOFSignal, tofSignal, float); //! track TOF signal -DECLARE_SOA_COLUMN(TOFEvTime, tofEvTime, float); //! event time -DECLARE_SOA_COLUMN(Length, length, float); //! track length (to assigned PV) -DECLARE_SOA_COLUMN(TOFExpMom, tofExpMom, float); //! tof Exp Mom (to assigned PV) +DECLARE_SOA_COLUMN(TOFSignal, tofSignal, float); //! track TOF signal +DECLARE_SOA_COLUMN(TOFEvTime, tofEvTime, float); //! event time +DECLARE_SOA_COLUMN(Length, length, float); //! track length (to assigned PV) +DECLARE_SOA_COLUMN(TOFExpMom, tofExpMom, float); //! tof Exp Mom (to assigned PV) // dynamics with expected times DECLARE_SOA_DYNAMIC_COLUMN(TOFExpTimeEl, tofExpTimeEl, //! Expected time for the track to reach the TOF under the electron hypothesis @@ -176,7 +176,7 @@ using DauTrackTOFPIDs = DauTrackTOFPIDs_001; // second gen: with collision Id, w namespace v0data { // define constants for NSigma operation -const float kNoTOFValue = -1e+6; +constexpr float kNoTOFValue = -1e+6; const float kEpsilon = 1e-4; // ==== TOF INFORMATION === @@ -187,8 +187,8 @@ DECLARE_SOA_COLUMN(PosTOFSignal, posTOFSignal, float); //! positive trac DECLARE_SOA_COLUMN(NegTOFSignal, negTOFSignal, float); //! negative track signal DECLARE_SOA_COLUMN(PosTOFEventTime, posTOFEventTime, float); //! positive track event time DECLARE_SOA_COLUMN(NegTOFEventTime, negTOFEventTime, float); //! negative track event time -DECLARE_SOA_COLUMN(PosTOFLength, posTOFLength, float); //! positive track length, recalculated -DECLARE_SOA_COLUMN(NegTOFLength, negTOFLength, float); //! negative track length, recalculated +DECLARE_SOA_COLUMN(PosTOFLength, posTOFLength, float); //! positive track length, recalculated +DECLARE_SOA_COLUMN(NegTOFLength, negTOFLength, float); //! negative track length, recalculated // delta-times DECLARE_SOA_COLUMN(PosTOFDeltaTLaPi, posTOFDeltaTLaPi, float); //! positive track TOFDeltaT from pion <- lambda expectation From 57e0134a9b4bf4f09953b04e1d2a825ee539ce72 Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Sun, 2 Nov 2025 20:22:03 +0100 Subject: [PATCH 04/22] remove template from TrackQa --- DPG/Tasks/TPC/tpcSkimsTableCreator.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx index 8b07a0d7505..033abf2fae4 100644 --- a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx +++ b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx @@ -279,8 +279,8 @@ struct TreeWriterTpcV0 { } }; - template - void fillSkimmedV0TableWithTrQAGeneric(V0Casc const& v0casc, T const& track, TQA const& trackQA, const bool existTrkQA, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float dEdxExp, const o2::track::PID::ID id, const int runnumber, const double dwnSmplFactor, const float hadronicRate, const int bcGlobalIndex, const int bcTimeFrameId, const int bcBcInTimeFrame) + template + void fillSkimmedV0TableWithTrQAGeneric(V0Casc const& v0casc, T const& track, aod::TracksQA const& trackQA, const bool existTrkQA, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float dEdxExp, const o2::track::PID::ID id, const int runnumber, const double dwnSmplFactor, const float hadronicRate, const int bcGlobalIndex, const int bcTimeFrameId, const int bcBcInTimeFrame) { const double ncl = track.tpcNClsFound(); const double nclPID = track.tpcNClsFindableMinusPID(); @@ -765,8 +765,8 @@ struct TreeWriterTpcTof { } }; - template - void fillSkimmedTPCTOFTableWithTrkQAGeneric(T const& track, TQA const& trackQA, const bool existTrkQA, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float nSigmaITS, const float dEdxExp, const o2::track::PID::ID id, const int runnumber, const double dwnSmplFactor, const double hadronicRate, const int bcGlobalIndex, const int bcTimeFrameId, const int bcBcInTimeFrame) + template + void fillSkimmedTPCTOFTableWithTrkQAGeneric(T const& track, aod::TracksQA const& trackQA, const bool existTrkQA, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float nSigmaITS, const float dEdxExp, const o2::track::PID::ID id, const int runnumber, const double dwnSmplFactor, const double hadronicRate, const int bcGlobalIndex, const int bcTimeFrameId, const int bcBcInTimeFrame) { const double ncl = track.tpcNClsFound(); const double nclPID = track.tpcNClsFindableMinusPID(); From 1301658bd91e7ebcccee0e7eb14792f09e0a8aa4 Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Tue, 18 Nov 2025 19:19:18 +0100 Subject: [PATCH 05/22] merge w/o and w/ TrkQA (to be tested) --- DPG/Tasks/TPC/tpcSkimsTableCreator.cxx | 421 ++++++++-------------- DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h | 6 + 2 files changed, 157 insertions(+), 270 deletions(-) diff --git a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx index 033abf2fae4..02535296ba2 100644 --- a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx +++ b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx @@ -221,65 +221,7 @@ struct TreeWriterTpcV0 { return -999.f; } - /// Function to fill skimmed tables - template - void fillSkimmedV0Table(V0Casc const& v0casc, T const& track, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float dEdxExp, const o2::track::PID::ID id, const int runnumber, const double dwnSmplFactor, const float hadronicRate) - { - - const double ncl = track.tpcNClsFound(); - const double nclPID = track.tpcNClsFindableMinusPID(); - const double p = track.tpcInnerParam(); - const double mass = o2::track::pid_constants::sMasses[id]; - const double bg = p / mass; - const int multTPC = collision.multTPC(); - const auto trackOcc = collision.trackOccupancyInTimeRange(); - const auto ft0Occ = collision.ft0cOccupancyInTimeRange(); - - const float alpha = v0casc.alpha(); - const float qt = v0casc.qtarm(); - const float cosPA = getCosPA(v0casc, collision); - const float pT = v0casc.pt(); - const float v0radius = getRadius(v0casc); - const float gammapsipair = v0casc.psipair(); - - const double pseudoRndm = track.pt() * 1000. - static_cast(track.pt() * 1000); - if (pseudoRndm < dwnSmplFactor) { - float usedDedx; - if constexpr (DoUseCorrectedDeDx) { - usedDedx = track.tpcSignalCorrected(); - } else { - usedDedx = track.tpcSignal(); - } - rowTPCTree(usedDedx, - 1. / dEdxExp, - track.tpcInnerParam(), - track.tgl(), - track.signed1Pt(), - track.eta(), - track.phi(), - track.y(), - mass, - bg, - multTPC / 11000., - std::sqrt(nClNorm / ncl), - nclPID, - id, - nSigmaTPC, - nSigmaTOF, - runnumber, - trackOcc, - ft0Occ, - hadronicRate, - alpha, - qt, - cosPA, - pT, - v0radius, - gammapsipair); - } - }; - - template + template void fillSkimmedV0TableWithTrQAGeneric(V0Casc const& v0casc, T const& track, aod::TracksQA const& trackQA, const bool existTrkQA, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float dEdxExp, const o2::track::PID::ID id, const int runnumber, const double dwnSmplFactor, const float hadronicRate, const int bcGlobalIndex, const int bcTimeFrameId, const int bcBcInTimeFrame) { const double ncl = track.tpcNClsFound(); @@ -306,7 +248,34 @@ struct TreeWriterTpcV0 { } else { usedDedx = track.tpcSignal(); } - if constexpr (IsWithdEdx) { + if constexpr (ModeId == ModeStandard) { + rowTPCTree(usedDedx, + 1. / dEdxExp, + track.tpcInnerParam(), + track.tgl(), + track.signed1Pt(), + track.eta(), + track.phi(), + track.y(), + mass, + bg, + multTPC / 11000., + std::sqrt(nClNorm / ncl), + nclPID, + id, + nSigmaTPC, + nSigmaTOF, + runnumber, + trackOcc, + ft0Occ, + hadronicRate, + alpha, + qt, + cosPA, + pT, + v0radius, + gammapsipair); + } else if constexpr (ModeId == ModeWithdEdxTrkQA) { rowTPCTreeWithdEdxTrkQA(usedDedx, 1. / dEdxExp, track.tpcInnerParam(), @@ -334,7 +303,7 @@ struct TreeWriterTpcV0 { v0radius, gammapsipair, existTrkQA ? trackQA.tpcdEdxNorm() : -999); - } else { + } else if constexpr (ModeId == ModeWithTrkQA) { rowTPCTreeWithTrkQA(usedDedx, 1. / dEdxExp, track.tpcInnerParam(), @@ -383,9 +352,9 @@ struct TreeWriterTpcV0 { void init(o2::framework::InitContext&) { const std::array doprocess{doprocessStandard, doprocessStandardWithCorrecteddEdx, doprocessWithdEdxTrQA, doprocessWithdEdxTrQAWithCorrecteddEdx, doprocessWithTrQA, doprocessWithTrQAWithCorrecteddEdx, doprocessDummy}; - // if (std::accumulate(doprocess.begin(), doprocess.end(), 0) != 1) { - // LOGP(fatal, "One and only one process function should be enabled"); - // } + if (std::accumulate(doprocess.begin(), doprocess.end(), 0) != 1) { + LOGP(fatal, "One and only one process function should be enabled"); + } ccdb->setURL("http://alice-ccdb.cern.ch"); ccdb->setCaching(true); @@ -429,82 +398,21 @@ struct TreeWriterTpcV0 { } } - template - void runStandard(Colls::iterator const& collision, V0sWithID const& v0s, CascsWithID const& cascs) - { - /// Check event slection - if (!isEventSelected(collision, applyEvSel)) { - return; - } - const auto& bc = collision.bc_as(); - const int runnumber = bc.runNumber(); - const float hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, irSource) * 1.e-3; - - rowTPCTree.reserve(2 * v0s.size() + cascs.size()); - - auto fillDaughterTrack = [&](const auto& mother, const TrksType::iterator& dauTrack, const V0Daughter& daughter) { - const bool passTrackSelection = isTrackSelected(dauTrack, trackSelection); - const bool passDownsamplig = downsampleTsalisCharged(fRndm, dauTrack.pt(), daughter.downsamplingTsalis, daughter.mass, sqrtSNN, daughter.maxPt4dwnsmplTsalis); - const bool passNSigmaTofCut = std::fabs(daughter.tofNSigma) < daughter.nSigmaTofDauTrack || std::fabs(daughter.tofNSigma - NSigmaTofUnmatched) < NSigmaTofUnmatchedEqualityTolerance; - const bool passMatchTofRequirement = !daughter.rejectNoTofDauTrack || std::fabs(daughter.tofNSigma - NSigmaTofUnmatched) > NSigmaTofUnmatchedEqualityTolerance; - if (passTrackSelection && passDownsamplig && passNSigmaTofCut && passMatchTofRequirement) { - fillSkimmedV0Table(mother, dauTrack, collision, daughter.tpcNSigma, daughter.tofNSigma, daughter.tpcExpSignal, daughter.id, runnumber, daughter.dwnSmplFactor, hadronicRate); - } - }; - - /// Loop over v0 candidates - for (const auto& v0 : v0s) { - const auto v0Id = v0.v0addid(); - if (v0Id == MotherUndef) { - continue; - } - const auto& posTrack = v0.posTrack_as(); - const auto& negTrack = v0.negTrack_as(); - - const V0Mother v0Mother = createV0Mother(v0Id); - const V0Daughter posDaughter = createV0Daughter(v0, posTrack, v0Id, v0Mother.posDaughterId, true); - const V0Daughter negDaughter = createV0Daughter(v0, negTrack, v0Id, v0Mother.negDaughterId, false); - - fillDaughterTrack(v0, posTrack, posDaughter); - fillDaughterTrack(v0, negTrack, negDaughter); - } - - /// Loop over cascade candidates - for (const auto& casc : cascs) { - const auto cascId = casc.cascaddid(); - if (cascId == MotherUndef) { - continue; - } - const auto& bachTrack = casc.bachelor_as(); - const V0Daughter bachDaughter = createV0Daughter(casc, bachTrack, cascId, DaughterKaon); - // Omega and antiomega - fillDaughterTrack(casc, bachTrack, bachDaughter); - } - } - - /// Apply a track quality selection with a filter! - void processStandard(Colls::iterator const& collision, Trks const&, V0sWithID const& v0s, CascsWithID const& cascs, aod::BCsWithTimestamps const&) - { - runStandard(collision, v0s, cascs); - } /// process Standard - PROCESS_SWITCH(TreeWriterTpcV0, processStandard, "Standard V0 Samples for PID", true); - - void processStandardWithCorrecteddEdx(Colls::iterator const& collision, TrksWithDEdxCorrection const&, V0sWithID const& v0s, CascsWithID const& cascs, aod::BCsWithTimestamps const&) - { - runStandard(collision, v0s, cascs); - } /// process StandardWithCorrecteddEdx - PROCESS_SWITCH(TreeWriterTpcV0, processStandardWithCorrecteddEdx, "Standard V0 Samples for PID with corrected dEdx", false); - Preslice perCollisionV0s = aod::v0data::collisionId; Preslice perCollisionCascs = aod::cascdata::collisionId; - template - void runWithTrQAGeneric(Colls const& collisions, TrksType const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, aod::TracksQAVersion const& tracksQA) + template + void runWithTrQAGeneric(Colls const& collisions, TrksType const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, TrkQAType const& tracksQA) { - std::vector labelTrack2TrackQA(myTracks.size(), -1); - for (const auto& trackQA : tracksQA) { - const int64_t trackId = trackQA.trackId(); - labelTrack2TrackQA.at(trackId) = trackQA.globalIndex(); + constexpr bool IsWithTrackQa = ModeId != ModeStandard; + + std::vector labelTrack2TrackQA; + if constexpr (IsWithTrackQa) { + labelTrack2TrackQA.resize(myTracks.size(), -1); + for (const auto& trackQA : tracksQA) { + const int64_t trackId = trackQA.trackId(); + labelTrack2TrackQA.at(trackId) = trackQA.globalIndex(); + } } for (const auto& collision : collisions) { /// Check event slection @@ -518,16 +426,17 @@ struct TreeWriterTpcV0 { const float hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, irSource) * 1.e-3; const int bcGlobalIndex = bc.globalIndex(); int bcTimeFrameId, bcBcInTimeFrame; - if constexpr (IsWithdEdx) { + if constexpr (ModeId == ModeWithdEdxTrkQA || ModeId == ModeStandard) { bcTimeFrameId = -999; bcBcInTimeFrame = -999; - } else { + if constexpr (ModeId == ModeWithdEdxTrkQA) { + rowTPCTreeWithdEdxTrkQA.reserve(2 * v0s.size() + cascs.size()); + } else if (ModeId == ModeStandard) { + rowTPCTree.reserve(2 * v0s.size() + cascs.size()); + } + } else if constexpr (ModeId == ModeWithTrkQA) { bcTimeFrameId = bc.tfId(); bcBcInTimeFrame = bc.bcInTF(); - } - if constexpr (IsWithdEdx) { - rowTPCTreeWithdEdxTrkQA.reserve(2 * v0s.size() + cascs.size()); - } else { rowTPCTreeWithTrkQA.reserve(2 * v0s.size() + cascs.size()); } @@ -537,18 +446,22 @@ struct TreeWriterTpcV0 { const bool passNSigmaTofCut = std::fabs(daughter.tofNSigma) < daughter.nSigmaTofDauTrack || std::fabs(daughter.tofNSigma - NSigmaTofUnmatched) < NSigmaTofUnmatchedEqualityTolerance; const bool passMatchTofRequirement = !daughter.rejectNoTofDauTrack || std::fabs(daughter.tofNSigma - NSigmaTofUnmatched) > NSigmaTofUnmatchedEqualityTolerance; if (passTrackSelection && passDownsamplig && passNSigmaTofCut && passMatchTofRequirement) { - fillSkimmedV0TableWithTrQAGeneric(mother, dauTrack, trackQAInstance, existTrkQA, collision, daughter.tpcNSigma, daughter.tofNSigma, daughter.tpcExpSignal, daughter.id, runnumber, daughter.dwnSmplFactor, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + fillSkimmedV0TableWithTrQAGeneric(mother, dauTrack, trackQAInstance, existTrkQA, collision, daughter.tpcNSigma, daughter.tofNSigma, daughter.tpcExpSignal, daughter.id, runnumber, daughter.dwnSmplFactor, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); } }; auto getTrackQA = [&](const TrksType::iterator& track) { - const auto trackGlobalIndex = track.globalIndex(); - const auto label = labelTrack2TrackQA.at(trackGlobalIndex); - const bool existTrkQA = (label != -1); - const int64_t trkIndex = existTrkQA ? label : 0; - const aod::TracksQA& trkQA = tracksQA.iteratorAt(trkIndex); - - return std::make_pair(trkQA, existTrkQA); + if constexpr (!IsWithTrackQa) { + return std::make_pair(aod::TracksQA{}, false); + } else { + const auto trackGlobalIndex = track.globalIndex(); + const auto label = labelTrack2TrackQA.at(trackGlobalIndex); + const bool existTrkQA = (label != -1); + const int64_t trkIndex = existTrkQA ? label : 0; + const aod::TracksQA& trkQA = tracksQA.iteratorAt(trkIndex); + + return std::make_pair(trkQA, existTrkQA); + } }; /// Loop over v0 candidates @@ -586,27 +499,40 @@ struct TreeWriterTpcV0 { } } + /// Apply a track quality selection with a filter! + void processStandard(Colls const& collisions, Trks const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, aod::BCsWithTimestamps const&) + { + runWithTrQAGeneric(collisions, myTracks, myV0s, myCascs, static_cast(nullptr)); + } /// process Standard + PROCESS_SWITCH(TreeWriterTpcV0, processStandard, "Standard V0 Samples for PID", true); + + void processStandardWithCorrecteddEdx(Colls const& collisions, TrksWithDEdxCorrection const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, aod::BCsWithTimestamps const&) + { + runWithTrQAGeneric(collisions, myTracks, myV0s, myCascs, static_cast(nullptr)); + } /// process StandardWithCorrecteddEdx + PROCESS_SWITCH(TreeWriterTpcV0, processStandardWithCorrecteddEdx, "Standard V0 Samples for PID with corrected dEdx", false); + void processWithdEdxTrQA(Colls const& collisions, Trks const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, aod::BCsWithTimestamps const&, aod::TracksQAVersion const& tracksQA) { - runWithTrQAGeneric(collisions, myTracks, myV0s, myCascs, tracksQA); + runWithTrQAGeneric(collisions, myTracks, myV0s, myCascs, tracksQA); } /// process with dEdx from TrackQA PROCESS_SWITCH(TreeWriterTpcV0, processWithdEdxTrQA, "Standard V0 Samples with dEdx from Track QA for PID", false); void processWithdEdxTrQAWithCorrecteddEdx(Colls const& collisions, TrksWithDEdxCorrection const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, aod::BCsWithTimestamps const&, aod::TracksQAVersion const& tracksQA) { - runWithTrQAGeneric(collisions, myTracks, myV0s, myCascs, tracksQA); + runWithTrQAGeneric(collisions, myTracks, myV0s, myCascs, tracksQA); } /// process with dEdx from TrackQA PROCESS_SWITCH(TreeWriterTpcV0, processWithdEdxTrQAWithCorrecteddEdx, "Standard V0 Samples with dEdx from Track QA for PID with corrected dEdx", false); void processWithTrQA(Colls const& collisions, Trks const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, MyBCTable const&, aod::TracksQAVersion const& tracksQA) { - runWithTrQAGeneric(collisions, myTracks, myV0s, myCascs, tracksQA); + runWithTrQAGeneric(collisions, myTracks, myV0s, myCascs, tracksQA); } /// process with TrackQA PROCESS_SWITCH(TreeWriterTpcV0, processWithTrQA, "Standard V0 Samples with Track QA for PID", false); void processWithTrQAWithCorrecteddEdx(Colls const& collisions, TrksWithDEdxCorrection const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, MyBCTable const&, aod::TracksQAVersion const& tracksQA) { - runWithTrQAGeneric(collisions, myTracks, myV0s, myCascs, tracksQA); + runWithTrQAGeneric(collisions, myTracks, myV0s, myCascs, tracksQA); } /// process with TrackQA PROCESS_SWITCH(TreeWriterTpcV0, processWithTrQAWithCorrecteddEdx, "Standard V0 Samples with Track QA for PID with corrected dEdx", false); @@ -719,53 +645,7 @@ struct TreeWriterTpcTof { TRandom3* fRndm = new TRandom3(0); - /// Function to fill trees - template - void fillSkimmedTPCTOFTable(T const& track, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float nSigmaITS, const float dEdxExp, const o2::track::PID::ID id, const int runnumber, const double dwnSmplFactor, const double hadronicRate) - { - - const double ncl = track.tpcNClsFound(); - const double nclPID = track.tpcNClsFindableMinusPID(); - const double p = track.tpcInnerParam(); - const double mass = o2::track::pid_constants::sMasses[id]; - const double bg = p / mass; - const int multTPC = collision.multTPC(); - const auto trackOcc = collision.trackOccupancyInTimeRange(); - const auto ft0Occ = collision.ft0cOccupancyInTimeRange(); - - const double pseudoRndm = track.pt() * 1000. - static_cast(track.pt() * 1000); - if (pseudoRndm < dwnSmplFactor) { - float usedEdx; - if constexpr (DoCorrectDeDx) { - usedEdx = track.tpcSignalCorrected(); - } else { - usedEdx = track.tpcSignal(); - } - rowTPCTOFTree(usedEdx, - 1. / dEdxExp, - track.tpcInnerParam(), - track.tgl(), - track.signed1Pt(), - track.eta(), - track.phi(), - track.y(), - mass, - bg, - multTPC / 11000., - std::sqrt(nClNorm / ncl), - nclPID, - id, - nSigmaTPC, - nSigmaTOF, - runnumber, - trackOcc, - ft0Occ, - hadronicRate, - nSigmaITS); - } - }; - - template + template void fillSkimmedTPCTOFTableWithTrkQAGeneric(T const& track, aod::TracksQA const& trackQA, const bool existTrkQA, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float nSigmaITS, const float dEdxExp, const o2::track::PID::ID id, const int runnumber, const double dwnSmplFactor, const double hadronicRate, const int bcGlobalIndex, const int bcTimeFrameId, const int bcBcInTimeFrame) { const double ncl = track.tpcNClsFound(); @@ -785,7 +665,29 @@ struct TreeWriterTpcTof { } else { usedEdx = track.tpcSignal(); } - if constexpr (IsWithdEdx) { + if (ModeId == ModeStandard) { + rowTPCTOFTree(usedEdx, + 1. / dEdxExp, + track.tpcInnerParam(), + track.tgl(), + track.signed1Pt(), + track.eta(), + track.phi(), + track.y(), + mass, + bg, + multTPC / 11000., + std::sqrt(nClNorm / ncl), + nclPID, + id, + nSigmaTPC, + nSigmaTOF, + runnumber, + trackOcc, + ft0Occ, + hadronicRate, + nSigmaITS); + } else if constexpr (ModeId == ModeWithdEdxTrkQA) { rowTPCTOFTreeWithdEdxTrkQA(usedEdx, 1. / dEdxExp, track.tpcInnerParam(), @@ -808,7 +710,7 @@ struct TreeWriterTpcTof { hadronicRate, nSigmaITS, existTrkQA ? trackQA.tpcdEdxNorm() : -999); - } else { + } else if constexpr (ModeId == ModeWithTrkQA) { rowTPCTOFTreeWithTrkQA(usedEdx, 1. / dEdxExp, track.tpcInnerParam(), @@ -850,9 +752,9 @@ struct TreeWriterTpcTof { void init(o2::framework::InitContext&) { const std::array doprocess{doprocessStandard, doprocessStandardWithCorrecteddEdx, doprocessWithdEdxTrQA, doprocessWithdEdxTrQAWithCorrecteddEdx, doprocessWithTrQA, doprocessWithTrQAWithCorrecteddEdx, doprocessDummy}; - // if (std::accumulate(doprocess.begin(), doprocess.end(), 0) != 1) { - // LOGP(fatal, "One and only one process function should be enabled"); - // } + if (std::accumulate(doprocess.begin(), doprocess.end(), 0) != 1) { + LOGP(fatal, "One and only one process function should be enabled"); + } ccdb->setURL("http://alice-ccdb.cern.ch"); ccdb->setCaching(true); @@ -870,63 +772,21 @@ struct TreeWriterTpcTof { } } - template - void runStandard(Colls::iterator const& collision, soa::Filtered const& tracks) - { - /// Check event selection - if (!isEventSelected(collision, applyEvSel)) { - return; - } - const auto& bc = collision.bc_as(); - const int runnumber = bc.runNumber(); - const float hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, irSource) * 1.e-3; - - rowTPCTOFTree.reserve(tracks.size()); - for (auto const& trk : tracks) { - - TofTrack tofTriton(true, maxMomHardCutOnlyTr, maxMomTPCOnlyTr, trk.tpcNSigmaTr(), nSigmaTPCOnlyTr, downsamplingTsalisTritons, MassTriton, trk.tofNSigmaTr(), -999., trk.tpcExpSignalTr(tpcSignalGeneric(trk)), PidTriton, dwnSmplFactorTr, nSigmaTofTpctofTr, nSigmaTpcTpctofTr); - - TofTrack tofDeuteron(true, maxMomHardCutOnlyDe, maxMomTPCOnlyDe, trk.tpcNSigmaDe(), nSigmaTPCOnlyDe, downsamplingTsalisDeuterons, MassDeuteron, trk.tofNSigmaDe(), -999., trk.tpcExpSignalDe(tpcSignalGeneric(trk)), PidDeuteron, dwnSmplFactorDe, nSigmaTofTpctofDe, nSigmaTpcTpctofDe); - - TofTrack tofProton(false, -999., maxMomTPCOnlyPr, trk.tpcNSigmaPr(), nSigmaTPCOnlyPr, downsamplingTsalisProtons, MassProton, trk.tofNSigmaPr(), -999., trk.tpcExpSignalPr(tpcSignalGeneric(trk)), PidProton, dwnSmplFactorPr, nSigmaTofTpctofPr, nSigmaTpcTpctofPr); - - TofTrack tofKaon(true, maxMomHardCutOnlyKa, maxMomTPCOnlyKa, trk.tpcNSigmaKa(), nSigmaTPCOnlyKa, downsamplingTsalisKaons, MassKPlus, trk.tofNSigmaKa(), -999., trk.tpcExpSignalKa(tpcSignalGeneric(trk)), PidKaon, dwnSmplFactorKa, nSigmaTofTpctofKa, nSigmaTpcTpctofKa); - - TofTrack tofPion(false, -999., maxMomTPCOnlyPi, trk.tpcNSigmaPi(), nSigmaTPCOnlyPi, downsamplingTsalisPions, MassPiPlus, trk.tofNSigmaPi(), -999., trk.tpcExpSignalPi(tpcSignalGeneric(trk)), PidPion, dwnSmplFactorPi, nSigmaTofTpctofPi, nSigmaTpcTpctofPi); - - for (const auto& tofTrack : {&tofTriton, &tofDeuteron, &tofProton, &tofKaon, &tofPion}) { - if ((!tofTrack->isApplyHardCutOnly || trk.tpcInnerParam() < tofTrack->maxMomHardCutOnly) && - ((trk.tpcInnerParam() <= tofTrack->maxMomTPCOnly && std::fabs(tofTrack->tpcNSigma) < tofTrack->nSigmaTPCOnly) || - (trk.tpcInnerParam() > tofTrack->maxMomTPCOnly && std::fabs(tofTrack->tofNSigma) < tofTrack->nSigmaTofTpctof && std::fabs(tofTrack->tpcNSigma) < tofTrack->nSigmaTpcTpctof)) && - downsampleTsalisCharged(fRndm, trk.pt(), tofTrack->downsamplingTsalis, tofTrack->mass, sqrtSNN)) { - fillSkimmedTPCTOFTable(trk, collision, tofTrack->tpcNSigma, tofTrack->tofNSigma, tofTrack->itsNSigma, tofTrack->tpcExpSignal, tofTrack->pid, runnumber, tofTrack->dwnSmplFactor, hadronicRate); - } - } - } /// Loop tracks - } - - void processStandard(Colls::iterator const& collision, soa::Filtered const& tracks, aod::BCsWithTimestamps const&) - { - runStandard(collision, tracks); - } /// process - PROCESS_SWITCH(TreeWriterTpcTof, processStandard, "Standard Samples for PID", true); - - void processStandardWithCorrecteddEdx(Colls::iterator const& collision, soa::Filtered const& tracks, aod::BCsWithTimestamps const&) - { - runStandard(collision, tracks); - } /// process - PROCESS_SWITCH(TreeWriterTpcTof, processStandardWithCorrecteddEdx, "Standard Samples for PID with corrected dEdx", false); - Preslice perCollisionTracks = aod::track::collisionId; Preslice perCollisionTracksWithCorrecteddEdx = aod::track::collisionId; - template - void runWithTrQAGeneric(Colls const& collisions, TrksType const& myTracks, aod::TracksQAVersion const& tracksQA, Preslice const& perCollisionTracksType) + template + void runWithTrQAGeneric(Colls const& collisions, TrksType const& myTracks, TrkQAType const& tracksQA, Preslice const& perCollisionTracksType) { - std::vector labelTrack2TrackQA(myTracks.size(), -1); - for (const auto& trackQA : tracksQA) { - const int64_t trackId = trackQA.trackId(); - labelTrack2TrackQA.at(trackId) = trackQA.globalIndex(); + constexpr bool IsWithTrackQa = ModeId != ModeStandard; + + std::vector labelTrack2TrackQA; + if constexpr (IsWithTrackQa) { + labelTrack2TrackQA.resize(myTracks.size(), -1); + for (const auto& trackQA : tracksQA) { + const int64_t trackId = trackQA.trackId(); + labelTrack2TrackQA.at(trackId) = trackQA.globalIndex(); + } } for (const auto& collision : collisions) { /// Check event selection @@ -943,25 +803,34 @@ struct TreeWriterTpcTof { const int runnumber = bc.runNumber(); float hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, irSource) * 1.e-3; int bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame; - if constexpr (IsWithdEdx) { + if constexpr (ModeId == ModeStandard || ModeId == ModeWithdEdxTrkQA) { bcGlobalIndex = -999; bcTimeFrameId = -999; bcBcInTimeFrame = -999; + if constexpr (ModeId == ModeStandard) { + rowTPCTOFTree.reserve(tracks.size()); + } else { + rowTPCTOFTreeWithdEdxTrkQA.reserve(tracks.size()); + } } else { bcGlobalIndex = bc.globalIndex(); bcTimeFrameId = bc.tfId(); bcBcInTimeFrame = bc.bcInTF(); + rowTPCTOFTreeWithTrkQA.reserve(tracks.size()); } - rowTPCTOFTreeWithTrkQA.reserve(tracks.size()); for (auto const& trk : tracksWithITSPid) { if (!isTrackSelected(trk, trackSelection)) { continue; } // get the corresponding trackQA using labelTracks2TracKQA and get variables of interest - const auto label = labelTrack2TrackQA.at(trk.globalIndex()); - const bool existTrkQA = (label != -1); - const int64_t trkIndex = existTrkQA ? label : 0; - const aod::TracksQA& trackQA = tracksQA.iteratorAt(trkIndex); + aod::TracksQA trackQA{}; + bool existTrkQA{false}; + if constexpr (IsWithTrackQa) { + const auto label = labelTrack2TrackQA.at(trk.globalIndex()); + existTrkQA = (label != -1); + const int64_t trkIndex = existTrkQA ? label : 0; + trackQA = tracksQA.iteratorAt(trkIndex); + } TofTrack tofTriton(true, maxMomHardCutOnlyTr, maxMomTPCOnlyTr, trk.tpcNSigmaTr(), nSigmaTPCOnlyTr, downsamplingTsalisTritons, MassTriton, trk.tofNSigmaTr(), trk.itsNSigmaTr(), trk.tpcExpSignalTr(tpcSignalGeneric(trk)), PidTriton, dwnSmplFactorTr, nSigmaTofTpctofTr, nSigmaTpcTpctofTr); @@ -978,34 +847,46 @@ struct TreeWriterTpcTof { ((trk.tpcInnerParam() <= tofTrack->maxMomTPCOnly && std::fabs(tofTrack->tpcNSigma) < tofTrack->nSigmaTPCOnly) || (trk.tpcInnerParam() > tofTrack->maxMomTPCOnly && std::fabs(tofTrack->tofNSigma) < tofTrack->nSigmaTofTpctof && std::fabs(tofTrack->tpcNSigma) < tofTrack->nSigmaTpcTpctof)) && downsampleTsalisCharged(fRndm, trk.pt(), tofTrack->downsamplingTsalis, tofTrack->mass, sqrtSNN)) { - fillSkimmedTPCTOFTableWithTrkQAGeneric(trk, trackQA, existTrkQA, collision, tofTrack->tpcNSigma, tofTrack->tofNSigma, tofTrack->itsNSigma, tofTrack->tpcExpSignal, tofTrack->pid, runnumber, tofTrack->dwnSmplFactor, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + fillSkimmedTPCTOFTableWithTrkQAGeneric(trk, trackQA, existTrkQA, collision, tofTrack->tpcNSigma, tofTrack->tofNSigma, tofTrack->itsNSigma, tofTrack->tpcExpSignal, tofTrack->pid, runnumber, tofTrack->dwnSmplFactor, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); } } } /// Loop tracks } } + void processStandard(Colls const& collisions, Trks const& myTracks, aod::BCsWithTimestamps const&) + { + runWithTrQAGeneric(collisions, myTracks, static_cast(nullptr), perCollisionTracks); + } /// process + PROCESS_SWITCH(TreeWriterTpcTof, processStandard, "Standard Samples for PID", true); + + void processStandardWithCorrecteddEdx(Colls const& collisions, TrksWithDEdxCorrection const& myTracks, aod::BCsWithTimestamps const&) + { + runWithTrQAGeneric(collisions, myTracks, static_cast(nullptr), perCollisionTracksWithCorrecteddEdx); + } /// process + PROCESS_SWITCH(TreeWriterTpcTof, processStandardWithCorrecteddEdx, "Standard Samples for PID with corrected dEdx", false); + void processWithdEdxTrQA(Colls const& collisions, Trks const& myTracks, aod::BCsWithTimestamps const&, aod::TracksQAVersion const& tracksQA) { - runWithTrQAGeneric(collisions, myTracks, tracksQA, perCollisionTracks); + runWithTrQAGeneric(collisions, myTracks, tracksQA, perCollisionTracks); } /// process PROCESS_SWITCH(TreeWriterTpcTof, processWithdEdxTrQA, "Samples for PID with TrackQA info", false); void processWithdEdxTrQAWithCorrecteddEdx(Colls const& collisions, TrksWithDEdxCorrection const& myTracks, aod::BCsWithTimestamps const&, aod::TracksQAVersion const& tracksQA) { - runWithTrQAGeneric(collisions, myTracks, tracksQA, perCollisionTracksWithCorrecteddEdx); + runWithTrQAGeneric(collisions, myTracks, tracksQA, perCollisionTracksWithCorrecteddEdx); } /// process PROCESS_SWITCH(TreeWriterTpcTof, processWithdEdxTrQAWithCorrecteddEdx, "Samples for PID with TrackQA info with corrected dEdx", false); void processWithTrQA(Colls const& collisions, Trks const& myTracks, MyBCTable const&, aod::TracksQAVersion const& tracksQA) { - runWithTrQAGeneric(collisions, myTracks, tracksQA, perCollisionTracks); + runWithTrQAGeneric(collisions, myTracks, tracksQA, perCollisionTracks); } /// process PROCESS_SWITCH(TreeWriterTpcTof, processWithTrQA, "Samples for PID with TrackQA info", false); void processWithTrQAWithCorrecteddEdx(Colls const& collisions, TrksWithDEdxCorrection const& myTracks, MyBCTable const&, aod::TracksQAVersion const& tracksQA) { - runWithTrQAGeneric(collisions, myTracks, tracksQA, perCollisionTracksWithCorrecteddEdx); + runWithTrQAGeneric(collisions, myTracks, tracksQA, perCollisionTracksWithCorrecteddEdx); } /// process PROCESS_SWITCH(TreeWriterTpcTof, processWithTrQAWithCorrecteddEdx, "Samples for PID with TrackQA info with correced dEdx", false); diff --git a/DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h b/DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h index acba9defae7..b4cbd0052c8 100644 --- a/DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h +++ b/DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h @@ -39,6 +39,12 @@ enum { EventSelectionRun3 }; +enum { + ModeStandard = 0, + ModeWithdEdxTrkQA, + ModeWithTrkQA +}; + /// Event selection template inline bool isEventSelected(const CollisionType& collision, const int applyEvSel) From 6a9318906c8b345c85c75ff34b8e6c05599c8f02 Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Wed, 19 Nov 2025 13:43:13 +0100 Subject: [PATCH 06/22] rename fill() and run() functions --- DPG/Tasks/TPC/tpcSkimsTableCreator.cxx | 36 +++++++++++++------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx index 02535296ba2..1f4d187f175 100644 --- a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx +++ b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx @@ -222,7 +222,7 @@ struct TreeWriterTpcV0 { } template - void fillSkimmedV0TableWithTrQAGeneric(V0Casc const& v0casc, T const& track, aod::TracksQA const& trackQA, const bool existTrkQA, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float dEdxExp, const o2::track::PID::ID id, const int runnumber, const double dwnSmplFactor, const float hadronicRate, const int bcGlobalIndex, const int bcTimeFrameId, const int bcBcInTimeFrame) + void fillSkimmedV0Table(V0Casc const& v0casc, T const& track, aod::TracksQA const& trackQA, const bool existTrkQA, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float dEdxExp, const o2::track::PID::ID id, const int runnumber, const double dwnSmplFactor, const float hadronicRate, const int bcGlobalIndex, const int bcTimeFrameId, const int bcBcInTimeFrame) { const double ncl = track.tpcNClsFound(); const double nclPID = track.tpcNClsFindableMinusPID(); @@ -402,7 +402,7 @@ struct TreeWriterTpcV0 { Preslice perCollisionCascs = aod::cascdata::collisionId; template - void runWithTrQAGeneric(Colls const& collisions, TrksType const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, TrkQAType const& tracksQA) + void runV0(Colls const& collisions, TrksType const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, TrkQAType const& tracksQA) { constexpr bool IsWithTrackQa = ModeId != ModeStandard; @@ -446,7 +446,7 @@ struct TreeWriterTpcV0 { const bool passNSigmaTofCut = std::fabs(daughter.tofNSigma) < daughter.nSigmaTofDauTrack || std::fabs(daughter.tofNSigma - NSigmaTofUnmatched) < NSigmaTofUnmatchedEqualityTolerance; const bool passMatchTofRequirement = !daughter.rejectNoTofDauTrack || std::fabs(daughter.tofNSigma - NSigmaTofUnmatched) > NSigmaTofUnmatchedEqualityTolerance; if (passTrackSelection && passDownsamplig && passNSigmaTofCut && passMatchTofRequirement) { - fillSkimmedV0TableWithTrQAGeneric(mother, dauTrack, trackQAInstance, existTrkQA, collision, daughter.tpcNSigma, daughter.tofNSigma, daughter.tpcExpSignal, daughter.id, runnumber, daughter.dwnSmplFactor, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + fillSkimmedV0Table(mother, dauTrack, trackQAInstance, existTrkQA, collision, daughter.tpcNSigma, daughter.tofNSigma, daughter.tpcExpSignal, daughter.id, runnumber, daughter.dwnSmplFactor, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); } }; @@ -502,37 +502,37 @@ struct TreeWriterTpcV0 { /// Apply a track quality selection with a filter! void processStandard(Colls const& collisions, Trks const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, aod::BCsWithTimestamps const&) { - runWithTrQAGeneric(collisions, myTracks, myV0s, myCascs, static_cast(nullptr)); + runV0(collisions, myTracks, myV0s, myCascs, static_cast(nullptr)); } /// process Standard PROCESS_SWITCH(TreeWriterTpcV0, processStandard, "Standard V0 Samples for PID", true); void processStandardWithCorrecteddEdx(Colls const& collisions, TrksWithDEdxCorrection const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, aod::BCsWithTimestamps const&) { - runWithTrQAGeneric(collisions, myTracks, myV0s, myCascs, static_cast(nullptr)); + runV0(collisions, myTracks, myV0s, myCascs, static_cast(nullptr)); } /// process StandardWithCorrecteddEdx PROCESS_SWITCH(TreeWriterTpcV0, processStandardWithCorrecteddEdx, "Standard V0 Samples for PID with corrected dEdx", false); void processWithdEdxTrQA(Colls const& collisions, Trks const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, aod::BCsWithTimestamps const&, aod::TracksQAVersion const& tracksQA) { - runWithTrQAGeneric(collisions, myTracks, myV0s, myCascs, tracksQA); + runV0(collisions, myTracks, myV0s, myCascs, tracksQA); } /// process with dEdx from TrackQA PROCESS_SWITCH(TreeWriterTpcV0, processWithdEdxTrQA, "Standard V0 Samples with dEdx from Track QA for PID", false); void processWithdEdxTrQAWithCorrecteddEdx(Colls const& collisions, TrksWithDEdxCorrection const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, aod::BCsWithTimestamps const&, aod::TracksQAVersion const& tracksQA) { - runWithTrQAGeneric(collisions, myTracks, myV0s, myCascs, tracksQA); + runV0(collisions, myTracks, myV0s, myCascs, tracksQA); } /// process with dEdx from TrackQA PROCESS_SWITCH(TreeWriterTpcV0, processWithdEdxTrQAWithCorrecteddEdx, "Standard V0 Samples with dEdx from Track QA for PID with corrected dEdx", false); void processWithTrQA(Colls const& collisions, Trks const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, MyBCTable const&, aod::TracksQAVersion const& tracksQA) { - runWithTrQAGeneric(collisions, myTracks, myV0s, myCascs, tracksQA); + runV0(collisions, myTracks, myV0s, myCascs, tracksQA); } /// process with TrackQA PROCESS_SWITCH(TreeWriterTpcV0, processWithTrQA, "Standard V0 Samples with Track QA for PID", false); void processWithTrQAWithCorrecteddEdx(Colls const& collisions, TrksWithDEdxCorrection const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, MyBCTable const&, aod::TracksQAVersion const& tracksQA) { - runWithTrQAGeneric(collisions, myTracks, myV0s, myCascs, tracksQA); + runV0(collisions, myTracks, myV0s, myCascs, tracksQA); } /// process with TrackQA PROCESS_SWITCH(TreeWriterTpcV0, processWithTrQAWithCorrecteddEdx, "Standard V0 Samples with Track QA for PID with corrected dEdx", false); @@ -646,7 +646,7 @@ struct TreeWriterTpcTof { TRandom3* fRndm = new TRandom3(0); template - void fillSkimmedTPCTOFTableWithTrkQAGeneric(T const& track, aod::TracksQA const& trackQA, const bool existTrkQA, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float nSigmaITS, const float dEdxExp, const o2::track::PID::ID id, const int runnumber, const double dwnSmplFactor, const double hadronicRate, const int bcGlobalIndex, const int bcTimeFrameId, const int bcBcInTimeFrame) + void fillSkimmedTpcTofTable(T const& track, aod::TracksQA const& trackQA, const bool existTrkQA, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float nSigmaITS, const float dEdxExp, const o2::track::PID::ID id, const int runnumber, const double dwnSmplFactor, const double hadronicRate, const int bcGlobalIndex, const int bcTimeFrameId, const int bcBcInTimeFrame) { const double ncl = track.tpcNClsFound(); const double nclPID = track.tpcNClsFindableMinusPID(); @@ -776,7 +776,7 @@ struct TreeWriterTpcTof { Preslice perCollisionTracksWithCorrecteddEdx = aod::track::collisionId; template - void runWithTrQAGeneric(Colls const& collisions, TrksType const& myTracks, TrkQAType const& tracksQA, Preslice const& perCollisionTracksType) + void runTof(Colls const& collisions, TrksType const& myTracks, TrkQAType const& tracksQA, Preslice const& perCollisionTracksType) { constexpr bool IsWithTrackQa = ModeId != ModeStandard; @@ -847,7 +847,7 @@ struct TreeWriterTpcTof { ((trk.tpcInnerParam() <= tofTrack->maxMomTPCOnly && std::fabs(tofTrack->tpcNSigma) < tofTrack->nSigmaTPCOnly) || (trk.tpcInnerParam() > tofTrack->maxMomTPCOnly && std::fabs(tofTrack->tofNSigma) < tofTrack->nSigmaTofTpctof && std::fabs(tofTrack->tpcNSigma) < tofTrack->nSigmaTpcTpctof)) && downsampleTsalisCharged(fRndm, trk.pt(), tofTrack->downsamplingTsalis, tofTrack->mass, sqrtSNN)) { - fillSkimmedTPCTOFTableWithTrkQAGeneric(trk, trackQA, existTrkQA, collision, tofTrack->tpcNSigma, tofTrack->tofNSigma, tofTrack->itsNSigma, tofTrack->tpcExpSignal, tofTrack->pid, runnumber, tofTrack->dwnSmplFactor, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + fillSkimmedTpcTofTable(trk, trackQA, existTrkQA, collision, tofTrack->tpcNSigma, tofTrack->tofNSigma, tofTrack->itsNSigma, tofTrack->tpcExpSignal, tofTrack->pid, runnumber, tofTrack->dwnSmplFactor, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); } } } /// Loop tracks @@ -856,37 +856,37 @@ struct TreeWriterTpcTof { void processStandard(Colls const& collisions, Trks const& myTracks, aod::BCsWithTimestamps const&) { - runWithTrQAGeneric(collisions, myTracks, static_cast(nullptr), perCollisionTracks); + runTof(collisions, myTracks, static_cast(nullptr), perCollisionTracks); } /// process PROCESS_SWITCH(TreeWriterTpcTof, processStandard, "Standard Samples for PID", true); void processStandardWithCorrecteddEdx(Colls const& collisions, TrksWithDEdxCorrection const& myTracks, aod::BCsWithTimestamps const&) { - runWithTrQAGeneric(collisions, myTracks, static_cast(nullptr), perCollisionTracksWithCorrecteddEdx); + runTof(collisions, myTracks, static_cast(nullptr), perCollisionTracksWithCorrecteddEdx); } /// process PROCESS_SWITCH(TreeWriterTpcTof, processStandardWithCorrecteddEdx, "Standard Samples for PID with corrected dEdx", false); void processWithdEdxTrQA(Colls const& collisions, Trks const& myTracks, aod::BCsWithTimestamps const&, aod::TracksQAVersion const& tracksQA) { - runWithTrQAGeneric(collisions, myTracks, tracksQA, perCollisionTracks); + runTof(collisions, myTracks, tracksQA, perCollisionTracks); } /// process PROCESS_SWITCH(TreeWriterTpcTof, processWithdEdxTrQA, "Samples for PID with TrackQA info", false); void processWithdEdxTrQAWithCorrecteddEdx(Colls const& collisions, TrksWithDEdxCorrection const& myTracks, aod::BCsWithTimestamps const&, aod::TracksQAVersion const& tracksQA) { - runWithTrQAGeneric(collisions, myTracks, tracksQA, perCollisionTracksWithCorrecteddEdx); + runTof(collisions, myTracks, tracksQA, perCollisionTracksWithCorrecteddEdx); } /// process PROCESS_SWITCH(TreeWriterTpcTof, processWithdEdxTrQAWithCorrecteddEdx, "Samples for PID with TrackQA info with corrected dEdx", false); void processWithTrQA(Colls const& collisions, Trks const& myTracks, MyBCTable const&, aod::TracksQAVersion const& tracksQA) { - runWithTrQAGeneric(collisions, myTracks, tracksQA, perCollisionTracks); + runTof(collisions, myTracks, tracksQA, perCollisionTracks); } /// process PROCESS_SWITCH(TreeWriterTpcTof, processWithTrQA, "Samples for PID with TrackQA info", false); void processWithTrQAWithCorrecteddEdx(Colls const& collisions, TrksWithDEdxCorrection const& myTracks, MyBCTable const&, aod::TracksQAVersion const& tracksQA) { - runWithTrQAGeneric(collisions, myTracks, tracksQA, perCollisionTracksWithCorrecteddEdx); + runTof(collisions, myTracks, tracksQA, perCollisionTracksWithCorrecteddEdx); } /// process PROCESS_SWITCH(TreeWriterTpcTof, processWithTrQAWithCorrecteddEdx, "Samples for PID with TrackQA info with correced dEdx", false); From 4600e37c9445e331a00a6278b4dd4caa14945085 Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Wed, 19 Nov 2025 14:43:02 +0100 Subject: [PATCH 07/22] get rid of magic constants --- DPG/Tasks/TPC/tpcSkimsTableCreator.cxx | 101 +++++++++++----------- DPG/Tasks/TPC/tpcSkimsTableCreator.h | 18 ++++ DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h | 6 -- 3 files changed, 68 insertions(+), 57 deletions(-) diff --git a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx index 1f4d187f175..d9237810604 100644 --- a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx +++ b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx @@ -133,15 +133,15 @@ struct TreeWriterTpcV0 { ctpRateFetcher mRateFetcher; struct V0Daughter { - double downsamplingTsalis{-999.}; - double mass{-999.}; - double maxPt4dwnsmplTsalis{-999.}; - double tpcNSigma{-999.}; - double tofNSigma{-999.}; - double tpcExpSignal{-999.}; + double downsamplingTsalis{UndefValueDouble}; + double mass{UndefValueDouble}; + double maxPt4dwnsmplTsalis{UndefValueDouble}; + double tpcNSigma{UndefValueDouble}; + double tofNSigma{UndefValueDouble}; + double tpcExpSignal{UndefValueDouble}; o2::track::PID::ID id{0}; - double dwnSmplFactor{-999.}; - double nSigmaTofDauTrack{-999.}; + double dwnSmplFactor{UndefValueDouble}; + double nSigmaTofDauTrack{UndefValueDouble}; bool rejectNoTofDauTrack{false}; }; @@ -165,8 +165,8 @@ struct TreeWriterTpcV0 { } struct V0Mother { - int posDaughterId{-999}; - int negDaughterId{-999}; + int posDaughterId{UndefValueInt}; + int negDaughterId{UndefValueInt}; }; V0Mother createV0Mother(const int motherId) @@ -209,7 +209,7 @@ struct TreeWriterTpcV0 { } LOGP(fatal, "getStrangenessTofNSigma for V0: wrong combination of motherId, daughterId and sign"); - return -999.f; + return UndefValueFloat; } float getStrangenessTofNSigma(CascsWithID::iterator const& casc, const int motherId, const int daughterId, bool) @@ -218,7 +218,7 @@ struct TreeWriterTpcV0 { return casc.tofNSigmaOmKa(); LOGP(fatal, "getStrangenessTofNSigma for cascade: wrong combination of motherId and daughterId"); - return -999.f; + return UndefValueFloat; } template @@ -259,7 +259,7 @@ struct TreeWriterTpcV0 { track.y(), mass, bg, - multTPC / 11000., + multTPC / MultiplicityNorm, std::sqrt(nClNorm / ncl), nclPID, id, @@ -286,7 +286,7 @@ struct TreeWriterTpcV0 { track.y(), mass, bg, - multTPC / 11000., + multTPC / MultiplicityNorm, std::sqrt(nClNorm / ncl), nclPID, id, @@ -302,7 +302,7 @@ struct TreeWriterTpcV0 { pT, v0radius, gammapsipair, - existTrkQA ? trackQA.tpcdEdxNorm() : -999); + existTrkQA ? trackQA.tpcdEdxNorm() : UndefValueFloat); } else if constexpr (ModeId == ModeWithTrkQA) { rowTPCTreeWithTrkQA(usedDedx, 1. / dEdxExp, @@ -314,7 +314,7 @@ struct TreeWriterTpcV0 { track.y(), mass, bg, - multTPC / 11000., + multTPC / MultiplicityNorm, std::sqrt(nClNorm / ncl), nclPID, id, @@ -333,16 +333,16 @@ struct TreeWriterTpcV0 { bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame, - existTrkQA ? trackQA.tpcClusterByteMask() : -999, - existTrkQA ? trackQA.tpcdEdxMax0R() : -999, - existTrkQA ? trackQA.tpcdEdxMax1R() : -999, - existTrkQA ? trackQA.tpcdEdxMax2R() : -999, - existTrkQA ? trackQA.tpcdEdxMax3R() : -999, - existTrkQA ? trackQA.tpcdEdxTot0R() : -999, - existTrkQA ? trackQA.tpcdEdxTot1R() : -999, - existTrkQA ? trackQA.tpcdEdxTot2R() : -999, - existTrkQA ? trackQA.tpcdEdxTot3R() : -999, - existTrkQA ? trackQA.tpcdEdxNorm() : -999); + existTrkQA ? trackQA.tpcClusterByteMask() : UndefValueInt, + existTrkQA ? trackQA.tpcdEdxMax0R() : UndefValueInt, + existTrkQA ? trackQA.tpcdEdxMax1R() : UndefValueInt, + existTrkQA ? trackQA.tpcdEdxMax2R() : UndefValueInt, + existTrkQA ? trackQA.tpcdEdxMax3R() : UndefValueInt, + existTrkQA ? trackQA.tpcdEdxTot0R() : UndefValueInt, + existTrkQA ? trackQA.tpcdEdxTot1R() : UndefValueInt, + existTrkQA ? trackQA.tpcdEdxTot2R() : UndefValueInt, + existTrkQA ? trackQA.tpcdEdxTot3R() : UndefValueInt, + existTrkQA ? trackQA.tpcdEdxNorm() : UndefValueFloat); } } } @@ -423,12 +423,12 @@ struct TreeWriterTpcV0 { const auto& cascs = myCascs.sliceBy(perCollisionCascs, collision.globalIndex()); const auto& bc = collision.bc_as(); const int runnumber = bc.runNumber(); - const float hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, irSource) * 1.e-3; + const float hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, irSource) * OneToKilo; const int bcGlobalIndex = bc.globalIndex(); int bcTimeFrameId, bcBcInTimeFrame; if constexpr (ModeId == ModeWithdEdxTrkQA || ModeId == ModeStandard) { - bcTimeFrameId = -999; - bcBcInTimeFrame = -999; + bcTimeFrameId = UndefValueInt; + bcBcInTimeFrame = UndefValueInt; if constexpr (ModeId == ModeWithdEdxTrkQA) { rowTPCTreeWithdEdxTrkQA.reserve(2 * v0s.size() + cascs.size()); } else if (ModeId == ModeStandard) { @@ -676,7 +676,7 @@ struct TreeWriterTpcTof { track.y(), mass, bg, - multTPC / 11000., + multTPC / MultiplicityNorm, std::sqrt(nClNorm / ncl), nclPID, id, @@ -698,7 +698,7 @@ struct TreeWriterTpcTof { track.y(), mass, bg, - multTPC / 11000., + multTPC / MultiplicityNorm, std::sqrt(nClNorm / ncl), nclPID, id, @@ -709,7 +709,7 @@ struct TreeWriterTpcTof { ft0Occ, hadronicRate, nSigmaITS, - existTrkQA ? trackQA.tpcdEdxNorm() : -999); + existTrkQA ? trackQA.tpcdEdxNorm() : UndefValueFloat); } else if constexpr (ModeId == ModeWithTrkQA) { rowTPCTOFTreeWithTrkQA(usedEdx, 1. / dEdxExp, @@ -721,7 +721,7 @@ struct TreeWriterTpcTof { track.y(), mass, bg, - multTPC / 11000., + multTPC / MultiplicityNorm, std::sqrt(nClNorm / ncl), nclPID, id, @@ -735,16 +735,16 @@ struct TreeWriterTpcTof { bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame, - existTrkQA ? trackQA.tpcClusterByteMask() : -999, - existTrkQA ? trackQA.tpcdEdxMax0R() : -999, - existTrkQA ? trackQA.tpcdEdxMax1R() : -999, - existTrkQA ? trackQA.tpcdEdxMax2R() : -999, - existTrkQA ? trackQA.tpcdEdxMax3R() : -999, - existTrkQA ? trackQA.tpcdEdxTot0R() : -999, - existTrkQA ? trackQA.tpcdEdxTot1R() : -999, - existTrkQA ? trackQA.tpcdEdxTot2R() : -999, - existTrkQA ? trackQA.tpcdEdxTot3R() : -999, - existTrkQA ? trackQA.tpcdEdxNorm() : -999); + existTrkQA ? trackQA.tpcClusterByteMask() : UndefValueInt, + existTrkQA ? trackQA.tpcdEdxMax0R() : UndefValueInt, + existTrkQA ? trackQA.tpcdEdxMax1R() : UndefValueInt, + existTrkQA ? trackQA.tpcdEdxMax2R() : UndefValueInt, + existTrkQA ? trackQA.tpcdEdxMax3R() : UndefValueInt, + existTrkQA ? trackQA.tpcdEdxTot0R() : UndefValueInt, + existTrkQA ? trackQA.tpcdEdxTot1R() : UndefValueInt, + existTrkQA ? trackQA.tpcdEdxTot2R() : UndefValueInt, + existTrkQA ? trackQA.tpcdEdxTot3R() : UndefValueInt, + existTrkQA ? trackQA.tpcdEdxNorm() : UndefValueFloat); } } } @@ -801,19 +801,18 @@ struct TreeWriterTpcTof { const auto& bc = collision.bc_as(); const int runnumber = bc.runNumber(); - float hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, irSource) * 1.e-3; - int bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame; + const float hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, irSource) * OneToKilo; + const int bcGlobalIndex = bc.globalIndex(); + int bcTimeFrameId, bcBcInTimeFrame; if constexpr (ModeId == ModeStandard || ModeId == ModeWithdEdxTrkQA) { - bcGlobalIndex = -999; - bcTimeFrameId = -999; - bcBcInTimeFrame = -999; + bcTimeFrameId = UndefValueInt; + bcBcInTimeFrame = UndefValueInt; if constexpr (ModeId == ModeStandard) { rowTPCTOFTree.reserve(tracks.size()); } else { rowTPCTOFTreeWithdEdxTrkQA.reserve(tracks.size()); } } else { - bcGlobalIndex = bc.globalIndex(); bcTimeFrameId = bc.tfId(); bcBcInTimeFrame = bc.bcInTF(); rowTPCTOFTreeWithTrkQA.reserve(tracks.size()); @@ -836,11 +835,11 @@ struct TreeWriterTpcTof { TofTrack tofDeuteron(true, maxMomHardCutOnlyDe, maxMomTPCOnlyDe, trk.tpcNSigmaDe(), nSigmaTPCOnlyDe, downsamplingTsalisDeuterons, MassDeuteron, trk.tofNSigmaDe(), trk.itsNSigmaDe(), trk.tpcExpSignalDe(tpcSignalGeneric(trk)), PidDeuteron, dwnSmplFactorDe, nSigmaTofTpctofDe, nSigmaTpcTpctofDe); - TofTrack tofProton(false, -999., maxMomTPCOnlyPr, trk.tpcNSigmaPr(), nSigmaTPCOnlyPr, downsamplingTsalisProtons, MassProton, trk.tofNSigmaPr(), trk.itsNSigmaPr(), trk.tpcExpSignalPr(tpcSignalGeneric(trk)), PidProton, dwnSmplFactorPr, nSigmaTofTpctofPr, nSigmaTpcTpctofPr); + TofTrack tofProton(false, UndefValueDouble, maxMomTPCOnlyPr, trk.tpcNSigmaPr(), nSigmaTPCOnlyPr, downsamplingTsalisProtons, MassProton, trk.tofNSigmaPr(), trk.itsNSigmaPr(), trk.tpcExpSignalPr(tpcSignalGeneric(trk)), PidProton, dwnSmplFactorPr, nSigmaTofTpctofPr, nSigmaTpcTpctofPr); TofTrack tofKaon(true, maxMomHardCutOnlyKa, maxMomTPCOnlyKa, trk.tpcNSigmaKa(), nSigmaTPCOnlyKa, downsamplingTsalisKaons, MassKPlus, trk.tofNSigmaKa(), trk.itsNSigmaKa(), trk.tpcExpSignalKa(tpcSignalGeneric(trk)), PidKaon, dwnSmplFactorKa, nSigmaTofTpctofKa, nSigmaTpcTpctofKa); - TofTrack tofPion(false, -999., maxMomTPCOnlyPi, trk.tpcNSigmaPi(), nSigmaTPCOnlyPi, downsamplingTsalisPions, MassPiPlus, trk.tofNSigmaPi(), trk.itsNSigmaPi(), trk.tpcExpSignalPi(tpcSignalGeneric(trk)), PidPion, dwnSmplFactorPi, nSigmaTofTpctofPi, nSigmaTpcTpctofPi); + TofTrack tofPion(false, UndefValueDouble, maxMomTPCOnlyPi, trk.tpcNSigmaPi(), nSigmaTPCOnlyPi, downsamplingTsalisPions, MassPiPlus, trk.tofNSigmaPi(), trk.itsNSigmaPi(), trk.tpcExpSignalPi(tpcSignalGeneric(trk)), PidPion, dwnSmplFactorPi, nSigmaTofTpctofPi, nSigmaTpcTpctofPi); for (const auto& tofTrack : {&tofTriton, &tofDeuteron, &tofProton, &tofKaon, &tofPion}) { if ((!tofTrack->isApplyHardCutOnly || trk.tpcInnerParam() < tofTrack->maxMomHardCutOnly) && diff --git a/DPG/Tasks/TPC/tpcSkimsTableCreator.h b/DPG/Tasks/TPC/tpcSkimsTableCreator.h index f47a784dfb5..a7224ddd082 100644 --- a/DPG/Tasks/TPC/tpcSkimsTableCreator.h +++ b/DPG/Tasks/TPC/tpcSkimsTableCreator.h @@ -133,4 +133,22 @@ DECLARE_SOA_TABLE(SkimmedTPCTOFTreeWithTrkQA, "AOD", "TPCTOFSKIMWQA", #undef TPCSKIMS_COLUMNS_V0 #undef TPCSKIMS_COLUMNS_BASE } // namespace o2::aod + +namespace o2::dpg_tpcskimstablecreator +{ +enum { + ModeStandard = 0, + ModeWithdEdxTrkQA, + ModeWithTrkQA +}; + +constexpr int UndefValueInt{-999}; +constexpr float UndefValueFloat{-999.f}; +constexpr double UndefValueDouble{-999.}; + +// an arbitrary big value to convert multiplicity into a value between 0 and 1 +constexpr double MultiplicityNorm{11000.}; + +constexpr float OneToKilo{1e-3f}; +} // namespace o2::dpg_tpcskimstablecreator #endif // DPG_TASKS_TPC_TPCSKIMSTABLECREATOR_H_ diff --git a/DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h b/DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h index b4cbd0052c8..acba9defae7 100644 --- a/DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h +++ b/DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h @@ -39,12 +39,6 @@ enum { EventSelectionRun3 }; -enum { - ModeStandard = 0, - ModeWithdEdxTrkQA, - ModeWithTrkQA -}; - /// Event selection template inline bool isEventSelected(const CollisionType& collision, const int applyEvSel) From 5b057d9c8274b52ba0fe0a2f753db95191d5beae Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Wed, 19 Nov 2025 14:49:00 +0100 Subject: [PATCH 08/22] mv tpcSignalGeneric() from struct members to utils --- DPG/Tasks/TPC/tpcSkimsTableCreator.cxx | 22 ---------------------- DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h | 11 +++++++++++ 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx index d9237810604..130b3a4bd08 100644 --- a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx +++ b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx @@ -387,17 +387,6 @@ struct TreeWriterTpcV0 { return casc.cascradius(); } - /// Evaluate tpcSignal with or without correction - template - double tpcSignalGeneric(const TrkType& track) - { - if constexpr (IsCorrectedDeDx) { - return track.tpcSignalCorrected(); - } else { - return track.tpcSignal(); - } - } - Preslice perCollisionV0s = aod::v0data::collisionId; Preslice perCollisionCascs = aod::cascdata::collisionId; @@ -761,17 +750,6 @@ struct TreeWriterTpcTof { ccdb->setFatalWhenNull(false); } - /// Evaluate tpcSignal with or without correction - template - double tpcSignalGeneric(const TrkType& track) - { - if constexpr (IsCorrectedDeDx) { - return track.tpcSignalCorrected(); - } else { - return track.tpcSignal(); - } - } - Preslice perCollisionTracks = aod::track::collisionId; Preslice perCollisionTracksWithCorrecteddEdx = aod::track::collisionId; diff --git a/DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h b/DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h index acba9defae7..b516bfd9792 100644 --- a/DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h +++ b/DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h @@ -93,5 +93,16 @@ inline bool isTrackSelected(const TrackType& track, const int trackSelection) return isSelected; } +/// Evaluate tpcSignal with or without dEdx correction +template +inline double tpcSignalGeneric(const TrkType& track) +{ + if constexpr (IsCorrectedDeDx) { + return track.tpcSignalCorrected(); + } else { + return track.tpcSignal(); + } +} + } // namespace o2::dpg_tpcskimstablecreator #endif // DPG_TASKS_TPC_UTILSTPCSKIMSTABLECREATOR_H_ From 59bc473964c997314117c2d1c385ae9f27ac13d9 Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Wed, 19 Nov 2025 14:57:03 +0100 Subject: [PATCH 09/22] adjust comments --- DPG/Tasks/TPC/tpcSkimsTableCreator.cxx | 33 +++++++++++++------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx index 130b3a4bd08..deb615efc46 100644 --- a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx +++ b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx @@ -345,7 +345,7 @@ struct TreeWriterTpcV0 { existTrkQA ? trackQA.tpcdEdxNorm() : UndefValueFloat); } } - } + } /// fillSkimmedV0Table TRandom3* fRndm = new TRandom3(0); @@ -486,43 +486,42 @@ struct TreeWriterTpcV0 { fillDaughterTrack(casc, bachTrack, bachDaughter, bachTrackQA, existBachTrkQA); } } - } + } /// runV0 - /// Apply a track quality selection with a filter! void processStandard(Colls const& collisions, Trks const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, aod::BCsWithTimestamps const&) { runV0(collisions, myTracks, myV0s, myCascs, static_cast(nullptr)); - } /// process Standard + } PROCESS_SWITCH(TreeWriterTpcV0, processStandard, "Standard V0 Samples for PID", true); void processStandardWithCorrecteddEdx(Colls const& collisions, TrksWithDEdxCorrection const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, aod::BCsWithTimestamps const&) { runV0(collisions, myTracks, myV0s, myCascs, static_cast(nullptr)); - } /// process StandardWithCorrecteddEdx + } PROCESS_SWITCH(TreeWriterTpcV0, processStandardWithCorrecteddEdx, "Standard V0 Samples for PID with corrected dEdx", false); void processWithdEdxTrQA(Colls const& collisions, Trks const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, aod::BCsWithTimestamps const&, aod::TracksQAVersion const& tracksQA) { runV0(collisions, myTracks, myV0s, myCascs, tracksQA); - } /// process with dEdx from TrackQA + } PROCESS_SWITCH(TreeWriterTpcV0, processWithdEdxTrQA, "Standard V0 Samples with dEdx from Track QA for PID", false); void processWithdEdxTrQAWithCorrecteddEdx(Colls const& collisions, TrksWithDEdxCorrection const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, aod::BCsWithTimestamps const&, aod::TracksQAVersion const& tracksQA) { runV0(collisions, myTracks, myV0s, myCascs, tracksQA); - } /// process with dEdx from TrackQA + } PROCESS_SWITCH(TreeWriterTpcV0, processWithdEdxTrQAWithCorrecteddEdx, "Standard V0 Samples with dEdx from Track QA for PID with corrected dEdx", false); void processWithTrQA(Colls const& collisions, Trks const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, MyBCTable const&, aod::TracksQAVersion const& tracksQA) { runV0(collisions, myTracks, myV0s, myCascs, tracksQA); - } /// process with TrackQA + } PROCESS_SWITCH(TreeWriterTpcV0, processWithTrQA, "Standard V0 Samples with Track QA for PID", false); void processWithTrQAWithCorrecteddEdx(Colls const& collisions, TrksWithDEdxCorrection const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, MyBCTable const&, aod::TracksQAVersion const& tracksQA) { runV0(collisions, myTracks, myV0s, myCascs, tracksQA); - } /// process with TrackQA + } PROCESS_SWITCH(TreeWriterTpcV0, processWithTrQAWithCorrecteddEdx, "Standard V0 Samples with Track QA for PID with corrected dEdx", false); void processDummy(Colls const&) {} @@ -736,7 +735,7 @@ struct TreeWriterTpcTof { existTrkQA ? trackQA.tpcdEdxNorm() : UndefValueFloat); } } - } + } /// fillSkimmedTpcTofTable void init(o2::framework::InitContext&) { @@ -829,42 +828,42 @@ struct TreeWriterTpcTof { } } /// Loop tracks } - } + } /// runTof void processStandard(Colls const& collisions, Trks const& myTracks, aod::BCsWithTimestamps const&) { runTof(collisions, myTracks, static_cast(nullptr), perCollisionTracks); - } /// process + } PROCESS_SWITCH(TreeWriterTpcTof, processStandard, "Standard Samples for PID", true); void processStandardWithCorrecteddEdx(Colls const& collisions, TrksWithDEdxCorrection const& myTracks, aod::BCsWithTimestamps const&) { runTof(collisions, myTracks, static_cast(nullptr), perCollisionTracksWithCorrecteddEdx); - } /// process + } PROCESS_SWITCH(TreeWriterTpcTof, processStandardWithCorrecteddEdx, "Standard Samples for PID with corrected dEdx", false); void processWithdEdxTrQA(Colls const& collisions, Trks const& myTracks, aod::BCsWithTimestamps const&, aod::TracksQAVersion const& tracksQA) { runTof(collisions, myTracks, tracksQA, perCollisionTracks); - } /// process + } PROCESS_SWITCH(TreeWriterTpcTof, processWithdEdxTrQA, "Samples for PID with TrackQA info", false); void processWithdEdxTrQAWithCorrecteddEdx(Colls const& collisions, TrksWithDEdxCorrection const& myTracks, aod::BCsWithTimestamps const&, aod::TracksQAVersion const& tracksQA) { runTof(collisions, myTracks, tracksQA, perCollisionTracksWithCorrecteddEdx); - } /// process + } PROCESS_SWITCH(TreeWriterTpcTof, processWithdEdxTrQAWithCorrecteddEdx, "Samples for PID with TrackQA info with corrected dEdx", false); void processWithTrQA(Colls const& collisions, Trks const& myTracks, MyBCTable const&, aod::TracksQAVersion const& tracksQA) { runTof(collisions, myTracks, tracksQA, perCollisionTracks); - } /// process + } PROCESS_SWITCH(TreeWriterTpcTof, processWithTrQA, "Samples for PID with TrackQA info", false); void processWithTrQAWithCorrecteddEdx(Colls const& collisions, TrksWithDEdxCorrection const& myTracks, MyBCTable const&, aod::TracksQAVersion const& tracksQA) { runTof(collisions, myTracks, tracksQA, perCollisionTracksWithCorrecteddEdx); - } /// process + } PROCESS_SWITCH(TreeWriterTpcTof, processWithTrQAWithCorrecteddEdx, "Samples for PID with TrackQA info with correced dEdx", false); void processDummy(Colls const&) {} From 7ff25c947ff3d17b627200f76e9d620f048863ab Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Wed, 19 Nov 2025 18:48:37 +0100 Subject: [PATCH 10/22] re-order struct members --- DPG/Tasks/TPC/tpcSkimsTableCreator.cxx | 244 ++++++++++++++----------- DPG/Tasks/TPC/tpcSkimsTableCreator.h | 7 + 2 files changed, 141 insertions(+), 110 deletions(-) diff --git a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx index deb615efc46..efc4aa579cb 100644 --- a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx +++ b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx @@ -61,33 +61,11 @@ using namespace o2::dpg_tpcskimstablecreator; struct TreeWriterTpcV0 { - Service ccdb; - - using Trks = soa::Join; - using TrksWithDEdxCorrection = soa::Join; - using Colls = soa::Join; - using MyBCTable = soa::Join; - using V0sWithID = soa::Join; - using CascsWithID = soa::Join; - - /// Tables to be produced Produces rowTPCTree; Produces rowTPCTreeWithdEdxTrkQA; Produces rowTPCTreeWithTrkQA; - constexpr static o2::track::PID::ID PidElectron{o2::track::PID::Electron}; - constexpr static o2::track::PID::ID PidPion{o2::track::PID::Pion}; - constexpr static o2::track::PID::ID PidKaon{o2::track::PID::Kaon}; - constexpr static o2::track::PID::ID PidProton{o2::track::PID::Proton}; - - // an arbitrary value of N sigma TOF assigned by TOF task to tracks which are not matched to TOF hits - constexpr static float NSigmaTofUnmatched{o2::aod::v0data::kNoTOFValue}; - constexpr static float NSigmaTofUnmatchedEqualityTolerance{std::fabs(NSigmaTofUnmatched) / 1e4f}; - - // an arbitrary value of "N sigma TOF" assigned to electorns (for uniformity reasons) - constexpr static float NSigmaTofElectorn{1000.f}; - - /// Configurables + /// Configurables general Configurable nSigmaTofDauTrackPi{"nSigmaTofDauTrackPi", 999.f, "n-sigma TOF cut on the pion daughter tracks"}; Configurable nSigmaTofDauTrackPr{"nSigmaTofDauTrackPr", 999.f, "n-sigma TOF cut on the proton daughter tracks"}; Configurable nSigmaTofDauTrackKa{"nSigmaTofDauTrackKa", 999.f, "n-sigma TOF cut on the kaon daughter tracks"}; @@ -113,6 +91,12 @@ struct TreeWriterTpcV0 { Configurable maxPt4dwnsmplTsalisElectrons{"maxPt4dwnsmplTsalisElectrons", 100., "Maximum Pt for applying downsampling factor of electrons"}; Configurable maxPt4dwnsmplTsalisKaons{"maxPt4dwnsmplTsalisKaons", 100., "Maximum Pt for applying downsampling factor of kaons"}; + // an arbitrary value of N sigma TOF assigned by TOF task to tracks which are not matched to TOF hits + constexpr static float NSigmaTofUnmatched{o2::aod::v0data::kNoTOFValue}; + constexpr static float NSigmaTofUnmatchedEqualityTolerance{std::fabs(NSigmaTofUnmatched) / 1e4f}; + // an arbitrary value of "N sigma TOF" assigned to electorns (for uniformity reasons) + constexpr static float NSigmaTofElectorn{1000.f}; + enum { // Reconstructed V0 and cascade MotherUndef = -1, MotherGamma = 0, @@ -130,8 +114,6 @@ struct TreeWriterTpcV0 { DaughterProton }; - ctpRateFetcher mRateFetcher; - struct V0Daughter { double downsamplingTsalis{UndefValueDouble}; double mass{UndefValueDouble}; @@ -145,6 +127,39 @@ struct TreeWriterTpcV0 { bool rejectNoTofDauTrack{false}; }; + struct V0Mother { + int posDaughterId{UndefValueInt}; + int negDaughterId{UndefValueInt}; + }; + + Service ccdb; + + ctpRateFetcher mRateFetcher; + + TRandom3* fRndm = new TRandom3(0); + + using Trks = soa::Join; + using TrksWithDEdxCorrection = soa::Join; + using Colls = soa::Join; + using MyBCTable = soa::Join; + using V0sWithID = soa::Join; + using CascsWithID = soa::Join; + + Preslice perCollisionV0s = aod::v0data::collisionId; + Preslice perCollisionCascs = aod::cascdata::collisionId; + + void init(o2::framework::InitContext&) + { + const std::array doprocess{doprocessStandard, doprocessStandardWithCorrecteddEdx, doprocessWithdEdxTrQA, doprocessWithdEdxTrQAWithCorrecteddEdx, doprocessWithTrQA, doprocessWithTrQAWithCorrecteddEdx, doprocessDummy}; + if (std::accumulate(doprocess.begin(), doprocess.end(), 0) != 1) { + LOGP(fatal, "One and only one process function should be enabled"); + } + + ccdb->setURL("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setFatalWhenNull(false); + } + template V0Daughter createV0Daughter(const V0Casc& v0Casc, const T& track, const int motherId, const int daughterId, const bool isPositive = true) { @@ -164,11 +179,6 @@ struct TreeWriterTpcV0 { } } - struct V0Mother { - int posDaughterId{UndefValueInt}; - int negDaughterId{UndefValueInt}; - }; - V0Mother createV0Mother(const int motherId) { switch (motherId) { @@ -347,20 +357,6 @@ struct TreeWriterTpcV0 { } } /// fillSkimmedV0Table - TRandom3* fRndm = new TRandom3(0); - - void init(o2::framework::InitContext&) - { - const std::array doprocess{doprocessStandard, doprocessStandardWithCorrecteddEdx, doprocessWithdEdxTrQA, doprocessWithdEdxTrQAWithCorrecteddEdx, doprocessWithTrQA, doprocessWithTrQAWithCorrecteddEdx, doprocessDummy}; - if (std::accumulate(doprocess.begin(), doprocess.end(), 0) != 1) { - LOGP(fatal, "One and only one process function should be enabled"); - } - - ccdb->setURL("http://alice-ccdb.cern.ch"); - ccdb->setCaching(true); - ccdb->setFatalWhenNull(false); - } - /// Evaluate cosPA of the v0 template double getCosPA(V0sWithID::iterator const& v0, CollisionType const&) @@ -387,9 +383,6 @@ struct TreeWriterTpcV0 { return casc.cascradius(); } - Preslice perCollisionV0s = aod::v0data::collisionId; - Preslice perCollisionCascs = aod::cascdata::collisionId; - template void runV0(Colls const& collisions, TrksType const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, TrkQAType const& tracksQA) { @@ -404,7 +397,6 @@ struct TreeWriterTpcV0 { } } for (const auto& collision : collisions) { - /// Check event slection if (!isEventSelected(collision, applyEvSel)) { continue; } @@ -488,37 +480,61 @@ struct TreeWriterTpcV0 { } } /// runV0 - void processStandard(Colls const& collisions, Trks const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, aod::BCsWithTimestamps const&) + void processStandard(Colls const& collisions, + Trks const& myTracks, + V0sWithID const& myV0s, + CascsWithID const& myCascs, + aod::BCsWithTimestamps const&) { runV0(collisions, myTracks, myV0s, myCascs, static_cast(nullptr)); } PROCESS_SWITCH(TreeWriterTpcV0, processStandard, "Standard V0 Samples for PID", true); - void processStandardWithCorrecteddEdx(Colls const& collisions, TrksWithDEdxCorrection const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, aod::BCsWithTimestamps const&) + void processStandardWithCorrecteddEdx(Colls const& collisions, + TrksWithDEdxCorrection const& myTracks, + V0sWithID const& myV0s, + CascsWithID const& myCascs, + aod::BCsWithTimestamps const&) { runV0(collisions, myTracks, myV0s, myCascs, static_cast(nullptr)); } PROCESS_SWITCH(TreeWriterTpcV0, processStandardWithCorrecteddEdx, "Standard V0 Samples for PID with corrected dEdx", false); - void processWithdEdxTrQA(Colls const& collisions, Trks const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, aod::BCsWithTimestamps const&, aod::TracksQAVersion const& tracksQA) + void processWithdEdxTrQA(Colls const& collisions, + Trks const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, aod::BCsWithTimestamps const&, aod::TracksQAVersion const& tracksQA) { runV0(collisions, myTracks, myV0s, myCascs, tracksQA); } PROCESS_SWITCH(TreeWriterTpcV0, processWithdEdxTrQA, "Standard V0 Samples with dEdx from Track QA for PID", false); - void processWithdEdxTrQAWithCorrecteddEdx(Colls const& collisions, TrksWithDEdxCorrection const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, aod::BCsWithTimestamps const&, aod::TracksQAVersion const& tracksQA) + void processWithdEdxTrQAWithCorrecteddEdx(Colls const& collisions, + TrksWithDEdxCorrection const& myTracks, + V0sWithID const& myV0s, + CascsWithID const& myCascs, + aod::BCsWithTimestamps const&, + aod::TracksQAVersion const& tracksQA) { runV0(collisions, myTracks, myV0s, myCascs, tracksQA); } PROCESS_SWITCH(TreeWriterTpcV0, processWithdEdxTrQAWithCorrecteddEdx, "Standard V0 Samples with dEdx from Track QA for PID with corrected dEdx", false); - void processWithTrQA(Colls const& collisions, Trks const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, MyBCTable const&, aod::TracksQAVersion const& tracksQA) + void processWithTrQA(Colls const& collisions, + Trks const& myTracks, + V0sWithID const& myV0s, + CascsWithID const& myCascs, + MyBCTable const&, + aod::TracksQAVersion const& tracksQA) { runV0(collisions, myTracks, myV0s, myCascs, tracksQA); } PROCESS_SWITCH(TreeWriterTpcV0, processWithTrQA, "Standard V0 Samples with Track QA for PID", false); - void processWithTrQAWithCorrecteddEdx(Colls const& collisions, TrksWithDEdxCorrection const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, MyBCTable const&, aod::TracksQAVersion const& tracksQA) + void processWithTrQAWithCorrecteddEdx(Colls const& collisions, + TrksWithDEdxCorrection const& myTracks, + V0sWithID const& myV0s, + CascsWithID const& myCascs, + MyBCTable const&, + aod::TracksQAVersion const& tracksQA) { runV0(collisions, myTracks, myV0s, myCascs, tracksQA); } @@ -531,35 +547,11 @@ struct TreeWriterTpcV0 { struct TreeWriterTpcTof { - Service ccdb; - - using Trks = soa::Join; - using TrksWithDEdxCorrection = soa::Join; - using Colls = soa::Join; - using MyBCTable = soa::Join; - - /// Tables to be produced Produces rowTPCTOFTree; Produces rowTPCTOFTreeWithdEdxTrkQA; Produces rowTPCTOFTreeWithTrkQA; - constexpr static o2::track::PID::ID PidPion{o2::track::PID::Pion}; - constexpr static o2::track::PID::ID PidKaon{o2::track::PID::Kaon}; - constexpr static o2::track::PID::ID PidProton{o2::track::PID::Proton}; - constexpr static o2::track::PID::ID PidDeuteron{o2::track::PID::Deuteron}; - constexpr static o2::track::PID::ID PidTriton{o2::track::PID::Triton}; - - /// Configurables + /// Configurables general Configurable nClNorm{"nClNorm", 152., "Number of cluster normalization. Run 2: 159, Run 3 152"}; Configurable applyEvSel{"applyEvSel", 2, "Flag to apply rapidity cut: 0 -> no event selection, 1 -> Run 2 event selection, 2 -> Run 3 event selection"}; Configurable trackSelection{"trackSelection", 1, "Track selection: 0 -> No Cut, 1 -> kGlobalTrack, 2 -> kGlobalTrackWoPtEta, 3 -> kGlobalTrackWoDCA, 4 -> kQualityTracks, 5 -> kInAcceptanceTracks"}; @@ -605,15 +597,6 @@ struct TreeWriterTpcTof { Configurable downsamplingTsalisKaons{"downsamplingTsalisKaons", -1., "Downsampling factor to reduce the number of kaons"}; Configurable downsamplingTsalisPions{"downsamplingTsalisPions", -1., "Downsampling factor to reduce the number of pions"}; - Filter trackFilter = (trackSelection.node() == static_cast(TrackSelectionNoCut)) || - ((trackSelection.node() == static_cast(TrackSelectionGlobalTrack)) && requireGlobalTrackInFilter()) || - ((trackSelection.node() == static_cast(TrackSelectionTrackWoPtEta)) && requireGlobalTrackWoPtEtaInFilter()) || - ((trackSelection.node() == static_cast(TrackSelectionGlobalTrackWoDCA)) && requireGlobalTrackWoDCAInFilter()) || - ((trackSelection.node() == static_cast(TrackSelectionQualityTracks)) && requireQualityTracksInFilter()) || - ((trackSelection.node() == static_cast(TrackSelectionInAcceptanceTracks)) && requireTrackCutInFilter(TrackSelectionFlags::kInAcceptanceTracks)); - - ctpRateFetcher mRateFetcher; - struct TofTrack { bool isApplyHardCutOnly; double maxMomHardCutOnly; @@ -631,8 +614,49 @@ struct TreeWriterTpcTof { double nSigmaTpcTpctof; }; + Service ccdb; + + ctpRateFetcher mRateFetcher; + TRandom3* fRndm = new TRandom3(0); + using Trks = soa::Join; + using TrksWithDEdxCorrection = soa::Join; + using Colls = soa::Join; + using MyBCTable = soa::Join; + + Filter trackFilter = (trackSelection.node() == static_cast(TrackSelectionNoCut)) || + ((trackSelection.node() == static_cast(TrackSelectionGlobalTrack)) && requireGlobalTrackInFilter()) || + ((trackSelection.node() == static_cast(TrackSelectionTrackWoPtEta)) && requireGlobalTrackWoPtEtaInFilter()) || + ((trackSelection.node() == static_cast(TrackSelectionGlobalTrackWoDCA)) && requireGlobalTrackWoDCAInFilter()) || + ((trackSelection.node() == static_cast(TrackSelectionQualityTracks)) && requireQualityTracksInFilter()) || + ((trackSelection.node() == static_cast(TrackSelectionInAcceptanceTracks)) && requireTrackCutInFilter(TrackSelectionFlags::kInAcceptanceTracks)); + + Preslice perCollisionTracks = aod::track::collisionId; + Preslice perCollisionTracksWithCorrecteddEdx = aod::track::collisionId; + + void init(o2::framework::InitContext&) + { + const std::array doprocess{doprocessStandard, doprocessStandardWithCorrecteddEdx, doprocessWithdEdxTrQA, doprocessWithdEdxTrQAWithCorrecteddEdx, doprocessWithTrQA, doprocessWithTrQAWithCorrecteddEdx, doprocessDummy}; + if (std::accumulate(doprocess.begin(), doprocess.end(), 0) != 1) { + LOGP(fatal, "One and only one process function should be enabled"); + } + + ccdb->setURL("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setFatalWhenNull(false); + } + template void fillSkimmedTpcTofTable(T const& track, aod::TracksQA const& trackQA, const bool existTrkQA, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float nSigmaITS, const float dEdxExp, const o2::track::PID::ID id, const int runnumber, const double dwnSmplFactor, const double hadronicRate, const int bcGlobalIndex, const int bcTimeFrameId, const int bcBcInTimeFrame) { @@ -737,21 +761,6 @@ struct TreeWriterTpcTof { } } /// fillSkimmedTpcTofTable - void init(o2::framework::InitContext&) - { - const std::array doprocess{doprocessStandard, doprocessStandardWithCorrecteddEdx, doprocessWithdEdxTrQA, doprocessWithdEdxTrQAWithCorrecteddEdx, doprocessWithTrQA, doprocessWithTrQAWithCorrecteddEdx, doprocessDummy}; - if (std::accumulate(doprocess.begin(), doprocess.end(), 0) != 1) { - LOGP(fatal, "One and only one process function should be enabled"); - } - - ccdb->setURL("http://alice-ccdb.cern.ch"); - ccdb->setCaching(true); - ccdb->setFatalWhenNull(false); - } - - Preslice perCollisionTracks = aod::track::collisionId; - Preslice perCollisionTracksWithCorrecteddEdx = aod::track::collisionId; - template void runTof(Colls const& collisions, TrksType const& myTracks, TrkQAType const& tracksQA, Preslice const& perCollisionTracksType) { @@ -766,7 +775,6 @@ struct TreeWriterTpcTof { } } for (const auto& collision : collisions) { - /// Check event selection const auto& tracks = myTracks.sliceBy(perCollisionTracksType, collision.globalIndex()); if (!isEventSelected(collision, applyEvSel)) { continue; @@ -830,37 +838,53 @@ struct TreeWriterTpcTof { } } /// runTof - void processStandard(Colls const& collisions, Trks const& myTracks, aod::BCsWithTimestamps const&) + void processStandard(Colls const& collisions, + Trks const& myTracks, + aod::BCsWithTimestamps const&) { runTof(collisions, myTracks, static_cast(nullptr), perCollisionTracks); } PROCESS_SWITCH(TreeWriterTpcTof, processStandard, "Standard Samples for PID", true); - void processStandardWithCorrecteddEdx(Colls const& collisions, TrksWithDEdxCorrection const& myTracks, aod::BCsWithTimestamps const&) + void processStandardWithCorrecteddEdx(Colls const& collisions, + TrksWithDEdxCorrection const& myTracks, + aod::BCsWithTimestamps const&) { runTof(collisions, myTracks, static_cast(nullptr), perCollisionTracksWithCorrecteddEdx); } PROCESS_SWITCH(TreeWriterTpcTof, processStandardWithCorrecteddEdx, "Standard Samples for PID with corrected dEdx", false); - void processWithdEdxTrQA(Colls const& collisions, Trks const& myTracks, aod::BCsWithTimestamps const&, aod::TracksQAVersion const& tracksQA) + void processWithdEdxTrQA(Colls const& collisions, + Trks const& myTracks, + aod::BCsWithTimestamps const&, + aod::TracksQAVersion const& tracksQA) { runTof(collisions, myTracks, tracksQA, perCollisionTracks); } PROCESS_SWITCH(TreeWriterTpcTof, processWithdEdxTrQA, "Samples for PID with TrackQA info", false); - void processWithdEdxTrQAWithCorrecteddEdx(Colls const& collisions, TrksWithDEdxCorrection const& myTracks, aod::BCsWithTimestamps const&, aod::TracksQAVersion const& tracksQA) + void processWithdEdxTrQAWithCorrecteddEdx(Colls const& collisions, + TrksWithDEdxCorrection const& myTracks, + aod::BCsWithTimestamps const&, + aod::TracksQAVersion const& tracksQA) { runTof(collisions, myTracks, tracksQA, perCollisionTracksWithCorrecteddEdx); } PROCESS_SWITCH(TreeWriterTpcTof, processWithdEdxTrQAWithCorrecteddEdx, "Samples for PID with TrackQA info with corrected dEdx", false); - void processWithTrQA(Colls const& collisions, Trks const& myTracks, MyBCTable const&, aod::TracksQAVersion const& tracksQA) + void processWithTrQA(Colls const& collisions, + Trks const& myTracks, + MyBCTable const&, + aod::TracksQAVersion const& tracksQA) { runTof(collisions, myTracks, tracksQA, perCollisionTracks); } PROCESS_SWITCH(TreeWriterTpcTof, processWithTrQA, "Samples for PID with TrackQA info", false); - void processWithTrQAWithCorrecteddEdx(Colls const& collisions, TrksWithDEdxCorrection const& myTracks, MyBCTable const&, aod::TracksQAVersion const& tracksQA) + void processWithTrQAWithCorrecteddEdx(Colls const& collisions, + TrksWithDEdxCorrection const& myTracks, + MyBCTable const&, + aod::TracksQAVersion const& tracksQA) { runTof(collisions, myTracks, tracksQA, perCollisionTracksWithCorrecteddEdx); } diff --git a/DPG/Tasks/TPC/tpcSkimsTableCreator.h b/DPG/Tasks/TPC/tpcSkimsTableCreator.h index a7224ddd082..845109bcb90 100644 --- a/DPG/Tasks/TPC/tpcSkimsTableCreator.h +++ b/DPG/Tasks/TPC/tpcSkimsTableCreator.h @@ -142,6 +142,13 @@ enum { ModeWithTrkQA }; +constexpr o2::track::PID::ID PidElectron{o2::track::PID::Electron}; +constexpr o2::track::PID::ID PidPion{o2::track::PID::Pion}; +constexpr o2::track::PID::ID PidKaon{o2::track::PID::Kaon}; +constexpr o2::track::PID::ID PidProton{o2::track::PID::Proton}; +constexpr o2::track::PID::ID PidDeuteron{o2::track::PID::Deuteron}; +constexpr o2::track::PID::ID PidTriton{o2::track::PID::Triton}; + constexpr int UndefValueInt{-999}; constexpr float UndefValueFloat{-999.f}; constexpr double UndefValueDouble{-999.}; From a70e1d5b9a6fa811843a1cbbe4cbaf69e391eb39 Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Fri, 21 Nov 2025 09:53:50 +0100 Subject: [PATCH 11/22] remove Filter from TOF struct - unused anymore, lead to runtime crash --- DPG/Tasks/TPC/tpcSkimsTableCreator.cxx | 7 ------- 1 file changed, 7 deletions(-) diff --git a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx index efc4aa579cb..42ad9379ccd 100644 --- a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx +++ b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx @@ -635,13 +635,6 @@ struct TreeWriterTpcTof { using Colls = soa::Join; using MyBCTable = soa::Join; - Filter trackFilter = (trackSelection.node() == static_cast(TrackSelectionNoCut)) || - ((trackSelection.node() == static_cast(TrackSelectionGlobalTrack)) && requireGlobalTrackInFilter()) || - ((trackSelection.node() == static_cast(TrackSelectionTrackWoPtEta)) && requireGlobalTrackWoPtEtaInFilter()) || - ((trackSelection.node() == static_cast(TrackSelectionGlobalTrackWoDCA)) && requireGlobalTrackWoDCAInFilter()) || - ((trackSelection.node() == static_cast(TrackSelectionQualityTracks)) && requireQualityTracksInFilter()) || - ((trackSelection.node() == static_cast(TrackSelectionInAcceptanceTracks)) && requireTrackCutInFilter(TrackSelectionFlags::kInAcceptanceTracks)); - Preslice perCollisionTracks = aod::track::collisionId; Preslice perCollisionTracksWithCorrecteddEdx = aod::track::collisionId; From 939bc93857646886905c03c0aae006eb5f137118 Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Fri, 21 Nov 2025 18:49:33 +0100 Subject: [PATCH 12/22] use (formally) the myTracks in the processStandard() - otherwise crash --- DPG/Tasks/TPC/tpcSkimsTableCreator.cxx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx index 42ad9379ccd..2d64a05ff0b 100644 --- a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx +++ b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx @@ -389,8 +389,11 @@ struct TreeWriterTpcV0 { constexpr bool IsWithTrackQa = ModeId != ModeStandard; std::vector labelTrack2TrackQA; - if constexpr (IsWithTrackQa) { + if (IsWithTrackQa) { + // this action should not be under constexpr, otherwise the processStandard() function crashes when it is subscribed for myTracks but they're not used labelTrack2TrackQA.resize(myTracks.size(), -1); + } + if constexpr (IsWithTrackQa) { for (const auto& trackQA : tracksQA) { const int64_t trackId = trackQA.trackId(); labelTrack2TrackQA.at(trackId) = trackQA.globalIndex(); @@ -501,7 +504,11 @@ struct TreeWriterTpcV0 { PROCESS_SWITCH(TreeWriterTpcV0, processStandardWithCorrecteddEdx, "Standard V0 Samples for PID with corrected dEdx", false); void processWithdEdxTrQA(Colls const& collisions, - Trks const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, aod::BCsWithTimestamps const&, aod::TracksQAVersion const& tracksQA) + Trks const& myTracks, + V0sWithID const& myV0s, + CascsWithID const& myCascs, + aod::BCsWithTimestamps const&, + aod::TracksQAVersion const& tracksQA) { runV0(collisions, myTracks, myV0s, myCascs, tracksQA); } From d9c99d4bf46d2acebc3376b4ddacb8c52acdabe4 Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Sun, 30 Nov 2025 00:24:55 +0100 Subject: [PATCH 13/22] add nSigmaIts to V0 trees --- DPG/Tasks/TPC/tpcSkimsTableCreator.cxx | 52 ++++++++++++++++---------- DPG/Tasks/TPC/tpcSkimsTableCreator.h | 4 +- 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx index 2d64a05ff0b..a9a9f92b9d4 100644 --- a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx +++ b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx @@ -120,6 +120,7 @@ struct TreeWriterTpcV0 { double maxPt4dwnsmplTsalis{UndefValueDouble}; double tpcNSigma{UndefValueDouble}; double tofNSigma{UndefValueDouble}; + double itsNSigma{UndefValueDouble}; double tpcExpSignal{UndefValueDouble}; o2::track::PID::ID id{0}; double dwnSmplFactor{UndefValueDouble}; @@ -165,13 +166,13 @@ struct TreeWriterTpcV0 { { switch (daughterId) { case DaughterElectron: - return V0Daughter{downsamplingTsalisElectrons, MassElectron, maxPt4dwnsmplTsalisElectrons, track.tpcNSigmaEl(), getStrangenessTofNSigma(v0Casc, motherId, daughterId, isPositive), track.tpcExpSignalEl(tpcSignalGeneric(track)), PidElectron, dwnSmplFactorEl, NSigmaTofElectorn + 1.f, false}; + return V0Daughter{downsamplingTsalisElectrons, MassElectron, maxPt4dwnsmplTsalisElectrons, track.tpcNSigmaEl(), getStrangenessTofNSigma(v0Casc, motherId, daughterId, isPositive), track.itsNSigmaEl(), track.tpcExpSignalEl(tpcSignalGeneric(track)), PidElectron, dwnSmplFactorEl, NSigmaTofElectorn + 1.f, false}; case DaughterPion: - return V0Daughter{downsamplingTsalisPions, MassPiPlus, maxPt4dwnsmplTsalisPions, track.tpcNSigmaPi(), getStrangenessTofNSigma(v0Casc, motherId, daughterId, isPositive), track.tpcExpSignalPi(tpcSignalGeneric(track)), PidPion, dwnSmplFactorPi, nSigmaTofDauTrackPi, rejectNoTofDauTrackPi}; + return V0Daughter{downsamplingTsalisPions, MassPiPlus, maxPt4dwnsmplTsalisPions, track.tpcNSigmaPi(), getStrangenessTofNSigma(v0Casc, motherId, daughterId, isPositive), track.itsNSigmaPi(), track.tpcExpSignalPi(tpcSignalGeneric(track)), PidPion, dwnSmplFactorPi, nSigmaTofDauTrackPi, rejectNoTofDauTrackPi}; case DaughterProton: - return V0Daughter{downsamplingTsalisProtons, MassProton, maxPt4dwnsmplTsalisProtons, track.tpcNSigmaPr(), getStrangenessTofNSigma(v0Casc, motherId, daughterId, isPositive), track.tpcExpSignalPr(tpcSignalGeneric(track)), PidProton, dwnSmplFactorPr, nSigmaTofDauTrackPr, rejectNoTofDauTrackPr}; + return V0Daughter{downsamplingTsalisProtons, MassProton, maxPt4dwnsmplTsalisProtons, track.tpcNSigmaPr(), getStrangenessTofNSigma(v0Casc, motherId, daughterId, isPositive), track.itsNSigmaPr(), track.tpcExpSignalPr(tpcSignalGeneric(track)), PidProton, dwnSmplFactorPr, nSigmaTofDauTrackPr, rejectNoTofDauTrackPr}; case DaughterKaon: - return V0Daughter{downsamplingTsalisKaons, MassKPlus, maxPt4dwnsmplTsalisKaons, track.tpcNSigmaKa(), getStrangenessTofNSigma(v0Casc, motherId, daughterId, isPositive), track.tpcExpSignalKa(tpcSignalGeneric(track)), PidKaon, dwnSmplFactorKa, nSigmaTofDauTrackKa, rejectNoTofDauTrackKa}; + return V0Daughter{downsamplingTsalisKaons, MassKPlus, maxPt4dwnsmplTsalisKaons, track.tpcNSigmaKa(), getStrangenessTofNSigma(v0Casc, motherId, daughterId, isPositive), track.itsNSigmaKa(), track.tpcExpSignalKa(tpcSignalGeneric(track)), PidKaon, dwnSmplFactorKa, nSigmaTofDauTrackKa, rejectNoTofDauTrackKa}; default: { LOGP(fatal, "createV0Daughter: unknown daughterId"); return V0Daughter(); @@ -232,7 +233,7 @@ struct TreeWriterTpcV0 { } template - void fillSkimmedV0Table(V0Casc const& v0casc, T const& track, aod::TracksQA const& trackQA, const bool existTrkQA, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float dEdxExp, const o2::track::PID::ID id, const int runnumber, const double dwnSmplFactor, const float hadronicRate, const int bcGlobalIndex, const int bcTimeFrameId, const int bcBcInTimeFrame) + void fillSkimmedV0Table(V0Casc const& v0casc, T const& track, aod::TracksQA const& trackQA, const bool existTrkQA, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float nSigmaITS, const float dEdxExp, const o2::track::PID::ID id, const int runnumber, const double dwnSmplFactor, const float hadronicRate, const int bcGlobalIndex, const int bcTimeFrameId, const int bcBcInTimeFrame) { const double ncl = track.tpcNClsFound(); const double nclPID = track.tpcNClsFindableMinusPID(); @@ -275,6 +276,7 @@ struct TreeWriterTpcV0 { id, nSigmaTPC, nSigmaTOF, + nSigmaITS, runnumber, trackOcc, ft0Occ, @@ -302,6 +304,7 @@ struct TreeWriterTpcV0 { id, nSigmaTPC, nSigmaTOF, + nSigmaITS, runnumber, trackOcc, ft0Occ, @@ -330,6 +333,7 @@ struct TreeWriterTpcV0 { id, nSigmaTPC, nSigmaTOF, + nSigmaITS, runnumber, trackOcc, ft0Occ, @@ -389,16 +393,18 @@ struct TreeWriterTpcV0 { constexpr bool IsWithTrackQa = ModeId != ModeStandard; std::vector labelTrack2TrackQA; - if (IsWithTrackQa) { - // this action should not be under constexpr, otherwise the processStandard() function crashes when it is subscribed for myTracks but they're not used - labelTrack2TrackQA.resize(myTracks.size(), -1); - } if constexpr (IsWithTrackQa) { + labelTrack2TrackQA.resize(myTracks.size(), -1); for (const auto& trackQA : tracksQA) { const int64_t trackId = trackQA.trackId(); labelTrack2TrackQA.at(trackId) = trackQA.globalIndex(); } } + + const auto& tracksWithITSPid = soa::Attach(myTracks); + for (const auto& collision : collisions) { if (!isEventSelected(collision, applyEvSel)) { continue; @@ -430,7 +436,7 @@ struct TreeWriterTpcV0 { const bool passNSigmaTofCut = std::fabs(daughter.tofNSigma) < daughter.nSigmaTofDauTrack || std::fabs(daughter.tofNSigma - NSigmaTofUnmatched) < NSigmaTofUnmatchedEqualityTolerance; const bool passMatchTofRequirement = !daughter.rejectNoTofDauTrack || std::fabs(daughter.tofNSigma - NSigmaTofUnmatched) > NSigmaTofUnmatchedEqualityTolerance; if (passTrackSelection && passDownsamplig && passNSigmaTofCut && passMatchTofRequirement) { - fillSkimmedV0Table(mother, dauTrack, trackQAInstance, existTrkQA, collision, daughter.tpcNSigma, daughter.tofNSigma, daughter.tpcExpSignal, daughter.id, runnumber, daughter.dwnSmplFactor, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + fillSkimmedV0Table(mother, dauTrack, trackQAInstance, existTrkQA, collision, daughter.tpcNSigma, daughter.tofNSigma, daughter.itsNSigma, daughter.tpcExpSignal, daughter.id, runnumber, daughter.dwnSmplFactor, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); } }; @@ -457,12 +463,17 @@ struct TreeWriterTpcV0 { const auto& posTrack = v0.posTrack_as(); const auto& negTrack = v0.negTrack_as(); + const auto posTrackId = posTrack.globalIndex(); + const auto& posTrackWithITSPid = tracksWithITSPid.rawIteratorAt(posTrackId); + const auto negTrackId = negTrack.globalIndex(); + const auto& negTrackWithITSPid = tracksWithITSPid.rawIteratorAt(negTrackId); + const auto& [posTrackQA, existPosTrkQA] = getTrackQA(posTrack); const auto& [negTrackQA, existNegTrkQA] = getTrackQA(negTrack); const V0Mother v0Mother = createV0Mother(v0Id); - const V0Daughter posDaughter = createV0Daughter(v0, posTrack, v0Id, v0Mother.posDaughterId, true); - const V0Daughter negDaughter = createV0Daughter(v0, negTrack, v0Id, v0Mother.negDaughterId, false); + const V0Daughter posDaughter = createV0Daughter(v0, posTrackWithITSPid, v0Id, v0Mother.posDaughterId, true); + const V0Daughter negDaughter = createV0Daughter(v0, negTrackWithITSPid, v0Id, v0Mother.negDaughterId, false); fillDaughterTrack(v0, posTrack, posDaughter, posTrackQA, existPosTrkQA); fillDaughterTrack(v0, negTrack, negDaughter, negTrackQA, existNegTrkQA); @@ -475,7 +486,9 @@ struct TreeWriterTpcV0 { continue; } const auto& bachTrack = casc.bachelor_as(); - const V0Daughter bachDaughter = createV0Daughter(casc, bachTrack, cascId, DaughterKaon); + const auto bachTrackId = bachTrack.globalIndex(); + const auto& bachTrackWithITSPid = tracksWithITSPid.rawIteratorAt(bachTrackId); + const V0Daughter bachDaughter = createV0Daughter(casc, bachTrackWithITSPid, cascId, DaughterKaon); const auto& [bachTrackQA, existBachTrkQA] = getTrackQA(bachTrack); // Omega and antiomega fillDaughterTrack(casc, bachTrack, bachDaughter, bachTrackQA, existBachTrkQA); @@ -694,11 +707,11 @@ struct TreeWriterTpcTof { id, nSigmaTPC, nSigmaTOF, + nSigmaITS, runnumber, trackOcc, ft0Occ, - hadronicRate, - nSigmaITS); + hadronicRate); } else if constexpr (ModeId == ModeWithdEdxTrkQA) { rowTPCTOFTreeWithdEdxTrkQA(usedEdx, 1. / dEdxExp, @@ -716,11 +729,11 @@ struct TreeWriterTpcTof { id, nSigmaTPC, nSigmaTOF, + nSigmaITS, runnumber, trackOcc, ft0Occ, hadronicRate, - nSigmaITS, existTrkQA ? trackQA.tpcdEdxNorm() : UndefValueFloat); } else if constexpr (ModeId == ModeWithTrkQA) { rowTPCTOFTreeWithTrkQA(usedEdx, @@ -739,11 +752,11 @@ struct TreeWriterTpcTof { id, nSigmaTPC, nSigmaTOF, + nSigmaITS, runnumber, trackOcc, ft0Occ, hadronicRate, - nSigmaITS, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame, @@ -780,9 +793,8 @@ struct TreeWriterTpcTof { continue; } const auto& tracksWithITSPid = soa::Attach(tracks); + aod::pidits::ITSNSigmaPi, aod::pidits::ITSNSigmaKa, aod::pidits::ITSNSigmaPr, + aod::pidits::ITSNSigmaDe, aod::pidits::ITSNSigmaTr>(tracks); const auto& bc = collision.bc_as(); const int runnumber = bc.runNumber(); diff --git a/DPG/Tasks/TPC/tpcSkimsTableCreator.h b/DPG/Tasks/TPC/tpcSkimsTableCreator.h index 845109bcb90..87f74c902fd 100644 --- a/DPG/Tasks/TPC/tpcSkimsTableCreator.h +++ b/DPG/Tasks/TPC/tpcSkimsTableCreator.h @@ -72,6 +72,7 @@ DECLARE_SOA_COLUMN(BcBcInTimeFrame, bcBcInTimeFrame, int); tpcskims::PidIndex, \ tpcskims::NSigTPC, \ tpcskims::NSigTOF, \ + tpcskims::NSigITS, \ tpcskims::RunNumber, \ tpcskims::TrackOcc, \ tpcskims::Ft0Occ, \ @@ -87,8 +88,7 @@ DECLARE_SOA_COLUMN(BcBcInTimeFrame, bcBcInTimeFrame, int); tpcskims::GammaPsiPair #define TPCSKIMS_COLUMNS_TOF \ - TPCSKIMS_COLUMNS_BASE, \ - tpcskims::NSigITS + TPCSKIMS_COLUMNS_BASE #define TPCSKIMS_COLUMNS_TRACK_QA \ tpcskims::BcGlobalIndex, \ From 3702cd7be7c68d4702a359b803bebe0918cb2b2f Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Thu, 4 Dec 2025 15:27:11 +0100 Subject: [PATCH 14/22] add occupancy variables to WithTrkQa tree --- DPG/Tasks/TPC/tpcSkimsTableCreator.cxx | 102 +++++++++++++++------- DPG/Tasks/TPC/tpcSkimsTableCreator.h | 37 +++++--- DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h | 39 +++++++++ 3 files changed, 133 insertions(+), 45 deletions(-) diff --git a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx index a9a9f92b9d4..25869159b9c 100644 --- a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx +++ b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx @@ -140,11 +140,13 @@ struct TreeWriterTpcV0 { TRandom3* fRndm = new TRandom3(0); using Trks = soa::Join; - using TrksWithDEdxCorrection = soa::Join; + using TrksWithDEdxCorrection = soa::Join; using Colls = soa::Join; using MyBCTable = soa::Join; using V0sWithID = soa::Join; using CascsWithID = soa::Join; + using TrksTmo = soa::Join; + using TrksTmoWithDEdxCorrection = soa::Join; Preslice perCollisionV0s = aod::v0data::collisionId; Preslice perCollisionCascs = aod::cascdata::collisionId; @@ -233,7 +235,7 @@ struct TreeWriterTpcV0 { } template - void fillSkimmedV0Table(V0Casc const& v0casc, T const& track, aod::TracksQA const& trackQA, const bool existTrkQA, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float nSigmaITS, const float dEdxExp, const o2::track::PID::ID id, const int runnumber, const double dwnSmplFactor, const float hadronicRate, const int bcGlobalIndex, const int bcTimeFrameId, const int bcBcInTimeFrame) + void fillSkimmedV0Table(V0Casc const& v0casc, T const& track, aod::TracksQA const& trackQA, const bool existTrkQA, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float nSigmaITS, const float dEdxExp, const o2::track::PID::ID id, const int runnumber, const double dwnSmplFactor, const float hadronicRate, const int bcGlobalIndex, const int bcTimeFrameId, const int bcBcInTimeFrame, const occupancyValues& occValues) { const double ncl = track.tpcNClsFound(); const double nclPID = track.tpcNClsFindableMinusPID(); @@ -356,6 +358,16 @@ struct TreeWriterTpcV0 { existTrkQA ? trackQA.tpcdEdxTot1R() : UndefValueInt, existTrkQA ? trackQA.tpcdEdxTot2R() : UndefValueInt, existTrkQA ? trackQA.tpcdEdxTot3R() : UndefValueInt, + occValues.tmoPrimUnfm80, + occValues.tmoFV0AUnfm80, + occValues.tmoFT0AUnfm80, + occValues.tmoFT0CUnfm80, + occValues.tmoRT0V0PrimUnfm80, + occValues.twmoPrimUnfm80, + occValues.twmoFV0AUnfm80, + occValues.twmoFT0AUnfm80, + occValues.twmoFT0CUnfm80, + occValues.twmoRT0V0PrimUnfm80, existTrkQA ? trackQA.tpcdEdxNorm() : UndefValueFloat); } } @@ -436,7 +448,11 @@ struct TreeWriterTpcV0 { const bool passNSigmaTofCut = std::fabs(daughter.tofNSigma) < daughter.nSigmaTofDauTrack || std::fabs(daughter.tofNSigma - NSigmaTofUnmatched) < NSigmaTofUnmatchedEqualityTolerance; const bool passMatchTofRequirement = !daughter.rejectNoTofDauTrack || std::fabs(daughter.tofNSigma - NSigmaTofUnmatched) > NSigmaTofUnmatchedEqualityTolerance; if (passTrackSelection && passDownsamplig && passNSigmaTofCut && passMatchTofRequirement) { - fillSkimmedV0Table(mother, dauTrack, trackQAInstance, existTrkQA, collision, daughter.tpcNSigma, daughter.tofNSigma, daughter.itsNSigma, daughter.tpcExpSignal, daughter.id, runnumber, daughter.dwnSmplFactor, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + occupancyValues occValues{}; + if constexpr (ModeId == ModeWithTrkQA) { + evaluateOccupancyVariables(dauTrack, occValues); + } + fillSkimmedV0Table(mother, dauTrack, trackQAInstance, existTrkQA, collision, daughter.tpcNSigma, daughter.tofNSigma, daughter.itsNSigma, daughter.tpcExpSignal, daughter.id, runnumber, daughter.dwnSmplFactor, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame, occValues); } }; @@ -539,24 +555,26 @@ struct TreeWriterTpcV0 { PROCESS_SWITCH(TreeWriterTpcV0, processWithdEdxTrQAWithCorrecteddEdx, "Standard V0 Samples with dEdx from Track QA for PID with corrected dEdx", false); void processWithTrQA(Colls const& collisions, - Trks const& myTracks, + TrksTmo const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, MyBCTable const&, - aod::TracksQAVersion const& tracksQA) + aod::TracksQAVersion const& tracksQA, + TrackMeanOccs const&) { - runV0(collisions, myTracks, myV0s, myCascs, tracksQA); + runV0(collisions, myTracks, myV0s, myCascs, tracksQA); } PROCESS_SWITCH(TreeWriterTpcV0, processWithTrQA, "Standard V0 Samples with Track QA for PID", false); void processWithTrQAWithCorrecteddEdx(Colls const& collisions, - TrksWithDEdxCorrection const& myTracks, + TrksTmoWithDEdxCorrection const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, MyBCTable const&, - aod::TracksQAVersion const& tracksQA) + aod::TracksQAVersion const& tracksQA, + TrackMeanOccs const&) { - runV0(collisions, myTracks, myV0s, myCascs, tracksQA); + runV0(collisions, myTracks, myV0s, myCascs, tracksQA); } PROCESS_SWITCH(TreeWriterTpcV0, processWithTrQAWithCorrecteddEdx, "Standard V0 Samples with Track QA for PID with corrected dEdx", false); @@ -646,17 +664,16 @@ struct TreeWriterTpcTof { aod::pidTOFFullEl, aod::pidTOFFullPi, aod::pidTOFFullKa, aod::pidTOFFullPr, aod::pidTOFFullDe, aod::pidTOFFullTr, aod::TrackSelection>; - using TrksWithDEdxCorrection = soa::Join; + using TrksWithDEdxCorrection = soa::Join; using Colls = soa::Join; using MyBCTable = soa::Join; + using TrksTmo = soa::Join; + using TrksTmoWithDEdxCorrection = soa::Join; Preslice perCollisionTracks = aod::track::collisionId; Preslice perCollisionTracksWithCorrecteddEdx = aod::track::collisionId; + Preslice perCollisionTracksTmo = aod::track::collisionId; + Preslice perCollisionTracksTmoWithCorrecteddEdx = aod::track::collisionId; void init(o2::framework::InitContext&) { @@ -671,7 +688,7 @@ struct TreeWriterTpcTof { } template - void fillSkimmedTpcTofTable(T const& track, aod::TracksQA const& trackQA, const bool existTrkQA, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float nSigmaITS, const float dEdxExp, const o2::track::PID::ID id, const int runnumber, const double dwnSmplFactor, const double hadronicRate, const int bcGlobalIndex, const int bcTimeFrameId, const int bcBcInTimeFrame) + void fillSkimmedTpcTofTable(T const& track, aod::TracksQA const& trackQA, const bool existTrkQA, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float nSigmaITS, const float dEdxExp, const o2::track::PID::ID id, const int runnumber, const double dwnSmplFactor, const double hadronicRate, const int bcGlobalIndex, const int bcTimeFrameId, const int bcBcInTimeFrame, const occupancyValues& occValues) { const double ncl = track.tpcNClsFound(); const double nclPID = track.tpcNClsFindableMinusPID(); @@ -769,13 +786,23 @@ struct TreeWriterTpcTof { existTrkQA ? trackQA.tpcdEdxTot1R() : UndefValueInt, existTrkQA ? trackQA.tpcdEdxTot2R() : UndefValueInt, existTrkQA ? trackQA.tpcdEdxTot3R() : UndefValueInt, + occValues.tmoPrimUnfm80, + occValues.tmoFV0AUnfm80, + occValues.tmoFT0AUnfm80, + occValues.tmoFT0CUnfm80, + occValues.tmoRT0V0PrimUnfm80, + occValues.twmoPrimUnfm80, + occValues.twmoFV0AUnfm80, + occValues.twmoFT0AUnfm80, + occValues.twmoFT0CUnfm80, + occValues.twmoRT0V0PrimUnfm80, existTrkQA ? trackQA.tpcdEdxNorm() : UndefValueFloat); } } } /// fillSkimmedTpcTofTable - template - void runTof(Colls const& collisions, TrksType const& myTracks, TrkQAType const& tracksQA, Preslice const& perCollisionTracksType) + template + void runTof(Colls const& collisions, TrksType const& myTracks, TrkQAType const& tracksQA, Preslice const& perCollisionTracksType, TMOType const& trackMeanOccs) { constexpr bool IsWithTrackQa = ModeId != ModeStandard; @@ -792,9 +819,13 @@ struct TreeWriterTpcTof { if (!isEventSelected(collision, applyEvSel)) { continue; } - const auto& tracksWithITSPid = soa::Attach(tracks); + auto tracksWithITSPid = soa::Attach(tracks); + + if constexpr (ModeId == ModeWithTrkQA) { + tracksWithITSPid.bindExternalIndices(&trackMeanOccs); + } const auto& bc = collision.bc_as(); const int runnumber = bc.runNumber(); @@ -838,12 +869,17 @@ struct TreeWriterTpcTof { TofTrack tofPion(false, UndefValueDouble, maxMomTPCOnlyPi, trk.tpcNSigmaPi(), nSigmaTPCOnlyPi, downsamplingTsalisPions, MassPiPlus, trk.tofNSigmaPi(), trk.itsNSigmaPi(), trk.tpcExpSignalPi(tpcSignalGeneric(trk)), PidPion, dwnSmplFactorPi, nSigmaTofTpctofPi, nSigmaTpcTpctofPi); + occupancyValues occValues; + if constexpr (ModeId == ModeWithTrkQA) { + evaluateOccupancyVariables(trk, occValues); + } + for (const auto& tofTrack : {&tofTriton, &tofDeuteron, &tofProton, &tofKaon, &tofPion}) { if ((!tofTrack->isApplyHardCutOnly || trk.tpcInnerParam() < tofTrack->maxMomHardCutOnly) && ((trk.tpcInnerParam() <= tofTrack->maxMomTPCOnly && std::fabs(tofTrack->tpcNSigma) < tofTrack->nSigmaTPCOnly) || (trk.tpcInnerParam() > tofTrack->maxMomTPCOnly && std::fabs(tofTrack->tofNSigma) < tofTrack->nSigmaTofTpctof && std::fabs(tofTrack->tpcNSigma) < tofTrack->nSigmaTpcTpctof)) && downsampleTsalisCharged(fRndm, trk.pt(), tofTrack->downsamplingTsalis, tofTrack->mass, sqrtSNN)) { - fillSkimmedTpcTofTable(trk, trackQA, existTrkQA, collision, tofTrack->tpcNSigma, tofTrack->tofNSigma, tofTrack->itsNSigma, tofTrack->tpcExpSignal, tofTrack->pid, runnumber, tofTrack->dwnSmplFactor, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + fillSkimmedTpcTofTable(trk, trackQA, existTrkQA, collision, tofTrack->tpcNSigma, tofTrack->tofNSigma, tofTrack->itsNSigma, tofTrack->tpcExpSignal, tofTrack->pid, runnumber, tofTrack->dwnSmplFactor, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame, occValues); } } } /// Loop tracks @@ -854,7 +890,7 @@ struct TreeWriterTpcTof { Trks const& myTracks, aod::BCsWithTimestamps const&) { - runTof(collisions, myTracks, static_cast(nullptr), perCollisionTracks); + runTof(collisions, myTracks, static_cast(nullptr), perCollisionTracks, static_cast(nullptr)); } PROCESS_SWITCH(TreeWriterTpcTof, processStandard, "Standard Samples for PID", true); @@ -862,7 +898,7 @@ struct TreeWriterTpcTof { TrksWithDEdxCorrection const& myTracks, aod::BCsWithTimestamps const&) { - runTof(collisions, myTracks, static_cast(nullptr), perCollisionTracksWithCorrecteddEdx); + runTof(collisions, myTracks, static_cast(nullptr), perCollisionTracksWithCorrecteddEdx, static_cast(nullptr)); } PROCESS_SWITCH(TreeWriterTpcTof, processStandardWithCorrecteddEdx, "Standard Samples for PID with corrected dEdx", false); @@ -871,7 +907,7 @@ struct TreeWriterTpcTof { aod::BCsWithTimestamps const&, aod::TracksQAVersion const& tracksQA) { - runTof(collisions, myTracks, tracksQA, perCollisionTracks); + runTof(collisions, myTracks, tracksQA, perCollisionTracks, static_cast(nullptr)); } PROCESS_SWITCH(TreeWriterTpcTof, processWithdEdxTrQA, "Samples for PID with TrackQA info", false); @@ -880,25 +916,27 @@ struct TreeWriterTpcTof { aod::BCsWithTimestamps const&, aod::TracksQAVersion const& tracksQA) { - runTof(collisions, myTracks, tracksQA, perCollisionTracksWithCorrecteddEdx); + runTof(collisions, myTracks, tracksQA, perCollisionTracksWithCorrecteddEdx, static_cast(nullptr)); } PROCESS_SWITCH(TreeWriterTpcTof, processWithdEdxTrQAWithCorrecteddEdx, "Samples for PID with TrackQA info with corrected dEdx", false); void processWithTrQA(Colls const& collisions, - Trks const& myTracks, + TrksTmo const& myTracks, MyBCTable const&, - aod::TracksQAVersion const& tracksQA) + aod::TracksQAVersion const& tracksQA, + TrackMeanOccs const& trackMeanOccs) { - runTof(collisions, myTracks, tracksQA, perCollisionTracks); + runTof(collisions, myTracks, tracksQA, perCollisionTracksTmo, trackMeanOccs); } PROCESS_SWITCH(TreeWriterTpcTof, processWithTrQA, "Samples for PID with TrackQA info", false); void processWithTrQAWithCorrecteddEdx(Colls const& collisions, - TrksWithDEdxCorrection const& myTracks, + TrksTmoWithDEdxCorrection const& myTracks, MyBCTable const&, - aod::TracksQAVersion const& tracksQA) + aod::TracksQAVersion const& tracksQA, + TrackMeanOccs const& trackMeanOccs) { - runTof(collisions, myTracks, tracksQA, perCollisionTracksWithCorrecteddEdx); + runTof(collisions, myTracks, tracksQA, perCollisionTracksTmoWithCorrecteddEdx, trackMeanOccs); } PROCESS_SWITCH(TreeWriterTpcTof, processWithTrQAWithCorrecteddEdx, "Samples for PID with TrackQA info with correced dEdx", false); diff --git a/DPG/Tasks/TPC/tpcSkimsTableCreator.h b/DPG/Tasks/TPC/tpcSkimsTableCreator.h index 87f74c902fd..89ceae87116 100644 --- a/DPG/Tasks/TPC/tpcSkimsTableCreator.h +++ b/DPG/Tasks/TPC/tpcSkimsTableCreator.h @@ -21,6 +21,7 @@ #define DPG_TASKS_TPC_TPCSKIMSTABLECREATOR_H_ #include "Common/Core/trackUtilities.h" +#include "Common/DataModel/OccupancyTables.h" #include "Common/DataModel/PIDResponse.h" #include @@ -90,19 +91,29 @@ DECLARE_SOA_COLUMN(BcBcInTimeFrame, bcBcInTimeFrame, int); #define TPCSKIMS_COLUMNS_TOF \ TPCSKIMS_COLUMNS_BASE -#define TPCSKIMS_COLUMNS_TRACK_QA \ - tpcskims::BcGlobalIndex, \ - tpcskims::BcTimeFrameId, \ - tpcskims::BcBcInTimeFrame, \ - o2::aod::trackqa::TPCClusterByteMask, \ - o2::aod::trackqa::TPCdEdxMax0R, \ - o2::aod::trackqa::TPCdEdxMax1R, \ - o2::aod::trackqa::TPCdEdxMax2R, \ - o2::aod::trackqa::TPCdEdxMax3R, \ - o2::aod::trackqa::TPCdEdxTot0R, \ - o2::aod::trackqa::TPCdEdxTot1R, \ - o2::aod::trackqa::TPCdEdxTot2R, \ - o2::aod::trackqa::TPCdEdxTot3R +#define TPCSKIMS_COLUMNS_TRACK_QA \ + tpcskims::BcGlobalIndex, \ + tpcskims::BcTimeFrameId, \ + tpcskims::BcBcInTimeFrame, \ + o2::aod::trackqa::TPCClusterByteMask, \ + o2::aod::trackqa::TPCdEdxMax0R, \ + o2::aod::trackqa::TPCdEdxMax1R, \ + o2::aod::trackqa::TPCdEdxMax2R, \ + o2::aod::trackqa::TPCdEdxMax3R, \ + o2::aod::trackqa::TPCdEdxTot0R, \ + o2::aod::trackqa::TPCdEdxTot1R, \ + o2::aod::trackqa::TPCdEdxTot2R, \ + o2::aod::trackqa::TPCdEdxTot3R, \ + o2::aod::trackmeanocc::TmoPrimUnfm80, \ + o2::aod::trackmeanocc::TmoFV0AUnfm80, \ + o2::aod::trackmeanocc::TmoFT0AUnfm80, \ + o2::aod::trackmeanocc::TmoFT0CUnfm80, \ + o2::aod::trackmeanocc::TmoRobustT0V0PrimUnfm80, \ + o2::aod::trackmeanocc::TwmoPrimUnfm80, \ + o2::aod::trackmeanocc::TwmoFV0AUnfm80, \ + o2::aod::trackmeanocc::TwmoFT0AUnfm80, \ + o2::aod::trackmeanocc::TwmoFT0CUnfm80, \ + o2::aod::trackmeanocc::TwmoRobustT0V0PrimUnfm80 DECLARE_SOA_TABLE(SkimmedTPCV0Tree, "AOD", "TPCSKIMV0TREE", TPCSKIMS_COLUMNS_V0); diff --git a/DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h b/DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h index b516bfd9792..312ed764935 100644 --- a/DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h +++ b/DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h @@ -20,6 +20,10 @@ #ifndef DPG_TASKS_TPC_UTILSTPCSKIMSTABLECREATOR_H_ #define DPG_TASKS_TPC_UTILSTPCSKIMSTABLECREATOR_H_ +#include "tpcSkimsTableCreator.h" + +#include "Common/DataModel/OccupancyTables.h" + #include namespace o2::dpg_tpcskimstablecreator @@ -104,5 +108,40 @@ inline double tpcSignalGeneric(const TrkType& track) } } +struct occupancyValues { + float tmoPrimUnfm80{UndefValueFloat}; + float tmoFV0AUnfm80{UndefValueFloat}; + float tmoFT0AUnfm80{UndefValueFloat}; + float tmoFT0CUnfm80{UndefValueFloat}; + float tmoRT0V0PrimUnfm80{UndefValueFloat}; + float twmoPrimUnfm80{UndefValueFloat}; + float twmoFV0AUnfm80{UndefValueFloat}; + float twmoFT0AUnfm80{UndefValueFloat}; + float twmoFT0CUnfm80{UndefValueFloat}; + float twmoRT0V0PrimUnfm80{UndefValueFloat}; +}; + +using TrackMeanOccs = soa::Join; + +/// Evaluate occupancy-related variables +template +inline void evaluateOccupancyVariables(const TrkType& track, occupancyValues& occValues) +{ + if (track.tmoId() == -1) { + return; + } + const auto& tmoFromTrack = track.template tmo_as(); + occValues.tmoPrimUnfm80 = tmoFromTrack.tmoPrimUnfm80(); + occValues.tmoFV0AUnfm80 = tmoFromTrack.tmoFV0AUnfm80(); + occValues.tmoFT0AUnfm80 = tmoFromTrack.tmoFT0AUnfm80(); + occValues.tmoFT0CUnfm80 = tmoFromTrack.tmoFT0CUnfm80(); + occValues.tmoRT0V0PrimUnfm80 = tmoFromTrack.tmoRobustT0V0PrimUnfm80(); + occValues.twmoPrimUnfm80 = tmoFromTrack.twmoPrimUnfm80(); + occValues.twmoFV0AUnfm80 = tmoFromTrack.twmoFV0AUnfm80(); + occValues.twmoFT0AUnfm80 = tmoFromTrack.twmoFT0AUnfm80(); + occValues.twmoFT0CUnfm80 = tmoFromTrack.twmoFT0CUnfm80(); + occValues.twmoRT0V0PrimUnfm80 = tmoFromTrack.twmoRobustT0V0PrimUnfm80(); +} + } // namespace o2::dpg_tpcskimstablecreator #endif // DPG_TASKS_TPC_UTILSTPCSKIMSTABLECREATOR_H_ From e5dc16d32195873c63b71ae0f03676186b3f7446 Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Thu, 4 Dec 2025 19:53:29 +0100 Subject: [PATCH 15/22] factor out repeating code in v0 and casc over pos, neg and bach --- DPG/Tasks/TPC/tpcSkimsTableCreator.cxx | 76 +++++++++++++++----------- 1 file changed, 43 insertions(+), 33 deletions(-) diff --git a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx index 25869159b9c..5d0745c4aaf 100644 --- a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx +++ b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx @@ -108,6 +108,7 @@ struct TreeWriterTpcV0 { }; enum { + DaughterUndef = -1, DaughterElectron = 0, DaughterPion, DaughterKaon, @@ -193,6 +194,10 @@ struct TreeWriterTpcV0 { return V0Mother{DaughterProton, DaughterPion}; case MotherAntiLambda: return V0Mother{DaughterPion, DaughterProton}; + case MotherOmega: + return V0Mother{DaughterUndef, DaughterKaon}; + case MotherAntiOmega: + return V0Mother{DaughterKaon, DaughterUndef}; default: { LOGP(fatal, "createV0Mother: unknown motherId"); return V0Mother(); @@ -399,6 +404,18 @@ struct TreeWriterTpcV0 { return casc.cascradius(); } + /// Evaluate add id of the v0 + double getAddId(V0sWithID::iterator const& v0) + { + return v0.v0addid(); + } + + /// Evaluate add id of the cascade + double getAddId(CascsWithID::iterator const& casc) + { + return casc.cascaddid(); + } + template void runV0(Colls const& collisions, TrksType const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, TrkQAType const& tracksQA) { @@ -442,20 +459,6 @@ struct TreeWriterTpcV0 { rowTPCTreeWithTrkQA.reserve(2 * v0s.size() + cascs.size()); } - auto fillDaughterTrack = [&](const auto& mother, const TrksType::iterator& dauTrack, const V0Daughter& daughter, const aod::TracksQA& trackQAInstance, const bool existTrkQA) { - const bool passTrackSelection = isTrackSelected(dauTrack, trackSelection); - const bool passDownsamplig = downsampleTsalisCharged(fRndm, dauTrack.pt(), daughter.downsamplingTsalis, daughter.mass, sqrtSNN, daughter.maxPt4dwnsmplTsalis); - const bool passNSigmaTofCut = std::fabs(daughter.tofNSigma) < daughter.nSigmaTofDauTrack || std::fabs(daughter.tofNSigma - NSigmaTofUnmatched) < NSigmaTofUnmatchedEqualityTolerance; - const bool passMatchTofRequirement = !daughter.rejectNoTofDauTrack || std::fabs(daughter.tofNSigma - NSigmaTofUnmatched) > NSigmaTofUnmatchedEqualityTolerance; - if (passTrackSelection && passDownsamplig && passNSigmaTofCut && passMatchTofRequirement) { - occupancyValues occValues{}; - if constexpr (ModeId == ModeWithTrkQA) { - evaluateOccupancyVariables(dauTrack, occValues); - } - fillSkimmedV0Table(mother, dauTrack, trackQAInstance, existTrkQA, collision, daughter.tpcNSigma, daughter.tofNSigma, daughter.itsNSigma, daughter.tpcExpSignal, daughter.id, runnumber, daughter.dwnSmplFactor, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame, occValues); - } - }; - auto getTrackQA = [&](const TrksType::iterator& track) { if constexpr (!IsWithTrackQa) { return std::make_pair(aod::TracksQA{}, false); @@ -470,6 +473,28 @@ struct TreeWriterTpcV0 { } }; + auto fillDaughterTrack = [&](const auto& mother, const TrksType::iterator& dauTrack, const auto& v0, const bool isPositive) { + const auto [trackQAInstance, existTrkQA] = getTrackQA(dauTrack); + const auto trackId = dauTrack.globalIndex(); + const auto& dauTrackWithITSPid = tracksWithITSPid.rawIteratorAt(trackId); + const auto v0Id = getAddId(v0); + const V0Mother v0Mother = createV0Mother(v0Id); + const auto daighterId = isPositive ? v0Mother.posDaughterId : v0Mother.negDaughterId; + const V0Daughter daughter = createV0Daughter(v0, dauTrackWithITSPid, v0Id, daighterId, isPositive); + + const bool passTrackSelection = isTrackSelected(dauTrack, trackSelection); + const bool passDownsamplig = downsampleTsalisCharged(fRndm, dauTrack.pt(), daughter.downsamplingTsalis, daughter.mass, sqrtSNN, daughter.maxPt4dwnsmplTsalis); + const bool passNSigmaTofCut = std::fabs(daughter.tofNSigma) < daughter.nSigmaTofDauTrack || std::fabs(daughter.tofNSigma - NSigmaTofUnmatched) < NSigmaTofUnmatchedEqualityTolerance; + const bool passMatchTofRequirement = !daughter.rejectNoTofDauTrack || std::fabs(daughter.tofNSigma - NSigmaTofUnmatched) > NSigmaTofUnmatchedEqualityTolerance; + if (passTrackSelection && passDownsamplig && passNSigmaTofCut && passMatchTofRequirement) { + occupancyValues occValues{}; + if constexpr (ModeId == ModeWithTrkQA) { + evaluateOccupancyVariables(dauTrack, occValues); + } + fillSkimmedV0Table(mother, dauTrack, trackQAInstance, existTrkQA, collision, daughter.tpcNSigma, daughter.tofNSigma, daughter.itsNSigma, daughter.tpcExpSignal, daughter.id, runnumber, daughter.dwnSmplFactor, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame, occValues); + } + }; + /// Loop over v0 candidates for (const auto& v0 : v0s) { const auto v0Id = v0.v0addid(); @@ -479,20 +504,8 @@ struct TreeWriterTpcV0 { const auto& posTrack = v0.posTrack_as(); const auto& negTrack = v0.negTrack_as(); - const auto posTrackId = posTrack.globalIndex(); - const auto& posTrackWithITSPid = tracksWithITSPid.rawIteratorAt(posTrackId); - const auto negTrackId = negTrack.globalIndex(); - const auto& negTrackWithITSPid = tracksWithITSPid.rawIteratorAt(negTrackId); - - const auto& [posTrackQA, existPosTrkQA] = getTrackQA(posTrack); - const auto& [negTrackQA, existNegTrkQA] = getTrackQA(negTrack); - - const V0Mother v0Mother = createV0Mother(v0Id); - const V0Daughter posDaughter = createV0Daughter(v0, posTrackWithITSPid, v0Id, v0Mother.posDaughterId, true); - const V0Daughter negDaughter = createV0Daughter(v0, negTrackWithITSPid, v0Id, v0Mother.negDaughterId, false); - - fillDaughterTrack(v0, posTrack, posDaughter, posTrackQA, existPosTrkQA); - fillDaughterTrack(v0, negTrack, negDaughter, negTrackQA, existNegTrkQA); + fillDaughterTrack(v0, posTrack, v0, true); + fillDaughterTrack(v0, negTrack, v0, false); } /// Loop over cascade candidates @@ -502,12 +515,9 @@ struct TreeWriterTpcV0 { continue; } const auto& bachTrack = casc.bachelor_as(); - const auto bachTrackId = bachTrack.globalIndex(); - const auto& bachTrackWithITSPid = tracksWithITSPid.rawIteratorAt(bachTrackId); - const V0Daughter bachDaughter = createV0Daughter(casc, bachTrackWithITSPid, cascId, DaughterKaon); - const auto& [bachTrackQA, existBachTrkQA] = getTrackQA(bachTrack); // Omega and antiomega - fillDaughterTrack(casc, bachTrack, bachDaughter, bachTrackQA, existBachTrkQA); + const auto isDaughterPositive = cascId == MotherAntiOmega ? true : false; + fillDaughterTrack(casc, bachTrack, casc, isDaughterPositive); } } } /// runV0 From d7e453d9bcd656739dec969a4d01121edfb3b2ed Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Thu, 4 Dec 2025 23:06:28 +0100 Subject: [PATCH 16/22] unite V0- and Casc-argument functions --- DPG/Tasks/TPC/tpcSkimsTableCreator.cxx | 56 +++++++++++++------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx index 5d0745c4aaf..c8b5653e389 100644 --- a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx +++ b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx @@ -378,42 +378,40 @@ struct TreeWriterTpcV0 { } } /// fillSkimmedV0Table - /// Evaluate cosPA of the v0 - template - double getCosPA(V0sWithID::iterator const& v0, CollisionType const&) + /// Evaluate cosPA of v0 or casc + template + double getCosPA(V0Casc const& v0casc, CollisionType const& collision) { - return v0.v0cosPA(); + static_assert(std::is_same_v || std::is_same_v, + "getCosPA() v0casc's type must be either V0sWithID::iterator or CascsWithID::iterator"); + if constexpr (std::is_same_v) + return v0casc.v0cosPA(); + else + return v0casc.casccosPA(collision.posX(), collision.posY(), collision.posZ()); } - /// Evaluate cosPA of the cascade - template - double getCosPA(CascsWithID::iterator const& casc, CollisionType const& collision) + /// Evaluate radius of v0 or casc + template + double getRadius(V0Casc const& v0casc) { - return casc.casccosPA(collision.posX(), collision.posY(), collision.posZ()); + static_assert(std::is_same_v || std::is_same_v, + "getRadius() v0casc's type must be either V0sWithID::iterator or CascsWithID::iterator"); + if constexpr (std::is_same_v) + return v0casc.v0radius(); + else + return v0casc.cascradius(); } - /// Evaluate radius of the v0 - double getRadius(V0sWithID::iterator const& v0) + /// Evaluate add id of v0 or casc + template + int getAddId(V0Casc const& v0casc) { - return v0.v0radius(); - } - - /// Evaluate radius of the cascade - double getRadius(CascsWithID::iterator const& casc) - { - return casc.cascradius(); - } - - /// Evaluate add id of the v0 - double getAddId(V0sWithID::iterator const& v0) - { - return v0.v0addid(); - } - - /// Evaluate add id of the cascade - double getAddId(CascsWithID::iterator const& casc) - { - return casc.cascaddid(); + static_assert(std::is_same_v || std::is_same_v, + "getAddId() v0casc's type must be either V0sWithID::iterator or CascsWithID::iterator"); + if constexpr (std::is_same_v) + return v0casc.v0addid(); + else + return v0casc.cascaddid(); } template From 0982875bb703a9e33426f26a067d68cbf08d100e Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Fri, 5 Dec 2025 19:27:35 +0100 Subject: [PATCH 17/22] use concepts for V0- and Casc-argument functions --- DPG/Tasks/TPC/tpcSkimsTableCreator.cxx | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx index c8b5653e389..3a34d6c2c24 100644 --- a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx +++ b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx @@ -47,7 +47,9 @@ #include #include +#include #include +#include #include #include @@ -59,6 +61,12 @@ using namespace o2::track; using namespace o2::dataformats; using namespace o2::dpg_tpcskimstablecreator; +using V0sWithID = soa::Join; +using CascsWithID = soa::Join; + +template +concept V0OrCasc = std::same_as || std::same_as; + struct TreeWriterTpcV0 { Produces rowTPCTree; @@ -144,8 +152,6 @@ struct TreeWriterTpcV0 { using TrksWithDEdxCorrection = soa::Join; using Colls = soa::Join; using MyBCTable = soa::Join; - using V0sWithID = soa::Join; - using CascsWithID = soa::Join; using TrksTmo = soa::Join; using TrksTmoWithDEdxCorrection = soa::Join; @@ -379,11 +385,9 @@ struct TreeWriterTpcV0 { } /// fillSkimmedV0Table /// Evaluate cosPA of v0 or casc - template + template double getCosPA(V0Casc const& v0casc, CollisionType const& collision) { - static_assert(std::is_same_v || std::is_same_v, - "getCosPA() v0casc's type must be either V0sWithID::iterator or CascsWithID::iterator"); if constexpr (std::is_same_v) return v0casc.v0cosPA(); else @@ -391,11 +395,9 @@ struct TreeWriterTpcV0 { } /// Evaluate radius of v0 or casc - template + template double getRadius(V0Casc const& v0casc) { - static_assert(std::is_same_v || std::is_same_v, - "getRadius() v0casc's type must be either V0sWithID::iterator or CascsWithID::iterator"); if constexpr (std::is_same_v) return v0casc.v0radius(); else @@ -403,11 +405,9 @@ struct TreeWriterTpcV0 { } /// Evaluate add id of v0 or casc - template + template int getAddId(V0Casc const& v0casc) { - static_assert(std::is_same_v || std::is_same_v, - "getAddId() v0casc's type must be either V0sWithID::iterator or CascsWithID::iterator"); if constexpr (std::is_same_v) return v0casc.v0addid(); else From c0812f1194e3c79c76ce01de7206d4b8d6403487 Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Mon, 8 Dec 2025 14:31:37 +0100 Subject: [PATCH 18/22] merge WithDeDxTrkQa tree to Standard tree --- DPG/Tasks/TPC/tpcSkimsTableCreator.cxx | 96 ++++++-------------------- DPG/Tasks/TPC/tpcSkimsTableCreator.h | 17 ++--- 2 files changed, 26 insertions(+), 87 deletions(-) diff --git a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx index 3a34d6c2c24..ce28a56ee9c 100644 --- a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx +++ b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx @@ -70,7 +70,6 @@ concept V0OrCasc = std::same_as || std::same_as rowTPCTree; - Produces rowTPCTreeWithdEdxTrkQA; Produces rowTPCTreeWithTrkQA; /// Configurables general @@ -266,13 +265,17 @@ struct TreeWriterTpcV0 { const double pseudoRndm = track.pt() * 1000. - static_cast(track.pt() * 1000); if (pseudoRndm < dwnSmplFactor) { - float usedDedx; + float usedDedx{UndefValueFloat}; if constexpr (DoUseCorrectedDeDx) { usedDedx = track.tpcSignalCorrected(); } else { usedDedx = track.tpcSignal(); } - if constexpr (ModeId == ModeStandard) { + float tpcdEdxNorm{UndefValueFloat}; + if constexpr (ModeId != ModeStandard) { + tpcdEdxNorm = existTrkQA ? trackQA.tpcdEdxNorm() : UndefValueFloat; + } + if constexpr (ModeId == ModeStandard || ModeId == ModeWithdEdxTrkQA) { rowTPCTree(usedDedx, 1. / dEdxExp, track.tpcInnerParam(), @@ -294,42 +297,14 @@ struct TreeWriterTpcV0 { trackOcc, ft0Occ, hadronicRate, + tpcdEdxNorm, alpha, qt, cosPA, pT, v0radius, gammapsipair); - } else if constexpr (ModeId == ModeWithdEdxTrkQA) { - rowTPCTreeWithdEdxTrkQA(usedDedx, - 1. / dEdxExp, - track.tpcInnerParam(), - track.tgl(), - track.signed1Pt(), - track.eta(), - track.phi(), - track.y(), - mass, - bg, - multTPC / MultiplicityNorm, - std::sqrt(nClNorm / ncl), - nclPID, - id, - nSigmaTPC, - nSigmaTOF, - nSigmaITS, - runnumber, - trackOcc, - ft0Occ, - hadronicRate, - alpha, - qt, - cosPA, - pT, - v0radius, - gammapsipair, - existTrkQA ? trackQA.tpcdEdxNorm() : UndefValueFloat); - } else if constexpr (ModeId == ModeWithTrkQA) { + } else { rowTPCTreeWithTrkQA(usedDedx, 1. / dEdxExp, track.tpcInnerParam(), @@ -351,6 +326,7 @@ struct TreeWriterTpcV0 { trackOcc, ft0Occ, hadronicRate, + tpcdEdxNorm, alpha, qt, cosPA, @@ -378,8 +354,7 @@ struct TreeWriterTpcV0 { occValues.twmoFV0AUnfm80, occValues.twmoFT0AUnfm80, occValues.twmoFT0CUnfm80, - occValues.twmoRT0V0PrimUnfm80, - existTrkQA ? trackQA.tpcdEdxNorm() : UndefValueFloat); + occValues.twmoRT0V0PrimUnfm80); } } } /// fillSkimmedV0Table @@ -446,11 +421,7 @@ struct TreeWriterTpcV0 { if constexpr (ModeId == ModeWithdEdxTrkQA || ModeId == ModeStandard) { bcTimeFrameId = UndefValueInt; bcBcInTimeFrame = UndefValueInt; - if constexpr (ModeId == ModeWithdEdxTrkQA) { - rowTPCTreeWithdEdxTrkQA.reserve(2 * v0s.size() + cascs.size()); - } else if (ModeId == ModeStandard) { - rowTPCTree.reserve(2 * v0s.size() + cascs.size()); - } + rowTPCTree.reserve(2 * v0s.size() + cascs.size()); } else if constexpr (ModeId == ModeWithTrkQA) { bcTimeFrameId = bc.tfId(); bcBcInTimeFrame = bc.bcInTF(); @@ -594,7 +565,6 @@ struct TreeWriterTpcV0 { struct TreeWriterTpcTof { Produces rowTPCTOFTree; - Produces rowTPCTOFTreeWithdEdxTrkQA; Produces rowTPCTOFTreeWithTrkQA; /// Configurables general @@ -715,7 +685,11 @@ struct TreeWriterTpcTof { } else { usedEdx = track.tpcSignal(); } - if (ModeId == ModeStandard) { + float tpcdEdxNorm{UndefValueFloat}; + if constexpr (ModeId != ModeStandard) { + tpcdEdxNorm = existTrkQA ? trackQA.tpcdEdxNorm() : UndefValueFloat; + } + if (ModeId == ModeStandard || ModeId == ModeWithdEdxTrkQA) { rowTPCTOFTree(usedEdx, 1. / dEdxExp, track.tpcInnerParam(), @@ -736,31 +710,9 @@ struct TreeWriterTpcTof { runnumber, trackOcc, ft0Occ, - hadronicRate); - } else if constexpr (ModeId == ModeWithdEdxTrkQA) { - rowTPCTOFTreeWithdEdxTrkQA(usedEdx, - 1. / dEdxExp, - track.tpcInnerParam(), - track.tgl(), - track.signed1Pt(), - track.eta(), - track.phi(), - track.y(), - mass, - bg, - multTPC / MultiplicityNorm, - std::sqrt(nClNorm / ncl), - nclPID, - id, - nSigmaTPC, - nSigmaTOF, - nSigmaITS, - runnumber, - trackOcc, - ft0Occ, - hadronicRate, - existTrkQA ? trackQA.tpcdEdxNorm() : UndefValueFloat); - } else if constexpr (ModeId == ModeWithTrkQA) { + hadronicRate, + tpcdEdxNorm); + } else { rowTPCTOFTreeWithTrkQA(usedEdx, 1. / dEdxExp, track.tpcInnerParam(), @@ -782,6 +734,7 @@ struct TreeWriterTpcTof { trackOcc, ft0Occ, hadronicRate, + tpcdEdxNorm, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame, @@ -803,8 +756,7 @@ struct TreeWriterTpcTof { occValues.twmoFV0AUnfm80, occValues.twmoFT0AUnfm80, occValues.twmoFT0CUnfm80, - occValues.twmoRT0V0PrimUnfm80, - existTrkQA ? trackQA.tpcdEdxNorm() : UndefValueFloat); + occValues.twmoRT0V0PrimUnfm80); } } } /// fillSkimmedTpcTofTable @@ -843,11 +795,7 @@ struct TreeWriterTpcTof { if constexpr (ModeId == ModeStandard || ModeId == ModeWithdEdxTrkQA) { bcTimeFrameId = UndefValueInt; bcBcInTimeFrame = UndefValueInt; - if constexpr (ModeId == ModeStandard) { - rowTPCTOFTree.reserve(tracks.size()); - } else { - rowTPCTOFTreeWithdEdxTrkQA.reserve(tracks.size()); - } + rowTPCTOFTree.reserve(tracks.size()); } else { bcTimeFrameId = bc.tfId(); bcBcInTimeFrame = bc.bcInTF(); diff --git a/DPG/Tasks/TPC/tpcSkimsTableCreator.h b/DPG/Tasks/TPC/tpcSkimsTableCreator.h index 89ceae87116..db10b3e42ce 100644 --- a/DPG/Tasks/TPC/tpcSkimsTableCreator.h +++ b/DPG/Tasks/TPC/tpcSkimsTableCreator.h @@ -77,7 +77,8 @@ DECLARE_SOA_COLUMN(BcBcInTimeFrame, bcBcInTimeFrame, int); tpcskims::RunNumber, \ tpcskims::TrackOcc, \ tpcskims::Ft0Occ, \ - tpcskims::HadronicRate + tpcskims::HadronicRate, \ + o2::aod::trackqa::TPCdEdxNorm #define TPCSKIMS_COLUMNS_V0 \ TPCSKIMS_COLUMNS_BASE, \ @@ -118,26 +119,16 @@ DECLARE_SOA_COLUMN(BcBcInTimeFrame, bcBcInTimeFrame, int); DECLARE_SOA_TABLE(SkimmedTPCV0Tree, "AOD", "TPCSKIMV0TREE", TPCSKIMS_COLUMNS_V0); -DECLARE_SOA_TABLE(SkimmedTPCV0TreeWithdEdxTrkQA, "AOD", "TPCSKIMV0WdE", - TPCSKIMS_COLUMNS_V0, - o2::aod::trackqa::TPCdEdxNorm); - DECLARE_SOA_TABLE(SkimmedTPCV0TreeWithTrkQA, "AOD", "TPCSKIMV0WQA", TPCSKIMS_COLUMNS_V0, - TPCSKIMS_COLUMNS_TRACK_QA, - o2::aod::trackqa::TPCdEdxNorm); + TPCSKIMS_COLUMNS_TRACK_QA); DECLARE_SOA_TABLE(SkimmedTPCTOFTree, "AOD", "TPCTOFSKIMTREE", TPCSKIMS_COLUMNS_TOF); -DECLARE_SOA_TABLE(SkimmedTPCTOFTreeWithdEdxTrkQA, "AOD", "TPCTOFSKIMWdE", - TPCSKIMS_COLUMNS_TOF, - o2::aod::trackqa::TPCdEdxNorm); - DECLARE_SOA_TABLE(SkimmedTPCTOFTreeWithTrkQA, "AOD", "TPCTOFSKIMWQA", TPCSKIMS_COLUMNS_TOF, - TPCSKIMS_COLUMNS_TRACK_QA, - o2::aod::trackqa::TPCdEdxNorm); + TPCSKIMS_COLUMNS_TRACK_QA); #undef TPCSKIMS_COLUMNS_TRACK_QA #undef TPCSKIMS_COLUMNS_TOF From 9cadc0866b3ad1c7fd003f12f0506dcc574501a7 Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Mon, 8 Dec 2025 14:41:37 +0100 Subject: [PATCH 19/22] reduce code repetition using tpcSignalGeneric<>() --- DPG/Tasks/TPC/tpcSkimsTableCreator.cxx | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx index ce28a56ee9c..17fc9f792dc 100644 --- a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx +++ b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx @@ -265,12 +265,7 @@ struct TreeWriterTpcV0 { const double pseudoRndm = track.pt() * 1000. - static_cast(track.pt() * 1000); if (pseudoRndm < dwnSmplFactor) { - float usedDedx{UndefValueFloat}; - if constexpr (DoUseCorrectedDeDx) { - usedDedx = track.tpcSignalCorrected(); - } else { - usedDedx = track.tpcSignal(); - } + const float usedDedx = tpcSignalGeneric(track); float tpcdEdxNorm{UndefValueFloat}; if constexpr (ModeId != ModeStandard) { tpcdEdxNorm = existTrkQA ? trackQA.tpcdEdxNorm() : UndefValueFloat; @@ -679,12 +674,7 @@ struct TreeWriterTpcTof { const double pseudoRndm = track.pt() * 1000. - static_cast(track.pt() * 1000); if (pseudoRndm < dwnSmplFactor) { - float usedEdx; - if constexpr (DoCorrectDeDx) { - usedEdx = track.tpcSignalCorrected(); - } else { - usedEdx = track.tpcSignal(); - } + const float usedEdx = tpcSignalGeneric(track); float tpcdEdxNorm{UndefValueFloat}; if constexpr (ModeId != ModeStandard) { tpcdEdxNorm = existTrkQA ? trackQA.tpcdEdxNorm() : UndefValueFloat; From 5b5fb2aa3166713b1c985afab3c45d78f9aad527 Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Sat, 20 Dec 2025 22:54:44 +0100 Subject: [PATCH 20/22] add occupancyMedianTime column --- DPG/Tasks/TPC/tpcSkimsTableCreator.cxx | 6 ++++++ DPG/Tasks/TPC/tpcSkimsTableCreator.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx index 17fc9f792dc..6cbfd01ed2c 100644 --- a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx +++ b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx @@ -255,6 +255,7 @@ struct TreeWriterTpcV0 { const int multTPC = collision.multTPC(); const auto trackOcc = collision.trackOccupancyInTimeRange(); const auto ft0Occ = collision.ft0cOccupancyInTimeRange(); + const auto occMedianTime = collision.occupancyMedianTime(); const float alpha = v0casc.alpha(); const float qt = v0casc.qtarm(); @@ -291,6 +292,7 @@ struct TreeWriterTpcV0 { runnumber, trackOcc, ft0Occ, + occMedianTime, hadronicRate, tpcdEdxNorm, alpha, @@ -320,6 +322,7 @@ struct TreeWriterTpcV0 { runnumber, trackOcc, ft0Occ, + occMedianTime, hadronicRate, tpcdEdxNorm, alpha, @@ -671,6 +674,7 @@ struct TreeWriterTpcTof { const int multTPC = collision.multTPC(); const auto trackOcc = collision.trackOccupancyInTimeRange(); const auto ft0Occ = collision.ft0cOccupancyInTimeRange(); + const auto occMedianTime = collision.occupancyMedianTime(); const double pseudoRndm = track.pt() * 1000. - static_cast(track.pt() * 1000); if (pseudoRndm < dwnSmplFactor) { @@ -700,6 +704,7 @@ struct TreeWriterTpcTof { runnumber, trackOcc, ft0Occ, + occMedianTime, hadronicRate, tpcdEdxNorm); } else { @@ -723,6 +728,7 @@ struct TreeWriterTpcTof { runnumber, trackOcc, ft0Occ, + occMedianTime, hadronicRate, tpcdEdxNorm, bcGlobalIndex, diff --git a/DPG/Tasks/TPC/tpcSkimsTableCreator.h b/DPG/Tasks/TPC/tpcSkimsTableCreator.h index db10b3e42ce..e487af69015 100644 --- a/DPG/Tasks/TPC/tpcSkimsTableCreator.h +++ b/DPG/Tasks/TPC/tpcSkimsTableCreator.h @@ -50,6 +50,7 @@ DECLARE_SOA_COLUMN(GammaPsiPair, gammaPsiPair, float); DECLARE_SOA_COLUMN(RunNumber, runNumber, int); DECLARE_SOA_COLUMN(TrackOcc, trackOcc, float); DECLARE_SOA_COLUMN(Ft0Occ, ft0Occ, float); +DECLARE_SOA_COLUMN(OccMedianTime, occMedianTime, float); DECLARE_SOA_COLUMN(HadronicRate, hadronicRate, float); DECLARE_SOA_COLUMN(BcGlobalIndex, bcGlobalIndex, int); DECLARE_SOA_COLUMN(BcTimeFrameId, bcTimeFrameId, int); @@ -77,6 +78,7 @@ DECLARE_SOA_COLUMN(BcBcInTimeFrame, bcBcInTimeFrame, int); tpcskims::RunNumber, \ tpcskims::TrackOcc, \ tpcskims::Ft0Occ, \ + tpcskims::OccMedianTime, \ tpcskims::HadronicRate, \ o2::aod::trackqa::TPCdEdxNorm From 140357a159fd4f0ed86b1697385dbf4c44d26c85 Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Sat, 20 Dec 2025 23:58:14 +0100 Subject: [PATCH 21/22] constexpr->const for std::fabs()-initialized variable (macOS-arm concession) --- DPG/Tasks/TPC/tpcSkimsTableCreator.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx index 6cbfd01ed2c..8313508bc14 100644 --- a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx +++ b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx @@ -100,7 +100,7 @@ struct TreeWriterTpcV0 { // an arbitrary value of N sigma TOF assigned by TOF task to tracks which are not matched to TOF hits constexpr static float NSigmaTofUnmatched{o2::aod::v0data::kNoTOFValue}; - constexpr static float NSigmaTofUnmatchedEqualityTolerance{std::fabs(NSigmaTofUnmatched) / 1e4f}; + const float nSigmaTofUnmatchedEqualityTolerance{std::fabs(NSigmaTofUnmatched) / 1e4f}; // an arbitrary value of "N sigma TOF" assigned to electorns (for uniformity reasons) constexpr static float NSigmaTofElectorn{1000.f}; @@ -451,8 +451,8 @@ struct TreeWriterTpcV0 { const bool passTrackSelection = isTrackSelected(dauTrack, trackSelection); const bool passDownsamplig = downsampleTsalisCharged(fRndm, dauTrack.pt(), daughter.downsamplingTsalis, daughter.mass, sqrtSNN, daughter.maxPt4dwnsmplTsalis); - const bool passNSigmaTofCut = std::fabs(daughter.tofNSigma) < daughter.nSigmaTofDauTrack || std::fabs(daughter.tofNSigma - NSigmaTofUnmatched) < NSigmaTofUnmatchedEqualityTolerance; - const bool passMatchTofRequirement = !daughter.rejectNoTofDauTrack || std::fabs(daughter.tofNSigma - NSigmaTofUnmatched) > NSigmaTofUnmatchedEqualityTolerance; + const bool passNSigmaTofCut = std::fabs(daughter.tofNSigma) < daughter.nSigmaTofDauTrack || std::fabs(daughter.tofNSigma - NSigmaTofUnmatched) < nSigmaTofUnmatchedEqualityTolerance; + const bool passMatchTofRequirement = !daughter.rejectNoTofDauTrack || std::fabs(daughter.tofNSigma - NSigmaTofUnmatched) > nSigmaTofUnmatchedEqualityTolerance; if (passTrackSelection && passDownsamplig && passNSigmaTofCut && passMatchTofRequirement) { occupancyValues occValues{}; if constexpr (ModeId == ModeWithTrkQA) { From 69c7dc49fcae4b3fa16b026a5a430544c003579b Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Sun, 21 Dec 2025 00:18:09 +0100 Subject: [PATCH 22/22] use UpperCamelCase for struct OccupancyValues --- DPG/Tasks/TPC/tpcSkimsTableCreator.cxx | 8 ++++---- DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx index 8313508bc14..f7fbc0f0e43 100644 --- a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx +++ b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx @@ -245,7 +245,7 @@ struct TreeWriterTpcV0 { } template - void fillSkimmedV0Table(V0Casc const& v0casc, T const& track, aod::TracksQA const& trackQA, const bool existTrkQA, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float nSigmaITS, const float dEdxExp, const o2::track::PID::ID id, const int runnumber, const double dwnSmplFactor, const float hadronicRate, const int bcGlobalIndex, const int bcTimeFrameId, const int bcBcInTimeFrame, const occupancyValues& occValues) + void fillSkimmedV0Table(V0Casc const& v0casc, T const& track, aod::TracksQA const& trackQA, const bool existTrkQA, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float nSigmaITS, const float dEdxExp, const o2::track::PID::ID id, const int runnumber, const double dwnSmplFactor, const float hadronicRate, const int bcGlobalIndex, const int bcTimeFrameId, const int bcBcInTimeFrame, const OccupancyValues& occValues) { const double ncl = track.tpcNClsFound(); const double nclPID = track.tpcNClsFindableMinusPID(); @@ -454,7 +454,7 @@ struct TreeWriterTpcV0 { const bool passNSigmaTofCut = std::fabs(daughter.tofNSigma) < daughter.nSigmaTofDauTrack || std::fabs(daughter.tofNSigma - NSigmaTofUnmatched) < nSigmaTofUnmatchedEqualityTolerance; const bool passMatchTofRequirement = !daughter.rejectNoTofDauTrack || std::fabs(daughter.tofNSigma - NSigmaTofUnmatched) > nSigmaTofUnmatchedEqualityTolerance; if (passTrackSelection && passDownsamplig && passNSigmaTofCut && passMatchTofRequirement) { - occupancyValues occValues{}; + OccupancyValues occValues{}; if constexpr (ModeId == ModeWithTrkQA) { evaluateOccupancyVariables(dauTrack, occValues); } @@ -664,7 +664,7 @@ struct TreeWriterTpcTof { } template - void fillSkimmedTpcTofTable(T const& track, aod::TracksQA const& trackQA, const bool existTrkQA, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float nSigmaITS, const float dEdxExp, const o2::track::PID::ID id, const int runnumber, const double dwnSmplFactor, const double hadronicRate, const int bcGlobalIndex, const int bcTimeFrameId, const int bcBcInTimeFrame, const occupancyValues& occValues) + void fillSkimmedTpcTofTable(T const& track, aod::TracksQA const& trackQA, const bool existTrkQA, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float nSigmaITS, const float dEdxExp, const o2::track::PID::ID id, const int runnumber, const double dwnSmplFactor, const double hadronicRate, const int bcGlobalIndex, const int bcTimeFrameId, const int bcBcInTimeFrame, const OccupancyValues& occValues) { const double ncl = track.tpcNClsFound(); const double nclPID = track.tpcNClsFindableMinusPID(); @@ -821,7 +821,7 @@ struct TreeWriterTpcTof { TofTrack tofPion(false, UndefValueDouble, maxMomTPCOnlyPi, trk.tpcNSigmaPi(), nSigmaTPCOnlyPi, downsamplingTsalisPions, MassPiPlus, trk.tofNSigmaPi(), trk.itsNSigmaPi(), trk.tpcExpSignalPi(tpcSignalGeneric(trk)), PidPion, dwnSmplFactorPi, nSigmaTofTpctofPi, nSigmaTpcTpctofPi); - occupancyValues occValues; + OccupancyValues occValues; if constexpr (ModeId == ModeWithTrkQA) { evaluateOccupancyVariables(trk, occValues); } diff --git a/DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h b/DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h index 312ed764935..4fab2b1b6a1 100644 --- a/DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h +++ b/DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h @@ -108,7 +108,7 @@ inline double tpcSignalGeneric(const TrkType& track) } } -struct occupancyValues { +struct OccupancyValues { float tmoPrimUnfm80{UndefValueFloat}; float tmoFV0AUnfm80{UndefValueFloat}; float tmoFT0AUnfm80{UndefValueFloat}; @@ -125,7 +125,7 @@ using TrackMeanOccs = soa::Join -inline void evaluateOccupancyVariables(const TrkType& track, occupancyValues& occValues) +inline void evaluateOccupancyVariables(const TrkType& track, OccupancyValues& occValues) { if (track.tmoId() == -1) { return;