Skip to content

Commit 9c9b87b

Browse files
committed
[PWGDQ] add more fine-grained event sampling options
Additional configurable variables allow to define a sampling fraction separately for each match type. This allows to generate ML training samples with a more uniform statistics of tracks associated to the different match types. Ad additional variable enables the selection of tracks associated to eaither even or odd BCs, useful for eample to generate separate track samples for training and verification of the ML models.
1 parent 7bbb349 commit 9c9b87b

1 file changed

Lines changed: 64 additions & 2 deletions

File tree

PWGDQ/Tasks/mftMchMatcher.cxx

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,15 @@ struct mftMchMatcher {
240240
Configurable<float> fzMatching{"cfgzMatching", -77.5f, "Plane for MFT-MCH matching"};
241241

242242
Configurable<float> fSamplingFraction{"cfgSamplingFraction", 1.f, "Fraction of randomly selected events to be processed"};
243+
Configurable<float> fSamplingFractionTrueLeadingMatches{"cfgSamplingFractionTrueLeadingMatches", 1.f, "Fraction of randomly selected leading true matches to be processed"};
244+
Configurable<float> fSamplingFractionWrongLeadingMatches{"cfgSamplingFractionWrongLeadingMatches", 1.f, "Fraction of randomly selected leading wrong matches to be processed"};
245+
Configurable<float> fSamplingFractionDecayLeadingMatches{"cfgSamplingFractionDecayLeadingMatches", 1.f, "Fraction of randomly selected leading decay matches to be processed"};
246+
Configurable<float> fSamplingFractionFakeLeadingMatches{"cfgSamplingFractionFakeLeadingMatches", 1.f, "Fraction of randomly selected leading fake matches to be processed"};
247+
Configurable<float> fSamplingFractionTrueNonLeadingMatches{"cfgSamplingFractionTrueNonLeadingMatches", 1.f, "Fraction of randomly selected non-leading true matches to be processed"};
248+
Configurable<float> fSamplingFractionWrongNonLeadingMatches{"cfgSamplingFractionWrongNonLeadingMatches", 1.f, "Fraction of randomly selected non-leading wrong matches to be processed"};
249+
Configurable<float> fSamplingFractionDecayNonLeadingMatches{"cfgSamplingFractionDecayNonLeadingMatches", 1.f, "Fraction of randomly selected non-leading decay matches to be processed"};
250+
Configurable<float> fSamplingFractionFakeNonLeadingMatches{"cfgSamplingFractionFakeNonLeadingMatches", 1.f, "Fraction of randomly selected non-leading fake matches to be processed"};
251+
Configurable<int> fSamplingBcOddness{"cfgSamplingBcOddness", -1, "Select only events with even (0) or odd (1) global BCs"};
243252

244253
//// Variables for ccdb
245254
Configurable<std::string> ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
@@ -430,6 +439,17 @@ struct mftMchMatcher {
430439
hMatchType->GetXaxis()->SetBinLabel(7, "decay (non leading)");
431440
hMatchType->GetXaxis()->SetBinLabel(8, "fake (non leading)");
432441
hMatchType->GetXaxis()->SetBinLabel(9, "undefined");
442+
443+
auto hMatchTypeAccepted = std::get<std::shared_ptr<TH1>>(registry.add("matchTypeAccepted", "Match type (accepted)", {HistType::kTH1F, {matchTypeAxis}}));
444+
hMatchTypeAccepted->GetXaxis()->SetBinLabel(1, "true (leading)");
445+
hMatchTypeAccepted->GetXaxis()->SetBinLabel(2, "wrong (leading)");
446+
hMatchTypeAccepted->GetXaxis()->SetBinLabel(3, "decay (leading)");
447+
hMatchTypeAccepted->GetXaxis()->SetBinLabel(4, "fake (leading)");
448+
hMatchTypeAccepted->GetXaxis()->SetBinLabel(5, "true (non leading)");
449+
hMatchTypeAccepted->GetXaxis()->SetBinLabel(6, "wrong (non leading)");
450+
hMatchTypeAccepted->GetXaxis()->SetBinLabel(7, "decay (non leading)");
451+
hMatchTypeAccepted->GetXaxis()->SetBinLabel(8, "fake (non leading)");
452+
hMatchTypeAccepted->GetXaxis()->SetBinLabel(9, "undefined");
433453
}
434454

435455
template <typename TMuons>
@@ -603,8 +623,6 @@ struct mftMchMatcher {
603623
mftCovIndexes[mftTrackCov.matchMFTTrackId()] = mftTrackCov.globalIndex();
604624
}
605625

606-
fwdMatchMLCandidates.reserve(muonTracks.size());
607-
608626
for (auto muon : muonTracks) {
609627
// only consider global MFT-MCH-MID matches
610628
if (static_cast<int>(muon.trackType()) != 0) {
@@ -670,6 +688,50 @@ struct mftMchMatcher {
670688

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

691+
// skipp odd/even BCs if requested
692+
if (fSamplingBcOddness.value >= 0 && (static_cast<int>((bc_coll.globalBC() % 2)) != fSamplingBcOddness.value)) {
693+
continue;
694+
}
695+
696+
float matchTypeSamplingFraction = 1.0;
697+
switch (matchType) {
698+
case kMatchTypeTrueLeading:
699+
matchTypeSamplingFraction = fSamplingFractionTrueLeadingMatches;
700+
break;
701+
case kMatchTypeTrueNonLeading:
702+
matchTypeSamplingFraction = fSamplingFractionTrueNonLeadingMatches;
703+
break;
704+
case kMatchTypeWrongLeading:
705+
matchTypeSamplingFraction = fSamplingFractionWrongLeadingMatches;
706+
break;
707+
case kMatchTypeWrongNonLeading:
708+
matchTypeSamplingFraction = fSamplingFractionWrongNonLeadingMatches;
709+
break;
710+
case kMatchTypeDecayLeading:
711+
matchTypeSamplingFraction = fSamplingFractionDecayLeadingMatches;
712+
break;
713+
case kMatchTypeDecayNonLeading:
714+
matchTypeSamplingFraction = fSamplingFractionDecayNonLeadingMatches;
715+
break;
716+
case kMatchTypeFakeLeading:
717+
matchTypeSamplingFraction = fSamplingFractionFakeLeadingMatches;
718+
break;
719+
case kMatchTypeFakeNonLeading:
720+
matchTypeSamplingFraction = fSamplingFractionFakeNonLeadingMatches;
721+
break;
722+
default:
723+
break;
724+
}
725+
726+
if (matchTypeSamplingFraction < 1.0) {
727+
double rnd = mDistribution(mGenerator);
728+
if (rnd > matchTypeSamplingFraction) {
729+
continue;
730+
}
731+
}
732+
733+
registry.get<TH1>(HIST("matchTypeAccepted"))->Fill(static_cast<int>(matchType));
734+
673735
fwdMatchMLCandidates(
674736
muonprop.getX(),
675737
muonprop.getY(),

0 commit comments

Comments
 (0)