Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions PWGCF/Femto/Core/baseSelection.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,48 @@ class BaseSelection
mSelectionContainers.at(observableIndex) = SelectionContainer<T, BitmaskType>(baseName, lowerLimit, upperLimit, selectionValues, limitType, skipMostPermissiveBit, isMinimalCut);
}

/// \brief Add a boolean based selection for a specific observable.
/// \param mode Whether the selection is not applied, minimal or optional cut
/// \param observableIndex Index of the observable.
void addSelection(int mode, int observableIndex)
{
if (static_cast<size_t>(observableIndex) >= NumObservables) {
LOG(fatal) << "Observable is not valid. Observable (index) has to be smaller than " << NumObservables;
}
switch (mode) {
case -1: // cut is optional and we store bit for the cut
mNSelections += 1;
mHasOptionalSelection = true;
mSelectionContainers.at(observableIndex) = SelectionContainer<T, BitmaskType>(std::vector<T>{1}, limits::LimitType::kEqual, false, false);
break;
case 0: // cut is not applied, initalize with empty vector, so we bail out later
mSelectionContainers.at(observableIndex) = SelectionContainer<T, BitmaskType>(std::vector<T>{}, limits::LimitType::kEqual, false, false);
break;
case 1: // cut is added as mininal selection (since it is only one value, not extra bit is stored)
mSelectionContainers.at(observableIndex) = SelectionContainer<T, BitmaskType>(std::vector<T>{1}, limits::LimitType::kEqual, true, true);
break;
default:
LOG(fatal) << "Invalid switch for boolean selection";
}
if (mNSelections >= sizeof(BitmaskType) * CHAR_BIT) {
LOG(fatal) << "Too many selections. At most " << sizeof(BitmaskType) * CHAR_BIT << " are supported";
}
}

/// \brief Update the limits of a function-based selection for a specific observable.
/// \param observable Index of the observable.
/// \param value Value at which to evaluate the selection functions.
void updateLimits(int observable, T value) { mSelectionContainers.at(observable).updateLimits(value); }
void updateLimits(int observable, T value)
{
mSelectionContainers.at(observable).updateLimits(value);
}

