4 void fmsPositionModel_db(
char* opt=
"",
char* year=
"15sim") {
5 TString option(opt), yr(year);
9 std::cout <<
"year = " << year <<
"\n";
10 if(yr.Contains(
"15pp")){
11 storeTime=
"2014-12-20 00:00:00";
12 date = 20141225; time = 0;
14 }
else if(yr.Contains(
"15pA")){
15 storeTime=
"2015-05-05 12:00:00";
16 date = 20150506; time = 0;
18 }
else if(yr.Contains(
"15sim")){
19 storeTime=
"2014-12-10 00:00:00";
20 date = 20141215; time = 0;
21 }
else if(yr.Contains(
"17ofl")){
22 storeTime=
"2016-12-20 00:00:00";
23 date = 20161225; time = 0;
25 }
else if(yr.Contains(
"17sim")){
26 storeTime=
"2016-12-10 00:00:00";
27 date = 20161215; time = 0;
29 std::cout <<
"Please specify valid year tag\n"; exit;
31 std::cout <<
"Opt =" << opt <<
"\n";
32 std::cout <<
"writedb = " << option.Contains(
"write") <<
"\n";
33 std::cout <<
"storetime =" << storeTime <<
"\n";
34 std::cout <<
"date,time =" << date <<
" "<< time <<
"\n";
36 gROOT->Macro(
"loadlib.C");
38 fmsPositionModel_st table;
39 if(option.Contains(
"writedb")) {
40 gSystem->Setenv(
"DB_ACCESS_MODE",
"write");
43 StDbTable* dbtable = node->addDbTable(
"fmsPositionModel");
44 mgr->setStoreTime(storeTime.Data());
49 if(yr.Contains(
"sim")) dbtable->setFlavor(
"sim");
50 mgr->storeDbTable(dbtable);
51 std::cout <<
"INFO: table saved to database" << std::endl;
54 std::cout <<
"INFO: Reading database" << std::endl;
55 gSystem->Unsetenv(
"DB_ACCESS_MODE");
59 dbMk->SetDateTime(date,time);
60 if(yr.Contains(
"ofl")) {dbMk->SetFlavor(
"ofl");}
61 else if(yr.Contains(
"sim")) {dbMk->SetFlavor(
"sim");}
65 DB = dbMk->GetDataBase(
"Geometry/fms/fmsPositionModel");
66 if (!DB) std::cout <<
"ERROR: no table found in db, or malformed local db config" << std::endl;
67 St_fmsPositionModel *dataset = 0;
68 dataset = (St_fmsPositionModel*) DB->
Find(
"fmsPositionModel");
70 td::cout <<
"ERROR: dataset does not contain requested table" << std::endl;
73 Int_t rows = dataset->GetNRows();
75 std::cout <<
"INFO: found INDEXED table with " << rows <<
" rows" << std::endl;
78 dbMk->GetValidity((
TTable*)dataset,val);
79 std::cout <<
"Dataset validity range: [ " << val[0].GetDate() <<
"." << val[0].GetTime() <<
" - "
80 << val[1].GetDate() <<
"." << val[1].GetTime() <<
" ] "
82 fmsPositionModel_st *tbl = dataset->GetTable();
83 for (Int_t i = 0; i < rows; i++) {
84 std::cout << Form(
"Row=%d Model=%d\n",i,tbl[i].model);
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