Skip to content

Commit d8fa98a

Browse files
event selection flag is now stored in the multiplicity table
1 parent 58ae096 commit d8fa98a

3 files changed

Lines changed: 70 additions & 71 deletions

File tree

PWGLF/DataModel/LFhe3HadronTables.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ DECLARE_SOA_COLUMN(SignedPtMC, signedPtMC, float);
8080
DECLARE_SOA_COLUMN(MassMC, massMC, float);
8181

8282
DECLARE_SOA_COLUMN(CollisionId, collisionId, int64_t);
83+
DECLARE_SOA_COLUMN(CollisionSelectionFlag, collisionSelectionFlag, int32_t);
8384
DECLARE_SOA_COLUMN(ZVertex, zVertex, float);
8485
DECLARE_SOA_COLUMN(Multiplicity, multiplicity, uint16_t);
8586
DECLARE_SOA_COLUMN(CentralityFT0C, centFT0C, float);
@@ -132,6 +133,7 @@ DECLARE_SOA_TABLE(he3HadronTableMC, "AOD", "HE3HADTABLEMC",
132133
he3HadronTablesNS::Flags)
133134
DECLARE_SOA_TABLE(he3HadronMult, "AOD", "HE3HADMULT",
134135
he3HadronTablesNS::CollisionId,
136+
he3HadronTablesNS::CollisionSelectionFlag,
135137
he3HadronTablesNS::ZVertex,
136138
he3HadronTablesNS::Multiplicity,
137139
he3HadronTablesNS::CentralityFT0C,

PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ struct he3HadronFemto {
349349
o2::aod::ITSResponse mResponseITS;
350350

351351
std::vector<bool> mGoodCollisions;
352+
std::vector<uint32_t> mCollisionSelectionFlags;
352353
std::vector<SVCand> mTrackPairs;
353354
o2::vertexing::DCAFitterN<2> mFitter;
354355
svPoolCreator mSvPoolCreator{He3PDG, ProtonPDG};
@@ -431,8 +432,8 @@ struct he3HadronFemto {
431432
}
432433

433434
mQaRegistry.get<TH1>(HIST("hEventSelections"))->GetXaxis()->SetBinLabel(1, "All");
434-
for (int iSel = 1; iSel < nuclei::evSel::kNevSels + 1; iSel++) {
435-
mQaRegistry.get<TH1>(HIST("hEventSelections"))->GetXaxis()->SetBinLabel(iSel + 1, nuclei::eventSelectionLabels[iSel].c_str());
435+
for (int iSel = 0; iSel < nuclei::evSel::kNevSels + 2; iSel++) {
436+
mQaRegistry.get<TH1>(HIST("hEventSelections"))->GetXaxis()->SetBinLabel(iSel + 2, nuclei::eventSelectionLabels[iSel].c_str());
436437
}
437438

438439
const int nBetheBlochParameters = 5;
@@ -529,14 +530,14 @@ struct he3HadronFemto {
529530
// ==================================================================================================================
530531

531532
template <bool isMC, typename Tcollision>
532-
bool selectCollision(const Tcollision& collision, const aod::BCsWithTimestamps&)
533+
bool selectCollision(const Tcollision& collision, const aod::BCsWithTimestamps&, uint32_t& collisionSelectionFlag)
533534
{
534535
mQaRegistry.fill(HIST("hEvents"), 0);
535536

536537
auto bc = collision.template bc_as<aod::BCsWithTimestamps>();
537538
initCCDB(bc);
538539

539-
if (!nuclei::eventSelection(collision, mQaRegistry, settingEventSelections, cutSettings.settingCutVertex)) {
540+
if (!nuclei::eventSelection(collision, mQaRegistry, settingEventSelections, cutSettings.settingCutVertex, collisionSelectionFlag)) {
540541
return false;
541542
}
542543
if (settingSkimmedProcessing) {
@@ -980,6 +981,7 @@ struct he3HadronFemto {
980981
template <typename Tcoll>
981982
void fillTable(const He3HadCandidate& he3Hadcand, const Tcoll& collision, bool isMC = false)
982983
{
984+
const uint32_t collisionSelectionFlag = mCollisionSelectionFlags[he3Hadcand.collisionID];
983985
outputDataTable(
984986
he3Hadcand.recoPtHe3(), he3Hadcand.recoEtaHe3(), he3Hadcand.recoPhiHe3(),
985987
he3Hadcand.recoPtHad(), he3Hadcand.recoEtaHad(), he3Hadcand.recoPhiHad(),
@@ -1000,8 +1002,8 @@ struct he3HadronFemto {
10001002
he3Hadcand.l4PtMC, he3Hadcand.l4MassMC, he3Hadcand.flags);
10011003
}
10021004
outputMultiplicityTable(
1003-
collision.globalIndex(), collision.posZ(), collision.numContrib(),
1004-
collision.centFT0C(), collision.multFT0C());
1005+
collision.globalIndex(), collisionSelectionFlag, collision.posZ(),
1006+
collision.numContrib(), collision.centFT0C(), collision.multFT0C());
10051007
outputQaTable(
10061008
he3Hadcand.trackIDHe3, he3Hadcand.trackIDHad, he3Hadcand.massTOFHe3,
10071009
he3Hadcand.pidtrkHad, he3Hadcand.sharedClustersHad);
@@ -1158,16 +1160,20 @@ struct he3HadronFemto {
11581160
{
11591161
mGoodCollisions.clear();
11601162
mGoodCollisions.resize(collisions.size(), false);
1163+
mCollisionSelectionFlags.clear();
1164+
mCollisionSelectionFlags.resize(collisions.size(), 0);
11611165

11621166
for (const auto& collision : collisions) {
11631167

11641168
mTrackPairs.clear();
11651169

1166-
if (!selectCollision</*isMC*/ false>(collision, bcs)) {
1170+
uint32_t collisionSelectionFlag = 0;
1171+
if (!selectCollision</*isMC*/ false>(collision, bcs, collisionSelectionFlag)) {
11671172
continue;
11681173
}
11691174

11701175
mGoodCollisions[collision.globalIndex()] = true;
1176+
mCollisionSelectionFlags[collision.globalIndex()] = collisionSelectionFlag;
11711177
const uint64_t collIdx = collision.globalIndex();
11721178
auto trackTableThisCollision = tracks.sliceBy(mPerCol, collIdx);
11731179
trackTableThisCollision.bindExternalIndices(&tracks);
@@ -1183,15 +1189,21 @@ struct he3HadronFemto {
11831189
}
11841190
PROCESS_SWITCH(he3HadronFemto, processSameEvent, "Process Same event", false);
11851191

1186-
void processMixedEvent(const CollisionsFull& collisions, const TrackCandidates& tracks)
1192+
void processMixedEvent(const CollisionsFull& collisions, const aod::BCsWithTimestamps& bcs, const TrackCandidates& tracks)
11871193
{
11881194
LOG(debug) << "Processing mixed event";
11891195
mTrackPairs.clear();
1196+
mCollisionSelectionFlags.clear();
1197+
mCollisionSelectionFlags.resize(collisions.size(), 0);
11901198

11911199
for (const auto& [c1, tracks1, c2, tracks2] : mPair) {
1192-
if (!c1.sel8() || !c2.sel8()) {
1200+
uint32_t collisionSelectionFlag1 = 0;
1201+
uint32_t collisionSelectionFlag2 = 0;
1202+
if (!selectCollision</*isMC*/ false>(c1, bcs, collisionSelectionFlag1) || !selectCollision</*isMC*/ false>(c2, bcs, collisionSelectionFlag2)) {
11931203
continue;
11941204
}
1205+
mCollisionSelectionFlags[c1.globalIndex()] = collisionSelectionFlag1;
1206+
mCollisionSelectionFlags[c2.globalIndex()] = collisionSelectionFlag2;
11951207

11961208
mQaRegistry.fill(HIST("hNcontributor"), c1.numContrib());
11971209
mQaRegistry.fill(HIST("hVtxZ"), c1.posZ());
@@ -1210,14 +1222,18 @@ struct he3HadronFemto {
12101222

12111223
mGoodCollisions.clear();
12121224
mGoodCollisions.resize(collisions.size(), false);
1225+
mCollisionSelectionFlags.clear();
1226+
mCollisionSelectionFlags.resize(collisions.size(), 0);
12131227

12141228
for (const auto& collision : collisions) {
12151229

12161230
mTrackPairs.clear();
12171231

1218-
if (!selectCollision</*isMC*/ true>(collision, bcs)) {
1232+
uint32_t collisionSelectionFlag = 0;
1233+
if (!selectCollision</*isMC*/ true>(collision, bcs, collisionSelectionFlag)) {
12191234
continue;
12201235
}
1236+
mCollisionSelectionFlags[collision.globalIndex()] = collisionSelectionFlag;
12211237

12221238
const uint64_t collIdx = collision.globalIndex();
12231239
mGoodCollisions[collIdx] = true;
@@ -1308,8 +1324,10 @@ struct he3HadronFemto {
13081324

13091325
void processPurity(const CollisionsFull::iterator& collision, const TrackCandidates& tracks, const aod::BCsWithTimestamps& bcs)
13101326
{
1311-
if (!selectCollision</*isMC*/ false>(collision, bcs))
1327+
uint32_t collisionSelectionFlag = 0; // dummy, purity study does not fill a tree
1328+
if (!selectCollision</*isMC*/ false>(collision, bcs, collisionSelectionFlag)) {
13121329
return;
1330+
}
13131331

13141332
for (const auto& track : tracks) {
13151333

@@ -1362,7 +1380,8 @@ struct he3HadronFemto {
13621380

13631381
void processPurityMc(const CollisionsFullMC::iterator& collision, const TrackCandidatesMC& tracks, const aod::BCsWithTimestamps& bcs, const aod::McParticles& /*mcParticles*/, const aod::McTrackLabels& /*mcTrackLabels*/)
13641382
{
1365-
if (!selectCollision</*isMC*/ false>(collision, bcs)) {
1383+
uint32_t collisionSelectionFlag = 0; // dummy, purity study does not fill a tree
1384+
if (!selectCollision</*isMC*/ false>(collision, bcs, collisionSelectionFlag)) {
13661385
return;
13671386
}
13681387

PWGLF/Utils/nucleiUtils.h

Lines changed: 37 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,23 @@ constexpr int EvSelDefault[evSel::kNevSels][1]{
329329
{0},
330330
{0}};
331331

332-
template <typename Tcollision> // move to nucleiUtils
333-
bool eventSelection(const Tcollision& collision, o2::framework::HistogramRegistry& registry, o2::framework::LabeledArray<int> eventSelections, const float cutVertex)
332+
template <typename Tcollision>
333+
bool eventSelection(const Tcollision& collision, o2::framework::HistogramRegistry& registry, o2::framework::LabeledArray<int> eventSelections, const float cutVertex, uint32_t& selectionFlag)
334334
{
335+
selectionFlag = 0;
336+
bool isSelected = true;
337+
auto checkCut = [&](int selIndex, bool pass) {
338+
if (pass) {
339+
selectionFlag |= (1u << selIndex);
340+
}
341+
if (eventSelections.get(selIndex) && !pass) {
342+
isSelected = false;
343+
}
344+
if (isSelected) {
345+
registry.fill(HIST("hEventSelections"), selIndex + 1);
346+
}
347+
};
348+
335349
if (!registry.contains(HIST("hVtxZBefore"))) {
336350
registry.add("hVtxZBefore", "Vertex distribution in Z before selections;Z (cm)", {o2::framework::HistType::kTH1F, {{400, -20.0, 20.0}}});
337351
}
@@ -344,69 +358,33 @@ bool eventSelection(const Tcollision& collision, o2::framework::HistogramRegistr
344358
registry.fill(HIST("hEventSelections"), 0);
345359
registry.fill(HIST("hVtxZBefore"), collision.posZ());
346360

347-
if (eventSelections.get(evSel::kTVX) && !collision.selection_bit(o2::aod::evsel::kIsTriggerTVX)) {
348-
return false;
349-
}
350-
registry.fill(HIST("hEventSelections"), evSel::kTVX + 1);
351-
352-
if (eventSelections.get(evSel::kZvtx) && std::abs(collision.posZ()) > cutVertex) {
353-
return false;
354-
}
355-
registry.fill(HIST("hEventSelections"), evSel::kZvtx + 1);
356-
357-
if (eventSelections.get(evSel::kTFborder) && !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) {
358-
return false;
359-
}
360-
registry.fill(HIST("hEventSelections"), evSel::kTFborder + 1);
361-
362-
if (eventSelections.get(evSel::kITSROFborder) && !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) {
363-
return false;
364-
}
365-
registry.fill(HIST("hEventSelections"), evSel::kITSROFborder + 1);
366-
367-
if (eventSelections.get(evSel::kNoSameBunchPileup) && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) {
368-
return false;
369-
}
370-
registry.fill(HIST("hEventSelections"), evSel::kNoSameBunchPileup + 1);
371-
372-
if (eventSelections.get(evSel::kIsGoodZvtxFT0vsPV) && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) {
373-
return false;
374-
}
375-
registry.fill(HIST("hEventSelections"), evSel::kIsGoodZvtxFT0vsPV + 1);
376-
377-
if (eventSelections.get(evSel::kIsGoodITSLayersAll) && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) {
378-
return false;
379-
}
380-
registry.fill(HIST("hEventSelections"), evSel::kIsGoodITSLayersAll + 1);
381-
382-
if constexpr (
383-
requires {
384-
collision.triggereventep();
385-
}) {
386-
if (eventSelections.get(evSel::kIsEPtriggered) && !collision.triggereventep()) {
387-
return false;
388-
}
389-
registry.fill(HIST("hEventSelections"), evSel::kIsEPtriggered + 1);
390-
}
391-
392-
if (eventSelections.get(evSel::kNoCollInRofStandard) && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) {
393-
return false;
394-
}
395-
registry.fill(HIST("hEventSelections"), evSel::kNoCollInRofStandard + 1);
361+
checkCut(evSel::kTVX, collision.selection_bit(o2::aod::evsel::kIsTriggerTVX));
362+
checkCut(evSel::kZvtx, std::abs(collision.posZ()) <= cutVertex);
363+
checkCut(evSel::kTFborder, collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder));
364+
checkCut(evSel::kITSROFborder, collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder));
365+
checkCut(evSel::kNoSameBunchPileup, collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup));
366+
checkCut(evSel::kIsGoodZvtxFT0vsPV, collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV));
367+
checkCut(evSel::kIsGoodITSLayersAll, collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll));
396368

397-
if (eventSelections.get(evSel::kNoHighMultCollInPrevRof) && !collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) {
398-
return false;
369+
if constexpr (requires { collision.triggereventep(); }) {
370+
checkCut(evSel::kIsEPtriggered, collision.triggereventep());
399371
}
400-
registry.fill(HIST("hEventSelections"), evSel::kNoHighMultCollInPrevRof + 1);
401372

402-
if (eventSelections.get(evSel::kNoCollInTimeRangeStandard) && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) {
403-
return false;
404-
}
405-
registry.fill(HIST("hEventSelections"), evSel::kNoCollInTimeRangeStandard + 1);
373+
checkCut(evSel::kNoCollInRofStandard, collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard));
374+
checkCut(evSel::kNoHighMultCollInPrevRof, collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof));
375+
checkCut(evSel::kNoCollInTimeRangeStandard, collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard));
406376

377+
407378
registry.fill(HIST("hVtxZ"), collision.posZ());
408379

409-
return true;
380+
return isSelected;
381+
}
382+
383+
template <typename Tcollision>
384+
bool eventSelection(const Tcollision& collision, o2::framework::HistogramRegistry& registry, o2::framework::LabeledArray<int> eventSelections, const float cutVertex)
385+
{
386+
uint32_t dummyFlag = 0;
387+
return eventSelection(collision, registry, eventSelections, cutVertex, dummyFlag);
410388
}
411389

412390
/**

0 commit comments

Comments
 (0)