4 void fpsConstant_db(
char* opt=
"",
char* year=
"15sim") {
5 TString option(opt), yr(year);
8 std::cout <<
"year = " << year <<
"\n";
9 if(yr.Contains(
"15ofl")){
10 storeTime=
"2014-12-20 00:00:01";
11 date = 20141220; time = 1;
12 }
else if(yr.Contains(
"15sim")){
13 storeTime=
"2014-12-10 00:00:02";
14 date = 20141210; time = 2;
15 }
else if(yr.Contains(
"17ofl")){
16 storeTime=
"2016-12-20 00:00:00";
17 date = 20161220; time = 0;
18 }
else if(yr.Contains(
"17sim")){
19 storeTime=
"2016-12-10 00:00:00";
20 date = 20161210; time = 0;
22 std::cout <<
"Please specify valid year tag\n"; exit;
24 std::cout <<
"Opt =" << opt <<
"\n";
25 std::cout <<
"writedb = " << option.Contains(
"write") <<
"\n";
26 std::cout <<
"storetime =" << storeTime <<
"\n";
27 std::cout <<
"date,time =" << date <<
" "<< time <<
"\n";
29 gROOT->Macro(
"loadlib.C");
32 if(option.Contains(
"writedb")) {
33 gSystem->Setenv(
"DB_ACCESS_MODE",
"write");
36 StDbTable* dbtable = node->addDbTable(
"fpsConstant");
37 mgr->setStoreTime(storeTime.Data());
46 if(yr.Contains(
"sim")) dbtable->setFlavor(
"sim");
47 mgr->storeDbTable(dbtable);
48 std::cout <<
"INFO: table saved to database" << std::endl;
51 std::cout <<
"INFO: Reading database" << std::endl;
52 gSystem->Unsetenv(
"DB_ACCESS_MODE");
56 dbMk->SetDateTime(date,time);
57 if(yr.Contains(
"ofl")) {dbMk->SetFlavor(
"ofl");}
58 else if(yr.Contains(
"sim")) {dbMk->SetFlavor(
"sim");}
62 DB = dbMk->GetDataBase(
"Geometry/fps/fpsConstant");
63 if (!DB) std::cout <<
"ERROR: no table found in db, or malformed local db config" << std::endl;
64 St_fpsConstant *dataset = 0;
65 dataset = (St_fpsConstant*) DB->
Find(
"fpsConstant");
67 td::cout <<
"ERROR: dataset does not contain requested table" << std::endl;
70 Int_t rows = dataset->GetNRows();
72 std::cout <<
"INFO: found INDEXED table with " << rows <<
" rows" << std::endl;
75 dbMk->GetValidity((
TTable*)dataset,val);
76 std::cout <<
"Dataset validity range: [ " << val[0].GetDate() <<
"." << val[0].GetTime() <<
" - "
77 << val[1].GetDate() <<
"." << val[1].GetTime() <<
" ] "
79 fpsConstant_st *tbl = dataset->GetTable();
80 for (Int_t i = 0; i < rows; i++) {
81 std::cout << Form(
"Row=%d nQuad=%1d nLayer=%1d maxSlat=%2d maxQTaddr=%1d maxQTch=%2d\n",i,
82 tbl[i].nQuad,tbl[i].nLayer,tbl[i].maxSlat,
83 tbl[i].maxQTaddr,tbl[i].maxQTch);
virtual void SetTable(char *data, int nrows, int *idList=0)
calloc'd version of data for StRoot
static StDbManager * Instance()
strdup(..) is not ANSI
virtual TDataSet * Find(const char *path) const