Skip to content

Commit 9b468a9

Browse files
committed
dev:ctpcfg
1 parent 555994a commit 9b468a9

File tree

4 files changed

+37
-26
lines changed

4 files changed

+37
-26
lines changed

DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ std::ostream& operator<<(std::ostream& in, const CTPConfiguration& conf);
208208
struct CtpCfg {
209209
CtpCfg() = default;
210210
std::string filename = "ctp.cfg";
211-
CtpCfg readAndSave(std::string& path);
211+
CtpCfg readAndSave(std::string& path, int& ret);
212212
uint32_t TFOrbits = 0;
213213
int ccdb = -1; // -1 means def constructor was called
214214
uint32_t orbitShift = 0;

DataFormats/Detectors/CTP/src/Configuration.cxx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,9 +1177,11 @@ int CTPInputsConfiguration::getInputIndexFromName(std::string& name)
11771177
return 0xff;
11781178
}
11791179

1180-
CtpCfg CtpCfg::readAndSave(std::string& path)
1180+
CtpCfg CtpCfg::readAndSave(std::string& path, int& ret)
11811181
{
1182-
std::ifstream ctpcfg(path + filename);
1182+
ret = 0;
1183+
std::string file = path + filename;
1184+
std::ifstream ctpcfg(file);
11831185
if (ctpcfg.is_open()) {
11841186
std::string line;
11851187
while (std::getline(ctpcfg, line)) {
@@ -1194,7 +1196,7 @@ CtpCfg CtpCfg::readAndSave(std::string& path)
11941196
size_t ntokens = tokens.size();
11951197
if (ntokens < 2) {
11961198
LOG(warn) << "Not enough tokens";
1197-
return *this;
1199+
continue;
11981200
}
11991201
if (tokens[0].find("TForbits") != std::string::npos) {
12001202
TFOrbits = std::atol(tokens[1].c_str());
@@ -1209,8 +1211,10 @@ CtpCfg CtpCfg::readAndSave(std::string& path)
12091211
LOG(warn) << " Token not found:" << tokens[0];
12101212
}
12111213
}
1214+
LOG(warn) << "Open file success:" << file;
12121215
} else {
1213-
LOG(warn) << "Can not open file:" << filename;
1216+
LOG(warn) << "Can not open file:" << file;
1217+
ret = 1;
12141218
}
12151219
return *this;
12161220
}

Detectors/CTP/workflowScalers/src/RunManager.cxx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,9 @@ int CTPRunManager::loadRun(const std::string& cfg)
123123
//
124124
mRunsLoaded[runnumber] = activerun;
125125
saveRunConfigToCCDB(&activerun->cfg, timeStamp);
126-
if (mCtpCfgDir != "none")
126+
if (mCtpCfgDir != "none") {
127127
saveCtpCfg(runnumber, timeStamp);
128+
}
128129
return 0;
129130
}
130131
int CTPRunManager::setRunConfigBK(uint32_t runNumber, const std::string& cfg)
@@ -274,6 +275,9 @@ int CTPRunManager::processMessage(std::string& topic, const std::string& message
274275
}
275276
return ret;
276277
}
278+
if(topic.find("rocnts") != std::string::npos) {
279+
return 0;
280+
}
277281
static int nerror = 0;
278282
if (topic.find("sox") != std::string::npos) {
279283
// get config

Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -174,26 +174,29 @@ int ctpCCDBManager::saveCtpCfg(uint32_t runNumber, long timeStart)
174174
return 0;
175175
}
176176
CtpCfg ctpcfg;
177-
ctpcfg.readAndSave(mCtpCfgDir);
178-
using namespace std::chrono_literals;
179-
std::chrono::seconds days3 = 259200s;
180-
std::chrono::seconds min10 = 600s;
181-
long time3days = std::chrono::duration_cast<std::chrono::milliseconds>(days3).count();
182-
long time10min = std::chrono::duration_cast<std::chrono::milliseconds>(min10).count();
183-
long tmin = timeStart - time10min;
184-
long tmax = timeStart + time3days;
185-
o2::ccdb::CcdbApi api;
186-
map<string, string> metadata; // can be empty
187-
metadata["runNumber"] = std::to_string(runNumber);
188-
api.init(mCCDBHost.c_str()); // or http://localhost:8080 for a local installation
189-
// store abitrary user object in strongly typed manner
190-
int ret = api.storeAsTFileAny(&ctpcfg, mCCDBPathCtpCfg, metadata, tmin, tmax);
191-
if (ret == 0) {
192-
LOG(info) << "CtpCfg saved in ccdb:" << mCCDBHost << " tmin:" << tmin << " tmax:" << tmax;
193-
} else {
194-
LOG(error) << "CtpCfg Problem writing to database ret:" << ret;
195-
}
196-
return 0;
177+
int ret;
178+
ctpcfg.readAndSave(mCtpCfgDir, ret);
179+
if(ret == 0) {
180+
using namespace std::chrono_literals;
181+
std::chrono::seconds days3 = 259200s;
182+
std::chrono::seconds min10 = 600s;
183+
long time3days = std::chrono::duration_cast<std::chrono::milliseconds>(days3).count();
184+
long time10min = std::chrono::duration_cast<std::chrono::milliseconds>(min10).count();
185+
long tmin = timeStart - time10min;
186+
long tmax = timeStart + time3days;
187+
o2::ccdb::CcdbApi api;
188+
map<string, string> metadata; // can be empty
189+
metadata["runNumber"] = std::to_string(runNumber);
190+
api.init(mCCDBHost.c_str()); // or http://localhost:8080 for a local installation
191+
// store abitrary user object in strongly typed manner
192+
ret = api.storeAsTFileAny(&ctpcfg, mCCDBPathCtpCfg, metadata, tmin, tmax);
193+
if (ret == 0) {
194+
LOG(info) << "CtpCfg saved in ccdb:" << mCCDBHost << " tmin:" << tmin << " tmax:" << tmax;
195+
} else {
196+
LOG(error) << "CtpCfg Problem writing to database ret:" << ret;
197+
}
198+
}
199+
return ret;
197200
}
198201
CTPConfiguration ctpCCDBManager::getConfigFromCCDB(long timestamp, std::string run, bool& ok)
199202
{

0 commit comments

Comments
 (0)