Skip to content

Commit e5dc16d

Browse files
committed
factor out repeating code in v0 and casc over pos, neg and bach
1 parent 3702cd7 commit e5dc16d

File tree

1 file changed

+43
-33
lines changed

1 file changed

+43
-33
lines changed

DPG/Tasks/TPC/tpcSkimsTableCreator.cxx

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ struct TreeWriterTpcV0 {
108108
};
109109

110110
enum {
111+
DaughterUndef = -1,
111112
DaughterElectron = 0,
112113
DaughterPion,
113114
DaughterKaon,
@@ -193,6 +194,10 @@ struct TreeWriterTpcV0 {
193194
return V0Mother{DaughterProton, DaughterPion};
194195
case MotherAntiLambda:
195196
return V0Mother{DaughterPion, DaughterProton};
197+
case MotherOmega:
198+
return V0Mother{DaughterUndef, DaughterKaon};
199+
case MotherAntiOmega:
200+
return V0Mother{DaughterKaon, DaughterUndef};
196201
default: {
197202
LOGP(fatal, "createV0Mother: unknown motherId");
198203
return V0Mother();
@@ -399,6 +404,18 @@ struct TreeWriterTpcV0 {
399404
return casc.cascradius();
400405
}
401406

407+
/// Evaluate add id of the v0
408+
double getAddId(V0sWithID::iterator const& v0)
409+
{
410+
return v0.v0addid();
411+
}
412+
413+
/// Evaluate add id of the cascade
414+
double getAddId(CascsWithID::iterator const& casc)
415+
{
416+
return casc.cascaddid();
417+
}
418+
402419
template <bool IsCorrectedDeDx, int ModeId, typename TrksType, typename BCType, typename TrkQAType>
403420
void runV0(Colls const& collisions, TrksType const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, TrkQAType const& tracksQA)
404421
{
@@ -442,20 +459,6 @@ struct TreeWriterTpcV0 {
442459
rowTPCTreeWithTrkQA.reserve(2 * v0s.size() + cascs.size());
443460
}
444461

445-
auto fillDaughterTrack = [&](const auto& mother, const TrksType::iterator& dauTrack, const V0Daughter& daughter, const aod::TracksQA& trackQAInstance, const bool existTrkQA) {
446-
const bool passTrackSelection = isTrackSelected(dauTrack, trackSelection);
447-
const bool passDownsamplig = downsampleTsalisCharged(fRndm, dauTrack.pt(), daughter.downsamplingTsalis, daughter.mass, sqrtSNN, daughter.maxPt4dwnsmplTsalis);
448-
const bool passNSigmaTofCut = std::fabs(daughter.tofNSigma) < daughter.nSigmaTofDauTrack || std::fabs(daughter.tofNSigma - NSigmaTofUnmatched) < NSigmaTofUnmatchedEqualityTolerance;
449-
const bool passMatchTofRequirement = !daughter.rejectNoTofDauTrack || std::fabs(daughter.tofNSigma - NSigmaTofUnmatched) > NSigmaTofUnmatchedEqualityTolerance;
450-
if (passTrackSelection && passDownsamplig && passNSigmaTofCut && passMatchTofRequirement) {
451-
occupancyValues occValues{};
452-
if constexpr (ModeId == ModeWithTrkQA) {
453-
evaluateOccupancyVariables(dauTrack, occValues);
454-
}
455-
fillSkimmedV0Table<IsCorrectedDeDx, ModeId>(mother, dauTrack, trackQAInstance, existTrkQA, collision, daughter.tpcNSigma, daughter.tofNSigma, daughter.itsNSigma, daughter.tpcExpSignal, daughter.id, runnumber, daughter.dwnSmplFactor, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame, occValues);
456-
}
457-
};
458-
459462
auto getTrackQA = [&](const TrksType::iterator& track) {
460463
if constexpr (!IsWithTrackQa) {
461464
return std::make_pair(aod::TracksQA{}, false);
@@ -470,6 +473,28 @@ struct TreeWriterTpcV0 {
470473
}
471474
};
472475

476+
auto fillDaughterTrack = [&](const auto& mother, const TrksType::iterator& dauTrack, const auto& v0, const bool isPositive) {
477+
const auto [trackQAInstance, existTrkQA] = getTrackQA(dauTrack);
478+
const auto trackId = dauTrack.globalIndex();
479+
const auto& dauTrackWithITSPid = tracksWithITSPid.rawIteratorAt(trackId);
480+
const auto v0Id = getAddId(v0);
481+
const V0Mother v0Mother = createV0Mother(v0Id);
482+
const auto daighterId = isPositive ? v0Mother.posDaughterId : v0Mother.negDaughterId;
483+
const V0Daughter daughter = createV0Daughter<IsCorrectedDeDx>(v0, dauTrackWithITSPid, v0Id, daighterId, isPositive);
484+
485+
const bool passTrackSelection = isTrackSelected(dauTrack, trackSelection);
486+
const bool passDownsamplig = downsampleTsalisCharged(fRndm, dauTrack.pt(), daughter.downsamplingTsalis, daughter.mass, sqrtSNN, daughter.maxPt4dwnsmplTsalis);
487+
const bool passNSigmaTofCut = std::fabs(daughter.tofNSigma) < daughter.nSigmaTofDauTrack || std::fabs(daughter.tofNSigma - NSigmaTofUnmatched) < NSigmaTofUnmatchedEqualityTolerance;
488+
const bool passMatchTofRequirement = !daughter.rejectNoTofDauTrack || std::fabs(daughter.tofNSigma - NSigmaTofUnmatched) > NSigmaTofUnmatchedEqualityTolerance;
489+
if (passTrackSelection && passDownsamplig && passNSigmaTofCut && passMatchTofRequirement) {
490+
occupancyValues occValues{};
491+
if constexpr (ModeId == ModeWithTrkQA) {
492+
evaluateOccupancyVariables(dauTrack, occValues);
493+
}
494+
fillSkimmedV0Table<IsCorrectedDeDx, ModeId>(mother, dauTrack, trackQAInstance, existTrkQA, collision, daughter.tpcNSigma, daughter.tofNSigma, daughter.itsNSigma, daughter.tpcExpSignal, daughter.id, runnumber, daughter.dwnSmplFactor, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame, occValues);
495+
}
496+
};
497+
473498
/// Loop over v0 candidates
474499
for (const auto& v0 : v0s) {
475500
const auto v0Id = v0.v0addid();
@@ -479,20 +504,8 @@ struct TreeWriterTpcV0 {
479504
const auto& posTrack = v0.posTrack_as<TrksType>();
480505
const auto& negTrack = v0.negTrack_as<TrksType>();
481506

482-
const auto posTrackId = posTrack.globalIndex();
483-
const auto& posTrackWithITSPid = tracksWithITSPid.rawIteratorAt(posTrackId);
484-
const auto negTrackId = negTrack.globalIndex();
485-
const auto& negTrackWithITSPid = tracksWithITSPid.rawIteratorAt(negTrackId);
486-
487-
const auto& [posTrackQA, existPosTrkQA] = getTrackQA(posTrack);
488-
const auto& [negTrackQA, existNegTrkQA] = getTrackQA(negTrack);
489-
490-
const V0Mother v0Mother = createV0Mother(v0Id);
491-
const V0Daughter posDaughter = createV0Daughter<IsCorrectedDeDx>(v0, posTrackWithITSPid, v0Id, v0Mother.posDaughterId, true);
492-
const V0Daughter negDaughter = createV0Daughter<IsCorrectedDeDx>(v0, negTrackWithITSPid, v0Id, v0Mother.negDaughterId, false);
493-
494-
fillDaughterTrack(v0, posTrack, posDaughter, posTrackQA, existPosTrkQA);
495-
fillDaughterTrack(v0, negTrack, negDaughter, negTrackQA, existNegTrkQA);
507+
fillDaughterTrack(v0, posTrack, v0, true);
508+
fillDaughterTrack(v0, negTrack, v0, false);
496509
}
497510

498511
/// Loop over cascade candidates
@@ -502,12 +515,9 @@ struct TreeWriterTpcV0 {
502515
continue;
503516
}
504517
const auto& bachTrack = casc.bachelor_as<TrksType>();
505-
const auto bachTrackId = bachTrack.globalIndex();
506-
const auto& bachTrackWithITSPid = tracksWithITSPid.rawIteratorAt(bachTrackId);
507-
const V0Daughter bachDaughter = createV0Daughter<IsCorrectedDeDx>(casc, bachTrackWithITSPid, cascId, DaughterKaon);
508-
const auto& [bachTrackQA, existBachTrkQA] = getTrackQA(bachTrack);
509518
// Omega and antiomega
510-
fillDaughterTrack(casc, bachTrack, bachDaughter, bachTrackQA, existBachTrkQA);
519+
const auto isDaughterPositive = cascId == MotherAntiOmega ? true : false;
520+
fillDaughterTrack(casc, bachTrack, casc, isDaughterPositive);
511521
}
512522
}
513523
} /// runV0

0 commit comments

Comments
 (0)