BOSS 7.1.0
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
}
 
enum  eLevel { 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 getReadInjSigIntervalInfo (unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
 
eRet getReadInjSigTimeInfo (unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
 
eRet getReadOffEvtFilterInfo (unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
 
eRet getReadCorrectedETSInfo (unsigned int serialNo, int runNo, int FirstEvent, std::string &Version, DatabaseRecordVector &res)
 
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 Metadata.h.

Member Enumeration Documentation

◆ eLevel

Used to form bit masks for dbs queries.

Enumerator
LEVELProd 
LEVELDev 
LEVELTest 
LEVELSuperseded 

Definition at line 46 of file Metadata.h.

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

◆ eRet

Enumerator
RETOk 
RETBadCnfFile 
RETBadHost 
RETNoConnect 
RETWrongState 
RETBadValue 
RETMySQLError 
RETNoSchemaMatch 

Definition at line 35 of file Metadata.h.

Constructor & Destructor Documentation

◆ Metadata()

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()

calibUtil::Metadata::~Metadata ( )

Definition at line 57 of file Metadata.cxx.

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

Member Function Documentation

◆ checkNulls()

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

Definition at line 1200 of file Metadata.cxx.

1200 {
1201 unsigned nCol = cols.size();
1202 rdbModel::Table* table = m_rdb->getTable(m_table);
1203
1204
1205 for (unsigned iCol = 0; iCol < nCol; iCol++) {
1206 rdbModel::Column* col = table->getColumnByName(cols[iCol]);
1207 if (!col->nullAllowed()) {
1208 std::cerr << "Column "
1209 << cols[iCol] << " in table " << m_table
1210 << " is not nullable" << std::endl;
1211 return false;
1212 }
1213 }
1214 return true;
1215}
bool nullAllowed() const
Returns true if column may take on value NULL.
Definition: Column.h:80
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().

◆ checkValues()

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

Definition at line 1183 of file Metadata.cxx.

1184 {
1185 unsigned nCol = cols.size();
1186 rdbModel::Table* table = m_rdb->getTable(m_table);
1187
1188
1189 for (unsigned iCol = 0; iCol < nCol; iCol++) {
1190 rdbModel::Column* col = table->getColumnByName(cols[iCol]);
1191 if (!col->okValue(vals[iCol])) {
1192 std::cerr << "Value " << vals[iCol] << " not allowed for column "
1193 << cols[iCol] << " in table " << m_table << std::endl;
1194 return false;
1195 }
1196 }
1197 return true;
1198}
bool okValue(const std::string &val, bool set=true) const
Definition: Column.cxx:21

Referenced by registerCalib().

◆ connectRead()

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().

◆ disconnectRead()

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().

◆ disconnectWrite()

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().

◆ findBest()

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)

◆ findSoonAfter()

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 }

◆ getInterval()

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

Get validity interval for a particular calibration.

◆ getRdb()

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

Definition at line 315 of file Metadata.h.

315{return m_rdb;}

◆ getReadConnection()

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

Definition at line 312 of file Metadata.h.

312{return m_readCxt;}

◆ getReadCorrectedETSInfo()

Metadata::eRet calibUtil::Metadata::getReadCorrectedETSInfo ( unsigned int  serialNo,
int  runNo,
int  FirstEvent,
std::string &  Version,
DatabaseRecordVector res 
)

Definition at line 483 of file Metadata.cxx.

488 {
489 using namespace rdbModel;
490 eRet ret;
491 char sql[200];
492 const char* parVer = Version.c_str();
493 sprintf(sql,"select Run,FinalETS,FileName,FilePath from CorrectedETS where Run= %d and FirstEvent = %d and Version = %d",run,FirstEvent,1);
494
495 int row_no = m_dbsvc->query("offlinedb", sql, res);
496 string FileName;
497 FileName=(*res[0])["FileName"];
498 std::cout<<"FileName is::::"<<FileName<<std::endl;
499 if(row_no<1){
500 std::cout<<"ERROR:error searching CorrectedETS calibration Data in the database with: "<<sql<<std::endl;
501 return RETMySQLError;
502 }
503
504 return RETOk;
505 }
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)
virtual int query(const std::string &dbName, const std::string &sql, DatabaseRecordVector &res)=0

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

◆ getReadDedxInfo()

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

669 {
670 using namespace rdbModel;
671 eRet ret;
672 char stmt1[400];
673 int run_No =runNo;
674 if(sftver=="default")
675 sftver = getenv("BES_RELEASE");
676 const char* SftVer = sftver.c_str();
677
678 if(calParVer!="default"){
679 const char* calpar = calParVer.c_str();
680 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);
681
682 }
683 if(calParVer=="default"){
684 // 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);
685 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);
686 }
687
688 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
689 if(row_no<1){
690 std::cout<<"ERROR:error searching Dedx calibration Data in the database with: "<<stmt1<<std::endl;
691 return RETMySQLError;
692 }
693 int RunFrom,RunTo;
694 DatabaseRecord& records = *res[0];
695 sscanf(records["RunFrom"], "%d", &RunFrom);
696 sscanf(records["RunTo"], "%d", &RunTo);
697 cout << "@table Dedx: RunFrom is:" << RunFrom << " RunTo is:" << RunTo << endl;
698 return RETOk;
699}
int runNo
Definition: DQA_TO_DB.cxx:12

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

