BOSS 7.0.5
BESIII Offline Software System
Loading...
Searching...
No Matches
Metadata.cxx
Go to the documentation of this file.
1// $Header: /bes/bes/BossCvs/Calibration/calibUtil/src/Metadata.cxx,v 1.42 2016/05/27 02:56:18 sunss Exp $
2
3/*
4#ifdef WIN32
5#include <windows.h>
6#endif
7*/
8
9#include "calibUtil/Metadata.h"
10#include "facilities/Util.h"
11#include "facilities/Timestamp.h"
12#include "rdbModel/Management/Manager.h"
13#include "rdbModel/Management/XercesBuilder.h"
14#include "GaudiKernel/Bootstrap.h"
15#include "GaudiKernel/ISvcLocator.h"
16
17
18
19#include "rdbModel/Db/MysqlConnection.h"
20#include "rdbModel/Db/MysqlResults.h"
21#include "rdbModel/Rdb.h"
22#include "rdbModel/RdbException.h"
23#include "rdbModel/Tables/Assertion.h"
24#include "rdbModel/Tables/Table.h"
25#include "rdbModel/Tables/Column.h"
26#include <iostream>
27#include <cstdio>
28#include <mysql.h>
29#include "TTree.h"
30#include "TBuffer.h"
31
32
33namespace calibUtil {
34
35 // Might be getting rid of this
36 // const unsigned int Metadata::s_rowReady = Metadata::eOpened
37 // | Metadata::eValid | Metadata::eInputDesc | Metadata::eComment;
38
39 Metadata::Metadata(const std::string& host, const std::string& table,
40 const std::string& dbName)
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 }
56
60 if (m_man) delete m_man;
61 }
62
63
64 Metadata::eRet Metadata::fetchUser(std::string& user) {
65 // WARNING: Windows and Linux/Solaris use different standard variables
66 // for login name. The test used below isn't quite right
67 // since one could conceivably compile with gcc on cygwin/Windows.
68#ifdef __GNUG__
69 user = std::string("$(USER)");
70#else
71 user = std::string("$(USERNAME)");
72#endif
73
74 int nsub = facilities::Util::expandEnvVar(&user);
75 if (nsub == 1) {
76 return RETOk;
77 }
78 else {
79 user = std::string("");
80 return RETBadValue;
81 }
82 }
83
84 // The next 5 methods concern connection to the server
85 bool Metadata::connect(rdbModel::Connection* cxt, std::string& host,
86 const std::string& user,
87 const std::string& pw, eRet& err,
88 const std::string& dbName) {
89
90 int nSub = facilities::Util::expandEnvVar(&host);
91 if (nSub < 0) {
92 err = RETBadHost;
93 return false;
94 }
95
96 bool connected = cxt->open(host, user, pw, dbName);
97 if (connected) {
98 err = RETOk;
99 return true;
100 }
101 else {
102 err = RETNoConnect;
103 return false;
104 }
105 }
106
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 }
128
129 bool Metadata::connectWrite(eRet& err) {
130 if (m_writeCxt == 0) {
131 m_writeCxt = new rdbModel::MysqlConnection();
132 bool ok;
133 if (m_dbName == std::string("calib_test") ) {
134 ok = connect(m_writeCxt, m_host, std::string("calib_tester"),
135 std::string("udine"), err, m_dbName);
136 }
137 else {
138 ok = connect(m_writeCxt, m_host, std::string("calibrator"),
139 std::string("calibrator"), err, m_dbName);
140 }
141 if (!ok) {
142 delete m_readCxt;
143 m_readCxt = 0;
144 } else { // look for compatible schema
145 std::string schema =
146 std::string("$(RDBMODELROOT)/xml/")+ m_dbName + ".xml";
147 err = compareSchema(m_writeCxt, schema);
148 }
149
150 return ok;
151 }
152 else return true;
153 }
154
156 if (m_readCxt) {
157 m_readCxt->close();
158 delete m_readCxt;
159 m_readCxt = 0;
160 }
161 }
162
164 if (m_writeCxt) {
165 m_writeCxt->close();
166 delete m_writeCxt;
167 m_writeCxt = 0;
168 }
169 }
170
172 Metadata::findSoonAfter(unsigned int *ser,
173 const std::string& calibType,
174 const std::string& SftVer,
175 const std::string& cal_ver,
176 const std::string& cal_par,
177 const std::string& rec_alg,
178 const std::string& rec_par,
179 const std::string& machine,
180 const std::string& flavor) {
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 }
242
244 const std::string& calibType,
245 const std::string& SftVer,
246 const std::string& cal_ver,
247 const std::string& cal_par,
248 const std::string& rec_alg,
249 const std::string& rec_par,
250 const std::string& machine,
251 const std::string& flavor)
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 }
312
313
314 Metadata::eRet Metadata::getReadInfo(unsigned int serialNo,
315 int *runFrm,
316 int *runTo,
317 std::string& dataFmt,
318 std::string& filename) {
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 }
375
377 int *runFrm,
378 int *runTo,
379 std::string& calParVer,
381 int runNo,
382 std::string& sftver) {
383 using namespace rdbModel;
384 eRet ret;
385 char stmt1[300];
386 int run_No =runNo;
387 if(sftver=="default")
388 sftver = getenv("BES_RELEASE");
389 const char* SftVer = sftver.c_str();
390
391 if(calParVer!="default"){
392 const char* calpar = calParVer.c_str();
393 sprintf(stmt1,"select BarTofPar,EndTofPar,TofConPar,BarTof,EtfTofPar,EtfTofBunch,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from TofCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = %s",SftVer,run_No,run_No,calpar);
394 }
395 if(calParVer=="default"){
396 sprintf(stmt1,"select BarTofPar,EndTofPar,TofConPar,BarTof,EtfTofPar,EtfTofBunch,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from TofCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);
397 }
398
399 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
400 if(row_no<1){
401 std::cout<<"ERROR:error searching TOF calibration Data in the database with: "<<stmt1<<std::endl;
402 return RETMySQLError;
403 }
404
405 return RETOk;
406 }
407
409 int *runFrm,
410 int *runTo,
411 std::string& calParVer,
413 int runNo,
414 std::string& sftver) {
415 using namespace rdbModel;
416 eRet ret;
417 char stmt1[300];
418 int run_No =runNo;
419 //char* SftVer = getenv("BES_RELEASE");
420 if(sftver=="default")
421 sftver = getenv("BES_RELEASE");
422 const char* SftVer = sftver.c_str();
423
424 if(calParVer!="default"){
425 const char* calpar = calParVer.c_str();
426 sprintf(stmt1,"select LayTree,BoxTree,StrTree,ResTree,ClsTree,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from MucCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);
427 }
428
429 if(calParVer=="default"){
430 // sprintf(stmt1,"select SftVer,LayTree,BoxTree,StrTree,ResTree,ClsTree,RunFrom,RunTo,max(CalParVer),FileName from MucCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d group by CalParVer",SftVer,run_No,run_No);
431 sprintf(stmt1,"select LayTree,BoxTree,StrTree,ResTree,ClsTree,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from MucCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);
432
433 }
434
435 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
436 if(row_no<1){
437 std::cout<<"ERROR:error searching MUC calibration Data in the database with: "<<stmt1<<std::endl;
438 return RETMySQLError;
439 }
440
441
442 return RETOk;
443 }
444
446 int *runFrm,
447 int *runTo,
448 std::string& calParVer,
450 int runNo,
451 std::string& sftver) {
452 using namespace rdbModel;
453 eRet ret;
454 char stmt1[200];
455 int run_No =runNo;
456
457 if(sftver=="default")
458 sftver = getenv("BES_RELEASE");
459 const char* SftVer = sftver.c_str();
460
461
462 if(calParVer!="default"){
463 const char* calpar = calParVer.c_str();
464 sprintf(stmt1,"select NewXtTrees,XtTree,QtTree,T0Tree,SdTree,R2tTrees,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from MdcCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = '%s'",SftVer,run_No,run_No,calpar);}
465
466 if(calParVer=="default"){
467 //sprintf(stmt1,"select NewXtTrees,XtTree,QtTree,T0Tree,SdTree,R2tTrees,RunFrom,RunTo,max(CalParVer),FileName from MdcCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d group by CalParVer",SftVer,run_No,run_No);}
468 sprintf(stmt1,"select NewXtTrees,XtTree,QtTree,T0Tree,SdTree,R2tTrees,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from MdcCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);}
469
470 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
471 if(row_no<1){
472 std::cout<<"ERROR:error searching Mdc calibration Data in the database with: "<<stmt1<<std::endl;
473 return RETMySQLError;
474 }
475
476
477 return RETOk;
478}
479
480
481
483 int *runFrm,
484 int *runTo,
485 std::string& calParVer,
487 int runNo,
488 std::string& sftver) {
489 using namespace rdbModel;
490 eRet ret;
491 char stmt1[300];
492 int run_No =runNo;
493 if(sftver=="default")
494 sftver = getenv("BES_RELEASE");
495 const char* SftVer = sftver.c_str();
496
497 if(calParVer!="default"){
498 const char* calpar = calParVer.c_str();
499 sprintf(stmt1,"select DigiCalibConst,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from EmcCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = %s",SftVer,run_No,run_No,calpar);
500 }
501
502 if(calParVer=="default"){
503 //sprintf(stmt1,"select DigiCalibConst,RunFrom,RunTo,max(CalParVer),FileName from EmcCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d group by CalParVer",SftVer,run_No,run_No);
504 sprintf(stmt1,"select DigiCalibConst,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from EmcCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);
505 }
506
507 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
508 if(row_no<1){
509 std::cout<<"ERROR:error searching EMC calibration Data in the database with: "<<stmt1<<std::endl;
510 return RETMySQLError;
511 }
512 return RETOk;
513}
514
515
517 int *runFrm,
518 int *runTo,
519 std::string& calParVer,
521 int runNo,
522 std::string& sftver) {
523 using namespace rdbModel;
524 eRet ret;
525 char stmt1[400];
526 int run_No =runNo;
527 if(sftver=="default")
528 sftver = getenv("BES_RELEASE");
529 const char* SftVer = sftver.c_str();
530
531 if(calParVer!="default"){
532 const char* calpar = calParVer.c_str();
533 sprintf(stmt1,"select DriftDist,EntranceAng,MeanGain,GasGain,LayerGain,Resolution,WireGain,ZDep,RunGain,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from DedxCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = %s",SftVer,run_No,run_No,calpar);
534
535 }
536 if(calParVer=="default"){
537 // sprintf(stmt1,"select DriftDist,EntranceAng,MeanGain,GasGain,LayerGain,Resolution,WireGain,ZDep,RunGain,RunFrom,RunTo,max(CalParVer),FileName from DedxCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d group by CalParVer",SftVer,run_No,run_No);
538 sprintf(stmt1,"select DriftDist,EntranceAng,MeanGain,GasGain,LayerGain,Resolution,WireGain,ZDep,RunGain,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from DedxCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);
539 }
540
541 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
542 if(row_no<1){
543 std::cout<<"ERROR:error searching Dedx calibration Data in the database with: "<<stmt1<<std::endl;
544 return RETMySQLError;
545 }
546 return RETOk;
547}
548
549
551 int *runFrm,
552 int *runTo,
553 std::string& calParVer,
555 int runNo,
556 std::string& sftver) {
557 using namespace rdbModel;
558 eRet ret;
559 char stmt1[400];
560 int run_No =runNo;
561 if(sftver=="default")
562 sftver = getenv("BES_RELEASE");
563 const char* SftVer = sftver.c_str();
564
565 if(calParVer!="default"){
566 const char* calpar = calParVer.c_str();
567 sprintf(stmt1,"select EsTimeH2,EsTimeH9,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from EsTimeCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = %s",SftVer,run_No,run_No,calpar);
568 }
569
570 if(calParVer=="default"){
571 sprintf(stmt1,"select EsTimeH2,EsTimeH9,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from EsTimeCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);
572 }
573 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
574 if(row_no<1){
575 std::cout<<"ERROR:error searching EsTime calibration Data in the database with: "<<stmt1<<std::endl;
576 return RETMySQLError;
577 }
578
579 return RETOk;
580}
581
582
583//get EstTof Information from mysql Database
585 int *runFrm,
586 int *runTo,
587 std::string& calParVer,
589 int runNo,
590 std::string& sftver) {
591 using namespace rdbModel;
592 eRet ret;
593 char stmt1[200];
594 int run_No =runNo;
595 if(sftver=="default")
596 sftver = getenv("BES_RELEASE");
597 const char* SftVer = sftver.c_str();
598
599 if(calParVer!="default"){
600 const char* calpar = calParVer.c_str();
601 sprintf(stmt1,"select BarTofPar,EndTofPar,TofConPar,BarTof,EtfTofPar,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from EstTofCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = %s",SftVer,run_No,run_No,calpar);
602 }
603 if(calParVer=="default"){
604 // sprintf(stmt1,"select BarTofPar,EndTofPar,TofConPar,BarTof,RunFrom,RunTo,max(CalParVer),FileName from EstTofCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d group by CalParVer",SftVer,run_No,run_No);
605 sprintf(stmt1,"select BarTofPar,EndTofPar,TofConPar,BarTof,EtfTofPar,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from EstTofCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);
606 }
607
608 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
609 if(row_no<1){
610 std::cout<<"ERROR:error searching EstTOF calibration Data in the database with: "<<stmt1<<std::endl;
611 return RETMySQLError;
612 }
613 return RETOk;
614}
615
616
618 int *runFrm,
619 int *runTo,
620 std::string& calParVer,
622 int runNo,
623 std::string& sftver) {
624 using namespace rdbModel;
625 eRet ret;
626 char stmt1[200];
627 int run_No =runNo;
628 if(sftver=="default")
629 sftver = getenv("BES_RELEASE");
630 const char* SftVer = sftver.c_str();
631
632 if(calParVer!="default"){
633 const char* calpar = calParVer.c_str();
634 sprintf(stmt1,"select BTofSim,ETofSim,SimConstants,RunFrom,RunTo,TofSimParVer,FileName,Status,SftVer from TofSimSvc where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and TofSimParVer = %s",SftVer,run_No,run_No,calpar);
635 }
636 if(calParVer=="default"){
637 // sprintf(stmt1,"select BTofSim,ETofSim,SimConstants,RunFrom,RunTo,max(TofSimParVer),FileName from TofSimSvc where SftVer = '%s' and RunFrom <= %d and RunTo >= %d group by TofSimParVer",SftVer,run_No,run_No);
638 sprintf(stmt1,"select BTofSim,ETofSim,SimConstants,RunFrom,RunTo,TofSimParVer,FileName,Status,SftVer from TofSimSvc where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by TofSimParVer desc",SftVer,run_No,run_No);
639 }
640
641
642 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
643 if(row_no<1){
644 std::cout<<"ERROR:error searching TOFSim calibration Data in the database with: "<<stmt1<<std::endl;
645 return RETMySQLError;
646 }
647
648 return RETOk;
649}
650
651
653 int *runFrm,
654 int *runTo,
655 std::string& calParVer,
657 int runNo,
658 std::string& sftver) {
659 using namespace rdbModel;
660 eRet ret;
661 char stmt1[200];
662 int run_No =runNo;
663 if(sftver=="default")
664 sftver = getenv("BES_RELEASE");
665 const char* SftVer = sftver.c_str();
666
667 if(calParVer!="default"){
668 const char* calpar = calParVer.c_str();
669 sprintf(stmt1,"select TH1F_Col,bin,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from DedxSim where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = %s",SftVer,run_No,run_No,calpar);
670 }
671 if(calParVer=="default"){
672 sprintf(stmt1,"select TH1F_Col,bin,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from DedxSim where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);
673 }
674
675 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
676 if(row_no<1){
677 std::cout<<"ERROR:error searching DedxSim calibration Data in the database with: "<<stmt1<<std::endl;
678 return RETMySQLError;
679 }
680 return RETOk;
681}
682
683
684
686 int *runFrm,
687 int *runTo,
688 std::string& calParVer,
690 int runNo,
691 std::string& sftver) {
692 using namespace rdbModel;
693 eRet ret;
694 char stmt1[200];
695 int run_No =runNo;
696 if(sftver=="default")
697 sftver = getenv("BES_RELEASE");
698 const char* SftVer = sftver.c_str();
699
700 if(calParVer!="default"){
701 const char* calpar = calParVer.c_str();
702 sprintf(stmt1,"select AlignEndPlate,WirePos,WireTension,RunFrom,RunTo,MdcAlignVer,AlignEPFileName,Status,SftVer from MdcAlignment where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and MdcAlignVer = %s",SftVer,run_No,run_No,calpar);
703 }
704 if(calParVer=="default"){
705 // sprintf(stmt1,"select AlignEndPlate,WirePos,WireTension,RunFrom,RunTo,max(MdcAlignVer),AlignEPFileName from MdcAlignment where SftVer = '%s' and RunFrom <= %d and RunTo >= %d group by MdcAlignVer",SftVer,run_No,run_No);
706 sprintf(stmt1,"select AlignEndPlate,WirePos,WireTension,RunFrom,RunTo,MdcAlignVer,AlignEPFileName,Status,SftVer from MdcAlignment where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by MdcAlignVer desc",SftVer,run_No,run_No);
707 }
708
709 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
710 if(row_no<1){
711 std::cout<<"ERROR:error searching MdcAlignment calibration Data in the database with: "<<stmt1<<std::endl;
712 return RETMySQLError;
713 }
714
715 return RETOk;
716}
717
719 int *runFrm,
720 int *runTo,
721 std::string& calParVer,
723 int runNo,
724 std::string& sftver) {
725 using namespace rdbModel;
726 eRet ret;
727 char stmt1[200];
728 int run_No =runNo;
729 if(sftver=="default")
730 sftver = getenv("BES_RELEASE");
731 const char* SftVer = sftver.c_str();
732
733 if(calParVer!="default"){
734 const char* calpar = calParVer.c_str();
735 sprintf(stmt1,"select WireEff,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from MdcDataConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = %s",SftVer,run_No,run_No,calpar);
736 }
737 if(calParVer=="default"){
738 sprintf(stmt1,"select WireEff,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from MdcDataConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);
739 }
740
741 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
742 if(row_no<1){
743 std::cout<<"ERROR:error searching MdcDataConst Data in the database with: "<<stmt1<<std::endl;
744 return RETMySQLError;
745 }
746
747 return RETOk;
748}
749
751 int *runFrm,
752 int *runTo,
753 std::string& calParVer,
755 int runNo,
756 std::string& sftver) {
757 using namespace rdbModel;
758 eRet ret;
759 char stmt1[400];
760 int run_No =runNo;
761 if(sftver=="default")
762 sftver = getenv("BES_RELEASE");
763 const char* SftVer = sftver.c_str();
764
765 if(calParVer!="default"){
766 const char* calpar = calParVer.c_str();
767 sprintf(stmt1,"select BarBoardNum,EndBoardNum,QELecBarParEast,QELecBarParWest,QELecEndPar,SimQELecBarParEast,SimQELecBarParWest,SimQELecEndPar,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from TofQELec where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = %s",SftVer,run_No,run_No,calpar);
768 }
769 if(calParVer=="default"){
770 sprintf(stmt1,"select BarBoardNum,EndBoardNum,QELecBarParEast,QELecBarParWest,QELecEndPar,SimQELecBarParEast,SimQELecBarParWest,SimQELecEndPar,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from TofQELec where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);
771 }
772 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
773 if(row_no<1){
774 std::cout<<"ERROR:error searching TofQElec calibration Data in the database with: "<<stmt1<<std::endl;
775 return RETMySQLError;
776 }
777 std::cout<<"metadata ok"<<std::endl;
778 return RETOk;
779}
780
781
782/*
783
784 | Field | Type | Null | Key | Default | How set |
785 +-------------+--------------------+------+-----+---------+------------------+
786 | ser_no | mediumint(9) | | PRI | NULL | auto_increment |
787 | instrument | varchar(16) | | | | [openRecord] |
788 | calib_type | varchar(20) | | | | [openRecord |
789 | data_fmt | varchar(10) | | | | [openRecord] |
790 | data_size | int(11) | YES | | NULL | [optional] |
791 | vstart | datetime | YES | | NULL |[addValidInterval]|
792 | vend | datetime | YES | | NULL |[addValidInterval]|
793 | enter_time | timestamp(14) | YES | | NULL | automatic |
794 | fmt_version | varchar(12) | YES | | NULL | [openRecord] |
795 | completion | enum('OK','INC','ABORT')
796 | YES | MUL | NULL | [openRecord] |
797 | proc_level | enum('PROD','TEST','DEV', 'SUPSED')
798 | | | TEST | [openRecord] |
799 | creator | varchar(255) | YES | | NULL | [addCreator] |
800 | uid | varchar(12) | | | |[insertRecord/
801 addUser] |
802 | data_ident | varchar(255) | | | | [openRecord] |
803 | input_desc | varchar(255) | YES | | NULL |[addInputDesc] |
804 | notes | varchar(255) | YES | | NULL | [addNotes] |
805 +-------------+--------------------+------+-----+---------+------------------+
806
807*/
808
810Metadata::doSelect(std::vector<rdbModel::Assertion::Operator *>& conditions,
811 rdbModel::StringVector& orderBy,
812 unsigned*& ser) {
813 using namespace rdbModel;
814 *ser = 0;
815
816 StringVector colNames(1);
817 colNames[0] = "ser_no";
818
819 // make the combined operator
820 Assertion::Operator andOp(OPTYPEand, conditions, true);
821
822 //Following creates an assertion such that creator (us) continues
823 // to own the associated operator.
824 Assertion whereClause(&andOp, 0, true);
825 ResultHandle* results = 0;
826
827 if(results){
828 delete results;
829 }
830
831 try { // make the query
832 results = m_readCxt->select(m_table, colNames, orderBy, &whereClause);
833
834 }
835 catch (RdbException ex) {
836 std::cout << ex.getMsg();
837 }
838
839 if (!results) { // Error. Should have ResultHandle even if 0 rows.
840 std::cout<<"no results"<<std::endl;
841 return RETMySQLError;
842 }
843
844
845
846 std::cout<<"There are results"<<std::endl;
847 // handle result.
848 if (results->getNRows() == 0) {
849 conditions.pop_back();
850 std::cout<<"no results"<<std::endl;
851 }
852 else{
853 std::vector<std::string> fields;
854 results->getRow(fields);
855
856 if(results){
857 delete results;
858 }
859 *ser = facilities::Util::stringToInt(fields[0]);
860 return RETOk;
861 }
862
863}
864
865int Metadata::registerCalib(const std::string& inst,
866 const std::string& flavor,
867 const std::string& calib_type,
868 const std::string& data_ident,
869 const std::string& data_fmt,
870 unsigned int& runfrm,
871 unsigned int& runto,
872 const std::string& input_desc,
873 const std::string& notes,
874 const std::string& proc_level,
875 const std::string& locale,
876 const std::string& fmt_version,
877 const std::string& completion)
878{
879
880 using namespace rdbModel;
881
882 eRet ret;
883
884 if (!m_writeCxt) {
885 connectWrite(ret);
886 if (ret != RETOk) return 0; // we or connectWrite should throw exception
887 }
888 StringVector cols;
889 StringVector vals;
890 StringVector nullCols;
891
892 cols.reserve(24);
893 vals.reserve(24);
894 nullCols.reserve(16);
895
896 if (inst.size() * calib_type.size() * flavor.size() * data_fmt.size()
897 * data_ident.size() * proc_level.size() * completion.size()
898 * locale.size() == 0) { // something is null that shouldn't be
899 return 0; // should perhaps throw exception
900 }
901 cols.push_back("calib_type"); vals.push_back(calib_type);
902 // cols.push_back("flavor"); vals.push_back(flavor);
903 cols.push_back("data_fmt"); vals.push_back(data_fmt);
904 cols.push_back("data_ident"); vals.push_back(data_ident);
905 cols.push_back("status"); vals.push_back(completion);
906 std::string s_runfrm,s_runto;
907 facilities::Util::itoa(runfrm,s_runfrm);
908 facilities::Util::itoa(runto,s_runto);
909 cols.push_back("RunFrom"); vals.push_back(s_runfrm);
910 cols.push_back("RunTo"); vals.push_back(s_runto);
911
912 // These, however, may be null
913 if (input_desc.size() > 0 ) {
914 cols.push_back("input_desc"); vals.push_back(input_desc);
915 } else nullCols.push_back("input_desc");
916
917 if (notes.size() > 0 ) {
918 cols.push_back("notes"); vals.push_back(notes);
919 } else nullCols.push_back("notes");
920
921 if (fmt_version.size() > 0 )
922 {
923 cols.push_back("fmt_version");
924 vals.push_back(fmt_version);
925 }
926
927 // The service -- that's us -- is responsible for creator, uid, enter_time
928 cols.push_back("creator"); vals.push_back("Metadata::registerCalib");
929 std::string uid;
930 fetchUser(uid);
931 cols.push_back("uid"); vals.push_back(uid);
932 facilities::Timestamp curTime;
933 cols.push_back("enter_time");vals.push_back(curTime.getString());
934 // update_time is set automatically by MySQL, but MySQL uses
935 // local timezone rather than gmt, so we have set it explicitly
936 cols.push_back("update_time");vals.push_back(curTime.getString());
937
938
939 if (m_rdb) {
940 bool ok = checkValues(cols, vals);
941 if (ok) checkNulls(nullCols);
942 if (!ok) return 0;
943 }
944
945 // ser_no gets set automatically by MySQL
946 int ser_no;
947 if (!(m_writeCxt->insertRow(m_table, cols, vals, &ser_no, &nullCols)) ) {
948 return 0;
949 } else {
950 adjustVend(ser_no);
951 return ser_no;
952 }
953}
954
955Metadata::eRet Metadata::compareSchema(rdbModel::Connection* conn,
956 const std::string& schema) {
957 using namespace rdbModel;
958
959
960 if (m_man) { // already did this
961 return (m_match) ? RETOk : RETNoSchemaMatch;
962 }
964
966 m_man->setInputSource(schema);
967
968 // Maybe first check if file exists? E.g., try opening for read
969
970 // good errcode is 0
971 int errcode = m_man->build();
972
973 if (errcode) {
974 std::cerr << "Error in database description file " << schema
975 << std::endl;
976 std::cerr << "Parse failed with error " << errcode << std::endl;
977 return RETBadCnfFile;
978 }
979 m_rdb = m_man->getRdb();
980
981 rdbModel::MATCH match = conn->matchSchema(m_rdb, false);
982
983 switch (match) {
986 m_match = true;
987 return RETOk;
989 std::cout << "XML schema and MySQL database are NOT compatible"
990 << std::endl;
991 return RETBadCnfFile;
993 std::cout << "Connection failed while attempting match" << std::endl;
994 return RETNoConnect;
995 }
996 return RETBadValue;
997}
998
1000 const rdbModel::StringVector& vals) const {
1001 unsigned nCol = cols.size();
1002 rdbModel::Table* table = m_rdb->getTable(m_table);
1003
1004
1005 for (unsigned iCol = 0; iCol < nCol; iCol++) {
1006 rdbModel::Column* col = table->getColumnByName(cols[iCol]);
1007 if (!col->okValue(vals[iCol])) {
1008 std::cerr << "Value " << vals[iCol] << " not allowed for column "
1009 << cols[iCol] << " in table " << m_table << std::endl;
1010 return false;
1011 }
1012 }
1013 return true;
1014}
1015
1017 unsigned nCol = cols.size();
1018 rdbModel::Table* table = m_rdb->getTable(m_table);
1019
1020
1021 for (unsigned iCol = 0; iCol < nCol; iCol++) {
1022 rdbModel::Column* col = table->getColumnByName(cols[iCol]);
1023 if (!col->nullAllowed()) {
1024 std::cerr << "Column "
1025 << cols[iCol] << " in table " << m_table
1026 << " is not nullable" << std::endl;
1027 return false;
1028 }
1029 }
1030 return true;
1031}
1032
1033
1034unsigned Metadata::adjustVend(int newSer) {
1035 using namespace rdbModel;
1036
1037 StringVector getCols;
1038 StringVector orderBy;
1039
1040 orderBy.clear();
1041 getCols.reserve(7);
1042
1043 std::string serString;
1044 facilities::Util::itoa(newSer, serString);
1045
1046 getCols.push_back("flavor");
1047 getCols.push_back("calib_type");
1048 getCols.push_back("completion");
1049
1050 ResultHandle* results = 0;
1051 eRet err;
1052 Assertion* where = 0;
1053 try {
1054 if (!m_writeCxt) {
1055 if (!connectWrite(err)) return 0;
1056 }
1057
1058 Assertion::Operator* serOp =
1059 new Assertion::Operator(OPTYPEequal, "ser_no", serString,
1060 FIELDTYPEold, FIELDTYPElit);
1061 //false, true);
1062
1063 where = new Assertion(serOp);
1064
1065 // Fetch information for new row: vstart, flavor, completion,
1066 // proc_level, calib_type, flavor
1067 results = m_writeCxt->select(m_table, getCols, orderBy, where);
1068 // results = m_writeCxt->select("metadata_v0", getCols, orderBy, where);
1069 delete where;
1070 where = 0;
1071 }
1072 catch (RdbException ex) {
1073 std::cout << ex.getMsg();
1074 delete where; // return heap memory
1075 return 0;
1076 }
1077 if (!results) { // This is an error. Should be non-null even if no rows
1078 std::cout << "MySQL failure in SELECT" << std::endl;
1079 return 0; // nothing to fix
1080 }
1081 if (results->getNRows() != 1) { // also a problem
1082 std::cout << "Look-up of serial# " << serString << " failed"
1083 << std::endl;
1084 return 0;
1085 }
1086 std::vector<std::string> fields;
1087 results->getRow(fields);
1088 if (fields[2] != "OK") return 0; // don't bother fixing in this case
1089
1090 // Now do an update on rows satisfying
1091 // ((flavor="f") && (calib_type = "c") && (completion= "OK") &&
1092 // (instrument = "i") && (proc_level = "p") &&
1093 // (vstart < "new-start" (vend > "new-vstart") );
1094 std::vector<Assertion::Operator *> conditions;
1095 conditions.reserve(7);
1096 for (unsigned ix = 0; ix < 5; ix++) {
1097 conditions.push_back(new Assertion::Operator(OPTYPEequal, getCols[ix],
1098 fields[ix],
1099 FIELDTYPEold, FIELDTYPElit));
1100 // false, true));
1101 }
1102 conditions.push_back(new Assertion::Operator(OPTYPElessThan, "vstart",
1103 fields[5],
1104 FIELDTYPEold, FIELDTYPElit));
1105 //false, true));
1106 conditions.push_back(new Assertion::Operator(OPTYPEgreaterThan, "vend",
1107 fields[5],
1108 FIELDTYPEold, FIELDTYPElit));
1109 // false, true));
1110
1111 Assertion::Operator* andOp =
1112 new Assertion::Operator(OPTYPEand, conditions);
1113 where = new Assertion(andOp);
1114
1115 StringVector toUpdate;
1116 toUpdate.push_back("vend");
1117 StringVector newVal;
1118 newVal.push_back(fields[5]);
1119 // also update update_time. If we leave it to MySQL, won't be GMT
1120 facilities::Timestamp curTime;
1121 toUpdate.push_back("update_time");newVal.push_back(curTime.getString());
1122
1123 unsigned nModified = m_writeCxt->update(m_table, toUpdate, newVal, where);
1124 delete where;
1125 return nModified;
1126}
1127
1128}
1129
1130
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
int runNo
Definition: DQA_TO_DB.cxx:12
virtual int query(const std::string &dbName, const std::string &sql, DatabaseRecordVector &res)=0
eRet getReadMdcDataConstInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition: Metadata.cxx:718
bool checkValues(const rdbModel::StringVector &cols, const rdbModel::StringVector &vals) const
Definition: Metadata.cxx:999
eRet getReadEsTimeInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition: Metadata.cxx:550
bool checkNulls(const rdbModel::StringVector &cols) const
Definition: Metadata.cxx:1016
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")
Definition: Metadata.cxx:243
eRet getReadTOFInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition: Metadata.cxx:376
eRet getReadInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &dataFmt, std::string &dataIdent)
Definition: Metadata.cxx:314
bool connectRead(eRet &err)
Definition: Metadata.cxx:107
eRet getReadDedxSimInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition: Metadata.cxx:652
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: Metadata.cxx:39
eRet getReadMUCInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition: Metadata.cxx:408
eRet getReadEstTofInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition: Metadata.cxx:584
eRet getReadTofSimInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition: Metadata.cxx:617
eRet getReadDedxInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition: Metadata.cxx:516
eRet getReadMdcAlignInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition: Metadata.cxx:685
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")
Definition: Metadata.cxx:865
eRet getReadMDCInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition: Metadata.cxx:445
eRet getReadTofQElecInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition: Metadata.cxx:750
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")
Definition: Metadata.cxx:172
eRet getReadEMCInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition: Metadata.cxx:482
std::string getString() const
Return string representation of time, not including nanoseconds;.
Definition: Timestamp.cxx:92
static int expandEnvVar(std::string *toExpand, const std::string &openDel=std::string("$("), const std::string &closeDel=std::string(")"))
static int atoi(const std::string &InStr)
converts an std::string to an integer
static int stringToInt(const std::string &InStr)
static const char * itoa(int val, std::string &outStr)
bool nullAllowed() const
Returns true if column may take on value NULL.
bool okValue(const std::string &val, bool set=true) const
Definition: Column.cxx:21
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 MATCH matchSchema(Rdb *rdb, bool matchDbName=true)=0
virtual unsigned int update(const std::string &tableName, const StringVector &colNames, const StringVector &values, const Assertion *where=0, const StringVector *nullCols=0)=0
virtual bool open(const std::string &host, const std::string &userid, const std::string &password, const std::string &dbName)=0
virtual bool insertRow(const std::string &tableName, const StringVector &colNames, const StringVector &values, int *auto_value=0, const StringVector *nullCols=0)=0
virtual bool close()=0
void setBuilder(Builder *b)
Definition: Manager.cxx:37
static Manager * getManager()
Definition: Manager.cxx:24
Table * getTable(const std::string &name) const
Definition: Rdb.cxx:16
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.
Column * getColumnByName(const std::string &name) const
Definition: Table.cxx:56
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)
#define ix(i)
Definition: minoreval.cpp:387
Module implements methods for clients to get generic services.