4 void fms_db_ChannelGeometry_akio(
char* opt=
"writedb",
int year=15) {
7 std::cout <<
"Opt =" << opt <<
"\n";
8 std::cout <<
"readdb = " << option.Contains(
"readdb") <<
"\n";
9 std::cout <<
"writedb = " << option.Contains(
"writedb") <<
"\n";
14 std::cout <<
"year = " << year <<
"\n";
16 storeTime=
"2007-11-09 00:00:02";
20 storeTime=
"2008-11-09 00:00:01";
24 storeTime=
"2014-12-20 00:00:00";
28 std::cout <<
"Please specify year\n";
31 std::cout <<
"storetime =" << storeTime <<
"\n";
32 std::cout <<
"date,time =" << date <<
" "<< time <<
"\n";
34 gROOT->Macro(
"LoadLogger.C");
35 gSystem->Load(
"St_base.so");
36 gSystem->Load(
"libStDb_Tables.so");
37 gSystem->Load(
"StDbLib.so");
40 const Int_t MAXINDEX = 20;
44 fmsChannelGeometry_st g[MAXINDEX];
45 memset(g,0,
sizeof(g));
47 gSystem->Load(
"StChain");
48 gSystem->Load(
"StBFChain");
49 gSystem->Load(
"StUtilities");
50 gSystem->Load(
"StIOMaker");
51 gSystem->Load(
"StarClassLibrary");
52 gSystem->Load(
"St_Tables");
53 gSystem->Load(
"StDbLib");
54 gSystem->Load(
"StDbBroker");
55 gSystem->Load(
"St_db_Maker");
59 dbMk->SetDateTime(date,time);
60 dbMk->SetFlavor(
"ofl");
69 DB = dbMk->GetInputDB(
"Geometry/fms/");
70 if (!DB) { std::cout <<
"ERROR: no db maker?" << std::endl; }
72 if(option.Contains(
"readdb")){
73 gSystem->Unsetenv(
"DB_ACCESS_MODE");
74 gSystem->Unsetenv(
"DB_SERVER_LOCAL_CONFIG");
75 St_fmsChannelGeometry *db = 0;
76 db = (St_fmsChannelGeometry*) DB->
Find(
"fmsChannelGeometry");
79 std::cout <<
"Reading fmsMap table\n";
80 fmsChannelGeometry_st *table = db->GetTable();
82 memcpy(g,table,
sizeof(fmsChannelGeometry_st)*n);
84 std::cout <<
"WARNING: No data in fmsChannelGeometry table (wrong timestamp?). Nothing to return, then.\n";
88 if(option.Contains(
"writedb")) {
89 gSystem->Setenv(
"DB_ACCESS_MODE",
"write");
90 cout <<
"DB_ACCESS_MODE="<<gSystem->Getenv(
"DB_ACCESS_MODE")<<endl;
93 StDbTable* table = node->addDbTable(
"fmsChannelGeometry");
94 mgr->setStoreTime(storeTime.Data());
115 g[n].detectorId = 0; g[n].type=0; g[n].ew=0; g[n].ns=0; g[n].nX= 7; g[n].nY= 7; n++;
116 g[n].detectorId = 1; g[n].type=0; g[n].ew=0; g[n].ns=1; g[n].nX= 7; g[n].nY= 7; n++;
117 g[n].detectorId = 2; g[n].type=1; g[n].ew=0; g[n].ns=0; g[n].nX= 7; g[n].nY= 1; n++;
118 g[n].detectorId = 3; g[n].type=1; g[n].ew=0; g[n].ns=1; g[n].nX= 7; g[n].nY= 1; n++;
120 g[n].detectorId = 4; g[n].type=2; g[n].ew=0; g[n].ns=0; g[n].nX=48; g[n].nY= 1; n++;
121 g[n].detectorId = 5; g[n].type=2; g[n].ew=0; g[n].ns=1; g[n].nX=48; g[n].nY= 1; n++;
122 g[n].detectorId = 6; g[n].type=3; g[n].ew=0; g[n].ns=0; g[n].nX= 1; g[n].nY=48; n++;
123 g[n].detectorId = 7; g[n].type=3; g[n].ew=0; g[n].ns=1; g[n].nX= 1; g[n].nY=48; n++;
125 g[n].detectorId = 8; g[n].type=4; g[n].ew=1; g[n].ns=0; g[n].nX=17; g[n].nY=34; n++;
126 g[n].detectorId = 9; g[n].type=4; g[n].ew=1; g[n].ns=1; g[n].nX=17; g[n].nY=34; n++;
127 g[n].detectorId =10; g[n].type=0; g[n].ew=1; g[n].ns=0; g[n].nX=12; g[n].nY=24; n++;
128 g[n].detectorId =11; g[n].type=0; g[n].ew=1; g[n].ns=1; g[n].nX=12; g[n].nY=24; n++;
129 g[n].detectorId =15; g[n].type=6; g[n].ew=1; g[n].ns=0; g[n].nX= 0; g[n].nY= 0; n++;
134 mgr->storeDbTable(table);
135 gSystem->Unsetenv(
"DB_ACCESS_MODE");
136 std::cout <<
"Done with database upload \n";
139 printf(
"n = %d\n",n);
140 printf(
" Id Typ ew ns nX nY\n");
141 for(
int i=0; i<n; i++){
142 printf(
"%3d %3d %3d %3d %3d %3d\n",g[i].detectorId,g[i].type,g[i].ew,g[i].ns,g[i].nX,g[i].nY);
virtual void SetTable(char *data, int nrows, int *idList=0)
calloc'd version of data for StRoot
virtual Long_t GetNRows() const
Returns the number of the used rows for the wrapped table.
static StDbManager * Instance()
strdup(..) is not ANSI
virtual TDataSet * Find(const char *path) const