From d7ac42e10210e89e764156c323998a824ab3bd69 Mon Sep 17 00:00:00 2001 From: lietava Date: Sun, 29 May 2022 06:59:45 +0200 Subject: [PATCH 1/3] dev: ctp config saved at start of run --- .../include/DataFormatsCTP/Configuration.h | 3 ++- .../Detectors/CTP/src/Configuration.cxx | 25 ++++++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h b/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h index a33c4759b49ec..49b76bf803b89 100644 --- a/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h +++ b/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h @@ -166,7 +166,8 @@ class CTPRunManager int addScalers(uint32_t irun, std::time_t time); int processMessage(std::string& topic, const std::string& message); void printActiveRuns() const; - int saveRunToCCDB(int i); + int saveRunScalersToCCDB(int i); + int saveRunConfigToCCDB(int i); int getConfigFromCCDB(); int getScalersFromCCDB(); int loadScalerNames(); diff --git a/DataFormats/Detectors/CTP/src/Configuration.cxx b/DataFormats/Detectors/CTP/src/Configuration.cxx index cdef3ca5101ba..854ca85ae9e63 100644 --- a/DataFormats/Detectors/CTP/src/Configuration.cxx +++ b/DataFormats/Detectors/CTP/src/Configuration.cxx @@ -591,7 +591,7 @@ int CTPRunManager::stopRun(uint32_t irun) const auto now = std::chrono::system_clock::now(); const long timeStamp = std::chrono::duration_cast(now.time_since_epoch()).count(); mActiveRuns[irun]->timeStop = timeStamp; - saveRunToCCDB(irun); + saveRunScalersToCCDB(irun); delete mActiveRuns[irun]; mActiveRuns[irun] = nullptr; return 0; @@ -685,6 +685,7 @@ int CTPRunManager::processMessage(std::string& topic, const std::string& message LOG(error) << "Internal error in processMessage: nullptr != 0 expected"; } mActiveRuns[i] = mRunInStart; + saveRunConfigToCCDB(i); mRunInStart = nullptr; addScalers(i, tt); } else if ((mCounters[i] == 0) && (mActiveRunNumbers[i] != 0)) { @@ -711,7 +712,7 @@ void CTPRunManager::printActiveRuns() const } std::cout << std::endl; } -int CTPRunManager::saveRunToCCDB(int i) +int CTPRunManager::saveRunScalersToCCDB(int i) { // data base CTPActiveRun* run = mActiveRuns[i]; @@ -721,9 +722,25 @@ int CTPRunManager::saveRunToCCDB(int i) map metadata; // can be empty api.init(mCcdbHost.c_str()); // or http://localhost:8080 for a local installation // store abitrary user object in strongly typed manner - api.storeAsTFileAny(&(run->cfg), o2::ctp::CCDBPathCTPConfig, metadata, tmin, tmax); api.storeAsTFileAny(&(run->scalers), o2::ctp::CCDBPathCTPScalers, metadata, tmin, tmax); - LOG(info) << "CTP config and scalers saved in ccdb, run:" << run->cfg.getRunNumber(); + LOG(info) << "CTP scalers saved in ccdb, run:" << run->cfg.getRunNumber(); + return 0; +} +int CTPRunManager::saveRunConfigToCCDB(int i) +{ + // data base + CTPActiveRun* run = mActiveRuns[i]; + long tmin = run->timeStart; + using namespace std::chrono_literals; + std::chrono::seconds days3 = 259200s; + long time3days = std::chrono::duration_cast(days3).count(); + long tmax = run->timeStart + time3days; + o2::ccdb::CcdbApi api; + map metadata; // can be empty + api.init(mCcdbHost.c_str()); // or http://localhost:8080 for a local installation + // store abitrary user object in strongly typed manner + api.storeAsTFileAny(&(run->cfg), o2::ctp::CCDBPathCTPConfig, metadata, tmin, tmax); + LOG(info) << "CTP config saved in ccdb, run:" << run->cfg.getRunNumber(); return 0; } int CTPRunManager::getConfigFromCCDB() From 51d4274f9479e6f389877cd18cb44f84a9dd95f6 Mon Sep 17 00:00:00 2001 From: lietava Date: Mon, 30 May 2022 08:22:13 +0200 Subject: [PATCH 2/3] dev: ctpconfig saved at sor --- .../include/DataFormatsCTP/Configuration.h | 5 ++-- .../Detectors/CTP/src/Configuration.cxx | 28 ++++++++++++------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h b/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h index 49b76bf803b89..913d6eec1d06e 100644 --- a/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h +++ b/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h @@ -167,7 +167,7 @@ class CTPRunManager int processMessage(std::string& topic, const std::string& message); void printActiveRuns() const; int saveRunScalersToCCDB(int i); - int saveRunConfigToCCDB(int i); + int saveRunConfigToCCDB(CTPConfiguration* cfg, long timeStart); int getConfigFromCCDB(); int getScalersFromCCDB(); int loadScalerNames(); @@ -181,7 +181,8 @@ class CTPRunManager std::map mScalerName2Position; CTPActiveRun* mRunInStart = nullptr; int mEOX = 0; // redundancy check - ClassDefNV(CTPRunManager, 1); + int mCtpcfg = 0; + ClassDefNV(CTPRunManager, 2); }; } // namespace ctp } // namespace o2 diff --git a/DataFormats/Detectors/CTP/src/Configuration.cxx b/DataFormats/Detectors/CTP/src/Configuration.cxx index 854ca85ae9e63..5b280a46d0fce 100644 --- a/DataFormats/Detectors/CTP/src/Configuration.cxx +++ b/DataFormats/Detectors/CTP/src/Configuration.cxx @@ -579,6 +579,7 @@ int CTPRunManager::startRun(const std::string& cfg) activerun->scalers.setClassMask(activerun->cfg.getTriggerClassMask()); // mRunInStart = activerun; + saveRunConfigToCCDB(&activerun->cfg, timeStamp); return 0; } int CTPRunManager::stopRun(uint32_t irun) @@ -630,6 +631,11 @@ int CTPRunManager::processMessage(std::string& topic, const std::string& message { LOG(info) << "Processing message with topic:" << topic; std::string firstcounters; + if (topic.find("ctpconfig") != std::string::npos) { + LOG(info) << "ctpcfg received"; + startRun(message); + mCtpcfg = 1; + } if (topic.find("sox") != std::string::npos) { // get config size_t irun = message.find("run"); @@ -639,9 +645,13 @@ int CTPRunManager::processMessage(std::string& topic, const std::string& message return 1; } LOG(info) << "SOX received, Run:" << irun; - std::string cfg = message.substr(irun, message.size() - irun); - LOG(info) << "Config:" << cfg; - startRun(cfg); + if(mCtpcfg == 0) { + std::string cfg = message.substr(irun, message.size() - irun); + LOG(info) << "Config:" << cfg; + startRun(cfg); + } else { + mCtpcfg = 0; + } firstcounters = message.substr(0, irun); } if (topic.find("eox") != std::string::npos) { @@ -685,7 +695,6 @@ int CTPRunManager::processMessage(std::string& topic, const std::string& message LOG(error) << "Internal error in processMessage: nullptr != 0 expected"; } mActiveRuns[i] = mRunInStart; - saveRunConfigToCCDB(i); mRunInStart = nullptr; addScalers(i, tt); } else if ((mCounters[i] == 0) && (mActiveRunNumbers[i] != 0)) { @@ -726,21 +735,20 @@ int CTPRunManager::saveRunScalersToCCDB(int i) LOG(info) << "CTP scalers saved in ccdb, run:" << run->cfg.getRunNumber(); return 0; } -int CTPRunManager::saveRunConfigToCCDB(int i) +int CTPRunManager::saveRunConfigToCCDB(CTPConfiguration* cfg, long timeStart) { // data base - CTPActiveRun* run = mActiveRuns[i]; - long tmin = run->timeStart; + long tmin = timeStart; using namespace std::chrono_literals; std::chrono::seconds days3 = 259200s; long time3days = std::chrono::duration_cast(days3).count(); - long tmax = run->timeStart + time3days; + long tmax = timeStart + time3days; o2::ccdb::CcdbApi api; map metadata; // can be empty api.init(mCcdbHost.c_str()); // or http://localhost:8080 for a local installation // store abitrary user object in strongly typed manner - api.storeAsTFileAny(&(run->cfg), o2::ctp::CCDBPathCTPConfig, metadata, tmin, tmax); - LOG(info) << "CTP config saved in ccdb, run:" << run->cfg.getRunNumber(); + api.storeAsTFileAny( cfg, o2::ctp::CCDBPathCTPConfig, metadata, tmin, tmax); + LOG(info) << "CTP config saved in ccdb, run:" << cfg->getRunNumber(); return 0; } int CTPRunManager::getConfigFromCCDB() From e3aeecd017893113ad3ada3253f6e134f7b22c7f Mon Sep 17 00:00:00 2001 From: lietava Date: Mon, 30 May 2022 08:22:34 +0200 Subject: [PATCH 3/3] clang --- DataFormats/Detectors/CTP/src/Configuration.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DataFormats/Detectors/CTP/src/Configuration.cxx b/DataFormats/Detectors/CTP/src/Configuration.cxx index 5b280a46d0fce..76e02b90529ea 100644 --- a/DataFormats/Detectors/CTP/src/Configuration.cxx +++ b/DataFormats/Detectors/CTP/src/Configuration.cxx @@ -645,12 +645,12 @@ int CTPRunManager::processMessage(std::string& topic, const std::string& message return 1; } LOG(info) << "SOX received, Run:" << irun; - if(mCtpcfg == 0) { + if (mCtpcfg == 0) { std::string cfg = message.substr(irun, message.size() - irun); LOG(info) << "Config:" << cfg; startRun(cfg); } else { - mCtpcfg = 0; + mCtpcfg = 0; } firstcounters = message.substr(0, irun); } @@ -747,7 +747,7 @@ int CTPRunManager::saveRunConfigToCCDB(CTPConfiguration* cfg, long timeStart) map metadata; // can be empty api.init(mCcdbHost.c_str()); // or http://localhost:8080 for a local installation // store abitrary user object in strongly typed manner - api.storeAsTFileAny( cfg, o2::ctp::CCDBPathCTPConfig, metadata, tmin, tmax); + api.storeAsTFileAny(cfg, o2::ctp::CCDBPathCTPConfig, metadata, tmin, tmax); LOG(info) << "CTP config saved in ccdb, run:" << cfg->getRunNumber(); return 0; }