Skip to content

Commit e478edb

Browse files
authored
[PWGCF] Femto framework add first mother ancestor option (#17428)
1 parent e4b4c19 commit e478edb

3 files changed

Lines changed: 49 additions & 17 deletions

File tree

PWGCF/Femto/Core/pairCleaner.h

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class BasePairCleaner
3434
if constexpr (modes::isFlagSet(mode, modes::Mode::kMc)) {
3535
mMixPairsWithCommonAncestor = pairCuts.mixOnlyCommonAncestor.value;
3636
mMixPairsWithNonCommonAncestor = pairCuts.mixOnlyNonCommonAncestor.value;
37+
mUseMotherAsAncestor = pairCuts.useMotherAsAncestor.value;
3738
if (mMixPairsWithCommonAncestor && mMixPairsWithNonCommonAncestor) {
3839
LOG(fatal) << "Both mixing with common and non-common ancestor is activated. Breaking...";
3940
}
@@ -48,34 +49,31 @@ class BasePairCleaner
4849
};
4950

5051
// mc only
52+
// ancestry is checked either with the partonic mother or with the first ancestor (i.e. the direct mother), depending on mUseMotherAsAncestor
5153
template <typename T1, typename T2, typename T3>
52-
bool mcPairHasCommonAncestor(T1 const& particle1, T2 const& particle2, T3 const& /*partonicMothers*/) const
54+
bool mcPairHasCommonAncestor(T1 const& particle1, T2 const& particle2, T3 const& partonicMothers) const
5355
{
54-
// 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
55-
if (!particle1.has_fMcPartMoth() || !particle2.has_fMcPartMoth()) {
56-
return false;
56+
if (mUseMotherAsAncestor) {
57+
return this->mcPairHasCommonMother(particle1, particle2);
5758
}
58-
59-
// get partonic mothers
60-
auto partonicMother1 = particle1.template fMcPartMoth_as<T3>();
61-
auto partonicMother2 = particle2.template fMcPartMoth_as<T3>();
62-
63-
return partonicMother1.globalIndex() == partonicMother2.globalIndex();
59+
return this->mcPairHasCommonPartonicMother(particle1, particle2, partonicMothers);
6460
};
6561

6662
template <typename T1, typename T2, typename T3>
67-
bool mcPairHasNonCommonAncestor(T1 const& particle1, T2 const& particle2, T3 const& /*partonicMothers*/) const
63+
bool mcPairHasNonCommonAncestor(T1 const& particle1, T2 const& particle2, T3 const& partonicMothers) const
6864
{
65+
if (mUseMotherAsAncestor) {
66+
// 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
67+
if (!particle1.has_fMcMother() || !particle2.has_fMcMother()) {
68+
return false;
69+
}
70+
return !this->mcPairHasCommonMother(particle1, particle2);
71+
}
6972
// 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
7073
if (!particle1.has_fMcPartMoth() || !particle2.has_fMcPartMoth()) {
7174
return false;
7275
}
73-
74-
// get partonic mothers
75-
auto partonicMother1 = particle1.template fMcPartMoth_as<T3>();
76-
auto partonicMother2 = particle2.template fMcPartMoth_as<T3>();
77-
78-
return partonicMother1.globalIndex() != partonicMother2.globalIndex();
76+
return !this->mcPairHasCommonPartonicMother(particle1, particle2, partonicMothers);
7977
};
8078

8179
// reco + mc
@@ -111,6 +109,38 @@ class BasePairCleaner
111109

112110
bool mMixPairsWithCommonAncestor = false;
113111
bool mMixPairsWithNonCommonAncestor = false;
112+
113+
private:
114+
// require both particles to originate from the same partonic mother
115+
template <typename T1, typename T2, typename T3>
116+
bool mcPairHasCommonPartonicMother(T1 const& particle1, T2 const& particle2, T3 const& /*partonicMothers*/) const
117+
{
118+
// 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
119+
if (!particle1.has_fMcPartMoth() || !particle2.has_fMcPartMoth()) {
120+
return false;
121+
}
122+
123+
// get partonic mothers
124+
auto partonicMother1 = particle1.template fMcPartMoth_as<T3>();
125+
auto partonicMother2 = particle2.template fMcPartMoth_as<T3>();
126+
127+
return partonicMother1.globalIndex() == partonicMother2.globalIndex();
128+
};
129+
130+
// require both particles to have the same first ancestor, i.e. the same direct mother
131+
// there is exactly one row in the mother table per generated mother, so comparing the indices is sufficient
132+
template <typename T1, typename T2>
133+
bool mcPairHasCommonMother(T1 const& particle1, T2 const& particle2) const
134+
{
135+
// 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
136+
if (!particle1.has_fMcMother() || !particle2.has_fMcMother()) {
137+
return false;
138+
}
139+
140+
return particle1.fMcMotherId() == particle2.fMcMotherId();
141+
};
142+
143+
bool mUseMotherAsAncestor = false;
114144
};
115145

116146
class TrackTrackPairCleaner : public BasePairCleaner

PWGCF/Femto/Core/pairHistManager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ struct ConfPairCuts : o2::framework::ConfigurableGroup {
249249
o2::framework::Configurable<float> massInvMax{"massInvMax", -1, "Maximal invariant mass (set to -1 to deactivate)"};
250250
o2::framework::Configurable<bool> mixOnlyCommonAncestor{"mixOnlyCommonAncestor", false, "Require pair to have common anchestor (in the same event)"};
251251
o2::framework::Configurable<bool> mixOnlyNonCommonAncestor{"mixOnlyNonCommonAncestor", false, "Require pair to have non-common anchestor (in the same event)"};
252+
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"};
252253
};
253254

254255
// the enum gives the correct index in the array

PWGCF/Femto/Core/tripletHistManager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ struct ConfTripletCuts : o2::framework::ConfigurableGroup {
140140
o2::framework::Configurable<float> mtMin{"mtMin", -1, "Minimal mt (set to -1 to deactivate)"};
141141
o2::framework::Configurable<bool> mixOnlyCommonAncestor{"mixOnlyCommonAncestor", false, "Require pair to have common anchestor (in the same event)"};
142142
o2::framework::Configurable<bool> mixOnlyNonCommonAncestor{"mixOnlyNonCommonAncestor", false, "Require pair to have non-common anchestor (in the same event)"};
143+
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"};
143144
};
144145

145146
// the enum gives the correct index in the array

0 commit comments

Comments
 (0)