10 void fPostChannelGeometry_db(
12 const char* year =
"17sim")
15 TString option(opt), yr(year), storeTime;
18 std::cout <<
"year = " <<year <<std::endl;
19 if (yr.Contains(
"17sim"))
21 storeTime =
"2016-12-10 00:00:00";
25 else if (yr.Contains(
"17ofl"))
27 storeTime =
"2016-12-20 00:00:00";
31 else { std::cout <<
"Please specify valid year tag\n"; exit; }
32 std::cout <<
"Opt =" << opt <<
"\n";
33 std::cout <<
"write = " << option.Contains(
"writedb") <<
"\n";
34 std::cout <<
"storetime = " << storeTime <<
"\n";
35 std::cout <<
"date, time = " << date <<
" "<< time <<
"\n";
37 gROOT->Macro(
"./loadlib.C");
41 const Int_t MAX_DB_INDEX = 12;
42 fpostChannelGeometry_st in[MAX_DB_INDEX];
46 if (option.Contains(
"writedb"))
48 gSystem->Setenv(
"DB_ACCESS_MODE",
"write");
51 StDbTable* dbtable = node->addDbTable(
"fpostChannelGeometry");
52 mgr->setStoreTime(storeTime.Data());
54 in[ 0].quad = 1; in[ 0].layer = 1; in[ 0].nslat = 9;
55 in[ 1].quad = 1; in[ 1].layer = 2; in[ 1].nslat = 14;
56 in[ 2].quad = 1; in[ 2].layer = 3; in[ 2].nslat = 0;
57 in[ 3].quad = 1; in[ 3].layer = 4; in[ 3].nslat = 25;
58 in[ 4].quad = 1; in[ 4].layer = 5; in[ 4].nslat = 43;
59 in[ 5].quad = 1; in[ 5].layer = 6; in[ 5].nslat = 34;
60 in[ 6].quad = 2; in[ 6].layer = 1; in[ 6].nslat = 0;
61 in[ 7].quad = 2; in[ 7].layer = 2; in[ 7].nslat = 0;
62 in[ 8].quad = 2; in[ 8].layer = 3; in[ 8].nslat = 14;
63 in[ 9].quad = 2; in[ 9].layer = 4; in[ 9].nslat = 25;
64 in[10].quad = 2; in[10].layer = 5; in[10].nslat = 43;
65 in[11].quad = 2; in[11].layer = 6; in[11].nslat = 34;
67 dbtable->
SetTable((
char*)&in, MAX_DB_INDEX);
68 if (yr.Contains(
"sim")) dbtable->setFlavor(
"sim");
69 mgr->storeDbTable(dbtable);
70 std::cout <<
"INFO: table saved to database" << std::endl;
75 if (option.Contains(
"readdb"))
77 std::cout <<
"INFO: Reading database" << std::endl;
78 gSystem->Unsetenv(
"DB_ACCESS_MODE");
83 dbMk->SetDateTime(date, time);
84 if (yr.Contains(
"ofl")) { dbMk->SetFlavor(
"ofl"); }
85 else if (yr.Contains(
"sim")) { dbMk->SetFlavor(
"sim"); }
90 DB = dbMk->GetDataBase(
"Geometry/fps/fpostChannelGeometry");
91 if (!DB) std::cout <<
"ERROR: no table found in db, or malformed local db config" << std::endl;
93 St_fpostChannelGeometry* dataset = 0;
94 dataset = (St_fpostChannelGeometry*) DB->
Find(
"fpostChannelGeometry");
95 if (!dataset) { std::cout <<
"ERROR: dataset does not contain requested table" << std::endl;
return; }
96 Int_t rows = dataset->GetNRows();
97 if (rows > 1) std::cout <<
"INFO: found INDEXED table with " << rows <<
" rows" << std::endl;
100 dbMk->GetValidity((
TTable*)dataset, val);
101 std::cout <<
"Dataset validity range: [ " << val[0].GetDate() <<
"." << val[0].GetTime() <<
" - "
102 << val[1].GetDate() <<
"." << val[1].GetTime() <<
" ] " << std::endl;
104 fpostChannelGeometry_st* table = (fpostChannelGeometry_st*)dataset->GetTable();
105 for (Int_t i = 0; i < rows; i++)
107 std::cout << Form(
"Row=%3d quad=%1d layer=%1d slat=%2d\n",
108 i, table[i].quad, table[i].layer, table[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