BOSS 7.0.5
BESIII Offline Software System
Loading...
Searching...
No Matches
calibUtil::Metadata Class Reference

#include <Metadata.h>

Public Types

enum  eRet {
  RETOk = 0 , RETBadCnfFile = 1 , RETBadHost = 2 , RETNoConnect = 3 ,
  RETWrongState = 4 , RETBadValue = 5 , RETMySQLError = 6 , RETNoSchemaMatch = 7 ,
  RETOk = 0 , RETBadCnfFile = 1 , RETBadHost = 2 , RETNoConnect = 3 ,
  RETWrongState = 4 , RETBadValue = 5 , RETMySQLError = 6 , RETNoSchemaMatch = 7
}
 
enum  eLevel {
  LEVELProd = 1 , LEVELDev = 2 , LEVELTest = 4 , LEVELSuperseded = 8 ,
  LEVELProd = 1 , LEVELDev = 2 , LEVELTest = 4 , LEVELSuperseded = 8
}
 Used to form bit masks for dbs queries. More...
 
enum  eRet {
  RETOk = 0 , RETBadCnfFile = 1 , RETBadHost = 2 , RETNoConnect = 3 ,
  RETWrongState = 4 , RETBadValue = 5 , RETMySQLError = 6 , RETNoSchemaMatch = 7 ,
  RETOk = 0 , RETBadCnfFile = 1 , RETBadHost = 2 , RETNoConnect = 3 ,
  RETWrongState = 4 , RETBadValue = 5 , RETMySQLError = 6 , RETNoSchemaMatch = 7
}
 
enum  eLevel {
  LEVELProd = 1 , LEVELDev = 2 , LEVELTest = 4 , LEVELSuperseded = 8 ,
  LEVELProd = 1 , LEVELDev = 2 , LEVELTest = 4 , LEVELSuperseded = 8
}
 Used to form bit masks for dbs queries. More...
 

Public Member Functions

 Metadata (const std::string &host="bes3db2.ihep.ac.cn", const std::string &table="*", const std::string &dbName="calib")
 Constructor keeps track of table of interest.
 
 ~Metadata ()
 
eRet findBest (unsigned int *ser, const std::string &calibType, const std::string &sft_ver, const std::string &cal_ver, const std::string &cal_par, const std::string &rec_alg, const std::string &rec_par, const std::string &machine, const std::string &flavor="VANILLA")
 
eRet findSoonAfter (unsigned int *ser, const std::string &calibType, const std::string &sft_ver, const std::string &cal_ver, const std::string &cal_par, const std::string &rec_alg, const std::string &rec_par, const std::string &machine, const std::string &flavor="VANILLA")
 
eRet getInterval (unsigned int serialNo, facilities::Timestamp *&since, facilities::Timestamp *&till)
 Get validity interval for a particular calibration.
 
eRet getReadInfo (unsigned int serialNo, int *runFrm, int *runTo, std::string &dataFmt, std::string &dataIdent)
 
