Skip to content
Merged
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
144 changes: 92 additions & 52 deletions PWGJE/Tasks/nucleiInJets.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "PWGJE/DataModel/JetSubtraction.h"
//
#include "PWGLF/DataModel/LFParticleIdentification.h"
#include "PWGLF/DataModel/mcCentrality.h"
#include "PWGLF/Utils/inelGt.h"

#include "Common/Core/RecoDecay.h"
Expand Down Expand Up @@ -190,6 +191,7 @@
// using EventTable = soa::Join<aod::JetCollisions, aod::EvSels, aod::CentFT0Ms, aod::CentFV0As, aod::CentFT0Cs>;
using EventTable = aod::JetCollisions;
using EventTableMC = soa::Join<EventTable, aod::JMcCollisionLbs>;
using JetMcCollisionWithCent = soa::Join<aod::JetMcCollisions, aod::McCentFT0Cs, aod::McCentFV0As>::iterator;
using JetCollWithLabel = o2::soa::Join<aod::JetCollisions, aod::JMcCollisionLbs, aod::BkgChargedRhos>::iterator;
using TrackCandidates = soa::Join<aod::Tracks, aod::TracksExtra, aod::TracksDCA, aod::TrackSelection, aod::pidTPCFullPi, aod::pidTPCFullKa,
aod::pidTPCFullPr, aod::pidTPCFullDe, aod::pidTPCFullHe, aod::pidTPCFullTr, aod::pidTOFFullPi, aod::pidTOFFullKa,
Expand Down Expand Up @@ -600,13 +602,16 @@
// Event and signal loss analysis histograms (inclusive)
jetHist.add("eventLoss/hEventStatistics", "Event Statistics for Loss Analysis", kTH1F, {{10, 0.f, 10.f}});
jetHist.get<TH1>(HIST("eventLoss/hEventStatistics"))->GetXaxis()->SetBinLabel(1, "All Generated");
jetHist.get<TH1>(HIST("eventLoss/hEventStatistics"))->GetXaxis()->SetBinLabel(2, "Gen |Vz|<10");
jetHist.get<TH1>(HIST("eventLoss/hEventStatistics"))->GetXaxis()->SetBinLabel(2, "Gen |Vz| cut");
jetHist.get<TH1>(HIST("eventLoss/hEventStatistics"))->GetXaxis()->SetBinLabel(3, "Gen True INEL>0");
jetHist.get<TH1>(HIST("eventLoss/hEventStatistics"))->GetXaxis()->SetBinLabel(4, "Has Reco Coll");
jetHist.get<TH1>(HIST("eventLoss/hEventStatistics"))->GetXaxis()->SetBinLabel(5, "Pass Sel8");
jetHist.get<TH1>(HIST("eventLoss/hEventStatistics"))->GetXaxis()->SetBinLabel(6, "Pass |Vz|<10");
jetHist.get<TH1>(HIST("eventLoss/hEventStatistics"))->GetXaxis()->SetBinLabel(7, "Pass rec INEL>0");
jetHist.get<TH1>(HIST("eventLoss/hEventStatistics"))->GetXaxis()->SetBinLabel(8, "EvSelPassedRecINELgt0");
jetHist.get<TH1>(HIST("eventLoss/hEventStatistics"))->GetXaxis()->SetBinLabel(6, "Pass reco |Vz| cut");
jetHist.get<TH1>(HIST("eventLoss/hEventStatistics"))->GetXaxis()->SetBinLabel(7, "Pass extra event sel");
jetHist.get<TH1>(HIST("eventLoss/hEventStatistics"))->GetXaxis()->SetBinLabel(8, "Reco selected");
jetHist.get<TH1>(HIST("eventLoss/hEventStatistics"))->GetXaxis()->SetBinLabel(9, "Reco selected + true INEL>0");
jetHist.add<TH2>("eventLoss/hRecoCollPerMCCollVsCent", "Reco collisions per MC collision;N_{reco coll};Centrality", HistType::kTH2F, {{10, -0.5f, 9.5f}, {100, 0.f, 100.f}});
jetHist.add<TH2>("eventLoss/hSelectedRecoCollPerMCCollVsCent", "Selected reco collisions per MC collision;N_{selected reco coll};Centrality", HistType::kTH2F, {{10, -0.5f, 9.5f}, {100, 0.f, 100.f}});

