Skip to content

Commit 59e1781

Browse files
committed
Fix: fix minor selection bugs
1 parent 82863ee commit 59e1781

4 files changed

Lines changed: 82 additions & 53 deletions

File tree

PWGCF/Femto/Core/cascadeBuilder.h

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ struct ConfCascadeFilters : o2::framework::ConfigurableGroup {
6363
};
6464

6565
#define CASCADE_DEFAULT_BITS \
66+
o2::framework::Configurable<bool> passThrough{"passThrough", false, "If true, all Cascades are passed through. Bits for all selections are stored."}; \
6667
o2::framework::Configurable<std::vector<float>> cascadeCpaMin{"cascadeCpaMin", {0.95f}, "Minimum cosine of pointing angle"}; \
6768
o2::framework::Configurable<std::vector<float>> cascadeTransRadMin{"cascadeTransRadMin", {0.9f}, "Minimum transverse radius (cm)"}; \
6869
o2::framework::Configurable<std::vector<float>> cascadeDcaDauMax{"cascadeDcaDauMax", {0.25f}, "Maximum DCA between the daughters at decay vertex (cm)"}; \
@@ -179,19 +180,27 @@ class CascadeSelection : public BaseSelection<float, o2::aod::femtodatatypes::Ca
179180
template <typename T1, typename T2>
180181
void configure(o2::framework::HistogramRegistry* registry, T1 const& config, T2 const& filter)
181182
{
183+
// check for pass through mode
184+
mPassThrough = config.passThrough.value;
185+
186+
// if pass through mode is activated, each cut is neutral (i.e. neither minimal nor optional and we do
187+
// store all bits, so the most permissive bit is not skipped for minimal selections)
188+
const bool isMinimalCut = mPassThrough ? false : true;
189+
const bool skipMostPermissiveBit = mPassThrough ? false : true;
190+
182191
if constexpr (modes::isEqual(cascadeType, modes::Cascade::kXi)) {
183192
mXiMassLowerLimit = filter.massXiMin.value;
184193
mXiMassUpperLimit = filter.massXiMax.value;
185194
mOmegaMassLowerLimit = filter.rejectMassOmegaMin.value;
186195
mOmegaMassUpperLimit = filter.rejectMassOmegaMax.value;
187-
this->addSelection(kBachelorTpcPion, cascadeSelectionNames.at(kBachelorTpcPion), config.bachelorTpcPion.value, limits::kAbsUpperLimit, true, true, false);
196+
this->addSelection(kBachelorTpcPion, cascadeSelectionNames.at(kBachelorTpcPion), config.bachelorTpcPion.value, limits::kAbsUpperLimit, skipMostPermissiveBit, isMinimalCut, false);
188197
}
189198
if constexpr (modes::isEqual(cascadeType, modes::Cascade::kOmega)) {
190199
mOmegaMassLowerLimit = filter.massOmegaMin.value;
191200
mOmegaMassUpperLimit = filter.massOmegaMax.value;
192201
mXiMassLowerLimit = filter.rejectMassXiMin.value;
193202
mXiMassUpperLimit = filter.rejectMassXiMax.value;
194-
this->addSelection(kBachelorTpcKaon, cascadeSelectionNames.at(kBachelorTpcKaon), config.bachelorTpcKaon.value, limits::kAbsUpperLimit, true, true, false);
203+
this->addSelection(kBachelorTpcKaon, cascadeSelectionNames.at(kBachelorTpcKaon), config.bachelorTpcKaon.value, limits::kAbsUpperLimit, skipMostPermissiveBit, isMinimalCut, false);
195204
}
196205

197206
mPtMin = filter.ptMin.value;
@@ -203,19 +212,19 @@ class CascadeSelection : public BaseSelection<float, o2::aod::femtodatatypes::Ca
203212
mLambdaMassMin = filter.massLambdaMin.value;
204213
mLambdaMassMax = filter.massLambdaMax.value;
205214

206-
this->addSelection(kPosDauTpc, cascadeSelectionNames.at(kPosDauTpc), config.posDauTpc.value, limits::kAbsUpperLimit, true, true, false);
207-
this->addSelection(kNegDauTpc, cascadeSelectionNames.at(kNegDauTpc), config.negDauTpc.value, limits::kAbsUpperLimit, true, true, false);
215+
this->addSelection(kPosDauTpc, cascadeSelectionNames.at(kPosDauTpc), config.posDauTpc.value, limits::kAbsUpperLimit, skipMostPermissiveBit, isMinimalCut, false);
216+
this->addSelection(kNegDauTpc, cascadeSelectionNames.at(kNegDauTpc), config.negDauTpc.value, limits::kAbsUpperLimit, skipMostPermissiveBit, isMinimalCut, false);
208217

209-
this->addSelection(kCascadeCpaMin, cascadeSelectionNames.at(kCascadeCpaMin), config.cascadeCpaMin.value, limits::kLowerLimit, true, true, false);
210-
this->addSelection(kCascadeTransRadMin, cascadeSelectionNames.at(kCascadeTransRadMin), config.cascadeTransRadMin.value, limits::kLowerLimit, true, true, false);
211-
this->addSelection(kCascadeDcaDaughMax, cascadeSelectionNames.at(kCascadeDcaDaughMax), config.cascadeDcaDauMax.value, limits::kAbsUpperLimit, true, true, false);
212-
this->addSelection(kLambdaCpaMin, cascadeSelectionNames.at(kLambdaCpaMin), config.lambdaCpaMin.value, limits::kLowerLimit, true, true, false);
213-
this->addSelection(kLambdaTransRadMin, cascadeSelectionNames.at(kLambdaTransRadMin), config.lambdaTransRadMin.value, limits::kLowerLimit, true, true, false);
214-
this->addSelection(kLambdaDcaDauMax, cascadeSelectionNames.at(kLambdaDcaDauMax), config.lambdaDcaDauMax.value, limits::kAbsUpperLimit, true, true, false);
215-
this->addSelection(kLambdaDcaToPvMin, cascadeSelectionNames.at(kLambdaDcaToPvMin), config.lambdaDcaToPvMin.value, limits::kLowerLimit, true, true, false);
216-
this->addSelection(kDauAbsEtaMax, cascadeSelectionNames.at(kDauAbsEtaMax), config.dauAbsEtaMax.value, limits::kAbsUpperLimit, true, true, false);
217-
this->addSelection(kDauDcaMin, cascadeSelectionNames.at(kDauDcaMin), config.dauDcaMin.value, limits::kAbsLowerLimit, true, true, false);
218-
this->addSelection(kDauTpcClsMin, cascadeSelectionNames.at(kDauTpcClsMin), config.dauTpcClustersMin.value, limits::kLowerLimit, true, true, false);
218+
this->addSelection(kCascadeCpaMin, cascadeSelectionNames.at(kCascadeCpaMin), config.cascadeCpaMin.value, limits::kLowerLimit, skipMostPermissiveBit, isMinimalCut, false);
219+
this->addSelection(kCascadeTransRadMin, cascadeSelectionNames.at(kCascadeTransRadMin), config.cascadeTransRadMin.value, limits::kLowerLimit, skipMostPermissiveBit, isMinimalCut, false);
220+
this->addSelection(kCascadeDcaDaughMax, cascadeSelectionNames.at(kCascadeDcaDaughMax), config.cascadeDcaDauMax.value, limits::kAbsUpperLimit, skipMostPermissiveBit, isMinimalCut, false);
221+
this->addSelection(kLambdaCpaMin, cascadeSelectionNames.at(kLambdaCpaMin), config.lambdaCpaMin.value, limits::kLowerLimit, skipMostPermissiveBit, isMinimalCut, false);
222+
this->addSelection(kLambdaTransRadMin, cascadeSelectionNames.at(kLambdaTransRadMin), config.lambdaTransRadMin.value, limits::kLowerLimit, skipMostPermissiveBit, isMinimalCut, false);
223+
this->addSelection(kLambdaDcaDauMax, cascadeSelectionNames.at(kLambdaDcaDauMax), config.lambdaDcaDauMax.value, limits::kAbsUpperLimit, skipMostPermissiveBit, isMinimalCut, false);
224+
this->addSelection(kLambdaDcaToPvMin, cascadeSelectionNames.at(kLambdaDcaToPvMin), config.lambdaDcaToPvMin.value, limits::kLowerLimit, skipMostPermissiveBit, isMinimalCut, false);
225+
this->addSelection(kDauAbsEtaMax, cascadeSelectionNames.at(kDauAbsEtaMax), config.dauAbsEtaMax.value, limits::kAbsUpperLimit, skipMostPermissiveBit, isMinimalCut, false);
226+
this->addSelection(kDauDcaMin, cascadeSelectionNames.at(kDauDcaMin), config.dauDcaMin.value, limits::kAbsLowerLimit, skipMostPermissiveBit, isMinimalCut, false);
227+
this->addSelection(kDauTpcClsMin, cascadeSelectionNames.at(kDauTpcClsMin), config.dauTpcClustersMin.value, limits::kLowerLimit, skipMostPermissiveBit, isMinimalCut, false);
219228

220229
this->setupContainers<HistName>(registry);
221230
};
@@ -307,13 +316,17 @@ class CascadeSelection : public BaseSelection<float, o2::aod::femtodatatypes::Ca
307316
return false; // should never happen
308317
}
309318

