Skip to content

Commit 895ff4b

Browse files
author
Nima Zardoshti
committed
PWGJE: fixing remaning calls to Mass in PDG
1 parent 019dc62 commit 895ff4b

4 files changed

Lines changed: 45 additions & 33 deletions

File tree

PWGJE/TableProducer/jetfinder.cxx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515

1616
#include "PWGJE/TableProducer/jetfinder.h"
1717

18-
using namespace o2;
19-
using namespace o2::framework;
20-
using namespace o2::framework::expressions;
21-
2218
#include "Framework/runDataProcessing.h"
2319

2420
template <typename JetTable, typename ConstituentTable, typename ConstituentSubTable>
@@ -66,7 +62,7 @@ struct JetFinderTask {
6662
Configurable<bool> DoRhoAreaSub{"DoRhoAreaSub", false, "do rho area subtraction"};
6763
Configurable<bool> DoConstSub{"DoConstSub", false, "do constituent subtraction"};
6864

69-
Service<o2::framework::O2DatabasePDG> pdg;
65+
Service<o2::framework::O2DatabasePDG> pdgDatabase;
7066
std::string trackSelection;
7167
std::string eventSelection;
7268
std::string particleSelection;
@@ -159,23 +155,23 @@ struct JetFinderTask {
159155
void processParticleLevelChargedJets(aod::McCollision const& collision, soa::Filtered<aod::McParticles> const& particles)
160156
{
161157
// TODO: MC event selection?
162-
analyseParticles<soa::Filtered<aod::McParticles>, soa::Filtered<aod::McParticles>::iterator>(inputParticles, particleSelection, 1, particles, pdg->Instance());
158+
analyseParticles<soa::Filtered<aod::McParticles>, soa::Filtered<aod::McParticles>::iterator>(inputParticles, particleSelection, 1, particles, pdgDatabase);
163159
findJets(jetFinder, inputParticles, jetRadius, collision, jetsTable, constituentsTable, constituentsSubTable, DoConstSub);
164160
}
165161
PROCESS_SWITCH(JetFinderTask, processParticleLevelChargedJets, "Particle level charged jet finding", false);
166162

167163
void processParticleLevelNeutralJets(aod::McCollision const& collision, soa::Filtered<aod::McParticles> const& particles)
168164
{
169165
// TODO: MC event selection?
170-
analyseParticles<soa::Filtered<aod::McParticles>, soa::Filtered<aod::McParticles>::iterator>(inputParticles, particleSelection, 2, particles, pdg->Instance());
166+
analyseParticles<soa::Filtered<aod::McParticles>, soa::Filtered<aod::McParticles>::iterator>(inputParticles, particleSelection, 2, particles, pdgDatabase);
171167
findJets(jetFinder, inputParticles, jetRadius, collision, jetsTable, constituentsTable, constituentsSubTable, DoConstSub);
172168
}
173169
PROCESS_SWITCH(JetFinderTask, processParticleLevelNeutralJets, "Particle level neutral jet finding", false);
174170

175171
void processParticleLevelFullJets(aod::McCollision const& collision, soa::Filtered<aod::McParticles> const& particles)
176172
{
177173
// TODO: MC event selection?
178-
analyseParticles<soa::Filtered<aod::McParticles>, soa::Filtered<aod::McParticles>::iterator>(inputParticles, particleSelection, 0, particles, pdg->Instance());
174+
analyseParticles<soa::Filtered<aod::McParticles>, soa::Filtered<aod::McParticles>::iterator>(inputParticles, particleSelection, 0, particles, pdgDatabase);
179175
findJets(jetFinder, inputParticles, jetRadius, collision, jetsTable, constituentsTable, constituentsSubTable, DoConstSub);
180176
}
181177

PWGJE/TableProducer/jetfinder.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include "Common/Core/TrackSelectionDefaults.h"
3131
#include "Common/DataModel/EventSelection.h"
3232
#include "Common/DataModel/TrackSelectionTables.h"
33-
#include "Common/Core/RecoDecay.h" // FIXME: Remove RecoDecay::getMassPDG
3433
#include "PWGJE/DataModel/EMCALClusters.h"
3534

3635
#include "PWGHF/Core/SelectorCuts.h"
@@ -41,6 +40,11 @@
4140
#include "PWGJE/Core/JetFinder.h"
4241
#include "PWGJE/DataModel/Jet.h"
4342

43+
using namespace o2;
44+
using namespace o2::analysis;
45+
using namespace o2::framework;
46+
using namespace o2::framework::expressions;
47+
4448
using JetTracks = o2::soa::Filtered<o2::soa::Join<o2::aod::Tracks, o2::aod::TrackSelection>>;
4549
using JetClusters = o2::soa::Filtered<o2::aod::EMCALClusters>;
4650

@@ -118,26 +122,26 @@ void analyseClusters(std::vector<fastjet::PseudoJet>& inputParticles, T const& c
118122

119123
// function that takes any generic candidate, performs selections and adds the candidate to the fastjet list
120124
template <typename T>
121-
bool analyseCandidate(std::vector<fastjet::PseudoJet>& inputParticles, int candPDG, float candPtMin, float candPtMax, float candYMin, float candYMax, T const& candidate)
125+
bool analyseCandidate(std::vector<fastjet::PseudoJet>& inputParticles, int candMass, float candPtMin, float candPtMax, float candYMin, float candYMax, T const& candidate)
122126
{
123-
if (candidate.y(RecoDecay::getMassPDG(candPDG)) < candYMin || candidate.y(RecoDecay::getMassPDG(candPDG)) > candYMax) { // FIXME: Remove RecoDecay::getMassPDG
127+
if (candidate.y(candMass) < candYMin || candidate.y(candMass) > candYMax) {
124128
return false;
125129
}
126130
if (candidate.pt() < candPtMin || candidate.pt() >= candPtMax) {
127131
return false;
128132
}
129-
FastJetUtilities::fillTracks(candidate, inputParticles, candidate.globalIndex(), static_cast<int>(JetConstituentStatus::candidateHF), RecoDecay::getMassPDG(candPDG)); // FIXME: Remove RecoDecay::getMassPDG
133+
FastJetUtilities::fillTracks(candidate, inputParticles, candidate.globalIndex(), static_cast<int>(JetConstituentStatus::candidateHF), candMass);
130134
return true;
131135
}
132136

133137
// function that checks the MC status of a candidate and then calls the function to analyseCandidates
134138
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)
139+
bool analyseCandidateMC(std::vector<fastjet::PseudoJet>& inputParticles, int candMass, int candDecay, float candPtMin, float candPtMax, float candYMin, float candYMax, T const& candidate, bool rejectBackgroundMCCandidates)
136140
{
137141
if (rejectBackgroundMCCandidates && !(std::abs(candidate.flagMcMatchRec()) == 1 << candDecay)) {
138142
return false;
139143
}
140-
return analyseCandidate(inputParticles, candPDG, candPtMin, candPtMax, candYMin, candYMax, candidate);
144+
return analyseCandidate(inputParticles, candMass, candPtMin, candPtMax, candYMin, candYMax, candidate);
141145
}
142146

143147
// function that calls the jet finding and fills the relevant tables
@@ -207,7 +211,7 @@ bool checkDaughters(T const& particle, int globalIndex)
207211
}
208212

209213
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)
214+
void analyseParticles(std::vector<fastjet::PseudoJet>& inputParticles, std::string particleSelection, int jetTypeParticleLevel, T const& particles, Service<o2::framework::O2DatabasePDG> pdgDatabase, std::optional<U> const& candidate = std::nullopt)
211215
{
212216
inputParticles.clear();
213217
for (auto& particle : particles) {
@@ -220,7 +224,7 @@ void analyseParticles(std::vector<fastjet::PseudoJet>& inputParticles, std::stri
220224
} else if (particleSelection == "PhysicalPrimaryAndHepMCStatus" && (!particle.isPhysicalPrimary() || particle.getHepMCStatusCode() != 1)) {
221225
continue;
222226
}
223-
auto pdgParticle = pdg->GetParticle(particle.pdgCode());
227+
auto pdgParticle = pdgDatabase->GetParticle(particle.pdgCode());
224228
auto pdgCharge = pdgParticle ? std::abs(pdgParticle->Charge()) : -1.0;
225229
if (jetTypeParticleLevel == static_cast<int>(JetType::charged) && pdgCharge < 3.0) {
226230
continue;

PWGJE/TableProducer/jetfinderhf.cxx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616
#include "PWGJE/TableProducer/jetfinder.h"
1717
#include "Common/Core/RecoDecay.h"
1818

19-
using namespace o2;
20-
using namespace o2::analysis;
21-
using namespace o2::framework;
22-
using namespace o2::framework::expressions;
23-
2419
/*
2520
void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
2621
{
@@ -94,7 +89,7 @@ struct JetFinderHFTask {
9489
Configurable<bool> DoRhoAreaSub{"DoRhoAreaSub", false, "do rho area subtraction"};
9590
Configurable<bool> DoConstSub{"DoConstSub", false, "do constituent subtraction"};
9691

97-
Service<o2::framework::O2DatabasePDG> pdg;
92+
Service<o2::framework::O2DatabasePDG> pdgDatabase;
9893
std::string trackSelection;
9994
std::string eventSelection;
10095
std::string particleSelection;
@@ -104,6 +99,7 @@ struct JetFinderHFTask {
10499

105100
int candPDG;
106101
int candDecay;
102+
double candMass;
107103

108104
void init(InitContext const&)
109105
{
@@ -144,6 +140,7 @@ struct JetFinderHFTask {
144140
candPDG = static_cast<int>(pdg::Code::kLambdaCPlus);
145141
candDecay = static_cast<int>(aod::hf_cand_3prong::DecayType::LcToPKPi);
146142
}
143+
candMass = pdgDatabase->Mass(candPDG);
147144
}
148145

149146
o2::aod::EMCALClusterDefinition clusterDefinition = o2::aod::emcalcluster::getClusterDefinitionFromString(clusterDefinitionS.value);
@@ -166,7 +163,7 @@ struct JetFinderHFTask {
166163

167164
for (auto& candidate : candidates) {
168165
inputParticles.clear();
169-
if (!analyseCandidate(inputParticles, candPDG, candPtMin, candPtMax, candYMin, candYMax, candidate)) {
166+
if (!analyseCandidate(inputParticles, candMass, candPtMin, candPtMax, candYMin, candYMax, candidate)) {
170167
continue;
171168
}
172169
analyseTracks(inputParticles, tracks, trackSelection, std::optional{candidate});
@@ -184,7 +181,7 @@ struct JetFinderHFTask {
184181

185182
for (auto& candidate : candidates) {
186183
inputParticles.clear();
187-
if (!analyseCandidateMC(inputParticles, candPDG, candDecay, candPtMin, candPtMax, candYMin, candYMax, candidate, rejectBackgroundMCCandidates)) {
184+
if (!analyseCandidateMC(inputParticles, candMass, candDecay, candPtMin, candPtMax, candYMin, candYMax, candidate, rejectBackgroundMCCandidates)) {
188185
continue;
189186
}
190187
analyseTracks(inputParticles, tracks, trackSelection, std::optional{candidate});
@@ -202,7 +199,7 @@ struct JetFinderHFTask {
202199

203200
for (auto const& particle : particles) {
204201
if (std::abs(particle.flagMcMatchGen()) & (1 << candDecay)) {
205-
auto particleY = RecoDecay::y(std::array{particle.px(), particle.py(), particle.pz()}, pdg->Mass(particle.pdgCode()));
202+
auto particleY = RecoDecay::y(std::array{particle.px(), particle.py(), particle.pz()}, pdgDatabase->Mass(particle.pdgCode()));
206203
if (particleY < candYMin || particleY > candYMax) {
207204
continue;
208205
}
@@ -213,8 +210,8 @@ struct JetFinderHFTask {
213210
}
214211
}
215212
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()));
213+
analyseParticles(inputParticles, particleSelection, jetTypeParticleLevel, particles, pdgDatabase, std::optional{candidate});
214+
FastJetUtilities::fillTracks(candidate, inputParticles, candidate.globalIndex(), static_cast<int>(JetConstituentStatus::candidateHF), pdgDatabase->Mass(candidate.pdgCode()));
218215
findJets(jetFinder, inputParticles, jetRadius, collision, jetsTable, constituentsTable, constituentsSubTable, DoConstSub, true);
219216
}
220217
}

PWGJE/Tasks/jetfinderhfQA.cxx

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
#include "Common/DataModel/EventSelection.h"
2626
#include "Common/DataModel/TrackSelectionTables.h"
2727

28-
#include "PWGHF/Core/PDG.h"
29-
3028
#include "PWGHF/Core/HfHelper.h"
3129
#include "PWGHF/DataModel/CandidateReconstructionTables.h"
3230
#include "PWGHF/DataModel/CandidateSelectionTables.h"
@@ -36,6 +34,7 @@
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

@@ -64,8 +63,24 @@ struct JetFinderHFQATask {
6463
std::vector<bool> filledJetR;
6564
std::vector<double> jetRadiiValues;
6665

66+
Service<o2::framework::O2DatabasePDG> pdgDatabase;
67+
int candPDG;
68+
double candMass;
69+
6770
void init(o2::framework::InitContext&)
6871
{
72+
73+
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
74+
candPDG = static_cast<int>(pdg::Code::kD0);
75+
}
76+
if constexpr (std::is_same_v<std::decay_t<CandidateTableData>, soa::Join<aod::HfCand3Prong, aod::HfSelLc>>) {
77+
candPDG = static_cast<int>(pdg::Code::kLambdaCPlus);
78+
}
79+
if constexpr (std::is_same_v<std::decay_t<CandidateTableData>, soa::Join<aod::HfCandBplus, aod::HfSelBplusToD0Pi>>) {
80+
candPDG = static_cast<int>(pdg::Code::kBPlus);
81+
}
82+
candMass = pdgDatabase->Mass(candPDG);
83+
6984
trackSelection = static_cast<std::string>(trackSelections);
7085
jetRadiiValues = (std::vector<double>)jetRadii;
7186

@@ -237,7 +252,7 @@ struct JetFinderHFQATask {
237252
registry.fill(HIST("h3_jet_r_jet_pt_candidate_pt"), jet.r() / 100.0, jet.pt(), hfcandidate.pt(), weight);
238253
registry.fill(HIST("h3_jet_r_jet_pt_candidate_eta"), jet.r() / 100.0, jet.pt(), hfcandidate.eta(), weight);
239254
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);
255+
registry.fill(HIST("h3_jet_r_jet_pt_candidate_y"), jet.r() / 100.0, jet.pt(), hfcandidate.y(candMass), weight);
241256

242257
if (jet.r() == round(selectedJetsRadius * 100.0f)) {
243258
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 +337,7 @@ struct JetFinderHFQATask {
322337
mcdCandPt = hfcandidate_mcd.pt();
323338
mcdCandPhi = hfcandidate_mcd.phi();
324339
mcdCandEta = hfcandidate_mcd.eta();
325-
mcdCandY = hfcandidate_mcd.y(o2::analysis::pdg::MassD0);
340+
mcdCandY = hfcandidate_mcd.y(candMass);
326341
}
327342

328343
for (auto& hfcandidate_mcp : mcpjet.template hfcandidates_as<std::decay_t<O>>()) {
@@ -474,12 +489,12 @@ struct JetFinderHFQATask {
474489
registry.fill(HIST("h3_jet_r_jet_pt_candidate_pt_MB"), jet.r() / 100.0, jet.pt(), hfcandidate.pt());
475490
registry.fill(HIST("h3_jet_r_jet_pt_candidate_eta_MB"), jet.r() / 100.0, jet.pt(), hfcandidate.eta());
476491
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));
492+
registry.fill(HIST("h3_jet_r_jet_pt_candidate_y_MB"), jet.r() / 100.0, jet.pt(), hfcandidate.y(candMass));
478493
if (collision.hasJetChHighPt() >= 1) {
479494
registry.fill(HIST("h3_jet_r_jet_pt_candidate_pt_Triggered"), jet.r() / 100.0, jet.pt(), hfcandidate.pt());
480495
registry.fill(HIST("h3_jet_r_jet_pt_candidate_eta_Triggered"), jet.r() / 100.0, jet.pt(), hfcandidate.eta());
481496
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));
497+
registry.fill(HIST("h3_jet_r_jet_pt_candidate_y_Triggered"), jet.r() / 100.0, jet.pt(), hfcandidate.y(candMass));
483498
}
484499
}
485500
}

0 commit comments

Comments
 (0)