Skip to content
Closed
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions PWGHF/DataModel/DerivedTables.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
{ \
namespace der_##_hf_namespace_ \
{ \
DECLARE_SOA_ARRAY_INDEX_COLUMN_CUSTOM(Hf##_hf_type_##CollBase, hfCollBases, "HF" _hf_description_ "COLLBASES"); /* o2-linter: disable=name/o2-column (unified getter) */ \

Check failure on line 96 in PWGHF/DataModel/DerivedTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
} \
} \
DECLARE_SOA_TABLE_STAGED(Hf##_hf_type_##McCollBases, "HF" _hf_description_ "MCCOLLBASE", \
Expand Down Expand Up @@ -162,6 +162,7 @@
DECLARE_SOA_COLUMN(FlagMcMatchGen, flagMcMatchGen, int8_t); //! flag for generator level matching
DECLARE_SOA_COLUMN(OriginMcGen, originMcGen, int8_t); //! particle origin, generator level
DECLARE_SOA_COLUMN(FlagMcDecayChanGen, flagMcDecayChanGen, int8_t); //! resonant decay channel flag, generator level
DECLARE_SOA_COLUMN(IdxMotherPart, idxMotherPart, int32_t); //! index of the mother particle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is the index useful?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need the pdg code of mother particle, at first I tried to store the pdf code of Mother Particle directly, but soon I found I also need the pt of mother particle.

So I think it's better to store the index, and then we will have all we needed variables by:

auto bHadMother = mcParticles.rawIteratorAt(mcParticle.idxBhadMotherPart() - mcParticles.offset());

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I have to say that I am not sure if this method works for jet particles table. I am still try to check this point.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe don't~
The derived table doesn't contain the Mother particle, and the index link was broken when I use the derived table right?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIU, in your example, mcParticle is HfDstarGenMcs::iterator and mcParticles is McParticles, correct?
What is your use case to have both tables at the same time?

Copy link
Contributor Author

@Mingze129 Mingze129 Jul 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to follow the example from the taskCharmPolarisation to write my own.
At line 2085 it has the same usage.

We looped over all mcParticle in mcParticles and passed both of them into the function.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But in that case, mcParticle and mcParticles come from the same table.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right.
So I also think this can not use directly. But I can't add everything to this table.
I am still working on this. Hope I can find a suitable way to do this.
Maybe I can join this extra table with aod::McParticles?

} // namespace hf_mc_particle

// Declares the base table with candidates (Bases).
Expand All @@ -170,7 +171,7 @@
{ \
namespace der_##_hf_namespace_ \
{ \
DECLARE_SOA_INDEX_COLUMN_CUSTOM(Hf##_hf_type_##CollBase, hfCollBase, "HF" _hf_description_ "COLLBASES"); /* o2-linter: disable=name/o2-column (unified getter) */ \

Check failure on line 174 in PWGHF/DataModel/DerivedTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
} \
} \
\
Expand Down Expand Up @@ -242,7 +243,7 @@
{ \
namespace der_##_hf_namespace_ \
{ \
DECLARE_SOA_INDEX_COLUMN_CUSTOM(Hf##_hf_type_##McCollBase, hfMcCollBase, "HF" _hf_description_ "MCCOLLBASES"); /* o2-linter: disable=name/o2-column (unified getter) */ \

Check failure on line 246 in PWGHF/DataModel/DerivedTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
} \
} \
DECLARE_SOA_TABLE_STAGED(Hf##_hf_type_##PBases, "HF" _hf_description_ "PBASE", \
Expand Down Expand Up @@ -492,6 +493,7 @@
DECLARE_SOA_COLUMN(MlScorePromptCharm, mlScorePromptCharm, float); //! ML score for prompt class
DECLARE_SOA_COLUMN(MlScoreNonPromptCharm, mlScoreNonPromptCharm, float); //! ML score for non-prompt class
DECLARE_SOA_COLUMN(MlScoresCharm, mlScoresCharm, std::vector<float>); //! vector of ML scores
DECLARE_SOA_COLUMN(FlagMcMatchGenCharm, flagMcMatchGenCharm, int8_t); //! flag for generator level matching
} // namespace hf_cand_mc_charm

// ----------------
Expand Down Expand Up @@ -935,6 +937,11 @@
hf_cand::NTracksDecayed,
o2::soa::Marker<MarkerDstar>);

DECLARE_SOA_TABLE_STAGED(HfDstarGenMcs, "HFDSTGENMC", //! Table with MC candidate info for generated D*+
hf_cand_mc_charm::FlagMcMatchGenCharm,
hf_mc_particle::IdxMotherPart,
o2::soa::Marker<MarkerDstar>);

// ----------------
// Ξc± → (Ξ∓ → (Λ → p π∓) π∓) π± π±
// ----------------
Expand Down
43 changes: 43 additions & 0 deletions PWGHF/TableProducer/derivedDataCreatorDstarToD0Pi.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ struct HfDerivedDataCreatorDstarToD0Pi {
Produces<o2::aod::HfDstarMls> rowCandidateMl;
Produces<o2::aod::HfDstarIds> rowCandidateId;
Produces<o2::aod::HfDstarMcs> rowCandidateMc;
Produces<o2::aod::HfDstarGenMcs> rowCandidateGenMc;

// Switches for filling tables
HfConfigurableDerivedData confDerData;
Expand All @@ -79,6 +80,7 @@ struct HfDerivedDataCreatorDstarToD0Pi {
Configurable<bool> fillCandidateMl{"fillCandidateMl", true, "Fill candidate selection ML scores"};
Configurable<bool> fillCandidateId{"fillCandidateId", true, "Fill original indices from the candidate table"};
Configurable<bool> fillCandidateMc{"fillCandidateMc", true, "Fill candidate MC info"};
Configurable<bool> fillCandidateGenMc{"fillCandidateGenMc", true, "Fill candidate generator level MC info"};
// Parameters for production of training samples
Configurable<float> downSampleBkgFactor{"downSampleBkgFactor", 1., "Fraction of background candidates to keep for ML trainings"};
Configurable<float> ptMaxForDownSample{"ptMaxForDownSample", 10., "Maximum pt for the application of the downsampling factor"};
Expand Down Expand Up @@ -204,6 +206,40 @@ struct HfDerivedDataCreatorDstarToD0Pi {
}
}

template <typename CollisionType, typename ParticleType, typename MatchMap>
void processGenMc(CollisionType const& mcCollisions,
o2::framework::Preslice<ParticleType> const& mcParticlesPerMcCollision,
ParticleType const& mcParticles,
MatchMap const& matchMap)
{
// Fill MC collision properties
for (const auto& mcCollision : mcCollisions) {
auto thisMcCollId = mcCollision.globalIndex();
auto particlesThisMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, thisMcCollId);
auto sizeTablePart = particlesThisMcColl.size();
LOGF(debug, "MC collision %d has %d MC particles", thisMcCollId, sizeTablePart);
// Skip MC collisions without HF particles (and without HF candidates in matched reconstructed collisions if saving indices of reconstructed collisions matched to MC collisions)
bool isEmpty = (matchMap.find(thisMcCollId) == matchMap.end()) || matchMap.find(thisMcCollId)->second.empty();
if (sizeTablePart == 0 && isEmpty) {
LOGF(debug, "Skipping MC collision %d", thisMcCollId);
continue;
}
reserveTable(rowCandidateGenMc, fillCandidateGenMc, sizeTablePart);
if (fillCandidateGenMc) {
for (const auto& particle : particlesThisMcColl) {
auto origin = particle.originMcGen();
int idxMotherPart = 0;
if (origin == RecoDecay::OriginType::NonPrompt) {
idxMotherPart = particle.idxBhadMotherPart();
}
rowCandidateGenMc(
particle.flagMcMatchGenD0(),
idxMotherPart);
}
}
}
}

template <bool isMl, bool isMc, bool onlyBkg, bool onlySig, typename CollType, typename CandType>
void processCandidates(CollType const& collisions,
Partition<CandType>& candidates,
Expand Down Expand Up @@ -322,6 +358,7 @@ struct HfDerivedDataCreatorDstarToD0Pi {
rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles);
processCandidates<false, true, false, true>(collisions, candidatesMcSig, tracks, bcs);
rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass);
processGenMc(mcCollisions, mcParticlesPerMcCollision, mcParticles, rowsCommon.matchedCollisions);
}
PROCESS_SWITCH(HfDerivedDataCreatorDstarToD0Pi, processMcSig, "Process MC only for signals", false);

Expand All @@ -335,6 +372,7 @@ struct HfDerivedDataCreatorDstarToD0Pi {
rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles);
processCandidates<false, true, true, false>(collisions, candidatesMcBkg, tracks, bcs);
rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass);
processGenMc(mcCollisions, mcParticlesPerMcCollision, mcParticles, rowsCommon.matchedCollisions);
}
PROCESS_SWITCH(HfDerivedDataCreatorDstarToD0Pi, processMcBkg, "Process MC only for background", false);

