Skip to content

Commit a36ec1a

Browse files
authored
[PWGHF,Trigger] Add option to select only signal in MC and improve MC matching (AliceO2Group#9801)
1 parent 8dac72b commit a36ec1a

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

EventFiltering/PWGHF/HFFilterPrepareMLSamples.cxx

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ struct HfFilterPrepareMlSamples { // Main struct
5555
Produces<aod::HFTrigTrain3P> train3P;
5656

5757
// parameters for production of training samples
58-
Configurable<bool> fillSignal{"fillSignal", true, "Flag to fill derived tables with signal for ML trainings"};
58+
Configurable<bool> fillOnlySignal{"fillOnlySignal", true, "Flag to fill derived tables with signal for ML trainings"};
5959
Configurable<bool> fillOnlyBackground{"fillOnlyBackground", true, "Flag to fill derived tables with background for ML trainings"};
6060
Configurable<float> downSampleBkgFactor{"downSampleBkgFactor", 1., "Fraction of background candidates to keep for ML trainings"};
6161
Configurable<float> massSbLeftMin{"massSbLeftMin", 1.72, "Left Sideband Lower Minv limit 2 Prong"};
@@ -78,6 +78,10 @@ struct HfFilterPrepareMlSamples { // Main struct
7878

7979
void init(InitContext&)
8080
{
81+
if (fillOnlySignal && fillOnlyBackground) {
82+
LOGP(fatal, "fillOnlySignal and fillOnlyBackground cannot be activated simultaneously, exit");
83+
}
84+
8185
ccdb->setURL(url.value);
8286
ccdb->setCaching(true);
8387
ccdb->setLocalObjectValidityChecking();
@@ -268,7 +272,15 @@ struct HfFilterPrepareMlSamples { // Main struct
268272

269273
// D0(bar) → π± K∓
270274
bool isInCorrectColl{false};
271-
auto indexRec = RecoDecay::getMatchedMCRec(mcParticles, std::array{trackPos, trackNeg}, o2::constants::physics::Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &sign);
275+
auto indexRec = RecoDecay::getMatchedMCRec<false, false, false, true, true>(mcParticles, std::array{trackPos, trackNeg}, o2::constants::physics::Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &sign);
276+
277+
if (fillOnlySignal && indexRec < 0) {
278+
continue;
279+
}
280+
if (fillOnlyBackground && indexRec >= 0) {
281+
continue;
282+
}
283+
272284
if (indexRec > -1) {
273285
auto particle = mcParticles.rawIteratorAt(indexRec);
274286
flag = RecoDecay::getCharmHadronOrigin(mcParticles, particle);
@@ -355,32 +367,39 @@ struct HfFilterPrepareMlSamples { // Main struct
355367
int8_t channel = -1;
356368

357369
// D± → π± K∓ π±
358-
auto indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, o2::constants::physics::Pdg::kDPlus, std::array{+kPiPlus, -kKPlus, +kPiPlus}, true, &sign, 2);
370+
auto indexRec = RecoDecay::getMatchedMCRec<false, false, false, true, true>(mcParticles, arrayDaughters, o2::constants::physics::Pdg::kDPlus, std::array{+kPiPlus, -kKPlus, +kPiPlus}, true, &sign, 2);
359371
if (indexRec >= 0) {
360372
channel = kDplus;
361373
}
362374
if (indexRec < 0) {
363375
// Ds± → K± K∓ π±
364-
indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, o2::constants::physics::Pdg::kDS, std::array{+kKPlus, -kKPlus, +kPiPlus}, true, &sign, 2);
376+
indexRec = RecoDecay::getMatchedMCRec<false, false, false, true, true>(mcParticles, arrayDaughters, o2::constants::physics::Pdg::kDS, std::array{+kKPlus, -kKPlus, +kPiPlus}, true, &sign, 2);
365377
if (indexRec >= 0) {
366378
channel = kDs;
367379
}
368380
}
369381
if (indexRec < 0) {
370382
// Λc± → p± K∓ π±
371-
indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, o2::constants::physics::Pdg::kLambdaCPlus, std::array{+kProton, -kKPlus, +kPiPlus}, true, &sign, 2);
383+
indexRec = RecoDecay::getMatchedMCRec<false, false, false, true, true>(mcParticles, arrayDaughters, o2::constants::physics::Pdg::kLambdaCPlus, std::array{+kProton, -kKPlus, +kPiPlus}, true, &sign, 2);
372384
if (indexRec >= 0) {
373385
channel = kLc;
374386
}
375387
}
376388
if (indexRec < 0) {
377389
// Ξc± → p± K∓ π±
378-
indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, o2::constants::physics::Pdg::kXiCPlus, std::array{+kProton, -kKPlus, +kPiPlus}, true, &sign, 2);
390+
indexRec = RecoDecay::getMatchedMCRec<false, false, false, true, true>(mcParticles, arrayDaughters, o2::constants::physics::Pdg::kXiCPlus, std::array{+kProton, -kKPlus, +kPiPlus}, true, &sign, 2);
379391
if (indexRec >= 0) {
380392
channel = kXic;
381393
}
382394
}
383395

396+
if (fillOnlySignal && indexRec < 0) {
397+
continue;
398+
}
399+
if (fillOnlyBackground && indexRec >= 0) {
400+
continue;
401+
}
402+
384403
bool isInCorrectColl{false};
385404
if (indexRec > -1) {
386405
auto particle = mcParticles.rawIteratorAt(indexRec);

0 commit comments

Comments
 (0)