Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PWGLF: Fix bug in MCGen process function of cascadeflow task #7949

Merged
merged 2 commits into from
Oct 11, 2024
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
147 changes: 89 additions & 58 deletions PWGLF/TableProducer/Strangeness/cascadeflow.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ using std::array;
using DauTracks = soa::Join<aod::DauTrackExtras, aod::DauTrackTPCPIDs>;
using CollEventPlane = soa::Join<aod::StraCollisions, aod::StraCents, aod::StraEvSels, aod::StraFT0CQVs, aod::StraRawCents, aod::StraFT0CQVsEv, aod::StraTPCQVs>::iterator;
using CollEventPlaneCentralFW = soa::Join<aod::StraCollisions, aod::StraCents, aod::StraEvSels, aod::StraFT0CQVs, aod::StraRawCents, aod::StraTPCQVs>::iterator;
using MCCollisionsStra = soa::Join<aod::StraMCCollisions, aod::StraMCCollMults>;
using CascCandidates = soa::Join<aod::CascCollRefs, aod::CascCores, aod::CascExtras, aod::CascBBs>;
using CascMCCandidates = soa::Join<aod::CascCollRefs, aod::CascCores, aod::CascExtras, aod::CascBBs, aod::CascMCMothers, aod::CascCoreMCLabels>;
using CascMCCandidates = soa::Join<aod::CascCollRefs, aod::CascCores, aod::CascExtras, aod::CascBBs, aod::CascCoreMCLabels>;

namespace cascadev2
{
Expand Down Expand Up @@ -147,6 +148,7 @@ struct cascadeFlow {
Configurable<float> nsigmatpcPi{"nsigmatpcPi", 5, "nsigmatpcPi"};
Configurable<float> mintpccrrows{"mintpccrrows", 70, "mintpccrrows"};
Configurable<float> etaCascMCGen{"etaCascMCGen", 0.8, "etaCascMCGen"};
Configurable<float> yCascMCGen{"yCascMCGen", 0.5, "yCascMCGen"};

Configurable<std::string> ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
Configurable<std::vector<std::string>> modelPathsCCDBXi{"modelPathsCCDBXi", std::vector<std::string>{"Users/c/chdemart/CascadesFlow"}, "Paths of models on CCDB"};
Expand Down Expand Up @@ -257,9 +259,9 @@ struct cascadeFlow {
return phi;
}

HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject};
HistogramRegistry histosMCGen{"histosMCGen", {}, OutputObjHandlingPolicy::AnalysisObject};
HistogramRegistry resolution{"resolution", {}, OutputObjHandlingPolicy::AnalysisObject};
HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject, false, true};
HistogramRegistry histosMCGen{"histosMCGen", {}, OutputObjHandlingPolicy::AnalysisObject, false, true};
HistogramRegistry resolution{"resolution", {}, OutputObjHandlingPolicy::AnalysisObject, false, true};

