CGEM BOSS 6.6.5.f
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-39/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 1017 of file Metadata.cxx.

1017 {
1018 unsigned nCol = cols.size();
1019 rdbModel::Table* table = m_rdb->getTable(m_table);
1020
1021
1022 for (unsigned iCol = 0; iCol < nCol; iCol++) {
1023 rdbModel::Column* col = table->getColumnByName(cols[iCol]);
1024 if (!col->nullAllowed()) {
1025 std::cerr << "Column "
1026 << cols[iCol] << " in table " << m_table
1027 << " is not nullable" << std::endl;
1028 return false;
1029 }
1030 }
1031 return true;
1032}
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 1000 of file Metadata.cxx.

1001 {
1002 unsigned nCol = cols.size();
1003 rdbModel::Table* table = m_rdb->getTable(m_table);
1004
1005
1006 for (unsigned iCol = 0; iCol < nCol; iCol++) {
1007 rdbModel::Column* col = table->getColumnByName(cols[iCol]);
1008 if (!col->okValue(vals[iCol])) {
1009 std::cerr << "Value " << vals[iCol] << " not allowed for column "
1010 << cols[iCol] << " in table " << m_table << std::endl;
1011 return false;
1012 }
1013 }
1014 return true;
1015}
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
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-39/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-39/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 517 of file Metadata.cxx.

523 {
524 using namespace rdbModel;
525 eRet ret;
526 char stmt1[400];
527 int run_No =runNo;
528 if(sftver=="default")
529 sftver = getenv("BES_RELEASE");
530 const char* SftVer = sftver.c_str();
531
532 if(calParVer!="default"){
533 const char* calpar = calParVer.c_str();
534 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);
535
536 }
537 if(calParVer=="default"){
538 // 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);
539 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);
540 }
541
542 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
543 if(row_no<1){
544 std::cout<<"ERROR:error searching Dedx calibration Data in the database with: "<<stmt1<<std::endl;
545 return RETMySQLError;
546 }
547 return RETOk;
548}
int runNo
virtual int query(const std::string &dbName, const std::string &sql, DatabaseRecordVector &res)=0

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 653 of file Metadata.cxx.

659 {
660 using namespace rdbModel;
661 eRet ret;
662 char stmt1[200];
663 int run_No =runNo;
664 if(sftver=="default")
665 sftver = getenv("BES_RELEASE");
666 const char* SftVer = sftver.c_str();
667
668 if(calParVer!="default"){
669 const char* calpar = calParVer.c_str();
670 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);
671 }
672 if(calParVer=="default"){
673 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);
674 }
675
676 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
677 if(row_no<1){
678 std::cout<<"ERROR:error searching DedxSim calibration Data in the database with: "<<stmt1<<std::endl;
679 return RETMySQLError;
680 }
681 return RETOk;
682}

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 483 of file Metadata.cxx.

489 {
490 using namespace rdbModel;
491 eRet ret;
492 char stmt1[300];
493 int run_No =runNo;
494 if(sftver=="default")
495 sftver = getenv("BES_RELEASE");
496 const char* SftVer = sftver.c_str();
497
498 if(calParVer!="default"){
499 const char* calpar = calParVer.c_str();
500 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);
501 }
502
503 if(calParVer=="default"){
504 //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);
505 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);
506 }
507
508 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
509 if(row_no<1){
510 std::cout<<"ERROR:error searching EMC calibration Data in the database with: "<<stmt1<<std::endl;
511 return RETMySQLError;
512 }
513 return RETOk;
514}

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 551 of file Metadata.cxx.

557 {
558 using namespace rdbModel;
559 eRet ret;
560 char stmt1[400];
561 int run_No =runNo;
562 if(sftver=="default")
563 sftver = getenv("BES_RELEASE");
564 const char* SftVer = sftver.c_str();
565
566 if(calParVer!="default"){
567 const char* calpar = calParVer.c_str();
568 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);
569 }
570
571 if(calParVer=="default"){
572 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);
573 }
574 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
575 if(row_no<1){
576 std::cout<<"ERROR:error searching EsTime calibration Data in the database with: "<<stmt1<<std::endl;
577 return RETMySQLError;
578 }
579
580 return RETOk;
581}

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 585 of file Metadata.cxx.

