Skip to content

Commit fb905df

Browse files
committed
CCDBPopulator adds runNumber (if any) tag to metadata
Since the tag might be queried, define its name via common constexpr
1 parent f456178 commit fb905df

File tree

6 files changed

+23
-6
lines changed

6 files changed

+23
-6
lines changed

Common/Utils/include/CommonUtils/NameConf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class NameConf : public o2::conf::ConfigurableParamHelper<NameConf>
6666
static constexpr std::string_view CCDBOBJECT = "ccdb_object"; // hardcoded
6767
static constexpr std::string_view CCDBMETA = "ccdb_meta"; // hardcoded
6868
static constexpr std::string_view CCDBQUERY = "ccdb_query"; // hardcoded
69+
static constexpr std::string_view CCDBRunTag = "runNumber";
6970

7071
// Filename to store geometry file
7172
static std::string getGeomFileName(const std::string_view prefix = "");

Detectors/Calibration/workflow/CCDBPopulatorSpec.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "CCDB/BasicCCDBManager.h"
2929
#include "CCDB/CcdbApi.h"
3030
#include "CCDB/CcdbObjectInfo.h"
31+
#include "CommonUtils/NameConf.h"
3132

3233
using CcdbManager = o2::ccdb::BasicCCDBManager;
3334

@@ -54,15 +55,27 @@ class CCDBPopulator : public o2::framework::Task
5455
{
5556
int nSlots = pc.inputs().getNofParts(0);
5657
assert(pc.inputs().getNofParts(1) == nSlots);
58+
auto runNoFromDH = o2::framework::DataRefUtils::getHeader<o2::header::DataHeader*>(pc.inputs().getFirstValid(true))->runNumber;
59+
std::string runNoStr;
60+
if (runNoFromDH > 0) {
61+
runNoStr = std::to_string(runNoFromDH);
62+
}
5763

64+
std::map<std::string, std::string> metadata;
5865
for (int isl = 0; isl < nSlots; isl++) {
5966
const auto wrp = pc.inputs().get<CcdbObjectInfo*>("clbWrapper", isl);
6067
const auto pld = pc.inputs().get<gsl::span<char>>("clbPayload", isl); // this is actually an image of TMemFile
68+
const auto* md = &wrp->getMetaData();
69+
if (runNoFromDH > 0 && md->find(o2::base::NameConf::CCDBRunTag.data()) == md->end()) { // if valid run number is provided and it is not filled in the metadata, add it to the clone
70+
metadata = *md; // clone since the md from the message is const
71+
metadata[o2::base::NameConf::CCDBRunTag.data()] = runNoStr;
72+
md = &metadata;
73+
}
6174

6275
LOG(info) << "Storing in ccdb " << wrp->getPath() << "/" << wrp->getFileName() << " of size " << pld.size()
6376
<< " Valid for " << wrp->getStartValidityTimestamp() << " : " << wrp->getEndValidityTimestamp();
6477
mAPI.storeAsBinaryFile(&pld[0], pld.size(), wrp->getFileName(), wrp->getObjectType(), wrp->getPath(),
65-
wrp->getMetaData(), wrp->getStartValidityTimestamp(), wrp->getEndValidityTimestamp());
78+
*md, wrp->getStartValidityTimestamp(), wrp->getEndValidityTimestamp());
6679
}
6780
}
6881

Detectors/TPC/base/include/TPCBase/CDBInterface.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "CCDB/CcdbApi.h"
2626
#include "TPCBase/CalDet.h"
2727
#include "DataFormatsTPC/LtrCalibData.h"
28+
#include "CommonUtils/NameConf.h"
2829

2930
namespace o2::tpc
3031
{
@@ -312,7 +313,7 @@ class CDBStorage
312313

313314
void setRunNumber(int run)
314315
{
315-
mMetaData["runNumber"] = std::to_string(run);
316+
mMetaData[o2::base::NameConf::CCDBRunTag.data()] = std::to_string(run);
316317
}
317318

318319
template <typename T>

Detectors/TPC/workflow/include/TPCWorkflow/CalibLaserTracksSpec.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "Framework/WorkflowSpec.h"
2525
#include "CCDB/CcdbApi.h"
2626
#include "CCDB/CcdbObjectInfo.h"
27+
#include "CommonUtils/NameConf.h"
2728

2829
#include "TPCWorkflow/ProcessingHelpers.h"
2930

@@ -102,7 +103,7 @@ class CalibLaserTracksDevice : public o2::framework::Task
102103
auto image = o2::ccdb::CcdbApi::createObjectImage(&ltrCalib, &w);
103104

104105
md = w.getMetaData();
105-
md["runNumber"] = std::to_string(mRunNumber);
106+
md[o2::base::NameConf::CCDBRunTag.data()] = std::to_string(mRunNumber);
106107
w.setMetaData(md);
107108

108109
const auto now = std::chrono::system_clock::now();

Detectors/TPC/workflow/src/CalDetMergerPublisherSpec.cxx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "TPCBase/CalDet.h"
4040
#include "TPCWorkflow/CalDetMergerPublisherSpec.h"
4141
#include "TPCWorkflow/ProcessingHelpers.h"
42+
#include "CommonUtils/NameConf.h"
4243

4344
using namespace o2::framework;
4445
using namespace o2::tpc;
@@ -178,7 +179,7 @@ class CalDetMergerPublisherSpec : public o2::framework::Task
178179
w.setEndValidityTimestamp(timeEnd);
179180

180181
md = w.getMetaData();
181-
md["runNumber"] = std::to_string(mRunNumber);
182+
md[o2::base::NameConf::CCDBRunTag.data()] = std::to_string(mRunNumber);
182183
w.setMetaData(md);
183184

184185
LOGP(info, "Sending object {}/{} of size {} bytes, valid for {} : {}", w.getPath(), w.getFileName(), image->size(), w.getStartValidityTimestamp(), w.getEndValidityTimestamp());
@@ -197,7 +198,7 @@ class CalDetMergerPublisherSpec : public o2::framework::Task
197198
w.setEndValidityTimestamp(timeEnd);
198199

199200
md = w.getMetaData();
200-
md["runNumber"] = std::to_string(mRunNumber);
201+
md[o2::base::NameConf::CCDBRunTag.data()] = std::to_string(mRunNumber);
201202
w.setMetaData(md);
202203

203204
LOG(info) << "Sending object " << w.getPath() << "/" << w.getFileName() << " of size " << image->size()

macro/CreateGRPECSObject.C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void CreateGRPECSObject(timePoint start, uint32_t nHBPerTF, DetID::mask_t detsRe
5656
api.init(ccdbPath);
5757
std::map<std::string, std::string> metadata;
5858
metadata["responsible"] = "ECS";
59-
metadata["run_number"] = std::to_string(run);
59+
metadata[o2::base::NameConf::CCDBRunTag.data()] = std::to_string(run);
6060
//long ts = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
6161
if (end < 0) {
6262
end = (start + 60 * 60 * 10) * 1000; // start + 10h, in ms

0 commit comments

Comments
 (0)