Expand All @@ -348,6 +386,7 @@ struct HfDerivedDataCreatorDstarToD0Pi {
rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles);
processCandidates<false, true, false, false>(collisions, candidatesMcAll, tracks, bcs);
rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass);
processGenMc(mcCollisions, mcParticlesPerMcCollision, mcParticles, rowsCommon.matchedCollisions);
}
PROCESS_SWITCH(HfDerivedDataCreatorDstarToD0Pi, processMcAll, "Process MC", false);

Expand All @@ -372,6 +411,7 @@ struct HfDerivedDataCreatorDstarToD0Pi {
rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles);
processCandidates<true, true, false, true>(collisions, candidatesMcMlSig, tracks, bcs);
rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass);
processGenMc(mcCollisions, mcParticlesPerMcCollision, mcParticles, rowsCommon.matchedCollisions);
}
PROCESS_SWITCH(HfDerivedDataCreatorDstarToD0Pi, processMcMlSig, "Process MC with ML only for signals", false);

Expand All @@ -385,6 +425,7 @@ struct HfDerivedDataCreatorDstarToD0Pi {
rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles);
processCandidates<true, true, true, false>(collisions, candidatesMcMlBkg, tracks, bcs);
rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass);
processGenMc(mcCollisions, mcParticlesPerMcCollision, mcParticles, rowsCommon.matchedCollisions);
}
PROCESS_SWITCH(HfDerivedDataCreatorDstarToD0Pi, processMcMlBkg, "Process MC with ML only for background", false);