319+
bool passThroughAllCascades() const { return mPassThrough; }
320+
310321
protected:
311322
float mXiMassLowerLimit = 0.f;
312323
float mXiMassUpperLimit = 999.f;
313324

314325
float mOmegaMassLowerLimit = 0.f;
315326
float mOmegaMassUpperLimit = 999.f;
316327

328+
bool mPassThrough = false;
329+
317330
// kinematic filters
318331
float mPtMin = 0.f;
319332
float mPtMax = 6.f;
@@ -390,11 +403,11 @@ class CascadeBuilder
390403
int64_t posDaughterIndex = 0;
391404
int64_t negDaughterIndex = 0;
392405
for (const auto& cascade : cascades) {
393-
if (!mCascadeSelection.checkFilters(cascade)) {
406+
if (!mCascadeSelection.passThroughAllCascades() && !mCascadeSelection.checkFilters(cascade)) {
394407
continue;
395408
}
396409
mCascadeSelection.applySelections(cascade, tracks, col);
397-
if (!mCascadeSelection.passesAllRequiredSelections()) {
410+
if (!mCascadeSelection.passThroughAllCascades() && !mCascadeSelection.passesAllRequiredSelections()) {
398411
continue;
399412
}
400413

@@ -424,11 +437,11 @@ class CascadeBuilder
424437
int64_t posDaughterIndex = 0;
425438
int64_t negDaughterIndex = 0;
426439
for (const auto& cascade : cascades) {
427-
if (!mCascadeSelection.checkFilters(cascade)) {
440+
if (!mCascadeSelection.passThroughAllCascades() && !mCascadeSelection.checkFilters(cascade)) {
428441
continue;
429442
}
430443
mCascadeSelection.applySelections(cascade, tracks, col);
431-
if (!mCascadeSelection.passesAllRequiredSelections()) {
444+
if (!mCascadeSelection.passThroughAllCascades() && !mCascadeSelection.passesAllRequiredSelections()) {
432445
continue;
433446
}
434447

@@ -438,19 +451,17 @@ class CascadeBuilder
438451
bachelorIndex = trackBuilder.template getDaughterIndex<system, modes::Track::kCascadeBachelor>(col, collisionProducts, mcCols, bachelor, trackProducts, mcParticles, mcBuilder, mcProducts);
439452

440453
auto posDaughter = cascade.template posTrack_as<T8>();
441-
posDaughterIndex = trackBuilder.template getDaughterIndex<system, modes::Track::kCascadeBachelor>(col, collisionProducts, mcCols, posDaughter, trackProducts, mcParticles, mcBuilder, mcProducts);
454+
posDaughterIndex = trackBuilder.template getDaughterIndex<system, modes::Track::kV0Daughter>(col, collisionProducts, mcCols, posDaughter, trackProducts, mcParticles, mcBuilder, mcProducts);
442455

443456
auto negDaughter = cascade.template negTrack_as<T8>();
444-
negDaughterIndex = trackBuilder.template getDaughterIndex<system, modes::Track::kCascadeBachelor>(col, collisionProducts, mcCols, negDaughter, trackProducts, mcParticles, mcBuilder, mcProducts);
457+
negDaughterIndex = trackBuilder.template getDaughterIndex<system, modes::Track::kV0Daughter>(col, collisionProducts, mcCols, negDaughter, trackProducts, mcParticles, mcBuilder, mcProducts);
445458

446459
fillCascade(collisionProducts, cascadeProducts, cascade, col, bachelorIndex, posDaughterIndex, negDaughterIndex);
447460
if constexpr (modes::isEqual(cascadeType, modes::Cascade::kXi)) {
448461
mcBuilder.template fillMcXiWithLabel<system>(col, mcCols, cascade, mcParticles, mcProducts);
449-
;
450462
}
451463
if constexpr (modes::isEqual(cascadeType, modes::Cascade::kOmega)) {
452464
mcBuilder.template fillMcOmegaWithLabel<system>(col, mcCols, cascade, mcParticles, mcProducts);
453-
;
454465
}
455466
}
456467
}
@@ -481,7 +492,7 @@ class CascadeBuilder
481492
cascade.v0cosPA(col.posX(), col.posY(), col.posZ()),
482493
cascade.dcaV0daughters(),
483494
cascade.v0radius(),
484-
cascade.dcav0topv(col.posY(), col.posY(), col.posZ()));
495+
cascade.dcav0topv(col.posX(), col.posY(), col.posZ()));
485496
}
486497
}
487498
if constexpr (modes::isEqual(cascadeType, modes::Cascade::kOmega)) {
@@ -507,7 +518,7 @@ class CascadeBuilder
507518
cascade.v0cosPA(col.posX(), col.posY(), col.posZ()),
508519
cascade.dcaV0daughters(),
509520
cascade.v0radius(),
510-
cascade.dcav0topv(col.posY(), col.posY(), col.posZ()));
521+
cascade.dcav0topv(col.posX(), col.posY(), col.posZ()));
511522
}
512523
}
513524
}

