Skip to content

Commit 0484b3d

Browse files
committed
Feat: use common daughterRow function
1 parent 9b2f986 commit 0484b3d

4 files changed

Lines changed: 26 additions & 54 deletions

File tree

PWGCF/Femto/Core/cascadeBuilder.h

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -837,9 +837,9 @@ class CascadeBuilderDerivedToDerived
837837
auto xiSlice = partitionXi->sliceByCached(o2::aod::femtobase::stored::fColId, col.globalIndex(), cache);
838838

839839
for (auto const& xi : xiSlice) {
840-
auto bachelor = oldTrackTable.rawIteratorAt(this->daughterRow(xi.bachelorId(), oldTrackTable));
841-
auto posDaughter = oldTrackTable.rawIteratorAt(this->daughterRow(xi.posDauId(), oldTrackTable));
842-
auto negDaughter = oldTrackTable.rawIteratorAt(this->daughterRow(xi.negDauId(), oldTrackTable));
840+
auto bachelor = oldTrackTable.rawIteratorAt(utils::daughterRow(xi.bachelorId(), oldTrackTable));
841+
auto posDaughter = oldTrackTable.rawIteratorAt(utils::daughterRow(xi.posDauId(), oldTrackTable));
842+
auto negDaughter = oldTrackTable.rawIteratorAt(utils::daughterRow(xi.negDauId(), oldTrackTable));
843843

844844
int64_t bachelorIndex = trackBuilder.getDaughterIndex(bachelor, newTrackTable, newCollisionTable);
845845
int64_t posDaughterIndex = trackBuilder.getDaughterIndex(posDaughter, newTrackTable, newCollisionTable);
@@ -867,9 +867,9 @@ class CascadeBuilderDerivedToDerived
867867
auto omegaSlice = partitionOmega->sliceByCached(o2::aod::femtobase::stored::fColId, col.globalIndex(), cache);
868868

869869
for (auto const& omega : omegaSlice) {
870-
auto bachelor = oldTrackTable.rawIteratorAt(this->daughterRow(omega.bachelorId(), oldTrackTable));
871-
auto posDaughter = oldTrackTable.rawIteratorAt(this->daughterRow(omega.posDauId(), oldTrackTable));
872-
auto negDaughter = oldTrackTable.rawIteratorAt(this->daughterRow(omega.negDauId(), oldTrackTable));
870+
auto bachelor = oldTrackTable.rawIteratorAt(utils::daughterRow(omega.bachelorId(), oldTrackTable));
871+
auto posDaughter = oldTrackTable.rawIteratorAt(utils::daughterRow(omega.posDauId(), oldTrackTable));
872+
auto negDaughter = oldTrackTable.rawIteratorAt(utils::daughterRow(omega.negDauId(), oldTrackTable));
873873

874874
int64_t bachelorIndex = trackBuilder.getDaughterIndex(bachelor, newTrackTable, newCollisionTable);
875875
int64_t posDaughterIndex = trackBuilder.getDaughterIndex(posDaughter, newTrackTable, newCollisionTable);
@@ -888,20 +888,6 @@ class CascadeBuilderDerivedToDerived
888888
}
889889

890890
private:
891-
/// Translate a global daughter index into a row of the current track table frame.
892-
/// Aborts if the index does not fall inside the frame, which would otherwise
893-
/// silently produce an out-of-range iterator.
894-
template <typename T>
895-
int64_t daughterRow(int64_t daughterId, T const& trackTable) const
896-
{
897-
const int64_t row = daughterId - trackTable.offset();
898-
if (daughterId < 0 || row < 0 || row >= static_cast<int64_t>(trackTable.size())) {
899-
LOG(fatal) << "Daughter index " << daughterId << " out of range for track table (offset "
900-
<< trackTable.offset() << ", size " << trackTable.size() << "). Breaking...";
901-
}
902-
return row;
903-
}
904-
905891
int mLimitXi = 0;
906892
int mLimitOmega = 0;
907893
};

PWGCF/Femto/Core/femtoUtils.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,20 @@ inline std::optional<T2> getIndex(const T1& index, const std::unordered_map<T1,
4747
return std::nullopt;
4848
}
4949

