From f0f939a7f8423562a8e4166dea01928942dc85de Mon Sep 17 00:00:00 2001 From: Daiki Sekihata Date: Sun, 19 Oct 2025 19:08:19 +0200 Subject: [PATCH] PWGEM/Dilepton: fix trigger counters --- PWGEM/Dilepton/Core/Dilepton.h | 6 ++-- PWGEM/Dilepton/Core/DileptonHadronMPC.h | 6 ++-- PWGEM/Dilepton/Core/PhotonHBT.h | 6 ++-- PWGEM/Dilepton/Core/SingleTrackQC.h | 6 ++-- PWGEM/Dilepton/DataModel/dileptonTables.h | 14 ++++++--- .../TableProducer/createEMEventDilepton.cxx | 30 ++++++++++++------- PWGEM/Dilepton/TableProducer/skimmerOTS.cxx | 29 ++++++++---------- 7 files changed, 59 insertions(+), 38 deletions(-) diff --git a/PWGEM/Dilepton/Core/Dilepton.h b/PWGEM/Dilepton/Core/Dilepton.h index 37e16c5ff25..4b8c4658b2d 100644 --- a/PWGEM/Dilepton/Core/Dilepton.h +++ b/PWGEM/Dilepton/Core/Dilepton.h @@ -1545,7 +1545,7 @@ struct Dilepton { PROCESS_SWITCH(Dilepton, processAnalysis, "run dilepton analysis", true); using FilteredMyCollisionsWithSWT = soa::Filtered; - void processTriggerAnalysis(FilteredMyCollisionsWithSWT const& collisions, aod::EMSWTriggerInfos const& cefpinfos, aod::EMSWTriggerCounters const& counters, Types const&... args) + void processTriggerAnalysis(FilteredMyCollisionsWithSWT const& collisions, aod::EMSWTriggerInfos const& cefpinfos, aod::EMSWTriggerATCounters const& countersAT, aod::EMSWTriggerTOICounters const& countersTOI, Types const&... args) { if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { auto electrons = std::get<0>(std::tie(args...)); @@ -1565,10 +1565,12 @@ struct Dilepton { // for nomalization int emswtId = o2::aod::pwgem::dilepton::swt::aliasLabels.at(cfg_swt_name.value); - for (const auto& counter : counters) { + for (const auto& counter : countersAT) { if (counter.isAnalyzed_bit(emswtId)) { fRegistry.fill(HIST("NormTrigger/hTriggerCounter"), mRunNumber, 0); } + } + for (const auto& counter : countersTOI) { if (counter.isAnalyzedToI_bit(emswtId)) { fRegistry.fill(HIST("NormTrigger/hTriggerCounter"), mRunNumber, 1); } diff --git a/PWGEM/Dilepton/Core/DileptonHadronMPC.h b/PWGEM/Dilepton/Core/DileptonHadronMPC.h index 2f44a679930..ef3b65e5230 100644 --- a/PWGEM/Dilepton/Core/DileptonHadronMPC.h +++ b/PWGEM/Dilepton/Core/DileptonHadronMPC.h @@ -1442,7 +1442,7 @@ struct DileptonHadronMPC { PROCESS_SWITCH(DileptonHadronMPC, processAnalysis, "run dilepton analysis", true); using FilteredMyCollisionsWithSWT = soa::Filtered; - void processTriggerAnalysis(FilteredMyCollisionsWithSWT const& collisions, FilteredRefTracks const& refTracks, aod::EMSWTriggerInfos const& cefpinfos, aod::EMSWTriggerCounters const& counters, Types const&... args) + void processTriggerAnalysis(FilteredMyCollisionsWithSWT const& collisions, FilteredRefTracks const& refTracks, aod::EMSWTriggerInfos const& cefpinfos, aod::EMSWTriggerATCounters const& countersAT, aod::EMSWTriggerTOICounters const& countersTOI, Types const&... args) { if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { auto electrons = std::get<0>(std::tie(args...)); @@ -1462,10 +1462,12 @@ struct DileptonHadronMPC { // for nomalization int emswtId = o2::aod::pwgem::dilepton::swt::aliasLabels.at(cfg_swt_name.value); - for (const auto& counter : counters) { + for (const auto& counter : countersAT) { if (counter.isAnalyzed_bit(emswtId)) { fRegistry.fill(HIST("NormTrigger/hTriggerCounter"), mRunNumber, 0); } + } + for (const auto& counter : countersTOI) { if (counter.isAnalyzedToI_bit(emswtId)) { fRegistry.fill(HIST("NormTrigger/hTriggerCounter"), mRunNumber, 1); } diff --git a/PWGEM/Dilepton/Core/PhotonHBT.h b/PWGEM/Dilepton/Core/PhotonHBT.h index fdb9755a299..46d5e1852ab 100644 --- a/PWGEM/Dilepton/Core/PhotonHBT.h +++ b/PWGEM/Dilepton/Core/PhotonHBT.h @@ -1459,7 +1459,7 @@ struct PhotonHBT { PROCESS_SWITCH(PhotonHBT, processAnalysis, "pairing for analysis", false); using FilteredMyCollisionsWithSWT = soa::Filtered; - void processTriggerAnalysis(FilteredMyCollisionsWithSWT const& collisions, aod::EMSWTriggerInfos const& cefpinfos, aod::EMSWTriggerCounters const& counters, Types const&... args) + void processTriggerAnalysis(FilteredMyCollisionsWithSWT const& collisions, aod::EMSWTriggerInfos const& cefpinfos, aod::EMSWTriggerATCounters const& countersAT, aod::EMSWTriggerTOICounters const& countersTOI, Types const&... args) { if constexpr (pairtype == ggHBTPairType::kPCMPCM) { auto v0photons = std::get<0>(std::tie(args...)); @@ -1484,10 +1484,12 @@ struct PhotonHBT { // for nomalization int emswtId = o2::aod::pwgem::dilepton::swt::aliasLabels.at(cfg_swt_name.value); - for (const auto& counter : counters) { + for (const auto& counter : countersAT) { if (counter.isAnalyzed_bit(emswtId)) { fRegistry.fill(HIST("NormTrigger/hTriggerCounter"), mRunNumber, 0); } + } + for (const auto& counter : countersTOI) { if (counter.isAnalyzedToI_bit(emswtId)) { fRegistry.fill(HIST("NormTrigger/hTriggerCounter"), mRunNumber, 1); } diff --git a/PWGEM/Dilepton/Core/SingleTrackQC.h b/PWGEM/Dilepton/Core/SingleTrackQC.h index 0b8e67435fc..6653e9b54e7 100644 --- a/PWGEM/Dilepton/Core/SingleTrackQC.h +++ b/PWGEM/Dilepton/Core/SingleTrackQC.h @@ -829,7 +829,7 @@ struct SingleTrackQC { PROCESS_SWITCH(SingleTrackQC, processQC, "run single track QC", true); using FilteredMyCollisionsWithSWT = soa::Filtered; - void processQC_TriggeredData(FilteredMyCollisionsWithSWT const& collisions, aod::EMSWTriggerInfos const& cefpinfos, aod::EMSWTriggerCounters const& counters, Types const&... args) + void processQC_TriggeredData(FilteredMyCollisionsWithSWT const& collisions, aod::EMSWTriggerInfos const& cefpinfos, aod::EMSWTriggerATCounters const& countersAT, aod::EMSWTriggerTOICounters const& countersTOI, Types const&... args) { if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { auto electrons = std::get<0>(std::tie(args...)); @@ -848,10 +848,12 @@ struct SingleTrackQC { // for nomalization int emswtId = o2::aod::pwgem::dilepton::swt::aliasLabels.at(cfg_swt_name.value); - for (const auto& counter : counters) { + for (const auto& counter : countersAT) { if (counter.isAnalyzed_bit(emswtId)) { fRegistry.fill(HIST("NormTrigger/hTriggerCounter"), mRunNumber, 0); } + } + for (const auto& counter : countersTOI) { if (counter.isAnalyzedToI_bit(emswtId)) { fRegistry.fill(HIST("NormTrigger/hTriggerCounter"), mRunNumber, 1); } diff --git a/PWGEM/Dilepton/DataModel/dileptonTables.h b/PWGEM/Dilepton/DataModel/dileptonTables.h index ce9a36977b3..a3bff9027b1 100644 --- a/PWGEM/Dilepton/DataModel/dileptonTables.h +++ b/PWGEM/Dilepton/DataModel/dileptonTables.h @@ -214,8 +214,11 @@ using EMSWTriggerBit = EMSWTriggerBits::iterator; DECLARE_SOA_TABLE(EMSWTriggerInfos, "AOD", "EMSWTINFO", bc::RunNumber, emevent::NInspectedTVX, emevent::NScalars, emevent::NSelections, o2::soa::Marker<1>); //! independent table. Don't join anything. using EMSWTriggerInfo = EMSWTriggerInfos::iterator; -DECLARE_SOA_TABLE(EMSWTriggerCounters, "AOD", "EMSWTCOUNTER", emevent::IsAnalyzed, emevent::IsAnalyzedToI, o2::soa::Marker<1>); //! independent table. Don't join anything. -using EMSWTriggerCounter = EMSWTriggerCounters::iterator; +DECLARE_SOA_TABLE(EMSWTriggerATCounters, "AOD", "EMSWTAT", emevent::IsAnalyzed, o2::soa::Marker<1>); //! independent table. Don't join anything. +using EMSWTriggerATCounter = EMSWTriggerATCounters::iterator; + +DECLARE_SOA_TABLE(EMSWTriggerTOICounters, "AOD", "EMSWTTOI", emevent::IsAnalyzedToI, o2::soa::Marker<1>); //! independent table. Don't join anything. +using EMSWTriggerTOICounter = EMSWTriggerTOICounters::iterator; DECLARE_SOA_TABLE(EMSWTriggerBitsTMP, "AOD", "EMSWTBITTMP", emevent::SWTAliasTmp, o2::soa::Marker<2>); //! joinable to aod::Collisions using EMSWTriggerBitTMP = EMSWTriggerBitsTMP::iterator; @@ -223,8 +226,11 @@ using EMSWTriggerBitTMP = EMSWTriggerBitsTMP::iterator; DECLARE_SOA_TABLE(EMSWTriggerInfosTMP, "AOD", "EMSWTINFOTMP", bc::RunNumber, emevent::NInspectedTVX, emevent::NScalars, emevent::NSelections, o2::soa::Marker<2>); using EMSWTriggerInfoTMP = EMSWTriggerInfosTMP::iterator; -DECLARE_SOA_TABLE(EMSWTriggerCountersTMP, "AOD", "EMSWTCOUNTERTMP", emevent::IsAnalyzed, emevent::IsAnalyzedToI, o2::soa::Marker<2>); //! independent table. Don't join anything. -using EMSWTriggerCounterTMP = EMSWTriggerCountersTMP::iterator; +DECLARE_SOA_TABLE(EMSWTriggerATCountersTMP, "AOD", "EMSWTATTMP", emevent::IsAnalyzed, o2::soa::Marker<2>); //! independent table. Don't join anything. +using EMSWTriggerATCounterTMP = EMSWTriggerATCountersTMP::iterator; + +DECLARE_SOA_TABLE(EMSWTriggerTOICountersTMP, "AOD", "EMSWTTOITMP", emevent::IsAnalyzedToI, o2::soa::Marker<2>); //! independent table. Don't join anything. +using EMSWTriggerTOICounterTMP = EMSWTriggerTOICountersTMP::iterator; DECLARE_SOA_TABLE(EMEventsProperty, "AOD", "EMEVENTPROP", //! joinable to EMEvents emevent::SpherocityPtWeighted, emevent::SpherocityPtUnWeighted, emevent::NtrackSpherocity); diff --git a/PWGEM/Dilepton/TableProducer/createEMEventDilepton.cxx b/PWGEM/Dilepton/TableProducer/createEMEventDilepton.cxx index 88de61009d3..f81e559c3dc 100644 --- a/PWGEM/Dilepton/TableProducer/createEMEventDilepton.cxx +++ b/PWGEM/Dilepton/TableProducer/createEMEventDilepton.cxx @@ -64,7 +64,8 @@ struct CreateEMEventDilepton { Produces event_qvec; Produces emswtbit; Produces emswtinfo; - Produces emswtcounter; + Produces emswtATcounter; + Produces emswtTOIcounter; Produces event_norm_info; enum class EMEventType : int { @@ -211,7 +212,7 @@ struct CreateEMEventDilepton { //---------- for data with swt ---------- - void processEvent_SWT(MyCollisionsWithSWT const& collisions, MyBCs const& bcs, aod::EMSWTriggerInfosTMP const& emswtinfostmp, aod::EMSWTriggerCountersTMP const& emswtcounterstmp) + void processEvent_SWT(MyCollisionsWithSWT const& collisions, MyBCs const& bcs, aod::EMSWTriggerInfosTMP const& emswtinfostmp, aod::EMSWTriggerATCountersTMP const& emswtATcounterstmp, aod::EMSWTriggerTOICountersTMP const& emswtTOIcounterstmp) { skimEvent(collisions, bcs); @@ -225,13 +226,16 @@ struct CreateEMEventDilepton { mRunNumber = info.runNumber(); } } - for (const auto& counter : emswtcounterstmp) { - emswtcounter(counter.isAnalyzed_raw(), counter.isAnalyzedToI_raw()); + for (const auto& counter : emswtATcounterstmp) { + emswtATcounter(counter.isAnalyzed_raw()); + } + for (const auto& counter : emswtTOIcounterstmp) { + emswtTOIcounter(counter.isAnalyzedToI_raw()); } } PROCESS_SWITCH(CreateEMEventDilepton, processEvent_SWT, "process event info", false); - void processEvent_SWT_Cent(MyCollisionsWithSWT_Cent const& collisions, MyBCs const& bcs, aod::EMSWTriggerInfosTMP const& emswtinfostmp, aod::EMSWTriggerCountersTMP const& emswtcounterstmp) + void processEvent_SWT_Cent(MyCollisionsWithSWT_Cent const& collisions, MyBCs const& bcs, aod::EMSWTriggerInfosTMP const& emswtinfostmp, aod::EMSWTriggerATCountersTMP const& emswtATcounterstmp, aod::EMSWTriggerTOICountersTMP const& emswtTOIcounterstmp) { skimEvent(collisions, bcs); @@ -245,13 +249,16 @@ struct CreateEMEventDilepton { mRunNumber = info.runNumber(); } } - for (const auto& counter : emswtcounterstmp) { - emswtcounter(counter.isAnalyzed_raw(), counter.isAnalyzedToI_raw()); + for (const auto& counter : emswtATcounterstmp) { + emswtATcounter(counter.isAnalyzed_raw()); + } + for (const auto& counter : emswtTOIcounterstmp) { + emswtTOIcounter(counter.isAnalyzedToI_raw()); } } PROCESS_SWITCH(CreateEMEventDilepton, processEvent_SWT_Cent, "process event info", false); - void processEvent_SWT_Cent_Qvec(MyCollisionsWithSWT_Cent_Qvec const& collisions, MyBCs const& bcs, aod::EMSWTriggerInfosTMP const& emswtinfostmp, aod::EMSWTriggerCountersTMP const& emswtcounterstmp) + void processEvent_SWT_Cent_Qvec(MyCollisionsWithSWT_Cent_Qvec const& collisions, MyBCs const& bcs, aod::EMSWTriggerInfosTMP const& emswtinfostmp, aod::EMSWTriggerATCountersTMP const& emswtATcounterstmp, aod::EMSWTriggerTOICountersTMP const& emswtTOIcounterstmp) { skimEvent(collisions, bcs); @@ -265,8 +272,11 @@ struct CreateEMEventDilepton { mRunNumber = info.runNumber(); } } - for (const auto& counter : emswtcounterstmp) { - emswtcounter(counter.isAnalyzed_raw(), counter.isAnalyzedToI_raw()); + for (const auto& counter : emswtATcounterstmp) { + emswtATcounter(counter.isAnalyzed_raw()); + } + for (const auto& counter : emswtTOIcounterstmp) { + emswtTOIcounter(counter.isAnalyzedToI_raw()); } } PROCESS_SWITCH(CreateEMEventDilepton, processEvent_SWT_Cent_Qvec, "process event info", false); diff --git a/PWGEM/Dilepton/TableProducer/skimmerOTS.cxx b/PWGEM/Dilepton/TableProducer/skimmerOTS.cxx index 37a3af0215b..194ed79c3dd 100644 --- a/PWGEM/Dilepton/TableProducer/skimmerOTS.cxx +++ b/PWGEM/Dilepton/TableProducer/skimmerOTS.cxx @@ -36,11 +36,12 @@ using namespace o2::soa; struct skimmerOTS { Produces swtinfo_tmp; // Join aod::Collision later. Produces swtbit_tmp; - Produces swtcounter_tmp; + Produces swtcounterAT_tmp; + Produces swtcounterTOI_tmp; // CCDB options Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - Configurable cfg_swt_names{"cfg_swt_names", "fHighTrackMult,fHighFt0Mult", "comma-separated software trigger names"}; // !trigger names have to be pre-registered in dileptonTable.h for bit operation! + Configurable cfg_swt_names{"cfg_swt_names", "fLMeeIMR,fLMeeHMR", "comma-separated software trigger names"}; // !trigger names have to be pre-registered in dileptonTable.h for bit operation! o2::framework::Configurable ccdbPathSoftwareTrigger{"ccdbPathSoftwareTrigger", "EventFiltering/Zorro/", "ccdb path for ZORRO objects"}; Configurable bcMarginForSoftwareTrigger{"bcMarginForSoftwareTrigger", 100, "Number of BCs of margin for software triggers"}; @@ -56,6 +57,7 @@ struct skimmerOTS { std::vector mATCounters; HistogramRegistry registry{"registry"}; + void init(o2::framework::InitContext&) { ccdb->setURL(ccdburl); @@ -130,14 +132,13 @@ struct skimmerOTS { void process(aod::Collisions const& collisions, aod::BCsWithTimestamps const&) { - for (const auto& collision : collisions) { auto bc = collision.template bc_as(); // don't use foundBC. initCCDB(bc); uint16_t trigger_bitmap = 0; - uint16_t analyzed_bitmap = 0; - uint16_t analyzedToI_bitmap = 0; + // uint16_t analyzed_bitmap = 0; + // uint16_t analyzedToI_bitmap = 0; registry.fill(HIST("hCollisionCounter"), 1); // all if (zorro.isSelected(bc.globalBC(), bcMarginForSoftwareTrigger)) { // triggered event @@ -154,15 +155,16 @@ struct skimmerOTS { // LOGF(info, "swtname = %s is fired. swt index in original swt table = %d, swt index for EM table = %d", swtname.data(), mTOIidx[idx], o2::aod::pwgem::dilepton::swt::aliasLabels.at(swtname)); registry.fill(HIST("hCollisionCounter"), idx + 2); // fired trigger - if (ATcounters[mTOIidx[idx]] > mATCounters[emswtId]) { - analyzed_bitmap |= BIT(emswtId); + // LOGF(info, "ATcounters[mTOIidx[idx]] = %d, TOIcounters[idx] = %d", ATcounters[mTOIidx[idx]], TOIcounters[idx]); + + while (ATcounters[mTOIidx[idx]] > mATCounters[emswtId]) { mATCounters[emswtId]++; - // mATCounters[emswtId] = ATcounters[mTOIidx[idx]]; // Dont' use this line. NOT always incremented by 1 in zorro!! + swtcounterAT_tmp(BIT(emswtId)); } - if (TOIcounters[idx] > mTOICounters[emswtId]) { - analyzedToI_bitmap |= BIT(emswtId); - mTOICounters[emswtId] = TOIcounters[idx]; // always incremented by 1 in zorro!! + while (TOIcounters[idx] > mTOICounters[emswtId]) { + mTOICounters[emswtId]++; // always incremented by 1 in zorro!! + swtcounterTOI_tmp(BIT(emswtId)); } // LOGF(info, "collision.globalIndex() = %d, bc.globalBC() = %llu, mTOICounters[%d] = %d, mATcounters[%d] = %d", collision.globalIndex(), bc.globalBC(), emswtId, mTOICounters[emswtId], emswtId, mATCounters[emswtId]); @@ -170,12 +172,7 @@ struct skimmerOTS { } // end of TOI loop } swtbit_tmp(trigger_bitmap); - if (analyzed_bitmap > 0 || analyzedToI_bitmap > 0) { // storing 0 is useless. - swtcounter_tmp(analyzed_bitmap, analyzedToI_bitmap); - } - } // end of collision loop - } // end of process }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)