4 void fpsSlatId_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:01";
14 date = 20141210; time = 1;
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 <<
"write = " << option.Contains(
"writedb") <<
"\n";
26 std::cout <<
"storetime =" << storeTime <<
"\n";
27 std::cout <<
"date,time =" << date <<
" "<< time <<
"\n";
29 gROOT->Macro(
"loadlib.C");
31 const Int_t MAX_DB_INDEX = 252;
32 fpsSlatId_st table[MAX_DB_INDEX];
34 if(option.Contains(
"writedb")) {
35 gSystem->Setenv(
"DB_ACCESS_MODE",
"write");
38 StDbTable* dbtable = node->addDbTable(
"fpsSlatId");
39 mgr->setStoreTime(storeTime.Data());
42 for (Int_t q = 1; q <= 4; q++) {
43 for (Int_t l = 1; l <= 3; l++) {
44 for (Int_t s = 1; s <= 21; s++) {
45 table[id].slatid = id;
50 if(flag==0){table[id].quad = q; table[id].layer = l; table[id].slat = s;}
51 else {table[id].quad = 0; table[id].layer = 0; table[id].slat = 0;}
57 dbtable->
SetTable((
char*)&table, MAX_DB_INDEX);
58 if(yr.Contains(
"sim")) dbtable->setFlavor(
"sim");
59 mgr->storeDbTable(dbtable);
60 std::cout <<
"INFO: table saved to database" << std::endl;
63 std::cout <<
"INFO: Reading database" << std::endl;
64 gSystem->Unsetenv(
"DB_ACCESS_MODE");
68 dbMk->SetDateTime(date,time);
69 if(yr.Contains(
"ofl")) {dbMk->SetFlavor(
"ofl");}
70 else if(yr.Contains(
"sim")) {dbMk->SetFlavor(
"sim");}
74 DB = dbMk->GetDataBase(
"Geometry/fps/fpsSlatId");
75 if (!DB) std::cout <<
"ERROR: no table found in db, or malformed local db config" << std::endl;
76 St_fpsSlatId *dataset = 0;
77 dataset = (St_fpsSlatId*) DB->
Find(
"fpsSlatId");
79 td::cout <<
"ERROR: dataset does not contain requested table" << std::endl;
82 Int_t rows = dataset->GetNRows();
84 std::cout <<
"INFO: found INDEXED table with " << rows <<
" rows" << std::endl;
87 dbMk->GetValidity((
TTable*)dataset,val);
88 std::cout <<
"Dataset validity range: [ " << val[0].GetDate() <<
"." << val[0].GetTime() <<
" - "
89 << val[1].GetDate() <<
"." << val[1].GetTime() <<
" ] "
91 fpsSlatId_st *tbl = dataset->GetTable();
92 for (Int_t i = 0; i < rows; i++) {
93 std::cout << Form(
"Row=%4d slatid=%3d quad=%2d layer=%2d slat=%2d\n",i,
94 tbl[i].slatid,tbl[i].quad,tbl[i].layer,tbl[i].slat);
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