Skip to content

Commit

Permalink
[PWGHF]: fix downscale of background for Xic tree creator (AliceO2Gro…
Browse files Browse the repository at this point in the history
…up#4221)

* fix to downsample to bkg only

* fix pdg access

* Please consider the following formatting changes

* Update PWGHF/TableProducer/treeCreatorXicToPKPi.cxx

Co-authored-by: Mattia Faggin <[email protected]>

* Update PWGHF/TableProducer/treeCreatorXicToPKPi.cxx

Co-authored-by: Mattia Faggin <[email protected]>

---------

Co-authored-by: ALICE Action Bot <[email protected]>
Co-authored-by: Mattia Faggin <[email protected]>
  • Loading branch information
3 people authored Dec 21, 2023
1 parent 2e1b15a commit dcdf57c
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions PWGHF/TableProducer/treeCreatorXicToPKPi.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ struct HfTreeCreatorXicToPKPi {
Configurable<bool> fillCandidateLiteTable{"fillCandidateLiteTable", false, "Switch to fill lite table with candidate properties"};
// parameters for production of training samples
Configurable<float> downSampleBkgFactor{"downSampleBkgFactor", 1., "Fraction of background candidates to keep for ML trainings"};
Configurable<float> ptMaxForDownSample{"ptMaxForDownSample", 10., "Maximum pt for the application of the downsampling factor"};
Configurable<bool> fillOnlyBackground{"fillOnlyBackground", false, "Flag to fill derived tables with background for ML trainings"};

HfHelper hfHelper;

Expand Down Expand Up @@ -272,15 +274,21 @@ struct HfTreeCreatorXicToPKPi {
auto trackPos1 = candidate.prong0_as<TracksWPid>(); // positive daughter (negative for the antiparticles)
auto trackNeg = candidate.prong1_as<TracksWPid>(); // negative daughter (positive for the antiparticles)
auto trackPos2 = candidate.prong2_as<TracksWPid>(); // positive daughter (negative for the antiparticles)
if (fillOnlyBackground && downSampleBkgFactor < 1.) {
double pseudoRndm = trackPos1.pt() * 1000. - static_cast<int64_t>(trackPos1.pt() * 1000);
if (candidate.pt() < ptMaxForDownSample && pseudoRndm >= downSampleBkgFactor) {
continue;
}
}
auto fillTable = [&](int CandFlag,
int FunctionSelection,
float FunctionInvMass,
float FunctionCt,
float FunctionY,
float FunctionE) {
double pseudoRndm = trackPos1.pt() * 1000. - (int64_t)(trackPos1.pt() * 1000);
if (FunctionSelection >= 1 && pseudoRndm < downSampleBkgFactor) {
if (FunctionSelection >= 1) {
if (fillCandidateLiteTable) {

rowCandidateLite(
candidate.chi2PCA(),
candidate.decayLength(),
Expand Down Expand Up @@ -451,14 +459,19 @@ struct HfTreeCreatorXicToPKPi {
auto trackPos1 = candidate.prong0_as<TracksWPid>(); // positive daughter (negative for the antiparticles)
auto trackNeg = candidate.prong1_as<TracksWPid>(); // negative daughter (positive for the antiparticles)
auto trackPos2 = candidate.prong2_as<TracksWPid>(); // positive daughter (negative for the antiparticles)
if (downSampleBkgFactor < 1.) {
double pseudoRndm = trackPos1.pt() * 1000. - static_cast<int64_t>(trackPos1.pt() * 1000);
if (candidate.pt() < ptMaxForDownSample && pseudoRndm >= downSampleBkgFactor) {
continue;
}
}
auto fillTable = [&](int CandFlag,
int FunctionSelection,
float FunctionInvMass,
float FunctionCt,
float FunctionY,
float FunctionE) {
double pseudoRndm = trackPos1.pt() * 1000. - (int64_t)(trackPos1.pt() * 1000);
if (FunctionSelection >= 1 && pseudoRndm < downSampleBkgFactor) {
if (FunctionSelection >= 1) {
if (fillCandidateLiteTable) {
rowCandidateLite(
candidate.chi2PCA(),
Expand Down Expand Up @@ -577,6 +590,7 @@ struct HfTreeCreatorXicToPKPi {
}
}
};

fillTable(0, candidate.isSelXicToPKPi(), hfHelper.invMassXicToPKPi(candidate), hfHelper.ctXic(candidate), hfHelper.yXic(candidate), hfHelper.eXic(candidate));
fillTable(1, candidate.isSelXicToPiKP(), hfHelper.invMassXicToPiKP(candidate), hfHelper.ctXic(candidate), hfHelper.yXic(candidate), hfHelper.eXic(candidate));
}
Expand Down

0 comments on commit dcdf57c

Please sign in to comment.