Skip to content

Commit d8e267d

Browse files
committed
Feat: add mc procssing to track-track task
1 parent 2e31a0d commit d8e267d

File tree

10 files changed

+628
-144
lines changed

10 files changed

+628
-144
lines changed

PWGCF/Femto/Core/collisionHistManager.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,14 @@ auto makeColHistSpecMap(const T& confBinningAnalysis)
113113
COL_HIST_ANALYSIS_MAP(confBinningAnalysis)};
114114
}
115115

116+
template <typename T>
117+
auto makeColMcHistSpecMap(const T& confBinningAnalysis)
118+
{
119+
return std::map<ColHist, std::vector<framework::AxisSpec>>{
120+
COL_HIST_ANALYSIS_MAP(confBinningAnalysis)
121+
COL_HIST_MC_MAP(confBinningAnalysis)};
122+
}
123+
116124
template <typename T1, typename T2>
117125
auto makeColQaHistSpecMap(const T1& confBinningAnalysis, const T2& confBinningQa)
118126
{
@@ -273,9 +281,12 @@ class CollisionHistManager
273281
template <typename T1, typename T2>
274282
void fillMc(T1 const& col, T2 const& /*mcCols*/)
275283
{
284+
if (!col.has_fMcCol()) {
285+
return;
286+
}
276287
auto genCol = col.template fMcCol_as<T2>();
277-
mHistogramRegistry->fill(HIST(ColMcDir) + HIST(getHistName(kMcMult, HistTable)), genCol.multMc());
278-
mHistogramRegistry->fill(HIST(ColMcDir) + HIST(getHistName(kMcCent, HistTable)), genCol.centMc());
288+
mHistogramRegistry->fill(HIST(ColMcDir) + HIST(getHistName(kMcMult, HistTable)), genCol.mult());
289+
mHistogramRegistry->fill(HIST(ColMcDir) + HIST(getHistName(kMcCent, HistTable)), genCol.cent());
279290
}
280291

281292
o2::framework::HistogramRegistry* mHistogramRegistry = nullptr;

PWGCF/Femto/Core/pairBuilder.h

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ class PairTrackTrackBuilder
8989
mColHistManager.template init<mode>(registry, colHistSpec);
9090
mPairHistManagerSe.template init<mode>(registry, pairHistSpec, confPairBinning, confPairCuts);
9191
mPairHistManagerMe.template init<mode>(registry, pairHistSpec, confPairBinning, confPairCuts);
92+
mPc.template init<mode>(confPairCuts);
9293

9394
if (mSameSpecies) {
9495
mTrackHistManager1.template init<mode>(registry, trackHistSpec1, confTrackSelection1);
@@ -130,6 +131,7 @@ class PairTrackTrackBuilder
130131
}
131132
}
132133

134+
// data
133135
template <modes::Mode mode, typename T1, typename T2, typename T3, typename T4, typename T5>
134136
void processSameEvent(T1 const& col, T2& trackTable, T3& partition1, T4& partition2, T5& cache)
135137
{
@@ -153,6 +155,30 @@ class PairTrackTrackBuilder
153155
}
154156
}
155157