◆ getReadDedxSimInfo()

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

823 {
824 using namespace rdbModel;
825 eRet ret;
826 char stmt1[200];
827 int run_No =runNo;
828 if(sftver=="default")
829 sftver = getenv("BES_RELEASE");
830 const char* SftVer = sftver.c_str();
831
832 if(calParVer!="default"){
833 const char* calpar = calParVer.c_str();
834 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);
835 }
836 if(calParVer=="default"){
837 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);
838 }
839
840 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
841 if(row_no<1){
842 std::cout<<"ERROR:error searching DedxSim calibration Data in the database with: "<<stmt1<<std::endl;
843 return RETMySQLError;
844 }
845 int RunFrom,RunTo;
846 DatabaseRecord& records = *res[0];
847 sscanf(records["RunFrom"], "%d", &RunFrom);
848 sscanf(records["RunTo"], "%d", &RunTo);
849 cout << "@table DedxSim: RunFrom is:" << RunFrom << " RunTo is:" << RunTo << endl;
850 return RETOk;
851}

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

◆ getReadEMCInfo()

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

630 {
631 using namespace rdbModel;
632 eRet ret;
633 char stmt1[300];
634 int run_No =runNo;
635 if(sftver=="default")
636 sftver = getenv("BES_RELEASE");
637 const char* SftVer = sftver.c_str();
638
639 if(calParVer!="default"){
640 const char* calpar = calParVer.c_str();
641 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);
642 }
643
644 if(calParVer=="default"){
645 //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);
646 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);
647 }
648
649 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
650 if(row_no<1){
651 std::cout<<"ERROR:error searching EMC calibration Data in the database with: "<<stmt1<<std::endl;
652 return RETMySQLError;
653 }
654 int RunFrom,RunTo;
655 DatabaseRecord& records = *res[0];
656 sscanf(records["RunFrom"], "%d", &RunFrom);
657 sscanf(records["RunTo"], "%d", &RunTo);
658 cout << "@table Emc: RunFrom is:" << RunFrom << " RunTo is:" << RunTo << endl;
659 return RETOk;
660}

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

◆ getReadEsTimeInfo()

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

