Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 49 additions & 3 deletions PWGDQ/Tasks/mftMchMatcher.cxx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.

Check failure on line 1 in PWGDQ/Tasks/mftMchMatcher.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[name/workflow-file]

Name of a workflow file must match the name of the main struct in it (without the PWG prefix). (Class implementation files should be in "Core" directories.)
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
Expand Down Expand Up @@ -142,9 +142,10 @@
DECLARE_SOA_COLUMN(Chi2Glob, chi2Glob, float);
DECLARE_SOA_COLUMN(Chi2Match, chi2Match, float);
DECLARE_SOA_COLUMN(IsAmbig, isAmbig, bool);
DECLARE_SOA_COLUMN(MFTMult, mftMult, int);

Check failure on line 145 in PWGDQ/Tasks/mftMchMatcher.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
DECLARE_SOA_COLUMN(MatchAttempts, matchAttempts, int);
DECLARE_SOA_COLUMN(DCAX, dcaX, float);

Check failure on line 147 in PWGDQ/Tasks/mftMchMatcher.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
DECLARE_SOA_COLUMN(DCAY, dcaY, float);

Check failure on line 148 in PWGDQ/Tasks/mftMchMatcher.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
DECLARE_SOA_COLUMN(McMaskGlob, mcMaskGlob, int);
DECLARE_SOA_COLUMN(MatchLabel, matchLabel, int);
DECLARE_SOA_COLUMN(IsSignal, isSignal, bool);
Expand Down Expand Up @@ -207,6 +208,7 @@
fwdmatchcandidates::DCAY,
fwdmatchcandidates::IsAmbig,
fwdmatchcandidates::MFTMult,
fwdmatchcandidates::MatchAttempts,
fwdmatchcandidates::McMaskMCH,
fwdmatchcandidates::McMaskMFT,
fwdmatchcandidates::McMaskGlob,
Expand Down Expand Up @@ -268,7 +270,6 @@
kMatchTypeUndefined
};

double mBzAtMftCenter{0};
o2::globaltracking::MatchGlobalFwd mExtrap;

int mRunNumber{0}; // needed to detect if the run changed and trigger update of magnetic field
Expand Down Expand Up @@ -311,7 +312,7 @@
double p = mchTrackAtVertex.p();

double pDCA = mchTrack.pDca();
double sigmaPDCA = (thetaAbs < 3) ? sigmaPDCA23 : sigmaPDCA310;

Check failure on line 315 in PWGDQ/Tasks/mftMchMatcher.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
double nrp = nSigmaPDCA * relPRes * p;
double pResEffect = sigmaPDCA / (1. - nrp / (1. + nrp));
double slopeResEffect = 535. * slopeRes * p;
Expand Down Expand Up @@ -458,7 +459,7 @@
fBestMatch.clear();
std::unordered_map<int, std::pair<float, int>> mCandidates;
for (const auto& muon : muons) {
if (static_cast<int>(muon.trackType()) < 2) {

Check failure on line 462 in PWGDQ/Tasks/mftMchMatcher.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
auto muonID = muon.matchMCHTrackId();
auto chi2 = muon.chi2MatchMCHMFT();
if (mCandidates.find(muonID) == mCandidates.end()) {
Expand All @@ -470,7 +471,7 @@
}
}
}
for (auto& pairCand : mCandidates) {
for (const auto& pairCand : mCandidates) {
fBestMatch[pairCand.second.second] = true;
}
}
Expand All @@ -483,7 +484,7 @@
// outer loop on muon tracks
for (const auto& muonTrack : muonTracks) {
// only consider MCH standalone or MCH-MID matches
if (static_cast<int>(muonTrack.trackType()) <= 2) {

Check failure on line 487 in PWGDQ/Tasks/mftMchMatcher.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
continue;
}

Expand Down Expand Up @@ -562,7 +563,7 @@
{
MuonMatchType result{kMatchTypeUndefined};

if (static_cast<int>(muonTrack.trackType()) > 2) {

Check failure on line 566 in PWGDQ/Tasks/mftMchMatcher.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
return result;
}

Expand Down Expand Up @@ -593,14 +594,50 @@

return result;
}
template <class EVT, class BC, class TMUON, class TMFTS>
int getMftMchMatchAttempts(EVT const& collisions,
BC const& bcs,
TMUON const& mchTrack,
TMFTS const& mftTracks)
{
if (!mchTrack.has_collision()) {
return 0;
}
const auto& collMch = collisions.rawIteratorAt(mchTrack.collisionId());
const auto& bcMch = bcs.rawIteratorAt(collMch.bcId());

int attempts{0};
for (const auto& mftTrack : mftTracks) {
if (!mftTrack.has_collision()) {
continue;
}

const auto& collMft = collisions.rawIteratorAt(mftTrack.collisionId());
const auto& bcMft = bcs.rawIteratorAt(collMft.bcId());

int64_t deltaBc = static_cast<int64_t>(bcMft.globalBC()) - static_cast<int64_t>(bcMch.globalBC());
double deltaBcNS = o2::constants::lhc::LHCBunchSpacingNS * deltaBc;
double deltaTrackTime = mftTrack.trackTime() - mchTrack.trackTime() + deltaBcNS;
double trackTimeResTot = mftTrack.trackTimeRes() + mchTrack.trackTimeRes();

if (std::fabs(deltaTrackTime) > trackTimeResTot) {
continue;
}
attempts += 1;
}

return attempts;
}

template <bool isMc, class TCOLLS, class TBCS, class TMUONS, class TMFTS, class TCOVS>
void fillTable(TCOLLS const& collisions,
TBCS const& /*bcs*/,
TBCS const& bcs,
TMUONS const& muonTracks,
TMFTS const& mftTracks,
TCOVS const& mftCovs)
{
std::unordered_map<int64_t, int> matchAttemptsMap;

registry.get<TH1>(HIST("acceptedEvents"))->Fill(0);
// reject a randomly selected fraction of events
if (fSamplingFraction < 1.0) {
Expand All @@ -619,11 +656,11 @@
}

mftCovIndexes.clear();
for (auto& mftTrackCov : mftCovs) {

Check failure on line 659 in PWGDQ/Tasks/mftMchMatcher.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
mftCovIndexes[mftTrackCov.matchMFTTrackId()] = mftTrackCov.globalIndex();
}

for (auto muon : muonTracks) {

Check failure on line 663 in PWGDQ/Tasks/mftMchMatcher.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
// only consider global MFT-MCH-MID matches
if (static_cast<int>(muon.trackType()) != 0) {
continue;
Expand Down Expand Up @@ -670,6 +707,14 @@

bool IsAmbig = (muon.compatibleCollIds().size() != 1);
int MFTMult = collision.mftNtracks();
int matchAttempts = 0;
auto matchAttemptsIt = matchAttemptsMap.find(muontrack.globalIndex());
if (matchAttemptsIt == matchAttemptsMap.end()) {
matchAttempts = getMftMchMatchAttempts(collisions, bcs, muontrack, mftTracks);
matchAttemptsMap.insert(std::make_pair(static_cast<int64_t>(muontrack.globalIndex()), matchAttempts));
} else {
matchAttempts = matchAttemptsIt->second;
}

auto matchType = kMatchTypeUndefined;
if constexpr (isMc) {
Expand Down Expand Up @@ -789,6 +834,7 @@
muon.fwdDcaY(),
IsAmbig,
MFTMult,
matchAttempts,
mcMaskMuon,
mcMaskMft,
ncMaskGlob,
Expand Down
Loading