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
Original file line number Diff line number Diff line change
Expand Up @@ -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(CTPConfiguration* cfg, long timeStart);
int getConfigFromCCDB();
int getScalersFromCCDB();
int loadScalerNames();
Expand All @@ -180,7 +181,8 @@ class CTPRunManager
std::map<std::string, uint32_t> mScalerName2Position;
CTPActiveRun* mRunInStart = nullptr;
int mEOX = 0; // redundancy check
ClassDefNV(CTPRunManager, 1);
int mCtpcfg = 0;
ClassDefNV(CTPRunManager, 2);
};
} // namespace ctp
} // namespace o2
Expand Down
39 changes: 32 additions & 7 deletions DataFormats/Detectors/CTP/src/Configuration.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -591,7 +592,7 @@ int CTPRunManager::stopRun(uint32_t irun)
const auto now = std::chrono::system_clock::now();
const long timeStamp = std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()).count();
mActiveRuns[irun]->timeStop = timeStamp;
saveRunToCCDB(irun);
saveRunScalersToCCDB(irun);
delete mActiveRuns[irun];
mActiveRuns[irun] = nullptr;
return 0;
Expand Down Expand Up @@ -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");
Expand All @@ -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) {
Expand Down Expand Up @@ -711,7 +721,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];
Expand All @@ -721,9 +731,24 @@ int CTPRunManager::saveRunToCCDB(int i)
map<string, string> 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(CTPConfiguration* cfg, long timeStart)
{
// data base
long tmin = timeStart;
using namespace std::chrono_literals;
std::chrono::seconds days3 = 259200s;
long time3days = std::chrono::duration_cast<std::chrono::milliseconds>(days3).count();
long tmax = timeStart + time3days;
o2::ccdb::CcdbApi api;
map<string, string> 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);
LOG(info) << "CTP config saved in ccdb, run:" << cfg->getRunNumber();
return 0;
}
int CTPRunManager::getConfigFromCCDB()
Expand Down