Skip to content

Commit de7648b

Browse files
committed
Feat: fix TOF selection logic of daughter tracks
1 parent 858ef22 commit de7648b

2 files changed

Lines changed: 26 additions & 16 deletions

File tree

‎PWGCF/Femto/Core/cascadeBuilder.h‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <array>
3434
#include <cmath>
3535
#include <cstdint>
36+
#include <limits>
3637
#include <string>
3738
#include <unordered_map>
3839
#include <vector>
@@ -80,8 +81,8 @@ struct ConfCascadeFilters : o2::framework::ConfigurableGroup {
8081
o2::framework::Configurable<std::vector<float>> negDauTpc{"negDauTpc", {5.f}, "Maximum |nsigma_Pion/Proton| TPC for negative daughter tracks"}; \
8182
o2::framework::Configurable<std::vector<float>> posDauTof{"posDauTof", {}, "Maximum |nsigma_Pion/Proton| TOF for positive daughter tracks"}; \
8283
o2::framework::Configurable<std::vector<float>> negDauTof{"negDauTof", {}, "Maximum |nsigma_Pion/Proton| TOF for negative daughter tracks"}; \
83-
o2::framework::Configurable<bool> requireTof{"requireTof", false, "If true, TOF PID is a mandatory selection"}; \
84-
o2::framework::Configurable<bool> keepTracksWithoutTof{"keepTracksWithoutTof", true, "If true, candidates whose daughters have no TOF signal are kept"};
84+
o2::framework::Configurable<bool> requireTof{"requireTof", false, "If true, the TOF PID cut is mandatory. For daughters with a TOF signal, the candidate is rejected on failure. For daughters without a TOF signal, the candidate is rejected unless keepTracksWithoutTof is true"}; \
85+
o2::framework::Configurable<bool> keepTracksWithoutTof{"keepTracksWithoutTof", true, "If true, daughters without a TOF signal pass the TOF PID cut unconditionally, overriding requireTof. If false, daughters without a TOF signal fail the TOF cut (and are rejected if requireTof is true)"};
8586

8687
struct ConfXiBits : o2::framework::ConfigurableGroup {
8788
std::string prefix = std::string("XiBits");
@@ -256,7 +257,7 @@ class CascadeSelection : public baseselection::BaseSelection<float, o2::analysis
256257
mOmegaMassLowerLimit = filter.rejectMassOmegaMin.value;
257258
mOmegaMassUpperLimit = filter.rejectMassOmegaMax.value;
258259
this->addSelection(kBachelorTpcPion, cascadeSelectionNames.at(kBachelorTpcPion), config.bachelorTpcPion.value, limits::kAbsUpperLimit, true, true, false);
259-
this->addSelection(kBachelorTofPion, cascadeSelectionNames.at(kBachelorTofPion), config.bachelorTofPion.value, limits::kAbsUpperLimit, true, mRequireTof, false);
260+
this->addSelection(kBachelorTofPion, cascadeSelectionNames.at(kBachelorTofPion), config.bachelorTofPion.value, limits::kAbsUpperLimit, mRequireTof, mRequireTof, false);
260261
}
261262
if constexpr (modes::isEqual(cascadeType, modes::Cascade::kOmega)) {
262263
mOmegaMassLowerLimit = filter.massOmegaMin.value;
@@ -265,13 +266,13 @@ class CascadeSelection : public baseselection::BaseSelection<float, o2::analysis
265266
mXiMassLowerLimit = filter.rejectMassXiMin.value;
266267
mXiMassUpperLimit = filter.rejectMassXiMax.value;
267268
this->addSelection(kBachelorTpcKaon, cascadeSelectionNames.at(kBachelorTpcKaon), config.bachelorTpcKaon.value, limits::kAbsUpperLimit, true, true, false);
268-
this->addSelection(kBachelorTofKaon, cascadeSelectionNames.at(kBachelorTofKaon), config.bachelorTofKaon.value, limits::kAbsUpperLimit, true, mRequireTof, false);
269+
this->addSelection(kBachelorTofKaon, cascadeSelectionNames.at(kBachelorTofKaon), config.bachelorTofKaon.value, limits::kAbsUpperLimit, mRequireTof, mRequireTof, false);
269270
}
270271

271272
this->addSelection(kPosDauTpc, cascadeSelectionNames.at(kPosDauTpc), config.posDauTpc.value, limits::kAbsUpperLimit, true, true, false);
272273
this->addSelection(kNegDauTpc, cascadeSelectionNames.at(kNegDauTpc), config.negDauTpc.value, limits::kAbsUpperLimit, true, true, false);
273-
this->addSelection(kPosDauTof, cascadeSelectionNames.at(kPosDauTof), config.posDauTof.value, limits::kAbsUpperLimit, true, mRequireTof, false);
274-
this->addSelection(kNegDauTof, cascadeSelectionNames.at(kNegDauTof), config.negDauTof.value, limits::kAbsUpperLimit, true, mRequireTof, false);
274+
this->addSelection(kPosDauTof, cascadeSelectionNames.at(kPosDauTof), config.posDauTof.value, limits::kAbsUpperLimit, mRequireTof, mRequireTof, false);
275+
this->addSelection(kNegDauTof, cascadeSelectionNames.at(kNegDauTof), config.negDauTof.value, limits::kAbsUpperLimit, mRequireTof, mRequireTof, false);
275276

276277
this->addSelection(kCascadeCpaMin, cascadeSelectionNames.at(kCascadeCpaMin), filter.ptMin.value, filter.ptMax.value, config.cascadeCpaMin.value, limits::kLowerFunctionLimit, true, true, false);
277278
this->addSelection(kCascadePaMax, cascadeSelectionNames.at(kCascadePaMax), filter.ptMin.value, filter.ptMax.value, config.cascadePaMax.value, limits::kUpperFunctionLimit, true, true, false);
@@ -341,14 +342,18 @@ class CascadeSelection : public baseselection::BaseSelection<float, o2::analysis
341342

342343
// pid selections
343344
// TPC nSigma comes from the daughter track, TOF nSigma and the has-TOF flags from the cascade candidate
344-
// if a daughter has no TOF signal, feed 0 so the bit passes any limit (opt-in via keepTracksWithoutTof)
345+
// if a daughter has no TOF signal: feed 0 so the bit passes any limit if keepTracksWithoutTof is set,
346+
// overriding requireTof; otherwise feed a value that fails every limit, so that if requireTof is also
347+
// true, the mandatory TOF cut correctly rejects the candidate instead of silently letting it through
345348
auto evaluatePid = [this](CascadeSels tpcBit, float tpcNSigma,
346349
CascadeSels tofBit, float tofNSigma, bool hasTof) {
347350
this->evaluateObservable(tpcBit, tpcNSigma);
348351
if (hasTof) {
349352
this->evaluateObservable(tofBit, tofNSigma);
350353
} else if (mKeepTracksWithoutTof) {
351354
this->evaluateObservable(tofBit, 0.f);
355+
} else {
356+
this->evaluateObservable(tofBit, std::numeric_limits<float>::max());
352357
}
353358
};
354359

‎PWGCF/Femto/Core/v0Builder.h‎

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <array>
3434
#include <cmath>
3535
#include <cstdint>
36+
#include <limits>
3637
#include <string>
3738
#include <unordered_map>
3839
#include <vector>
@@ -72,8 +73,8 @@ struct ConfV0Filters : o2::framework::ConfigurableGroup {
7273
o2::framework::Configurable<std::vector<float>> dauAbsEtaMax{"dauAbsEtaMax", {0.8f}, "Maximum |eta| for daughter tracks"}; \
7374
o2::framework::Configurable<std::vector<float>> dauAbsDcaxyMin{"dauAbsDcaxyMin", {0.05f}, "Minimum DCAxy of the daughters from primary vertex (cm)"}; \
7475
o2::framework::Configurable<std::vector<float>> dauTpcClustersMin{"dauTpcClustersMin", {80.f}, "Minimum number of TPC clusters for daughter tracks"}; \
75-
o2::framework::Configurable<bool> requireTof{"requireTof", false, "If true, TOF PID is a mandatory selection. If false, TOF PID is optional"}; \
76-
o2::framework::Configurable<bool> keepTracksWithoutTof{"keepTracksWithoutTof", true, "If true, the bit mask for the TOF selection will be true for all limits if the daughter track has no TOF"};
76+
o2::framework::Configurable<bool> requireTof{"requireTof", false, "If true, the TOF PID cut is mandatory. For daughters with a TOF signal, the candidate is rejected on failure. For daughters without a TOF signal, the candidate is rejected unless keepTracksWithoutTof is true"}; \
77+
o2::framework::Configurable<bool> keepTracksWithoutTof{"keepTracksWithoutTof", true, "If true, daughters without a TOF signal pass the TOF PID cut unconditionally, overriding requireTof. If false, daughters without a TOF signal fail the TOF cut (and are rejected if requireTof is true)"};
7778

7879
// derived selection bits for lambda
7980
struct ConfLambdaBits : o2::framework::ConfigurableGroup {
@@ -267,15 +268,15 @@ class V0Selection : public baseselection::BaseSelection<float, datatypes::V0Mask
267268
if constexpr (modes::isEqual(v0Type, modes::V0::kLambda)) {
268269
this->addSelection(kPosDaughTpcProton, v0SelectionNames.at(kPosDaughTpcProton), config.posDauTpcProton.value, limits::kAbsUpperLimit, true, true, false);
269270
this->addSelection(kNegDaughTpcPion, v0SelectionNames.at(kNegDaughTpcPion), config.negDauTpcPion.value, limits::kAbsUpperLimit, true, true, false);
270-
this->addSelection(kPosDaughTofProton, v0SelectionNames.at(kPosDaughTofProton), config.posDauTofProton.value, limits::kAbsUpperLimit, true, mRequireTof, false);
271-
this->addSelection(kNegDaughTofPion, v0SelectionNames.at(kNegDaughTofPion), config.negDauTofPion.value, limits::kAbsUpperLimit, true, mRequireTof, false);
271+
this->addSelection(kPosDaughTofProton, v0SelectionNames.at(kPosDaughTofProton), config.posDauTofProton.value, limits::kAbsUpperLimit, mRequireTof, mRequireTof, false);
272+
this->addSelection(kNegDaughTofPion, v0SelectionNames.at(kNegDaughTofPion), config.negDauTofPion.value, limits::kAbsUpperLimit, mRequireTof, mRequireTof, false);
272273
}
273274

274275
if constexpr (modes::isEqual(v0Type, modes::V0::kAntiLambda)) {
275276
this->addSelection(kPosDaughTpcPion, v0SelectionNames.at(kPosDaughTpcPion), config.posDauTpcPion.value, limits::kAbsUpperLimit, true, true, false);
276277
this->addSelection(kNegDaughTpcProton, v0SelectionNames.at(kNegDaughTpcProton), config.negDauTpcProton.value, limits::kAbsUpperLimit, true, true, false);
277-
this->addSelection(kPosDaughTofPion, v0SelectionNames.at(kPosDaughTofPion), config.posDauTofPion.value, limits::kAbsUpperLimit, true, mRequireTof, false);
278-
this->addSelection(kNegDaughTofProton, v0SelectionNames.at(kNegDaughTofProton), config.negDauTofProton.value, limits::kAbsUpperLimit, true, mRequireTof, false);
278+
this->addSelection(kPosDaughTofPion, v0SelectionNames.at(kPosDaughTofPion), config.posDauTofPion.value, limits::kAbsUpperLimit, mRequireTof, mRequireTof, false);
279+
this->addSelection(kNegDaughTofProton, v0SelectionNames.at(kNegDaughTofProton), config.negDauTofProton.value, limits::kAbsUpperLimit, mRequireTof, mRequireTof, false);
279280
}
280281
}
281282
if constexpr (modes::isEqual(v0Type, modes::V0::kK0short)) {
@@ -287,8 +288,8 @@ class V0Selection : public baseselection::BaseSelection<float, datatypes::V0Mask
287288

288289
this->addSelection(kPosDaughTpcPion, v0SelectionNames.at(kPosDaughTpcPion), config.posDauTpcPion.value, limits::kAbsUpperLimit, true, true, false);
289290
this->addSelection(kNegDaughTpcPion, v0SelectionNames.at(kNegDaughTpcPion), config.negDauTpcPion.value, limits::kAbsUpperLimit, true, true, false);
290-
this->addSelection(kPosDaughTofPion, v0SelectionNames.at(kPosDaughTofPion), config.posDauTofPion.value, limits::kAbsUpperLimit, true, mRequireTof, false);
291-
this->addSelection(kNegDaughTofPion, v0SelectionNames.at(kNegDaughTofPion), config.negDauTofPion.value, limits::kAbsUpperLimit, true, mRequireTof, false);
291+
this->addSelection(kPosDaughTofPion, v0SelectionNames.at(kPosDaughTofPion), config.posDauTofPion.value, limits::kAbsUpperLimit, mRequireTof, mRequireTof, false);
292+
this->addSelection(kNegDaughTofPion, v0SelectionNames.at(kNegDaughTofPion), config.negDauTofPion.value, limits::kAbsUpperLimit, mRequireTof, mRequireTof, false);
292293
}
293294

294295
this->addSelection(kDcaDaughMax, v0SelectionNames.at(kDcaDaughMax), config.dcaDauMax.value, limits::kAbsUpperLimit, true, true, false);
@@ -350,14 +351,18 @@ class V0Selection : public baseselection::BaseSelection<float, datatypes::V0Mask
350351

351352
// PID of the daughters under the mass hypothesis of this v0 type
352353
// TPC nSigma comes from the daughter track, TOF nSigma from the strangeness-tagged v0 candidate
353-
// if the daughter has no TOF signal, feed 0 so the bit passes any limit (opt-in via keepTracksWithoutTof)
354+
// if the daughter has no TOF signal: feed 0 so the bit passes any limit if keepTracksWithoutTof is set,
355+
// overriding requireTof; otherwise feed a value that fails every limit, so that if requireTof is also
356+
// true, the mandatory TOF cut correctly rejects the candidate instead of silently letting it through
354357
auto evaluateDaughterPid = [this](V0Sels tpcBit, float tpcNSigma,
355358
V0Sels tofBit, float tofNSigma, bool hasTof) {
356359
this->evaluateObservable(tpcBit, tpcNSigma);
357360
if (hasTof) {
358361
this->evaluateObservable(tofBit, tofNSigma);
359362
} else if (mKeepTracksWithoutTof) {
360363
this->evaluateObservable(tofBit, 0.f);
364+
} else {
365+
this->evaluateObservable(tofBit, std::numeric_limits<float>::max());
361366
}
362367
};
363368

0 commit comments

Comments
 (0)