|
42 | 42 |
|
43 | 43 | O2_DECLARE_DYNAMIC_LOG(ccdb); |
44 | 44 |
|
45 | | - |
46 | | - |
47 | 45 | namespace o2::framework |
48 | 46 | { |
49 | 47 | // Fill valid routes. Notice that for analysis the timestamps are associated to |
@@ -84,8 +82,13 @@ AlgorithmSpec AnalysisCCDBHelpers::fetchFromCCDB(ConfigContext const& /*ctx*/) |
84 | 82 | // device's options. Here we just read the final value — honouring any further |
85 | 83 | // runtime override supplied via CLI or JSON config. |
86 | 84 | std::unordered_map<std::string, std::string> ccdbUrls; |
| 85 | + std::unordered_map<std::string, std::string> runDependent; |
87 | 86 | for (auto& input : dec.analysisCCDBInputs) { |
88 | 87 | for (auto& m : input.metadata) { |
| 88 | + if (m.name.starts_with("ccdb-run-dependent:")) { |
| 89 | + runDependent.emplace(m.name, m.defaultValue.asString()); |
| 90 | + continue; |
| 91 | + } |
89 | 92 | if (!m.name.starts_with("ccdb:") || ccdbUrls.count(m.name)) { |
90 | 93 | continue; |
91 | 94 | } |
@@ -120,6 +123,8 @@ AlgorithmSpec AnalysisCCDBHelpers::fetchFromCCDB(ConfigContext const& /*ctx*/) |
120 | 123 | auto fieldMetadata = std::make_shared<arrow::KeyValueMetadata>(); |
121 | 124 | auto it = ccdbUrls.find(m.name); |
122 | 125 | fieldMetadata->Append("url", it != ccdbUrls.end() ? it->second : m.defaultValue.asString()); |
| 126 | + auto runDep = runDependent.find("ccdb-run-dependent:" + m.name.substr(strlen("ccdb:"))); |
| 127 | + fieldMetadata->Append("runDependent", runDep != runDependent.end() ? runDep->second : "0"); |
123 | 128 | auto columnName = m.name.substr(strlen("ccdb:")); |
124 | 129 | fields.emplace_back(std::make_shared<arrow::Field>(columnName, soa::asArrowDataType<int64_t[3]>(), false, fieldMetadata)); |
125 | 130 | } |
@@ -280,12 +285,22 @@ AlgorithmSpec AnalysisCCDBHelpers::fetchFromCCDB(ConfigContext const& /*ctx*/) |
280 | 285 | for (auto& field : schema->fields()) { |
281 | 286 | auto const& url = pathTables[i][fi++].resolve(uniformityKey, field->name()); |
282 | 287 | // Time to actually populate the blob |
| 288 | + // A run-dependent object is queried with the run number rather than by |
| 289 | + // timestamp alone. The run comes from the uniformity value, so the column's |
| 290 | + // table has to be uniform in the run number for this to mean anything. |
| 291 | + int const fieldRunDependent = field->metadata()->Contains("runDependent") |
| 292 | + ? std::stoi(*field->metadata()->Get("runDependent")) |
| 293 | + : 0; |
| 294 | + if (fieldRunDependent != 0 && uniformityColumnName != "fRunNumber") { |
| 295 | + LOGP(fatal, R"(Column "{}" of {} is declared run-dependent, but its table is uniform in "{}" rather than fRunNumber, so no run number is available to query with. Declare the table with DECLARE_SOA_UNIFORM_TABLE(..., aod::BCs, o2::aod::bc::RunNumber, ...).)", |
| 296 | + field->name(), outBinding, uniformityColumnName); |
| 297 | + } |
283 | 298 | ops.push_back({ |
284 | 299 | .spec = spec, |
285 | 300 | .url = url, |
286 | 301 | .timestamp = timestamp, |
287 | | - .runNumber = 1, |
288 | | - .runDependent = 0, |
| 302 | + .runNumber = fieldRunDependent != 0 ? static_cast<int>(uniformityKey) : 1, |
| 303 | + .runDependent = fieldRunDependent, |
289 | 304 | .queryRate = 0, |
290 | 305 | }); |
291 | 306 | } |
|
0 commit comments