4 void fpsGain_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 = 20141225; time = 0;
12 }
else if(yr.Contains(
"15sim")){
13 storeTime=
"2014-12-10 00:00:02";
14 date = 20141215; time = 0;
16 std::cout <<
"Please specify valid year tag\n"; exit;
18 std::cout <<
"Opt =" << opt <<
"\n";
19 std::cout <<
"write = " << option.Contains(
"writedb") <<
"\n";
20 std::cout <<
"storetime =" << storeTime <<
"\n";
21 std::cout <<
"date,time =" << date <<
" "<< time <<
"\n";
23 gROOT->Macro(
"loadlib.C");
25 const Int_t MAX_DB_INDEX = 252;
26 fpsGain_st table[MAX_DB_INDEX];
28 if(option.Contains(
"writedb")) {
29 gSystem->Setenv(
"DB_ACCESS_MODE",
"write");
32 StDbTable* dbtable = node->addDbTable(
"fpsGain");
33 mgr->setStoreTime(storeTime.Data());
36 for (Int_t q = 1; q <= 4; q++) {
37 for (Int_t l = 1; l <= 3; l++) {
38 for (Int_t s = 1; s <= 21; s++) {
39 table[id].slatid = id;
46 if(flag==0){table[id].slatid = id; table[id].MIP=mip;}
47 else {table[id].slatid = id; table[id].MIP=0;}
48 printf(
"id=%3d Q%1dL%1dS%2d mip=%f\n",
id,q,l,s,table[
id].MIP);
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(
"Calibrations/fps/fpsGain");
72 if (!DB) std::cout <<
"ERROR: no table found in db, or malformed local db config" << std::endl;
73 St_fpsGain *dataset = 0;
74 dataset = (St_fpsGain*) DB->
Find(
"fpsGain");
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 fpsGain_st *tbl = dataset->GetTable();
89 for (Int_t i = 0; i < rows; i++) {
90 std::cout << Form(
"Row=%4d slatid=%3d MIP=%8.4f\n",i,
91 tbl[i].slatid,tbl[i].MIP);
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