From 4befc4ca43f5c873f6a725e1192b9ab8181c5370 Mon Sep 17 00:00:00 2001 From: Andrea Date: Fri, 18 Jul 2025 15:38:30 +0200 Subject: [PATCH 1/8] adding filtering of collisions to save space and better balancing filtering of tracks. --- DPG/Tasks/ITS/filterTracks.cxx | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/DPG/Tasks/ITS/filterTracks.cxx b/DPG/Tasks/ITS/filterTracks.cxx index c4dcfacc9a4..a25b35f8155 100644 --- a/DPG/Tasks/ITS/filterTracks.cxx +++ b/DPG/Tasks/ITS/filterTracks.cxx @@ -146,17 +146,22 @@ struct FilterTracks { Produces selectedGenParticles; Produces filterCollTable; + SliceCache cache; // Configurable dummy{"dummy", 0, "dummy"}; Configurable minTrackPt{"minTrackPt", 0.25, "min track pt"}; Configurable trackDcaXyMax{"trackDcaXyMax", 0.5, "max track pt"}; Configurable trackPtSampling{"trackPtSampling", 0, "track sampling mode"}; Configurable trackPtWeightLowPt{"trackPtWeightLowPt", 0.01f, "trackPtWeightLowPt"}; Configurable trackPtWeightMidPt{"trackPtWeightMidPt", 0.10f, "trackPtWeightMidPt"}; + Configurable collFilterFraction{"collFilterFraction", 0.05f, "collFilterFraction"}; Filter trackFilter = requireGlobalTrackWoDCAInFilter() && aod::track::pt > minTrackPt&& nabs(aod::track::dcaXY) < trackDcaXyMax; + Filter collFilter = nabs(aod::collision::posZ * 10000.f - nround(aod::collision::posZ * 10000.f)) < collFilterFraction.node() * 2.f; using CollisionsWithEvSel = soa::Join; using TracksWithSelAndDca = soa::Join; using TracksWithSelAndDcaMc = soa::Join; + using FilterCollisionsWithEvSel = soa::Filtered; + Partition> lowPtTracks = aod::track::pt < 2.f && (nabs(aod::track::pt * 10000.f - nround(aod::track::pt * 10000.f)) < trackPtWeightLowPt.node() * 2.f); Partition> midPtTracks = aod::track::pt > 2.f && aod::track::pt < 5.f && (nabs(aod::track::pt * 10000.f - nround(aod::track::pt * 10000.f)) < trackPtWeightMidPt.node() * 2.f); Partition> highPtTracks = aod::track::pt > 5.f; @@ -254,45 +259,53 @@ struct FilterTracks { filteredTracksMC(0, 0, 0, 0, 0, 0, 0, 0, 0, 0); } } - void processData(soa::Filtered const& tracks) + void processData(FilterCollisionsWithEvSel::iterator const& collision, soa::Filtered const& tracks) { + float zvtz = collision.posZ(); // dummy to silent compilation error about unused variable if (trackPtSampling == 0) { for (auto& track : tracks) { fillTableData(track); } } else { - for (auto& track : lowPtTracks) { + auto lowPtTracksThisColl = lowPtTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + for (auto& track : lowPtTracksThisColl) { fillTableData(track); } - for (auto& track : midPtTracks) { + auto midPtTracksThisColl = midPtTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + for (auto& track : midPtTracksThisColl) { fillTableData(track); } - for (auto& track : highPtTracks) { + auto highPtTracksThisColl = highPtTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + for (auto& track : highPtTracksThisColl) { fillTableData(track); } } } PROCESS_SWITCH(FilterTracks, processData, "process data", true); - void processCollisions(CollisionsWithEvSel::iterator const& collision) + void processCollisions(FilterCollisionsWithEvSel::iterator const& collision) { filterCollTable(collision.bcId(), collision.posX(), collision.posY(), collision.posZ(), collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ(), collision.flags(), collision.chi2(), collision.numContrib(), collision.collisionTime(), collision.collisionTimeRes()); } PROCESS_SWITCH(FilterTracks, processCollisions, "process collisions", true); - void processMC(soa::Filtered const& tracks, aod::McParticles const& mcParticles) + void processMC(FilterCollisionsWithEvSel::iterator const& collision, soa::Filtered const& tracks, aod::McParticles const& mcParticles) { + float zvtz = collision.posZ(); // dummy to silent compilation error about unused variable if (trackPtSampling == 0) { for (auto& track : tracks) { fillTableDataMC(track, mcParticles); } } else { - for (auto& track : lowPtTracksMC) { + auto lowPtTracksMCThisColl = lowPtTracksMC->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + for (auto& track : lowPtTracksMCThisColl) { fillTableDataMC(track, mcParticles); } - for (auto& track : midPtTracksMC) { + auto midPtTracksMCThisColl = midPtTracksMC->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + for (auto& track : midPtTracksMCThisColl) { fillTableDataMC(track, mcParticles); } - for (auto& track : highPtTracksMC) { + auto highPtTracksMCThisColl = highPtTracksMC->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + for (auto& track : highPtTracksMCThisColl) { fillTableDataMC(track, mcParticles); } } From 35bef7b5f728a7d954e12f99d4a41c97f4294346 Mon Sep 17 00:00:00 2001 From: Andrea Date: Fri, 18 Jul 2025 18:10:14 +0200 Subject: [PATCH 2/8] removal of unused parameter --- DPG/Tasks/ITS/filterTracks.cxx | 2 -- 1 file changed, 2 deletions(-) diff --git a/DPG/Tasks/ITS/filterTracks.cxx b/DPG/Tasks/ITS/filterTracks.cxx index a25b35f8155..9acc835fb15 100644 --- a/DPG/Tasks/ITS/filterTracks.cxx +++ b/DPG/Tasks/ITS/filterTracks.cxx @@ -261,7 +261,6 @@ struct FilterTracks { } void processData(FilterCollisionsWithEvSel::iterator const& collision, soa::Filtered const& tracks) { - float zvtz = collision.posZ(); // dummy to silent compilation error about unused variable if (trackPtSampling == 0) { for (auto& track : tracks) { fillTableData(track); @@ -290,7 +289,6 @@ struct FilterTracks { void processMC(FilterCollisionsWithEvSel::iterator const& collision, soa::Filtered const& tracks, aod::McParticles const& mcParticles) { - float zvtz = collision.posZ(); // dummy to silent compilation error about unused variable if (trackPtSampling == 0) { for (auto& track : tracks) { fillTableDataMC(track, mcParticles); From c9bbc8026cd91ff5ad785f1d04da66ee849e171f Mon Sep 17 00:00:00 2001 From: Andrea Date: Sat, 19 Jul 2025 17:39:54 +0200 Subject: [PATCH 3/8] Dummy commit --- DPG/Tasks/ITS/filterTracks.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DPG/Tasks/ITS/filterTracks.cxx b/DPG/Tasks/ITS/filterTracks.cxx index 9acc835fb15..722f1856051 100644 --- a/DPG/Tasks/ITS/filterTracks.cxx +++ b/DPG/Tasks/ITS/filterTracks.cxx @@ -10,7 +10,7 @@ // or submit itself to any jurisdiction. /// \author Andrea Rossi -/// \brief Simple task to filter tracks and save infos to trees for DCA-related studies (alignment, HF-related issues) +/// \brief Simple task to filter tracks and save infos to trees for DCA-related studies (alignment, HF-related issues, ...) #include "Common/Core/RecoDecay.h" #include "Common/Core/TrackSelection.h" From ce48c8ea40ae2b6ceb259f74c986841078aa54c4 Mon Sep 17 00:00:00 2001 From: Andrea Date: Tue, 22 Jul 2025 10:54:55 +0200 Subject: [PATCH 4/8] making MegaLinter and Linter happier --- DPG/Tasks/ITS/filterTracks.cxx | 143 ++++++++++++++++++--------------- 1 file changed, 78 insertions(+), 65 deletions(-) diff --git a/DPG/Tasks/ITS/filterTracks.cxx b/DPG/Tasks/ITS/filterTracks.cxx index 722f1856051..1f66eb3889d 100644 --- a/DPG/Tasks/ITS/filterTracks.cxx +++ b/DPG/Tasks/ITS/filterTracks.cxx @@ -8,9 +8,11 @@ // In applying this license CERN does not waive the privileges and immunities // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \author Andrea Rossi +/// \file filterTracks.cxx /// \brief Simple task to filter tracks and save infos to trees for DCA-related studies (alignment, HF-related issues, ...) +/// +/// \author Andrea Rossi #include "Common/Core/RecoDecay.h" #include "Common/Core/TrackSelection.h" @@ -25,6 +27,10 @@ #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" +#include + +#include + using namespace o2; using namespace o2::framework; using namespace o2::aod::track; @@ -33,7 +39,7 @@ using namespace o2::framework::expressions; namespace o2::aod { -namespace filterTracks +namespace filtertracks { DECLARE_SOA_INDEX_COLUMN(Collision, collision); //! Collision index @@ -58,7 +64,7 @@ DECLARE_SOA_COLUMN(NsigmaTOFpr, nsigmaTOFpr, float); //! TOF nsigma w.r.t. proto DECLARE_SOA_COLUMN(TpcNCluster, tpcNCluster, int); //! TOF nsigma w.r.t. proton mass hypothesis ///// MC INFO -DECLARE_SOA_COLUMN(MainHfMotherPdgCode, mainMotherPdgCode, int); //! mother pdg code for particles coming from HF, skipping intermediate resonance states. Not trustable when mother is not HF. Not suited for Sc->Lc decays, since Sc are never pointed to +DECLARE_SOA_COLUMN(MainHfMotherPdgCode, mainHfMotherPdgCode, int); //! mother pdg code for particles coming from HF, skipping intermediate resonance states. Not trustable when mother is not HF. Not suited for Sc->Lc decays, since Sc are never pointed to DECLARE_SOA_COLUMN(IsPhysicalPrimary, isPhysicalPrimary, bool); //! is phyiscal primary according to ALICE definition DECLARE_SOA_COLUMN(MainBeautyAncestorPdgCode, mainBeautyAncestorPdgCode, int); //! pdgcode of beauty particle when this is an ancestor, otherwise -1 DECLARE_SOA_COLUMN(MainMotherOrigIndex, mainMotherOrigIndex, int); //! original index in MCParticle tree of main mother: needed when checking if particles come from same mother @@ -69,7 +75,7 @@ DECLARE_SOA_COLUMN(MainMotherY, mainMotherY, float); //! origi DECLARE_SOA_COLUMN(MainBeautyAncestorPt, mainBeautyAncestorPt, float); //! original index in MCParticle tree of main mother: needed when chekcing if particles come from same mother DECLARE_SOA_COLUMN(MainBeautyAncestorY, mainBeautyAncestorY, float); //! original index in MCParticle tree of main mother: needed when chekcing if particles come from same mother DECLARE_SOA_COLUMN(MaxEtaDaughter, maxEtaDaughter, float); //! max (abs) eta of daughter particles, needed to reproduce acceptance cut -} // namespace filterTracks +} // namespace filtertracks DECLARE_SOA_TABLE(FilterColl, "AOD", "FILTERCOLL", o2::aod::collision::BCId, o2::aod::collision::PosX, @@ -88,7 +94,7 @@ DECLARE_SOA_TABLE(FilterColl, "AOD", "FILTERCOLL", o2::aod::collision::CollisionTimeRes); DECLARE_SOA_TABLE(FilterTrack, "AOD", "FILTERTRACK", o2::aod::track::CollisionId, - aod::filterTracks::IsInsideBeamPipe, + aod::filtertracks::IsInsideBeamPipe, o2::aod::track::TrackType, o2::aod::track::X, o2::aod::track::Alpha, @@ -98,43 +104,43 @@ DECLARE_SOA_TABLE(FilterTrack, "AOD", "FILTERTRACK", o2::aod::track::Tgl, o2::aod::track::Signed1Pt); DECLARE_SOA_TABLE(FilterTrackExtr, "AOD", "FILTERTRACKEXTR", - // aod::filterTracks::Px,aod::filterTracks::Py, aod::filterTracks::Pz, - aod::filterTracks::Pt, o2::aod::track::Eta, - o2::aod::filterTracks::Charge, + // aod::filtertracks::Px,aod::filtertracks::Py, aod::filtertracks::Pz, + aod::filtertracks::Pt, o2::aod::track::Eta, + o2::aod::filtertracks::Charge, o2::aod::track::DcaXY, o2::aod::track::DcaZ, o2::aod::track::SigmaDcaXY2, o2::aod::track::SigmaDcaZ2, - aod::filterTracks::NsigmaTPCpi, aod::filterTracks::NsigmaTPCka, aod::filterTracks::NsigmaTPCpr, - aod::filterTracks::NsigmaTOFpi, aod::filterTracks::NsigmaTOFka, aod::filterTracks::NsigmaTOFpr); + aod::filtertracks::NsigmaTPCpi, aod::filtertracks::NsigmaTPCka, aod::filtertracks::NsigmaTPCpr, + aod::filtertracks::NsigmaTOFpi, aod::filtertracks::NsigmaTOFka, aod::filtertracks::NsigmaTOFpr); DECLARE_SOA_TABLE(FiltTracExtDet, "AOD", "FILTTRACEXTDET", o2::aod::track::ITSClusterSizes, o2::aod::track::ITSChi2NCl, o2::aod::track::TPCChi2NCl, - aod::filterTracks::TpcNCluster, + aod::filtertracks::TpcNCluster, o2::aod::track::TrackTime); DECLARE_SOA_TABLE(FilterTrackMC, "AOD", "FILTERTRACKMC", - // aod::filterTracks::Px,aod::filterTracks::Py, aod::filterTracks::Pz, + // aod::filtertracks::Px,aod::filtertracks::Py, aod::filtertracks::Pz, o2::aod::mcparticle::PdgCode, - o2::aod::filterTracks::IsPhysicalPrimary, - o2::aod::filterTracks::MainHfMotherPdgCode, - o2::aod::filterTracks::MainBeautyAncestorPdgCode, - o2::aod::filterTracks::MainMotherOrigIndex, - o2::aod::filterTracks::MainMotherNfinalStateDaught, - o2::aod::filterTracks::MainMotherPt, - o2::aod::filterTracks::MainMotherY, - o2::aod::filterTracks::MainBeautyAncestorPt, - o2::aod::filterTracks::MainBeautyAncestorY); + o2::aod::filtertracks::IsPhysicalPrimary, + o2::aod::filtertracks::MainHfMotherPdgCode, + o2::aod::filtertracks::MainBeautyAncestorPdgCode, + o2::aod::filtertracks::MainMotherOrigIndex, + o2::aod::filtertracks::MainMotherNfinalStateDaught, + o2::aod::filtertracks::MainMotherPt, + o2::aod::filtertracks::MainMotherY, + o2::aod::filtertracks::MainBeautyAncestorPt, + o2::aod::filtertracks::MainBeautyAncestorY); DECLARE_SOA_TABLE(GenParticles, "AOD", "GENPARTICLES", - // aod::filterTracks::Px,aod::filterTracks::Py, aod::filterTracks::Pz, + // aod::filtertracks::Px,aod::filtertracks::Py, aod::filtertracks::Pz, o2::aod::mcparticle::PdgCode, o2::aod::mcparticle::McCollisionId, - o2::aod::filterTracks::MainBeautyAncestorPdgCode, - o2::aod::filterTracks::MainMotherPt, - o2::aod::filterTracks::MainMotherY, - o2::aod::filterTracks::MaxEtaDaughter, - o2::aod::filterTracks::MainBeautyAncestorPt, - o2::aod::filterTracks::MainBeautyAncestorY); + o2::aod::filtertracks::MainBeautyAncestorPdgCode, + o2::aod::filtertracks::MainMotherPt, + o2::aod::filtertracks::MainMotherY, + o2::aod::filtertracks::MaxEtaDaughter, + o2::aod::filtertracks::MainBeautyAncestorPt, + o2::aod::filtertracks::MainBeautyAncestorY); } // namespace o2::aod struct FilterTracks { @@ -162,18 +168,22 @@ struct FilterTracks { using TracksWithSelAndDcaMc = soa::Join; using FilterCollisionsWithEvSel = soa::Filtered; - Partition> lowPtTracks = aod::track::pt < 2.f && (nabs(aod::track::pt * 10000.f - nround(aod::track::pt * 10000.f)) < trackPtWeightLowPt.node() * 2.f); - Partition> midPtTracks = aod::track::pt > 2.f && aod::track::pt < 5.f && (nabs(aod::track::pt * 10000.f - nround(aod::track::pt * 10000.f)) < trackPtWeightMidPt.node() * 2.f); - Partition> highPtTracks = aod::track::pt > 5.f; + float lowPtThreshold = 2.; + float midPtThreshold = 5.; + float nDigitScaleFactor = 10000.; + Partition> lowPtTracks = aod::track::pt < lowPtThreshold && (nabs(aod::track::pt * nDigitScaleFactor - nround(aod::track::pt * nDigitScaleFactor)) < trackPtWeightLowPt.node() * lowPtThreshold); + Partition> midPtTracks = aod::track::pt > lowPtThreshold&& aod::track::pt < midPtThreshold && (nabs(aod::track::pt * nDigitScaleFactor - nround(aod::track::pt * nDigitScaleFactor)) < trackPtWeightMidPt.node() * lowPtThreshold); + Partition> highPtTracks = aod::track::pt > midPtThreshold; - Partition> lowPtTracksMC = aod::track::pt < 2.f && (nabs(aod::track::pt * 10000.f - nround(aod::track::pt * 10000.f)) < trackPtWeightLowPt.node() * 2.f); - Partition> midPtTracksMC = aod::track::pt > 2.f && aod::track::pt < 5.f && (nabs(aod::track::pt * 10000.f - nround(aod::track::pt * 10000.f)) < trackPtWeightMidPt.node() * 2.f); - Partition> highPtTracksMC = aod::track::pt > 5.f; + Partition> lowPtTracksMC = aod::track::pt < lowPtThreshold && (nabs(aod::track::pt * nDigitScaleFactor - nround(aod::track::pt * nDigitScaleFactor)) < trackPtWeightLowPt.node() * lowPtThreshold); + Partition> midPtTracksMC = aod::track::pt > lowPtThreshold&& aod::track::pt < midPtThreshold && (nabs(aod::track::pt * nDigitScaleFactor - nround(aod::track::pt * nDigitScaleFactor)) < trackPtWeightMidPt.node() * lowPtThreshold); + Partition> highPtTracksMC = aod::track::pt > midPtThreshold; - std::array pdgSignalParticleArray = {310, 421, 4122}; // K0s, D0 and Lc - std::array pdgDecayLc = {2212, -321, 211}; - std::array pdgDecayDzero = {-321, 211}; - std::array pdgDecayKzero = {-211, 211}; + const int nStudiedParticlesMc = 3; + std::array pdgSignalParticleArray = {kK0Short, o2::constants::physics::Pdg::kD0, o2::constants::physics::Pdg::kLambdaCPlus}; // K0s, D0 and Lc + std::array pdgDecayLc = {kProton, kKMinus, kPiPlus}; + std::array pdgDecayDzero = {kKMinus, kPiPlus}; + std::array pdgDecayKzero = {kPiMinus, kPiPlus}; void init(InitContext&) { @@ -192,15 +202,15 @@ struct FilterTracks { { fillTableData(track); - bool has_MCparticle = track.has_mcParticle(); - if (has_MCparticle) { + bool has_McParticle = track.has_mcParticle(); + if (has_McParticle) { /// the track is not fake // check whether the particle comes from a charm or beauty hadron and store its index auto mcparticle = track.mcParticle(); int pdgParticleMother = 0; - for (int iSignPart = 0; iSignPart < 3; iSignPart++) { + for (int iSignPart = 0; iSignPart < nStudiedParticlesMc; iSignPart++) { pdgParticleMother = pdgSignalParticleArray[iSignPart]; auto motherIndex = RecoDecay::getMother(mcParticles, mcparticle, pdgParticleMother, true); // check whether mcparticle derives from a particle with pdg = pdgparticlemother, accepting also antiparticle (<- the true parameter) if (motherIndex != -1) { @@ -208,7 +218,7 @@ struct FilterTracks { // just for internal check // double mass=particleMother.e()*particleMother.e()-particleMother.pt()*particleMother.pt()-particleMother.pz()*particleMother.pz(); // filteredTracksMC(mcparticle.pdgCode(),mcparticle.isPhysicalPrimary(),particleMother.pdgCode(),0,motherIndex,0,particleMother.pt(),particleMother.y(),std::sqrt(mass),0); - if (pdgParticleMother == 310) { + if (pdgParticleMother == kK0Short) { auto daughtersSlice = mcparticle.template daughters_as(); int ndaught = daughtersSlice.size(); // might not be accurate in case K0s interact with material before decaying if (ndaught != 2) @@ -220,24 +230,26 @@ struct FilterTracks { int ndaught = 0; std::vector indxDaughers; - if (pdgParticleMother == 421) { + if (pdgParticleMother == o2::constants::physics::Pdg::kD0) { if (RecoDecay::isMatchedMCGen(mcParticles, particleMother, pdgParticleMother, pdgDecayDzero, true, nullptr, 3, &indxDaughers)) { ndaught = 2; // std::cout<<"######## FOUND D0, MATCHED! pdg: " <(mcParticles, particleMother, pdgParticleMother, pdgDecayLc, true, nullptr, 3, &indxDaughers)) { ndaught = 3; - } else + } else { ndaught = -indxDaughers.size(); + } } // now check whether the charm hadron is prompt or comes from beauty decay std::vector idxBhadMothers; if (RecoDecay::getCharmHadronOrigin(mcParticles, particleMother, false, &idxBhadMothers) == RecoDecay::OriginType::NonPrompt) { if (idxBhadMothers.size() > 1) { LOG(info) << "more than 1 B mother hadron found, should not be: "; - for (unsigned long iBhM = 0; iBhM < idxBhadMothers.size(); iBhM++) { + for (int64_t iBhM = 0; iBhM < idxBhadMothers.size(); iBhM++) { auto particleBhadr = mcParticles.rawIteratorAt(idxBhadMothers[iBhM]); LOG(info) << particleBhadr.pdgCode(); } @@ -262,20 +274,20 @@ struct FilterTracks { void processData(FilterCollisionsWithEvSel::iterator const& collision, soa::Filtered const& tracks) { if (trackPtSampling == 0) { - for (auto& track : tracks) { + for (auto const& track : tracks) { fillTableData(track); } } else { auto lowPtTracksThisColl = lowPtTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); - for (auto& track : lowPtTracksThisColl) { + for (auto const& track : lowPtTracksThisColl) { fillTableData(track); } auto midPtTracksThisColl = midPtTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); - for (auto& track : midPtTracksThisColl) { + for (auto const& track : midPtTracksThisColl) { fillTableData(track); } auto highPtTracksThisColl = highPtTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); - for (auto& track : highPtTracksThisColl) { + for (auto const& track : highPtTracksThisColl) { fillTableData(track); } } @@ -290,38 +302,38 @@ struct FilterTracks { void processMC(FilterCollisionsWithEvSel::iterator const& collision, soa::Filtered const& tracks, aod::McParticles const& mcParticles) { if (trackPtSampling == 0) { - for (auto& track : tracks) { + for (auto const& track : tracks) { fillTableDataMC(track, mcParticles); } } else { auto lowPtTracksMCThisColl = lowPtTracksMC->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); - for (auto& track : lowPtTracksMCThisColl) { + for (auto const& track : lowPtTracksMCThisColl) { fillTableDataMC(track, mcParticles); } auto midPtTracksMCThisColl = midPtTracksMC->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); - for (auto& track : midPtTracksMCThisColl) { + for (auto const& track : midPtTracksMCThisColl) { fillTableDataMC(track, mcParticles); } auto highPtTracksMCThisColl = highPtTracksMC->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); - for (auto& track : highPtTracksMCThisColl) { + for (auto const& track : highPtTracksMCThisColl) { fillTableDataMC(track, mcParticles); } } - for (auto& mcpart : mcParticles) { // NOTE THAT OF COURSE IN CASE OF SAMPLING THE GEN TABLE WON'T MATCH THE RECO EVEN CONSIDERING EFFICIENCY + for (auto const& mcpart : mcParticles) { // NOTE THAT OF COURSE IN CASE OF SAMPLING THE GEN TABLE WON'T MATCH THE RECO EVEN CONSIDERING EFFICIENCY int pdgCode = mcpart.pdgCode(); // for(int iSignPart=0;iSignPart<3;iSignPart++){ std::vector indxDaughers; float etamax = 0; bool isMatchedToSignal = false; - if (std::abs(pdgCode) == 310) { - isMatchedToSignal = RecoDecay::isMatchedMCGen(mcParticles, mcpart, 310, pdgDecayKzero, true, nullptr, 1, &indxDaughers); + if (std::abs(pdgCode) == kK0Short) { + isMatchedToSignal = RecoDecay::isMatchedMCGen(mcParticles, mcpart, kK0Short, pdgDecayKzero, true, nullptr, 1, &indxDaughers); } - if (std::abs(pdgCode) == 421) { - isMatchedToSignal = RecoDecay::isMatchedMCGen(mcParticles, mcpart, 421, pdgDecayDzero, true, nullptr, 3, &indxDaughers); - } else if (std::abs(pdgCode) == 4122) { - isMatchedToSignal = RecoDecay::isMatchedMCGen(mcParticles, mcpart, 4122, pdgDecayLc, true, nullptr, 3, &indxDaughers); + if (std::abs(pdgCode) == o2::constants::physics::Pdg::kD0) { + isMatchedToSignal = RecoDecay::isMatchedMCGen(mcParticles, mcpart, o2::constants::physics::Pdg::kD0, pdgDecayDzero, true, nullptr, 3, &indxDaughers); + } else if (std::abs(pdgCode) == o2::constants::physics::Pdg::kLambdaCPlus) { + isMatchedToSignal = RecoDecay::isMatchedMCGen(mcParticles, mcpart, o2::constants::physics::Pdg::kLambdaCPlus, pdgDecayLc, true, nullptr, 3, &indxDaughers); // std::cout<<"Lc found, matched to MC? "<(); @@ -339,7 +351,7 @@ struct FilterTracks { etamax = eta; } } - if (pdgCode == 310) { + if (pdgCode == kK0Short) { selectedGenParticles(mcpart.pdgCode(), mcpart.mcCollisionId(), 0, mcpart.pt(), mcpart.y(), etamax, 0, 0); continue; } @@ -347,7 +359,7 @@ struct FilterTracks { if (RecoDecay::getCharmHadronOrigin(mcParticles, mcpart, false, &idxBhadMothers) == RecoDecay::OriginType::NonPrompt) { if (idxBhadMothers.size() > 1) { LOG(info) << "loop on gen particles: more than 1 B mother hadron found, should not be: "; - for (unsigned long iBhM = 0; iBhM < idxBhadMothers.size(); iBhM++) { + for (int64_t iBhM = 0; iBhM < idxBhadMothers.size(); iBhM++) { auto particleBhadr = mcParticles.rawIteratorAt(idxBhadMothers[iBhM]); LOG(info) << particleBhadr.pdgCode(); } @@ -355,8 +367,9 @@ struct FilterTracks { auto particleBhadr = mcParticles.rawIteratorAt(idxBhadMothers[0]); // int pdgBhad=particleBhadr.pdgCode(); selectedGenParticles(mcpart.pdgCode(), mcpart.mcCollisionId(), particleBhadr.pdgCode(), mcpart.pt(), mcpart.y(), etamax, particleBhadr.pt(), particleBhadr.y()); - } else + } else { selectedGenParticles(mcpart.pdgCode(), mcpart.mcCollisionId(), 0, mcpart.pt(), mcpart.y(), etamax, 0, 0); + } } // } From df8a984e9a35271e8fd10217f728bb981fc29e52 Mon Sep 17 00:00:00 2001 From: Andrea Date: Tue, 22 Jul 2025 11:25:27 +0200 Subject: [PATCH 5/8] another linter fix --- DPG/Tasks/ITS/filterTracks.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DPG/Tasks/ITS/filterTracks.cxx b/DPG/Tasks/ITS/filterTracks.cxx index 1f66eb3889d..79558b095e2 100644 --- a/DPG/Tasks/ITS/filterTracks.cxx +++ b/DPG/Tasks/ITS/filterTracks.cxx @@ -202,8 +202,8 @@ struct FilterTracks { { fillTableData(track); - bool has_McParticle = track.has_mcParticle(); - if (has_McParticle) { + bool hasMcParticle = track.has_mcParticle(); + if (hasMcParticle) { /// the track is not fake // check whether the particle comes from a charm or beauty hadron and store its index From 6d2ccbcf34e0327baf2f425fa47d36b6a7cdb06c Mon Sep 17 00:00:00 2001 From: Andrea Date: Tue, 22 Jul 2025 16:18:37 +0200 Subject: [PATCH 6/8] fix linter and compilation errors due to different data-type comparison --- DPG/Tasks/ITS/filterTracks.cxx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/DPG/Tasks/ITS/filterTracks.cxx b/DPG/Tasks/ITS/filterTracks.cxx index 79558b095e2..7f886cf305a 100644 --- a/DPG/Tasks/ITS/filterTracks.cxx +++ b/DPG/Tasks/ITS/filterTracks.cxx @@ -179,11 +179,12 @@ struct FilterTracks { Partition> midPtTracksMC = aod::track::pt > lowPtThreshold&& aod::track::pt < midPtThreshold && (nabs(aod::track::pt * nDigitScaleFactor - nround(aod::track::pt * nDigitScaleFactor)) < trackPtWeightMidPt.node() * lowPtThreshold); Partition> highPtTracksMC = aod::track::pt > midPtThreshold; - const int nStudiedParticlesMc = 3; - std::array pdgSignalParticleArray = {kK0Short, o2::constants::physics::Pdg::kD0, o2::constants::physics::Pdg::kLambdaCPlus}; // K0s, D0 and Lc + const static int nStudiedParticlesMc = 3; + std::array pdgSignalParticleArray = {kK0Short, o2::constants::physics::Pdg::kD0, o2::constants::physics::Pdg::kLambdaCPlus}; // K0s, D0 and Lc std::array pdgDecayLc = {kProton, kKMinus, kPiPlus}; std::array pdgDecayDzero = {kKMinus, kPiPlus}; std::array pdgDecayKzero = {kPiMinus, kPiPlus}; + const int nK0sShortDaught=2; void init(InitContext&) { @@ -221,7 +222,7 @@ struct FilterTracks { if (pdgParticleMother == kK0Short) { auto daughtersSlice = mcparticle.template daughters_as(); int ndaught = daughtersSlice.size(); // might not be accurate in case K0s interact with material before decaying - if (ndaught != 2) + if (ndaught != nK0sShortDaught) ndaught *= -1; filteredTracksMC(mcparticle.pdgCode(), mcparticle.isPhysicalPrimary(), particleMother.pdgCode(), 0, motherIndex, ndaught, particleMother.pt(), particleMother.y(), 0, 0); // std::cout<<"FOUND K0s, MATCHED! size array "< 1) { LOG(info) << "more than 1 B mother hadron found, should not be: "; - for (int64_t iBhM = 0; iBhM < idxBhadMothers.size(); iBhM++) { + for (uint64_t iBhM = 0; iBhM < idxBhadMothers.size(); iBhM++) { auto particleBhadr = mcParticles.rawIteratorAt(idxBhadMothers[iBhM]); LOG(info) << particleBhadr.pdgCode(); } @@ -344,7 +345,7 @@ struct FilterTracks { // } } if (isMatchedToSignal) { - for (auto mcpartdaughtIdx : indxDaughers) { + for (auto const mcpartdaughtIdx : indxDaughers) { auto mcPartDaught = mcParticles.rawIteratorAt(mcpartdaughtIdx); double eta = std::abs(mcPartDaught.eta()); if ((eta) > etamax) { @@ -359,7 +360,7 @@ struct FilterTracks { if (RecoDecay::getCharmHadronOrigin(mcParticles, mcpart, false, &idxBhadMothers) == RecoDecay::OriginType::NonPrompt) { if (idxBhadMothers.size() > 1) { LOG(info) << "loop on gen particles: more than 1 B mother hadron found, should not be: "; - for (int64_t iBhM = 0; iBhM < idxBhadMothers.size(); iBhM++) { + for (uint64_t iBhM = 0; iBhM < idxBhadMothers.size(); iBhM++) { auto particleBhadr = mcParticles.rawIteratorAt(idxBhadMothers[iBhM]); LOG(info) << particleBhadr.pdgCode(); } From b770a01d974eae35fce5d0fe7dc184d48ce11a27 Mon Sep 17 00:00:00 2001 From: Andrea Date: Tue, 22 Jul 2025 16:22:20 +0200 Subject: [PATCH 7/8] clang format... --- DPG/Tasks/ITS/filterTracks.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DPG/Tasks/ITS/filterTracks.cxx b/DPG/Tasks/ITS/filterTracks.cxx index 7f886cf305a..a1167f4c570 100644 --- a/DPG/Tasks/ITS/filterTracks.cxx +++ b/DPG/Tasks/ITS/filterTracks.cxx @@ -184,7 +184,7 @@ struct FilterTracks { std::array pdgDecayLc = {kProton, kKMinus, kPiPlus}; std::array pdgDecayDzero = {kKMinus, kPiPlus}; std::array pdgDecayKzero = {kPiMinus, kPiPlus}; - const int nK0sShortDaught=2; + const int nK0sShortDaught = 2; void init(InitContext&) { From cf2d5edbfbf4cb6eabfd3baaec8366ae85af1230 Mon Sep 17 00:00:00 2001 From: Andrea Date: Tue, 22 Jul 2025 17:04:07 +0200 Subject: [PATCH 8/8] linter and megalinter fixes --- DPG/Tasks/ITS/filterTracks.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DPG/Tasks/ITS/filterTracks.cxx b/DPG/Tasks/ITS/filterTracks.cxx index a1167f4c570..0a535e1607b 100644 --- a/DPG/Tasks/ITS/filterTracks.cxx +++ b/DPG/Tasks/ITS/filterTracks.cxx @@ -144,6 +144,7 @@ DECLARE_SOA_TABLE(GenParticles, "AOD", "GENPARTICLES", } // namespace o2::aod struct FilterTracks { + const static int nStudiedParticlesMc = 3; Produces filteredTracksTableExtra; Produces filteredTracksTable; @@ -179,7 +180,6 @@ struct FilterTracks { Partition> midPtTracksMC = aod::track::pt > lowPtThreshold&& aod::track::pt < midPtThreshold && (nabs(aod::track::pt * nDigitScaleFactor - nround(aod::track::pt * nDigitScaleFactor)) < trackPtWeightMidPt.node() * lowPtThreshold); Partition> highPtTracksMC = aod::track::pt > midPtThreshold; - const static int nStudiedParticlesMc = 3; std::array pdgSignalParticleArray = {kK0Short, o2::constants::physics::Pdg::kD0, o2::constants::physics::Pdg::kLambdaCPlus}; // K0s, D0 and Lc std::array pdgDecayLc = {kProton, kKMinus, kPiPlus}; std::array pdgDecayDzero = {kKMinus, kPiPlus}; @@ -345,7 +345,7 @@ struct FilterTracks { // } } if (isMatchedToSignal) { - for (auto const mcpartdaughtIdx : indxDaughers) { + for (auto const& mcpartdaughtIdx : indxDaughers) { auto mcPartDaught = mcParticles.rawIteratorAt(mcpartdaughtIdx); double eta = std::abs(mcPartDaught.eta()); if ((eta) > etamax) {