50+
/// Translate a global daughter index into a row of the current track table frame.
51+
/// Aborts if the index does not fall inside the frame, which would otherwise
52+
/// silently produce an out-of-range iterator.
53+
template <typename T>
54+
int64_t daughterRow(int64_t daughterId, T const& trackTable)
55+
{
56+
const int64_t row = daughterId - trackTable.offset();
57+
if (daughterId < 0 || row < 0 || row >= static_cast<int64_t>(trackTable.size())) {
58+
LOG(fatal) << "Daughter index " << daughterId << " out of range for track table (offset "
59+
<< trackTable.offset() << ", size " << trackTable.size() << "). Breaking...";
60+
}
61+
return row;
62+
}
63+
5064
template <typename T>
5165
float itsSignal(T const& track)
5266
{

PWGCF/Femto/Core/kinkBuilder.h

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ class KinkBuilderDerivedToDerived
783783
auto sigmaSlice = partitionSigma->sliceByCached(o2::aod::femtobase::stored::fColId, col.globalIndex(), cache);
784784

785785
for (auto const& sigma : sigmaSlice) {
786-
auto chaDaughter = oldTrackTable.rawIteratorAt(this->daughterRow(sigma.chaDauId(), oldTrackTable));
786+
auto chaDaughter = oldTrackTable.rawIteratorAt(utils::daughterRow(sigma.chaDauId(), oldTrackTable));
787787

788788
int64_t chaDaughterIndex = trackBuilder.getDaughterIndex(chaDaughter, newTrackTable, newCollisionTable);
789789

@@ -807,7 +807,7 @@ class KinkBuilderDerivedToDerived
807807
auto sigmaPlusSlice = partitionSigmaPlus->sliceByCached(o2::aod::femtobase::stored::fColId, col.globalIndex(), cache);
808808

809809
for (auto const& sigmaPlus : sigmaPlusSlice) {
810-
auto chaDaughter = oldTrackTable.rawIteratorAt(this->daughterRow(sigmaPlus.chaDauId(), oldTrackTable));
810+
auto chaDaughter = oldTrackTable.rawIteratorAt(utils::daughterRow(sigmaPlus.chaDauId(), oldTrackTable));
811811

812812
int64_t chaDaughterIndex = trackBuilder.getDaughterIndex(chaDaughter, newTrackTable, newCollisionTable);
813813

@@ -822,20 +822,6 @@ class KinkBuilderDerivedToDerived
822822
}
823823

824824
private:
825-
/// Translate a global daughter index into a row of the current track table frame.
826-
/// Aborts if the index does not fall inside the frame, which would otherwise
827-
/// silently produce an out-of-range iterator.
828-
template <typename T>
829-
int64_t daughterRow(int64_t daughterId, T const& trackTable) const
830-
{
831-
const int64_t row = daughterId - trackTable.offset();
832-
if (daughterId < 0 || row < 0 || row >= static_cast<int64_t>(trackTable.size())) {
833-
LOG(fatal) << "Daughter index " << daughterId << " out of range for track table (offset "
834-
<< trackTable.offset() << ", size " << trackTable.size() << "). Breaking...";
835-
}
836-
return row;
837-
}
838-
839825
int mLimitSigma = 0;
840826
int mLimitSigmaPlus = 0;
841827
};

PWGCF/Femto/Core/v0Builder.h

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -828,8 +828,8 @@ class V0BuilderDerivedToDerived
828828
auto lambdaSlice = partitionLambda->sliceByCached(o2::aod::femtobase::stored::fColId, col.globalIndex(), cache);
829829

830830
for (auto const& lambda : lambdaSlice) {
831-
auto posDaughter = oldTrackTable.rawIteratorAt(this->daughterRow(lambda.posDauId(), oldTrackTable));
832-
auto negDaughter = oldTrackTable.rawIteratorAt(this->daughterRow(lambda.negDauId(), oldTrackTable));
831+
auto posDaughter = oldTrackTable.rawIteratorAt(utils::daughterRow(lambda.posDauId(), oldTrackTable));
832+
auto negDaughter = oldTrackTable.rawIteratorAt(utils::daughterRow(lambda.negDauId(), oldTrackTable));
833833

834834
int64_t posDaughterIndex = trackBuilder.getDaughterIndex(posDaughter, newTrackTable, newCollisionTable);
835835
int64_t negDaughterIndex = trackBuilder.getDaughterIndex(negDaughter, newTrackTable, newCollisionTable);
@@ -855,8 +855,8 @@ class V0BuilderDerivedToDerived
855855
auto k0shortSlice = partitionK0short->sliceByCached(o2::aod::femtobase::stored::fColId, col.globalIndex(), cache);
856856

857857
for (auto const& k0short : k0shortSlice) {
858-
auto posDaughter = oldTrackTable.rawIteratorAt(this->daughterRow(k0short.posDauId(), oldTrackTable));
859-
auto negDaughter = oldTrackTable.rawIteratorAt(this->daughterRow(k0short.negDauId(), oldTrackTable));
858+
auto posDaughter = oldTrackTable.rawIteratorAt(utils::daughterRow(k0short.posDauId(), oldTrackTable));
859+
auto negDaughter = oldTrackTable.rawIteratorAt(utils::daughterRow(k0short.negDauId(), oldTrackTable));
860860

861861
int64_t posDaughterIndex = trackBuilder.getDaughterIndex(posDaughter, newTrackTable, newCollisionTable);
862862
int64_t negDaughterIndex = trackBuilder.getDaughterIndex(negDaughter, newTrackTable, newCollisionTable);
@@ -873,20 +873,6 @@ class V0BuilderDerivedToDerived
873873
}
874874

875875
private:
876-
/// Translate a global daughter index into a row of the current track table frame.
877-
/// Aborts if the index does not fall inside the frame, which would otherwise
878-
/// silently produce an out-of-range iterator.
879-
template <typename T>
880-
int64_t daughterRow(int64_t daughterId, T const& trackTable) const
881-
{
882-
const int64_t row = daughterId - trackTable.offset();
883-
if (daughterId < 0 || row < 0 || row >= static_cast<int64_t>(trackTable.size())) {
884-
LOG(fatal) << "Daughter index " << daughterId << " out of range for track table (offset "
885-
<< trackTable.offset() << ", size " << trackTable.size() << "). Breaking...";
886-
}
887-
return row;
888-
}
889-
890876
int mLimitLambda = 0;
891877
int mLimitK0short = 0;
892878
};

0 commit comments

Comments
 (0)