PWGCF/Femto/Core/cascadeHistManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ constexpr std::array<histmanager::HistInfo<CascadeHist>, kCascadeHistLast> HistT
136136
{kEta, o2::framework::HistType::kTH1F, "hEta", "Pseudorapdity; #eta; Entries"},
137137
{kPhi, o2::framework::HistType::kTH1F, "hPhi", "Azimuthal angle; #varphi; Entries"},
138138
{kMass, o2::framework::HistType::kTH1F, "hMass", "Invariant Mass; m_{Inv} (GeV/#it{c}^{2}); Entries"},
139-
{kSign, o2::framework::HistType::kTH1F, "hSign", "Sign (-1 -> antiparticle, 0 -> self conjugate, +1 -> particle); sign; Entries"},
139+
{kSign, o2::framework::HistType::kTH1F, "hSign", "Sign (-1 -> particle, 0 -> self conjugate, +1 -> antiparticle); sign; Entries"},
140140
{kPtVsMass, o2::framework::HistType::kTH2F, "hPtVsMass", "Transverse momentum vs invariant mass; p_{T} (GeV/#it{c}); m_{Inv} (GeV/#it{c}^{2})"},
141141
{kMassXi, o2::framework::HistType::kTH1F, "hMassXi", "Mass #Xi; m_{#Lambda#pi} (GeV/#it{c}^{2}); Entries"},
142142
{kMassOmega, o2::framework::HistType::kTH1F, "hMassOmega", "mass #Omega; m_{#LambdaK} (GeV/#it{c}^{2}); Entries"},