Expand All @@ -398,13 +439,15 @@ struct HfDerivedDataCreatorDstarToD0Pi {
rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles);
processCandidates<true, true, false, false>(collisions, candidatesMcMlAll, tracks, bcs);
rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass);
processGenMc(mcCollisions, mcParticlesPerMcCollision, mcParticles, rowsCommon.matchedCollisions);
}
PROCESS_SWITCH(HfDerivedDataCreatorDstarToD0Pi, processMcMlAll, "Process MC with ML", false);

void processMcGenOnly(TypeMcCollisions const& mcCollisions,
MatchedGenCandidatesMc const& mcParticles)
{
rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass);
processGenMc(mcCollisions, mcParticlesPerMcCollision, mcParticles, rowsCommon.matchedCollisions);
}
PROCESS_SWITCH(HfDerivedDataCreatorDstarToD0Pi, processMcGenOnly, "Process MC gen. only", false);
};
Expand Down
2 changes: 1 addition & 1 deletion PWGJE/DataModel/Jet.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.

Check failure on line 1 in PWGJE/DataModel/Jet.h

View workflow job for this annotation

GitHub Actions / O2 linter

[doc/file]

Provide mandatory file documentation.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
Expand All @@ -18,7 +18,7 @@
///
/// \author Nima Zardoshti <nima.zardoshti@cern.ch>
/// \author Jochen Klein <jochen.klein@cern.ch>
/// \author Raymond Ehlers <raymond.ehlers@cern.ch>, ORNL

Check failure on line 21 in PWGJE/DataModel/Jet.h

View workflow job for this annotation

GitHub Actions / O2 linter

[doc/file]

Documentation for \file is missing, incorrect or misplaced.

#ifndef PWGJE_DATAMODEL_JET_H_
#define PWGJE_DATAMODEL_JET_H_
Expand All @@ -43,8 +43,8 @@

namespace jet
{
DECLARE_SOA_INDEX_COLUMN(JCollision, collision);

Check failure on line 46 in PWGJE/DataModel/Jet.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
DECLARE_SOA_INDEX_COLUMN(JMcCollision, mcCollision);

Check failure on line 47 in PWGJE/DataModel/Jet.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
DECLARE_SOA_COLUMN(Pt, pt, float); //!
DECLARE_SOA_COLUMN(Eta, eta, float); //!
DECLARE_SOA_COLUMN(Phi, phi, float); //!
Expand Down Expand Up @@ -86,11 +86,11 @@
jet::Pz<jet::Pt, jet::Eta>, \
jet::P<jet::Pt, jet::Eta>, \
_name_##util::Dummy##_jet_type_##s<>); \
namespace _name_##matchingGeo \

Check failure on line 89 in PWGJE/DataModel/Jet.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/namespace]

Use snake_case for names of namespaces. Double underscores are not allowed.
{ \
DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL(_jet_type_, matchedJetGeo, int32_t, _jet_type_##s, "_geo"); \
} \
namespace _name_##matchingPt \

Check failure on line 93 in PWGJE/DataModel/Jet.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/namespace]

Use snake_case for names of namespaces. Double underscores are not allowed.
{ \
DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL(_jet_type_, matchedJetPt, int32_t, _jet_type_##s, "_pt"); \
} \
Expand All @@ -104,7 +104,7 @@
{ \
DECLARE_SOA_INDEX_COLUMN(_jet_type_, jet); \
DECLARE_SOA_ARRAY_INDEX_COLUMN(_track_type_, tracks); \
DECLARE_SOA_ARRAY_INDEX_COLUMN(JCluster, clusters); \

Check failure on line 107 in PWGJE/DataModel/Jet.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL(Candidates, candidates, int32_t, _cand_type_, "_cand"); \
} \
DECLARE_SOA_TABLE(_jet_type_##Constituents, "AOD", _Description_ "C", \
Expand Down Expand Up @@ -237,7 +237,7 @@
using JetTracksSubDstar = JTrackDstarSubs;
using JetParticlesSubDstar = JMcParticleDstarSubs;
using McCollisionsDstar = o2::soa::Join<HfDstarMcCollBases, JDstarMcCollisionIds>;
using CandidatesDstarMCP = o2::soa::Join<HfDstarPBases, JDstarPIds>;
using CandidatesDstarMCP = o2::soa::Join<HfDstarPBases, JDstarPIds, HfDstarGenMcs>;

using CollisionsLc = o2::soa::Join<HfLcCollBases, JLcCollisionIds>;
using CandidatesLcData = o2::soa::Join<HfLcBases, HfLcPars, HfLcParEs, HfLcSels, HfLcMls, JLcIds>;
Expand Down
2 changes: 2 additions & 0 deletions PWGJE/TableProducer/derivedDataWriter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ struct JetDerivedDataWriter {
Produces<aod::StoredHfDstarMcRCollIds> storedDstarMcCollisionsMatchingTable;
Produces<aod::StoredHfDstarPBases> storedDstarParticlesTable;
Produces<aod::StoredJDstarPIds> storedDstarParticleIdsTable;
Produces<aod::StoredHfDstarGenMcs> storedDstarGenMcsTable;
} productsDstar;

struct : ProducesGroup {
Expand Down Expand Up @@ -653,6 +654,7 @@ struct JetDerivedDataWriter {
for (const auto& DstarParticle : dstarParticlesPerMcCollision) {
jethfutilities::fillHFCandidateMcTable(DstarParticle, products.productsDstar.storedDstarMcCollisionsTable.lastIndex(), products.productsDstar.storedDstarParticlesTable);
products.productsDstar.storedDstarParticleIdsTable(mcCollisionMapping[mcCollision.globalIndex()], particleMapping[DstarParticle.mcParticleId()]);
products.productsDstar.storedDstarGenMcsTable(DstarParticle.flagMcMatchGenCharm(), DstarParticle.idxMotherPart());
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions PWGJE/Tasks/jetSubstructureHFOutput.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ struct JetSubstructureHFOutputTask {
Produces<CandidateMCPOutputTable> hfParticlesTable;
} products;

Produces<aod::StoredHfDstarGenMcs> storedDstarGenMcsTable;

struct : ConfigurableGroup {
Configurable<float> jetPtMinData{"jetPtMinData", 0.0, "minimum jet pT cut for data jets"};
Configurable<float> jetPtMinDataSub{"jetPtMinDataSub", 0.0, "minimum jet pT cut for eventwise constituent subtracted data jets"};
Expand Down Expand Up @@ -370,6 +372,9 @@ struct JetSubstructureHFOutputTask {
}
jetcandidateutilities::fillCandidateMcTable(candidate, candidateCollisionIndex, products.hfParticlesTable);
candidateMap.insert(std::make_pair(candidate.globalIndex(), products.hfParticlesTable.lastIndex()));
if constexpr (jethfutilities::isDstarMcCandidate<U>()) {
storedDstarGenMcsTable(candidate.flagMcMatchGenCharm(), candidate.idxMotherPart());
}
} else {
auto hfCollisionIndex = candidateCollisionMapping.find(jetcandidateutilities::getCandidateCollisionId(candidate));
if (hfCollisionIndex != candidateCollisionMapping.end()) {
Expand Down
Loading