Skip to content

Commit b78b50c

Browse files
authored
ctpdev: orbitreset and orbitsox via zmq II (#14147)
* dev: finishing orbitsox and orbitreset via zmq * clang * fix * fix * dev: removed infologger and using LOG(important) * clang * fix
1 parent 0a831b2 commit b78b50c

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

Detectors/CTP/workflowScalers/include/CTPWorkflowScalers/RunManager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "DataFormatsCTP/Configuration.h"
1919
#include "BookkeepingApi/BkpClientFactory.h"
2020
#include "BookkeepingApi/BkpClient.h"
21+
2122
using namespace o2::bkp::api;
2223
namespace o2
2324
{

Detectors/CTP/workflowScalers/src/RunManager.cxx

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <regex>
1919
#include "CommonUtils/StringUtils.h"
2020
#include <fairlogger/Logger.h>
21+
2122
using namespace o2::ctp;
2223
///
2324
/// Active run to keep cfg and saclers of active runs
@@ -232,10 +233,44 @@ int CTPRunManager::processMessage(std::string& topic, const std::string& message
232233
return 0;
233234
}
234235
if (topic.find("soxorbit") != std::string::npos) {
235-
return 0;
236+
std::vector<std::string> tokens = o2::utils::Str::tokenize(message, ' ');
237+
int ret = 0;
238+
if (tokens.size() == 3) {
239+
long timestamp = std::stol(tokens[0]);
240+
uint32_t runnumber = std::stoul(tokens[1]);
241+
uint32_t orbit = std::stoul(tokens[2]);
242+
ret = saveSoxOrbit(runnumber, orbit, timestamp);
243+
std::string logmessage;
244+
if (ret) {
245+
logmessage = "Failed to update CCDB with SOX orbit.";
246+
} else {
247+
logmessage = "CCDB updated with SOX orbit.";
248+
}
249+
LOG(important) << logmessage << " run:" << runnumber << " sox orbit:" << orbit << " ts:" << timestamp;
250+
} else {
251+
LOG(error) << "Topic soxorbit dize !=3: " << message << " token size:" << tokens.size();
252+
ret = 1;
253+
}
254+
return ret;
236255
}
237256
if (topic.find("orbitreset") != std::string::npos) {
238-
return 0;
257+
std::vector<std::string> tokens = o2::utils::Str::tokenize(message, ' ');
258+
int ret = 0;
259+
if (tokens.size() == 1) {
260+
long timestamp = std::stol(tokens[0]);
261+
ret = saveOrbitReset(timestamp);
262+
std::string logmessage;
263+
if (ret) {
264+
logmessage = "Failed to update CCDB with orbitreset. ";
265+
} else {
266+
logmessage = "CCDB updated with orbitreset. ";
267+
}
268+
LOG(important) << logmessage << timestamp;
269+
} else {
270+
LOG(error) << "Topic orbit reset != 2: " << message << " token size:" << tokens.size();
271+
ret = 1;
272+
}
273+
return ret;
239274
}
240275
static int nerror = 0;
241276
if (topic.find("sox") != std::string::npos) {

Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ int ctpCCDBManager::saveSoxOrbit(uint32_t runNumber, uint32_t soxOrbit, long tim
122122
vect.push_back(timestamp);
123123
vect.push_back((uint64_t)runNumber);
124124
vect.push_back((uint64_t)soxOrbit);
125-
long tmin = timestamp;
125+
long tmin = timestamp / 1000;
126126
long tmax = tmin + 381928219;
127127
o2::ccdb::CcdbApi api;
128128
map<string, string> metadata; // can be empty
@@ -149,9 +149,10 @@ int ctpCCDBManager::saveOrbitReset(long timeStamp)
149149
if (timeStamp == 0) {
150150
auto now = std::chrono::system_clock::now();
151151
timeStamp = std::chrono::duration_cast<std::chrono::microseconds>(now.time_since_epoch()).count();
152+
LOG(warn) << "Received timestamp = 0 , using current time:" << timeStamp;
152153
}
153154
vect.push_back(timeStamp);
154-
long tmin = timeStamp;
155+
long tmin = timeStamp / 1000;
155156
long tmax = tmin + 381928219;
156157
o2::ccdb::CcdbApi api;
157158
map<string, string> metadata; // can be empty

0 commit comments

Comments
 (0)