// Signal loss histograms (only the ones that are actually used)
jetHist.add<TH3>("eventLoss/signalLoss/h3GenParticlesPtVsEtaVsCent_INELgt0", "Generated Particles p_{T} vs #eta vs Centrality", HistType::kTH3F, {{PtAxis}, {100, -1.5f, 1.5f}, {100, 0, 100}});
Expand Down Expand Up @@ -733,6 +738,10 @@
jetHist.add<TH2>("eff/recmatched/perpCone/pt/PtParticleTypeTPCTOFVeto", "Pt (p) vs particletype", HistType::kTH2D, {{PtAxis}, {14, -7, 7}});
jetHist.add<TH3>("eff/recmatched/gen/pt/PtParticleType", "Pt (p) vs jetflag vs particletype", HistType::kTH3D, {{PtAxis}, {2, 0, 2}, {14, -7, 7}});
jetHist.add<TH2>("eff/recmatched/gen/perpCone/pt/PtParticleType", "Pt (p) vs particletype", HistType::kTH2D, {{PtAxis}, {14, -7, 7}});
jetHist.add<TH3>("eff/recmatched/mcC/gen/pt/PtParticleType", "Pt (gen, mcC) vs jetflag vs particletype", HistType::kTH3D, {{PtAxis}, {2, 0, 2}, {14, -7, 7}});
jetHist.add<TH3>("eff/recmatched/mcCSpectra/gen/pt/PtParticleType", "Pt (gen, mcCSpectra) vs jetflag vs particletype", HistType::kTH3D, {{PtAxis}, {2, 0, 2}, {14, -7, 7}});
jetHist.add<TH2>("eff/recmatched/mcC/gen/perpCone/pt/PtParticleType", "Pt (gen, mcC, perp cone) vs particletype", HistType::kTH2D, {{PtAxis}, {14, -7, 7}});
jetHist.add<TH2>("eff/recmatched/mcCSpectra/gen/perpCone/pt/PtParticleType", "Pt (gen, mcCSpectra, perp cone) vs particletype", HistType::kTH2D, {{PtAxis}, {14, -7, 7}});
// gen matched
jetHist.add<TH2>("genmatched/hRecMatchedJetPt", "matched jet pT (Rec level);#it{p}_{T,jet part} (GeV/#it{c}); #it{p}_{T,jet part} - #it{p}_{T,jet det}", HistType::kTH2F, {{100, 0., 100.}, {400, -20., 20.}});
jetHist.add<TH2>("genmatched/hRecMatchedVsGenJetPt", "matched jet pT (Rec level);#it{p}_{T,jet det}; #it{p}_{T,jet part} (GeV/#it{c})", HistType::kTH2F, {{100, 0., 100.}, {100, 0., 100.}});
Expand Down Expand Up @@ -1766,7 +1775,7 @@
if (isWithJetEvents && nJets == 0)
return;
jetHist.fill(HIST("jet/h1JetEvents"), 0.5);
for (auto& track : tracks) {

Check failure on line 1778 in PWGJE/Tasks/nucleiInJets.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
auto trk = track.track_as<TrackCandidatesLfPid>();
fillTrackInfo<false>(trk, chargedjets, leadingJetWithPtEtaPhi, backgroundRho);
}
Expand All @@ -1784,7 +1793,7 @@
return;
jetHist.fill(HIST("hNEventsInc"), 1.5);

if (std::abs(coll.posZ()) > 10) // bad vertex

Check failure on line 1796 in PWGJE/Tasks/nucleiInJets.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
return;
jetHist.fill(HIST("hNEventsInc"), 2.5);
if (selNoSameBunchPileup && !isSelNoSameBunchPileup)
Expand Down Expand Up @@ -2130,7 +2139,7 @@
// bool jetFlag = kFALSE;
jetHist.fill(HIST("mcdJet/eventStat"), 1.5);

if (std::abs(collisionJet.posZ()) > 10)

Check failure on line 2142 in PWGJE/Tasks/nucleiInJets.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
return;

