Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions PWGJE/TableProducer/jetfinder.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename JetTable, typename ConstituentTable, typename ConstituentSubTable>
struct JetFinderTask {
Produces<JetTable> jetsTable;
Expand Down Expand Up @@ -66,7 +66,7 @@ struct JetFinderTask {
Configurable<bool> DoRhoAreaSub{"DoRhoAreaSub", false, "do rho area subtraction"};
Configurable<bool> DoConstSub{"DoConstSub", false, "do constituent subtraction"};

Service<o2::framework::O2DatabasePDG> pdg;
Service<o2::framework::O2DatabasePDG> pdgDatabase;
std::string trackSelection;
std::string eventSelection;
std::string particleSelection;
Expand Down Expand Up @@ -159,23 +159,23 @@ struct JetFinderTask {
void processParticleLevelChargedJets(aod::McCollision const& collision, soa::Filtered<aod::McParticles> const& particles)
{
// TODO: MC event selection?
analyseParticles<soa::Filtered<aod::McParticles>, soa::Filtered<aod::McParticles>::iterator>(inputParticles, particleSelection, 1, particles, pdg->Instance());
analyseParticles<soa::Filtered<aod::McParticles>, soa::Filtered<aod::McParticles>::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);

void processParticleLevelNeutralJets(aod::McCollision const& collision, soa::Filtered<aod::McParticles> const& particles)
{
// TODO: MC event selection?
analyseParticles<soa::Filtered<aod::McParticles>, soa::Filtered<aod::McParticles>::iterator>(inputParticles, particleSelection, 2, particles, pdg->Instance());
analyseParticles<soa::Filtered<aod::McParticles>, soa::Filtered<aod::McParticles>::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);

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

Expand Down
17 changes: 8 additions & 9 deletions PWGJE/TableProducer/jetfinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -118,26 +117,26 @@ void analyseClusters(std::vector<fastjet::PseudoJet>& inputParticles, T const& c

// function that takes any generic candidate, performs selections and adds the candidate to the fastjet list
template <typename T>
bool analyseCandidate(std::vector<fastjet::PseudoJet>& inputParticles, int candPDG, float candPtMin, float candPtMax, float candYMin, float candYMax, T const& candidate)
bool analyseCandidate(std::vector<fastjet::PseudoJet>& 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<int>(JetConstituentStatus::candidateHF), RecoDecay::getMassPDG(candPDG)); // FIXME: Remove RecoDecay::getMassPDG
FastJetUtilities::fillTracks(candidate, inputParticles, candidate.globalIndex(), static_cast<int>(JetConstituentStatus::candidateHF), candMass);
return true;
}

// function that checks the MC status of a candidate and then calls the function to analyseCandidates
template <typename T>
bool analyseCandidateMC(std::vector<fastjet::PseudoJet>& inputParticles, int candPDG, int candDecay, float candPtMin, float candPtMax, float candYMin, float candYMax, T const& candidate, bool rejectBackgroundMCCandidates)
bool analyseCandidateMC(std::vector<fastjet::PseudoJet>& 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
Expand Down Expand Up @@ -207,7 +206,7 @@ bool checkDaughters(T const& particle, int globalIndex)
}

template <typename T, typename U>
void analyseParticles(std::vector<fastjet::PseudoJet>& inputParticles, std::string particleSelection, int jetTypeParticleLevel, T const& particles, TDatabasePDG* pdg, std::optional<U> const& candidate = std::nullopt)
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)
{
inputParticles.clear();
for (auto& particle : particles) {
Expand All @@ -220,7 +219,7 @@ void analyseParticles(std::vector<fastjet::PseudoJet>& 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<int>(JetType::charged) && pdgCharge < 3.0) {
continue;
Expand Down
20 changes: 10 additions & 10 deletions PWGJE/TableProducer/jetfinderhf.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,16 @@ struct JetFinderHFTask {
Configurable<bool> DoRhoAreaSub{"DoRhoAreaSub", false, "do rho area subtraction"};
Configurable<bool> DoConstSub{"DoConstSub", false, "do constituent subtraction"};

Service<o2::framework::O2DatabasePDG> pdg;
Service<o2::framework::O2DatabasePDG> pdgDatabase;
std::string trackSelection;
std::string eventSelection;
std::string particleSelection;

JetFinder jetFinder;
std::vector<fastjet::PseudoJet> inputParticles;

int candPDG;
int candDecay;
double candMass;

void init(InitContext const&)
{
Expand Down Expand Up @@ -133,15 +133,15 @@ struct JetFinderHFTask {
jetFinder.ghostRepeatN = ghostRepeat;

if constexpr (std::is_same_v<std::decay_t<CandidateTableData>, CandidatesD0Data>) { // Note : need to be careful if configurable workflow options are added later
candPDG = static_cast<int>(pdg::Code::kD0);
candMass = pdg::MassD0;
candDecay = static_cast<int>(aod::hf_cand_2prong::DecayType::D0ToPiK);
}
if constexpr (std::is_same_v<std::decay_t<CandidateTableData>, CandidatesBplusData>) {
candPDG = static_cast<int>(pdg::Code::kBPlus);
candMass = pdg::MassBPlus;
candDecay = static_cast<int>(aod::hf_cand_bplus::DecayType::BplusToD0Pi);
}
if constexpr (std::is_same_v<std::decay_t<CandidateTableData>, CandidatesLcData>) {
candPDG = static_cast<int>(pdg::Code::kLambdaCPlus);
candMass = pdg::MassLambdaCPlus;
candDecay = static_cast<int>(aod::hf_cand_3prong::DecayType::LcToPKPi);
}
}
Expand All @@ -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});
Expand All @@ -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});
Expand All @@ -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;
}
Expand All @@ -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<int>(JetConstituentStatus::candidateHF), pdg->Mass(candidate.pdgCode()));
analyseParticles(inputParticles, particleSelection, jetTypeParticleLevel, particles, pdgDatabase, std::optional{candidate});
FastJetUtilities::fillTracks(candidate, inputParticles, candidate.globalIndex(), static_cast<int>(JetConstituentStatus::candidateHF), pdgDatabase->Mass(candidate.pdgCode()));
findJets(jetFinder, inputParticles, jetRadius, collision, jetsTable, constituentsTable, constituentsSubTable, DoConstSub, true);
}
}
Expand Down
3 changes: 1 addition & 2 deletions PWGJE/Tasks/jetfinderQA.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -34,8 +35,6 @@ using namespace o2;
using namespace o2::framework;
using namespace o2::framework::expressions;