158+
// mc
159+
template <modes::Mode mode, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
160+
void processSameEvent(T1 const& col, T2 const& mcCols, T3& trackTable, T4& partition1, T5& partition2, T6 const& mcParticles, T7 const& mcMothers, T8 const& mcPartonicMothers, T9& cache)
161+
{
162+
if (mSameSpecies) {
163+
auto trackSlice1 = partition1->sliceByCached(o2::aod::femtobase::stored::fColId, col.globalIndex(), cache);
164+
if (trackSlice1.size() == 0) {
165+
return;
166+
}
167+
mColHistManager.template fill<mode>(col, mcCols);
168+
mCprSe.setMagField(col.magField());
169+
pairprocesshelpers::processSameEvent<mode>(trackSlice1, trackTable, mcParticles, mcMothers, mcPartonicMothers, col, mcCols, mTrackHistManager1, mPairHistManagerSe, mCprSe, mPc, mRng, mMixIdenticalParticles);
170+
} else {
171+
auto trackSlice1 = partition1->sliceByCached(o2::aod::femtobase::stored::fColId, col.globalIndex(), cache);
172+
auto trackSlice2 = partition2->sliceByCached(o2::aod::femtobase::stored::fColId, col.globalIndex(), cache);
173+
if (trackSlice1.size() == 0 || trackSlice2.size() == 0) {
174+
return;
175+
}
176+
mColHistManager.template fill<mode>(col, mcCols);
177+
mCprSe.setMagField(col.magField());
178+
pairprocesshelpers::processSameEvent<mode>(trackSlice1, trackSlice2, trackTable, mcParticles, mcMothers, mcPartonicMothers, col, mcCols, mTrackHistManager1, mTrackHistManager2, mPairHistManagerSe, mCprSe, mPc);
179+
}
180+
}
181+
156182
template <modes::Mode mode, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
157183
void processMixedEvent(T1 const& cols, T2& trackTable, T3& partition1, T4& partition2, T5& cache, T6& binsVtxMult, T7& binsVtxCent, T8& binsVtxMultCent)
158184
{
@@ -188,6 +214,40 @@ class PairTrackTrackBuilder
188214
}
189215
}
190216

217+
template <modes::Mode mode, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10>
218+
void processMixedEvent(T1 const& cols, T2 const& mcCols, T3& trackTable, T4& partition1, T5& partition2, T6 const& mcParticles, T7& cache, T8& binsVtxMult, T9& binsVtxCent, T10& binsVtxMultCent)
219+
{
220+
if (mSameSpecies) {
221+
switch (mMixingPolicy) {
222+
case static_cast<int>(pairhistmanager::kVtxMult):
223+
pairprocesshelpers::processMixedEvent<mode>(cols, mcCols, partition1, trackTable, mcParticles, cache, binsVtxMult, mMixingDepth, mPairHistManagerMe, mCprMe, mPc);
224+
break;
225+
case static_cast<int>(pairhistmanager::kVtxCent):
226+
pairprocesshelpers::processMixedEvent<mode>(cols, mcCols, partition1, trackTable, mcParticles, cache, binsVtxCent, mMixingDepth, mPairHistManagerMe, mCprMe, mPc);
227+
break;
228+
case static_cast<int>(pairhistmanager::kVtxMultCent):
229+
pairprocesshelpers::processMixedEvent<mode>(cols, mcCols, partition1, trackTable, mcParticles, cache, binsVtxMultCent, mMixingDepth, mPairHistManagerMe, mCprMe, mPc);
230+
break;
231+
default:
232+
LOG(fatal) << "Invalid binning policiy specifed. Breaking...";
233+
}
234+
} else {
235+
switch (mMixingPolicy) {
236+
case static_cast<int>(pairhistmanager::kVtxMult):
237+
pairprocesshelpers::processMixedEvent<mode>(cols, mcCols, partition1, partition2, trackTable, mcParticles, cache, binsVtxMult, mMixingDepth, mPairHistManagerMe, mCprMe, mPc);
238+
break;
239+
case static_cast<int>(pairhistmanager::kVtxCent):
240+
pairprocesshelpers::processMixedEvent<mode>(cols, mcCols, partition1, partition2, trackTable, mcParticles, cache, binsVtxCent, mMixingDepth, mPairHistManagerMe, mCprMe, mPc);
241+
break;
242+
case static_cast<int>(pairhistmanager::kVtxMultCent):
243+
pairprocesshelpers::processMixedEvent<mode>(cols, mcCols, partition1, partition2, trackTable, mcParticles, cache, binsVtxMultCent, mMixingDepth, mPairHistManagerMe, mCprMe, mPc);
244+
break;
245+
default:
246+
LOG(fatal) << "Invalid binning policiy specifed. Breaking...";
247+
}
248+
}
249+
}
250+
191251
private:
192252
colhistmanager::CollisionHistManager mColHistManager;
193253
trackhistmanager::TrackHistManager<prefixTrack1> mTrackHistManager1;

PWGCF/Femto/Core/pairCleaner.h

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
#ifndef PWGCF_FEMTO_CORE_PAIRCLEANER_H_
1717
#define PWGCF_FEMTO_CORE_PAIRCLEANER_H_
1818