708 {
709 using namespace rdbModel;
710 eRet ret;
711 char stmt1[400];
712 int run_No =runNo;
713 if(sftver=="default")
714 sftver = getenv("BES_RELEASE");
715 const char* SftVer = sftver.c_str();
716
717 if(calParVer!="default"){
718 const char* calpar = calParVer.c_str();
719 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);
720 }
721
722 if(calParVer=="default"){
723 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);
724 }
725 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
726 if(row_no<1){
727 std::cout<<"ERROR:error searching EsTime calibration Data in the database with: "<<stmt1<<std::endl;
728 return RETMySQLError;
729 }
730 int RunFrom,RunTo;
731 DatabaseRecord& records = *res[0];
732 sscanf(records["RunFrom"], "%d", &RunFrom);
733 sscanf(records["RunTo"], "%d", &RunTo);
734 cout << "@table EsTime: RunFrom is:" << RunFrom << " RunTo is:" << RunTo << endl;
735 return RETOk;
736}

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

◆ getReadEstTofInfo()

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

746 {
747 using namespace rdbModel;
748 eRet ret;
749 char stmt1[200];
750 int run_No =runNo;
751 if(sftver=="default")
752 sftver = getenv("BES_RELEASE");
753 const char* SftVer = sftver.c_str();
754
755 if(calParVer!="default"){
756 const char* calpar = calParVer.c_str();
757 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);
758 }
759 if(calParVer=="default"){
760 // 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);
761 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);
762 }
763
764 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
765 if(row_no<1){
766 std::cout<<"ERROR:error searching EstTOF calibration Data in the database with: "<<stmt1<<std::endl;
767 return RETMySQLError;
768 }
769 int RunFrom,RunTo;
770 DatabaseRecord& records = *res[0];
771 sscanf(records["RunFrom"], "%d", &RunFrom);
772 sscanf(records["RunTo"], "%d", &RunTo);
773 cout << "@table EstTof: RunFrom is:" << RunFrom << " RunTo is:" << RunTo << endl;
774 return RETOk;
775}

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

◆ getReadInfo()

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 std::string getMsg()
Definition: RdbException.h:14
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.

◆ getReadInjSigIntervalInfo()

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

Definition at line 377 of file Metadata.cxx.

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

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

◆ getReadInjSigTimeInfo()

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

Definition at line 412 of file Metadata.cxx.

418 {
419 using namespace rdbModel;
420 eRet ret;
421 char stmt1[200];
422 int run_No =runNo;
423
424 if(sftver=="default")
425 sftver = getenv("BES_RELEASE");
426 const char* SftVer = sftver.c_str();
427 cout<<"getReadInjSigTimeInfo start:::::"<<endl;
428 if(calParVer!="default"){
429 const char* calpar = calParVer.c_str();
430 sprintf(stmt1,"select ist,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from InjSigTime where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = '%s'",SftVer,run_No,run_No,calpar);}
431
432 if(calParVer=="default"){
433 sprintf(stmt1,"select ist,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from InjSigTime where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);}
434 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
435 if(row_no<1){
436 std::cout<<"ERROR:error searching InjSigTime calibration Data in the database with: "<<stmt1<<std::endl; return RETMySQLError;
437 }
438 int RunFrom,RunTo;
439 DatabaseRecord& records = *res[0];
440 sscanf(records["RunFrom"], "%d", &RunFrom);
441 sscanf(records["RunTo"], "%d", &RunTo);
442 cout << "@table InjSigTimeInfo: RunFrom is:" << RunFrom << " RunTo is:" << RunTo << endl;
443 return RETOk;
444
445 }

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

◆ getReadMdcAlignInfo()

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

861 {
862 using namespace rdbModel;
863 eRet ret;
864 char stmt1[200];
865 int run_No =runNo;
866 if(sftver=="default")
867 sftver = getenv("BES_RELEASE");
868 const char* SftVer = sftver.c_str();
869
870 if(calParVer!="default"){
871 const char* calpar = calParVer.c_str();
872 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);
873 }
874 if(calParVer=="default"){
875 // 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);
876 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);
877 }
878
879 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
880 if(row_no<1){
881 std::cout<<"ERROR:error searching MdcAlignment calibration Data in the database with: "<<stmt1<<std::endl;
882 return RETMySQLError;
883 }
884 int RunFrom,RunTo;
885 DatabaseRecord& records = *res[0];
886 sscanf(records["RunFrom"], "%d", &RunFrom);
887 sscanf(records["RunTo"], "%d", &RunTo);
888 cout << "@table MdcAligment: RunFrom is:" << RunFrom << " RunTo is:" << RunTo << endl;
889 return RETOk;
890}

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

