Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PWGLF] Fix unbound indices in KF hypernuclei code #8803

Merged
merged 24 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
50 changes: 25 additions & 25 deletions PWGLF/DataModel/LFHypernucleiKfTables.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// 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.
// authors Janik Ditzel <[email protected]> and Michael Hartung <[email protected]>

Check warning on line 11 in PWGLF/DataModel/LFHypernucleiKfTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[doc/file]

Documentation for \file is missing, incorrect or misplaced.

Check warning on line 11 in PWGLF/DataModel/LFHypernucleiKfTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[doc/file]

Documentation for \brief is missing, incorrect or misplaced.

#ifndef PWGLF_DATAMODEL_LFHYPERNUCLEIKFTABLES_H_
#define PWGLF_DATAMODEL_LFHYPERNUCLEIKFTABLES_H_
Expand All @@ -24,31 +24,31 @@
{
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); //!
DECLARE_SOA_COLUMN(Svy, svy, float); //!
DECLARE_SOA_COLUMN(Svz, svz, float); //!
DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, [](float px, float py) { return RecoDecay::pt(std::array{px, py}); });
DECLARE_SOA_DYNAMIC_COLUMN(Y, y, [](float E, float pz) { return 0.5 * TMath::Log((E + pz) / (E - pz)); });

Check warning on line 44 in PWGLF/DataModel/LFHypernucleiKfTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[root-entity]

Consider replacing ROOT entities with equivalents from standard C++ or from O2.
DECLARE_SOA_DYNAMIC_COLUMN(Mass, mass, [](float E, float px, float py, float pz) { return TMath::Sqrt(E * E - px * px - py * py - pz * pz); });

Check warning on line 45 in PWGLF/DataModel/LFHypernucleiKfTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[root-entity]

Consider replacing ROOT entities with equivalents from standard C++ or from O2.
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 @@
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 All @@ -88,12 +88,12 @@
DECLARE_SOA_COLUMN(TOFMass, tofMass, float); //!
DECLARE_SOA_COLUMN(IsPVContributor, isPVContributor, bool); //!
DECLARE_SOA_COLUMN(SubMass, subMass, float); //!
DECLARE_SOA_DYNAMIC_COLUMN(Px, px, [](float pt, float phi) { return (double)pt * TMath::Cos(phi); });

Check warning on line 91 in PWGLF/DataModel/LFHypernucleiKfTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[root-entity]

Consider replacing ROOT entities with equivalents from standard C++ or from O2.
DECLARE_SOA_DYNAMIC_COLUMN(Py, py, [](float pt, float phi) { return (double)pt * TMath::Sin(phi); });

Check warning on line 92 in PWGLF/DataModel/LFHypernucleiKfTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[root-entity]

Consider replacing ROOT entities with equivalents from standard C++ or from O2.
DECLARE_SOA_DYNAMIC_COLUMN(Pz, pz, [](float pt, float eta) { return (double)pt * TMath::SinH(eta); });

Check warning on line 93 in PWGLF/DataModel/LFHypernucleiKfTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[root-entity]

Consider replacing ROOT entities with equivalents from standard C++ or from O2.
DECLARE_SOA_DYNAMIC_COLUMN(P, p, [](float pt, float eta) { return pt * TMath::CosH(eta); }); //

Check warning on line 94 in PWGLF/DataModel/LFHypernucleiKfTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[root-entity]

Consider replacing ROOT entities with equivalents from standard C++ or from O2.
DECLARE_SOA_DYNAMIC_COLUMN(Y, y, [](float pt, float eta, float mass) { return std::log((RecoDecay::sqrtSumOfSquares(mass, pt * TMath::CosH(eta)) + pt * TMath::SinH(eta)) / RecoDecay::sqrtSumOfSquares(mass, pt)); });

Check warning on line 95 in PWGLF/DataModel/LFHypernucleiKfTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[root-entity]

Consider replacing ROOT entities with equivalents from standard C++ or from O2.
DECLARE_SOA_DYNAMIC_COLUMN(Lambda, lambda, [](float eta) { return 1. / TMath::CosH(eta); });

Check warning on line 96 in PWGLF/DataModel/LFHypernucleiKfTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[root-entity]

Consider replacing ROOT entities with equivalents from standard C++ or from O2.
DECLARE_SOA_DYNAMIC_COLUMN(ITSnCluster, itsNcluster, [](uint32_t itsClusterSizes) {
uint8_t n = 0;
for (uint8_t i = 0; i < 7; i++) {
Expand Down Expand Up @@ -149,29 +149,29 @@
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(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 @@
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
Loading