eRet getReadTOFInfo (unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
 
eRet getReadEMCInfo (unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
 
eRet getReadDedxInfo (unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
 
eRet getReadMDCInfo (unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
 
eRet getReadMUCInfo (unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
 
eRet getReadEsTimeInfo (unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
 
eRet getReadEstTofInfo (unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
 
eRet getReadMdcAlignInfo (unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
 
eRet getReadMdcDataConstInfo (unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
 
eRet getReadTofQElecInfo (unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
 
eRet getReadTofSimInfo (unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
 
eRet getReadDedxSimInfo (unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
 
int registerCalib (const std::string &inst, const std::string &flavor, const std::string &calib_type, const std::string &data_ident, const std::string &data_format, unsigned int &runfrm, unsigned int &runto, const std::string &input_desc, const std::string &notes, const std::string &proc_level, const std::string &locale, const std::string &fmt_version="", const std::string &completion="OK")
 
bool connectRead (eRet &err)
 
bool checkValues (const rdbModel::StringVector &cols, const rdbModel::StringVector &vals) const
 
bool checkNulls (const rdbModel::StringVector &cols) const
 
rdbModel::ConnectiongetReadConnection ()
 
rdbModel::RdbgetRdb ()
 
const std::string & getTable ()
 
void disconnectRead ()
 
void disconnectWrite ()
 
 Metadata (const std::string &host="bes3db2.ihep.ac.cn", const std::string &table="*", const std::string &dbName="calib")
 Constructor keeps track of table of interest.
 
 ~Metadata ()
 
eRet findBest (unsigned int *ser, const std::string &calibType, const std::string &sft_ver, const std::string &cal_ver, const std::string &cal_par, const std::string &rec_alg, const std::string &rec_par, const std::string &machine, const std::string &flavor="VANILLA")
 
eRet findSoonAfter (unsigned int *ser, const std::string &calibType, const std::string &sft_ver, const std::string &cal_ver, const std::string &cal_par, const std::string &rec_alg, const std::string &rec_par, const std::string &machine, const std::string &flavor="VANILLA")
 
eRet getInterval (unsigned int serialNo, facilities::Timestamp *&since, facilities::Timestamp *&till)
 Get validity interval for a particular calibration.
 
eRet getReadInfo (unsigned int serialNo, int *runFrm, int *runTo, std::string &dataFmt, std::string &dataIdent)
 
eRet getReadTOFInfo (unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
 
eRet getReadEMCInfo (unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
 
eRet getReadDedxInfo (unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
 
eRet getReadMDCInfo (unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
 
eRet getReadMUCInfo (unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
 
eRet getReadEsTimeInfo (unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
 
eRet getReadEstTofInfo (unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
 
eRet getReadMdcAlignInfo (unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
 
eRet getReadMdcDataConstInfo (unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
 
eRet getReadTofQElecInfo (unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
 
eRet getReadTofSimInfo (unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
 
eRet getReadDedxSimInfo (unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
 
int registerCalib (const std::string &inst, const std::string &flavor, const std::string &calib_type, const std::string &data_ident, const std::string &data_format, unsigned int &runfrm, unsigned int &runto, const std::string &input_desc, const std::string &notes, const std::string &proc_level, const std::string &locale, const std::string &fmt_version="", const std::string &completion="OK")
 
bool connectRead (eRet &err)
 
bool checkValues (const rdbModel::StringVector &cols, const rdbModel::StringVector &vals) const
 
bool checkNulls (const rdbModel::StringVector &cols) const
 
rdbModel::ConnectiongetReadConnection ()
 
rdbModel::RdbgetRdb ()
 
const std::string & getTable ()
 
void disconnectRead ()
 
void disconnectWrite ()
 

Detailed Description

Provide interface between calibration clients and the MySQL database for calibration metadata. Supported operations include writing a new record, looking for the serial number of a "best match" record (findBest), and a method for retrieving the information necessary to read the data set corresponding to a particular metadata record (getReadInfo). Writing a record is done in stages: open the record (openRecord), add certain fields (addValidInterval, addNotes, etc.), and finally to write the full record to the database (insertRecord).

The class contains definitions for several enumerated types, corresponding to possible entries for columns in a metadata record. Within the MySQL database the values are kept as strings. The enumerated types are provided to insulate clients from these details; enumerations are easier to document and to check for validity.

Definition at line 33 of file Calibration/calibUtil/calibUtil-00-00-43/calibUtil/Metadata.h.

Member Enumeration Documentation

◆ eLevel [1/2]

◆ eLevel [2/2]

Used to form bit masks for dbs queries.

Enumerator
LEVELProd 
LEVELDev 
LEVELTest 
LEVELSuperseded 
LEVELProd 
LEVELDev 
LEVELTest 
LEVELSuperseded 

Definition at line 46 of file InstallArea/include/calibUtil/calibUtil/Metadata.h.

46 {
47 LEVELProd = 1,
48 LEVELDev = 2,
49 LEVELTest = 4,
51 };

◆ eRet [1/2]

◆ eRet [2/2]

Enumerator
RETOk 
RETBadCnfFile 
RETBadHost 
RETNoConnect 
RETWrongState 
RETBadValue 
RETMySQLError 
RETNoSchemaMatch 
RETOk 
RETBadCnfFile 
RETBadHost 
RETNoConnect 
RETWrongState 
RETBadValue 
RETMySQLError 
RETNoSchemaMatch 

Definition at line 35 of file InstallArea/include/calibUtil/calibUtil/Metadata.h.

35 {
36 RETOk = 0,
37 RETBadCnfFile = 1,
38 RETBadHost = 2,
39 RETNoConnect = 3,
40 RETWrongState = 4,
41 RETBadValue = 5,
42 RETMySQLError = 6,
44 };

Constructor & Destructor Documentation

◆ Metadata() [1/2]

calibUtil::Metadata::Metadata ( const std::string &  host = "bes3db2.ihep.ac.cn",
const std::string &  table = "*",
const std::string &  dbName = "calib" 
)

Constructor keeps track of table of interest.

Definition at line 39 of file Metadata.cxx.

41 : m_readCxt(0), m_writeCxt(0), // m_row(""), m_rowStatus(0),
42 m_host(host), m_table(table), m_dbName(dbName), m_man(0), m_rdb(0),
43 m_match(false) {
44 if (table.compare("*") == 0) m_table = std::string("$(MYSQL_METATABLE)");
45 if (host.compare("*") == 0) m_host = std::string("$(MYSQL_HOST)");
46
47 int nsub = facilities::Util::expandEnvVar(&m_table);
48 // If this doesn't work, use default
49 if (nsub < 0) m_table = std::string("metadata");
50 StatusCode sc=Gaudi::svcLocator()->service("DatabaseSvc", m_dbsvc, true);
51 if ( !sc.isSuccess() ) {
52 std::cout <<"Metadata ERROR ::Could not retrieve the DataBaseSvc" << std::endl;;
53 exit(1);
54 }
55 }
static int expandEnvVar(std::string *toExpand, const std::string &openDel=std::string("$("), const std::string &closeDel=std::string(")"))

◆ ~Metadata() [1/2]

calibUtil::Metadata::~Metadata ( )

Definition at line 57 of file Metadata.cxx.

57 {
60 if (m_man) delete m_man;
61 }

◆ Metadata() [2/2]

calibUtil::Metadata::Metadata ( const std::string &  host = "bes3db2.ihep.ac.cn",
const std::string &  table = "*",
const std::string &  dbName = "calib" 
)

Constructor keeps track of table of interest.

◆ ~Metadata() [2/2]

calibUtil::Metadata::~Metadata ( )

Member Function Documentation

◆ checkNulls() [1/2]

bool calibUtil::Metadata::checkNulls ( const rdbModel::StringVector cols) const

Definition at line 1016 of file Metadata.cxx.

1016 {
1017 unsigned nCol = cols.size();
1018 rdbModel::Table* table = m_rdb->getTable(m_table);
1019
1020
1021 for (unsigned iCol = 0; iCol < nCol; iCol++) {
1022 rdbModel::Column* col = table->getColumnByName(cols[iCol]);
1023 if (!col->nullAllowed()) {
1024 std::cerr << "Column "
1025 << cols[iCol] << " in table " << m_table
1026 << " is not nullable" << std::endl;
1027 return false;
1028 }
1029 }
1030 return true;
1031}
bool nullAllowed() const
Returns true if column may take on value NULL.
Table * getTable(const std::string &name) const
Definition: Rdb.cxx:16
Column * getColumnByName(const std::string &name) const
Definition: Table.cxx:56

Referenced by registerCalib().

◆ checkNulls() [2/2]

bool calibUtil::Metadata::checkNulls ( const rdbModel::StringVector cols) const

◆ checkValues() [1/2]

bool calibUtil::Metadata::checkValues ( const rdbModel::StringVector cols,
const rdbModel::StringVector vals 
) const

Definition at line 999 of file Metadata.cxx.

1000 {
1001 unsigned nCol = cols.size();
1002 rdbModel::Table* table = m_rdb->getTable(m_table);
1003
1004
1005 for (unsigned iCol = 0; iCol < nCol; iCol++) {
1006 rdbModel::Column* col = table->getColumnByName(cols[iCol]);
1007 if (!col->okValue(vals[iCol])) {
1008 std::cerr << "Value " << vals[iCol] << " not allowed for column "
1009 << cols[iCol] << " in table " << m_table << std::endl;
1010 return false;
1011 }
1012 }
1013 return true;
1014}
bool okValue(const std::string &val, bool set=true) const
Definition: Column.cxx:21

Referenced by registerCalib().

◆ checkValues() [2/2]

bool calibUtil::Metadata::checkValues ( const rdbModel::StringVector cols,
const rdbModel::StringVector vals 
) const

◆ connectRead() [1/2]

bool calibUtil::Metadata::connectRead ( eRet err)

Definition at line 107 of file Metadata.cxx.

107 {
108 if (m_readCxt == 0) {
109 // for now use std::cout, std::cerr
110 m_readCxt = new rdbModel::MysqlConnection();
111 // bool ok = connect(m_readCxt, m_host, std::string("maqm"),
112 // std::string("maqm_offline"), err, m_dbName);
113 bool ok = connect(m_readCxt, m_host, std::string("guest"),
114 std::string("guestpass"), err, m_dbName);
115 if (!ok) {
116 delete m_readCxt;
117 m_readCxt = 0;
118 } /* else { // look for compatible schema
119 std::string schema =
120 std::string("$(RDBMODELROOT)/xml/")+ m_dbName + ".xml";
121 err = compareSchema(m_readCxt, schema);
122 }*/
123 return ok;
124 }
125
126 else return true;
127 }

Referenced by findBest(), findSoonAfter(), and getReadInfo().

◆ connectRead() [2/2]

bool calibUtil::Metadata::connectRead ( eRet err)

◆ disconnectRead() [1/2]

void calibUtil::Metadata::disconnectRead ( )

Definition at line 155 of file Metadata.cxx.

155 {
156 if (m_readCxt) {
157 m_readCxt->close();
158 delete m_readCxt;
159 m_readCxt = 0;
160 }
161 }
virtual bool close()=0

Referenced by ~Metadata().

◆ disconnectRead() [2/2]

void calibUtil::Metadata::disconnectRead ( )

◆ disconnectWrite() [1/2]

void calibUtil::Metadata::disconnectWrite ( )

Definition at line 163 of file Metadata.cxx.

163 {
164 if (m_writeCxt) {
165 m_writeCxt->close();
166 delete m_writeCxt;
167 m_writeCxt = 0;
168 }
169 }

Referenced by ~Metadata().

◆ disconnectWrite() [2/2]

void calibUtil::Metadata::disconnectWrite ( )

◆ findBest() [1/2]

Metadata::eRet calibUtil::Metadata::findBest ( unsigned int *  ser,
const std::string &  calibType,
const std::string &  sft_ver,
const std::string &  cal_ver,
const std::string &  cal_par,
const std::string &  rec_alg,
const std::string &  rec_par,
const std::string &  machine,
const std::string &  flavor = "VANILLA" 
)

Return serial number for calibration which is best match to criteria, using strings for calibType and instrument arguments. This method may be useful for development when a particular instrument or calibration type is not officially supported.

Parameters
serserial number of best match as integer or zero if no matches (output)
calibTypetype of data, must match
timestampmust be within validity interval; closer to center is better
levelMaskacceptable levels ("production" better than "dev" better than "test" better than "superseded")
instrumente.g. LAT, EM, CU,...
flavoroptionally specify non-standard calibration flavor
Returns
status. Should be RETOk.

If there are multiple calibrations which are not distinguished by the above, pick the one most recently written.

Definition at line 243 of file Metadata.cxx.

252 {
253 using namespace rdbModel;
254
255 eRet ret;
256 *ser = 0;
257 if (!m_readCxt) {
258 connectRead(ret);
259 if (ret != RETOk) return ret;
260 }
261
262 // Sort rows by timestamp. Would like most recent first
263 StringVector orderBy;
264
265 std::vector<Assertion::Operator *> conditions;
266 conditions.reserve(8);
267 Assertion::Operator completeOp(OPTYPEequal, "status", "OK",
268 FIELDTYPEold, FIELDTYPElit);
269 // false, true);
270
271 Assertion::Operator calibTypeOp(OPTYPEequal, "calib_type", calibType,
272 FIELDTYPEold, FIELDTYPElit);
273 // false, true);
274 // Assertion::Operator flavorOp(OPTYPEequal, "flavor", flavor,
275 // FIELDTYPEold, FIELDTYPElit);
276 // false, true);
277 Assertion::Operator sftverOp(OPTYPEequal, "SftVer",SftVer,
278 FIELDTYPEold, FIELDTYPElit);
279 Assertion::Operator calverOp(OPTYPEequal, "cal_ver",cal_ver,
280 FIELDTYPEold, FIELDTYPElit);
281 Assertion::Operator calparOp(OPTYPEequal, "cal_par",cal_par,
282 FIELDTYPEold, FIELDTYPElit);
283 Assertion::Operator recalgOp(OPTYPEequal, "rec_alg",rec_alg,
284 FIELDTYPEold, FIELDTYPElit);
285 Assertion::Operator recparOp(OPTYPEequal, "rec_par",rec_par,
286 FIELDTYPEold, FIELDTYPElit);
287 Assertion::Operator machineOp(OPTYPEequal, "machine",machine,
288 FIELDTYPEold, FIELDTYPElit);
289 int run=10005;
290 std::string s_run;
291 facilities::Util::itoa(run,s_run);
292 Assertion::Operator runfrmOp(OPTYPElessOrEqual,"RunFrom",s_run,
293 FIELDTYPEold, FIELDTYPElit);
294
295 Assertion::Operator runtoOp(OPTYPEgreaterOrEqual,"RunTo",s_run,
296 FIELDTYPEold, FIELDTYPElit);
297
298 conditions.push_back(&completeOp);
299 conditions.push_back(&calibTypeOp);
300 // conditions.push_back(&flavorOp);
301 conditions.push_back(&sftverOp);
302 conditions.push_back(&calverOp);
303 conditions.push_back(&calparOp);
304 conditions.push_back(&recalgOp);
305 conditions.push_back(&recparOp);
306 conditions.push_back(&machineOp);
307 conditions.push_back(&runfrmOp);
308 conditions.push_back(&runtoOp);
309 // Finally, set a value for PROC_LEVEL and make the query (ies)
310 return doSelect(conditions, orderBy, ser);
311 }
std::vector< std::string > StringVector
Simple algorithm to test functioning of "the other" TDS.
Definition: CheckMySQL.h:50
char * SftVer
Definition: DQA_TO_DB.cxx:18
bool connectRead(eRet &err)
Definition: Metadata.cxx:107
static const char * itoa(int val, std::string &outStr)

◆ findBest() [2/2]

eRet calibUtil::Metadata::findBest ( unsigned int *  ser,
const std::string &  calibType,
const std::string &  sft_ver,
const std::string &  cal_ver,
const std::string &  cal_par,
const std::string &  rec_alg,
const std::string &  rec_par,
const std::string &  machine,
const std::string &  flavor = "VANILLA" 
)

Return serial number for calibration which is best match to criteria, using strings for calibType and instrument arguments. This method may be useful for development when a particular instrument or calibration type is not officially supported.

Parameters
serserial number of best match as integer or zero if no matches (output)
calibTypetype of data, must match
timestampmust be within validity interval; closer to center is better
levelMaskacceptable levels ("production" better than "dev" better than "test" better than "superseded")
instrumente.g. LAT, EM, CU,...
flavoroptionally specify non-standard calibration flavor
Returns
status. Should be RETOk.

If there are multiple calibrations which are not distinguished by the above, pick the one most recently written.

◆ findSoonAfter() [1/2]

Metadata::eRet calibUtil::Metadata::findSoonAfter ( unsigned int *  ser,
const std::string &  calibType,
const std::string &  sft_ver,
const std::string &  cal_ver,
const std::string &  cal_par,
const std::string &  rec_alg,
const std::string &  rec_par,
const std::string &  machine,
const std::string &  flavor = "VANILLA" 
)

Similar to findBest above, but here caller constrains the update_time of the calibration by specifying an earliest and (optional) latest time for it. The serial number of the calibration meeting all other conditions, and with the earliest update_time, will be returned.

Parameters
serserial number of best match as integer or zero if no matches (output)
calibTypetype of data, must match
update_startptr to time; early bound for update_time
update_endptr to late bound for update_time (may be 0)
levelMaskacceptable levels ("production" better than "dev" better than "test" better than "superseded")
instrumente.g. LAT, EM, CU,...
flavoroptionally specify non-standard calibration flavor
Returns
status. Should be RETOk.

Definition at line 172 of file Metadata.cxx.

180 {
181 using namespace rdbModel;
182
183 eRet ret;
184 *ser = 0;
185 if (!m_readCxt) {
186 connectRead(ret);
187 if (ret != RETOk) return ret;
188 }
189
190 StringVector orderBy;
191
192 std::vector<Assertion::Operator *> conditions;
193 conditions.reserve(8);
194
195 Assertion::Operator completeOp(OPTYPEequal, "status", "OK",
196 FIELDTYPEold, FIELDTYPElit);
197 // false, true);
198 Assertion::Operator calibTypeOp(OPTYPEequal, "calib_type", calibType,
199 FIELDTYPEold, FIELDTYPElit);
200 // false, true);
201 // Assertion::Operator flavorOp(OPTYPEequal, "flavor", flavor,
202 // FIELDTYPEold, FIELDTYPElit);
203 //false, true);
204 Assertion::Operator sftverOp(OPTYPEequal, "SftVer",SftVer,
205 FIELDTYPEold, FIELDTYPElit);
206 Assertion::Operator calverOp(OPTYPEequal, "cal_ver",cal_ver,
207 FIELDTYPEold, FIELDTYPElit);
208 Assertion::Operator calparOp(OPTYPEequal, "cal_par",cal_par,
209 FIELDTYPEold, FIELDTYPElit);
210 Assertion::Operator recalgOp(OPTYPEequal, "rec_alg",rec_alg,
211 FIELDTYPEold, FIELDTYPElit);
212 Assertion::Operator recparOp(OPTYPEequal, "rec_par",rec_par,
213 FIELDTYPEold, FIELDTYPElit);
214 Assertion::Operator machineOp(OPTYPEequal, "machine",machine,
215 FIELDTYPEold, FIELDTYPElit);
216
217 int run=10005;
218 std::string s_run;
219 std::cout<<"run no is::"<<s_run<<std::endl;
220 facilities::Util::itoa(run,s_run);
221 Assertion::Operator runfrmOp(OPTYPElessOrEqual,"RunFrom",s_run,
222 FIELDTYPEold, FIELDTYPElit);
223
224 Assertion::Operator runtoOp(OPTYPEgreaterOrEqual,"RunTo",s_run,
225 FIELDTYPEold, FIELDTYPElit);
226
227 conditions.push_back(&completeOp);
228 conditions.push_back(&calibTypeOp);
229 // conditions.push_back(&flavorOp);
230 conditions.push_back(&sftverOp);
231 conditions.push_back(&calverOp);
232 conditions.push_back(&calparOp);
233 conditions.push_back(&recalgOp);
234 conditions.push_back(&recparOp);
235 conditions.push_back(&machineOp);
236 conditions.push_back(&runfrmOp);
237 conditions.push_back(&runtoOp);
238 ret = doSelect(conditions, orderBy, ser);
239
240 return ret;
241 }

◆ findSoonAfter() [2/2]

eRet calibUtil::Metadata::findSoonAfter ( unsigned int *  ser,
const std::string &  calibType,
const std::string &  sft_ver,
const std::string &  cal_ver,
const std::string &  cal_par,
const std::string &  rec_alg,
const std::string &  rec_par,
const std::string &  machine,
const std::string &  flavor = "VANILLA" 
)

Similar to findBest above, but here caller constrains the update_time of the calibration by specifying an earliest and (optional) latest time for it. The serial number of the calibration meeting all other conditions, and with the earliest update_time, will be returned.

Parameters
serserial number of best match as integer or zero if no matches (output)
calibTypetype of data, must match
update_startptr to time; early bound for update_time
update_endptr to late bound for update_time (may be 0)
levelMaskacceptable levels ("production" better than "dev" better than "test" better than "superseded")
instrumente.g. LAT, EM, CU,...
flavoroptionally specify non-standard calibration flavor
Returns
status. Should be RETOk.

◆ getInterval() [1/2]

eRet calibUtil::Metadata::getInterval ( unsigned int  serialNo,
facilities::Timestamp *&  since,
facilities::Timestamp *&  till 
)

Get validity interval for a particular calibration.

◆ getInterval() [2/2]

eRet calibUtil::Metadata::getInterval ( unsigned int  serialNo,
facilities::Timestamp *&  since,
facilities::Timestamp *&  till 
)

Get validity interval for a particular calibration.

◆ getRdb() [1/2]

rdbModel::Rdb * calibUtil::Metadata::getRdb ( )
inline

Definition at line 285 of file Calibration/calibUtil/calibUtil-00-00-43/calibUtil/Metadata.h.

285{return m_rdb;}

◆ getRdb() [2/2]

rdbModel::Rdb * calibUtil::Metadata::getRdb ( )
inline

Definition at line 285 of file InstallArea/include/calibUtil/calibUtil/Metadata.h.

285{return m_rdb;}

◆ getReadConnection() [1/2]

rdbModel::Connection * calibUtil::Metadata::getReadConnection ( )
inline

Definition at line 282 of file Calibration/calibUtil/calibUtil-00-00-43/calibUtil/Metadata.h.

282{return m_readCxt;}

◆ getReadConnection() [2/2]

rdbModel::Connection * calibUtil::Metadata::getReadConnection ( )
inline

Definition at line 282 of file InstallArea/include/calibUtil/calibUtil/Metadata.h.

282{return m_readCxt;}

◆ getReadDedxInfo() [1/2]

Metadata::eRet calibUtil::Metadata::getReadDedxInfo ( unsigned int  serialNo,
int *  runFrm,
int *  runTo,
std::string &  calParVer,
DatabaseRecordVector res,
int  runNo,
std::string &  sftver 
)

Definition at line 516 of file Metadata.cxx.

522 {
523 using namespace rdbModel;
524 eRet ret;
525 char stmt1[400];
526 int run_No =runNo;
527 if(sftver=="default")
528 sftver = getenv("BES_RELEASE");
529 const char* SftVer = sftver.c_str();
530
531 if(calParVer!="default"){
532 const char* calpar = calParVer.c_str();
533 sprintf(stmt1,"select DriftDist,EntranceAng,MeanGain,GasGain,LayerGain,Resolution,WireGain,ZDep,RunGain,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from DedxCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = %s",SftVer,run_No,run_No,calpar);
534
535 }
536 if(calParVer=="default"){
537 // sprintf(stmt1,"select DriftDist,EntranceAng,MeanGain,GasGain,LayerGain,Resolution,WireGain,ZDep,RunGain,RunFrom,RunTo,max(CalParVer),FileName from DedxCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d group by CalParVer",SftVer,run_No,run_No);
538 sprintf(stmt1,"select DriftDist,EntranceAng,MeanGain,GasGain,LayerGain,Resolution,WireGain,ZDep,RunGain,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from DedxCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);
539 }
540
541 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
542 if(row_no<1){
543 std::cout<<"ERROR:error searching Dedx calibration Data in the database with: "<<stmt1<<std::endl;
544 return RETMySQLError;
545 }
546 return RETOk;
547}
int runNo
Definition: DQA_TO_DB.cxx:12
virtual int query(const std::string &dbName, const std::string &sql, DatabaseRecordVector &res)=0
sprintf(cut,"kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)

Referenced by CalibMySQLCnvSvc::createCalib(), and CalibMySQLCnvSvc::updateCalib().

◆ getReadDedxInfo() [2/2]

eRet calibUtil::Metadata::getReadDedxInfo ( unsigned int  serialNo,
int *  runFrm,
int *  runTo,
std::string &  calParVer,
DatabaseRecordVector res,
int  runNo,
std::string &  sftver 
)

◆ getReadDedxSimInfo() [1/2]

Metadata::eRet calibUtil::Metadata::getReadDedxSimInfo ( unsigned int  serialNo,
int *  runFrm,
int *  runTo,
std::string &  calParVer,
DatabaseRecordVector res,
int  runNo,
std::string &  sftver 
)

Definition at line 652 of file Metadata.cxx.

658 {
659 using namespace rdbModel;
660 eRet ret;
661 char stmt1[200];
662 int run_No =runNo;
663 if(sftver=="default")
664 sftver = getenv("BES_RELEASE");
665 const char* SftVer = sftver.c_str();
666
667 if(calParVer!="default"){
668 const char* calpar = calParVer.c_str();
669 sprintf(stmt1,"select TH1F_Col,bin,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from DedxSim where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = %s",SftVer,run_No,run_No,calpar);
670 }
671 if(calParVer=="default"){
672 sprintf(stmt1,"select TH1F_Col,bin,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from DedxSim where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);
673 }
674
675 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
676 if(row_no<1){
677 std::cout<<"ERROR:error searching DedxSim calibration Data in the database with: "<<stmt1<<std::endl;
678 return RETMySQLError;
679 }
680 return RETOk;
681}

Referenced by CalibMySQLCnvSvc::createCalib(), and CalibMySQLCnvSvc::updateCalib().

◆ getReadDedxSimInfo() [2/2]

eRet calibUtil::Metadata::getReadDedxSimInfo ( unsigned int  serialNo,
int *  runFrm,
int *  runTo,
std::string &  calParVer,
DatabaseRecordVector res,
int  runNo,
std::string &  sftver 
)

◆ getReadEMCInfo() [1/2]

Metadata::eRet calibUtil::Metadata::getReadEMCInfo ( unsigned int  serialNo,
int *  runFrm,
int *  runTo,
std::string &  calParVer,
DatabaseRecordVector res,
int  runNo,
std::string &  sftver 
)

Definition at line 482 of file Metadata.cxx.

488 {
489 using namespace rdbModel;
490 eRet ret;
491 char stmt1[300];
492 int run_No =runNo;
493 if(sftver=="default")
494 sftver = getenv("BES_RELEASE");
495 const char* SftVer = sftver.c_str();
496
497 if(calParVer!="default"){
498 const char* calpar = calParVer.c_str();
499 sprintf(stmt1,"select DigiCalibConst,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from EmcCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = %s",SftVer,run_No,run_No,calpar);
500 }
501
502 if(calParVer=="default"){
503 //sprintf(stmt1,"select DigiCalibConst,RunFrom,RunTo,max(CalParVer),FileName from EmcCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d group by CalParVer",SftVer,run_No,run_No);
504 sprintf(stmt1,"select DigiCalibConst,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from EmcCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);
505 }
506
507 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
508 if(row_no<1){
509 std::cout<<"ERROR:error searching EMC calibration Data in the database with: "<<stmt1<<std::endl;
510 return RETMySQLError;
511 }
512 return RETOk;
513}

Referenced by CalibMySQLCnvSvc::createCalib(), and CalibMySQLCnvSvc::updateCalib().

◆ getReadEMCInfo() [2/2]

eRet calibUtil::Metadata::getReadEMCInfo ( unsigned int  serialNo,
int *  runFrm,
int *  runTo,
std::string &  calParVer,
DatabaseRecordVector res,
int  runNo,
std::string &  sftver 
)

◆ getReadEsTimeInfo() [1/2]

Metadata::eRet calibUtil::Metadata::getReadEsTimeInfo ( unsigned int  serialNo,
int *  runFrm,
int *  runTo,
std::string &  calParVer,
DatabaseRecordVector res,
int  runNo,
std::string &  sftver 
)

Definition at line 550 of file Metadata.cxx.

556 {
557 using namespace rdbModel;
558 eRet ret;
559 char stmt1[400];
560 int run_No =runNo;
561 if(sftver=="default")
562 sftver = getenv("BES_RELEASE");
563 const char* SftVer = sftver.c_str();
564
565 if(calParVer!="default"){
566 const char* calpar = calParVer.c_str();
567 sprintf(stmt1,"select EsTimeH2,EsTimeH9,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from EsTimeCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = %s",SftVer,run_No,run_No,calpar);
568 }
569
570 if(calParVer=="default"){
571 sprintf(stmt1,"select EsTimeH2,EsTimeH9,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from EsTimeCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);
572 }
573 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
574 if(row_no<1){
575 std::cout<<"ERROR:error searching EsTime calibration Data in the database with: "<<stmt1<<std::endl;
576 return RETMySQLError;
577 }
578
579 return RETOk;
580}

Referenced by CalibMySQLCnvSvc::createCalib(), and CalibMySQLCnvSvc::updateCalib().

◆ getReadEsTimeInfo() [2/2]

eRet calibUtil::Metadata::getReadEsTimeInfo ( unsigned int  serialNo,
int *  runFrm,
int *  runTo,
std::string &  calParVer,
DatabaseRecordVector res,
int  runNo,
std::string &  sftver 
)

◆ getReadEstTofInfo() [1/2]

Metadata::eRet calibUtil::Metadata::getReadEstTofInfo ( unsigned int  serialNo,
int *  runFrm,
int *  runTo,
std::string &  calParVer,
DatabaseRecordVector res,
int  runNo,
std::string &  sftver 
)

Definition at line 584 of file Metadata.cxx.

590 {
591 using namespace rdbModel;
592 eRet ret;
593 char stmt1[200];
594 int run_No =runNo;
595 if(sftver=="default")
596 sftver = getenv("BES_RELEASE");
597 const char* SftVer = sftver.c_str();
598
599 if(calParVer!="default"){
600 const char* calpar = calParVer.c_str();
601 sprintf(stmt1,"select BarTofPar,EndTofPar,TofConPar,BarTof,EtfTofPar,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from EstTofCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = %s",SftVer,run_No,run_No,calpar);
602 }
603 if(calParVer=="default"){
604 // sprintf(stmt1,"select BarTofPar,EndTofPar,TofConPar,BarTof,RunFrom,RunTo,max(CalParVer),FileName from EstTofCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d group by CalParVer",SftVer,run_No,run_No);
605 sprintf(stmt1,"select BarTofPar,EndTofPar,TofConPar,BarTof,EtfTofPar,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from EstTofCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);
606 }
607
608 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
609 if(row_no<1){
610 std::cout<<"ERROR:error searching EstTOF calibration Data in the database with: "<<stmt1<<std::endl;
611 return RETMySQLError;
612 }
613 return RETOk;
614}

Referenced by CalibMySQLCnvSvc::createCalib(), and CalibMySQLCnvSvc::updateCalib().

◆ getReadEstTofInfo() [2/2]

eRet calibUtil::Metadata::getReadEstTofInfo ( unsigned int  serialNo,
int *  runFrm,
int *  runTo,
std::string &  calParVer,
DatabaseRecordVector res,
int  runNo,
std::string &  sftver 
)

◆ getReadInfo() [1/2]

Metadata::eRet calibUtil::Metadata::getReadInfo ( unsigned int  serialNo,
int *  runFrm,
int *  runTo,
std::string &  dataFmt,
std::string &  dataIdent 
)

Given a calibration serial number, return information needed for caller to read in the data.

Parameters
serialNo[input]
dataFormat
fmtVersion
filename
Returns
true if serialNo exists in dbs and "filename" has non-null value; else false.

Definition at line 314 of file Metadata.cxx.

318 {
319 using namespace rdbModel;
320 eRet ret;
321 if (!m_readCxt) {
322 connectRead(ret);
323 if (ret != RETOk) {
324 return ret;
325 }
326 }
327 StringVector colNames(4);
328 colNames[0] = "data_fmt";
329 colNames[1] = "data_ident";
330 colNames[2] = "RunFrom";
331 colNames[3] = "RunTo";
332
333 std::string serNoVal;
334 facilities::Util::itoa(serialNo, serNoVal);
335 Assertion::Operator* serOp =
336 new Assertion::Operator(OPTYPEequal, "ser_no", serNoVal,
337 FIELDTYPEold, FIELDTYPElit);
338 //false, true);
339 Assertion whereClause(serOp);
340 StringVector orderBy;
341 orderBy.clear();
342
343 // make the query
344 ResultHandle* results = 0;
345 try {
346
347 results = m_readCxt->select(m_table, colNames, orderBy, &whereClause);
348
349 }
350 catch (RdbException ex) {
351 std::cout << ex.getMsg();
352 return RETMySQLError;
353 }
354
355 if (!results) return RETMySQLError;
356 if (!results->getNRows() ) return RETBadValue;
357
358 std::vector<std::string> fields;
359 std::cout<<"test id \\"<<std::endl;
360 results->getRow(fields);
361 dataFmt = fields[0];
362 filename = fields[1];
363 std::string runfrm,runto;
364 runfrm=fields[2];
365 runto=fields[3];
366 *runFrm=facilities::Util::atoi(runfrm);
367 *runTo=facilities::Util::atoi(runto);
368 delete results;
369 //runFrm=fields[2];
370 //runTo=fields[3];
371 // std::cout<<"runfrm is:"<<runFrm<<"runto is:"<<runTo<<std::endl;
372 if ((dataFmt == "") || (filename == "")) return RETBadValue;
373 return RETOk;
374 }
static int atoi(const std::string &InStr)
converts an std::string to an integer
virtual ResultHandle * select(const std::string &tableName, const StringVector &getCols, const StringVector &orderCols, const Assertion *where=0, int rowLimit=0, int rowOffset=0)=0
virtual bool getRow(std::vector< std::string > &fields, unsigned int i=0, bool clear=true)=0
virtual unsigned int getNRows() const =0
Return number of rows in results.

◆ getReadInfo() [2/2]

eRet calibUtil::Metadata::getReadInfo ( unsigned int  serialNo,
int *  runFrm,
int *  runTo,
std::string &  dataFmt,
std::string &  dataIdent 
)

Given a calibration serial number, return information needed for caller to read in the data.

Parameters
serialNo[input]
dataFormat
fmtVersion
filename
Returns
true if serialNo exists in dbs and "filename" has non-null value; else false.

◆ getReadMdcAlignInfo() [1/2]

Metadata::eRet calibUtil::Metadata::getReadMdcAlignInfo ( unsigned int  serialNo,
int *  runFrm,
int *  runTo,
std::string &  calParVer,
DatabaseRecordVector res,
int  runNo,
std::string &  sftver 
)

Definition at line 685 of file Metadata.cxx.

691 {
692 using namespace rdbModel;
693 eRet ret;
694 char stmt1[200];
695 int run_No =runNo;
696 if(sftver=="default")
697 sftver = getenv("BES_RELEASE");
698 const char* SftVer = sftver.c_str();
699
700 if(calParVer!="default"){
701 const char* calpar = calParVer.c_str();
702 sprintf(stmt1,"select AlignEndPlate,WirePos,WireTension,RunFrom,RunTo,MdcAlignVer,AlignEPFileName,Status,SftVer from MdcAlignment where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and MdcAlignVer = %s",SftVer,run_No,run_No,calpar);
703 }
704 if(calParVer=="default"){
705 // sprintf(stmt1,"select AlignEndPlate,WirePos,WireTension,RunFrom,RunTo,max(MdcAlignVer),AlignEPFileName from MdcAlignment where SftVer = '%s' and RunFrom <= %d and RunTo >= %d group by MdcAlignVer",SftVer,run_No,run_No);
706 sprintf(stmt1,"select AlignEndPlate,WirePos,WireTension,RunFrom,RunTo,MdcAlignVer,AlignEPFileName,Status,SftVer from MdcAlignment where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by MdcAlignVer desc",SftVer,run_No,run_No);
707 }
708
709 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
710 if(row_no<1){
711 std::cout<<"ERROR:error searching MdcAlignment calibration Data in the database with: "<<stmt1<<std::endl;
712 return RETMySQLError;
713 }
714
715 return RETOk;
716}

Referenced by CalibMySQLCnvSvc::createCalib(), and CalibMySQLCnvSvc::updateCalib().

◆ getReadMdcAlignInfo() [2/2]

eRet calibUtil::Metadata::getReadMdcAlignInfo ( unsigned int  serialNo,
int *  runFrm,
int *  runTo,
std::string &  calParVer,
DatabaseRecordVector res,
int  runNo,
std::string &  sftver 
)

◆ getReadMdcDataConstInfo() [1/2]

Metadata::eRet calibUtil::Metadata::getReadMdcDataConstInfo ( unsigned int  serialNo,
int *  runFrm,
int *  runTo,
std::string &  calParVer,
DatabaseRecordVector res,
int  runNo,
std::string &  sftver 
)

Definition at line 718 of file Metadata.cxx.

724 {
725 using namespace rdbModel;
726 eRet ret;
727 char stmt1[200];
728 int run_No =runNo;
729 if(sftver=="default")
730 sftver = getenv("BES_RELEASE");
731 const char* SftVer = sftver.c_str();
732
733 if(calParVer!="default"){
734 const char* calpar = calParVer.c_str();
735 sprintf(stmt1,"select WireEff,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from MdcDataConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = %s",SftVer,run_No,run_No,calpar);
736 }
737 if(calParVer=="default"){
738 sprintf(stmt1,"select WireEff,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from MdcDataConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);
739 }
740
741 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
742 if(row_no<1){
743 std::cout<<"ERROR:error searching MdcDataConst Data in the database with: "<<stmt1<<std::endl;
744 return RETMySQLError;
745 }
746
747 return RETOk;
748}

Referenced by CalibMySQLCnvSvc::createCalib(), and CalibMySQLCnvSvc::updateCalib().

◆ getReadMdcDataConstInfo() [2/2]

eRet calibUtil::Metadata::getReadMdcDataConstInfo ( unsigned int  serialNo,
int *  runFrm,
int *  runTo,
std::string &  calParVer,
DatabaseRecordVector res,
int  runNo,
std::string &  sftver 
)

◆ getReadMDCInfo() [1/2]

Metadata::eRet calibUtil::Metadata::getReadMDCInfo ( unsigned int  serialNo,
int *  runFrm,
int *  runTo,
std::string &  calParVer,
DatabaseRecordVector res,
int  runNo,
std::string &  sftver 
)

Definition at line 445 of file Metadata.cxx.

451 {
452 using namespace rdbModel;
453 eRet ret;
454 char stmt1[200];
455 int run_No =runNo;
456
457 if(sftver=="default")
458 sftver = getenv("BES_RELEASE");
459 const char* SftVer = sftver.c_str();
460
461
462 if(calParVer!="default"){
463 const char* calpar = calParVer.c_str();
464 sprintf(stmt1,"select NewXtTrees,XtTree,QtTree,T0Tree,SdTree,R2tTrees,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from MdcCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = '%s'",SftVer,run_No,run_No,calpar);}
465
466 if(calParVer=="default"){
467 //sprintf(stmt1,"select NewXtTrees,XtTree,QtTree,T0Tree,SdTree,R2tTrees,RunFrom,RunTo,max(CalParVer),FileName from MdcCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d group by CalParVer",SftVer,run_No,run_No);}
468 sprintf(stmt1,"select NewXtTrees,XtTree,QtTree,T0Tree,SdTree,R2tTrees,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from MdcCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);}
469
470 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
471 if(row_no<1){
472 std::cout<<"ERROR:error searching Mdc calibration Data in the database with: "<<stmt1<<std::endl;
473 return RETMySQLError;
474 }
475
476
477 return RETOk;
478}

Referenced by CalibMySQLCnvSvc::createCalib(), and CalibMySQLCnvSvc::updateCalib().

◆ getReadMDCInfo() [2/2]

eRet calibUtil::Metadata::getReadMDCInfo ( unsigned int  serialNo,
int *  runFrm,
int *  runTo,
std::string &  calParVer,
DatabaseRecordVector res,
int  runNo,
std::string &  sftver 
)

◆ getReadMUCInfo() [1/2]

Metadata::eRet calibUtil::Metadata::getReadMUCInfo ( unsigned int  serialNo,
int *  runFrm,
int *  runTo,
std::string &  calParVer,
DatabaseRecordVector res,
int  runNo,
std::string &  sftver 
)

Definition at line 408 of file Metadata.cxx.

414 {
415 using namespace rdbModel;
416 eRet ret;
417 char stmt1[300];
418 int run_No =runNo;
419 //char* SftVer = getenv("BES_RELEASE");
420 if(sftver=="default")
421 sftver = getenv("BES_RELEASE");
422 const char* SftVer = sftver.c_str();
423
424 if(calParVer!="default"){
425 const char* calpar = calParVer.c_str();
426 sprintf(stmt1,"select LayTree,BoxTree,StrTree,ResTree,ClsTree,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from MucCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);
427 }
428
429 if(calParVer=="default"){
430 // sprintf(stmt1,"select SftVer,LayTree,BoxTree,StrTree,ResTree,ClsTree,RunFrom,RunTo,max(CalParVer),FileName from MucCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d group by CalParVer",SftVer,run_No,run_No);
431 sprintf(stmt1,"select LayTree,BoxTree,StrTree,ResTree,ClsTree,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from MucCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);
432
433 }
434
435 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
436 if(row_no<1){
437 std::cout<<"ERROR:error searching MUC calibration Data in the database with: "<<stmt1<<std::endl;
438 return RETMySQLError;
439 }
440
441
442 return RETOk;
443 }

Referenced by CalibMySQLCnvSvc::createCalib(), and CalibMySQLCnvSvc::updateCalib().

◆ getReadMUCInfo() [2/2]

eRet calibUtil::Metadata::getReadMUCInfo ( unsigned int  serialNo,
int *  runFrm,
int *  runTo,
std::string &  calParVer,
DatabaseRecordVector res,
int  runNo,
std::string &  sftver 
)

◆ getReadTOFInfo() [1/2]

Metadata::eRet calibUtil::Metadata::getReadTOFInfo ( unsigned int  serialNo,
int *  runFrm,
int *  runTo,
std::string &  calParVer,
DatabaseRecordVector res,
int  runNo,
std::string &  sftver 
)

Definition at line 376 of file Metadata.cxx.

382 {
383 using namespace rdbModel;
384 eRet ret;
385 char stmt1[300];
386 int run_No =runNo;
387 if(sftver=="default")
388 sftver = getenv("BES_RELEASE");
389 const char* SftVer = sftver.c_str();
390
391 if(calParVer!="default"){
392 const char* calpar = calParVer.c_str();
393 sprintf(stmt1,"select BarTofPar,EndTofPar,TofConPar,BarTof,EtfTofPar,EtfTofBunch,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from TofCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = %s",SftVer,run_No,run_No,calpar);
394 }
395 if(calParVer=="default"){
396 sprintf(stmt1,"select BarTofPar,EndTofPar,TofConPar,BarTof,EtfTofPar,EtfTofBunch,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from TofCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);
397 }
398
399 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
400 if(row_no<1){
401 std::cout<<"ERROR:error searching TOF calibration Data in the database with: "<<stmt1<<std::endl;
402 return RETMySQLError;
403 }
404
405 return RETOk;
406 }

Referenced by CalibMySQLCnvSvc::createCalib(), and CalibMySQLCnvSvc::updateCalib().

◆ getReadTOFInfo() [2/2]

eRet calibUtil::Metadata::getReadTOFInfo ( unsigned int  serialNo,
int *  runFrm,
int *  runTo,
std::string &  calParVer,
DatabaseRecordVector res,
int  runNo,
std::string &  sftver 
)

◆ getReadTofQElecInfo() [1/2]

Metadata::eRet calibUtil::Metadata::getReadTofQElecInfo ( unsigned int  serialNo,
int *  runFrm,
int *  runTo,
std::string &  calParVer,
DatabaseRecordVector res,
int  runNo,
std::string &  sftver 
)

Definition at line 750 of file Metadata.cxx.

756 {
757 using namespace rdbModel;
758 eRet ret;
759 char stmt1[400];
760 int run_No =runNo;
761 if(sftver=="default")
762 sftver = getenv("BES_RELEASE");
763 const char* SftVer = sftver.c_str();
764
765 if(calParVer!="default"){
766 const char* calpar = calParVer.c_str();
767 sprintf(stmt1,"select BarBoardNum,EndBoardNum,QELecBarParEast,QELecBarParWest,QELecEndPar,SimQELecBarParEast,SimQELecBarParWest,SimQELecEndPar,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from TofQELec where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = %s",SftVer,run_No,run_No,calpar);
768 }
769 if(calParVer=="default"){
770 sprintf(stmt1,"select BarBoardNum,EndBoardNum,QELecBarParEast,QELecBarParWest,QELecEndPar,SimQELecBarParEast,SimQELecBarParWest,SimQELecEndPar,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from TofQELec where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);
771 }
772 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
773 if(row_no<1){
774 std::cout<<"ERROR:error searching TofQElec calibration Data in the database with: "<<stmt1<<std::endl;
775 return RETMySQLError;
776 }
777 std::cout<<"metadata ok"<<std::endl;
778 return RETOk;
779}

Referenced by CalibMySQLCnvSvc::createCalib(), and CalibMySQLCnvSvc::updateCalib().

◆ getReadTofQElecInfo() [2/2]

eRet calibUtil::Metadata::getReadTofQElecInfo ( unsigned int  serialNo,
int *  runFrm,
int *  runTo,
std::string &  calParVer,
DatabaseRecordVector res,
int  runNo,
std::string &  sftver 
)

◆ getReadTofSimInfo() [1/2]

Metadata::eRet calibUtil::Metadata::getReadTofSimInfo ( unsigned int  serialNo,
int *  runFrm,
int *  runTo,
std::string &  calParVer,
DatabaseRecordVector res,
int  runNo,
std::string &  sftver 
)

Definition at line 617 of file Metadata.cxx.

623 {
624 using namespace rdbModel;
625 eRet ret;
626 char stmt1[200];
627 int run_No =runNo;
628 if(sftver=="default")
629 sftver = getenv("BES_RELEASE");
630 const char* SftVer = sftver.c_str();
631
632 if(calParVer!="default"){
633 const char* calpar = calParVer.c_str();
634 sprintf(stmt1,"select BTofSim,ETofSim,SimConstants,RunFrom,RunTo,TofSimParVer,FileName,Status,SftVer from TofSimSvc where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and TofSimParVer = %s",SftVer,run_No,run_No,calpar);
635 }
636 if(calParVer=="default"){
637 // sprintf(stmt1,"select BTofSim,ETofSim,SimConstants,RunFrom,RunTo,max(TofSimParVer),FileName from TofSimSvc where SftVer = '%s' and RunFrom <= %d and RunTo >= %d group by TofSimParVer",SftVer,run_No,run_No);
638 sprintf(stmt1,"select BTofSim,ETofSim,SimConstants,RunFrom,RunTo,TofSimParVer,FileName,Status,SftVer from TofSimSvc where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by TofSimParVer desc",SftVer,run_No,run_No);
639 }
640
641
642 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
643 if(row_no<1){
644 std::cout<<"ERROR:error searching TOFSim calibration Data in the database with: "<<stmt1<<std::endl;
645 return RETMySQLError;
646 }
647
648 return RETOk;
649}

Referenced by CalibMySQLCnvSvc::createCalib(), and CalibMySQLCnvSvc::updateCalib().

◆ getReadTofSimInfo() [2/2]

eRet calibUtil::Metadata::getReadTofSimInfo ( unsigned int  serialNo,
int *  runFrm,
int *  runTo,
std::string &  calParVer,
DatabaseRecordVector res,
int  runNo,
std::string &  sftver 
)

◆ getTable() [1/2]

const std::string & calibUtil::Metadata::getTable ( )
inline

Definition at line 286 of file Calibration/calibUtil/calibUtil-00-00-43/calibUtil/Metadata.h.

286{return m_table;}

◆ getTable() [2/2]

const std::string & calibUtil::Metadata::getTable ( )
inline

Definition at line 286 of file InstallArea/include/calibUtil/calibUtil/Metadata.h.

286{return m_table;}

◆ registerCalib() [1/2]

int calibUtil::Metadata::registerCalib ( const std::string &  inst,
const std::string &  flavor,
const std::string &  calib_type,
const std::string &  data_ident,
const std::string &  data_format,
unsigned int &  runfrm,
unsigned int &  runto,
const std::string &  input_desc,
const std::string &  notes,
const std::string &  proc_level,
const std::string &  locale,
const std::string &  fmt_version = "",
const std::string &  completion = "OK" 
)

Definition at line 865 of file Metadata.cxx.

878{
879
880 using namespace rdbModel;
881
882 eRet ret;
883
884 if (!m_writeCxt) {
885 connectWrite(ret);
886 if (ret != RETOk) return 0; // we or connectWrite should throw exception
887 }
888 StringVector cols;
889 StringVector vals;
890 StringVector nullCols;
891
892 cols.reserve(24);
893 vals.reserve(24);
894 nullCols.reserve(16);
895
896 if (inst.size() * calib_type.size() * flavor.size() * data_fmt.size()
897 * data_ident.size() * proc_level.size() * completion.size()
898 * locale.size() == 0) { // something is null that shouldn't be
899 return 0; // should perhaps throw exception
900 }
901 cols.push_back("calib_type"); vals.push_back(calib_type);
902 // cols.push_back("flavor"); vals.push_back(flavor);
903 cols.push_back("data_fmt"); vals.push_back(data_fmt);
904 cols.push_back("data_ident"); vals.push_back(data_ident);
905 cols.push_back("status"); vals.push_back(completion);
906 std::string s_runfrm,s_runto;
907 facilities::Util::itoa(runfrm,s_runfrm);
908 facilities::Util::itoa(runto,s_runto);
909 cols.push_back("RunFrom"); vals.push_back(s_runfrm);
910 cols.push_back("RunTo"); vals.push_back(s_runto);
911
912 // These, however, may be null
913 if (input_desc.size() > 0 ) {
914 cols.push_back("input_desc"); vals.push_back(input_desc);
915 } else nullCols.push_back("input_desc");
916
917 if (notes.size() > 0 ) {
918 cols.push_back("notes"); vals.push_back(notes);
919 } else nullCols.push_back("notes");
920
921 if (fmt_version.size() > 0 )
922 {
923 cols.push_back("fmt_version");
924 vals.push_back(fmt_version);
925 }
926
927 // The service -- that's us -- is responsible for creator, uid, enter_time
928 cols.push_back("creator"); vals.push_back("Metadata::registerCalib");
929 std::string uid;
930 fetchUser(uid);
931 cols.push_back("uid"); vals.push_back(uid);
932 facilities::Timestamp curTime;
933 cols.push_back("enter_time");vals.push_back(curTime.getString());
934 // update_time is set automatically by MySQL, but MySQL uses
935 // local timezone rather than gmt, so we have set it explicitly
936 cols.push_back("update_time");vals.push_back(curTime.getString());
937
938
939 if (m_rdb) {
940 bool ok = checkValues(cols, vals);
941 if (ok) checkNulls(nullCols);
942 if (!ok) return 0;
943 }
944
945 // ser_no gets set automatically by MySQL
946 int ser_no;
947 if (!(m_writeCxt->insertRow(m_table, cols, vals, &ser_no, &nullCols)) ) {
948 return 0;
949 } else {
950 adjustVend(ser_no);
951 return ser_no;
952 }
953}
bool checkValues(const rdbModel::StringVector &cols, const rdbModel::StringVector &vals) const
Definition: Metadata.cxx:999
bool checkNulls(const rdbModel::StringVector &cols) const
Definition: Metadata.cxx:1016
std::string getString() const
Return string representation of time, not including nanoseconds;.
Definition: Timestamp.cxx:92
virtual bool insertRow(const std::string &tableName, const StringVector &colNames, const StringVector &values, int *auto_value=0, const StringVector *nullCols=0)=0

◆ registerCalib() [2/2]

int calibUtil::Metadata::registerCalib ( const std::string &  inst,
const std::string &  flavor,
const std::string &  calib_type,
const std::string &  data_ident,
const std::string &  data_format,
unsigned int &  runfrm,
unsigned int &  runto,
const std::string &  input_desc,
const std::string &  notes,
const std::string &  proc_level,
const std::string &  locale,
const std::string &  fmt_version = "",
const std::string &  completion = "OK" 
)

The documentation for this class was generated from the following files: