Skip to content

Commit

Permalink
[PWGLF] Fix unbound indices in KF hypernuclei code (AliceO2Group#8803)
Browse files Browse the repository at this point in the history
Co-authored-by: ALICE Action Bot <[email protected]>
  • Loading branch information
2 people authored and Archita-Dash committed Dec 11, 2024
1 parent 0f6f87b commit 847670f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 40 deletions.
50 changes: 25 additions & 25 deletions PWGLF/DataModel/LFHypernucleiKfTables.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ namespace hykfmcColl
{
DECLARE_SOA_COLUMN(PassedEvSel, passedEvSel, bool); //!
}
DECLARE_SOA_TABLE(HypKfMcCollisions, "AOD", "HYPKFMCCOLL",
DECLARE_SOA_TABLE(HypKfMcColls, "AOD", "HYPKFMCCOLL",
o2::soa::Index<>,
hykfmcColl::PassedEvSel,
mccollision::PosX,
mccollision::PosY,
mccollision::PosZ);
using HypKfMcCollision = HypKfMcCollisions::iterator;
using HypKfMcColl = HypKfMcColls::iterator;

namespace hykfmc
{
DECLARE_SOA_INDEX_COLUMN(HypKfMcCollision, hypKfMcCollision);
DECLARE_SOA_INDEX_COLUMN(HypKfMcColl, hypKfMcColl);
DECLARE_SOA_COLUMN(Species, species, int8_t); //!
DECLARE_SOA_COLUMN(IsPhysicalPrimary, isPhysicalPrimary, bool); //!
DECLARE_SOA_COLUMN(Svx, svx, float); //!
Expand All @@ -46,9 +46,9 @@ DECLARE_SOA_DYNAMIC_COLUMN(Mass, mass, [](float E, float px, float py, float pz)
DECLARE_SOA_DYNAMIC_COLUMN(IsMatter, isMatter, [](int pdgCode) { return pdgCode > 0; });
} // namespace hykfmc

DECLARE_SOA_TABLE(HypKfMcParticles, "AOD", "HYPKFMCPART",
DECLARE_SOA_TABLE(HypKfMcParts, "AOD", "HYPKFMCPART",
o2::soa::Index<>,
hykfmc::HypKfMcCollisionId,
hykfmc::HypKfMcCollId,
hykfmc::Species,
mcparticle::PdgCode,
hykfmc::IsPhysicalPrimary,
Expand All @@ -63,23 +63,23 @@ DECLARE_SOA_TABLE(HypKfMcParticles, "AOD", "HYPKFMCPART",
hykfmc::Y<mcparticle::E, mcparticle::Pz>,
hykfmc::Mass<mcparticle::E, mcparticle::Px, mcparticle::Py, mcparticle::Pz>,
hykfmc::IsMatter<mcparticle::PdgCode>);
using HypKfMcParticle = HypKfMcParticles::iterator;
using HypKfMcPart = HypKfMcParts::iterator;

DECLARE_SOA_TABLE(HypKfCollisions, "AOD", "HYPKFCOLL",
DECLARE_SOA_TABLE(HypKfColls, "AOD", "HYPKFCOLL",
o2::soa::Index<>,
hykfmcColl::PassedEvSel,
hykfmc::HypKfMcCollisionId,
hykfmc::HypKfMcCollId,
collision::PosX,
collision::PosY,
collision::PosZ,
cent::CentFT0A,
cent::CentFT0C,
cent::CentFT0M);
using HypKfCollision = HypKfCollisions::iterator;
using HypKfColl = HypKfColls::iterator;

namespace hykftrk
{
DECLARE_SOA_INDEX_COLUMN(HypKfCollision, hypKfCollision);
DECLARE_SOA_INDEX_COLUMN(HypKfColl, hypKfColl);
DECLARE_SOA_COLUMN(Rigidity, rigidity, float); //!
DECLARE_SOA_COLUMN(TPCnCluster, tpcNcluster, float); //!
DECLARE_SOA_COLUMN(TPCnSigma, tpcNsigma, float); //!
Expand Down Expand Up @@ -149,29 +149,29 @@ DECLARE_SOA_TABLE(HypKfTracks, "AOD", "HYPKFTRACK",
hykftrk::ITSmeanClsSize<track::ITSClusterSizes>);
using HypKfTrack = HypKfTracks::iterator;

DECLARE_SOA_TABLE(HypKfSubDaughters, "AOD", "HYPKFSUBD",
DECLARE_SOA_TABLE(HypKfSubDs, "AOD", "HYPKFSUBD",
o2::soa::Index<>,
hykftrk::SubMass);
using HypKfSubDaughter = HypKfSubDaughters::iterator;
using HypKfSubD = HypKfSubDs::iterator;

DECLARE_SOA_TABLE(HypKfDaughterAddons, "AOD", "HYPKFDADD",
DECLARE_SOA_TABLE(HypKfDaughtAdds, "AOD", "HYPKFDAUGHTADD",
o2::soa::Index<>,
track::X,
track::Y,
track::Z,
mcparticle::Px,
mcparticle::Py,
mcparticle::Pz);
using HypKfDaughterAddon = HypKfDaughterAddons::iterator;
using HypKfDaughtAdd = HypKfDaughtAdds::iterator;

namespace hykfhyp
{
DECLARE_SOA_INDEX_COLUMN(HypKfCollision, hypKfCollision);
DECLARE_SOA_INDEX_COLUMN(HypKfMcParticle, hypKfMcParticle);
DECLARE_SOA_ARRAY_INDEX_COLUMN(HypKfDaughterAddon, addons);
DECLARE_SOA_INDEX_COLUMN(HypKfColl, hypKfColl);
DECLARE_SOA_INDEX_COLUMN(HypKfMcPart, hypKfMcPart);
DECLARE_SOA_ARRAY_INDEX_COLUMN(HypKfDaughtAdd, addons);
DECLARE_SOA_ARRAY_INDEX_COLUMN(HypKfTrack, daughterTracks);
DECLARE_SOA_SELF_INDEX_COLUMN(HypDaughter, hypDaughter);
DECLARE_SOA_ARRAY_INDEX_COLUMN(HypKfSubDaughter, subDaughters);
DECLARE_SOA_SELF_INDEX_COLUMN_FULL(HypDaughter, hypDaughter, int, "HypKfHypNucs");
DECLARE_SOA_ARRAY_INDEX_COLUMN(HypKfSubD, subDaughters);
DECLARE_SOA_COLUMN(Primary, primary, bool); //!
DECLARE_SOA_COLUMN(Mass, mass, float); //!
DECLARE_SOA_COLUMN(Px, px, float); //!
Expand All @@ -188,19 +188,19 @@ DECLARE_SOA_DYNAMIC_COLUMN(Eta, eta, [](float px, float py, float pz) { return R
DECLARE_SOA_DYNAMIC_COLUMN(Phi, phi, [](float px, float py) { return RecoDecay::phi(std::array{px, py}); });
DECLARE_SOA_DYNAMIC_COLUMN(P, p, [](float px, float py, float pz) { return RecoDecay::p(px, py, pz); }); //
DECLARE_SOA_DYNAMIC_COLUMN(Y, y, [](float px, float py, float pz, float mass) { return RecoDecay::y(std::array{px, py, pz}, mass); });
DECLARE_SOA_DYNAMIC_COLUMN(McTrue, mcTrue, [](int hypKfMcParticleId) { return hypKfMcParticleId > 0; });
DECLARE_SOA_DYNAMIC_COLUMN(McTrue, mcTrue, [](int hypKfMcPartId) { return hypKfMcPartId > 0; });
DECLARE_SOA_DYNAMIC_COLUMN(IsMatter, isMatter, [](int8_t species) { return species > 0; });
DECLARE_SOA_DYNAMIC_COLUMN(Cascade, cascade, [](int hypDaughter) { return hypDaughter > 0; });
} // namespace hykfhyp

DECLARE_SOA_TABLE(HypKfHypNucs, "AOD", "HYPKFHYPNUC",
o2::soa::Index<>,
hykfhyp::HypKfMcParticleId,
hykfhyp::HypKfCollisionId,
hykfhyp::HypKfMcPartId,
hykfhyp::HypKfCollId,
hykfhyp::HypKfTrackIds,
hykfhyp::HypKfDaughterAddonIds,
hykfhyp::HypKfDaughtAddIds,
hykfhyp::HypDaughterId,
hykfhyp::HypKfSubDaughterIds,
hykfhyp::HypKfSubDIds,
hykfmc::Species,
hykfhyp::Primary,
hykfhyp::Mass,
Expand All @@ -221,7 +221,7 @@ DECLARE_SOA_TABLE(HypKfHypNucs, "AOD", "HYPKFHYPNUC",
hykfhyp::Eta<hykfhyp::Px, hykfhyp::Py, hykfhyp::Pz>,
hykfhyp::Phi<hykfhyp::Px, hykfhyp::Py>,
hykfhyp::P<hykfhyp::Px, hykfhyp::Py, hykfhyp::Pz>,
hykfhyp::McTrue<hykfhyp::HypKfMcParticleId>,
hykfhyp::McTrue<hykfhyp::HypKfMcPartId>,
hykfhyp::IsMatter<hykfmc::Species>,
hykfhyp::Cascade<hykfhyp::HypDaughterId>);
using HypKfHypNuc = HypKfHypNucs::iterator;
Expand Down
10 changes: 5 additions & 5 deletions PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -405,12 +405,12 @@ std::vector<std::shared_ptr<TH1>> hInvMass;
//----------------------------------------------------------------------------------------------------------------
struct hypKfRecoTask {

Produces<aod::HypKfMcCollisions> outputMcCollisionTable;
Produces<aod::HypKfMcParticles> outputMcParticleTable;
Produces<aod::HypKfCollisions> outputCollisionTable;
Produces<aod::HypKfMcColls> outputMcCollisionTable;
Produces<aod::HypKfMcParts> outputMcParticleTable;
Produces<aod::HypKfColls> outputCollisionTable;
Produces<aod::HypKfTracks> outputTrackTable;
Produces<aod::HypKfDaughterAddons> outputDaughterAddonTable;
Produces<aod::HypKfSubDaughters> outputSubDaughterTable;
Produces<aod::HypKfDaughtAdds> outputDaughterAddonTable;
Produces<aod::HypKfSubDs> outputSubDaughterTable;
Produces<aod::HypKfHypNucs> outputHypNucTable;

Preslice<aod::TrackAssoc> perCollision = aod::track_association::collisionId;
Expand Down
20 changes: 10 additions & 10 deletions PWGLF/TableProducer/Nuspex/hypKfTreeCreator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ struct hypKfTreeCreator {
Produces<aod::HypKfMcCascadeTwoThreeCandidates> outputTableMcTwoThree;
Produces<aod::HypKfCascadeThreeTwoCandidates> outputTableThreeTwo;
Produces<aod::HypKfMcCascadeThreeTwoCandidates> outputTableMcThreeTwo;
PresliceUnsorted<aod::HypKfHypNucs> perMcParticle = aod::hykfhyp::hypKfMcParticleId;
PresliceUnsorted<aod::HypKfHypNucs> perMcParticle = aod::hykfhyp::hypKfMcPartId;

Configurable<int> cfgSpecies{"cfgSpecies", 0, "Select species"};
Configurable<int> cfgNprimDaughters{"cfgNprimDaughters", 0, "Number of primary daughters"};
Expand All @@ -354,7 +354,7 @@ struct hypKfTreeCreator {
}
//___________________________________________________________________________________________________________________________________________________________

void processData(aod::HypKfHypNucs const& hypNucs, aod::HypKfCollisions const& hypKfColls, aod::HypKfTracks const& hypKfTrks, aod::HypKfDaughterAddons const& hypKfDAdd, aod::HypKfSubDaughters const& hypKfDSub)
void processData(aod::HypKfHypNucs const& hypNucs, aod::HypKfColls const& hypKfColls, aod::HypKfTracks const& hypKfTrks, aod::HypKfDaughtAdds const& hypKfDAdd, aod::HypKfSubDs const& hypKfDSub)
{
for (auto& hypNuc : hypNucs) {
if (std::abs(hypNuc.species()) != cfgSpecies)
Expand Down Expand Up @@ -514,12 +514,12 @@ struct hypKfTreeCreator {
}
//___________________________________________________________________________________________________________________________________________________________

void fillCandidate(hyperNucleus& cand, hyperNucleus& hypDaughter, aod::HypKfHypNuc const& hypNuc, aod::HypKfHypNucs const&, aod::HypKfCollisions const&, aod::HypKfTracks const&, aod::HypKfDaughterAddons const&, aod::HypKfSubDaughters const&)
void fillCandidate(hyperNucleus& cand, hyperNucleus& hypDaughter, aod::HypKfHypNuc const& hypNuc, aod::HypKfHypNucs const&, aod::HypKfColls const&, aod::HypKfTracks const&, aod::HypKfDaughtAdds const&, aod::HypKfSubDs const&)
{
cand.daughterTracks.clear();
cand.subDaughterMassVec.clear();
auto coll = hypNuc.hypKfCollision();
auto addOns = hypNuc.addons_as<aod::HypKfDaughterAddons>();
auto coll = hypNuc.hypKfColl();
auto addOns = hypNuc.addons_as<aod::HypKfDaughtAdds>();
auto posVec = posVector(addOns);
cand.Species = std::abs(hypNuc.species());
cand.IsMatter = hypNuc.isMatter();
Expand Down Expand Up @@ -584,20 +584,20 @@ struct hypKfTreeCreator {
return;

trackCount = 0;
auto subDaughters = hypNuc.subDaughters_as<aod::HypKfSubDaughters>();
auto subDaughters = hypNuc.subDaughters_as<aod::HypKfSubDs>();
for (auto& subDaughter : subDaughters) {
cand.daughterTracks.at(trackCount++).SubMass = subDaughter.subMass();
}
}
//___________________________________________________________________________________________________________________________________________________________

void processMC(aod::HypKfMcParticles const& mcHypNucs, aod::HypKfHypNucs const& hypNucs, aod::HypKfMcCollisions const&, aod::HypKfCollisions const& hypKfColls, aod::HypKfTracks const& hypKfTrks, aod::HypKfDaughterAddons const& hypKfDAdd, aod::HypKfSubDaughters const& hypKfDSub)
void processMC(aod::HypKfMcParts const& mcHypNucs, aod::HypKfHypNucs const& hypNucs, aod::HypKfMcColls const&, aod::HypKfColls const& hypKfColls, aod::HypKfTracks const& hypKfTrks, aod::HypKfDaughtAdds const& hypKfDAdd, aod::HypKfSubDs const& hypKfDSub)
{
isMC = true;
for (auto& mcHypNuc : mcHypNucs) {
if (std::abs(mcHypNuc.species()) != cfgSpecies)
continue;
auto mcColl = mcHypNuc.hypKfMcCollision();
auto mcColl = mcHypNuc.hypKfMcColl();
const auto mcParticleIdx = mcHypNuc.globalIndex();
auto hypNucsByMc = hypNucs.sliceBy(perMcParticle, mcParticleIdx);
hyperNucleus candidate, hypDaughter, dummy;
Expand All @@ -620,8 +620,8 @@ struct hypKfTreeCreator {
candidate.SvyGen = mcHypNuc.svy();
candidate.SvzGen = mcHypNuc.svz();
for (auto& hypNuc : hypNucsByMc) {
auto coll = hypNuc.hypKfCollision();
if (coll.hypKfMcCollisionId() == mcHypNuc.hypKfMcCollisionId()) {
auto coll = hypNuc.hypKfColl();
if (coll.hypKfMcCollId() == mcHypNuc.hypKfMcCollId()) {
candidate.CollisionMcTrue = true;
}
candidate.IsReconstructed++;
Expand Down

0 comments on commit 847670f

Please sign in to comment.