Skip to content
Merged
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
64 changes: 47 additions & 17 deletions PWGCF/Femto/Core/pairCleaner.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class BasePairCleaner
if constexpr (modes::isFlagSet(mode, modes::Mode::kMc)) {
mMixPairsWithCommonAncestor = pairCuts.mixOnlyCommonAncestor.value;
mMixPairsWithNonCommonAncestor = pairCuts.mixOnlyNonCommonAncestor.value;
mUseMotherAsAncestor = pairCuts.useMotherAsAncestor.value;
if (mMixPairsWithCommonAncestor && mMixPairsWithNonCommonAncestor) {
LOG(fatal) << "Both mixing with common and non-common ancestor is activated. Breaking...";
}
Expand All @@ -48,34 +49,31 @@ class BasePairCleaner
};

// mc only
// ancestry is checked either with the partonic mother or with the first ancestor (i.e. the direct mother), depending on mUseMotherAsAncestor
template <typename T1, typename T2, typename T3>
bool mcPairHasCommonAncestor(T1 const& particle1, T2 const& particle2, T3 const& /*partonicMothers*/) const
bool mcPairHasCommonAncestor(T1 const& particle1, T2 const& particle2, T3 const& partonicMothers) const
{
// if one of the two particles has no associated partonic mother, we cannot know if they have a common anchestor, so we break out with false
if (!particle1.has_fMcPartMoth() || !particle2.has_fMcPartMoth()) {
return false;
if (mUseMotherAsAncestor) {
return this->mcPairHasCommonMother(particle1, particle2);
}

// get partonic mothers
auto partonicMother1 = particle1.template fMcPartMoth_as<T3>();
auto partonicMother2 = particle2.template fMcPartMoth_as<T3>();

return partonicMother1.globalIndex() == partonicMother2.globalIndex();
return this->mcPairHasCommonPartonicMother(particle1, particle2, partonicMothers);
};

template <typename T1, typename T2, typename T3>
bool mcPairHasNonCommonAncestor(T1 const& particle1, T2 const& particle2, T3 const& /*partonicMothers*/) const
bool mcPairHasNonCommonAncestor(T1 const& particle1, T2 const& particle2, T3 const& partonicMothers) const
{
if (mUseMotherAsAncestor) {
// if one of the two particles has no associated mother, we cannot know if they have a common anchestor, so we break out with false
if (!particle1.has_fMcMother() || !particle2.has_fMcMother()) {
return false;
}
return !this->mcPairHasCommonMother(particle1, particle2);
}
// if one of the two particles has no associated partonic mother, we cannot know if they have a common anchestor, so we break out with false
if (!particle1.has_fMcPartMoth() || !particle2.has_fMcPartMoth()) {
return false;
}

// get partonic mothers
auto partonicMother1 = particle1.template fMcPartMoth_as<T3>();
auto partonicMother2 = particle2.template fMcPartMoth_as<T3>();

return partonicMother1.globalIndex() != partonicMother2.globalIndex();
return !this->mcPairHasCommonPartonicMother(particle1, particle2, partonicMothers);
};

// reco + mc
Expand Down Expand Up @@ -111,6 +109,38 @@ class BasePairCleaner

bool mMixPairsWithCommonAncestor = false;
bool mMixPairsWithNonCommonAncestor = false;

private:
// require both particles to originate from the same partonic mother
template <typename T1, typename T2, typename T3>
bool mcPairHasCommonPartonicMother(T1 const& particle1, T2 const& particle2, T3 const& /*partonicMothers*/) const
{
// if one of the two particles has no associated partonic mother, we cannot know if they have a common anchestor, so we break out with false
if (!particle1.has_fMcPartMoth() || !particle2.has_fMcPartMoth()) {
return false;
}

// get partonic mothers
auto partonicMother1 = particle1.template fMcPartMoth_as<T3>();
auto partonicMother2 = particle2.template fMcPartMoth_as<T3>();

return partonicMother1.globalIndex() == partonicMother2.globalIndex();
};

// require both particles to have the same first ancestor, i.e. the same direct mother
// there is exactly one row in the mother table per generated mother, so comparing the indices is sufficient
template <typename T1, typename T2>
bool mcPairHasCommonMother(T1 const& particle1, T2 const& particle2) const
{
// if one of the two particles has no associated mother, we cannot know if they have a common anchestor, so we break out with false
if (!particle1.has_fMcMother() || !particle2.has_fMcMother()) {
return false;
}

return particle1.fMcMotherId() == particle2.fMcMotherId();
};

bool mUseMotherAsAncestor = false;
};

class TrackTrackPairCleaner : public BasePairCleaner
Expand Down
1 change: 1 addition & 0 deletions PWGCF/Femto/Core/pairHistManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ struct ConfPairCuts : o2::framework::ConfigurableGroup {
o2::framework::Configurable<float> massInvMax{"massInvMax", -1, "Maximal invariant mass (set to -1 to deactivate)"};
o2::framework::Configurable<bool> mixOnlyCommonAncestor{"mixOnlyCommonAncestor", false, "Require pair to have common anchestor (in the same event)"};
o2::framework::Configurable<bool> mixOnlyNonCommonAncestor{"mixOnlyNonCommonAncestor", false, "Require pair to have non-common anchestor (in the same event)"};
o2::framework::Configurable<bool> useMotherAsAncestor{"useMotherAsAncestor", false, "Use the first ancestor (i.e. the direct mother) instead of the partonic mother when requiring (non-)common ancestry"};
};

// the enum gives the correct index in the array
Expand Down
1 change: 1 addition & 0 deletions PWGCF/Femto/Core/tripletHistManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ struct ConfTripletCuts : o2::framework::ConfigurableGroup {
o2::framework::Configurable<float> mtMin{"mtMin", -1, "Minimal mt (set to -1 to deactivate)"};
o2::framework::Configurable<bool> mixOnlyCommonAncestor{"mixOnlyCommonAncestor", false, "Require pair to have common anchestor (in the same event)"};
o2::framework::Configurable<bool> mixOnlyNonCommonAncestor{"mixOnlyNonCommonAncestor", false, "Require pair to have non-common anchestor (in the same event)"};
o2::framework::Configurable<bool> useMotherAsAncestor{"useMotherAsAncestor", false, "Use the first ancestor (i.e. the direct mother) instead of the partonic mother when requiring (non-)common ancestry"};
};

// the enum gives the correct index in the array
Expand Down
Loading