jetHist.fill(HIST("mcdJet/eventStat"), 2.5);
Expand All @@ -2138,7 +2147,7 @@
int nJets = 0;
std::vector<float> leadingJetWithPtEtaPhi(3);
float leadingJetPt = -1.0f;
for (auto& mcdjet : mcdjets) {

Check failure on line 2150 in PWGJE/Tasks/nucleiInJets.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
jetHist.fill(HIST("mcdJet/hJetPt"), mcdjet.pt());
jetHist.fill(HIST("mcdJet/hJetEta"), mcdjet.eta());
jetHist.fill(HIST("mcdJet/hJetPhi"), mcdjet.phi());
Expand Down Expand Up @@ -2212,7 +2221,7 @@
jetHist.fill(HIST("recmatched/vertexZ"), collision.posZ());

// Event-wise random splitting for closure test: decide once per event
bool useDataLikeHist = (randUniform.Uniform(0, 1) < 0.5);

Check failure on line 2224 in PWGJE/Tasks/nucleiInJets.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
const float backgroundRho = collision.rho();
const float jetArea = M_PI * cfgjetR * cfgjetR;
if (usebkgSubractionMC) {
Expand Down Expand Up @@ -2414,8 +2423,22 @@

if (mapPDGToValue(mcParticle.pdgCode()) != 0) {
jetHist.fill(HIST("eff/recmatched/gen/pt/PtParticleType"), mcParticle.pt(), jetFlagMC, mapPDGToValue(mcParticle.pdgCode()));
if (useMcC) {
if (useDataLikeHist) {
jetHist.fill(HIST("eff/recmatched/mcC/gen/pt/PtParticleType"), mcParticle.pt(), jetFlagMC, mapPDGToValue(mcParticle.pdgCode()));
} else {
jetHist.fill(HIST("eff/recmatched/mcCSpectra/gen/pt/PtParticleType"), mcParticle.pt(), jetFlagMC, mapPDGToValue(mcParticle.pdgCode()));
}
}
if (jetFlagPerpConeMC) {
jetHist.fill(HIST("eff/recmatched/gen/perpCone/pt/PtParticleType"), mcParticle.pt(), mapPDGToValue(mcParticle.pdgCode()));
if (useMcC) {
if (useDataLikeHist) {
jetHist.fill(HIST("eff/recmatched/mcC/gen/perpCone/pt/PtParticleType"), mcParticle.pt(), mapPDGToValue(mcParticle.pdgCode()));
} else {
jetHist.fill(HIST("eff/recmatched/mcCSpectra/gen/perpCone/pt/PtParticleType"), mcParticle.pt(), mapPDGToValue(mcParticle.pdgCode()));
}
}
}
}
} // mcParticle
Expand All @@ -2428,7 +2451,7 @@
{
if (cDebugLevel > 0) {
nprocessSimJEEvents++;
if ((nprocessSimJEEvents + 1) % 100000 == 0)

Check failure on line 2454 in PWGJE/Tasks/nucleiInJets.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
LOG(debug) << "Jet Events: " << nprocessSimJEEvents;
}
if (recocolls.size() <= 0) // not reconstructed
Expand All @@ -2443,7 +2466,7 @@
jetHist.fill(HIST("genmatched/vertexZ"), collision.posZ());

// Event-wise random splitting for closure test: decide once per event
bool useDataLikeHist = (randUniform.Uniform(0, 1) < 0.5);

Check failure on line 2469 in PWGJE/Tasks/nucleiInJets.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.

std::vector<double> mcpJetPt{};
std::vector<double> mcpJetPhi{};
Expand Down Expand Up @@ -2625,7 +2648,7 @@
if (std::abs(rapidity) > cfgtrkMaxRap)
continue;
// Proton
if (std::abs(mcTrack.pdgCode()) == 2212) { // Proton

Check failure on line 2651 in PWGJE/Tasks/nucleiInJets.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/explicit-code]

Avoid hard-coded PDG codes. Use named values from PDG_t or o2::constants::physics::Pdg instead.
jetHist.fill(HIST("recInc/eff/tpcTrack3D"), mcTrack.pt(), mapPDGToValue(mcTrack.pdgCode()), centrality);
if (track.hasTOF())
jetHist.fill(HIST("recInc/eff/tpcTofTrack3D"), mcTrack.pt(), mapPDGToValue(mcTrack.pdgCode()), centrality);
Expand Down Expand Up @@ -2655,14 +2678,14 @@
// TPCTOF and TPCTOFVeto histograms
// Proton
if (std::abs(track.tpcNSigmaPr()) < cfgnTPCPIDPr && track.hasTOF()) {
if (std::abs(mcTrack.pdgCode()) == 2212) {

Check failure on line 2681 in PWGJE/Tasks/nucleiInJets.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/explicit-code]

Avoid hard-coded PDG codes. Use named values from PDG_t or o2::constants::physics::Pdg instead.
jetHist.fill(HIST("recInc/pt/PtParticleTypeTPCTOF"), mcTrack.pt(), mapPDGToValue(mcTrack.pdgCode()), centrality);
if (std::abs(track.tofNSigmaPr()) < cfgnTPCPIDPrTOF)
jetHist.fill(HIST("recInc/pt/PtParticleTypeTPCTOFVeto"), mcTrack.pt(), mapPDGToValue(mcTrack.pdgCode()), centrality);
}
} else {
if (std::abs(track.tpcNSigmaPr()) < cfgnTPCPIDPr) {
if (std::abs(mcTrack.pdgCode()) == 2212) {

Check failure on line 2688 in PWGJE/Tasks/nucleiInJets.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/explicit-code]

Avoid hard-coded PDG codes. Use named values from PDG_t or o2::constants::physics::Pdg instead.
jetHist.fill(HIST("recInc/pt/PtParticleTypeTPCTOFVeto"), mcTrack.pt(), mapPDGToValue(mcTrack.pdgCode()), centrality);
}
}
Expand Down Expand Up @@ -2714,96 +2737,113 @@
}

// Process function for event and signal loss analysis (inclusive)
void processEventSignalLoss(aod::JetMcCollision const& mcCollision,
void processEventSignalLoss(JetMcCollisionWithCent const& mcCollision,
soa::SmallGroups<soa::Join<aod::JMcCollisionLbs, aod::JetCollisions>> const& recoColls,
aod::JetParticles const& mcParticles,
TrackCandidates const&)
{

// Fill generated event statistics
jetHist.fill(HIST("eventLoss/hEventStatistics"), 0.5); // All Generated

// Check if we have a reconstructed collision
bool hasRecoColl = false;
bool passSel8 = false;
bool passVz = false;
bool passINELgt0 = false;
bool isSel8 = false;

float centrality = -999;
auto mcParticles_perColl = mcParticles.sliceBy(perMCCol, mcCollision.globalIndex());
float centrality = -999.f;
switch (centralityType) {
case 0: // FT0M
case 0:
centrality = mcCollision.centFT0M();
break;
case 1: // FT0C
centrality = mcCollision.multFT0C();
case 1:
centrality = mcCollision.centFT0C();
break;
case 2: // V0A
centrality = mcCollision.multFV0A();
case 2:
centrality = mcCollision.centFV0A();
break;
default:
centrality = -999;
centrality = mcCollision.centFT0M();
break;
}
const bool passGenVz = std::abs(mcCollision.posZ()) < cfgMaxZVertex;
const bool mcINELgt0 = o2::pwglf::isINELgt0mc(mcParticles_perColl, pdgDB);

// Check INEL>0 at MC level using PWGLF functionality
bool mcINELgt0 = o2::pwglf::isINELgt0mc(mcParticles, pdgDB);
if (mcCollision.posZ() < 10) {
jetHist.fill(HIST("eventLoss/hEventStatistics"), 1.5);
if (mcINELgt0) {
jetHist.fill(HIST("eventLoss/hEventStatistics"), 2.5);
}
if (!passGenVz) {
return;
}
jetHist.fill(HIST("eventLoss/hEventStatistics"), 1.5); // Gen |Vz| cut

if (!mcINELgt0) {
return;
}
jetHist.fill(HIST("eventLoss/hEventStatistics"), 2.5); // Gen True INEL>0

int nRecoColls = 0;
int nSelectedRecoColls = 0;
bool hasRecoColl = false;
bool passSel8 = false;
bool passRecoVz = false;
bool passExtraEventSel = false;
bool hasSelectedRecoColl = false;
for (const auto& recoColl : recoColls) {
++nRecoColls;
hasRecoColl = true;
if (jetderiveddatautilities::selectCollision(recoColl, jetderiveddatautilities::initialiseEventSelectionBits("sel8")))
isSel8 = true;
jetHist.fill(HIST("eventLoss/hEventStatistics"), 3.5); // Has Reco Coll
const bool isSel8 = jetderiveddatautilities::selectCollision(recoColl, jetderiveddatautilities::initialiseEventSelectionBits("sel8"));
const bool isRecoVz = std::abs(recoColl.posZ()) < cfgMaxZVertex;
const bool isNoSameBunchPileup = !selNoSameBunchPileup || jetderiveddatautilities::selectCollision(recoColl, jetderiveddatautilities::initialiseEventSelectionBits("NoSameBunchPileup"));
const bool isGoodZvtxFT0vsPV = !selIsGoodZvtxFT0vsPV || jetderiveddatautilities::selectCollision(recoColl, jetderiveddatautilities::initialiseEventSelectionBits("IsGoodZvtxFT0vsPV"));
const bool isOccupancy = !useOccupancy || isOccupancyAccepted(recoColl);
const bool isExtraEventSel = isNoSameBunchPileup && isGoodZvtxFT0vsPV && isOccupancy;

if (isSel8) {
passSel8 = true;
jetHist.fill(HIST("eventLoss/hEventStatistics"), 4.5); // Pass Sel8
}

if (std::abs(recoColl.posZ()) < 10.0) {
passVz = true;
jetHist.fill(HIST("eventLoss/hEventStatistics"), 5.5); // Pass |Vz|<10
if (isRecoVz) {
passRecoVz = true;
}

if (mcINELgt0) {
passINELgt0 = true;
jetHist.fill(HIST("eventLoss/hEventStatistics"), 6.5); // Pass rec INEL>0
if (isExtraEventSel) {
passExtraEventSel = true;
}

break; // Only first reco collision
if (isSel8 && isRecoVz && isExtraEventSel) {
++nSelectedRecoColls;
hasSelectedRecoColl = true;
}
}

// Final selection (all cuts passed)
if (hasRecoColl && passSel8 && passVz && passINELgt0) {
jetHist.fill(HIST("eventLoss/hEventStatistics"), 7.5); // Final Selection
jetHist.fill(HIST("eventLoss/hRecoCollPerMCCollVsCent"), nRecoColls, centrality);
jetHist.fill(HIST("eventLoss/hSelectedRecoCollPerMCCollVsCent"), nSelectedRecoColls, centrality);

if (hasRecoColl) {
jetHist.fill(HIST("eventLoss/hEventStatistics"), 3.5); // Has Reco Coll
}
if (passSel8) {
jetHist.fill(HIST("eventLoss/hEventStatistics"), 4.5); // Pass Sel8
}
if (passRecoVz) {
jetHist.fill(HIST("eventLoss/hEventStatistics"), 5.5); // Pass reco |Vz| cut
}
if (passExtraEventSel) {
jetHist.fill(HIST("eventLoss/hEventStatistics"), 6.5); // Pass extra event sel
}
if (hasSelectedRecoColl) {
jetHist.fill(HIST("eventLoss/hEventStatistics"), 7.5); // Reco selected
jetHist.fill(HIST("eventLoss/hEventStatistics"), 8.5); // Reco selected + true INEL>0
}

auto mcParticles_perColl = mcParticles.sliceBy(perMCCol, mcCollision.globalIndex());
for (const auto& mcParticle : mcParticles_perColl) {
if (!mcParticle.isPhysicalPrimary())
continue;

// Apply kinematic cuts similar to track selection
if (std::fabs(mcParticle.eta()) > cfgtrkMaxEta)
continue;
if (std::fabs(mcParticle.y()) > cfgtrkMaxRap)
continue;

int particleType = mapPDGToValue(mcParticle.pdgCode());
if (particleType == 0)
continue; // Only interested particles

// Fill INEL>0 specific histograms
if (mcINELgt0) {
jetHist.fill(HIST("eventLoss/signalLoss/h3GenParticlesPtVsEtaVsCent_TrueINELgt0"), mcParticle.pt(), mcParticle.eta(), centrality);
jetHist.fill(HIST("eventLoss/signalLoss/h3GenParticleTypeVsPtVsCent_TrueINELgt0"), mcParticle.pt(), particleType, centrality);
}
jetHist.fill(HIST("eventLoss/signalLoss/h3GenParticlesPtVsEtaVsCent_TrueINELgt0"), mcParticle.pt(), mcParticle.eta(), centrality);
jetHist.fill(HIST("eventLoss/signalLoss/h3GenParticleTypeVsPtVsCent_TrueINELgt0"), mcParticle.pt(), particleType, centrality);

// Fill generated particle histograms (rec events)
if (hasRecoColl && passSel8 && passVz && passINELgt0) {
if (hasSelectedRecoColl) {
jetHist.fill(HIST("eventLoss/signalLoss/h3GenParticlesPtVsEtaVsCent_INELgt0"), mcParticle.pt(), mcParticle.eta(), centrality);
jetHist.fill(HIST("eventLoss/signalLoss/h3GenParticleTypeVsPtVsCent_INELgt0"), mcParticle.pt(), particleType, centrality);
}
Expand Down
Loading