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
209 changes: 153 additions & 56 deletions PWGLF/Tasks/Strangeness/nonPromptCascade.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@
#include "ReconstructionDataFormats/Vertex.h"

#include "Math/Vector4D.h"
#include "TDatabasePDG.h"

Check failure on line 39 in PWGLF/Tasks/Strangeness/nonPromptCascade.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/database]

Do not use TDatabasePDG directly. Use o2::constants::physics::Mass... or Service<o2::framework::O2DatabasePDG> instead.
#include "THnSparse.h"
#include "TParticlePDG.h"
#include "TTree.h"

#include <cmath>
#include <memory>
Expand Down Expand Up @@ -142,13 +144,13 @@
if (particle.has_mothers()) {
auto mom = particle.template mothers_as<aod::McParticles>()[0];
int pdgCodeMom = mom.pdgCode();
fromBeauty = std::abs(pdgCodeMom) / 5000 == 1 || std::abs(pdgCodeMom) / 500 == 1 || std::abs(pdgCodeMom) == 5;

Check failure on line 147 in PWGLF/Tasks/Strangeness/nonPromptCascade.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.
fromCharm = std::abs(pdgCodeMom) / 4000 == 1 || std::abs(pdgCodeMom) / 400 == 1 || std::abs(pdgCodeMom) == 4;

Check failure on line 148 in PWGLF/Tasks/Strangeness/nonPromptCascade.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.
while (mom.has_mothers()) {
const auto grandma = mom.template mothers_as<aod::McParticles>()[0];
int pdgCodeGrandma = std::abs(grandma.pdgCode());
fromBeauty = fromBeauty || (pdgCodeGrandma / 5000 == 1 || pdgCodeGrandma / 500 == 1 || pdgCodeGrandma == 5);

Check failure on line 152 in PWGLF/Tasks/Strangeness/nonPromptCascade.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.
fromCharm = fromCharm || (pdgCodeGrandma / 4000 == 1 || pdgCodeGrandma / 400 == 1 || pdgCodeGrandma == 4);

Check failure on line 153 in PWGLF/Tasks/Strangeness/nonPromptCascade.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.
mom = grandma;
}
}
Expand Down Expand Up @@ -185,6 +187,7 @@
using CollisionCandidatesRun3 = soa::Join<aod::Collisions, aod::EvSels, aod::FT0Mults, aod::FV0Mults, aod::CentFT0Cs, aod::CentFV0As, aod::CentFT0Ms, aod::MultsGlobal>;
using CollisionCandidatesRun3MC = soa::Join<aod::Collisions, aod::McCollisionLabels, aod::EvSels, aod::FT0Mults, aod::FV0Mults, aod::CentFT0Cs, aod::CentFV0As, aod::CentFT0Ms, aod::MultsGlobal>;
using CollisionsWithLabel = soa::Join<aod::Collisions, aod::McCollisionLabels, aod::MultsGlobal>;
using TracksWithLabel = soa::Join<aod::Tracks, aod::McTrackLabels>;

Preslice<TracksExtData> perCollision = aod::track::collisionId;
Preslice<TracksExtMC> perCollisionMC = aod::track::collisionId;
Expand Down Expand Up @@ -212,8 +215,7 @@

Configurable<float> cfgMaxMult{"cfgMaxMult", 8000.f, "Upper range of multiplicty histo"};
Configurable<float> cfgMaxMultFV0{"cfgMaxMultFV0", 10000.f, "Upper range of multiplicty FV0 histo"};
Configurable<float> cfgMinMult{"cfgMinMult", 3000.f, "Lower range of FT0M histo in zoomed histo"};
Configurable<float> cfgMaxCent{"cfgMaxCent", 8.0025f, "Upper range of FT0M histo"};
Configurable<std::string> cfgPtEdgesdNdeta{"ptEdges", "0,0.2,0.4,0.6,0.8,1,1.2,1.6,2.0,2.4,2.8,3.2,3.6,4,4.5,5,5.5,6,7,8,10", "Pt bin edges (comma-separated)"};

Zorro mZorro;
OutputObj<ZorroSummary> mZorroSummary{"ZorroSummary"};
Expand All @@ -225,23 +227,11 @@
o2::vertexing::DCAFitterN<2> mDCAFitter;
std::array<int, 2> mProcessCounter = {0, 0}; // {Tracked, All}
std::map<uint64_t, uint32_t> mToiMap;
std::unordered_map<std::string, std::shared_ptr<TH2>> mHistsPerRunMultVsCent;
std::unordered_map<std::string, std::shared_ptr<TH2>> mHistsPerRunMultVsCentZoom;
std::unordered_map<std::string, std::shared_ptr<TH2>> mHistsPerRunNtracktVsCent;
std::unordered_map<std::string, std::shared_ptr<TH2>> mHistsPerRunNtracktVsCentZoom;