PWGCF/Femto/Core/trackBuilder.h

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ const std::unordered_map<TrackSels, std::string> trackSelectionNames = {
241241
{kTPCcRowsMin, "Min. number of crossed TPC rows"},
242242
{kTPCnClsOvercRowsMin, "Min. fraction of TPC clusters over TPC crossed rows"},
243243
{kTPCsClsMax, "Max. number of shared TPC clusters"},
244-
{kTPCsClsMax, "Max. number of shared TPC clusters"},
244+
// NOTE: removed duplicate {kTPCsClsMax, ...} entry that was here (harmless but dead duplicate key).
245245
{kTPCsClsFracMax, "Max. fractions of shared TPC clusters"},
246246
{kITSnClsMin, "Min. number of ITS clusters"},
247247
{kITSnClsIbMin, "Min. number of ITS clusters in the inner barrel"},
@@ -588,15 +588,18 @@ class TrackBuilder
588588
}
589589

590590
template <modes::Track type, typename T1, typename T2, typename T3>
591-
void fillTrack(T1 const& track, T2& trackProducts, T3& collisionProducts)
591+
bool fillTrack(T1 const& track, T2& trackProducts, T3& collisionProducts)
592592
{
593-
if (mProduceTracks) {
594-
trackProducts.producedTracks(collisionProducts.producedCollision.lastIndex(),
595-
track.pt() * track.sign(),
596-
track.eta(),
597-
track.phi());
598-
indexMap.emplace(track.globalIndex(), trackProducts.producedTracks.lastIndex());
593+
if (!mProduceTracks) {
594+
return false;
599595
}
596+
597+
trackProducts.producedTracks(collisionProducts.producedCollision.lastIndex(),
598+
track.pt() * track.sign(),
599+
track.eta(),
600+
track.phi());
601+
indexMap.emplace(track.globalIndex(), trackProducts.producedTracks.lastIndex());
602+
600603
if (mProduceTrackMasks) {
601604
if constexpr (type == modes::Track::kTrack) {
602605
trackProducts.producedTrackMasks(mTrackSelection.getBitmask());
@@ -672,6 +675,7 @@ class TrackBuilder
672675
}
673676
trackProducts.producedHeliumPids(itsHe, track.tpcNSigmaHe(), track.tofNSigmaHe());
674677
}
678+
return true;
675679
}
676680

677681
template <modes::System system, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10>
@@ -681,6 +685,7 @@ class TrackBuilder
681685
return;
682686
}
683687
for (const auto& trackWithItsPid : tracksWithItsPid) {
688+
// NOTE: passThrough is intentionally not wired in here yet for the MC path (to be added later).
684689
if (!mTrackSelection.checkFilters(trackWithItsPid)) {
685690
continue;
686691
}
@@ -696,13 +701,16 @@ class TrackBuilder
696701
}
697702

