Skip to content
Open
Show file tree
Hide file tree
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
81 changes: 61 additions & 20 deletions PWGDQ/Tasks/mftMchMatcher.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@
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(DCAX, dcaX, float);

Check failure on line 146 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 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(McMaskGlob, mcMaskGlob, int);
DECLARE_SOA_COLUMN(MatchLabel, matchLabel, int);
DECLARE_SOA_COLUMN(IsSignal, isSignal, bool);
Expand Down Expand Up @@ -302,7 +302,7 @@
double p = mchTrackAtVertex.p();

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

Check failure on line 305 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 @@ -438,7 +438,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 441 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 @@ -450,7 +450,7 @@
}
}
}
for (auto& pairCand : mCandidates) {

Check failure on line 453 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.
fBestMatch[pairCand.second.second] = true;
}
}
Expand All @@ -463,7 +463,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 466 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 @@ -542,7 +542,7 @@
{
MuonMatchType result{kMatchTypeUndefined};

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

Check failure on line 545 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 @@ -574,19 +574,13 @@
return result;
}

void processMC(MyEvents const& collisions,
aod::BCsWithTimestamps const& bcs,
MyMuonsMC const& muonTracks,
MyMFTsMC const& mftTracks,
MyMFTCovariances const& mftCovs,
aod::McParticles const& /*mcParticles*/)
template <bool isMc, class TCOLLS, class TBCS, class TMUONS, class TMFTS, class TCOVS>
void fillTable(TCOLLS const& collisions,
TBCS const& /*bcs*/,
TMUONS const& muonTracks,
TMFTS const& mftTracks,
TCOVS const& mftCovs)
{
if (bcs.size() > 0) {
auto bc = bcs.begin();
initCCDB(bc);
VarManager::SetMatchingPlane(fzMatching.value);
}

registry.get<TH1>(HIST("acceptedEvents"))->Fill(0);
// reject a randomly selected fraction of events
if (fSamplingFraction < 1.0) {
Expand All @@ -600,16 +594,18 @@
fillBestMuonMatches(muonTracks);

std::vector<std::pair<int64_t, int64_t>> matchablePairs;
fillMatchablePairs(muonTracks, mftTracks, matchablePairs);
if constexpr (isMc) {
fillMatchablePairs(muonTracks, mftTracks, matchablePairs);
}

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

Check failure on line 602 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();
}

fwdMatchMLCandidates.reserve(muonTracks.size());

for (auto muon : muonTracks) {

Check failure on line 608 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 All @@ -626,10 +622,10 @@
}

const auto& collision = collisions.rawIteratorAt(muon.collisionId());
auto bc_coll = collision.bc_as<aod::BCsWithTimestamps>();
auto bc_coll = collision.template bc_as<TBCS>();

auto muontrack = muon.template matchMCHTrack_as<MyMuonsMC>();
auto mfttrack = muon.template matchMFTTrack_as<MyMFTsMC>();
auto muontrack = muon.template matchMCHTrack_as<TMUONS>();
auto mfttrack = muon.template matchMFTTrack_as<TMFTS>();
auto const& mfttrackcov = mftCovs.rawIteratorAt(mftCovIndexes[mfttrack.globalIndex()]);

auto muonTime = muontrack.trackTime() + bc_coll.globalBC() * o2::constants::lhc::LHCBunchSpacingNS;
Expand Down Expand Up @@ -657,9 +653,21 @@
bool IsAmbig = (muon.compatibleCollIds().size() != 1);
int MFTMult = collision.mftNtracks();

auto matchType = getMatchType(muon, muonTracks, mftTracks, matchablePairs, isBestMatch);
auto matchType = kMatchTypeUndefined;
if constexpr (isMc) {
matchType = getMatchType(muon, muonTracks, mftTracks, matchablePairs, isBestMatch);
}
bool isSignal = (matchType == kMatchTypeTrueLeading) || (matchType == kMatchTypeTrueNonLeading);

int mcMaskMuon = 0;
int mcMaskMft = 0;
int ncMaskGlob = 0;
if constexpr (isMc) {
mcMaskMuon = muontrack.mcMask();
mcMaskMft = mfttrack.mcMask();
ncMaskGlob = muon.mcMask();
}

registry.get<TH1>(HIST("matchType"))->Fill(static_cast<int>(matchType));

fwdMatchMLCandidates(
Expand Down Expand Up @@ -719,15 +727,48 @@
muon.fwdDcaY(),
IsAmbig,
MFTMult,
muontrack.mcMask(),
mfttrack.mcMask(),
muon.mcMask(),
mcMaskMuon,
mcMaskMft,
ncMaskGlob,
static_cast<int>(matchType),
isSignal);
}
}

void processMC(MyEvents const& collisions,
aod::BCsWithTimestamps const& bcs,
MyMuonsMC const& muonTracks,
MyMFTsMC const& mftTracks,
MyMFTCovariances const& mftCovs,
aod::McParticles const& /*mcParticles*/)
{
if (bcs.size() > 0) {
auto bc = bcs.begin();
initCCDB(bc);
VarManager::SetMatchingPlane(fzMatching.value);
}

fillTable<true>(collisions, bcs, muonTracks, mftTracks, mftCovs);
}

PROCESS_SWITCH(mftMchMatcher, processMC, "process_MC", true);

void processRD(MyEvents const& collisions,
aod::BCsWithTimestamps const& bcs,
MyMuonsWithCov const& muonTracks,
MyMFTs const& mftTracks,
MyMFTCovariances const& mftCovs)
{
if (bcs.size() > 0) {
auto bc = bcs.begin();
initCCDB(bc);
VarManager::SetMatchingPlane(fzMatching.value);
}

fillTable<false>(collisions, bcs, muonTracks, mftTracks, mftCovs);
}

PROCESS_SWITCH(mftMchMatcher, processRD, "process_RD", false);
};

WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
Expand Down
Loading
Loading