From ee3c278ec9067fdaf73dd1b8cfa907898e0d491c Mon Sep 17 00:00:00 2001 From: Daiki Sekihata Date: Fri, 31 Oct 2025 20:41:30 +0100 Subject: [PATCH] PWGEM/Dilepton: add status code in mc particle table --- PWGEM/Dilepton/DataModel/dileptonTables.h | 24 +++++++- .../TableProducer/associateMCinfoDilepton.cxx | 2 +- .../Dilepton/Tasks/Converters/CMakeLists.txt | 5 ++ .../Tasks/Converters/mcParticleConverter1.cxx | 61 +++++++++++++++++++ PWGEM/Dilepton/Utils/MCUtilities.h | 5 +- .../TableProducer/associateMCinfoPhoton.cxx | 17 +++--- 6 files changed, 102 insertions(+), 12 deletions(-) create mode 100644 PWGEM/Dilepton/Tasks/Converters/mcParticleConverter1.cxx diff --git a/PWGEM/Dilepton/DataModel/dileptonTables.h b/PWGEM/Dilepton/DataModel/dileptonTables.h index a3bff9027b1..e63969edfda 100644 --- a/PWGEM/Dilepton/DataModel/dileptonTables.h +++ b/PWGEM/Dilepton/DataModel/dileptonTables.h @@ -301,7 +301,7 @@ DECLARE_SOA_DYNAMIC_COLUMN(Y, y, //! Particle rapidity } // namespace emmcparticle // This table contains all MC truth tracks -DECLARE_SOA_TABLE_FULL(EMMCParticles, "EMMCParticles", "AOD", "EMMCPARTICLE", //! MC track information (on disk) +DECLARE_SOA_TABLE_FULL(EMMCParticles_000, "EMMCParticles", "AOD", "EMMCPARTICLE", //! MC track information (on disk) o2::soa::Index<>, emmcparticle::EMMCEventId, mcparticle::PdgCode, mcparticle::Flags, emmcparticle::MothersIds, emmcparticle::DaughtersIds, @@ -312,13 +312,33 @@ DECLARE_SOA_TABLE_FULL(EMMCParticles, "EMMCParticles", "AOD", "EMMCPARTICLE", // emmcparticle::Pt, emmcparticle::Eta, emmcparticle::Phi, - emmcparticle::P, emmcparticle::Y, mcparticle::ProducedByGenerator, mcparticle::FromBackgroundEvent, mcparticle::IsPhysicalPrimary); +DECLARE_SOA_TABLE_VERSIONED(EMMCParticles_001, "AOD", "EMMCPARTICLE", 1, //! MC track information (on disk) + o2::soa::Index<>, emmcparticle::EMMCEventId, + mcparticle::PdgCode, mcparticle::Flags, mcparticle::StatusCode, + emmcparticle::MothersIds, emmcparticle::DaughtersIds, + mcparticle::Px, mcparticle::Py, mcparticle::Pz, mcparticle::E, + mcparticle::Vx, mcparticle::Vy, mcparticle::Vz, + + // dynamic column + emmcparticle::Pt, + emmcparticle::Eta, + emmcparticle::Phi, + emmcparticle::P, + emmcparticle::Y, + mcparticle::ProducedByGenerator, + mcparticle::FromBackgroundEvent, + mcparticle::IsPhysicalPrimary, + mcparticle::GetGenStatusCode, + mcparticle::GetHepMCStatusCode, + mcparticle::GetProcess); + +using EMMCParticles = EMMCParticles_001; using EMMCParticle = EMMCParticles::iterator; namespace emmcgenvectormeson diff --git a/PWGEM/Dilepton/TableProducer/associateMCinfoDilepton.cxx b/PWGEM/Dilepton/TableProducer/associateMCinfoDilepton.cxx index 92078356fd6..1b4044f4bf3 100644 --- a/PWGEM/Dilepton/TableProducer/associateMCinfoDilepton.cxx +++ b/PWGEM/Dilepton/TableProducer/associateMCinfoDilepton.cxx @@ -625,7 +625,7 @@ struct AssociateMCInfoDilepton { } } - emmcparticles(fEventIdx.find(oldLabel)->second, mctrack.pdgCode(), mctrack.flags(), + emmcparticles(fEventIdx.find(oldLabel)->second, mctrack.pdgCode(), mctrack.flags(), mctrack.statusCode(), mothers, daughters, mctrack.px(), mctrack.py(), mctrack.pz(), mctrack.e(), mctrack.vx(), mctrack.vy(), mctrack.vz()); diff --git a/PWGEM/Dilepton/Tasks/Converters/CMakeLists.txt b/PWGEM/Dilepton/Tasks/Converters/CMakeLists.txt index 489839883ec..5653dbd4e83 100644 --- a/PWGEM/Dilepton/Tasks/Converters/CMakeLists.txt +++ b/PWGEM/Dilepton/Tasks/Converters/CMakeLists.txt @@ -50,3 +50,8 @@ o2physics_add_dpl_workflow(muon-converter1 PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(mcparticle-converter1 + SOURCES mcParticleConverter1.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + diff --git a/PWGEM/Dilepton/Tasks/Converters/mcParticleConverter1.cxx b/PWGEM/Dilepton/Tasks/Converters/mcParticleConverter1.cxx new file mode 100644 index 00000000000..5f219f459ca --- /dev/null +++ b/PWGEM/Dilepton/Tasks/Converters/mcParticleConverter1.cxx @@ -0,0 +1,61 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. +// +// ======================== +// +// This code produces emmctable table 001 from 000. +// Please write to: daiki.sekihata@cern.ch + +#include "PWGEM/Dilepton/DataModel/dileptonTables.h" + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +#include + +using namespace o2; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; + +struct mcParticleConverter1 { + Produces mcParticle_001; + + void process(aod::EMMCParticles_000 const& mcParticles) + { + for (const auto& mcParticle : mcParticles) { + // LOGF(info, "mcParticles.emmceventId() = %d, mcParticle.mothersIds().size() = %d, mcParticle.daughtersIds().size() = %d", mcParticle.emmceventId(), mcParticle.mothersIds().size(), mcParticle.daughtersIds().size()); + + std::vector mothersIds; + for (const auto& id : mcParticle.mothersIds()) { + mothersIds.emplace_back(id); + } + + std::vector daughtersIds; + for (const auto& id : mcParticle.daughtersIds()) { + daughtersIds.emplace_back(id); + } + + mcParticle_001( + mcParticle.emmceventId(), mcParticle.pdgCode(), mcParticle.flags(), 0, + mothersIds, daughtersIds, + mcParticle.px(), mcParticle.py(), mcParticle.pz(), mcParticle.e(), + mcParticle.vx(), mcParticle.vy(), mcParticle.vz()); + } // end of mc particle loop + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"mcparticle-converter1"})}; +} diff --git a/PWGEM/Dilepton/Utils/MCUtilities.h b/PWGEM/Dilepton/Utils/MCUtilities.h index ca4c095a628..bce62504aae 100644 --- a/PWGEM/Dilepton/Utils/MCUtilities.h +++ b/PWGEM/Dilepton/Utils/MCUtilities.h @@ -317,7 +317,7 @@ int IsHF(TMCParticle1 const& p1, TMCParticle2 const& p2, TMCParticles const& mcp auto mp = mcparticles.iteratorAt(motherid1); mothers_id1.emplace_back(motherid1); mothers_pdg1.emplace_back(mp.pdgCode()); - + // LOGF(info, "mp1.globalIndex() = %d, mp1.pdgCode() = %d, mp1.getGenStatusCode() = %d", mp.globalIndex(), mp.pdgCode(), mp.getGenStatusCode()); if (mp.has_mothers()) { motherid1 = mp.mothersIds()[0]; } else { @@ -337,6 +337,7 @@ int IsHF(TMCParticle1 const& p1, TMCParticle2 const& p2, TMCParticles const& mcp auto mp = mcparticles.iteratorAt(motherid2); mothers_id2.emplace_back(motherid2); mothers_pdg2.emplace_back(mp.pdgCode()); + // LOGF(info, "mp2.globalIndex() = %d, mp2.pdgCode() = %d, mp2.getGenStatusCode() = %d", mp.globalIndex(), mp.pdgCode(), mp.getGenStatusCode()); if (mp.has_mothers()) { motherid2 = mp.mothersIds()[0]; @@ -348,6 +349,8 @@ int IsHF(TMCParticle1 const& p1, TMCParticle2 const& p2, TMCParticles const& mcp } } + // require correlation between q-qbar. (not q-q) // need statusCode + bool is_direct_from_b1 = IsFromBeauty(p1, mcparticles) > 0 && IsFromCharm(p1, mcparticles) < 0; bool is_direct_from_b2 = IsFromBeauty(p2, mcparticles) > 0 && IsFromCharm(p2, mcparticles) < 0; bool is_prompt_c1 = IsFromBeauty(p1, mcparticles) < 0 && IsFromCharm(p1, mcparticles) > 0; diff --git a/PWGEM/PhotonMeson/TableProducer/associateMCinfoPhoton.cxx b/PWGEM/PhotonMeson/TableProducer/associateMCinfoPhoton.cxx index 2fafc5118e3..885a2e85a38 100644 --- a/PWGEM/PhotonMeson/TableProducer/associateMCinfoPhoton.cxx +++ b/PWGEM/PhotonMeson/TableProducer/associateMCinfoPhoton.cxx @@ -16,16 +16,17 @@ /// \author Daiki Sekihata (daiki.sekihata@cern.ch) /// -#include -#include +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" +#include "PWGEM/PhotonMeson/Utils/MCUtilities.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" #include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" #include "ReconstructionDataFormats/Track.h" -#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" -#include "PWGEM/PhotonMeson/Utils/MCUtilities.h" + +#include +#include using namespace o2; using namespace o2::framework; @@ -434,7 +435,7 @@ struct AssociateMCInfoPhoton { } } - emmcparticles(fEventIdx.find(oldLabel)->second, mcParticle.pdgCode(), mcParticle.flags(), + emmcparticles(fEventIdx.find(oldLabel)->second, mcParticle.pdgCode(), mcParticle.flags(), mcParticle.statusCode(), mothers, daughters, mcParticle.px(), mcParticle.py(), mcParticle.pz(), mcParticle.e(), mcParticle.vx(), mcParticle.vy(), mcParticle.vz());