int nBinsMult = cfgMaxMult;
int nBinsMultFV0 = cfgMaxMultFV0;
int nBinsMultZoom = cfgMaxMult - cfgMinMult;
int nBinsCentZoom = (cfgMaxCent + 0.0025) / 0.005;

AxisSpec multAxis = {nBinsMult, 0, cfgMaxMult, "Multiplicity FT0M"};
AxisSpec multAxisFV0 = {nBinsMultFV0, 0, cfgMaxMultFV0, "Multiplicity FT0M"};
AxisSpec centAxis = {101, -0.025, 101.025, "Centrality"};
AxisSpec centAxisZoom = {nBinsCentZoom, -0.0025, cfgMaxCent, "Centrality"};
AxisSpec multAxisZoom = {nBinsMultZoom, cfgMinMult, cfgMaxMult, "Multiplicity FT0M"};
AxisSpec nTracksAxis = {100, 0., 100., "NTracksGlobal"};
AxisSpec nTracksAxisMC = {100, 0., 100., "NTracksMC"};
//
HistogramRegistry mRegistryMults{"Multhistos"};
HistogramRegistry mRegistrydNdeta{"dNdetahistos"};

//

void initCCDB(aod::BCsWithTimestamps::iterator const& bc)
{
Expand All @@ -262,7 +252,7 @@
}
}

void init(InitContext const&)
void init(InitContext& context)
{
mZorroSummary.setObject(mZorro.getZorroSummary());
mCCDB->setURL(ccdbUrl);
Expand All @@ -283,18 +273,77 @@
std::array<std::string, 7> cutsNames{"# candidates", "hasTOF", "nClusTPC", "nSigmaTPCbach", "nSigmaTPCprotontrack", "nSigmaTPCpiontrack", "cosPA"};
auto cutsOmega{std::get<std::shared_ptr<TH2>>(mRegistry.add("h_PIDcutsOmega", ";;Invariant mass (GeV/#it{c}^{2})", HistType::kTH2D, {{cutsNames.size(), -0.5, -0.5 + cutsNames.size()}, {125, 1.650, 1.700}}))};
auto cutsXi{std::get<std::shared_ptr<TH2>>(mRegistry.add("h_PIDcutsXi", ";;Invariant mass (GeV/#it{c}^{2})", HistType::kTH2D, {{6, -0.5, 5.5}, {125, 1.296, 1.346}}))};
mRegistry.add("hMultVsCent", "hMultVsCent", HistType::kTH2F, {centAxis, multAxis});
mRegistry.add("hMultVsCentZoom", "hMultVsCentZoom", HistType::kTH2F, {centAxisZoom, multAxisZoom});
mRegistry.add("hNTracksVsCent", "hNTracksVsCent", HistType::kTH2F, {centAxis, nTracksAxis});
mRegistry.add("hNTracksVsCentZoom", "hNTracksVsCentZoom", HistType::kTH2F, {centAxisZoom, nTracksAxis});
mRegistry.add("hMultFV0VshNTracks", "hMultFV0VshNTracks", HistType::kTH2F, {nTracksAxis, multAxisFV0});
mRegistry.add("hNTracksVsCentFV0A", "hNTracksVsCentFV0A", HistType::kTH2F, {nTracksAxis, centAxis});
mRegistry.add("hNTracksMCVsTracksReco", "hNTracksMCVsTracksReco", HistType::kTH2F, {nTracksAxisMC, nTracksAxis});
mRegistry.add("hNTracksMCNotInReco", "hNTracksMCNotInReco", HistType::kTH1F, {nTracksAxisMC});
for (size_t iBin{0}; iBin < cutsNames.size(); ++iBin) {
cutsOmega->GetYaxis()->SetBinLabel(iBin + 1, cutsNames[iBin].c_str());
cutsXi->GetYaxis()->SetBinLabel(iBin + 1, cutsNames[iBin].c_str());
}
//
int nBinsMult = cfgMaxMult;
int nBinsMultFV0 = cfgMaxMultFV0;

AxisSpec multAxis = {nBinsMult, 0, cfgMaxMult, "Multiplicity FT0M"};
AxisSpec multAxisFV0 = {nBinsMultFV0, 0, cfgMaxMultFV0, "Multiplicity FT0M"};
AxisSpec nTracksAxis = {100, 0., 100., "NTracksGlobal"};
AxisSpec nTracksAxisMC = {100, 0., 100., "NTracksMC"};
std::vector<double> centBinning;
std::vector<double> multBinning;
std::vector<double> trackBinning;
std::vector<double> runsBinning;
double cent = -0.0;
while (cent < 100) {
if (cent < 0.1) {
centBinning.push_back(cent);
cent += 0.01;
} else if (cent < 1) {
centBinning.push_back(cent);
cent += 0.1;
} else {
centBinning.push_back(cent);
cent += 1;
}
}
double ntracks = 0;
while (ntracks < 100) {
trackBinning.push_back(ntracks);
ntracks++;
}
double run = 550367 - 0.5;
for (int i = 0; i < 9000; i++) {
runsBinning.push_back(run);
run++;
}
AxisSpec centAxis{centBinning, "Centrality (%)"};
// AxisSpec multAxis{multBinning, "Multiplicity"};
AxisSpec trackAxisMC{trackBinning, "NTracks MC"};
AxisSpec trackAxis{trackBinning, "NTracks Global Reco"};
AxisSpec runsAxis{runsBinning, "Run Number"};

mRegistryMults.add("hCentMultsRuns", "hCentMultsRuns", HistType::kTHnSparseF, {centAxis, multAxis, centAxis, multAxisFV0, nTracksAxis, runsAxis});
//
// dN/deta
//
bool runMCdNdeta = context.options().get<bool>("processdNdetaMC");
// std::cout << "runMCdNdeta: " << runMCdNdeta << std::endl;
if (runMCdNdeta) {
std::vector<double> ptBins;
std::vector<std::string> tokens = o2::utils::Str::tokenize(cfgPtEdgesdNdeta, ',');
for (auto const& pts : tokens) {
double pt = 0;
try {
pt = std::stof(pts);
} catch (...) {
LOG(error) << "Wrong cfgPtEdgesdNdeta string:" << cfgPtEdgesdNdeta << std::endl;
}
ptBins.push_back(pt);
}
AxisSpec ptAxisMC{ptBins, "pT MC"};
AxisSpec ptAxisReco{ptBins, "pT Reco"};

// multMeasured, multMC, ptMeasured, ptMC
mRegistrydNdeta.add("hdNdetaRM/hdNdetaRM", "hdNdetaRM", HistType::kTHnSparseF, {nTracksAxisMC, nTracksAxis, ptAxisMC, ptAxisReco});
mRegistrydNdeta.add("hdNdetaRM/hdNdetaRMNotInRecoCol", "hdNdetaRMNotInRecoCol", HistType::kTHnSparseF, {nTracksAxisMC, ptAxisMC});
mRegistrydNdeta.add("hdNdetaRM/hdNdetaRMNotInRecoTrk", "hdNdetaRMNotInRecoTrk", HistType::kTHnSparseF, {nTracksAxisMC, ptAxisMC});
}
}