◆ getReadMdcDataConstInfo()

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

898 {
899 using namespace rdbModel;
900 eRet ret;
901 char stmt1[200];
902 int run_No =runNo;
903 if(sftver=="default")
904 sftver = getenv("BES_RELEASE");
905 const char* SftVer = sftver.c_str();
906
907 if(calParVer!="default"){
908 const char* calpar = calParVer.c_str();
909 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);
910 }
911 if(calParVer=="default"){
912 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);
913 }
914
915 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
916 if(row_no<1){
917 std::cout<<"ERROR:error searching MdcDataConst Data in the database with: "<<stmt1<<std::endl;
918 return RETMySQLError;
919 }
920 int RunFrom,RunTo;
921 DatabaseRecord& records = *res[0];
922 sscanf(records["RunFrom"], "%d", &RunFrom);
923 sscanf(records["RunTo"], "%d", &RunTo);
924 cout << "@table MdcData: RunFrom is:" << RunFrom << " RunTo is:" << RunTo << endl;
925 return RETOk;
926}

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

◆ getReadMDCInfo()

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

589 {
590 using namespace rdbModel;
591 eRet ret;
592 char stmt1[200];
593 int run_No =runNo;
594
595 if(sftver=="default")
596 sftver = getenv("BES_RELEASE");
597 const char* SftVer = sftver.c_str();
598
599
600 if(calParVer!="default"){
601 const char* calpar = calParVer.c_str();
602 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);}
603
604 if(calParVer=="default"){
605 //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);}
606 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);}
607
608 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
609 if(row_no<1){
610 std::cout<<"ERROR:error searching Mdc calibration Data in the database with: "<<stmt1<<std::endl;
611 return RETMySQLError;
612 }
613 int RunFrom,RunTo;
614 DatabaseRecord& records = *res[0];
615 sscanf(records["RunFrom"], "%d", &RunFrom);
616 sscanf(records["RunTo"], "%d", &RunTo);
617 cout << "@table Mdc: RunFrom is:" << RunFrom << " RunTo is:" << RunTo << endl;
618
619 return RETOk;
620}

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

◆ getReadMUCInfo()

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

549 {
550 using namespace rdbModel;
551 eRet ret;
552 char stmt1[300];
553 int run_No =runNo;
554 //char* SftVer = getenv("BES_RELEASE");
555 if(sftver=="default")
556 sftver = getenv("BES_RELEASE");
557 const char* SftVer = sftver.c_str();
558
559 if(calParVer!="default"){
560 const char* calpar = calParVer.c_str();
561 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);
562 }
563
564 if(calParVer=="default"){
565 // 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);
566 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);
567
568 }
569
570 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
571 if(row_no<1){
572 std::cout<<"ERROR:error searching MUC calibration Data in the database with: "<<stmt1<<std::endl;
573 return RETMySQLError;
574 }
575 int RunFrom,RunTo;
576 DatabaseRecord& records = *res[0];
577 sscanf(records["RunFrom"], "%d", &RunFrom);
578 sscanf(records["RunTo"], "%d", &RunTo);
579 cout << "@table Muc: RunFrom is:" << RunFrom << " RunTo is:" << RunTo << endl;
580 return RETOk;
581 }

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

◆ getReadOffEvtFilterInfo()

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

Definition at line 447 of file Metadata.cxx.

