10 void fPostConstant_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");
45 if (option.Contains(
"writedb"))
47 gSystem->Setenv(
"DB_ACCESS_MODE",
"write");
50 StDbTable* dbtable = node->addDbTable(
"fpostConstant");
51 mgr->setStoreTime(storeTime.Data());
60 if (yr.Contains(
"sim")) dbtable->setFlavor(
"sim");
61 mgr->storeDbTable(dbtable);
62 std::cout <<
"INFO: table saved to database" << std::endl;
67 if (option.Contains(
"readdb"))
69 std::cout <<
"INFO: Reading database" << std::endl;
70 gSystem->Unsetenv(
"DB_ACCESS_MODE");
75 dbMk->SetDateTime(date, time);
76 if (yr.Contains(
"ofl")) { dbMk->SetFlavor(
"ofl"); }
77 else if (yr.Contains(
"sim")) { dbMk->SetFlavor(
"sim"); }
82 DB = dbMk->GetDataBase(
"Geometry/fps/fpostConstant");
83 if (!DB) std::cout <<
"ERROR: no table found in db, or malformed local db config" << std::endl;
85 St_fpostConstant *dataset = 0;
86 dataset = (St_fpostConstant*) DB->
Find(
"fpostConstant");
87 if (!dataset) { std::cout <<
"ERROR: dataset does not contain requested table" << std::endl;
return; }
88 Int_t rows = dataset->GetNRows();
89 if (rows > 1) std::cout <<
"INFO: found INDEXED table with " << rows <<
" rows" << std::endl;
92 dbMk->GetValidity((
TTable*)dataset, val);
93 std::cout <<
"Dataset validity range: [ " << val[0].GetDate() <<
"." << val[0].GetTime() <<
" - "
94 << val[1].GetDate() <<
"." << val[1].GetTime() <<
" ] " << std::endl;
96 fpostConstant_st *table = (fpostConstant_st*)dataset->GetTable();
97 for (Int_t i = 0; i < rows; i++)
99 std::cout << Form(
"Row=%d nQuad=%1d nLayer=%1d maxSlat=%2d maxQTaddr=%1d maxQTch=%2d\n",
100 i, table[i].nQuad, table[i].nLayer, table[i].maxSlat, table[i].maxQTaddr, table[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