Skip to content

Commit

Permalink
Addition of data model info for mothers
Browse files Browse the repository at this point in the history
  • Loading branch information
ddobrigk committed Dec 3, 2023
1 parent b9bf561 commit a31bda4
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 49 deletions.
30 changes: 30 additions & 0 deletions PWGLF/DataModel/LFStrangenessTables.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,21 @@ DECLARE_SOA_TABLE(DauTrackExtras, "AOD", "DAUTRACKEXTRA", //! detector propertie

using DauTrackExtra = DauTrackExtras::iterator;

namespace motherParticle
{
DECLARE_SOA_COLUMN(Px, px, float); //! px
DECLARE_SOA_COLUMN(Py, py, float); //! py
DECLARE_SOA_COLUMN(Pz, pz, float); //! pz
DECLARE_SOA_COLUMN(PDGCode, pdgCode, int); //! pdg code
DECLARE_SOA_COLUMN(IsPhysicalPrimary, isPhysicalPrimary, bool); //! primary criterion
}

DECLARE_SOA_TABLE(MotherMCParticles, "AOD", "MOTHERMCPART", //! mother MC information
motherParticle::Px, motherParticle::Py, motherParticle::Pz,
motherParticle::PDGCode, motherParticle::IsPhysicalPrimary);

using MotherMCParticle = MotherMCParticles::iterator;

namespace v0data
{
//______________________________________________________
Expand All @@ -106,6 +121,7 @@ DECLARE_SOA_INDEX_COLUMN(V0, v0); //!
DECLARE_SOA_INDEX_COLUMN_FULL(PosTrackExtra, posTrackExtra, int, DauTrackExtras, "_PosExtra"); //!
DECLARE_SOA_INDEX_COLUMN_FULL(NegTrackExtra, negTrackExtra, int, DauTrackExtras, "_NegExtra"); //!
DECLARE_SOA_INDEX_COLUMN(StraCollision, straCollision); //!
DECLARE_SOA_INDEX_COLUMN(MotherMCParticle, motherMCParticle); //!

//______________________________________________________
// REGULAR COLUMNS FOR V0CORES
Expand Down Expand Up @@ -377,11 +393,16 @@ DECLARE_SOA_TABLE(V0MCCores, "AOD", "V0MCCORE", //! MC properties of the V0 for
v0data::PxPosMC, v0data::PyPosMC, v0data::PzPosMC,
v0data::PxNegMC, v0data::PyNegMC, v0data::PzNegMC);

DECLARE_SOA_TABLE(V0MCMothers, "AOD", "V0MCMOTHER", //! optional table for MC mothers
o2::soa::Index<>, v0data::MotherMCParticleId);

using V0Index = V0Indices::iterator;
using V0Core = V0Cores::iterator;
using V0TrackX = V0TrackXs::iterator;
using V0Datas = soa::Join<V0Indices, V0TrackXs, V0Cores>;
using V0Data = V0Datas::iterator;
using V0MCDatas = soa::Join<V0MCCores, V0MCMothers>;
using V0MCData = V0MCDatas::iterator;

// definitions of indices for interlink tables
namespace v0data
Expand Down Expand Up @@ -462,6 +483,7 @@ DECLARE_SOA_INDEX_COLUMN_FULL(NegTrackExtra, negTrackExtra, int, DauTrackExtras,
DECLARE_SOA_INDEX_COLUMN_FULL(BachTrackExtra, bachTrackExtra, int, DauTrackExtras, "_BachExtra"); //!
DECLARE_SOA_INDEX_COLUMN_FULL(StrangeTrackExtra, strangeTrackExtra, int, DauTrackExtras, "_StrangeExtra"); //!
DECLARE_SOA_INDEX_COLUMN(StraCollision, straCollision); //!
DECLARE_SOA_INDEX_COLUMN(MotherMCParticle, motherMCParticle); //!

//______________________________________________________
// REGULAR COLUMNS FOR CASCCORES
Expand Down Expand Up @@ -755,6 +777,9 @@ DECLARE_SOA_TABLE(CascMCCores, "AOD", "CASCMCCORE", //! bachelor-baryon correlat
cascdata::PxBachMC, cascdata::PyBachMC, cascdata::PzBachMC,
cascdata::PxMC, cascdata::PyMC, cascdata::PzMC);

DECLARE_SOA_TABLE(CascMCMothers, "AOD", "CASCMCMOTHER", //! optional table for MC mothers
o2::soa::Index<>, cascdata::MotherMCParticleId);

DECLARE_SOA_TABLE(CascBBs, "AOD", "CASCBB", //! bachelor-baryon correlation variables
cascdata::BachBaryonCosPA, cascdata::BachBaryonDCAxyToPV)

Expand Down Expand Up @@ -811,6 +836,11 @@ using CascData = CascDatas::iterator;
using KFCascData = KFCascDatas::iterator;
using TraCascData = TraCascDatas::iterator;

using CascMCCore = CascMCCores::iterator;
using CascMCMother = CascMCMothers::iterator;
using CascMCDatas = soa::Join<CascMCCores, CascMCMothers>;
using CascMCData = CascMCDatas::iterator;

// For compatibility with previous table declarations
using CascDataFull = CascDatas;
using CascDataExt = CascDatas;
Expand Down
33 changes: 17 additions & 16 deletions PWGLF/TableProducer/cascademcbuilder.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,22 @@ struct cascademcbuilder {
// build cascade labels
void processCascades(aod::CascDatas const& casctable, aod::V0sLinked const&, aod::V0Datas const& v0table, aod::McTrackLabels const&, aod::McParticles const&)
{
int pdgCode = -1, pdgCodeMother = -1;
int pdgCodePositive = -1, pdgCodeNegative = -1, pdgCodeBachelor = -1, pdgCodeV0 = -1;
bool isPhysicalPrimary = false;
float xmc = -999.0f, ymc = -999.0f, zmc = -999.0f;
float xlmc = -999.0f, ylmc = -999.0f, zlmc = -999.0f;
float pxposmc = -999.0f, pyposmc = -999.0f, pzposmc = -999.0f;
float pxnegmc = -999.0f, pynegmc = -999.0f, pznegmc = -999.0f;
float pxbachmc = -999.0f, pybachmc = -999.0f, pzbachmc = -999.0f;
float px = -999.0f, py = -999.0f, pz = -999.0f;
for (auto& casc : casctable) {
int pdgCode = -1, pdgCodeMother = -1;
int pdgCodePositive = -1, pdgCodeNegative = -1, pdgCodeBachelor = -1, pdgCodeV0 = -1;
bool isPhysicalPrimary = false;
float xmc = -999.0f, ymc = -999.0f, zmc = -999.0f;
float xlmc = -999.0f, ylmc = -999.0f, zlmc = -999.0f;
float pxposmc = -999.0f, pyposmc = -999.0f, pzposmc = -999.0f;
float pxnegmc = -999.0f, pynegmc = -999.0f, pznegmc = -999.0f;
float pxbachmc = -999.0f, pybachmc = -999.0f, pzbachmc = -999.0f;
float px = -999.0f, py = -999.0f, pz = -999.0f;

// Loop over those that actually have the corresponding V0 associated to them
auto v0 = casc.v0_as<o2::aod::V0sLinked>();
if (!(v0.has_v0Data())) {
casclabels(-1);
continue; // skip those cascades for which V0 doesn't exist
continue; // skip those cascades for which V0 doesn't exist (but: should never happen)
}
auto v0data = v0.v0Data(); // de-reference index to correct v0data in case it exists
int lLabel = -1;
Expand Down Expand Up @@ -109,9 +110,9 @@ struct cascademcbuilder {
for (auto& lPosMother : lMCPosTrack.mothers_as<aod::McParticles>()) {
if (lNegMother == lPosMother) {
// acquire information
xlmc = lNegMother.vx();
ylmc = lNegMother.vy();
zlmc = lNegMother.vz();
xlmc = lMCPosTrack.vx();
ylmc = lMCPosTrack.vy();
zlmc = lMCPosTrack.vz();
pdgCodeV0 = lNegMother.pdgCode();

// if we got to this level, it means the mother particle exists and is the same
Expand All @@ -122,9 +123,9 @@ struct cascademcbuilder {
lLabel = lV0Mother.globalIndex();
pdgCode = lV0Mother.pdgCode();
isPhysicalPrimary = lV0Mother.isPhysicalPrimary();
xmc = lV0Mother.vx();
ymc = lV0Mother.vy();
zmc = lV0Mother.vz();
xmc = lMCBachTrack.vx();
ymc = lMCBachTrack.vy();
zmc = lMCBachTrack.vz();
px = lV0Mother.px();
py = lV0Mother.py();
pz = lV0Mother.pz();
Expand Down
26 changes: 14 additions & 12 deletions PWGLF/TableProducer/lambdakzerobuilder.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -652,18 +652,20 @@ struct lambdakzeroBuilder {
auto lPtAnHy = RecoDecay::sqrtSumOfSquares(v0candidate.posP[0] + 2.0f * v0candidate.negP[0], v0candidate.posP[1] + 2.0f * v0candidate.negP[1]);

// Fill basic mass histograms
if ((V0.isdEdxGamma() || dEdxUnchecked) && (V0.isTrueGamma() || mcUnchecked))
registry.fill(HIST("h2dGammaMass"), lPt, lGammaMass);
if ((V0.isdEdxK0Short() || dEdxUnchecked) && (V0.isTrueK0Short() || mcUnchecked))
registry.fill(HIST("h2dK0ShortMass"), lPt, lK0ShortMass);
if ((V0.isdEdxLambda() || dEdxUnchecked) && (V0.isTrueLambda() || mcUnchecked))
registry.fill(HIST("h2dLambdaMass"), lPt, lLambdaMass);
if ((V0.isdEdxAntiLambda() || dEdxUnchecked) && (V0.isTrueAntiLambda() || mcUnchecked))
registry.fill(HIST("h2dAntiLambdaMass"), lPt, lAntiLambdaMass);
if ((V0.isdEdxHypertriton() || dEdxUnchecked) && (V0.isTrueHypertriton() || mcUnchecked))
registry.fill(HIST("h2dHypertritonMass"), lPtHy, lHypertritonMass);
if ((V0.isdEdxAntiHypertriton() || dEdxUnchecked) && (V0.isTrueAntiHypertriton() || mcUnchecked))
registry.fill(HIST("h2dAntiHypertritonMass"), lPtAnHy, lAntiHypertritonMass);
if( TMath::Abs(RecoDecay::eta(std::array{px, py, pz}))<0.5 ) {
if ((V0.isdEdxGamma() || dEdxUnchecked) && (V0.isTrueGamma() || mcUnchecked))
registry.fill(HIST("h2dGammaMass"), lPt, lGammaMass);
if ((V0.isdEdxK0Short() || dEdxUnchecked) && (V0.isTrueK0Short() || mcUnchecked))
registry.fill(HIST("h2dK0ShortMass"), lPt, lK0ShortMass);
if ((V0.isdEdxLambda() || dEdxUnchecked) && (V0.isTrueLambda() || mcUnchecked))
registry.fill(HIST("h2dLambdaMass"), lPt, lLambdaMass);
if ((V0.isdEdxAntiLambda() || dEdxUnchecked) && (V0.isTrueAntiLambda() || mcUnchecked))
registry.fill(HIST("h2dAntiLambdaMass"), lPt, lAntiLambdaMass);
if ((V0.isdEdxHypertriton() || dEdxUnchecked) && (V0.isTrueHypertriton() || mcUnchecked))
registry.fill(HIST("h2dHypertritonMass"), lPtHy, lHypertritonMass);
if ((V0.isdEdxAntiHypertriton() || dEdxUnchecked) && (V0.isTrueAntiHypertriton() || mcUnchecked))
registry.fill(HIST("h2dAntiHypertritonMass"), lPtAnHy, lAntiHypertritonMass);
}

// Fill ITS cluster maps with specific mass cuts
if (TMath::Abs(lGammaMass - 0.0) < dQAGammaMassWindow && ((V0.isdEdxGamma() || dEdxUnchecked) && (V0.isTrueGamma() || mcUnchecked))) {
Expand Down
16 changes: 8 additions & 8 deletions PWGLF/TableProducer/lambdakzeromcbuilder.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ struct lambdakzeromcbuilder {
// build V0 labels
void process(aod::V0Datas const& v0table, aod::McTrackLabels const&, aod::McParticles const& particlesMC)
{
int pdgCode = -1, pdgCodeMother = -1, pdgCodePositive = -1, pdgCodeNegative = -1;
bool isPhysicalPrimary = false;
float xmc = -999.0f, ymc = -999.0f, zmc = -999.0f;
float pxposmc = -999.0f, pyposmc = -999.0f, pzposmc = -999.0f;
float pxnegmc = -999.0f, pynegmc = -999.0f, pznegmc = -999.0f;
for (auto& v0 : v0table) {
int lLabel = -1;
int pdgCode = -1, pdgCodeMother = -1, pdgCodePositive = -1, pdgCodeNegative = -1;
bool isPhysicalPrimary = false;
float xmc = -999.0f, ymc = -999.0f, zmc = -999.0f;
float pxposmc = -999.0f, pyposmc = -999.0f, pzposmc = -999.0f;
float pxnegmc = -999.0f, pynegmc = -999.0f, pznegmc = -999.0f;

auto lNegTrack = v0.negTrack_as<aod::McTrackLabels>();
auto lPosTrack = v0.posTrack_as<aod::McTrackLabels>();
Expand All @@ -83,9 +83,9 @@ struct lambdakzeromcbuilder {
if (lNegMother.globalIndex() == lPosMother.globalIndex()) {
lLabel = lNegMother.globalIndex();
// acquire information
xmc = lNegMother.vx();
ymc = lNegMother.vy();
zmc = lNegMother.vz();
xmc = lMCPosTrack.vx();
ymc = lMCPosTrack.vy();
zmc = lMCPosTrack.vz();
pdgCode = lNegMother.pdgCode();
isPhysicalPrimary = lNegMother.isPhysicalPrimary();
if (lNegMother.has_mothers()) {
Expand Down
12 changes: 7 additions & 5 deletions PWGLF/TableProducer/lambdakzeromcfinder.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ struct lambdakzeromcfinder {
Configurable<float> yPreFilter{"yPreFilter", 2.5, "broad y pre-filter for speed"};
ConfigurableAxis axisPtQA{"axisPtQA", {VARIABLE_WIDTH, 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.2f, 2.4f, 2.6f, 2.8f, 3.0f, 3.2f, 3.4f, 3.6f, 3.8f, 4.0f, 4.4f, 4.8f, 5.2f, 5.6f, 6.0f, 6.5f, 7.0f, 7.5f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 17.0f, 19.0f, 21.0f, 23.0f, 25.0f, 30.0f, 35.0f, 40.0f, 50.0f}, "pt axis for QA histograms"};

Configurable<bool> doNotRequireTPC{"doNotRequireTPC", true, "do not require TPC for V0 MC finding"};

Preslice<aod::McParticle> perMcCollision = aod::mcparticle::mcCollisionId;

std::vector<int> v0collisionId;
Expand Down Expand Up @@ -244,7 +246,7 @@ struct lambdakzeromcfinder {
if (track.mcParticleId() == daughter.globalIndex()) {
if (track.hasITS())
positiveITS = true;
if (track.hasTPC()) {
if (track.hasTPC() || doNotRequireTPC) {
positiveTPC = true;
trackIndexPositive = track.globalIndex(); // assign only if TPC present
posPt = track.pt();
Expand All @@ -259,7 +261,7 @@ struct lambdakzeromcfinder {
if (track.mcParticleId() == daughter.globalIndex()) {
if (track.hasITS())
negativeITS = true;
if (track.hasTPC()) {
if (track.hasTPC() || doNotRequireTPC) {
negativeTPC = true;
trackIndexNegative = track.globalIndex(); // assign only if TPC present
negPt = track.pt();
Expand Down Expand Up @@ -319,7 +321,7 @@ struct lambdakzeromcfinder {
bool reconstructed = false;
for (auto& mcParticle : mcParticles) {
if (fabs(mcParticle.y()) > yPreFilter)
continue; // go declarative at a later stage but pre-filter here
continue; // go declarative at a later stage but pre-filter here

if (mcParticle.pdgCode() == 22 && findGamma) {
reconstructed = ProcessV0(mcParticle, tracks, bestCollisionIndex, positiveITS, negativeITS, positiveTPC, negativeTPC, positiveTPCITS, negativeTPCITS);
Expand Down Expand Up @@ -431,7 +433,7 @@ struct lambdakzeromcfinder {
continue;
for (auto& posMotherParticle : posParticle.mothers_as<aod::McParticles>()) {
// determine if mother particle satisfies any condition curently being searched for
for (uint16_t ipdg = 0; ipdg < searchedV0PDG.size(); ipdg++)
for (int ipdg = 0; ipdg < searchedV0PDG.size(); ipdg++)
if (searchedV0PDG[ipdg] == posMotherParticle.pdgCode()) {
v0pdgIndex = ipdg; // index mapping to desired V0 species
motherIndex = posMotherParticle.globalIndex();
Expand All @@ -450,7 +452,7 @@ struct lambdakzeromcfinder {
if (!negParticle.has_mothers())
continue;
for (auto& negMotherParticle : negParticle.mothers_as<aod::McParticles>()) {
if (negMotherParticle.globalIndex() == posMotherParticle.globalIndex() && negMotherParticle.pdgCode() == searchedV0NegativePDG[v0pdgIndex]) {
if (negMotherParticle.globalIndex() == posMotherParticle.globalIndex() && negParticle.pdgCode() == searchedV0NegativePDG[v0pdgIndex]) {
// de-reference best collision
int bestCollisionIndex = -1;
auto mcCollision = posParticle.mcCollision_as<soa::Join<aod::McCollisions, aod::McCollsExtra>>();
Expand Down
41 changes: 41 additions & 0 deletions PWGLF/TableProducer/strangederivedbuilder.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ struct strangederivedbuilder {
Produces<aod::TraToCascRefs> traToCascRefs; // tracked -> cascades
Produces<aod::KFToCascRefs> kfToCascRefs; // KF -> cascades

//__________________________________________________
// mother information
Produces<aod::V0MCMothers> v0mothers; // V0 mother references
Produces<aod::CascMCMothers> cascmothers; // casc mother references
Produces<aod::MotherMCParticles> motherMCParticles; //mc particles for mothers

// histogram registry for bookkeeping
HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject};

Expand Down Expand Up @@ -319,6 +325,40 @@ struct strangederivedbuilder {
// done!
}

void processStrangeMothers(soa::Join<aod::V0Datas, aod::McV0Labels> const& V0s, soa::Join<aod::CascDatas, aod::McCascLabels> const& Cascades, aod::McParticles const& mcParticles)
{
std::vector<int> motherReference(mcParticles.size(), -1); // index -1: not used / no reference

//__________________________________________________
// mark mcParticles for referencing
for (auto const& v0 : V0s)
motherReference[v0.mcParticleId()] = 0;
for (auto const& ca : Cascades)
motherReference[ca.mcParticleId()] = 0;
//__________________________________________________
// Figure out the numbering of the new mcMother table
// assume filling per order
int nParticles = 0;
for (int i = 0; i < motherReference.size(); i++) {
if (motherReference[i] >= 0) {
motherReference[i] = nParticles++; // count particles of interest
}
}
//__________________________________________________
// populate track references
for (auto const& v0 : V0s)
v0mothers(motherReference[v0.mcParticleId()]); // joinable with V0Datas
for (auto const& ca : Cascades)
cascmothers(motherReference[ca.mcParticleId()]); // joinable with CascDatas
//__________________________________________________
// populate motherMCParticles
for (auto const& tr : mcParticles) {
if (motherReference[tr.globalIndex()] >= 0) {
motherMCParticles(tr.px(), tr.py(), tr.pz(), tr.pdgCode(), tr.isPhysicalPrimary());
}
}
}

using interlinkedCascades = soa::Join<aod::Cascades, aod::CascDataLink, aod::KFCascDataLink, aod::TraCascDataLink>;

void processCascadeInterlinkTracked(interlinkedCascades const& masterCascades, aod::CascIndices const& Cascades, aod::TraCascIndices const& TraCascades)
Expand Down Expand Up @@ -384,6 +424,7 @@ struct strangederivedbuilder {
PROCESS_SWITCH(strangederivedbuilder, processCollisions, "Produce collisions (V0s + casc)", true);
PROCESS_SWITCH(strangederivedbuilder, processTrackExtrasV0sOnly, "Produce track extra information (V0s only)", true);
PROCESS_SWITCH(strangederivedbuilder, processTrackExtras, "Produce track extra information (V0s + casc)", true);
PROCESS_SWITCH(strangederivedbuilder, processStrangeMothers, "Produce tables with mother info for V0s + casc", true);
PROCESS_SWITCH(strangederivedbuilder, processCascadeInterlinkTracked, "Produce tables interconnecting cascades", false);
PROCESS_SWITCH(strangederivedbuilder, processCascadeInterlinkKF, "Produce tables interconnecting cascades", false);
PROCESS_SWITCH(strangederivedbuilder, processSimulation, "Produce simulated information", true);
Expand Down
Loading

0 comments on commit a31bda4

Please sign in to comment.