Skip to content

Commit 32e844a

Browse files
ChiaraDeMartin95Chiara De Martin
andauthored
Add process function to compute fraction of primary lambdas (#14507)
Co-authored-by: Chiara De Martin <chdemart@alicecerno2.cern.ch>
1 parent 052ce4f commit 32e844a

File tree

1 file changed

+125
-0
lines changed

1 file changed

+125
-0
lines changed

PWGLF/TableProducer/Strangeness/cascadeflow.cxx

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ using CollEventAndSpecPlane = soa::Join<aod::StraCollisions, aod::StraCents, aod
5252
using CollEventAndSpecPlaneCentralFW = soa::Join<aod::StraCollisions, aod::StraCents, aod::StraEvSels, aod::StraFT0CQVs, aod::StraTPCQVs, aod::StraZDCSP, aod::StraStamps>::iterator;
5353
using MCCollisionsStra = soa::Join<aod::StraMCCollisions, aod::StraMCCollMults>;
5454
using V0Candidates = soa::Join<aod::V0CollRefs, aod::V0Cores, aod::V0Extras>;
55+
using V0MCCandidates = soa::Join<aod::V0CollRefs, aod::V0Cores, aod::V0Extras, aod::V0CoreMCLabels>;
5556
using CascCandidates = soa::Join<aod::CascCollRefs, aod::CascCores, aod::CascExtras, aod::CascBBs>;
5657
using CascMCCandidates = soa::Join<aod::CascCollRefs, aod::CascCores, aod::CascExtras, aod::CascBBs, aod::CascCoreMCLabels>;
5758

@@ -92,6 +93,7 @@ const double AlphaLambda[2] = {0.747, -0.757}; // decay parameter of Lambda and
9293

9394
std::shared_ptr<TH2> hMassBeforeSelVsPt[nCharges];
9495
std::shared_ptr<TH2> hMassAfterSelVsPt[nCharges];
96+
std::shared_ptr<TH2> hMassAfterSelVsPtTrue[nCharges];
9597
} // namespace lambdav2
9698