#include "Framework/runDataProcessing.h"

struct JetFinderQATask {

HistogramRegistry registry;
Expand Down
30 changes: 20 additions & 10 deletions PWGJE/Tasks/jetfinderhfQA.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <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>
struct JetFinderHFQATask {
HistogramRegistry registry;
Expand All @@ -64,8 +61,21 @@ struct JetFinderHFQATask {
std::vector<bool> filledJetR;
std::vector<double> jetRadiiValues;

double candMass;

void init(o2::framework::InitContext&)
{

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
candMass = pdg::MassD0;
}
if constexpr (std::is_same_v<std::decay_t<CandidateTableData>, soa::Join<aod::HfCand3Prong, aod::HfSelLc>>) {
candMass = pdg::MassLambdaCPlus;
}
if constexpr (std::is_same_v<std::decay_t<CandidateTableData>, soa::Join<aod::HfCandBplus, aod::HfSelBplusToD0Pi>>) {
candMass = pdg::MassBPlus;
}

trackSelection = static_cast<std::string>(trackSelections);
jetRadiiValues = (std::vector<double>)jetRadii;

Expand Down Expand Up @@ -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<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>>) {
Expand Down Expand Up @@ -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<std::decay_t<O>>()) {
Expand Down Expand Up @@ -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));
}
}
}
Expand Down