/// \brief Reset the internal bitmask and evaluation flags before evaluating a new event.
void reset()
{
mFinalBitmask.reset();
mPassesMinimalSelections = true;
// will be true if no optional cut as been defined and
// will be true if no optional cut has been defined and
// will be set to false if we have optional cuts (but will be set to true in the case at least one optional cut succeeds)
mPassesOptionalSelections = !mHasOptionalSelection;
}
Expand Down
54 changes: 27 additions & 27 deletions PWGCF/Femto/Core/cascadeBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,23 +337,23 @@ class CascadeBuilder
template <typename T1, typename T2, typename T3, typename T4>
void init(T1& config, T2& filter, T3& table, T4& initContext)
{
cascadeSelection.configure(config, filter);
mCascadeSelection.configure(config, filter);
if constexpr (modes::isEqual(cascadeType, modes::Cascade::kXi)) {
LOG(info) << "Initialize femto Xi builder...";
produceXis = utils::enableTable("FXis_001", table.produceXis.value, initContext);
produceXiMasks = utils::enableTable("FXiMasks_001", table.produceXiMasks.value, initContext);
produceXiExtras = utils::enableTable("FXiExtras_001", table.produceXiExtras.value, initContext);
mProduceXis = utils::enableTable("FXis_001", table.produceXis.value, initContext);
mProduceXiMasks = utils::enableTable("FXiMasks_001", table.produceXiMasks.value, initContext);
mProduceXiExtras = utils::enableTable("FXiExtras_001", table.produceXiExtras.value, initContext);
}
if constexpr (modes::isEqual(cascadeType, modes::Cascade::kOmega)) {
LOG(info) << "Initialize femto Omega builder...";
produceOmegas = utils::enableTable("FOmegas_001", table.produceOmegas.value, initContext);
produceOmegaMasks = utils::enableTable("FOmegaMasks_001", table.produceOmegaMasks.value, initContext);
produceOmegaExtras = utils::enableTable("FOmegaExtras_001", table.produceOmegaExtras.value, initContext);
mProduceOmegas = utils::enableTable("FOmegas_001", table.produceOmegas.value, initContext);
mProduceOmegaMasks = utils::enableTable("FOmegaMasks_001", table.produceOmegaMasks.value, initContext);
mProduceOmegaExtras = utils::enableTable("FOmegaExtras_001", table.produceOmegaExtras.value, initContext);
}

if (produceXis || produceXiExtras || produceXiMasks || produceOmegas || produceOmegaMasks || produceOmegaExtras) {
if (mProduceXis || mProduceXiExtras || mProduceXiMasks || mProduceOmegas || mProduceOmegaMasks || mProduceOmegaExtras) {
mFillAnyTable = true;
cascadeSelection.printSelections(cascadeSelsName, cascadeSelsToString);
mCascadeSelection.printSelections(cascadeSelsName, cascadeSelsToString);
} else {
LOG(info) << "No tables configured";
}
Expand All @@ -371,11 +371,11 @@ class CascadeBuilder
int64_t posDaughterIndex = 0;
int64_t negDaughterIndex = 0;
for (const auto& cascade : fullCascades) {
if (!cascadeSelection.checkFilters(cascade)) {
if (!mCascadeSelection.checkFilters(cascade)) {
continue;
}
cascadeSelection.applySelections(cascade, fullTracks, col);
if (cascadeSelection.passesAllRequiredSelections() && cascadeSelection.checkHypothesis(cascade)) {
mCascadeSelection.applySelections(cascade, fullTracks, col);
if (mCascadeSelection.passesAllRequiredSelections() && mCascadeSelection.checkHypothesis(cascade)) {

auto bachelor = cascade.template bachelor_as<T5>();
auto posDaughter = cascade.template posTrack_as<T5>();
Expand All @@ -394,7 +394,7 @@ class CascadeBuilder
void fillCascade(T1& collisionProducts, T2& cascadeProducts, T3 const& cascade, T4 const& col, int bachelorIndex, int posDaughterIndex, int negDaughterIndex)
{
if constexpr (modes::isEqual(cascadeType, modes::Cascade::kXi)) {
if (produceXis) {
if (mProduceXis) {
cascadeProducts.producedXis(collisionProducts.producedCollision.lastIndex(),
cascade.sign() * cascade.pt(),
cascade.eta(),
Expand All @@ -404,10 +404,10 @@ class CascadeBuilder
posDaughterIndex,
negDaughterIndex);
}
if (produceXiMasks) {
cascadeProducts.producedXiMasks(cascadeSelection.getBitmask());
if (mProduceXiMasks) {
cascadeProducts.producedXiMasks(mCascadeSelection.getBitmask());
}
if (produceXiExtras) {
if (mProduceXiExtras) {
cascadeProducts.producedXiExtras(
cascade.mOmega(),
cascade.casccosPA(col.posX(), col.posY(), col.posZ()),
Expand All @@ -420,7 +420,7 @@ class CascadeBuilder
}
}
if constexpr (modes::isEqual(cascadeType, modes::Cascade::kOmega)) {
if (produceOmegas) {
if (mProduceOmegas) {
cascadeProducts.producedOmegas(collisionProducts.producedCollision.lastIndex(),
cascade.sign() * cascade.pt(),
cascade.eta(),
Expand All @@ -430,10 +430,10 @@ class CascadeBuilder
posDaughterIndex,
negDaughterIndex);
}
if (produceOmegaMasks) {
cascadeProducts.producedOmegaMasks(cascadeSelection.getBitmask());
if (mProduceOmegaMasks) {
cascadeProducts.producedOmegaMasks(mCascadeSelection.getBitmask());
}
if (produceOmegaExtras) {
if (mProduceOmegaExtras) {
cascadeProducts.producedOmegaExtras(
cascade.mXi(),
cascade.casccosPA(col.posX(), col.posY(), col.posZ()),
Expand All @@ -450,14 +450,14 @@ class CascadeBuilder
bool fillAnyTable() { return mFillAnyTable; }

private:
CascadeSelection<cascadeType> cascadeSelection;
CascadeSelection<cascadeType> mCascadeSelection;
bool mFillAnyTable = false;
bool produceXis = false;
bool produceXiMasks = false;
bool produceXiExtras = false;
bool produceOmegas = false;
bool produceOmegaMasks = false;
bool produceOmegaExtras = false;
bool mProduceXis = false;
bool mProduceXiMasks = false;
bool mProduceXiExtras = false;
bool mProduceOmegas = false;
bool mProduceOmegaMasks = false;
bool mProduceOmegaExtras = false;
};

} // namespace cascadebuilder
Expand Down
Loading
Loading