Skip to content

Commit be52273

Browse files
Diana KrupovaDiana Krupova
authored andcommitted
[PWGUD] Modification of global track selection in UPCCandidateProducer
1 parent d6045c4 commit be52273

File tree

1 file changed

+40
-18
lines changed

1 file changed

+40
-18
lines changed

PWGUD/TableProducer/UPCCandidateProducer.cxx

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,37 +1602,59 @@ 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
1607+
const auto& fwdTrackIDs = pair.second; // Forward tracks (Global with MFT)
16081608
uint32_t nMFTs = fwdTrackIDs.size();
1609-
std::vector<int64_t> trkCandIDs{};
1609+
// ensure we have two MFT tracks
1610+
if (nMFTs != 2) {
1611+
continue;
1612+
}
16101613

1611-
// Find corresponding midTrackIDs using std::find_if
1614+
// find the corresponding MCH-MID tracks
16121615
auto midIt = std::find_if(bcsMatchedTrIdsMID.begin(), bcsMatchedTrIdsMID.end(),
16131616
[globalBC](const auto& midPair) {
16141617
return midPair.first == static_cast<uint64_t>(globalBC);
16151618
});
1616-
16171619
const auto* midTrackIDs = (midIt != bcsMatchedTrIdsMID.end()) ? &midIt->second : nullptr;
16181620

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

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

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

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

16381660
uint64_t closestBcMCH = 0;

0 commit comments

Comments
 (0)