19+
#include "PWGCF/Femto/Core/modes.h"
20+
21+
#include "fairlogger/Logger.h"
22+
1923
namespace o2::analysis::femto
2024
{
2125
namespace paircleaner
@@ -27,23 +31,85 @@ class BasePairCleaner
2731
BasePairCleaner() = default;
2832
virtual ~BasePairCleaner() = default;
2933

34+
template <modes::Mode mode, typename T>
35+
void init(T const& PairCuts)
36+
{
37+
if constexpr (modes::isFlagSet(mode, modes::Mode::kMc)) {
38+
mMixPairsWithCommonAncestor = PairCuts.mixOnlyCommonAncestor.value;
39+
mMixPairsWithNonCommonAncestor = PairCuts.mixOnlyNonCommonAncestor.value;
40+
if (mMixPairsWithCommonAncestor && mMixPairsWithNonCommonAncestor) {
41+
LOG(fatal) << "Both mixing with common and non-common ancestor is activated. Breaking...";
42+
}
43+
}
44+
}
45+
3046
protected:
3147
template <typename T1, typename T2>
3248
bool isCleanTrackPair(T1 const& track1, T2 const& track2) const
3349
{
3450
return track1.globalIndex() != track2.globalIndex();
3551
};
52+
53+
template <typename T1, typename T2, typename T3>
54+
bool pairHasCommonAncestor(T1 const& particle1, T2 const& particle2, T3 const& /*partonicMothers*/) const
55+
{
56+
// if one of the two particles has no associated partonic mother, we cannot now if they have a common anchestor, so we break out with false
57+
if (!particle1.has_fMcPartMoth() || !particle2.has_fMcPartMoth()) {
58+
return false;
59+
}
60+
// get mc particles
61+
auto partonicMother1 = particle1.template fMcPartMoth_as<T3>();
62+
auto partonicMother2 = particle2.template fMcPartMoth_as<T3>();
63+
// get partonic mothers
64+
return partonicMother1.globalIndex() == partonicMother2.globalIndex();
65+
};
66+
67+
template <typename T1, typename T2, typename T3>
68+
bool pairHasNonCommonAncestor(T1 const& particle1, T2 const& particle2, T3 const& /*partonicMothers*/) const
69+
{
70+
// if one of the two particles has no associated partonic mother, we cannot now if they have a common anchestor, so we break out with false
71+
if (!particle1.has_fMcPartMoth() || !particle2.has_fMcPartMoth()) {
72+
return false;
73+
}
74+
// get mc particles
75+
auto partonicMother1 = particle1.template fMcPartMoth_as<T3>();
76+
auto partonicMother2 = particle2.template fMcPartMoth_as<T3>();
77+
// get partonic mothers
78+
return partonicMother1.globalIndex() != partonicMother2.globalIndex();
79+
};
80+
81+
bool mMixPairsWithCommonAncestor = false;
82+
bool mMixPairsWithNonCommonAncestor = false;
3683
};
3784

3885
class TrackTrackPairCleaner : public BasePairCleaner
3986
{
4087
public:
4188
TrackTrackPairCleaner() = default;
89+
4290
template <typename T1, typename T2, typename T3>
4391
bool isCleanPair(T1 const& track1, T2 const& track2, T3 const& /*trackTable*/) const
4492
{
4593
return this->isCleanTrackPair(track1, track2);
4694
}
95+
96+
template <typename T1, typename T2, typename T3, typename T4>
97+
bool isCleanPair(T1 const& track1, T2 const& track2, T3 const& /*trackTable*/, T4 const& partonicMothers) const
98+
{
99+
bool isCleanPair = this->isCleanTrackPair(track1, track2);
100+
if (!isCleanPair) {
101+
return false;
102+
}
103+
// pair is clean
104+
// no check if we require common or non-common ancestry
105+
if (mMixPairsWithCommonAncestor) {
106+
return this->pairHasCommonAncestor(track1, track2, partonicMothers);
107+
}
108+
if (mMixPairsWithNonCommonAncestor) {
109+
return this->pairHasNonCommonAncestor(track1, track2, partonicMothers);
110+
}
111+
return true;
112+
}
47113
};
48114

49115
class V0V0PairCleaner : public BasePairCleaner

0 commit comments

Comments
 (0)