Skip to content
Closed
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
51 changes: 39 additions & 12 deletions PWGEM/Dilepton/DataModel/dileptonTables.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,28 @@
}
return bitMap;
}

// enum that is used as an index for an event-counter during the DD production.
// This keeps the DD size minimal as its only filled once per DF
enum EMEventSelectionBits {
kAll = 0, // o2-linter: disable=magic-number (enum)
kHasMCColl,
kGoodZVtx,
kIsFT0AND,
kNoTFB,
kITSROFB,
kNoSameBunchPileUp,
kGoodZVtxFTOPV,
kNoCollInTimeRange,
kGoodTrackOccupancy,
kGoodFT0Occupancy,
kTVXInEMC,
kGoodCent,
kGoodRCT,
kGoodSel8,
kSize
};

} // namespace emevsel

namespace emevent
Expand Down Expand Up @@ -193,18 +215,19 @@
DECLARE_SOA_COLUMN(SpherocityPtWeighted, spherocity_ptweighted, float); //! transverse spherocity
DECLARE_SOA_COLUMN(SpherocityPtUnWeighted, spherocity_ptunweighted, float); //! transverse spherocity
DECLARE_SOA_COLUMN(NtrackSpherocity, ntspherocity, int);
DECLARE_SOA_COLUMN(IsSelected, isSelected, bool); //! MB event selection info
DECLARE_SOA_COLUMN(IsEoI, isEoI, bool); //! lepton or photon exists in MB event (not for CEFP)
DECLARE_SOA_COLUMN(PosX, posX, float); //! only for treeCreatetorML.cxx
DECLARE_SOA_COLUMN(PosY, posY, float); //! only for treeCreatetorML.cxx
DECLARE_SOA_COLUMN(PosZint16, posZint16, int16_t); //! this is only to reduce data size
DECLARE_SOA_COLUMN(CentFT0Cuint16, centFT0Cuint16, uint16_t); //! this is only to reduce data size
DECLARE_SOA_COLUMN(PosZint8, posZint8, int8_t); //! this is only to reduce data size
DECLARE_SOA_COLUMN(CentFT0Cuint8, centFT0Cuint8, uint8_t); //! this is only to reduce data size
DECLARE_SOA_COLUMN(CentNTPVuint8, centNTPVuint8, uint8_t); //! this is only to reduce data size
DECLARE_SOA_COLUMN(CentNGlobaluint8, centNGlobaluint8, uint8_t); //! this is only to reduce data size
DECLARE_SOA_COLUMN(CentFT0Muint8, centFT0Muint8, uint8_t); //! this is only to reduce data size
DECLARE_SOA_COLUMN(CentFT0Auint8, centFT0Auint8, uint8_t); //! this is only to reduce data size
DECLARE_SOA_COLUMN(IsSelected, isSelected, bool); //! MB event selection info
DECLARE_SOA_COLUMN(EventSelectionBit, eventSelectionBit, std::vector<uint64_t>); //! Event selection info stored in binned data for each DF
DECLARE_SOA_COLUMN(IsEoI, isEoI, bool); //! lepton or photon exists in MB event (not for CEFP)
DECLARE_SOA_COLUMN(PosX, posX, float); //! only for treeCreatetorML.cxx
DECLARE_SOA_COLUMN(PosY, posY, float); //! only for treeCreatetorML.cxx
DECLARE_SOA_COLUMN(PosZint16, posZint16, int16_t); //! this is only to reduce data size
DECLARE_SOA_COLUMN(CentFT0Cuint16, centFT0Cuint16, uint16_t); //! this is only to reduce data size
DECLARE_SOA_COLUMN(PosZint8, posZint8, int8_t); //! this is only to reduce data size
DECLARE_SOA_COLUMN(CentFT0Cuint8, centFT0Cuint8, uint8_t); //! this is only to reduce data size
DECLARE_SOA_COLUMN(CentNTPVuint8, centNTPVuint8, uint8_t); //! this is only to reduce data size
DECLARE_SOA_COLUMN(CentNGlobaluint8, centNGlobaluint8, uint8_t); //! this is only to reduce data size
DECLARE_SOA_COLUMN(CentFT0Muint8, centFT0Muint8, uint8_t); //! this is only to reduce data size
DECLARE_SOA_COLUMN(CentFT0Auint8, centFT0Auint8, uint8_t); //! this is only to reduce data size
// DECLARE_SOA_COLUMN(CentFT0Cuint8, centFT0Cuint8, uint8_t); //! this is only to reduce data size
// DECLARE_SOA_COLUMN(CentNTPVuint8, centNTPVuint8, uint8_t); //! this is only to reduce data size
// DECLARE_SOA_COLUMN(CentNGlobaluint8, centNGlobaluint8, uint8_t); //! this is only to reduce data size
Expand Down Expand Up @@ -238,11 +261,11 @@
namespace emeventnorm
{
DECLARE_SOA_DYNAMIC_COLUMN(PosZ, posZ, [](int8_t posZint8) -> float { return (posZint8 < 0 ? std::nextafter(posZint8 * 0.5f, -std::numeric_limits<float>::infinity()) : std::nextafter(posZint8 * 0.5f, std::numeric_limits<float>::infinity())); }); //! posZ is multiplied by 2 in createEMEventDileton.cxx
DECLARE_SOA_DYNAMIC_COLUMN(CentFT0M, centFT0M, [](uint8_t centuint8) -> float { return centuint8 < 100 ? std::nextafter(centuint8 * 0.01f, std::numeric_limits<float>::infinity()) : std::nextafter(centuint8 - 110.f, std::numeric_limits<float>::infinity()); }); //! centrality is multiplied by 100 in createEMEventDilepton.cxx

Check failure on line 264 in PWGEM/Dilepton/DataModel/dileptonTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
DECLARE_SOA_DYNAMIC_COLUMN(CentFT0A, centFT0A, [](uint8_t centuint8) -> float { return centuint8 < 100 ? std::nextafter(centuint8 * 0.01f, std::numeric_limits<float>::infinity()) : std::nextafter(centuint8 - 110.f, std::numeric_limits<float>::infinity()); }); //! centrality is multiplied by 100 in createEMEventDilepton.cxx

Check failure on line 265 in PWGEM/Dilepton/DataModel/dileptonTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
DECLARE_SOA_DYNAMIC_COLUMN(CentFT0C, centFT0C, [](uint8_t centuint8) -> float { return centuint8 < 100 ? std::nextafter(centuint8 * 0.01f, std::numeric_limits<float>::infinity()) : std::nextafter(centuint8 - 110.f, std::numeric_limits<float>::infinity()); }); //! centrality is multiplied by 100 in createEMEventDilepton.cxx

Check failure on line 266 in PWGEM/Dilepton/DataModel/dileptonTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
DECLARE_SOA_DYNAMIC_COLUMN(CentNTPV, centNTPV, [](uint8_t centuint8) -> float { return centuint8 < 100 ? std::nextafter(centuint8 * 0.01f, std::numeric_limits<float>::infinity()) : std::nextafter(centuint8 - 110.f, std::numeric_limits<float>::infinity()); }); //! centrality is multiplied by 100 in createEMEventDilepton.cxx

Check failure on line 267 in PWGEM/Dilepton/DataModel/dileptonTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
DECLARE_SOA_DYNAMIC_COLUMN(CentNGlobal, centNGlobal, [](uint8_t centuint8) -> float { return centuint8 < 100 ? std::nextafter(centuint8 * 0.01f, std::numeric_limits<float>::infinity()) : std::nextafter(centuint8 - 110.f, std::numeric_limits<float>::infinity()); }); //! centrality is multiplied by 100 in createEMEventDilepton.cxx

Check failure on line 268 in PWGEM/Dilepton/DataModel/dileptonTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
} // namespace emeventnorm