template <typename CollisionType, typename TrackType>
Expand Down Expand Up @@ -361,27 +410,13 @@
{
// std::cout << "Filling mult histos" << std::endl;
for (const auto& coll : collisions) {
std::string histNameMvC = "mult/hMultVsCent_run" + std::to_string(mRunNumber);
std::string histNameMvCZ = "mult/hMultVsCentZoom_run" + std::to_string(mRunNumber);
std::string histNameTvC = "mult/hNTracksVsCent_run" + std::to_string(mRunNumber);
std::string histNameTvCZ = "mult/hNTracksVsCentZoom_run" + std::to_string(mRunNumber);
if (!mHistsPerRunMultVsCent.contains(histNameMvC)) {
mHistsPerRunMultVsCent[histNameMvC] = std::get<std::shared_ptr<TH2>>(mRegistry.add(histNameMvC.c_str(), histNameMvC.c_str(), HistType::kTH2F, {centAxis, multAxis}));
mHistsPerRunMultVsCentZoom[histNameMvCZ] = std::get<std::shared_ptr<TH2>>(mRegistry.add(histNameMvCZ.c_str(), histNameMvCZ.c_str(), HistType::kTH2F, {centAxisZoom, multAxisZoom}));
mHistsPerRunNtracktVsCent[histNameTvC] = std::get<std::shared_ptr<TH2>>(mRegistry.add(histNameTvC.c_str(), histNameTvC.c_str(), HistType::kTH2F, {centAxis, nTracksAxis}));
mHistsPerRunNtracktVsCentZoom[histNameTvCZ] = std::get<std::shared_ptr<TH2>>(mRegistry.add(histNameTvCZ.c_str(), histNameTvCZ.c_str(), HistType::kTH2F, {centAxisZoom, nTracksAxis}));
}
mHistsPerRunMultVsCent[histNameMvC]->Fill(coll.centFT0M(), coll.multFT0M());
mHistsPerRunMultVsCentZoom[histNameMvCZ]->Fill(coll.centFT0M(), coll.multFT0M());
mHistsPerRunNtracktVsCent[histNameTvC]->Fill(coll.centFT0M(), coll.multNTracksGlobal());
mHistsPerRunNtracktVsCentZoom[histNameTvCZ]->Fill(coll.centFT0M(), coll.multNTracksGlobal());
// run integrated histos
mRegistry.fill(HIST("hMultVsCent"), coll.centFT0M(), coll.multFT0M());
mRegistry.fill(HIST("hMultVsCentZoom"), coll.centFT0M(), coll.multFT0M());
mRegistry.fill(HIST("hNTracksVsCent"), coll.centFT0M(), (float)coll.multNTracksGlobal());
mRegistry.fill(HIST("hNTracksVsCentZoom"), coll.centFT0M(), coll.multNTracksGlobal());
mRegistry.fill(HIST("hMultFV0VshNTracks"), coll.multNTracksGlobal(), coll.multFV0A());
mRegistry.fill(HIST("hNTracksVsCentFV0A"), coll.multNTracksGlobal(), coll.centFV0A());
float centFT0M = coll.centFT0M();
float multFT0M = coll.multFT0M();
float centFV0A = coll.centFV0A();
float multFV0A = coll.multFV0A();
float multNTracks = coll.multNTracksGlobal();
float run = mRunNumber;
mRegistryMults.fill(HIST("hCentMultsRuns"), centFT0M, multFT0M, centFV0A, multFV0A, multNTracks, run);
}
};