591 {
592 using namespace rdbModel;
593 eRet ret;
594 char stmt1[200];
595 int run_No =runNo;
596 if(sftver=="default")
597 sftver = getenv("BES_RELEASE");
598 const char* SftVer = sftver.c_str();
599
600 if(calParVer!="default"){
601 const char* calpar = calParVer.c_str();
602 sprintf(stmt1,"select BarTofPar,EndTofPar,TofConPar,BarTof,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);
603 }
604 if(calParVer=="default"){
605 // 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);
606 sprintf(stmt1,"select BarTofPar,EndTofPar,TofConPar,BarTof,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);
607 }
608
609 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
610 if(row_no<1){
611 std::cout<<"ERROR:error searching EstTOF calibration Data in the database with: "<<stmt1<<std::endl;
612 return RETMySQLError;
613 }
614 return RETOk;
615}

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 686 of file Metadata.cxx.

692 {
693 using namespace rdbModel;
694 eRet ret;
695 char stmt1[200];
696 int run_No =runNo;
697 if(sftver=="default")
698 sftver = getenv("BES_RELEASE");
699 const char* SftVer = sftver.c_str();
700
701 if(calParVer!="default"){
702 const char* calpar = calParVer.c_str();
703 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);
704 }
705 if(calParVer=="default"){
706 // 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);
707 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);
708 }
709
710 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
711 if(row_no<1){
712 std::cout<<"ERROR:error searching MdcAlignment calibration Data in the database with: "<<stmt1<<std::endl;
713 return RETMySQLError;
714 }
715
716 return RETOk;
717}

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 719 of file Metadata.cxx.

725 {
726 using namespace rdbModel;
727 eRet ret;
728 char stmt1[200];
729 int run_No =runNo;
730 if(sftver=="default")
731 sftver = getenv("BES_RELEASE");
732 const char* SftVer = sftver.c_str();
733
734 if(calParVer!="default"){
735 const char* calpar = calParVer.c_str();
736 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);
737 }
738 if(calParVer=="default"){
739 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);
740 }
741
742 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
743 if(row_no<1){
744 std::cout<<"ERROR:error searching MdcDataConst Data in the database with: "<<stmt1<<std::endl;
745 return RETMySQLError;
746 }
747
748 return RETOk;
749}

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 446 of file Metadata.cxx.

452 {
453 using namespace rdbModel;
454 eRet ret;
455 char stmt1[200];
456 int run_No =runNo;
457
458 if(sftver=="default")
459 sftver = getenv("BES_RELEASE");
460 const char* SftVer = sftver.c_str();
461
462
463 if(calParVer!="default"){
464 const char* calpar = calParVer.c_str();
465 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);}
466
467 if(calParVer=="default"){
468 //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);}
469 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);}
470
471 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
472 if(row_no<1){
473 std::cout<<"ERROR:error searching Mdc calibration Data in the database with: "<<stmt1<<std::endl;
474 return RETMySQLError;
475 }
476
477
478 return RETOk;
479}

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 409 of file Metadata.cxx.

415 {
416 using namespace rdbModel;
417 eRet ret;
418 char stmt1[300];
419 int run_No =runNo;
420 //char* SftVer = getenv("BES_RELEASE");
421 if(sftver=="default")
422 sftver = getenv("BES_RELEASE");
423 const char* SftVer = sftver.c_str();
424
425 if(calParVer!="default"){
426 const char* calpar = calParVer.c_str();
427 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);
428 }
429
430 if(calParVer=="default"){
431 // 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);
432 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);
433
434 }
435
436 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
437 if(row_no<1){
438 std::cout<<"ERROR:error searching MUC calibration Data in the database with: "<<stmt1<<std::endl;
439 return RETMySQLError;
440 }
441
442
443 return RETOk;
444 }

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,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,RunFrom,RunTo,max(CalParVer),FileName,SftVer from TofCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d group by CalParVer",SftVer,run_No,run_No);
397 sprintf(stmt1,"select BarTofPar,EndTofPar,TofConPar,BarTof,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);
398 }
399
400 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
401 if(row_no<1){
402 std::cout<<"ERROR:error searching TOF calibration Data in the database with: "<<stmt1<<std::endl;
403 return RETMySQLError;
404 }
405
406 return RETOk;
407 }

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 751 of file Metadata.cxx.

757 {
758 using namespace rdbModel;
759 eRet ret;
760 char stmt1[400];
761 int run_No =runNo;
762 if(sftver=="default")
763 sftver = getenv("BES_RELEASE");
764 const char* SftVer = sftver.c_str();
765
766 if(calParVer!="default"){
767 const char* calpar = calParVer.c_str();
768 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);
769 }
770 if(calParVer=="default"){
771 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);
772 }
773 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
774 if(row_no<1){
775 std::cout<<"ERROR:error searching TofQElec calibration Data in the database with: "<<stmt1<<std::endl;
776 return RETMySQLError;
777 }
778 std::cout<<"metadata ok"<<std::endl;
779 return RETOk;
780}

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 618 of file Metadata.cxx.

624 {
625 using namespace rdbModel;
626 eRet ret;
627 char stmt1[200];
628 int run_No =runNo;
629 if(sftver=="default")
630 sftver = getenv("BES_RELEASE");
631 const char* SftVer = sftver.c_str();
632
633 if(calParVer!="default"){
634 const char* calpar = calParVer.c_str();
635 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);
636 }
637 if(calParVer=="default"){
638 // 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);
639 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);
640 }
641
642
643 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
644 if(row_no<1){
645 std::cout<<"ERROR:error searching TOFSim calibration Data in the database with: "<<stmt1<<std::endl;
646 return RETMySQLError;
647 }
648
649 return RETOk;
650}

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-39/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 866 of file Metadata.cxx.

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