698703
template <modes::System system, modes::Track trackType, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
699-
void fillMcTrack(T1 const& col, T2& collisionProducts, T3 const& mcCols, T4 const& track, T5 const& trackWithItsPid, T6& trackProducts, T7 const& mcParticles, T8& mcBuilder, T9& mcProducts)
704+
bool fillMcTrack(T1 const& col, T2& collisionProducts, T3 const& mcCols, T4 const& track, T5 const& trackWithItsPid, T6& trackProducts, T7 const& mcParticles, T8& mcBuilder, T9& mcProducts)
700705
{
706+
// NOTE: return value added, mirroring fillTrack(), so getDaughterIndex can detect
707+
// whether a row was actually added before trusting lastIndex().
701708
if (!mProduceTracks) {
702-
return;
709+
return false;
703710
}
704711
this->template fillTrack<trackType>(trackWithItsPid, trackProducts, collisionProducts);
705712
mcBuilder.template fillMcTrackWithLabel<system>(col, mcCols, track, mcParticles, mcProducts);
713+
return true;
706714
}
707715

708716
template <modes::Track type, typename T1, typename T2, typename T3>
@@ -711,11 +719,13 @@ class TrackBuilder
711719
auto result = utils::getIndex(daughter.globalIndex(), indexMap);
712720
if (result) {
713721
return result.value();
714-
} else {
715-
this->fillTrack<type>(daughter, trackProducts, collisionProducts);
716-
int64_t idx = trackProducts.producedTracks.lastIndex();
717-
return idx;
718722
}
723+
if (!this->template fillTrack<type>(daughter, trackProducts, collisionProducts)) {
724+
LOG(fatal) << "Trying to register a daughter track, but FTracks table is disabled. "
725+
<< "Enable TrackTables.produceTracks when V0/Cascade/Kink tables that need daughter indices are enabled.";
726+
}
727+
// daughter is last track which was added added
728+
return trackProducts.producedTracks.lastIndex();
719729
}
720730

721731
template <modes::System system, modes::Track type, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
@@ -725,11 +735,13 @@ class TrackBuilder
725735
if (result) {
726736
// daugher already in track table
727737
return result.value();
728-
} else {
729-
this->fillMcTrack<system, type>(col, collisionProducts, mcCols, daughter, daughter, trackProducts, mcParticles, mcBuilder, mcProducts);
730-
// daughter is last track which was added added
731-
return trackProducts.producedTracks.lastIndex();
732738
}
739+
if (!this->template fillMcTrack<system, type>(col, collisionProducts, mcCols, daughter, daughter, trackProducts, mcParticles, mcBuilder, mcProducts)) {
740+
LOG(fatal) << "Trying to register a MC daughter track, but FTracks table is disabled. "
741+
<< "Enable TrackTables.produceTracks when V0/Cascade/Kink tables that need daughter indices are enabled.";
742+
}
743+
// daughter is last track which was added added
744+
return trackProducts.producedTracks.lastIndex();
733745
}
734746

735747
template <typename T>

0 commit comments

Comments
 (0)