Skip to content
Merged
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
16 changes: 16 additions & 0 deletions PWGLF/DataModel/ZDCCalTables.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,19 @@
// It only stores the ZDC energies and links back to ZDCCalTables.
namespace zdcenergytable
{
DECLARE_SOA_INDEX_COLUMN(ZDCCalTable, zdcCalTable);

Check failure on line 57 in PWGLF/DataModel/ZDCCalTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.

DECLARE_SOA_COLUMN(ZNACommon, znaCommon, float);

Check failure on line 59 in PWGLF/DataModel/ZDCCalTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
DECLARE_SOA_COLUMN(ZNCCommon, zncCommon, float);

Check failure on line 60 in PWGLF/DataModel/ZDCCalTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.

DECLARE_SOA_COLUMN(ZNA0, zna0, float);

Check failure on line 62 in PWGLF/DataModel/ZDCCalTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
DECLARE_SOA_COLUMN(ZNA1, zna1, float);

Check failure on line 63 in PWGLF/DataModel/ZDCCalTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
DECLARE_SOA_COLUMN(ZNA2, zna2, float);

Check failure on line 64 in PWGLF/DataModel/ZDCCalTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
DECLARE_SOA_COLUMN(ZNA3, zna3, float);

Check failure on line 65 in PWGLF/DataModel/ZDCCalTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.

DECLARE_SOA_COLUMN(ZNC0, znc0, float);

Check failure on line 67 in PWGLF/DataModel/ZDCCalTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
DECLARE_SOA_COLUMN(ZNC1, znc1, float);

Check failure on line 68 in PWGLF/DataModel/ZDCCalTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
DECLARE_SOA_COLUMN(ZNC2, znc2, float);

Check failure on line 69 in PWGLF/DataModel/ZDCCalTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
DECLARE_SOA_COLUMN(ZNC3, znc3, float);
} // namespace zdcenergytable

Expand All @@ -85,5 +85,21 @@

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_
25 changes: 24 additions & 1 deletion PWGLF/TableProducer/Common/zdcvector.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
#include <chrono>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <string>
#include <unordered_map>
#include <vector>

using namespace o2;
Expand All @@ -59,6 +61,7 @@ struct zdcvector {

Produces<aod::ZDCCalTables> zdccaltable;
Produces<aod::ZDCEnergyTables> zdcenergytable;
Produces<aod::ZDCTimeTables> zdctimetable;

// Configurables.
struct : ConfigurableGroup {
Expand Down Expand Up @@ -100,8 +103,10 @@ struct zdcvector {
} rctCut;

Configurable<bool> storeZdcEnergy{"storeZdcEnergy", true, "Store ZDC tower/common energies in a linked extra table"};
Configurable<bool> storeZdcTime{"storeZdcTime", true, "Store timestamp and time from first event of run"};

RCTFlagsChecker rctChecker;
std::unordered_map<int, uint64_t> runStartTime;

void init(o2::framework::InitContext&)
{
Expand Down Expand Up @@ -194,6 +199,17 @@ struct zdcvector {
float znc3 = 0.f;

auto bc = collision.foundBC_as<BCsRun3>();
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<float>(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.
Expand All @@ -213,8 +229,10 @@ struct zdcvector {
qyA,
qyC);

auto zdcCalIndex = zdccaltable.lastIndex();

if (storeZdcEnergy) {
zdcenergytable(zdccaltable.lastIndex(),
zdcenergytable(zdcCalIndex,
znaEnergycommon,
zncEnergycommon,
zna0,
Expand All @@ -226,6 +244,11 @@ struct zdcvector {
znc2,
znc3);
}
if (storeZdcTime) {
zdctimetable(zdcCalIndex,
timestampzdc,
timeInMinutes);
}
};

if (!bc.has_zdc()) {
Expand Down
Loading