4 void fms_db_ChannelGeometry(
char* opt=
"readdb",
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";
30 std::cout <<
"Please specify year\n";
33 std::cout <<
"storetime =" << storeTime <<
"\n";
34 std::cout <<
"date,time =" << date <<
" "<< time <<
"\n";
36 gROOT->Macro(
"LoadLogger.C");
37 gSystem->Load(
"St_base.so");
38 gSystem->Load(
"libStDb_Tables.so");
39 gSystem->Load(
"StDbLib.so");
42 const Int_t MAXINDEX = 12;
46 fmsChannelGeometry_st g[MAXINDEX];
47 memset(g,0,
sizeof(g));
49 gSystem->Load(
"StChain");
50 gSystem->Load(
"StBFChain");
51 gSystem->Load(
"StUtilities");
52 gSystem->Load(
"StIOMaker");
53 gSystem->Load(
"StarClassLibrary");
54 gSystem->Load(
"St_Tables");
55 gSystem->Load(
"StDbLib");
56 gSystem->Load(
"StDbBroker");
57 gSystem->Load(
"St_db_Maker");
61 dbMk->SetDateTime(date,time);
62 dbMk->SetFlavor(
"ofl");
71 DB = dbMk->GetInputDB(
"Geometry/fms/");
72 if (!DB) { std::cout <<
"ERROR: no db maker?" << std::endl; }
74 if(option.Contains(
"readdb")){
75 gSystem->Unsetenv(
"DB_ACCESS_MODE");
76 gSystem->Unsetenv(
"DB_SERVER_LOCAL_CONFIG");
77 St_fmsChannelGeometry *db = 0;
78 db = (St_fmsChannelGeometry*) DB->
Find(
"fmsChannelGeometry");
81 std::cout <<
"Reading fmsMap table\n";
82 fmsChannelGeometry_st *table = db->GetTable();
84 memcpy(g,table,
sizeof(fmsChannelGeometry_st)*n);
86 std::cout <<
"WARNING: No data in fmsChannelGeometry table (wrong timestamp?). Nothing to return, then.\n";
90 if(option.Contains(
"writedb")) {
91 gSystem->Setenv(
"DB_ACCESS_MODE",
"write");
92 cout <<
"DB_ACCESS_MODE="<<gSystem->Getenv(
"DB_ACCESS_MODE")<<endl;
95 StDbTable* wtable = node->addDbTable(
"fmsChannelGeometry");
96 mgr->setStoreTime(storeTime.Data());
116 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++;
117 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++;
118 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++;
119 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++;
121 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++;
122 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++;
123 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++;
124 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++;
126 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++;
127 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++;
128 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++;
129 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++;
134 mgr->storeDbTable(wtable);
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