// Tables to produce
Produces<aod::CascTraining> trainingSample;
Expand Down Expand Up @@ -352,6 +354,7 @@ struct cascadeFlow {
const AxisSpec v2Axis{200, -1., 1., "#it{v}_{2}"};
const AxisSpec CentAxis{18, 0., 90., "FT0C centrality percentile"};
TString hNEventsLabels[8] = {"All", "sel8", "z vrtx", "kNoSameBunchPileup", "kIsGoodZvtxFT0vsPV", "trackOccupancyInTimeRange", "kNoCollInTimeRange", "kIsGoodEventEP"};
TString hNEventsLabelsMC[5] = {"All", "z vtx", ">=1RecoColl", "1Reco", "2Reco"};

resolution.add("QVectorsT0CTPCA", "QVectorsT0CTPCA", HistType::kTH2F, {axisQVs, CentAxis});
resolution.add("QVectorsT0CTPCC", "QVectorsT0CTPCC", HistType::kTH2F, {axisQVs, CentAxis});
Expand Down Expand Up @@ -386,9 +389,16 @@ struct cascadeFlow {
histos.add("hv2CEPvsFT0C", "hv2CEPvsFT0C", HistType::kTH2F, {CentAxis, {100, -1, 1}});
histos.add("hv2CEPvsv2CSP", "hv2CEPvsV2CSP", HistType::kTH2F, {{100, -1, 1}, {100, -1, 1}});

histosMCGen.add("h2DGenXi", "h2DGenXi", HistType::kTH2F, {{100, 0, 00}, {200, 0, 20}});
histosMCGen.add("h2DGenOmega", "h2DGenOmega", HistType::kTH2F, {{100, 0, 100}, {200, 0, 20}});
histosMCGen.add("hGenEta", "hGenEta", HistType::kTH1F, {{100, -1, 1}});
histosMCGen.add("h2DGenXiEta08", "h2DGenXiEta08", HistType::kTH2F, {{100, 0, 00}, {200, 0, 20}});
histosMCGen.add("h2DGenOmegaEta08", "h2DGenOmegaEta08", HistType::kTH2F, {{100, 0, 100}, {200, 0, 20}});
histosMCGen.add("h2DGenXiY05", "h2DGenXiY05", HistType::kTH2F, {{100, 0, 00}, {200, 0, 20}});
histosMCGen.add("h2DGenOmegaY05", "h2DGenOmegaY05", HistType::kTH2F, {{100, 0, 100}, {200, 0, 20}});
histosMCGen.add("hGenXiY", "hGenXiY", HistType::kTH1F, {{100, -1, 1}});
histosMCGen.add("hGenOmegaY", "hGenOmegaY", HistType::kTH1F, {{100, -1, 1}});
histosMCGen.add("hNEventsMC", "hNEventsMC", {HistType::kTH1F, {{5, 0.f, 5.f}}});
for (Int_t n = 1; n <= histosMCGen.get<TH1>(HIST("hNEventsMC"))->GetNbinsX(); n++) {
histosMCGen.get<TH1>(HIST("hNEventsMC"))->GetXaxis()->SetBinLabel(n, hNEventsLabelsMC[n - 1]);
}

for (int iS{0}; iS < 2; ++iS) {
cascadev2::hMassBeforeSelVsPt[iS] = histos.add<TH2>(Form("hMassBeforeSelVsPt%s", cascadev2::speciesNames[iS].data()), "hMassBeforeSelVsPt", HistType::kTH2F, {massCascAxis[iS], ptAxis});
Expand Down Expand Up @@ -773,6 +783,7 @@ struct cascadeFlow {
continue;

auto cascMC = casc.cascMCCore_as<soa::Join<aod::CascMCCores, aod::CascMCCollRefs>>();

int pdgCode{cascMC.pdgCode()};
if (!(std::abs(pdgCode) == 3312 && std::abs(cascMC.pdgCodeV0()) == 3122 && std::abs(cascMC.pdgCodeBachelor()) == 211) // Xi
&& !(std::abs(pdgCode) == 3334 && std::abs(cascMC.pdgCodeV0()) == 3122 && std::abs(cascMC.pdgCodeBachelor()) == 321)) // Omega
Expand Down Expand Up @@ -852,63 +863,83 @@ struct cascadeFlow {
fillAnalysedTable(coll, casc, v2CSP, v2CEP, PsiT0C, BDTresponse[0], BDTresponse[1], pdgCode);
}
}
void processMCGen(soa::Join<aod::StraMCCollisions, aod::StraMCCollMults>::iterator const& mcCollision, soa::Join<aod::StraCollisions, aod::StraCents, aod::StraEvSels, aod::StraCollLabels> const& collisions, soa::Join<aod::CascMCCores, aod::CascMCCollRefs> const& CascMCCores)
{
// Generated with accepted z vertex
if (TMath::Abs(mcCollision.posZ()) > cutzvertex) {
return;
}

// Check if there is at least one of the reconstructed collisions associated to this MC collision
auto groupedCollisions = collisions.sliceBy(perMcCollision, mcCollision.globalIndex());
int biggestNContribs = -1;
int bestCollisionIndex = -1;
float centrality = 100.5f;
int nCollisions = 0;
for (auto const& collision : groupedCollisions) {
void processMCGen(MCCollisionsStra const& mcCollisions, soa::Join<aod::StraCollisions, aod::StraCents, aod::StraEvSels, aod::StraCollLabels> const& collisions, soa::Join<aod::CascMCCores, aod::CascMCCollRefs> const& CascMCCores)
{

if (!AcceptEvent(collision)) {
continue;
}
if (biggestNContribs < collision.multPVTotalContributors()) {
biggestNContribs = collision.multPVTotalContributors();
bestCollisionIndex = collision.globalIndex();
centrality = collision.centFT0C();
for (auto const& mcCollision : mcCollisions) {
histosMCGen.fill(HIST("hNEventsMC"), 0.5);
// Generated with accepted z vertex
if (TMath::Abs(mcCollision.posZ()) > cutzvertex) {
return;
}
nCollisions++;
}
if (nCollisions < 1) {
return;
}
for (auto const& cascMC : CascMCCores) {
if (!cascMC.has_straMCCollision())
continue;
histosMCGen.fill(HIST("hNEventsMC"), 1.5);
// Check if there is at least one of the reconstructed collisions associated to this MC collision

if (!cascMC.isPhysicalPrimary())
continue;

float ptmc = RecoDecay::sqrtSumOfSquares(cascMC.pxMC(), cascMC.pyMC());

float theta = std::atan(ptmc / cascMC.pzMC()); //-pi/2 < theta < pi/2
auto groupedCollisions = collisions.sliceBy(perMcCollision, mcCollision.globalIndex());

float theta1 = 0;

// if pz is positive (i.e. positive rapidity): 0 < theta < pi/2
if (theta > 0)
theta1 = theta; // 0 < theta1/2 < pi/4 --> 0 < tan (theta1/2) < 1 --> positive eta
// if pz is negative (i.e. negative rapidity): -pi/2 < theta < 0 --> we need 0 < theta1/2 < pi/2 for the ln to be defined
else
theta1 = TMath::Pi() + theta; // pi/2 < theta1 < pi --> pi/4 < theta1/2 < pi/2 --> 1 < tan (theta1/2) --> negative eta

float cascMCeta = -log(std::tan(theta1 / 2));
if (TMath::Abs(cascMCeta) > etaCascMCGen)
continue;
histosMCGen.fill(HIST("hGenEta"), cascMCeta);
int biggestNContribs = -1;
int bestCollisionIndex = -1;
float centrality = 100.5f;
int nCollisions = 0;
for (auto const& collision : groupedCollisions) {

if (TMath::Abs(cascMC.pdgCode()) == 3312) {
histosMCGen.fill(HIST("h2dGenXi"), centrality, ptmc);
} else if (TMath::Abs(cascMC.pdgCode() == 3334)) {
histosMCGen.fill(HIST("h2dGenOmega"), centrality, ptmc);
if (!AcceptEvent(collision)) {
continue;
}
if (biggestNContribs < collision.multPVTotalContributors()) {
biggestNContribs = collision.multPVTotalContributors();
bestCollisionIndex = collision.globalIndex();
centrality = collision.centFT0C();
}
nCollisions++;
}
if (nCollisions < 1) {
return;
}
histosMCGen.fill(HIST("hNEventsMC"), 2.5);
if (nCollisions == 1)
histosMCGen.fill(HIST("hNEventsMC"), 3.5);
else if (nCollisions == 2)
histosMCGen.fill(HIST("hNEventsMC"), 4.5);
for (auto const& cascMC : CascMCCores) {
if (!cascMC.has_straMCCollision())
continue;

if (!cascMC.isPhysicalPrimary())
continue;

float ptmc = RecoDecay::sqrtSumOfSquares(cascMC.pxMC(), cascMC.pyMC());

float theta = std::atan(ptmc / cascMC.pzMC()); //-pi/2 < theta < pi/2

float theta1 = 0;

// if pz is positive (i.e. positive rapidity): 0 < theta < pi/2
if (theta > 0)
theta1 = theta; // 0 < theta1/2 < pi/4 --> 0 < tan (theta1/2) < 1 --> positive eta
// if pz is negative (i.e. negative rapidity): -pi/2 < theta < 0 --> we need 0 < theta1/2 < pi/2 for the ln to be defined
else
theta1 = TMath::Pi() + theta; // pi/2 < theta1 < pi --> pi/4 < theta1/2 < pi/2 --> 1 < tan (theta1/2) --> negative eta

float cascMCeta = -log(std::tan(theta1 / 2));
float cascMCy = 0;

if (TMath::Abs(cascMC.pdgCode()) == 3312) {
cascMCy = RecoDecay::y(std::array{cascMC.pxMC(), cascMC.pyMC(), cascMC.pzMC()}, constants::physics::MassXiMinus);
if (TMath::Abs(cascMCeta) < etaCascMCGen)
histosMCGen.fill(HIST("h2DGenXiEta08"), centrality, ptmc);
if (TMath::Abs(cascMCy) < yCascMCGen)
histosMCGen.fill(HIST("h2DGenXiY05"), centrality, ptmc);
histosMCGen.fill(HIST("hGenXiY"), cascMCy);
} else if (TMath::Abs(cascMC.pdgCode() == 3334)) {
cascMCy = RecoDecay::y(std::array{cascMC.pxMC(), cascMC.pyMC(), cascMC.pzMC()}, constants::physics::MassOmegaMinus);
if (TMath::Abs(cascMCeta) < etaCascMCGen)
histosMCGen.fill(HIST("h2DGenOmegaEta08"), centrality, ptmc);
if (TMath::Abs(cascMCy) < yCascMCGen)
histosMCGen.fill(HIST("h2DGenOmegaY05"), centrality, ptmc);
histosMCGen.fill(HIST("hGenOmegaY"), cascMCy);
}
}
}
}
Expand Down
Loading