DECLARE_SOA_TABLE(EMBCs_000, "AOD", "EMBC", //! bc information for normalization
Expand Down Expand Up @@ -435,6 +458,10 @@
emevent::IsSelected);
using EMEvSel = EMEvSels::iterator;

DECLARE_SOA_TABLE(EMEvSelBits, "AOD", "EMEVSELBITS", //! produces binned data that can be loaded in analysis task for event counting
emevent::EventSelectionBit);
using EMEvSelBit = EMEvSelBits::iterator;

DECLARE_SOA_TABLE(EMEoIs, "AOD", "EMEOI", //! joinable to o2::aod::Collisions in createEMEventDilepton.cxx
emevent::IsEoI);
using EMEoI = EMEoIs::iterator;
Expand Down Expand Up @@ -677,7 +704,7 @@
DECLARE_SOA_DYNAMIC_COLUMN(Tgl, tgl, [](float eta) -> float { return std::tan(o2::constants::math::PIHalf - 2 * std::atan(std::exp(-eta))); });
DECLARE_SOA_DYNAMIC_COLUMN(MeanClusterSizeITS, meanClusterSizeITS, [](uint32_t itsClusterSizes) -> float {
int total_cluster_size = 0, nl = 0;
for (unsigned int layer = 0; layer < 7; layer++) {

Check failure on line 707 in PWGEM/Dilepton/DataModel/dileptonTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
int cluster_size_per_layer = (itsClusterSizes >> (layer * 4)) & 0xf;
if (cluster_size_per_layer > 0) {
nl++;
Expand All @@ -692,7 +719,7 @@
});
DECLARE_SOA_DYNAMIC_COLUMN(MeanClusterSizeITSib, meanClusterSizeITSib, [](uint32_t itsClusterSizes) -> float {
int total_cluster_size = 0, nl = 0;
for (unsigned int layer = 0; layer < 3; layer++) {

Check failure on line 722 in PWGEM/Dilepton/DataModel/dileptonTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
int cluster_size_per_layer = (itsClusterSizes >> (layer * 4)) & 0xf;
if (cluster_size_per_layer > 0) {
nl++;
Expand All @@ -707,7 +734,7 @@
});
DECLARE_SOA_DYNAMIC_COLUMN(MeanClusterSizeITSob, meanClusterSizeITSob, [](uint32_t itsClusterSizes) -> float {
int total_cluster_size = 0, nl = 0;
for (unsigned int layer = 3; layer < 7; layer++) {

Check failure on line 737 in PWGEM/Dilepton/DataModel/dileptonTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
int cluster_size_per_layer = (itsClusterSizes >> (layer * 4)) & 0xf;
if (cluster_size_per_layer > 0) {
nl++;
Expand Down Expand Up @@ -1026,7 +1053,7 @@
DECLARE_SOA_DYNAMIC_COLUMN(NClustersMFT, nClustersMFT, //! Number of MFT clusters
[](uint64_t mftClusterSizesAndTrackFlags) -> uint8_t {
uint8_t nClusters = 0;
for (int layer = 0; layer < 10; layer++) {

Check failure on line 1056 in PWGEM/Dilepton/DataModel/dileptonTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
if ((mftClusterSizesAndTrackFlags >> (layer * 6)) & 0x3F) {
nClusters++;
}
Expand All @@ -1036,7 +1063,7 @@
DECLARE_SOA_DYNAMIC_COLUMN(MFTClusterMap, mftClusterMap, //! MFT cluster map, one bit per a layer, starting from the innermost
[](uint64_t mftClusterSizesAndTrackFlags) -> uint16_t {
uint16_t clmap = 0;
for (unsigned int layer = 0; layer < 10; layer++) {

Check failure on line 1066 in PWGEM/Dilepton/DataModel/dileptonTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
if ((mftClusterSizesAndTrackFlags >> (layer * 6)) & 0x3f) {
clmap |= (1 << layer);
}
Expand Down
31 changes: 31 additions & 0 deletions PWGEM/Dilepton/TableProducer/eventSelection.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ using namespace o2;
using namespace o2::framework;
using namespace o2::framework::expressions;
using namespace o2::soa;
using EventSelectionBits = o2::aod::emevsel::EMEventSelectionBits;

using MyCollisions = soa::Join<aod::Collisions, aod::EvSels>;
using MyCollisions_Cent = soa::Join<MyCollisions, aod::Mults, aod::CentFT0Ms, aod::CentFT0As, aod::CentFT0Cs>;
Expand All @@ -46,6 +47,7 @@ using MyCollisionsMC_Cent = soa::Join<MyCollisionsMC, aod::Mults, aod::CentFT0Ms

struct EMEventSelection {
Produces<o2::aod::EMEvSels> emevsel;
Produces<o2::aod::EMEvSelBits> emevselbits;

// Configurables
Configurable<int> cfgCentEstimator{"cfgCentEstimator", 2, "FT0M:0, FT0A:1, FT0C:2"};
Expand Down Expand Up @@ -73,83 +75,112 @@ struct EMEventSelection {

Configurable<bool> cfgRequireTVXinEMC{"cfgRequireTVXinEMC", false, "require kTVXinEMC (only for EMC analyses)"};

Configurable<bool> cfgRequireSel8{"cfgRequireSel8", false, "require sel8 condition"};

o2::aod::rctsel::RCTFlagsChecker rctChecker;

std::vector<uint64_t> vecEvSelBits;

void init(InitContext&)
{
rctChecker.init(cfgRCTLabel.value, cfgCheckZDC.value, cfgTreatLimitedAcceptanceAsBad.value);
vecEvSelBits.assign(EventSelectionBits::kSize, 0);
}

template <typename TCollision>
bool isSelectedEvent(TCollision const& collision)
{
vecEvSelBits[EventSelectionBits::kAll]++;
if constexpr (std::is_same_v<std::decay_t<TCollision>, MyCollisionsMC::iterator> || std::is_same_v<std::decay_t<TCollision>, MyCollisionsMC_Cent::iterator>) {
if (!collision.has_mcCollision()) {
return false;
}
}
vecEvSelBits[EventSelectionBits::kHasMCColl]++;

if (collision.posZ() < cfgZvtxMin || cfgZvtxMax < collision.posZ()) {
return false;
}
vecEvSelBits[EventSelectionBits::kGoodZVtx]++;

if (cfgRequireFT0AND && !collision.selection_bit(o2::aod::evsel::kIsTriggerTVX)) {
return false;
}
vecEvSelBits[EventSelectionBits::kIsFT0AND]++;

if (cfgRequireNoTFB && !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) {
return false;
}
vecEvSelBits[EventSelectionBits::kNoTFB]++;

if (cfgRequireNoITSROFB && !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) {
return false;
}
vecEvSelBits[EventSelectionBits::kITSROFB]++;

if (cfgRequireNoSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) {
return false;
}
vecEvSelBits[EventSelectionBits::kNoSameBunchPileUp]++;

if (cfgRequireGoodZvtxFT0vsPV && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) {
return false;
}
vecEvSelBits[EventSelectionBits::kGoodZVtxFTOPV]++;

if (cfgRequireNoCollInTimeRangeStandard && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) {
return false;
}
vecEvSelBits[EventSelectionBits::kNoCollInTimeRange]++;

if (!(cfgTrackOccupancyMin <= collision.trackOccupancyInTimeRange() && collision.trackOccupancyInTimeRange() < cfgTrackOccupancyMax)) {
return false;
}
vecEvSelBits[EventSelectionBits::kGoodTrackOccupancy]++;

if (!(cfgFT0COccupancyMin <= collision.ft0cOccupancyInTimeRange() && collision.ft0cOccupancyInTimeRange() < cfgFT0COccupancyMax)) {
return false;
}
vecEvSelBits[EventSelectionBits::kGoodFT0Occupancy]++;

if (cfgRequireTVXinEMC && !collision.alias_bit(triggerAliases::kTVXinEMC)) {
return false;
}
vecEvSelBits[EventSelectionBits::kTVXInEMC]++;

if constexpr (std::is_same_v<std::decay_t<TCollision>, MyCollisions_Cent::iterator>) {
const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()};
if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) {
return false;
}
}
vecEvSelBits[EventSelectionBits::kGoodCent]++;

if (cfgRequireGoodRCT && !rctChecker.checkTable(collision)) {
// LOGF(info, "rejected by RCT flag");
return false;
}
vecEvSelBits[EventSelectionBits::kGoodRCT]++;

if (cfgRequireSel8 && !collision.sel8()) {
return false;
}
vecEvSelBits[EventSelectionBits::kGoodSel8]++;

return true;
}

template <typename TCollisions>
void processEventSelection(TCollisions const& collisions)
{
// reset the event counter to zero for all elements
vecEvSelBits.assign(EventSelectionBits::kSize, 0);

for (const auto& collision : collisions) {
emevsel(isSelectedEvent(collision));
} // end of collision loop
// Write event selection info at the end of DF
emevselbits(vecEvSelBits);
} // end of process

PROCESS_SWITCH_FULL(EMEventSelection, processEventSelection<MyCollisions>, processEventSelection, "event selection", true);
Expand Down
Loading