Expand Down Expand Up @@ -524,13 +559,13 @@
if (protonTrack.mcParticle().has_mothers() && pionTrack.mcParticle().has_mothers() && bachelor.mcParticle().has_mothers()) {
if (protonTrack.mcParticle().mothersIds()[0] == pionTrack.mcParticle().mothersIds()[0]) {
const auto v0part = protonTrack.mcParticle().template mothers_first_as<aod::McParticles>();
if (std::abs(v0part.pdgCode()) == 3122 && v0part.has_mothers()) {

Check failure on line 562 in PWGLF/Tasks/Strangeness/nonPromptCascade.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.
const auto motherV0 = v0part.template mothers_as<aod::McParticles>()[0];
if (v0part.mothersIds()[0] == bachelor.mcParticle().mothersIds()[0]) {
if (std::abs(motherV0.pdgCode()) == 3312 || std::abs(motherV0.pdgCode()) == 3334) {

Check failure on line 565 in PWGLF/Tasks/Strangeness/nonPromptCascade.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.
isGoodCascade = true;

isOmega = (std::abs(motherV0.pdgCode()) == 3334);

Check failure on line 568 in PWGLF/Tasks/Strangeness/nonPromptCascade.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.
fromHF = isFromHF(motherV0);
mcParticleID = v0part.mothersIds()[0];
}
Expand Down Expand Up @@ -758,7 +793,7 @@
}
PROCESS_SWITCH(NonPromptCascadeTask, processCascadesData, "process cascades: Data analysis", false);

int getMCMult(aod::McParticles const& mcParticles, int mcCollId)
int getMCMult(aod::McParticles const& mcParticles, int mcCollId, std::vector<float>& ptMCvec)
{
int mult = 0;
for (auto const& mcp : mcParticles) {
Expand All @@ -767,7 +802,7 @@
bool accept = mcp.isPhysicalPrimary();
accept = accept && (mcp.eta() < 0.5) && (mcp.eta() > -0.5);
int q = 0;
auto pdgEntry = TDatabasePDG::Instance()->GetParticle(mcp.pdgCode());

Check failure on line 805 in PWGLF/Tasks/Strangeness/nonPromptCascade.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/database]

Do not use TDatabasePDG directly. Use o2::constants::physics::Mass... or Service<o2::framework::O2DatabasePDG> instead.
if (pdgEntry) {
q = int(std::round(pdgEntry->Charge() / 3.0));
} else {
Expand All @@ -776,35 +811,97 @@
accept = accept && (q != 0);
if (accept) {
++mult;
ptMCvec.push_back(mcp.pt());
}
}
}
return mult;
}
void processNegMC(CollisionsWithLabel const& colls, aod::McCollisions const& mcCollisions, aod::McParticles const& mcParticles)
void processdNdetaMC(CollisionsWithLabel const& colls, aod::McCollisions const& mcCollisions, aod::McParticles const& mcParticles, TracksWithLabel const& tracks)
{
// std::cout << "ProcNegMC" << std::endl;
// Map: collision index -> reco multiplicity
std::vector<int> recoMult(colls.size(), 0);
for (auto const& trk : tracks) {
int collId = trk.collisionId();
// Here you can impose same track cuts as for MC (eta, primaries, etc.)
if (std::abs(trk.eta()) > 0.5f) {
continue;
}
++recoMult[collId];
}
std::vector<int> isReco(mcParticles.size(), 0);
std::vector<int> isRecoMult(mcParticles.size(), 0);
std::vector<int> mcReconstructed(mcCollisions.size(), 0);
// std::cout << " reco cols with mc:" << colls.size() << " tracks:" << tracks.size() << " mccols:" << mcCollisions.size() << "mcParticles:" << mcParticles.size() << std::endl;
for (auto const& col : colls) {
int mcCollId = col.mcCollisionId(); // col.template mcCollision_as<aod::McCollisions>();
int collId = col.globalIndex();
// auto mc = col.mcCollision();
// int mcId = mc.globalIndex();
// std::cout << "globalIndex:" << mcId << " colID:" << mcCollId << std::endl;
int mult = getMCMult(mcParticles, mcCollId);
std::vector<float> mcptvec;
float mult = getMCMult(mcParticles, mcCollId, mcptvec);
mcReconstructed[mcCollId] = 1;
mRegistry.fill(HIST("hNTracksMCVsTracksReco"), mult, col.multNTracksGlobal());
for (auto const& trk : tracks) {
int mcPid = trk.mcParticleId(); // depends on your label table
if (mcPid >= 0 && mcPid < (int)mcParticles.size()) {
isReco[mcPid] = 1;
isRecoMult[mcPid] = mult;
} else {
continue;
}
if (trk.collisionId() != collId) {
continue; // different event
}
auto mcPar = mcParticles.rawIteratorAt(mcPid);
// Apply same acceptance as in MC multiplicity
if (!mcPar.isPhysicalPrimary()) {
continue;
}
if (std::abs(mcPar.eta()) > 0.5f) {
continue;
}
int q = 0;
auto pdgEntry = TDatabasePDG::Instance()->GetParticle(mcPar.pdgCode());

Check failure on line 866 in PWGLF/Tasks/Strangeness/nonPromptCascade.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/database]

Do not use TDatabasePDG directly. Use o2::constants::physics::Mass... or Service<o2::framework::O2DatabasePDG> instead.
if (pdgEntry) {
q = int(std::round(pdgEntry->Charge() / 3.0));
}
if (q == 0) {
continue;
}
// float multReco = recoMult[collId];
float multReco = col.multNTracksGlobal();
float ptReco = trk.pt();
float ptMC = mcPar.pt();
mRegistrydNdeta.fill(HIST("hdNdetaRM/hdNdetaRM"), mult, multReco, ptMC, ptReco);
}

// mRegistry.fill(HIST("hNTracksMCVsTracksReco"), mult, col.multNTracksGlobal());
}
// count mc particles with no reco tracks
for (auto const& mcp : mcParticles) {
int mcPidG = mcp.globalIndex();
// std::cout << "mcPidG:" << mcPidG << std::endl;
if (!isReco[mcPidG]) {
mRegistrydNdeta.fill(HIST("hdNdetaRM/hdNdetaRMNotInRecoTrk"), isRecoMult[mcPidG], mcp.pt());
}
}
// count unreconstructed mc collisions
for (auto const& mc : mcCollisions) {
int gindex = mc.globalIndex();
// std::cout << "mc globalIndex:" << gindex << std::endl;
if (!mcReconstructed[gindex]) {
int mult = getMCMult(mcParticles, gindex);
std::vector<float> mcptvec;
int mult = getMCMult(mcParticles, gindex, mcptvec);
// std::cout << "===> unreconstructed:" << mult << std::endl;
mRegistry.fill(HIST("hNTracksMCNotInReco"), mult);
for (auto const& pt : mcptvec) {
mRegistrydNdeta.fill(HIST("hdNdetaRM/hdNdetaRMNotInRecoCol"), mult, pt);
}
}
}
}
PROCESS_SWITCH(NonPromptCascadeTask, processNegMC, "process mc", false);
PROCESS_SWITCH(NonPromptCascadeTask, processdNdetaMC, "process mc dN/deta", false);
};

WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
Expand Down
Loading