From 905b48745e6fc03a4cd071f6c50d01ba211da746 Mon Sep 17 00:00:00 2001 From: Prottay Das Date: Wed, 6 May 2026 19:43:45 +0200 Subject: [PATCH] added a linked table for time --- PWGLF/DataModel/ZDCCalTables.h | 16 +++++++++++++++ PWGLF/TableProducer/Common/zdcvector.cxx | 25 +++++++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/PWGLF/DataModel/ZDCCalTables.h b/PWGLF/DataModel/ZDCCalTables.h index 40b5fbdd575..097fb57e16c 100644 --- a/PWGLF/DataModel/ZDCCalTables.h +++ b/PWGLF/DataModel/ZDCCalTables.h @@ -85,5 +85,21 @@ DECLARE_SOA_TABLE(ZDCEnergyTables, "AOD", "ZDCENERGY", using ZDCEnergyTable = ZDCEnergyTables::iterator; +// Extra optional linked table for time information. +// It only stores timestamp and relative time, linked back to ZDCCalTables. +namespace zdctimetable +{ +DECLARE_SOA_INDEX_COLUMN(ZDCCalTable, zdcCalTable); + +DECLARE_SOA_COLUMN(Timestamp, timestamp, uint64_t); // bc.timestamp(), in ms +DECLARE_SOA_COLUMN(TimeMin, timeMin, float); // time from first event seen in this run, in minutes +} // namespace zdctimetable + +DECLARE_SOA_TABLE(ZDCTimeTables, "AOD", "ZDCTIME", + zdctimetable::ZDCCalTableId, + zdctimetable::Timestamp, + zdctimetable::TimeMin); + +using ZDCTimeTable = ZDCTimeTables::iterator; } // namespace o2::aod #endif // PWGLF_DATAMODEL_ZDCCALTABLES_H_ diff --git a/PWGLF/TableProducer/Common/zdcvector.cxx b/PWGLF/TableProducer/Common/zdcvector.cxx index dd1b9860d05..b6b5407156f 100644 --- a/PWGLF/TableProducer/Common/zdcvector.cxx +++ b/PWGLF/TableProducer/Common/zdcvector.cxx @@ -44,7 +44,9 @@ #include #include #include +#include #include +#include #include using namespace o2; @@ -59,6 +61,7 @@ struct zdcvector { Produces zdccaltable; Produces zdcenergytable; + Produces zdctimetable; // Configurables. struct : ConfigurableGroup { @@ -100,8 +103,10 @@ struct zdcvector { } rctCut; Configurable storeZdcEnergy{"storeZdcEnergy", true, "Store ZDC tower/common energies in a linked extra table"}; + Configurable storeZdcTime{"storeZdcTime", true, "Store timestamp and time from first event of run"}; RCTFlagsChecker rctChecker; + std::unordered_map runStartTime; void init(o2::framework::InitContext&) { @@ -194,6 +199,17 @@ struct zdcvector { float znc3 = 0.f; auto bc = collision.foundBC_as(); + const uint64_t timestampzdc = bc.timestamp(); // in milliseconds + + float timeInMinutes = 0.f; + + auto itStart = runStartTime.find(currentRunNumber); + if (itStart == runStartTime.end()) { + runStartTime[currentRunNumber] = timestampzdc; + timeInMinutes = 0.f; + } else { + timeInMinutes = static_cast(timestampzdc - itStart->second) / 60000.f; + } // Helper to keep your early-return structure unchanged. // Every time ZDCCalTables is filled, the optional linked energy table is also filled. @@ -213,8 +229,10 @@ struct zdcvector { qyA, qyC); + auto zdcCalIndex = zdccaltable.lastIndex(); + if (storeZdcEnergy) { - zdcenergytable(zdccaltable.lastIndex(), + zdcenergytable(zdcCalIndex, znaEnergycommon, zncEnergycommon, zna0, @@ -226,6 +244,11 @@ struct zdcvector { znc2, znc3); } + if (storeZdcTime) { + zdctimetable(zdcCalIndex, + timestampzdc, + timeInMinutes); + } }; if (!bc.has_zdc()) {