Skip to content

Commit d6045c4

Browse files
diana0x0fDiana Krupova
andauthored
[PWGUD] Fix global forward tracks selection and store tan lambda information (#9185)
Co-authored-by: Diana Krupova <diana@Dianas-MacBook-Pro.local>
1 parent a5e761a commit d6045c4

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

PWGUD/TableProducer/UPCCandidateProducer.cxx

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,28 +1600,41 @@ struct UpcCandProducer {
16001600

16011601
std::vector<int> selTrackIdsGlobal{};
16021602

1603-
// storing n-prong matches
16041603
int32_t candID = 0;
1605-
auto midIt = bcsMatchedTrIdsMID.begin();
1604+
16061605
for (auto& pair : bcsMatchedTrIdsGlobal) { // candidates with MFT
16071606
auto globalBC = static_cast<int64_t>(pair.first);
1608-
const auto& fwdTrackIDs = pair.second;
1607+
const auto& fwdTrackIDs = pair.second; // Forward tracks
16091608
uint32_t nMFTs = fwdTrackIDs.size();
1610-
if (nMFTs > fNFwdProngs) // too many tracks
1611-
continue;
16121609
std::vector<int64_t> trkCandIDs{};
1613-
const auto& midTrackIDs = midIt->second; // to retrieve corresponding MCH-MID tracks
1610+
1611+
// Find corresponding midTrackIDs using std::find_if
1612+
auto midIt = std::find_if(bcsMatchedTrIdsMID.begin(), bcsMatchedTrIdsMID.end(),
1613+
[globalBC](const auto& midPair) {
1614+
return midPair.first == static_cast<uint64_t>(globalBC);
1615+
});
1616+
1617+
const auto* midTrackIDs = (midIt != bcsMatchedTrIdsMID.end()) ? &midIt->second : nullptr;
1618+
1619+
if (nMFTs > fNFwdProngs) // Skip if too many tracks
1620+
continue;
1621+
16141622
if (nMFTs == fNFwdProngs) {
1623+
16151624
for (auto iMft : fwdTrackIDs) {
16161625
auto trk = fwdTracks.iteratorAt(iMft);
16171626
auto trkEta = trk.eta();
1618-
if (trkEta > fMinEtaMFT && trkEta < fMaxEtaMFT) { // If the track is in the MFT acceptance, store the global track
1619-
trkCandIDs.insert(trkCandIDs.end(), fwdTrackIDs.begin(), fwdTrackIDs.end());
1620-
} else { // If the track is not in the MFT acceptance, store the MCH-MID track
1621-
trkCandIDs.insert(trkCandIDs.end(), midTrackIDs.begin(), midTrackIDs.end());
1627+
1628+
if (trkEta > fMinEtaMFT && trkEta < fMaxEtaMFT) {
1629+
// Track is within MFT acceptance, store forward track IDs
1630+
trkCandIDs.push_back(iMft);
1631+
} else if (midTrackIDs) {
1632+
// Track is outside MFT acceptance, store corresponding MID track IDs
1633+
trkCandIDs.insert(trkCandIDs.end(), midTrackIDs->begin(), midTrackIDs->end());
16221634
}
16231635
}
16241636
}
1637+
16251638
uint64_t closestBcMCH = 0;
16261639
upchelpers::FITInfo fitInfo{};
16271640
fitInfo.timeFT0A = -999.f;
@@ -1732,7 +1745,6 @@ struct UpcCandProducer {
17321745
amplitudesV0A,
17331746
relBCsV0A);
17341747
candID++;
1735-
midIt++;
17361748
trkCandIDs.clear();
17371749
}
17381750

0 commit comments

Comments
 (0)