4 void fpsChannelGeometry_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 = 12;
32 fpsChannelGeometry_st table[MAX_DB_INDEX];
34 if(option.Contains(
"writedb")) {
35 gSystem->Setenv(
"DB_ACCESS_MODE",
"write");
38 StDbTable* dbtable = node->addDbTable(
"fpsChannelGeometry");
39 mgr->setStoreTime(storeTime.Data());
41 table[ 0].quad = 1; table[ 0].layer = 1; table[ 0].nslat = 21;
42 table[ 1].quad = 1; table[ 1].layer = 2; table[ 1].nslat = 21;
43 table[ 2].quad = 1; table[ 2].layer = 3; table[ 2].nslat = 21;
44 table[ 3].quad = 2; table[ 3].layer = 1; table[ 3].nslat = 19;
45 table[ 4].quad = 2; table[ 4].layer = 2; table[ 4].nslat = 19;
46 table[ 5].quad = 2; table[ 5].layer = 3; table[ 5].nslat = 19;
47 table[ 6].quad = 3; table[ 6].layer = 1; table[ 6].nslat = 21;
48 table[ 7].quad = 3; table[ 7].layer = 2; table[ 7].nslat = 21;
49 table[ 8].quad = 3; table[ 8].layer = 3; table[ 8].nslat = 21;
50 table[ 9].quad = 4; table[ 9].layer = 1; table[ 9].nslat = 19;
51 table[10].quad = 4; table[10].layer = 2; table[10].nslat = 19;
52 table[11].quad = 4; table[11].layer = 3; table[11].nslat = 19;
54 dbtable->
SetTable((
char*)&table, MAX_DB_INDEX);
55 if(yr.Contains(
"sim")) dbtable->setFlavor(
"sim");
56 mgr->storeDbTable(dbtable);
57 std::cout <<
"INFO: table saved to database" << std::endl;
60 std::cout <<
"INFO: Reading database" << std::endl;
61 gSystem->Unsetenv(
"DB_ACCESS_MODE");
65 dbMk->SetDateTime(date,time);
66 if(yr.Contains(
"ofl")) {dbMk->SetFlavor(
"ofl");}
67 else if(yr.Contains(
"sim")) {dbMk->SetFlavor(
"sim");}
71 DB = dbMk->GetDataBase(
"Geometry/fps/fpsChannelGeometry");
72 if (!DB) std::cout <<
"ERROR: no table found in db, or malformed local db config" << std::endl;
73 St_fpsChannelGeometry *dataset = 0;
74 dataset = (St_fpsChannelGeometry*) DB->
Find(
"fpsChannelGeometry");
76 td::cout <<
"ERROR: dataset does not contain requested table" << std::endl;
79 Int_t rows = dataset->GetNRows();
81 std::cout <<
"INFO: found INDEXED table with " << rows <<
" rows" << std::endl;
84 dbMk->GetValidity((
TTable*)dataset,val);
85 std::cout <<
"Dataset validity range: [ " << val[0].GetDate() <<
"." << val[0].GetTime() <<
" - "
86 << val[1].GetDate() <<
"." << val[1].GetTime() <<
" ] "
88 fpsChannelGeometry_st *tbl = dataset->GetTable();
89 for (Int_t i = 0; i < rows; i++) {
90 std::cout << Form(
"Row=%4d quad=%1d layer=%1d nslat=%2d\n",i,
91 tbl[i].quad,tbl[i].layer,tbl[i].nslat);
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