453 {
454 using namespace rdbModel;
455 eRet ret;
456 char stmt1[200];
457 int run_No =runNo;
458
459 if(sftver=="default")
460 sftver = getenv("BES_RELEASE");
461 const char* SftVer = sftver.c_str();
462 if(calParVer!="default"){
463 const char* calpar = calParVer.c_str();
464 sprintf(stmt1,"select data,oef,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from OffEvtFilter 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 data,oef,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from OffEvtFilter where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);}
468 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
469 if(row_no<1){
470 std::cout<<"ERROR:error searching OffEvtFilter calibration Data in the database with: "<<stmt1<<std::endl; return RETMySQLError;
471 }
472 int RunFrom,RunTo;
473 DatabaseRecord& records = *res[0];
474 sscanf(records["RunFrom"], "%d", &RunFrom);
475 sscanf(records["RunTo"], "%d", &RunTo);
476 cout << "@table OffEvtFilter: RunFrom is:" << RunFrom << " RunTo is:" << RunTo << endl;
477
478 return RETOk;
479
480 }

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

◆ getReadTOFInfo()

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

513 {
514 using namespace rdbModel;
515 eRet ret;
516 char stmt1[300];
517 int run_No =runNo;
518 if(sftver=="default")
519 sftver = getenv("BES_RELEASE");
520 const char* SftVer = sftver.c_str();
521
522 if(calParVer!="default"){
523 const char* calpar = calParVer.c_str();
524 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);
525 }
526 if(calParVer=="default"){
527 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);
528 }
529
530 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
531 if(row_no<1){
532 std::cout<<"ERROR:error searching TOF calibration Data in the database with: "<<stmt1<<std::endl;
533 return RETMySQLError;
534 }
535 int RunFrom,RunTo;
536 DatabaseRecord& records = *res[0];
537 sscanf(records["RunFrom"], "%d", &RunFrom);
538 sscanf(records["RunTo"], "%d", &RunTo);
539 cout << "@table TofCalConst: RunFrom is:" << RunFrom << " RunTo is:" << RunTo << endl;
540 return RETOk;
541 }

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

◆ getReadTofQElecInfo()

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

934 {
935 using namespace rdbModel;
936 eRet ret;
937 char stmt1[400];
938 int run_No =runNo;
939 if(sftver=="default")
940 sftver = getenv("BES_RELEASE");
941 const char* SftVer = sftver.c_str();
942
943 if(calParVer!="default"){
944 const char* calpar = calParVer.c_str();
945 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);
946 }
947 if(calParVer=="default"){
948 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);
949 }
950 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
951 if(row_no<1){
952 std::cout<<"ERROR:error searching TofQElec calibration Data in the database with: "<<stmt1<<std::endl;
953 return RETMySQLError;
954 }
955 int RunFrom,RunTo;
956 DatabaseRecord& records = *res[0];
957 sscanf(records["RunFrom"], "%d", &RunFrom);
958 sscanf(records["RunTo"], "%d", &RunTo);
959 cout << "Read from DB TofQElec: RunFrom " << RunFrom << " RunTo= " << RunTo << endl;
960 std::cout<<"metadata ok"<<std::endl;
961
962 return RETOk;
963}

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

◆ getReadTofSimInfo()

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

784 {
785 using namespace rdbModel;
786 eRet ret;
787 char stmt1[200];
788 int run_No =runNo;
789 if(sftver=="default")
790 sftver = getenv("BES_RELEASE");
791 const char* SftVer = sftver.c_str();
792
793 if(calParVer!="default"){
794 const char* calpar = calParVer.c_str();
795 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);
796 }
797 if(calParVer=="default"){
798 // 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);
799 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);
800 }
801
802
803 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
804 if(row_no<1){
805 std::cout<<"ERROR:error searching TOFSim calibration Data in the database with: "<<stmt1<<std::endl;
806 return RETMySQLError;
807 }
808 int RunFrom,RunTo;
809 DatabaseRecord& records = *res[0];
810 sscanf(records["RunFrom"], "%d", &RunFrom);
811 sscanf(records["RunTo"], "%d", &RunTo);
812 cout << "@table TofSim: RunFrom is:" << RunFrom << " RunTo is:" << RunTo << endl;
813 return RETOk;
814}

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

