From bff27c7d38e3ab710f1404639f280c6f28813e2b Mon Sep 17 00:00:00 2001 From: Nima Zardoshti Date: Wed, 1 Nov 2023 14:30:46 +0100 Subject: [PATCH] PWGJE: fixing remaning calls to Mass in PDG --- PWGJE/TableProducer/jetfinder.cxx | 12 ++++++------ PWGJE/TableProducer/jetfinder.h | 17 ++++++++-------- PWGJE/TableProducer/jetfinderhf.cxx | 20 +++++++++---------- PWGJE/Tasks/jetfinderQA.cxx | 3 +-- PWGJE/Tasks/jetfinderhfQA.cxx | 30 +++++++++++++++++++---------- 5 files changed, 45 insertions(+), 37 deletions(-) diff --git a/PWGJE/TableProducer/jetfinder.cxx b/PWGJE/TableProducer/jetfinder.cxx index 77d3326c60a..4e08b2dddf4 100644 --- a/PWGJE/TableProducer/jetfinder.cxx +++ b/PWGJE/TableProducer/jetfinder.cxx @@ -14,13 +14,13 @@ // Author: Jochen Klein, Nima Zardoshti, Raymond Ehlers #include "PWGJE/TableProducer/jetfinder.h" +#include "Framework/runDataProcessing.h" using namespace o2; +using namespace o2::analysis; using namespace o2::framework; using namespace o2::framework::expressions; -#include "Framework/runDataProcessing.h" - template struct JetFinderTask { Produces jetsTable; @@ -66,7 +66,7 @@ struct JetFinderTask { Configurable DoRhoAreaSub{"DoRhoAreaSub", false, "do rho area subtraction"}; Configurable DoConstSub{"DoConstSub", false, "do constituent subtraction"}; - Service pdg; + Service pdgDatabase; std::string trackSelection; std::string eventSelection; std::string particleSelection; @@ -159,7 +159,7 @@ struct JetFinderTask { void processParticleLevelChargedJets(aod::McCollision const& collision, soa::Filtered const& particles) { // TODO: MC event selection? - analyseParticles, soa::Filtered::iterator>(inputParticles, particleSelection, 1, particles, pdg->Instance()); + analyseParticles, soa::Filtered::iterator>(inputParticles, particleSelection, 1, particles, pdgDatabase); findJets(jetFinder, inputParticles, jetRadius, collision, jetsTable, constituentsTable, constituentsSubTable, DoConstSub); } PROCESS_SWITCH(JetFinderTask, processParticleLevelChargedJets, "Particle level charged jet finding", false); @@ -167,7 +167,7 @@ struct JetFinderTask { void processParticleLevelNeutralJets(aod::McCollision const& collision, soa::Filtered const& particles) { // TODO: MC event selection? - analyseParticles, soa::Filtered::iterator>(inputParticles, particleSelection, 2, particles, pdg->Instance()); + analyseParticles, soa::Filtered::iterator>(inputParticles, particleSelection, 2, particles, pdgDatabase); findJets(jetFinder, inputParticles, jetRadius, collision, jetsTable, constituentsTable, constituentsSubTable, DoConstSub); } PROCESS_SWITCH(JetFinderTask, processParticleLevelNeutralJets, "Particle level neutral jet finding", false); @@ -175,7 +175,7 @@ struct JetFinderTask { void processParticleLevelFullJets(aod::McCollision const& collision, soa::Filtered const& particles) { // TODO: MC event selection? - analyseParticles, soa::Filtered::iterator>(inputParticles, particleSelection, 0, particles, pdg->Instance()); + analyseParticles, soa::Filtered::iterator>(inputParticles, particleSelection, 0, particles, pdgDatabase); findJets(jetFinder, inputParticles, jetRadius, collision, jetsTable, constituentsTable, constituentsSubTable, DoConstSub); } diff --git a/PWGJE/TableProducer/jetfinder.h b/PWGJE/TableProducer/jetfinder.h index 0646e043a12..ba676b2d115 100644 --- a/PWGJE/TableProducer/jetfinder.h +++ b/PWGJE/TableProducer/jetfinder.h @@ -24,18 +24,17 @@ #include "Framework/AnalysisDataModel.h" #include "Framework/ASoA.h" #include "Framework/O2DatabasePDGPlugin.h" -#include "TDatabasePDG.h" #include "Common/Core/TrackSelection.h" #include "Common/Core/TrackSelectionDefaults.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/TrackSelectionTables.h" -#include "Common/Core/RecoDecay.h" // FIXME: Remove RecoDecay::getMassPDG #include "PWGJE/DataModel/EMCALClusters.h" #include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/Core/PDG.h" #include "PWGJE/Core/FastJetUtilities.h" #include "PWGJE/Core/JetFinder.h" @@ -118,26 +117,26 @@ void analyseClusters(std::vector& inputParticles, T const& c // function that takes any generic candidate, performs selections and adds the candidate to the fastjet list template -bool analyseCandidate(std::vector& inputParticles, int candPDG, float candPtMin, float candPtMax, float candYMin, float candYMax, T const& candidate) +bool analyseCandidate(std::vector& inputParticles, int candMass, float candPtMin, float candPtMax, float candYMin, float candYMax, T const& candidate) { - if (candidate.y(RecoDecay::getMassPDG(candPDG)) < candYMin || candidate.y(RecoDecay::getMassPDG(candPDG)) > candYMax) { // FIXME: Remove RecoDecay::getMassPDG + if (candidate.y(candMass) < candYMin || candidate.y(candMass) > candYMax) { return false; } if (candidate.pt() < candPtMin || candidate.pt() >= candPtMax) { return false; } - FastJetUtilities::fillTracks(candidate, inputParticles, candidate.globalIndex(), static_cast(JetConstituentStatus::candidateHF), RecoDecay::getMassPDG(candPDG)); // FIXME: Remove RecoDecay::getMassPDG + FastJetUtilities::fillTracks(candidate, inputParticles, candidate.globalIndex(), static_cast(JetConstituentStatus::candidateHF), candMass); return true; } // function that checks the MC status of a candidate and then calls the function to analyseCandidates template -bool analyseCandidateMC(std::vector& inputParticles, int candPDG, int candDecay, float candPtMin, float candPtMax, float candYMin, float candYMax, T const& candidate, bool rejectBackgroundMCCandidates) +bool analyseCandidateMC(std::vector& inputParticles, int candMass, int candDecay, float candPtMin, float candPtMax, float candYMin, float candYMax, T const& candidate, bool rejectBackgroundMCCandidates) { if (rejectBackgroundMCCandidates && !(std::abs(candidate.flagMcMatchRec()) == 1 << candDecay)) { return false; } - return analyseCandidate(inputParticles, candPDG, candPtMin, candPtMax, candYMin, candYMax, candidate); + return analyseCandidate(inputParticles, candMass, candPtMin, candPtMax, candYMin, candYMax, candidate); } // function that calls the jet finding and fills the relevant tables @@ -207,7 +206,7 @@ bool checkDaughters(T const& particle, int globalIndex) } template -void analyseParticles(std::vector& inputParticles, std::string particleSelection, int jetTypeParticleLevel, T const& particles, TDatabasePDG* pdg, std::optional const& candidate = std::nullopt) +void analyseParticles(std::vector& inputParticles, std::string particleSelection, int jetTypeParticleLevel, T const& particles, o2::framework::Service pdgDatabase, std::optional const& candidate = std::nullopt) { inputParticles.clear(); for (auto& particle : particles) { @@ -220,7 +219,7 @@ void analyseParticles(std::vector& inputParticles, std::stri } else if (particleSelection == "PhysicalPrimaryAndHepMCStatus" && (!particle.isPhysicalPrimary() || particle.getHepMCStatusCode() != 1)) { continue; } - auto pdgParticle = pdg->GetParticle(particle.pdgCode()); + auto pdgParticle = pdgDatabase->GetParticle(particle.pdgCode()); auto pdgCharge = pdgParticle ? std::abs(pdgParticle->Charge()) : -1.0; if (jetTypeParticleLevel == static_cast(JetType::charged) && pdgCharge < 3.0) { continue; diff --git a/PWGJE/TableProducer/jetfinderhf.cxx b/PWGJE/TableProducer/jetfinderhf.cxx index ea7e6274269..98fb080473a 100644 --- a/PWGJE/TableProducer/jetfinderhf.cxx +++ b/PWGJE/TableProducer/jetfinderhf.cxx @@ -94,7 +94,7 @@ struct JetFinderHFTask { Configurable DoRhoAreaSub{"DoRhoAreaSub", false, "do rho area subtraction"}; Configurable DoConstSub{"DoConstSub", false, "do constituent subtraction"}; - Service pdg; + Service pdgDatabase; std::string trackSelection; std::string eventSelection; std::string particleSelection; @@ -102,8 +102,8 @@ struct JetFinderHFTask { JetFinder jetFinder; std::vector inputParticles; - int candPDG; int candDecay; + double candMass; void init(InitContext const&) { @@ -133,15 +133,15 @@ struct JetFinderHFTask { jetFinder.ghostRepeatN = ghostRepeat; if constexpr (std::is_same_v, CandidatesD0Data>) { // Note : need to be careful if configurable workflow options are added later - candPDG = static_cast(pdg::Code::kD0); + candMass = pdg::MassD0; candDecay = static_cast(aod::hf_cand_2prong::DecayType::D0ToPiK); } if constexpr (std::is_same_v, CandidatesBplusData>) { - candPDG = static_cast(pdg::Code::kBPlus); + candMass = pdg::MassBPlus; candDecay = static_cast(aod::hf_cand_bplus::DecayType::BplusToD0Pi); } if constexpr (std::is_same_v, CandidatesLcData>) { - candPDG = static_cast(pdg::Code::kLambdaCPlus); + candMass = pdg::MassLambdaCPlus; candDecay = static_cast(aod::hf_cand_3prong::DecayType::LcToPKPi); } } @@ -166,7 +166,7 @@ struct JetFinderHFTask { for (auto& candidate : candidates) { inputParticles.clear(); - if (!analyseCandidate(inputParticles, candPDG, candPtMin, candPtMax, candYMin, candYMax, candidate)) { + if (!analyseCandidate(inputParticles, candMass, candPtMin, candPtMax, candYMin, candYMax, candidate)) { continue; } analyseTracks(inputParticles, tracks, trackSelection, std::optional{candidate}); @@ -184,7 +184,7 @@ struct JetFinderHFTask { for (auto& candidate : candidates) { inputParticles.clear(); - if (!analyseCandidateMC(inputParticles, candPDG, candDecay, candPtMin, candPtMax, candYMin, candYMax, candidate, rejectBackgroundMCCandidates)) { + if (!analyseCandidateMC(inputParticles, candMass, candDecay, candPtMin, candPtMax, candYMin, candYMax, candidate, rejectBackgroundMCCandidates)) { continue; } analyseTracks(inputParticles, tracks, trackSelection, std::optional{candidate}); @@ -202,7 +202,7 @@ struct JetFinderHFTask { for (auto const& particle : particles) { if (std::abs(particle.flagMcMatchGen()) & (1 << candDecay)) { - auto particleY = RecoDecay::y(std::array{particle.px(), particle.py(), particle.pz()}, pdg->Mass(particle.pdgCode())); + auto particleY = RecoDecay::y(std::array{particle.px(), particle.py(), particle.pz()}, pdgDatabase->Mass(particle.pdgCode())); if (particleY < candYMin || particleY > candYMax) { continue; } @@ -213,8 +213,8 @@ struct JetFinderHFTask { } } for (auto& candidate : candidates) { - analyseParticles(inputParticles, particleSelection, jetTypeParticleLevel, particles, pdg->Instance(), std::optional{candidate}); - FastJetUtilities::fillTracks(candidate, inputParticles, candidate.globalIndex(), static_cast(JetConstituentStatus::candidateHF), pdg->Mass(candidate.pdgCode())); + analyseParticles(inputParticles, particleSelection, jetTypeParticleLevel, particles, pdgDatabase, std::optional{candidate}); + FastJetUtilities::fillTracks(candidate, inputParticles, candidate.globalIndex(), static_cast(JetConstituentStatus::candidateHF), pdgDatabase->Mass(candidate.pdgCode())); findJets(jetFinder, inputParticles, jetRadius, collision, jetsTable, constituentsTable, constituentsSubTable, DoConstSub, true); } } diff --git a/PWGJE/Tasks/jetfinderQA.cxx b/PWGJE/Tasks/jetfinderQA.cxx index f27fb89752f..bb9d8a5a65e 100644 --- a/PWGJE/Tasks/jetfinderQA.cxx +++ b/PWGJE/Tasks/jetfinderQA.cxx @@ -18,6 +18,7 @@ #include "Framework/AnalysisTask.h" #include "Framework/O2DatabasePDGPlugin.h" #include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" #include "Common/Core/TrackSelection.h" #include "Common/Core/TrackSelectionDefaults.h" @@ -34,8 +35,6 @@ using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -#include "Framework/runDataProcessing.h" - struct JetFinderQATask { HistogramRegistry registry; diff --git a/PWGJE/Tasks/jetfinderhfQA.cxx b/PWGJE/Tasks/jetfinderhfQA.cxx index d1e14f1b197..7370d73bc19 100644 --- a/PWGJE/Tasks/jetfinderhfQA.cxx +++ b/PWGJE/Tasks/jetfinderhfQA.cxx @@ -16,31 +16,28 @@ #include "Framework/ASoA.h" #include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" -#include "Framework/O2DatabasePDGPlugin.h" #include "Framework/HistogramRegistry.h" -#include "TDatabasePDG.h" +#include "Framework/runDataProcessing.h" #include "Common/Core/TrackSelection.h" #include "Common/Core/TrackSelectionDefaults.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/TrackSelectionTables.h" -#include "PWGHF/Core/PDG.h" - #include "PWGHF/Core/HfHelper.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/Core/PDG.h" #include "PWGJE/DataModel/Jet.h" #include "EventFiltering/filterTables.h" using namespace o2; +using namespace o2::analysis; using namespace o2::framework; using namespace o2::framework::expressions; -#include "Framework/runDataProcessing.h" - template struct JetFinderHFQATask { HistogramRegistry registry; @@ -64,8 +61,21 @@ struct JetFinderHFQATask { std::vector filledJetR; std::vector jetRadiiValues; + double candMass; + void init(o2::framework::InitContext&) { + + if constexpr (std::is_same_v, soa::Join>) { // Note : need to be careful if configurable workflow options are added later + candMass = pdg::MassD0; + } + if constexpr (std::is_same_v, soa::Join>) { + candMass = pdg::MassLambdaCPlus; + } + if constexpr (std::is_same_v, soa::Join>) { + candMass = pdg::MassBPlus; + } + trackSelection = static_cast(trackSelections); jetRadiiValues = (std::vector)jetRadii; @@ -237,7 +247,7 @@ struct JetFinderHFQATask { registry.fill(HIST("h3_jet_r_jet_pt_candidate_pt"), jet.r() / 100.0, jet.pt(), hfcandidate.pt(), weight); registry.fill(HIST("h3_jet_r_jet_pt_candidate_eta"), jet.r() / 100.0, jet.pt(), hfcandidate.eta(), weight); registry.fill(HIST("h3_jet_r_jet_pt_candidate_phi"), jet.r() / 100.0, jet.pt(), hfcandidate.phi(), weight); - registry.fill(HIST("h3_jet_r_jet_pt_candidate_y"), jet.r() / 100.0, jet.pt(), hfcandidate.y(o2::analysis::pdg::MassD0), weight); + registry.fill(HIST("h3_jet_r_jet_pt_candidate_y"), jet.r() / 100.0, jet.pt(), hfcandidate.y(candMass), weight); if (jet.r() == round(selectedJetsRadius * 100.0f)) { if constexpr (std::is_same_v, soa::Join> || std::is_same_v, soa::Join>) { @@ -322,7 +332,7 @@ struct JetFinderHFQATask { mcdCandPt = hfcandidate_mcd.pt(); mcdCandPhi = hfcandidate_mcd.phi(); mcdCandEta = hfcandidate_mcd.eta(); - mcdCandY = hfcandidate_mcd.y(o2::analysis::pdg::MassD0); + mcdCandY = hfcandidate_mcd.y(candMass); } for (auto& hfcandidate_mcp : mcpjet.template hfcandidates_as>()) { @@ -474,12 +484,12 @@ struct JetFinderHFQATask { registry.fill(HIST("h3_jet_r_jet_pt_candidate_pt_MB"), jet.r() / 100.0, jet.pt(), hfcandidate.pt()); registry.fill(HIST("h3_jet_r_jet_pt_candidate_eta_MB"), jet.r() / 100.0, jet.pt(), hfcandidate.eta()); registry.fill(HIST("h3_jet_r_jet_pt_candidate_phi_MB"), jet.r() / 100.0, jet.pt(), hfcandidate.phi()); - registry.fill(HIST("h3_jet_r_jet_pt_candidate_y_MB"), jet.r() / 100.0, jet.pt(), hfcandidate.y(o2::analysis::pdg::MassD0)); + registry.fill(HIST("h3_jet_r_jet_pt_candidate_y_MB"), jet.r() / 100.0, jet.pt(), hfcandidate.y(candMass)); if (collision.hasJetChHighPt() >= 1) { registry.fill(HIST("h3_jet_r_jet_pt_candidate_pt_Triggered"), jet.r() / 100.0, jet.pt(), hfcandidate.pt()); registry.fill(HIST("h3_jet_r_jet_pt_candidate_eta_Triggered"), jet.r() / 100.0, jet.pt(), hfcandidate.eta()); registry.fill(HIST("h3_jet_r_jet_pt_candidate_phi_Triggered"), jet.r() / 100.0, jet.pt(), hfcandidate.phi()); - registry.fill(HIST("h3_jet_r_jet_pt_candidate_y_Triggered"), jet.r() / 100.0, jet.pt(), hfcandidate.y(o2::analysis::pdg::MassD0)); + registry.fill(HIST("h3_jet_r_jet_pt_candidate_y_Triggered"), jet.r() / 100.0, jet.pt(), hfcandidate.y(candMass)); } } }