Skip to content

Commit 8ea9022

Browse files
committed
[PWGDQ] add match attempts in ML training data producer
The number of match attempts is currently the best estimator of the multiplicity of MFT tracks that are combined with each MCH track when the global muon matching is performed.
1 parent f41cbc6 commit 8ea9022

1 file changed

Lines changed: 48 additions & 1 deletion

File tree

PWGDQ/Tasks/mftMchMatcher.cxx

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ DECLARE_SOA_COLUMN(Chi2Glob, chi2Glob, float);
143143
DECLARE_SOA_COLUMN(Chi2Match, chi2Match, float);
144144
DECLARE_SOA_COLUMN(IsAmbig, isAmbig, bool);
145145
DECLARE_SOA_COLUMN(MFTMult, mftMult, int);
146+
DECLARE_SOA_COLUMN(MatchAttempts, matchAttempts, int);
146147
DECLARE_SOA_COLUMN(DCAX, dcaX, float);
147148
DECLARE_SOA_COLUMN(DCAY, dcaY, float);
148149
DECLARE_SOA_COLUMN(McMaskGlob, mcMaskGlob, int);
@@ -207,6 +208,7 @@ DECLARE_SOA_TABLE(FwdMatchMLCandidates, "AOD", "FWDMLCAND",
207208
fwdmatchcandidates::DCAY,
208209
fwdmatchcandidates::IsAmbig,
209210
fwdmatchcandidates::MFTMult,
211+
fwdmatchcandidates::MatchAttempts,
210212
fwdmatchcandidates::McMaskMCH,
211213
fwdmatchcandidates::McMaskMFT,
212214
fwdmatchcandidates::McMaskGlob,
@@ -593,14 +595,50 @@ struct mftMchMatcher {
593595

594596
return result;
595597
}
598+
template <class EVT, class BC, class TMUON, class TMFTS>
599+
int getMftMchMatchAttempts(EVT const& collisions,
600+
BC const& bcs,
601+
TMUON const& mchTrack,
602+
TMFTS const& mftTracks)
603+
{
604+
if (!mchTrack.has_collision()) {
605+
return 0;
606+
}
607+
const auto& collMch = collisions.rawIteratorAt(mchTrack.collisionId());
608+
const auto& bcMch = bcs.rawIteratorAt(collMch.bcId());
609+
610+
int attempts{0};
611+
for (const auto& mftTrack : mftTracks) {
612+
if (!mftTrack.has_collision()) {
613+
continue;
614+
}
615+
616+
const auto& collMft = collisions.rawIteratorAt(mftTrack.collisionId());
617+
const auto& bcMft = bcs.rawIteratorAt(collMft.bcId());
618+
619+
int64_t deltaBc = static_cast<int64_t>(bcMft.globalBC()) - static_cast<int64_t>(bcMch.globalBC());
620+
double deltaBcNS = o2::constants::lhc::LHCBunchSpacingNS * deltaBc;
621+
double deltaTrackTime = mftTrack.trackTime() - mchTrack.trackTime() + deltaBcNS;
622+
double trackTimeResTot = mftTrack.trackTimeRes() + mchTrack.trackTimeRes();
623+
624+
if (std::fabs(deltaTrackTime) > trackTimeResTot) {
625+
continue;
626+
}
627+
attempts += 1;
628+
}
629+
630+
return attempts;
631+
}
596632

597633
template <bool isMc, class TCOLLS, class TBCS, class TMUONS, class TMFTS, class TCOVS>
598634
void fillTable(TCOLLS const& collisions,
599-
TBCS const& /*bcs*/,
635+
TBCS const& bcs,
600636
TMUONS const& muonTracks,
601637
TMFTS const& mftTracks,
602638
TCOVS const& mftCovs)
603639
{
640+
std::unordered_map<int64_t, int> matchAttemptsMap;
641+
604642
registry.get<TH1>(HIST("acceptedEvents"))->Fill(0);
605643
// reject a randomly selected fraction of events
606644
if (fSamplingFraction < 1.0) {
@@ -670,6 +708,14 @@ struct mftMchMatcher {
670708

671709
bool IsAmbig = (muon.compatibleCollIds().size() != 1);
672710
int MFTMult = collision.mftNtracks();
711+
int matchAttempts = 0;
712+
auto matchAttemptsIt = matchAttemptsMap.find(muontrack.globalIndex());
713+
if (matchAttemptsIt == matchAttemptsMap.end()) {
714+
matchAttempts = getMftMchMatchAttempts(collisions, bcs, muontrack, mftTracks);
715+
matchAttemptsMap.insert(std::make_pair(static_cast<int64_t>(muontrack.globalIndex()), matchAttempts));
716+
} else {
717+
matchAttempts = matchAttemptsIt->second;
718+
}
673719

674720
auto matchType = kMatchTypeUndefined;
675721
if constexpr (isMc) {
@@ -789,6 +835,7 @@ struct mftMchMatcher {
789835
muon.fwdDcaY(),
790836
IsAmbig,
791837
MFTMult,
838+
matchAttempts,
792839
mcMaskMuon,
793840
mcMaskMft,
794841
ncMaskGlob,

0 commit comments

Comments
 (0)