◆ getTable()

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

Definition at line 316 of file Metadata.h.

316{return m_table;}

◆ registerCalib()

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

1062{
1063
1064 using namespace rdbModel;
1065
1066 eRet ret;
1067
1068 if (!m_writeCxt) {
1069 connectWrite(ret);
1070 if (ret != RETOk) return 0; // we or connectWrite should throw exception
1071 }
1072 StringVector cols;
1073 StringVector vals;
1074 StringVector nullCols;
1075
1076 cols.reserve(24);
1077 vals.reserve(24);
1078 nullCols.reserve(16);
1079
1080 if (inst.size() * calib_type.size() * flavor.size() * data_fmt.size()
1081 * data_ident.size() * proc_level.size() * completion.size()
1082 * locale.size() == 0) { // something is null that shouldn't be
1083 return 0; // should perhaps throw exception
1084 }
1085 cols.push_back("calib_type"); vals.push_back(calib_type);
1086 // cols.push_back("flavor"); vals.push_back(flavor);
1087 cols.push_back("data_fmt"); vals.push_back(data_fmt);
1088 cols.push_back("data_ident"); vals.push_back(data_ident);
1089 cols.push_back("status"); vals.push_back(completion);
1090 std::string s_runfrm,s_runto;
1091 facilities::Util::itoa(runfrm,s_runfrm);
1092 facilities::Util::itoa(runto,s_runto);
1093 cols.push_back("RunFrom"); vals.push_back(s_runfrm);
1094 cols.push_back("RunTo"); vals.push_back(s_runto);
1095
1096 // These, however, may be null
1097 if (input_desc.size() > 0 ) {
1098 cols.push_back("input_desc"); vals.push_back(input_desc);
1099 } else nullCols.push_back("input_desc");
1100
1101 if (notes.size() > 0 ) {
1102 cols.push_back("notes"); vals.push_back(notes);
1103 } else nullCols.push_back("notes");
1104
1105 if (fmt_version.size() > 0 )
1106 {
1107 cols.push_back("fmt_version");
1108 vals.push_back(fmt_version);
1109 }
1110
1111 // The service -- that's us -- is responsible for creator, uid, enter_time
1112 cols.push_back("creator"); vals.push_back("Metadata::registerCalib");
1113 std::string uid;
1114 fetchUser(uid);
1115 cols.push_back("uid"); vals.push_back(uid);
1116 facilities::Timestamp curTime;
1117 cols.push_back("enter_time");vals.push_back(curTime.getString());
1118 // update_time is set automatically by MySQL, but MySQL uses
1119 // local timezone rather than gmt, so we have set it explicitly
1120 cols.push_back("update_time");vals.push_back(curTime.getString());
1121
1122
1123 if (m_rdb) {
1124 bool ok = checkValues(cols, vals);
1125 if (ok) checkNulls(nullCols);
1126 if (!ok) return 0;
1127 }
1128
1129 // ser_no gets set automatically by MySQL
1130 int ser_no;
1131 if (!(m_writeCxt->insertRow(m_table, cols, vals, &ser_no, &nullCols)) ) {
1132 return 0;
1133 } else {
1134 adjustVend(ser_no);
1135 return ser_no;
1136 }
1137}
bool checkValues(const rdbModel::StringVector &cols, const rdbModel::StringVector &vals) const
Definition: Metadata.cxx:1183
bool checkNulls(const rdbModel::StringVector &cols) const
Definition: Metadata.cxx:1200
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

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