21#include <fairlogger/Logger.h>
31 LOG(info) <<
"Scalers not written to CCDB none";
35 using namespace std::chrono_literals;
36 std::chrono::seconds days3 = 259200s;
37 std::chrono::seconds min10 = 600s;
38 long time3days = std::chrono::duration_cast<std::chrono::milliseconds>(days3).count();
39 long time10min = std::chrono::duration_cast<std::chrono::milliseconds>(min10).count();
40 long tmin = timeStart - time10min;
41 long tmax = timeStop + time3days;
43 map<string, string> metadata;
49 LOG(info) <<
"CTP scalers saved in ccdb:" <<
mCCDBHost <<
" run:" << scalers.
getRunNumber() <<
" tmin:" << tmin <<
" tmax:" << tmax;
51 LOG(fatal) <<
"Problem writing to database ret:" << ret;
59 LOG(info) <<
"Scalers not written to QCDB none";
63 using namespace std::chrono_literals;
64 std::chrono::seconds days3 = 259200s;
65 std::chrono::seconds min10 = 600s;
66 long time3days = std::chrono::duration_cast<std::chrono::milliseconds>(days3).count();
67 long time10min = std::chrono::duration_cast<std::chrono::milliseconds>(min10).count();
68 long tmin = timeStart - time10min;
69 long tmax = timeStop + time3days;
71 map<string, string> metadata;
77 LOG(info) <<
"CTP scalers saved in qcdb:" <<
mQCDBHost <<
" run:" << scalers.
getRunNumber() <<
" tmin:" << tmin <<
" tmax:" << tmax;
79 LOG(fatal) <<
"CTP scalers Problem writing to database qcdb ret:" << ret;
87 LOG(info) <<
"CTP config not written to CCDB none";
90 using namespace std::chrono_literals;
91 std::chrono::seconds days3 = 259200s;
92 std::chrono::seconds min10 = 600s;
93 long time3days = std::chrono::duration_cast<std::chrono::milliseconds>(days3).count();
94 long time10min = std::chrono::duration_cast<std::chrono::milliseconds>(min10).count();
95 long tmin = timeStart - time10min;
96 long tmax = timeStart + time3days;
98 map<string, string> metadata;
104 LOG(info) <<
"CTP config saved in ccdb:" <<
mCCDBHost <<
" run:" << cfg->
getRunNumber() <<
" tmin:" << tmin <<
" tmax:" << tmax;
106 LOG(fatal) <<
"CTPConfig: Problem writing to database ret:" << ret;
114 LOG(info) <<
"SOX Orbit not written to CCDB none";
117 std::vector<int64_t> vect;
118 if (timestamp == 0) {
119 auto now = std::chrono::system_clock::now();
120 timestamp = std::chrono::duration_cast<std::chrono::microseconds>(now.time_since_epoch()).count();
122 vect.push_back(timestamp);
123 vect.push_back((uint64_t)runNumber);
124 vect.push_back((uint64_t)soxOrbit);
125 long tmin = timestamp;
126 long tmax = tmin + 381928219;
128 map<string, string> metadata;
135 LOG(info) <<
"SOX orbit saved in ccdb:" <<
mCCDBHost <<
" run:" << runNumber <<
" tmin:" << tmin <<
" tmax:" << tmax;
137 LOG(fatal) <<
"SOX orbit Problem writing to database ret:" << ret;
145 LOG(info) <<
"Orbit Reset not written to CCDB none";
148 std::vector<int64_t> vect;
149 if (timeStamp == 0) {
150 auto now = std::chrono::system_clock::now();
151 timeStamp = std::chrono::duration_cast<std::chrono::microseconds>(now.time_since_epoch()).count();
153 vect.push_back(timeStamp);
154 long tmin = timeStamp;
155 long tmax = tmin + 381928219;
157 map<string, string> metadata;
163 LOG(info) <<
"Orbit reset saved in ccdb:" <<
mCCDBHost <<
" tmin:" << tmin <<
" tmax:" << tmax;
165 LOG(fatal) <<
"Orbit reset Problem writing to database ret:" << ret;
173 map<string, string> metadata;
174 metadata[
"runNumber"] = run;
176 if (ctpconfigdb ==
nullptr) {
177 LOG(info) <<
"CTP config not in database, timestamp:" << timestamp;
181 LOG(info) <<
"CTP config found. Run:" << run;
191 LOG(error) <<
"CTP config not in CCDB";
200 map<string, string> metadata;
201 metadata[
"runNumber"] = run;
203 if (ctpscalers ==
nullptr) {
204 LOG(info) <<
"CTPRunScalers not in database, timestamp:" << timestamp;
static BasicCCDBManager & instance()
int storeAsTFileAny(const T *obj, std::string const &path, std::map< std::string, std::string > const &metadata, long startValidityTimestamp=-1, long endValidityTimestamp=-1, std::vector< char >::size_type maxSize=0) const
void init(std::string const &hosts)
const std::string mCCDBPathOrbitReset
static std::string mCCDBHost
Database constants.
const std::string mQCDBPathCTPScalers
int saveRunScalersToQCDB(CTPRunScalers &scalers, long timeStart, long timeStop)
static std::string mQCDBHost
int saveSoxOrbit(uint32_t runNumber, uint32_t soxOrbit, long timeStart)
CTPRunScalers getScalersFromCCDB(long timestamp, std::string, bool &ok)
int saveRunScalersToCCDB(CTPRunScalers &scalers, long timeStart, long timeStop)
int saveRunConfigToCCDB(CTPConfiguration *cfg, long timeStart)
static CTPConfiguration getConfigFromCCDB(long timestamp, std::string run, bool &ok)
const std::string mCCDBPathCTPScalers
int saveOrbitReset(long timeStamp)
const std::string mCCDBPathSoxOrbit
const std::string CCDBPathCTPConfig
Database constants.
std::string to_string(gsl::span< T, Size > span)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"