Skip to content

Commit 1ed492c

Browse files
nzardoshNima Zardoshti
andauthored
PWGJE: fixing remaning calls to Mass in PDG (#3748)
Co-authored-by: Nima Zardoshti <nzardosh@alicecerno2.cern.ch>
1 parent f9f3242 commit 1ed492c

5 files changed

Lines changed: 45 additions & 37 deletions

File tree

PWGJE/TableProducer/jetfinder.cxx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
// Author: Jochen Klein, Nima Zardoshti, Raymond Ehlers
1515

1616
#include "PWGJE/TableProducer/jetfinder.h"
17+
#include "Framework/runDataProcessing.h"
1718

1819
using namespace o2;
20+
using namespace o2::analysis;
1921
using namespace o2::framework;
2022
using namespace o2::framework::expressions;
2123

22-
#include "Framework/runDataProcessing.h"
23-
2424
template <typename JetTable, typename ConstituentTable, typename ConstituentSubTable>
2525
struct JetFinderTask {
2626
Produces<JetTable> jetsTable;
@@ -66,7 +66,7 @@ struct JetFinderTask {
6666
Configurable<bool> DoRhoAreaSub{"DoRhoAreaSub", false, "do rho area subtraction"};
6767
Configurable<bool> DoConstSub{"DoConstSub", false, "do constituent subtraction"};
6868

69-
Service<o2::framework::O2DatabasePDG> pdg;
69+
Service<o2::framework::O2DatabasePDG> pdgDatabase;
7070
std::string trackSelection;
7171
std::string eventSelection;
7272
std::string particleSelection;
@@ -159,23 +159,23 @@ struct JetFinderTask {
159159
void processParticleLevelChargedJets(aod::McCollision const& collision, soa::Filtered<aod::McParticles> const& particles)
160160
{
161161
// TODO: MC event selection?
162-
analyseParticles<soa::Filtered<aod::McParticles>, soa::Filtered<aod::McParticles>::iterator>(inputParticles, particleSelection, 1, particles, pdg->Instance());
162+
analyseParticles<soa::Filtered<aod::McParticles>, soa::Filtered<aod::McParticles>::iterator>(inputParticles, particleSelection, 1, particles, pdgDatabase);
163163
findJets(jetFinder, inputParticles, jetRadius, collision, jetsTable, constituentsTable, constituentsSubTable, DoConstSub);
164164
}
165165
PROCESS_SWITCH(JetFinderTask, processParticleLevelChargedJets, "Particle level charged jet finding", false);
166166

167167
void processParticleLevelNeutralJets(aod::McCollision const& collision, soa::Filtered<aod::McParticles> const& particles)
168168
{
169169
// TODO: MC event selection?
170-
analyseParticles<soa::Filtered<aod::McParticles>, soa::Filtered<aod::McParticles>::iterator>(inputParticles, particleSelection, 2, particles, pdg->Instance());
170+
analyseParticles<soa::Filtered<aod::McParticles>, soa::Filtered<aod::McParticles>::iterator>(inputParticles, particleSelection, 2, particles, pdgDatabase);
171171
findJets(jetFinder, inputParticles, jetRadius, collision, jetsTable, constituentsTable, constituentsSubTable, DoConstSub);
172172
}
173173
PROCESS_SWITCH(JetFinderTask, processParticleLevelNeutralJets, "Particle level neutral jet finding", false);
174174

175175
void processParticleLevelFullJets(aod::McCollision const& collision, soa::Filtered<aod::McParticles> const& particles)
176176
{
177177
// TODO: MC event selection?
178-
analyseParticles<soa::Filtered<aod::McParticles>, soa::Filtered<aod::McParticles>::iterator>(inputParticles, particleSelection, 0, particles, pdg->Instance());
178+
analyseParticles<soa::Filtered<aod::McParticles>, soa::Filtered<aod::McParticles>::iterator>(inputParticles, particleSelection, 0, particles, pdgDatabase);
179179
findJets(jetFinder, inputParticles, jetRadius, collision, jetsTable, constituentsTable, constituentsSubTable, DoConstSub);
180180
}
181181

PWGJE/TableProducer/jetfinder.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,17 @@
2424
#include "Framework/AnalysisDataModel.h"
2525
#include "Framework/ASoA.h"
2626
#include "Framework/O2DatabasePDGPlugin.h"
27-
#include "TDatabasePDG.h"
2827

2928
#include "Common/Core/TrackSelection.h"
3029
#include "Common/Core/TrackSelectionDefaults.h"
3130
#include "Common/DataModel/EventSelection.h"
3231
#include "Common/DataModel/TrackSelectionTables.h"
33-
#include "Common/Core/RecoDecay.h" // FIXME: Remove RecoDecay::getMassPDG
3432
#include "PWGJE/DataModel/EMCALClusters.h"
3533

3634
#include "PWGHF/Core/SelectorCuts.h"
3735
#include "PWGHF/DataModel/CandidateReconstructionTables.h"
3836
#include "PWGHF/DataModel/CandidateSelectionTables.h"
37+
#include "PWGHF/Core/PDG.h"
3938

4039
#include "PWGJE/Core/FastJetUtilities.h"
4140
#include "PWGJE/Core/JetFinder.h"
@@ -118,26 +117,26 @@ void analyseClusters(std::vector<fastjet::PseudoJet>& inputParticles, T const& c
118117

119118
// function that takes any generic candidate, performs selections and adds the candidate to the fastjet list
120119
template <typename T>
121-
bool analyseCandidate(std::vector<fastjet::PseudoJet>& inputParticles, int candPDG, float candPtMin, float candPtMax, float candYMin, float candYMax, T const& candidate)
120+
bool analyseCandidate(std::vector<fastjet::PseudoJet>& inputParticles, int candMass, float candPtMin, float candPtMax, float candYMin, float candYMax, T const& candidate)
122121
{
123-
if (candidate.y(RecoDecay::getMassPDG(candPDG)) < candYMin || candidate.y(RecoDecay::getMassPDG(candPDG)) > candYMax) { // FIXME: Remove RecoDecay::getMassPDG
122+
if (candidate.y(candMass) < candYMin || candidate.y(candMass) > candYMax) {
124123
return false;
125124
}
126125
if (candidate.pt() < candPtMin || candidate.pt() >= candPtMax) {
127126
return false;
128127
}
129-
FastJetUtilities::fillTracks(candidate, inputParticles, candidate.globalIndex(), static_cast<int>(JetConstituentStatus::candidateHF), RecoDecay::getMassPDG(candPDG)); // FIXME: Remove RecoDecay::getMassPDG
128+
FastJetUtilities::fillTracks(candidate, inputParticles, candidate.globalIndex(), static_cast<int>(JetConstituentStatus::candidateHF), candMass);
130129
return true;
131130
}
132131

133132
// function that checks the MC status of a candidate and then calls the function to analyseCandidates
134133
template <typename T>
135-
bool analyseCandidateMC(std::vector<fastjet::PseudoJet>& inputParticles, int candPDG, int candDecay, float candPtMin, float candPtMax, float candYMin, float candYMax, T const& candidate, bool rejectBackgroundMCCandidates)
134+
bool analyseCandidateMC(std::vector<fastjet::PseudoJet>& inputParticles, int candMass, int candDecay, float candPtMin, float candPtMax, float candYMin, float candYMax, T const& candidate, bool rejectBackgroundMCCandidates)
136135
{
137136
if (rejectBackgroundMCCandidates && !(std::abs(candidate.flagMcMatchRec()) == 1 << candDecay)) {
138137
return false;
139138
}
140-
return analyseCandidate(inputParticles, candPDG, candPtMin, candPtMax, candYMin, candYMax, candidate);
139+
return analyseCandidate(inputParticles, candMass, candPtMin, candPtMax, candYMin, candYMax, candidate);
141140
}
142141

143142
// function that calls the jet finding and fills the relevant tables
@@ -207,7 +206,7 @@ bool checkDaughters(T const& particle, int globalIndex)
207206
}
208207

209208
template <typename T, typename U>
210-
void analyseParticles(std::vector<fastjet::PseudoJet>& inputParticles, std::string particleSelection, int jetTypeParticleLevel, T const& particles, TDatabasePDG* pdg, std::optional<U> const& candidate = std::nullopt)
209+
void analyseParticles(std::vector<fastjet::PseudoJet>& inputParticles, std::string particleSelection, int jetTypeParticleLevel, T const& particles, o2::framework::Service<o2::framework::O2DatabasePDG> pdgDatabase, std::optional<U> const& candidate = std::nullopt)
211210
{
212211
inputParticles.clear();
213212
for (auto& particle : particles) {
@@ -220,7 +219,7 @@ void analyseParticles(std::vector<fastjet::PseudoJet>& inputParticles, std::stri
220219
} else if (particleSelection == "PhysicalPrimaryAndHepMCStatus" && (!particle.isPhysicalPrimary() || particle.getHepMCStatusCode() != 1)) {
221220
continue;
222221
}
223-
auto pdgParticle = pdg->GetParticle(particle.pdgCode());
222+
auto pdgParticle = pdgDatabase->GetParticle(particle.pdgCode());
224223
auto pdgCharge = pdgParticle ? std::abs(pdgParticle->Charge()) : -1.0;
225224
if (jetTypeParticleLevel == static_cast<int>(JetType::charged) && pdgCharge < 3.0) {
226225
continue;

PWGJE/TableProducer/jetfinderhf.cxx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,16 @@ struct JetFinderHFTask {
9494
Configurable<bool> DoRhoAreaSub{"DoRhoAreaSub", false, "do rho area subtraction"};
9595
Configurable<bool> DoConstSub{"DoConstSub", false, "do constituent subtraction"};
9696

97-
Service<o2::framework::O2DatabasePDG> pdg;
97+
Service<o2::framework::O2DatabasePDG> pdgDatabase;
9898
std::string trackSelection;
9999
std::string eventSelection;
100100
std::string particleSelection;
101101

102102
JetFinder jetFinder;
103103
std::vector<fastjet::PseudoJet> inputParticles;
104104

105-
int candPDG;
106105
int candDecay;
106+
double candMass;
107107

108108
void init(InitContext const&)
109109
{
@@ -133,15 +133,15 @@ struct JetFinderHFTask {
133133
jetFinder.ghostRepeatN = ghostRepeat;
134134

135135
if constexpr (std::is_same_v<std::decay_t<CandidateTableData>, CandidatesD0Data>) { // Note : need to be careful if configurable workflow options are added later
136-
candPDG = static_cast<int>(pdg::Code::kD0);
136+
candMass = pdg::MassD0;
137137
candDecay = static_cast<int>(aod::hf_cand_2prong::DecayType::D0ToPiK);
138138
}
139139
if constexpr (std::is_same_v<std::decay_t<CandidateTableData>, CandidatesBplusData>) {
140-
candPDG = static_cast<int>(pdg::Code::kBPlus);
140+
candMass = pdg::MassBPlus;
141141
candDecay = static_cast<int>(aod::hf_cand_bplus::DecayType::BplusToD0Pi);
142142
}
143143
if constexpr (std::is_same_v<std::decay_t<CandidateTableData>, CandidatesLcData>) {
144-
candPDG = static_cast<int>(pdg::Code::kLambdaCPlus);
144+
candMass = pdg::MassLambdaCPlus;
145145
candDecay = static_cast<int>(aod::hf_cand_3prong::DecayType::LcToPKPi);
146146
}
147147
}
@@ -166,7 +166,7 @@ struct JetFinderHFTask {
166166

167167
for (auto& candidate : candidates) {
168168
inputParticles.clear();
169-
if (!analyseCandidate(inputParticles, candPDG, candPtMin, candPtMax, candYMin, candYMax, candidate)) {
169+
if (!analyseCandidate(inputParticles, candMass, candPtMin, candPtMax, candYMin, candYMax, candidate)) {
170170
continue;
171171
}
172172
analyseTracks(inputParticles, tracks, trackSelection, std::optional{candidate});
@@ -184,7 +184,7 @@ struct JetFinderHFTask {
184184

185185
for (auto& candidate : candidates) {
186186
inputParticles.clear();
187-
if (!analyseCandidateMC(inputParticles, candPDG, candDecay, candPtMin, candPtMax, candYMin, candYMax, candidate, rejectBackgroundMCCandidates)) {
187+
if (!analyseCandidateMC(inputParticles, candMass, candDecay, candPtMin, candPtMax, candYMin, candYMax, candidate, rejectBackgroundMCCandidates)) {
188188
continue;
189189
}
190190
analyseTracks(inputParticles, tracks, trackSelection, std::optional{candidate});
@@ -202,7 +202,7 @@ struct JetFinderHFTask {
202202

203203
for (auto const& particle : particles) {
204204
if (std::abs(particle.flagMcMatchGen()) & (1 << candDecay)) {
205-
auto particleY = RecoDecay::y(std::array{particle.px(), particle.py(), particle.pz()}, pdg->Mass(particle.pdgCode()));
205+
auto particleY = RecoDecay::y(std::array{particle.px(), particle.py(), particle.pz()}, pdgDatabase->Mass(particle.pdgCode()));
206206
if (particleY < candYMin || particleY > candYMax) {
207207
continue;
208208
}
@@ -213,8 +213,8 @@ struct JetFinderHFTask {
213213
}
214214
}
215215
for (auto& candidate : candidates) {
216-
analyseParticles(inputParticles, particleSelection, jetTypeParticleLevel, particles, pdg->Instance(), std::optional{candidate});
217-
FastJetUtilities::fillTracks(candidate, inputParticles, candidate.globalIndex(), static_cast<int>(JetConstituentStatus::candidateHF), pdg->Mass(candidate.pdgCode()));
216+
analyseParticles(inputParticles, particleSelection, jetTypeParticleLevel, particles, pdgDatabase, std::optional{candidate});
217+
FastJetUtilities::fillTracks(candidate, inputParticles, candidate.globalIndex(), static_cast<int>(JetConstituentStatus::candidateHF), pdgDatabase->Mass(candidate.pdgCode()));
218218
findJets(jetFinder, inputParticles, jetRadius, collision, jetsTable, constituentsTable, constituentsSubTable, DoConstSub, true);
219219
}
220220
}

PWGJE/Tasks/jetfinderQA.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "Framework/AnalysisTask.h"
1919
#include "Framework/O2DatabasePDGPlugin.h"
2020
#include "Framework/HistogramRegistry.h"
21+
#include "Framework/runDataProcessing.h"
2122

2223
#include "Common/Core/TrackSelection.h"
2324
#include "Common/Core/TrackSelectionDefaults.h"
@@ -34,8 +35,6 @@ using namespace o2;
3435
using namespace o2::framework;
3536
using namespace o2::framework::expressions;
3637

37-
#include "Framework/runDataProcessing.h"
38-
3938
struct JetFinderQATask {
4039

4140
HistogramRegistry registry;

PWGJE/Tasks/jetfinderhfQA.cxx

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,28 @@
1616
#include "Framework/ASoA.h"
1717
#include "Framework/AnalysisDataModel.h"
1818
#include "Framework/AnalysisTask.h"
19-
#include "Framework/O2DatabasePDGPlugin.h"
2019
#include "Framework/HistogramRegistry.h"
21-
#include "TDatabasePDG.h"
20+
#include "Framework/runDataProcessing.h"
2221

2322
#include "Common/Core/TrackSelection.h"
2423
#include "Common/Core/TrackSelectionDefaults.h"
2524
#include "Common/DataModel/EventSelection.h"
2625
#include "Common/DataModel/TrackSelectionTables.h"
2726

28-
#include "PWGHF/Core/PDG.h"
29-
3027
#include "PWGHF/Core/HfHelper.h"
3128
#include "PWGHF/DataModel/CandidateReconstructionTables.h"
3229
#include "PWGHF/DataModel/CandidateSelectionTables.h"
30+
#include "PWGHF/Core/PDG.h"
3331

3432
#include "PWGJE/DataModel/Jet.h"
3533

3634
#include "EventFiltering/filterTables.h"
3735

3836
using namespace o2;
37+
using namespace o2::analysis;
3938
using namespace o2::framework;
4039
using namespace o2::framework::expressions;
4140

42-
#include "Framework/runDataProcessing.h"
43-
4441
template <typename JetTableData, typename JetConstituentTableData, typename CandidateTableData, typename JetTableMCD, typename JetConstituentTableMCD, typename JetMatchingTableMCDMCP, typename JetTableMCDWeighted, typename CandidateTableMCD, typename JetTableMCP, typename JetConstituentTableMCP, typename JetMatchingTableMCPMCD, typename JetTableMCPWeighted, typename ParticleTableMCP>
4542
struct JetFinderHFQATask {
4643
HistogramRegistry registry;
@@ -64,8 +61,21 @@ struct JetFinderHFQATask {
6461
std::vector<bool> filledJetR;
6562
std::vector<double> jetRadiiValues;
6663

64+
double candMass;
65+
6766
void init(o2::framework::InitContext&)
6867
{
68+
69+
if constexpr (std::is_same_v<std::decay_t<CandidateTableData>, soa::Join<aod::HfCand2Prong, aod::HfSelD0>>) { // Note : need to be careful if configurable workflow options are added later
70+
candMass = pdg::MassD0;
71+
}
72+
if constexpr (std::is_same_v<std::decay_t<CandidateTableData>, soa::Join<aod::HfCand3Prong, aod::HfSelLc>>) {
73+
candMass = pdg::MassLambdaCPlus;
74+
}
75+
if constexpr (std::is_same_v<std::decay_t<CandidateTableData>, soa::Join<aod::HfCandBplus, aod::HfSelBplusToD0Pi>>) {
76+
candMass = pdg::MassBPlus;
77+
}
78+
6979
trackSelection = static_cast<std::string>(trackSelections);
7080
jetRadiiValues = (std::vector<double>)jetRadii;
7181

@@ -237,7 +247,7 @@ struct JetFinderHFQATask {
237247
registry.fill(HIST("h3_jet_r_jet_pt_candidate_pt"), jet.r() / 100.0, jet.pt(), hfcandidate.pt(), weight);
238248
registry.fill(HIST("h3_jet_r_jet_pt_candidate_eta"), jet.r() / 100.0, jet.pt(), hfcandidate.eta(), weight);
239249
registry.fill(HIST("h3_jet_r_jet_pt_candidate_phi"), jet.r() / 100.0, jet.pt(), hfcandidate.phi(), weight);
240-
registry.fill(HIST("h3_jet_r_jet_pt_candidate_y"), jet.r() / 100.0, jet.pt(), hfcandidate.y(o2::analysis::pdg::MassD0), weight);
250+
registry.fill(HIST("h3_jet_r_jet_pt_candidate_y"), jet.r() / 100.0, jet.pt(), hfcandidate.y(candMass), weight);
241251

242252
if (jet.r() == round(selectedJetsRadius * 100.0f)) {
243253
if constexpr (std::is_same_v<std::decay_t<U>, soa::Join<aod::HfCand2Prong, aod::HfSelD0>> || std::is_same_v<std::decay_t<U>, soa::Join<aod::HfCand2Prong, aod::HfSelD0, aod::HfCand2ProngMcRec>>) {
@@ -322,7 +332,7 @@ struct JetFinderHFQATask {
322332
mcdCandPt = hfcandidate_mcd.pt();
323333
mcdCandPhi = hfcandidate_mcd.phi();
324334
mcdCandEta = hfcandidate_mcd.eta();
325-
mcdCandY = hfcandidate_mcd.y(o2::analysis::pdg::MassD0);
335+
mcdCandY = hfcandidate_mcd.y(candMass);
326336
}
327337

328338
for (auto& hfcandidate_mcp : mcpjet.template hfcandidates_as<std::decay_t<O>>()) {
@@ -474,12 +484,12 @@ struct JetFinderHFQATask {
474484
registry.fill(HIST("h3_jet_r_jet_pt_candidate_pt_MB"), jet.r() / 100.0, jet.pt(), hfcandidate.pt());
475485
registry.fill(HIST("h3_jet_r_jet_pt_candidate_eta_MB"), jet.r() / 100.0, jet.pt(), hfcandidate.eta());
476486
registry.fill(HIST("h3_jet_r_jet_pt_candidate_phi_MB"), jet.r() / 100.0, jet.pt(), hfcandidate.phi());
477-
registry.fill(HIST("h3_jet_r_jet_pt_candidate_y_MB"), jet.r() / 100.0, jet.pt(), hfcandidate.y(o2::analysis::pdg::MassD0));
487+
registry.fill(HIST("h3_jet_r_jet_pt_candidate_y_MB"), jet.r() / 100.0, jet.pt(), hfcandidate.y(candMass));
478488
if (collision.hasJetChHighPt() >= 1) {
479489
registry.fill(HIST("h3_jet_r_jet_pt_candidate_pt_Triggered"), jet.r() / 100.0, jet.pt(), hfcandidate.pt());
480490
registry.fill(HIST("h3_jet_r_jet_pt_candidate_eta_Triggered"), jet.r() / 100.0, jet.pt(), hfcandidate.eta());
481491
registry.fill(HIST("h3_jet_r_jet_pt_candidate_phi_Triggered"), jet.r() / 100.0, jet.pt(), hfcandidate.phi());
482-
registry.fill(HIST("h3_jet_r_jet_pt_candidate_y_Triggered"), jet.r() / 100.0, jet.pt(), hfcandidate.y(o2::analysis::pdg::MassD0));
492+
registry.fill(HIST("h3_jet_r_jet_pt_candidate_y_Triggered"), jet.r() / 100.0, jet.pt(), hfcandidate.y(candMass));
483493
}
484494
}
485495
}

0 commit comments

Comments
 (0)