From 2bb86388dec73aa8814b130e2a194221e928acb5 Mon Sep 17 00:00:00 2001 From: Roman Lietava Date: Fri, 23 Jan 2026 18:39:32 +0100 Subject: [PATCH 1/6] dev: code for repopulating BK with old configs/scalers --- Detectors/CTP/workflowScalers/CMakeLists.txt | 8 + .../CTPWorkflowScalers/ctpCCDBManager.h | 5 +- .../CTP/workflowScalers/src/ctp-bk-write.cxx | 167 ++++++++++++++++++ .../workflowScalers/src/ctpCCDBManager.cxx | 27 +++ 4 files changed, 205 insertions(+), 2 deletions(-) create mode 100644 Detectors/CTP/workflowScalers/src/ctp-bk-write.cxx diff --git a/Detectors/CTP/workflowScalers/CMakeLists.txt b/Detectors/CTP/workflowScalers/CMakeLists.txt index a31774ac66d69..f02a7f33e2abd 100644 --- a/Detectors/CTP/workflowScalers/CMakeLists.txt +++ b/Detectors/CTP/workflowScalers/CMakeLists.txt @@ -34,3 +34,11 @@ o2_add_executable( SOURCES src/ctp-ccdb-orbit.cxx PUBLIC_LINK_LIBRARIES O2::DataFormatsCTP Boost::program_options) +o2_add_executable( + bk-write + COMPONENT_NAME ctp + SOURCES src/ctp-bk-write.cxx + PUBLIC_LINK_LIBRARIES O2::DataFormatsCTP + O2::CTPWorkflowScalers + AliceO2::BookkeepingApi + Boost::program_options) diff --git a/Detectors/CTP/workflowScalers/include/CTPWorkflowScalers/ctpCCDBManager.h b/Detectors/CTP/workflowScalers/include/CTPWorkflowScalers/ctpCCDBManager.h index 4237ad4501fcc..df2aa79d18697 100644 --- a/Detectors/CTP/workflowScalers/include/CTPWorkflowScalers/ctpCCDBManager.h +++ b/Detectors/CTP/workflowScalers/include/CTPWorkflowScalers/ctpCCDBManager.h @@ -31,8 +31,9 @@ class ctpCCDBManager int saveOrbitReset(long timeStamp); int saveCtpCfg(uint32_t runNumber, long timeStamp); static CTPConfiguration getConfigFromCCDB(long timestamp, std::string run, bool& ok); - static CTPConfiguration getConfigFromCCDB(long timestamp, std::string run); - CTPRunScalers getScalersFromCCDB(long timestamp, std::string, bool& ok); + CTPConfiguration getConfigFromCCDB(long timestamp, std::string run); + CTPRunScalers getScalersFromCCDB(long timestamp, std::string run, bool& ok); + static CTPRunScalers getScalersFromCCDB(long timestamp, std::string, std::string path, bool& ok); static void setCCDBHost(std::string host) { mCCDBHost = host; }; static void setQCDBHost(std::string host) { mQCDBHost = host; }; void setCtpCfgDir(std::string& ctpcfgdir) { mCtpCfgDir = ctpcfgdir; }; diff --git a/Detectors/CTP/workflowScalers/src/ctp-bk-write.cxx b/Detectors/CTP/workflowScalers/src/ctp-bk-write.cxx new file mode 100644 index 0000000000000..1b474289a78fc --- /dev/null +++ b/Detectors/CTP/workflowScalers/src/ctp-bk-write.cxx @@ -0,0 +1,167 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +// example to run: +// +#include +#include +#include +#include +#include "CommonUtils/StringUtils.h" +#include +#include "CTPWorkflowScalers/ctpCCDBManager.h" +#include "BookkeepingApi/BkpClientFactory.h" +#include "BookkeepingApi/BkpClient.h" +#include +#include +#include +#include +namespace bpo = boost::program_options; +// + +int main(int argc, char** argv) +{ + const std::string testCCDB = "http://ccdb-test.cern.ch:8080"; + // std::string prodCCDB = "http://o2-ccdb.internal"; + const std::string aliceCCDB = "http://alice-ccdb.cern.ch"; + bpo::variables_map vm; + bpo::options_description opt_general("Usage:\n " + std::string(argv[0]) + + " Write ctp config or scalers to BK\n"); + bpo::options_description opt_hidden(""); + bpo::options_description opt_all; + bpo::positional_options_description opt_pos; + try { + auto add_option = opt_general.add_options(); + add_option("help,h", "Print this help message"); + add_option("input-file,f", bpo::value()->default_value("none"), "input file name, none - do not read file"); + add_option("bkhost,b", bpo::value()->default_value("none"), "bk web address"); + add_option("ccdb", bpo::value()->default_value("alice"), "choose databse: test- test ccdb; prod - production ccdb; alice - alice ccdb; else ccdb parameter"); + add_option("run-number,r", bpo::value()->default_value(0), "run number"); + add_option("timestamp,t", bpo::value()->default_value(0), "timestamp; if 0 timestamp is calulated inside this code"); + add_option("cfg,c",bpo::value()->default_value(0),"Do cfg"); + add_option("scalers,s",bpo::value()->default_value(0),"Do scalers"); + // + opt_all.add(opt_general).add(opt_hidden); + bpo::store(bpo::command_line_parser(argc, argv).options(opt_all).positional(opt_pos).run(), vm); + if (vm.count("help")) { + std::cout << opt_general << std::endl; + exit(0); + } + bpo::notify(vm); + } catch (bpo::error& e) { + std::cerr << "ERROR: " << e.what() << std::endl + << std::endl; + std::cerr << opt_general << std::endl; + exit(1); + } catch (std::exception& e) { + std::cerr << e.what() << ", application will now exit" << std::endl; + exit(2); + } + uint64_t timestamp = vm["timestamp"].as(); + // + int ret = 0; + std::vector runs; + int32_t run = vm["run-number"].as(); + std::cout << "run:" << run << std::endl; + if(run) { + std::cout << "pushing" << std::endl; + runs.push_back(std::to_string(run)); + } + // read input file + std::string filename = vm["input-file"].as(); + std::ifstream file(filename); + if (!file.is_open()) { + std::cout << "Cannot open file! Using only run:" << run << std::endl; + } else { + std::string line; + while (std::getline(file, line)) { + std::cout << line << "\n"; + std::vector tokens = o2::utils::Str::tokenize(line, ' '); + //int run = std::stoi(tokens[0]); + runs.push_back(tokens[0]); + } + } + bool cfg = vm["cfg"].as(); + bool scalers = vm["scalers"].as(); + std::cout << "Doing: cfg:" << cfg << " scal:" << scalers << std::endl; + if(cfg || scalers){ + std::string bkhost = vm["bkhost"].as(); + std::unique_ptr mBKClient = o2::bkp::api::BkpClientFactory::create(bkhost); + //get from ccdb + std::string ccdbAddress; + if (vm["ccdb"].as() == "prod") { + //ccdbAddress = prodCCDB; + } else if (vm["ccdb"].as() == "test") { + ccdbAddress = testCCDB; + } else if (vm["ccdb"].as() == "alice") { + ccdbAddress = aliceCCDB; + } else { + ccdbAddress = vm["ccdb"].as(); + } + o2::ctp::ctpCCDBManager::setCCDBHost(ccdbAddress); + std::cout << "CCDB: " << vm["ccdb"].as() << " " << ccdbAddress << std::endl; + //o2::ccdb::CcdbApi api; + //api.init(ccdbAddress.c_str()); + std::map metadata; + for(auto const& run: runs) { + metadata["runNumber"] = run; + bool ok; + int runNumber = std::stoi(run); + auto ctpcfg = o2::ctp::ctpCCDBManager::getConfigFromCCDB(timestamp,run,ok); + + if(cfg) { + std::string ctpcfgstr = ctpcfg.getConfigString(); + try { + mBKClient->run()->setRawCtpTriggerConfiguration(runNumber, ctpcfgstr); + } catch (std::runtime_error& error) { + std::cerr << "An error occurred: " << error.what() << std::endl; + //return 1; + } + LOG(info) << "Run BK:" << run << " CFG:" << cfg; + } + if(scalers){ + auto ctpcnts = o2::ctp::ctpCCDBManager::getScalersFromCCDB(timestamp,run, "CTP/Calib/Scalers", ok); + ctpcnts.convertRawToO2(); + std::vector clsinds = ctpcnts.getClassIndexes(); + long ts = ctpcnts.getTimeLimit().second; + int i = 0; + for(auto const& ind: clsinds){ + std::array cntsbk = ctpcnts.getIntegralForClass(i); + std::string clsname = ctpcfg.getClassNameFromHWIndex(cntsbk[0]); + try { + mBKClient->ctpTriggerCounters()->createOrUpdateForRun(runNumber, clsname, ts, cntsbk[1], cntsbk[2], cntsbk[3], cntsbk[4], cntsbk[5], cntsbk[6]); + std::cout << runNumber << " clsname: " << clsname << "t:" << ts << "cnts:" << cntsbk[1] << " " << cntsbk[2] << " " << cntsbk[3] << " " << cntsbk[4] << " " << cntsbk[5] << " " << cntsbk[6] << std::endl;; + + } catch (std::runtime_error& error) { + std::cerr << "An error occurred: " << error.what() << std::endl; + //return 1; + } + LOG(info) << "Run BK scalers ok"; + i++; + } + } + } + // add to bk + } + std::cout << "o2-ctp-bk-write done" << std::endl; + return ret; +} diff --git a/Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx b/Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx index df75b21c2effd..172921ab4f45a 100644 --- a/Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx +++ b/Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx @@ -204,10 +204,16 @@ int ctpCCDBManager::saveCtpCfg(uint32_t runNumber, long timeStart) } CTPConfiguration ctpCCDBManager::getConfigFromCCDB(long timestamp, std::string run, bool& ok) { + auto& mgr = o2::ccdb::BasicCCDBManager::instance(); mgr.setURL(mCCDBHost); std::map metadata; // can be empty metadata["runNumber"] = run; + if(timestamp == 0) { + // Timestamp + auto soreor = mgr.getRunDuration(std::stoi(run)); + timestamp = (soreor.second - soreor.first) / 2 + soreor.first; + } auto ctpconfigdb = mgr.getSpecific(CCDBPathCTPConfig, timestamp, metadata); if (ctpconfigdb == nullptr) { LOG(info) << "CTP config not in database, timestamp:" << timestamp; @@ -245,3 +251,24 @@ CTPRunScalers ctpCCDBManager::getScalersFromCCDB(long timestamp, std::string run } return *ctpscalers; } +CTPRunScalers ctpCCDBManager::getScalersFromCCDB(long timestamp, std::string run, std::string path, bool& ok) +{ + auto& mgr = o2::ccdb::BasicCCDBManager::instance(); + mgr.setURL(mCCDBHost); + std::map metadata; // can be empty + metadata["runNumber"] = run; + if(timestamp == 0) { + // Timestamp + auto soreor = mgr.getRunDuration(std::stoi(run)); + timestamp = (soreor.second - soreor.first) / 2 + soreor.first; + } + auto ctpscalers = mgr.getSpecific(path, timestamp, metadata); + if (ctpscalers == nullptr) { + LOG(info) << "CTPRunScalers not in database, timestamp:" << timestamp; + ok = 0; + } else { + // ctpscalers->printStream(std::cout); + ok = 1; + } + return *ctpscalers; +} \ No newline at end of file From a75a1a4d60de1e78a3864c6516f37b581df1b6d8 Mon Sep 17 00:00:00 2001 From: Roman Lietava Date: Fri, 23 Jan 2026 18:40:17 +0100 Subject: [PATCH 2/6] clang --- .../CTP/workflowScalers/src/ctp-bk-write.cxx | 199 +++++++++--------- .../workflowScalers/src/ctpCCDBManager.cxx | 6 +- 2 files changed, 103 insertions(+), 102 deletions(-) diff --git a/Detectors/CTP/workflowScalers/src/ctp-bk-write.cxx b/Detectors/CTP/workflowScalers/src/ctp-bk-write.cxx index 1b474289a78fc..69c976b766f2c 100644 --- a/Detectors/CTP/workflowScalers/src/ctp-bk-write.cxx +++ b/Detectors/CTP/workflowScalers/src/ctp-bk-write.cxx @@ -40,16 +40,16 @@ namespace bpo = boost::program_options; int main(int argc, char** argv) { - const std::string testCCDB = "http://ccdb-test.cern.ch:8080"; - // std::string prodCCDB = "http://o2-ccdb.internal"; - const std::string aliceCCDB = "http://alice-ccdb.cern.ch"; - bpo::variables_map vm; - bpo::options_description opt_general("Usage:\n " + std::string(argv[0]) + - " Write ctp config or scalers to BK\n"); - bpo::options_description opt_hidden(""); - bpo::options_description opt_all; - bpo::positional_options_description opt_pos; - try { + const std::string testCCDB = "http://ccdb-test.cern.ch:8080"; + // std::string prodCCDB = "http://o2-ccdb.internal"; + const std::string aliceCCDB = "http://alice-ccdb.cern.ch"; + bpo::variables_map vm; + bpo::options_description opt_general("Usage:\n " + std::string(argv[0]) + + " Write ctp config or scalers to BK\n"); + bpo::options_description opt_hidden(""); + bpo::options_description opt_all; + bpo::positional_options_description opt_pos; + try { auto add_option = opt_general.add_options(); add_option("help,h", "Print this help message"); add_option("input-file,f", bpo::value()->default_value("none"), "input file name, none - do not read file"); @@ -57,111 +57,112 @@ int main(int argc, char** argv) add_option("ccdb", bpo::value()->default_value("alice"), "choose databse: test- test ccdb; prod - production ccdb; alice - alice ccdb; else ccdb parameter"); add_option("run-number,r", bpo::value()->default_value(0), "run number"); add_option("timestamp,t", bpo::value()->default_value(0), "timestamp; if 0 timestamp is calulated inside this code"); - add_option("cfg,c",bpo::value()->default_value(0),"Do cfg"); - add_option("scalers,s",bpo::value()->default_value(0),"Do scalers"); + add_option("cfg,c", bpo::value()->default_value(0), "Do cfg"); + add_option("scalers,s", bpo::value()->default_value(0), "Do scalers"); // opt_all.add(opt_general).add(opt_hidden); bpo::store(bpo::command_line_parser(argc, argv).options(opt_all).positional(opt_pos).run(), vm); if (vm.count("help")) { - std::cout << opt_general << std::endl; - exit(0); + std::cout << opt_general << std::endl; + exit(0); } bpo::notify(vm); - } catch (bpo::error& e) { + } catch (bpo::error& e) { std::cerr << "ERROR: " << e.what() << std::endl - << std::endl; + << std::endl; std::cerr << opt_general << std::endl; exit(1); - } catch (std::exception& e) { + } catch (std::exception& e) { std::cerr << e.what() << ", application will now exit" << std::endl; exit(2); + } + uint64_t timestamp = vm["timestamp"].as(); + // + int ret = 0; + std::vector runs; + int32_t run = vm["run-number"].as(); + std::cout << "run:" << run << std::endl; + if (run) { + std::cout << "pushing" << std::endl; + runs.push_back(std::to_string(run)); + } + // read input file + std::string filename = vm["input-file"].as(); + std::ifstream file(filename); + if (!file.is_open()) { + std::cout << "Cannot open file! Using only run:" << run << std::endl; + } else { + std::string line; + while (std::getline(file, line)) { + std::cout << line << "\n"; + std::vector tokens = o2::utils::Str::tokenize(line, ' '); + // int run = std::stoi(tokens[0]); + runs.push_back(tokens[0]); } - uint64_t timestamp = vm["timestamp"].as(); - // - int ret = 0; - std::vector runs; - int32_t run = vm["run-number"].as(); - std::cout << "run:" << run << std::endl; - if(run) { - std::cout << "pushing" << std::endl; - runs.push_back(std::to_string(run)); - } - // read input file - std::string filename = vm["input-file"].as(); - std::ifstream file(filename); - if (!file.is_open()) { - std::cout << "Cannot open file! Using only run:" << run << std::endl; + } + bool cfg = vm["cfg"].as(); + bool scalers = vm["scalers"].as(); + std::cout << "Doing: cfg:" << cfg << " scal:" << scalers << std::endl; + if (cfg || scalers) { + std::string bkhost = vm["bkhost"].as(); + std::unique_ptr mBKClient = o2::bkp::api::BkpClientFactory::create(bkhost); + // get from ccdb + std::string ccdbAddress; + if (vm["ccdb"].as() == "prod") { + // ccdbAddress = prodCCDB; + } else if (vm["ccdb"].as() == "test") { + ccdbAddress = testCCDB; + } else if (vm["ccdb"].as() == "alice") { + ccdbAddress = aliceCCDB; } else { - std::string line; - while (std::getline(file, line)) { - std::cout << line << "\n"; - std::vector tokens = o2::utils::Str::tokenize(line, ' '); - //int run = std::stoi(tokens[0]); - runs.push_back(tokens[0]); - } + ccdbAddress = vm["ccdb"].as(); } - bool cfg = vm["cfg"].as(); - bool scalers = vm["scalers"].as(); - std::cout << "Doing: cfg:" << cfg << " scal:" << scalers << std::endl; - if(cfg || scalers){ - std::string bkhost = vm["bkhost"].as(); - std::unique_ptr mBKClient = o2::bkp::api::BkpClientFactory::create(bkhost); - //get from ccdb - std::string ccdbAddress; - if (vm["ccdb"].as() == "prod") { - //ccdbAddress = prodCCDB; - } else if (vm["ccdb"].as() == "test") { - ccdbAddress = testCCDB; - } else if (vm["ccdb"].as() == "alice") { - ccdbAddress = aliceCCDB; - } else { - ccdbAddress = vm["ccdb"].as(); - } - o2::ctp::ctpCCDBManager::setCCDBHost(ccdbAddress); - std::cout << "CCDB: " << vm["ccdb"].as() << " " << ccdbAddress << std::endl; - //o2::ccdb::CcdbApi api; - //api.init(ccdbAddress.c_str()); - std::map metadata; - for(auto const& run: runs) { - metadata["runNumber"] = run; - bool ok; - int runNumber = std::stoi(run); - auto ctpcfg = o2::ctp::ctpCCDBManager::getConfigFromCCDB(timestamp,run,ok); + o2::ctp::ctpCCDBManager::setCCDBHost(ccdbAddress); + std::cout << "CCDB: " << vm["ccdb"].as() << " " << ccdbAddress << std::endl; + // o2::ccdb::CcdbApi api; + // api.init(ccdbAddress.c_str()); + std::map metadata; + for (auto const& run : runs) { + metadata["runNumber"] = run; + bool ok; + int runNumber = std::stoi(run); + auto ctpcfg = o2::ctp::ctpCCDBManager::getConfigFromCCDB(timestamp, run, ok); - if(cfg) { - std::string ctpcfgstr = ctpcfg.getConfigString(); - try { - mBKClient->run()->setRawCtpTriggerConfiguration(runNumber, ctpcfgstr); - } catch (std::runtime_error& error) { - std::cerr << "An error occurred: " << error.what() << std::endl; - //return 1; - } - LOG(info) << "Run BK:" << run << " CFG:" << cfg; - } - if(scalers){ - auto ctpcnts = o2::ctp::ctpCCDBManager::getScalersFromCCDB(timestamp,run, "CTP/Calib/Scalers", ok); - ctpcnts.convertRawToO2(); - std::vector clsinds = ctpcnts.getClassIndexes(); - long ts = ctpcnts.getTimeLimit().second; - int i = 0; - for(auto const& ind: clsinds){ - std::array cntsbk = ctpcnts.getIntegralForClass(i); - std::string clsname = ctpcfg.getClassNameFromHWIndex(cntsbk[0]); - try { - mBKClient->ctpTriggerCounters()->createOrUpdateForRun(runNumber, clsname, ts, cntsbk[1], cntsbk[2], cntsbk[3], cntsbk[4], cntsbk[5], cntsbk[6]); - std::cout << runNumber << " clsname: " << clsname << "t:" << ts << "cnts:" << cntsbk[1] << " " << cntsbk[2] << " " << cntsbk[3] << " " << cntsbk[4] << " " << cntsbk[5] << " " << cntsbk[6] << std::endl;; + if (cfg) { + std::string ctpcfgstr = ctpcfg.getConfigString(); + try { + mBKClient->run()->setRawCtpTriggerConfiguration(runNumber, ctpcfgstr); + } catch (std::runtime_error& error) { + std::cerr << "An error occurred: " << error.what() << std::endl; + // return 1; + } + LOG(info) << "Run BK:" << run << " CFG:" << cfg; + } + if (scalers) { + auto ctpcnts = o2::ctp::ctpCCDBManager::getScalersFromCCDB(timestamp, run, "CTP/Calib/Scalers", ok); + ctpcnts.convertRawToO2(); + std::vector clsinds = ctpcnts.getClassIndexes(); + long ts = ctpcnts.getTimeLimit().second; + int i = 0; + for (auto const& ind : clsinds) { + std::array cntsbk = ctpcnts.getIntegralForClass(i); + std::string clsname = ctpcfg.getClassNameFromHWIndex(cntsbk[0]); + try { + mBKClient->ctpTriggerCounters()->createOrUpdateForRun(runNumber, clsname, ts, cntsbk[1], cntsbk[2], cntsbk[3], cntsbk[4], cntsbk[5], cntsbk[6]); + std::cout << runNumber << " clsname: " << clsname << "t:" << ts << "cnts:" << cntsbk[1] << " " << cntsbk[2] << " " << cntsbk[3] << " " << cntsbk[4] << " " << cntsbk[5] << " " << cntsbk[6] << std::endl; + ; - } catch (std::runtime_error& error) { - std::cerr << "An error occurred: " << error.what() << std::endl; - //return 1; - } - LOG(info) << "Run BK scalers ok"; - i++; - } - } + } catch (std::runtime_error& error) { + std::cerr << "An error occurred: " << error.what() << std::endl; + // return 1; + } + LOG(info) << "Run BK scalers ok"; + i++; } - // add to bk + } } - std::cout << "o2-ctp-bk-write done" << std::endl; - return ret; + // add to bk + } + std::cout << "o2-ctp-bk-write done" << std::endl; + return ret; } diff --git a/Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx b/Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx index 172921ab4f45a..74d4a905c93e2 100644 --- a/Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx +++ b/Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx @@ -204,12 +204,12 @@ int ctpCCDBManager::saveCtpCfg(uint32_t runNumber, long timeStart) } CTPConfiguration ctpCCDBManager::getConfigFromCCDB(long timestamp, std::string run, bool& ok) { - + auto& mgr = o2::ccdb::BasicCCDBManager::instance(); mgr.setURL(mCCDBHost); std::map metadata; // can be empty metadata["runNumber"] = run; - if(timestamp == 0) { + if (timestamp == 0) { // Timestamp auto soreor = mgr.getRunDuration(std::stoi(run)); timestamp = (soreor.second - soreor.first) / 2 + soreor.first; @@ -257,7 +257,7 @@ CTPRunScalers ctpCCDBManager::getScalersFromCCDB(long timestamp, std::string run mgr.setURL(mCCDBHost); std::map metadata; // can be empty metadata["runNumber"] = run; - if(timestamp == 0) { + if (timestamp == 0) { // Timestamp auto soreor = mgr.getRunDuration(std::stoi(run)); timestamp = (soreor.second - soreor.first) / 2 + soreor.first; From 2f8cc88fccbb9d36ceb7d2078b3c16786249bc09 Mon Sep 17 00:00:00 2001 From: Roman Lietava Date: Sat, 24 Jan 2026 08:56:18 +0100 Subject: [PATCH 3/6] fixes --- .../CTP/workflowScalers/src/ctp-bk-write.cxx | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/Detectors/CTP/workflowScalers/src/ctp-bk-write.cxx b/Detectors/CTP/workflowScalers/src/ctp-bk-write.cxx index 69c976b766f2c..f118cffc37b85 100644 --- a/Detectors/CTP/workflowScalers/src/ctp-bk-write.cxx +++ b/Detectors/CTP/workflowScalers/src/ctp-bk-write.cxx @@ -37,7 +37,9 @@ #include namespace bpo = boost::program_options; // - +// Test in the lab +// o2-ctp-bk-write -r 37 -s 1 -c 1 --ccdb='http://acsl-ccdb.cern.ch:8083' -b 'acsl-aliecs.cern.ch:4001' -t 1753185071753 +// int main(int argc, char** argv) { const std::string testCCDB = "http://ccdb-test.cern.ch:8080"; @@ -88,16 +90,18 @@ int main(int argc, char** argv) } // read input file std::string filename = vm["input-file"].as(); - std::ifstream file(filename); - if (!file.is_open()) { - std::cout << "Cannot open file! Using only run:" << run << std::endl; - } else { - std::string line; - while (std::getline(file, line)) { - std::cout << line << "\n"; - std::vector tokens = o2::utils::Str::tokenize(line, ' '); - // int run = std::stoi(tokens[0]); - runs.push_back(tokens[0]); + if(filename != "none") { + std::ifstream file(filename); + if (!file.is_open()) { + std::cout << "Cannot open file! Using only run:" << run << std::endl; + } else { + std::string line; + while (std::getline(file, line)) { + std::cout << line << "\n"; + std::vector tokens = o2::utils::Str::tokenize(line, ' '); + // int run = std::stoi(tokens[0]); + runs.push_back(tokens[0]); + } } } bool cfg = vm["cfg"].as(); @@ -119,8 +123,6 @@ int main(int argc, char** argv) } o2::ctp::ctpCCDBManager::setCCDBHost(ccdbAddress); std::cout << "CCDB: " << vm["ccdb"].as() << " " << ccdbAddress << std::endl; - // o2::ccdb::CcdbApi api; - // api.init(ccdbAddress.c_str()); std::map metadata; for (auto const& run : runs) { metadata["runNumber"] = run; @@ -148,8 +150,8 @@ int main(int argc, char** argv) std::array cntsbk = ctpcnts.getIntegralForClass(i); std::string clsname = ctpcfg.getClassNameFromHWIndex(cntsbk[0]); try { - mBKClient->ctpTriggerCounters()->createOrUpdateForRun(runNumber, clsname, ts, cntsbk[1], cntsbk[2], cntsbk[3], cntsbk[4], cntsbk[5], cntsbk[6]); - std::cout << runNumber << " clsname: " << clsname << "t:" << ts << "cnts:" << cntsbk[1] << " " << cntsbk[2] << " " << cntsbk[3] << " " << cntsbk[4] << " " << cntsbk[5] << " " << cntsbk[6] << std::endl; + //mBKClient->ctpTriggerCounters()->createOrUpdateForRun(runNumber, clsname, ts, cntsbk[1], cntsbk[2], cntsbk[3], cntsbk[4], cntsbk[5], cntsbk[6]); + std::cout << runNumber << " clsname: " << cntsbk[0] << " " << clsname << "t:" << ts << "cnts:" << cntsbk[1] << " " << cntsbk[2] << " " << cntsbk[3] << " " << cntsbk[4] << " " << cntsbk[5] << " " << cntsbk[6] << std::endl; ; } catch (std::runtime_error& error) { From 68257d898c733306e45fbbaff7a0518a647b438c Mon Sep 17 00:00:00 2001 From: Roman Lietava Date: Sat, 24 Jan 2026 09:00:43 +0100 Subject: [PATCH 4/6] fixes --- Detectors/CTP/workflowScalers/src/ctp-bk-write.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Detectors/CTP/workflowScalers/src/ctp-bk-write.cxx b/Detectors/CTP/workflowScalers/src/ctp-bk-write.cxx index f118cffc37b85..dbb5a2eaaf91d 100644 --- a/Detectors/CTP/workflowScalers/src/ctp-bk-write.cxx +++ b/Detectors/CTP/workflowScalers/src/ctp-bk-write.cxx @@ -150,15 +150,15 @@ int main(int argc, char** argv) std::array cntsbk = ctpcnts.getIntegralForClass(i); std::string clsname = ctpcfg.getClassNameFromHWIndex(cntsbk[0]); try { - //mBKClient->ctpTriggerCounters()->createOrUpdateForRun(runNumber, clsname, ts, cntsbk[1], cntsbk[2], cntsbk[3], cntsbk[4], cntsbk[5], cntsbk[6]); - std::cout << runNumber << " clsname: " << cntsbk[0] << " " << clsname << "t:" << ts << "cnts:" << cntsbk[1] << " " << cntsbk[2] << " " << cntsbk[3] << " " << cntsbk[4] << " " << cntsbk[5] << " " << cntsbk[6] << std::endl; + mBKClient->ctpTriggerCounters()->createOrUpdateForRun(runNumber, clsname, ts, cntsbk[1], cntsbk[2], cntsbk[3], cntsbk[4], cntsbk[5], cntsbk[6]); + std::cout << runNumber << " clsname: " << cntsbk[0] << " " << clsname << " t:" << ts << " cnts:" << cntsbk[1] << " " << cntsbk[2] << " " << cntsbk[3] << " " << cntsbk[4] << " " << cntsbk[5] << " " << cntsbk[6] << std::endl; ; } catch (std::runtime_error& error) { std::cerr << "An error occurred: " << error.what() << std::endl; // return 1; } - LOG(info) << "Run BK scalers ok"; + LOG(debug) << "Run BK scalers ok"; i++; } } From c66d05afc9bc255cb64439107e5d598631c987bb Mon Sep 17 00:00:00 2001 From: Roman Lietava Date: Sat, 24 Jan 2026 09:01:31 +0100 Subject: [PATCH 5/6] clang --- Detectors/CTP/workflowScalers/src/ctp-bk-write.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Detectors/CTP/workflowScalers/src/ctp-bk-write.cxx b/Detectors/CTP/workflowScalers/src/ctp-bk-write.cxx index dbb5a2eaaf91d..242dbe851cec2 100644 --- a/Detectors/CTP/workflowScalers/src/ctp-bk-write.cxx +++ b/Detectors/CTP/workflowScalers/src/ctp-bk-write.cxx @@ -90,18 +90,18 @@ int main(int argc, char** argv) } // read input file std::string filename = vm["input-file"].as(); - if(filename != "none") { + if (filename != "none") { std::ifstream file(filename); if (!file.is_open()) { - std::cout << "Cannot open file! Using only run:" << run << std::endl; + std::cout << "Cannot open file! Using only run:" << run << std::endl; } else { - std::string line; - while (std::getline(file, line)) { + std::string line; + while (std::getline(file, line)) { std::cout << line << "\n"; std::vector tokens = o2::utils::Str::tokenize(line, ' '); // int run = std::stoi(tokens[0]); runs.push_back(tokens[0]); - } + } } } bool cfg = vm["cfg"].as(); From 62f12b806cf8d4c408b8ee67014402975aed75ef Mon Sep 17 00:00:00 2001 From: Roman Lietava Date: Sat, 24 Jan 2026 09:08:11 +0100 Subject: [PATCH 6/6] fix --- Detectors/CTP/workflowScalers/src/ctp-bk-write.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Detectors/CTP/workflowScalers/src/ctp-bk-write.cxx b/Detectors/CTP/workflowScalers/src/ctp-bk-write.cxx index 242dbe851cec2..8460c07dcc896 100644 --- a/Detectors/CTP/workflowScalers/src/ctp-bk-write.cxx +++ b/Detectors/CTP/workflowScalers/src/ctp-bk-write.cxx @@ -93,7 +93,7 @@ int main(int argc, char** argv) if (filename != "none") { std::ifstream file(filename); if (!file.is_open()) { - std::cout << "Cannot open file! Using only run:" << run << std::endl; + LOG(fatal) << "Cannot open file:" << filename << std::endl; } else { std::string line; while (std::getline(file, line)) {