diff --git a/PWGLF/DataModel/LFhe3HadronTables.h b/PWGLF/DataModel/LFhe3HadronTables.h index a31b806b0d3..6beb5b8729e 100644 --- a/PWGLF/DataModel/LFhe3HadronTables.h +++ b/PWGLF/DataModel/LFhe3HadronTables.h @@ -80,6 +80,7 @@ DECLARE_SOA_COLUMN(SignedPtMC, signedPtMC, float); DECLARE_SOA_COLUMN(MassMC, massMC, float); DECLARE_SOA_COLUMN(CollisionId, collisionId, int64_t); +DECLARE_SOA_COLUMN(CollisionSelectionFlag, collisionSelectionFlag, int32_t); DECLARE_SOA_COLUMN(ZVertex, zVertex, float); DECLARE_SOA_COLUMN(Multiplicity, multiplicity, uint16_t); DECLARE_SOA_COLUMN(CentralityFT0C, centFT0C, float); @@ -132,6 +133,7 @@ DECLARE_SOA_TABLE(he3HadronTableMC, "AOD", "HE3HADTABLEMC", he3HadronTablesNS::Flags) DECLARE_SOA_TABLE(he3HadronMult, "AOD", "HE3HADMULT", he3HadronTablesNS::CollisionId, + he3HadronTablesNS::CollisionSelectionFlag, he3HadronTablesNS::ZVertex, he3HadronTablesNS::Multiplicity, he3HadronTablesNS::CentralityFT0C, diff --git a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx index ec84cb4c179..da049dcada4 100644 --- a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx +++ b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx @@ -349,6 +349,7 @@ struct he3HadronFemto { o2::aod::ITSResponse mResponseITS; std::vector mGoodCollisions; + std::vector mCollisionSelectionFlags; std::vector mTrackPairs; o2::vertexing::DCAFitterN<2> mFitter; svPoolCreator mSvPoolCreator{He3PDG, ProtonPDG}; @@ -431,8 +432,8 @@ struct he3HadronFemto { } mQaRegistry.get(HIST("hEventSelections"))->GetXaxis()->SetBinLabel(1, "All"); - for (int iSel = 1; iSel < nuclei::evSel::kNevSels + 1; iSel++) { - mQaRegistry.get(HIST("hEventSelections"))->GetXaxis()->SetBinLabel(iSel + 1, nuclei::eventSelectionLabels[iSel].c_str()); + for (int iSel = 0; iSel < nuclei::evSel::kNevSels + 2; iSel++) { + mQaRegistry.get(HIST("hEventSelections"))->GetXaxis()->SetBinLabel(iSel + 2, nuclei::eventSelectionLabels[iSel].c_str()); } const int nBetheBlochParameters = 5; @@ -529,14 +530,14 @@ struct he3HadronFemto { // ================================================================================================================== template - bool selectCollision(const Tcollision& collision, const aod::BCsWithTimestamps&) + bool selectCollision(const Tcollision& collision, const aod::BCsWithTimestamps&, uint32_t& collisionSelectionFlag) { mQaRegistry.fill(HIST("hEvents"), 0); auto bc = collision.template bc_as(); initCCDB(bc); - if (!nuclei::eventSelection(collision, mQaRegistry, settingEventSelections, cutSettings.settingCutVertex)) { + if (!nuclei::eventSelection(collision, mQaRegistry, settingEventSelections, cutSettings.settingCutVertex, collisionSelectionFlag)) { return false; } if (settingSkimmedProcessing) { @@ -980,6 +981,7 @@ struct he3HadronFemto { template void fillTable(const He3HadCandidate& he3Hadcand, const Tcoll& collision, bool isMC = false) { + const uint32_t collisionSelectionFlag = mCollisionSelectionFlags[he3Hadcand.collisionID]; outputDataTable( he3Hadcand.recoPtHe3(), he3Hadcand.recoEtaHe3(), he3Hadcand.recoPhiHe3(), he3Hadcand.recoPtHad(), he3Hadcand.recoEtaHad(), he3Hadcand.recoPhiHad(), @@ -1000,8 +1002,8 @@ struct he3HadronFemto { he3Hadcand.l4PtMC, he3Hadcand.l4MassMC, he3Hadcand.flags); } outputMultiplicityTable( - collision.globalIndex(), collision.posZ(), collision.numContrib(), - collision.centFT0C(), collision.multFT0C()); + collision.globalIndex(), collisionSelectionFlag, collision.posZ(), + collision.numContrib(), collision.centFT0C(), collision.multFT0C()); outputQaTable( he3Hadcand.trackIDHe3, he3Hadcand.trackIDHad, he3Hadcand.massTOFHe3, he3Hadcand.pidtrkHad, he3Hadcand.sharedClustersHad); @@ -1158,16 +1160,20 @@ struct he3HadronFemto { { mGoodCollisions.clear(); mGoodCollisions.resize(collisions.size(), false); + mCollisionSelectionFlags.clear(); + mCollisionSelectionFlags.resize(collisions.size(), 0); for (const auto& collision : collisions) { mTrackPairs.clear(); - if (!selectCollision(collision, bcs)) { + uint32_t collisionSelectionFlag = 0; + if (!selectCollision(collision, bcs, collisionSelectionFlag)) { continue; } mGoodCollisions[collision.globalIndex()] = true; + mCollisionSelectionFlags[collision.globalIndex()] = collisionSelectionFlag; const uint64_t collIdx = collision.globalIndex(); auto trackTableThisCollision = tracks.sliceBy(mPerCol, collIdx); trackTableThisCollision.bindExternalIndices(&tracks); @@ -1183,15 +1189,21 @@ struct he3HadronFemto { } PROCESS_SWITCH(he3HadronFemto, processSameEvent, "Process Same event", false); - void processMixedEvent(const CollisionsFull& collisions, const TrackCandidates& tracks) + void processMixedEvent(const CollisionsFull& collisions, const aod::BCsWithTimestamps& bcs, const TrackCandidates& tracks) { LOG(debug) << "Processing mixed event"; mTrackPairs.clear(); + mCollisionSelectionFlags.clear(); + mCollisionSelectionFlags.resize(collisions.size(), 0); for (const auto& [c1, tracks1, c2, tracks2] : mPair) { - if (!c1.sel8() || !c2.sel8()) { + uint32_t collisionSelectionFlag1 = 0; + uint32_t collisionSelectionFlag2 = 0; + if (!selectCollision(c1, bcs, collisionSelectionFlag1) || !selectCollision(c2, bcs, collisionSelectionFlag2)) { continue; } + mCollisionSelectionFlags[c1.globalIndex()] = collisionSelectionFlag1; + mCollisionSelectionFlags[c2.globalIndex()] = collisionSelectionFlag2; mQaRegistry.fill(HIST("hNcontributor"), c1.numContrib()); mQaRegistry.fill(HIST("hVtxZ"), c1.posZ()); @@ -1210,14 +1222,18 @@ struct he3HadronFemto { mGoodCollisions.clear(); mGoodCollisions.resize(collisions.size(), false); + mCollisionSelectionFlags.clear(); + mCollisionSelectionFlags.resize(collisions.size(), 0); for (const auto& collision : collisions) { mTrackPairs.clear(); - if (!selectCollision(collision, bcs)) { + uint32_t collisionSelectionFlag = 0; + if (!selectCollision(collision, bcs, collisionSelectionFlag)) { continue; } + mCollisionSelectionFlags[collision.globalIndex()] = collisionSelectionFlag; const uint64_t collIdx = collision.globalIndex(); mGoodCollisions[collIdx] = true; @@ -1308,8 +1324,10 @@ struct he3HadronFemto { void processPurity(const CollisionsFull::iterator& collision, const TrackCandidates& tracks, const aod::BCsWithTimestamps& bcs) { - if (!selectCollision(collision, bcs)) + uint32_t collisionSelectionFlag = 0; // dummy, purity study does not fill a tree + if (!selectCollision(collision, bcs, collisionSelectionFlag)) { return; + } for (const auto& track : tracks) { @@ -1362,7 +1380,8 @@ struct he3HadronFemto { void processPurityMc(const CollisionsFullMC::iterator& collision, const TrackCandidatesMC& tracks, const aod::BCsWithTimestamps& bcs, const aod::McParticles& /*mcParticles*/, const aod::McTrackLabels& /*mcTrackLabels*/) { - if (!selectCollision(collision, bcs)) { + uint32_t collisionSelectionFlag = 0; // dummy, purity study does not fill a tree + if (!selectCollision(collision, bcs, collisionSelectionFlag)) { return; } diff --git a/PWGLF/Utils/nucleiUtils.h b/PWGLF/Utils/nucleiUtils.h index 27b8e3818fc..cf1bf47df5a 100644 --- a/PWGLF/Utils/nucleiUtils.h +++ b/PWGLF/Utils/nucleiUtils.h @@ -329,9 +329,23 @@ constexpr int EvSelDefault[evSel::kNevSels][1]{ {0}, {0}}; -template // move to nucleiUtils -bool eventSelection(const Tcollision& collision, o2::framework::HistogramRegistry& registry, o2::framework::LabeledArray eventSelections, const float cutVertex) +template +bool eventSelection(const Tcollision& collision, o2::framework::HistogramRegistry& registry, o2::framework::LabeledArray eventSelections, const float cutVertex, uint32_t& selectionFlag) { + selectionFlag = 0; + bool isSelected = true; + auto checkCut = [&](int selIndex, bool pass) { + if (pass) { + selectionFlag |= (1u << selIndex); + } + if (eventSelections.get(selIndex) && !pass) { + isSelected = false; + } + if (isSelected) { + registry.fill(HIST("hEventSelections"), selIndex + 1); + } + }; + if (!registry.contains(HIST("hVtxZBefore"))) { registry.add("hVtxZBefore", "Vertex distribution in Z before selections;Z (cm)", {o2::framework::HistType::kTH1F, {{400, -20.0, 20.0}}}); } @@ -344,69 +358,32 @@ bool eventSelection(const Tcollision& collision, o2::framework::HistogramRegistr registry.fill(HIST("hEventSelections"), 0); registry.fill(HIST("hVtxZBefore"), collision.posZ()); - if (eventSelections.get(evSel::kTVX) && !collision.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { - return false; - } - registry.fill(HIST("hEventSelections"), evSel::kTVX + 1); - - if (eventSelections.get(evSel::kZvtx) && std::abs(collision.posZ()) > cutVertex) { - return false; - } - registry.fill(HIST("hEventSelections"), evSel::kZvtx + 1); - - if (eventSelections.get(evSel::kTFborder) && !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { - return false; - } - registry.fill(HIST("hEventSelections"), evSel::kTFborder + 1); - - if (eventSelections.get(evSel::kITSROFborder) && !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { - return false; - } - registry.fill(HIST("hEventSelections"), evSel::kITSROFborder + 1); - - if (eventSelections.get(evSel::kNoSameBunchPileup) && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { - return false; - } - registry.fill(HIST("hEventSelections"), evSel::kNoSameBunchPileup + 1); - - if (eventSelections.get(evSel::kIsGoodZvtxFT0vsPV) && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { - return false; - } - registry.fill(HIST("hEventSelections"), evSel::kIsGoodZvtxFT0vsPV + 1); + checkCut(evSel::kTVX, collision.selection_bit(o2::aod::evsel::kIsTriggerTVX)); + checkCut(evSel::kZvtx, std::abs(collision.posZ()) <= cutVertex); + checkCut(evSel::kTFborder, collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)); + checkCut(evSel::kITSROFborder, collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)); + checkCut(evSel::kNoSameBunchPileup, collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)); + checkCut(evSel::kIsGoodZvtxFT0vsPV, collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)); + checkCut(evSel::kIsGoodITSLayersAll, collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)); - if (eventSelections.get(evSel::kIsGoodITSLayersAll) && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { - return false; - } - registry.fill(HIST("hEventSelections"), evSel::kIsGoodITSLayersAll + 1); - - if constexpr ( - requires { - collision.triggereventep(); - }) { - if (eventSelections.get(evSel::kIsEPtriggered) && !collision.triggereventep()) { - return false; - } - registry.fill(HIST("hEventSelections"), evSel::kIsEPtriggered + 1); + if constexpr (requires { collision.triggereventep(); }) { + checkCut(evSel::kIsEPtriggered, collision.triggereventep()); } - if (eventSelections.get(evSel::kNoCollInRofStandard) && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { - return false; - } - registry.fill(HIST("hEventSelections"), evSel::kNoCollInRofStandard + 1); - - if (eventSelections.get(evSel::kNoHighMultCollInPrevRof) && !collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) { - return false; - } - registry.fill(HIST("hEventSelections"), evSel::kNoHighMultCollInPrevRof + 1); - - if (eventSelections.get(evSel::kNoCollInTimeRangeStandard) && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { - return false; - } - registry.fill(HIST("hEventSelections"), evSel::kNoCollInTimeRangeStandard + 1); + checkCut(evSel::kNoCollInRofStandard, collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)); + checkCut(evSel::kNoHighMultCollInPrevRof, collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)); + checkCut(evSel::kNoCollInTimeRangeStandard, collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)); registry.fill(HIST("hVtxZ"), collision.posZ()); - return true; + return isSelected; +} + +template +bool eventSelection(const Tcollision& collision, o2::framework::HistogramRegistry& registry, o2::framework::LabeledArray eventSelections, const float cutVertex) +{ + uint32_t dummyFlag = 0; + return eventSelection(collision, registry, eventSelections, cutVertex, dummyFlag); } /** @@ -420,10 +397,10 @@ float getCentrality(Tcollision const& collision, const int centralityEstimator, hFailCentrality->Fill(0.); } if constexpr (!o2::aod::HasCentrality) { // requires aod::CentFV0As, aod::CentFT0Ms, aod::CentFT0As, aod::CentFT0Cs, aod::CentNTPVs - return -1.f; if (hFailCentrality) { hFailCentrality->Fill(1.); } + return -1.f; } if (centralityEstimator == centDetectors::kFV0A) { return collision.centFV0A(); @@ -633,11 +610,11 @@ class PidManager } private: - float mTpcBetheBlochParams[6]; + float mTpcBetheBlochParams[6] = {-999.f, -999.f, -999.f, -999.f, -999.f, -999.f}; bool mUseTpcCentralCalibration = true; // this just becomes a check for the null pointer in the parameters o2::aod::ITSResponse mResponseITS; float mMomScaling[2]{1., 0.}; - int mSpecies; + int mSpecies = -1; }; } // namespace nuclei