9799
namespace cascade_flow_cuts_ml
@@ -927,6 +929,8 @@ struct cascadeFlow {
927929
const AxisSpec thnAxisCosThetaOmegaAlpha{thnAxisConfigs.thnConfigAxisCosThetaOmegaAlpha, "CosThetaOmegaWithAlpha"};
928930
const AxisSpec thnAxisCosThetaProtonAlpha{thnAxisConfigs.thnConfigAxisCosThetaProtonAlpha, "CosThetaProtonWithAlpha"};
929931

932+
histos.add("hCentvsPtvsPrimaryFracLambda", "hCentvsPtvsPrimaryFracLambda", HistType::kTH3F, {{100, 0, 100}, thnAxisPtLambda, {4, -0.5, 3.5}});
933+
histos.add("hCentvsPrimaryFracLambda", "hCentvsPrimaryFracLambda", HistType::kTH2F, {{100, 0, 100}, {4, -0.5, 3.5}});
930934
histos.add("massXi_ProtonAcc", "massXi", HistType::kTH1F, {thnAxisMassXi});
931935
histos.add("massOmega_ProtonAcc", "massOmega", HistType::kTH1F, {thnAxisMassOmega});
932936

@@ -1025,6 +1029,7 @@ struct cascadeFlow {
10251029
for (int iS{0}; iS < nCharges; ++iS) {
10261030
lambdav2::hMassBeforeSelVsPt[iS] = histos.add<TH2>(Form("hMassBeforeSelVsPt%s", lambdav2::speciesNames[iS].data()), "hMassBeforeSelVsPt", HistType::kTH2F, {massLambdaAxis[iS], ptAxisLambda});
10271031
lambdav2::hMassAfterSelVsPt[iS] = histos.add<TH2>(Form("hMassAfterSelVsPt%s", lambdav2::speciesNames[iS].data()), "hMassAfterSelVsPt", HistType::kTH2F, {massLambdaAxis[iS], ptAxisLambda});
1032+
lambdav2::hMassAfterSelVsPtTrue[iS] = histos.add<TH2>(Form("hMassAfterSelVsPtTrue%s", lambdav2::speciesNames[iS].data()), "hMassAfterSelVsPtTrue", HistType::kTH2F, {massLambdaAxis[iS], ptAxisLambda});
10281033
}
10291034

10301035
if (isApplyML) {
@@ -2498,6 +2503,125 @@ struct cascadeFlow {
24982503
}
24992504
}
25002505

2506+
void processMCPrimaryLambdaFraction(soa::Join<aod::StraCollisions, aod::StraCents, aod::StraEvSels>::iterator const& coll, V0MCCandidates const& V0s, DauTracks const&, soa::Join<aod::V0MCCores, aod::V0MCCollRefs> const&)
2507+
{
2508+
2509+
Float_t collisionCentrality = 0;
2510+
if (isCollisionCentrality == 0) { // T0C
2511+
collisionCentrality = coll.centFT0C();
2512+
} else if (isCollisionCentrality == 1) { // T0M
2513+
collisionCentrality = coll.centFT0M();
2514+
}
2515+
2516+
histos.fill(HIST("hEventCentralityBefEvSel"), collisionCentrality);
2517+
2518+
if (!AcceptEvent(coll, 1)) {
2519+
return;
2520+
}
2521+
2522+
// no EP requirements as in MC we do not have EP info
2523+
histos.fill(HIST("hNEvents"), 9.5);
2524+
histos.fill(HIST("hEventCentrality"), collisionCentrality);
2525+
histos.fill(HIST("hEventVertexZ"), coll.posZ());
2526+
2527+
for (auto const& v0 : V0s) {
2528+
2529+
/// Add some minimal cuts for single track variables (min number of TPC clusters)
2530+
auto negExtra = v0.negTrackExtra_as<DauTracks>();
2531+
auto posExtra = v0.posTrackExtra_as<DauTracks>();
2532+
2533+
int counterLambda = 0;
2534+
int counterALambda = 0;
2535+
bool isLambdaCandidate = 0;
2536+
bool isALambdaCandidate = 0;
2537+
2538+
// check if v0 has MC info
2539+
if (!v0.has_v0MCCore())
2540+
continue;
2541+
2542+
//-- selections ------------------------------------------------------------
2543+
if (isLambdaAccepted(negExtra, posExtra, counterLambda))
2544+
isLambdaCandidate = 1;
2545+
if (isAntiLambdaAccepted(negExtra, posExtra, counterALambda))
2546+
isALambdaCandidate = 1;
2547+
histos.fill(HIST("hLambdaDauSel"), counterLambda);
2548+
histos.fill(HIST("hALambdaDauSel"), counterALambda);
2549+
2550+
if (v0.pt() < V0Configs.MinPtV0 || v0.pt() > V0Configs.MaxPtV0) {
2551+
continue;
2552+
}
2553+
2554+
float massV0[nCharges]{v0.mLambda(), v0.mAntiLambda()};
2555+
lambdav2::hMassBeforeSelVsPt[0]->Fill(massV0[0], v0.pt());
2556+
lambdav2::hMassBeforeSelVsPt[1]->Fill(massV0[1], v0.pt());
2557+
2558+
bool isSelectedV0[2]{false, false};
2559+
if (isV0TopoAccepted(v0) && isLambdaCandidate)
2560+
isSelectedV0[0] = true;
2561+
if (isV0TopoAccepted(v0) && isALambdaCandidate)
2562+
isSelectedV0[1] = true;
2563+
2564+
if (isSelectedV0[0] && !isSelectedV0[1]) { // Lambdas
2565+
histos.fill(HIST("hLambdaCandidate"), 0);
2566+
}
2567+
if (isSelectedV0[1] && !isSelectedV0[0]) { // AntiLambdas
2568+
histos.fill(HIST("hLambdaCandidate"), 1);
2569+
}
2570+
if (isSelectedV0[0] && isSelectedV0[1]) {
2571+
histos.fill(HIST("hLambdaCandidate"), 2);
2572+
if (v0.mLambda() > V0Configs.MinMassLambda && v0.mLambda() < V0Configs.MaxMassLambda && v0.mAntiLambda() > V0Configs.MinMassLambda && v0.mAntiLambda() < V0Configs.MaxMassLambda) {
2573+
histos.fill(HIST("hLambdaCandidate"), 3);
2574+
continue; // in case of ambiguity between Lambda and AntiLambda, I skip the particle; checked to be zero in range 1.105 - 1.125
2575+
}
2576+
if (!(v0.mLambda() > V0Configs.MinMassLambda && v0.mLambda() < V0Configs.MaxMassLambda) && !(v0.mAntiLambda() > V0Configs.MinMassLambda && v0.mAntiLambda() < V0Configs.MaxMassLambda))
2577+
histos.fill(HIST("hLambdaCandidate"), 4); // bkg candidates
2578+
}
2579+
if (!isSelectedV0[0] && !isSelectedV0[1])
2580+
continue;
2581+
2582+
lambdav2::hMassAfterSelVsPt[0]->Fill(massV0[0], v0.pt());
2583+
lambdav2::hMassAfterSelVsPt[1]->Fill(massV0[1], v0.pt());
2584+
//--------------------------------------------------------------
2585+
2586+
auto v0MC = v0.v0MCCore_as<soa::Join<aod::V0MCCores, aod::V0MCCollRefs>>();
2587+
int pdgCode{v0MC.pdgCode()};
2588+
// select true lambdas
2589+
bool isTrueLambda = 0;
2590+
bool isTrueALambda = 0;
2591+
if (pdgCode == PDG_t::kLambda0 && v0MC.pdgCodePositive() == PDG_t::kProton && v0MC.pdgCodeNegative() == PDG_t::kPiMinus)
2592+
isTrueLambda = 1;
2593+
else if (pdgCode == PDG_t::kLambda0Bar && v0MC.pdgCodePositive() == PDG_t::kPiPlus && v0MC.pdgCodeNegative() == PDG_t::kProtonBar)
2594+
isTrueALambda = 1;
2595+
if (!isTrueLambda && !isTrueALambda)
2596+
continue;
2597+
if (isTrueLambda)
2598+
lambdav2::hMassAfterSelVsPtTrue[0]->Fill(massV0[0], v0.pt());
2599+
if (isTrueALambda)
2600+
lambdav2::hMassAfterSelVsPtTrue[1]->Fill(massV0[1], v0.pt());
2601+
2602+
bool isPrimary = v0MC.isPhysicalPrimary();
2603+
2604+
// histo for primary fraction
2605+
if (isTrueLambda) {
2606+
if (isPrimary) {
2607+
histos.fill(HIST("hCentvsPtvsPrimaryFracLambda"), collisionCentrality, v0.pt(), 0);
2608+
histos.fill(HIST("hCentvsPrimaryFracLambda"), collisionCentrality, 0);
2609+
} else {
2610+
histos.fill(HIST("hCentvsPtvsPrimaryFracLambda"), collisionCentrality, v0.pt(), 1);
2611+
histos.fill(HIST("hCentvsPrimaryFracLambda"), collisionCentrality, 1);
2612+
}
2613+
} else if (isTrueALambda) {
2614+
if (isPrimary) {
2615+
histos.fill(HIST("hCentvsPtvsPrimaryFracLambda"), collisionCentrality, v0.pt(), 2);
2616+
histos.fill(HIST("hCentvsPrimaryFracLambda"), collisionCentrality, 2);
2617+
} else {
2618+
histos.fill(HIST("hCentvsPtvsPrimaryFracLambda"), collisionCentrality, v0.pt(), 3);
2619+
histos.fill(HIST("hCentvsPrimaryFracLambda"), collisionCentrality, 3);
2620+
}
2621+
}
2622+
}
2623+
}
2624+
25012625
PROCESS_SWITCH(cascadeFlow, processTrainingBackground, "Process to create the training dataset for the background", true);
25022626
PROCESS_SWITCH(cascadeFlow, processTrainingSignal, "Process to create the training dataset for the signal", false);
25032627
PROCESS_SWITCH(cascadeFlow, processAnalyseData, "Process to apply ML model to the data", false);
@@ -2506,6 +2630,7 @@ struct cascadeFlow {
25062630
PROCESS_SWITCH(cascadeFlow, processAnalyseLambdaEP2CentralFW, "Process to measure flow and polarization of Lambda - event plane calibration from central framework", false);
25072631
PROCESS_SWITCH(cascadeFlow, processAnalyseMC, "Process to apply ML model to the MC", false);
25082632
PROCESS_SWITCH(cascadeFlow, processMCGen, "Process to store MC generated particles", false);
2633+
PROCESS_SWITCH(cascadeFlow, processMCPrimaryLambdaFraction, "Process to compute primary lambda fraction", false);
25092634
};
25102635

25112636
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)

0 commit comments

Comments
 (0)