Skip to content

Commit 660616f

Browse files
diana0x0fDiana Krupova
andauthored
[PWGUD] Modification of global track selection in UPCCandidateProducer (#9268)
Co-authored-by: Diana Krupova <diana@Dianas-MacBook-Pro.local>
1 parent e238c86 commit 660616f

File tree

1 file changed

+37
-19
lines changed

1 file changed

+37
-19
lines changed

PWGUD/TableProducer/UPCCandidateProducer.cxx

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,37 +1602,55 @@ struct UpcCandProducer {
16021602

16031603
int32_t candID = 0;
16041604

1605-
for (auto& pair : bcsMatchedTrIdsGlobal) { // candidates with MFT
1605+
for (auto& pair : bcsMatchedTrIdsGlobal) {
16061606
auto globalBC = static_cast<int64_t>(pair.first);
1607-
const auto& fwdTrackIDs = pair.second; // Forward tracks
1608-
uint32_t nMFTs = fwdTrackIDs.size();
1609-
std::vector<int64_t> trkCandIDs{};
1607+
const auto& fwdTrackIDs = pair.second; // Forward tracks (Global with MFT)
1608+
if (fwdTrackIDs.size() != 2) { // ensure we have two MFT tracks
1609+
continue;
1610+
}
16101611

1611-
// Find corresponding midTrackIDs using std::find_if
1612+
// find the corresponding MCH-MID tracks
16121613
auto midIt = std::find_if(bcsMatchedTrIdsMID.begin(), bcsMatchedTrIdsMID.end(),
16131614
[globalBC](const auto& midPair) {
16141615
return midPair.first == static_cast<uint64_t>(globalBC);
16151616
});
1616-
16171617
const auto* midTrackIDs = (midIt != bcsMatchedTrIdsMID.end()) ? &midIt->second : nullptr;
16181618

1619-
if (nMFTs > fNFwdProngs) // Skip if too many tracks
1619+
// ensure MCH-MID tracks are available
1620+
if (!midTrackIDs || midTrackIDs->size() != 2) {
16201621
continue;
1622+
}
16211623

1622-
if (nMFTs == fNFwdProngs) {
1624+
std::vector<int64_t> trkCandIDs;
16231625

1624-
for (auto iMft : fwdTrackIDs) {
1625-
auto trk = fwdTracks.iteratorAt(iMft);
1626-
auto trkEta = trk.eta();
1626+
// retrieve global track eta and apply the logic
1627+
bool firstInAcceptance = false, secondInAcceptance = false;
16271628

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());
1634-
}
1635-
}
1629+
const auto& trk1 = fwdTracks.iteratorAt(fwdTrackIDs[0]);
1630+
const auto& trk2 = fwdTracks.iteratorAt(fwdTrackIDs[1]);
1631+
1632+
if (trk1.eta() > fMinEtaMFT && trk1.eta() < fMaxEtaMFT) {
1633+
firstInAcceptance = true;
1634+
}
1635+
if (trk2.eta() > fMinEtaMFT && trk2.eta() < fMaxEtaMFT) {
1636+
secondInAcceptance = true;
1637+
}
1638+
1639+
// handle the four cases
1640+
if (!firstInAcceptance && !secondInAcceptance) {
1641+
// Case 1: Both outside MFT acceptance
1642+
trkCandIDs.insert(trkCandIDs.end(), midTrackIDs->begin(), midTrackIDs->end());
1643+
} else if (firstInAcceptance && !secondInAcceptance) {
1644+
// Case 2: First inside, second outside
1645+
trkCandIDs.push_back(fwdTrackIDs[0]); // Keep first global
1646+
trkCandIDs.push_back((*midTrackIDs)[1]); // Replace second with MCH-MID
1647+
} else if (!firstInAcceptance && secondInAcceptance) {
1648+
// Case 3: First outside, second inside
1649+
trkCandIDs.push_back((*midTrackIDs)[0]); // Replace first with MCH-MID
1650+
trkCandIDs.push_back(fwdTrackIDs[1]); // Keep second global
1651+
} else {
1652+
// Case 4: Both inside MFT acceptance
1653+
trkCandIDs.insert(trkCandIDs.end(), fwdTrackIDs.begin(), fwdTrackIDs.end());
16361654
}
16371655

16381656
uint64_t closestBcMCH = 0;

0 commit comments

Comments
 (0)