4 void fcsDetectorPosition_db(
char* opt =
"",
char* input) {
5 gROOT->Macro(
"LoadLogger.C");
6 gSystem->Load(
"St_base.so");
7 gSystem->Load(
"libStDb_Tables.so");
8 gSystem->Load(
"StDbLib.so");
11 fcsDetectorPosition_st detpos;
14 std::cout <<
"Opt =" << opt <<
"\n";
15 std::cout <<
"writedb = " << option.Contains(
"writedb") <<
"\n";
18 TString storeTime(
"");
20 if(
data.Contains(
"run21sim")){
21 storeTime =
"2020-12-10 00:01:00"; flavor=
"sim";
22 detpos.xoff[0]=-6.570*2.54; detpos.yoff[0]=0.0; detpos.zoff[0]=279.592*2.54;
23 detpos.xoff[1]= 6.570*2.54; detpos.yoff[1]=0.0; detpos.zoff[1]=279.592*2.54;
24 detpos.xoff[2]=-7.430*2.54; detpos.yoff[2]=0.0; detpos.zoff[2]=308.123*2.54;
25 detpos.xoff[3]= 7.430*2.54; detpos.yoff[3]=0.0; detpos.zoff[3]=308.123*2.54;
27 if(
data.Contains(
"run21ofl")){
28 storeTime =
"2020-12-20 00:00:00"; flavor=
"ofl";
29 detpos.xoff[0]=-6.570*2.54-50; detpos.yoff[0]=0.0; detpos.zoff[0]=279.592*2.54;
30 detpos.xoff[1]= 6.570*2.54+50; detpos.yoff[1]=0.0; detpos.zoff[1]=279.592*2.54;
31 detpos.xoff[2]=-7.430*2.54-50; detpos.yoff[2]=0.0; detpos.zoff[2]=308.123*2.54;
32 detpos.xoff[3]= 7.430*2.54+50; detpos.yoff[3]=0.0; detpos.zoff[3]=308.123*2.54;
34 if(
data.Contains(
"run21Feb17")){
35 storeTime =
"2021-02-17 18:00:00"; flavor=
"ofl";
36 detpos.xoff[0]=-6.850*2.54; detpos.yoff[0]=0.0; detpos.zoff[0]=279.592*2.54;
37 detpos.xoff[1]= 6.850*2.54; detpos.yoff[1]=0.0; detpos.zoff[1]=279.592*2.54;
38 detpos.xoff[2]=-8.380*2.54; detpos.yoff[2]=0.0; detpos.zoff[2]=308.123*2.54;
39 detpos.xoff[3]= 8.380*2.54; detpos.yoff[3]=0.0; detpos.zoff[3]=308.123*2.54;
41 if(
data.Contains(
"run21Mar31")){
42 storeTime =
"2021-03-31 18:00:00"; flavor=
"ofl";
43 detpos.xoff[0]=-6.850*2.54-50; detpos.yoff[0]=0.0; detpos.zoff[0]=279.592*2.54;
44 detpos.xoff[1]= 6.850*2.54+50; detpos.yoff[1]=0.0; detpos.zoff[1]=279.592*2.54;
45 detpos.xoff[2]=-8.380*2.54-50; detpos.yoff[2]=0.0; detpos.zoff[2]=308.123*2.54;
46 detpos.xoff[3]= 8.380*2.54+50; detpos.yoff[3]=0.0; detpos.zoff[3]=308.123*2.54;
48 if(
data.Contains(
"run21May06")){
49 storeTime =
"2021-05-06 20:00:00"; flavor=
"ofl";
50 detpos.xoff[0]=-6.850*2.54; detpos.yoff[0]=0.0; detpos.zoff[0]=279.592*2.54;
51 detpos.xoff[1]= 6.850*2.54; detpos.yoff[1]=0.0; detpos.zoff[1]=279.592*2.54;
52 detpos.xoff[2]=-8.380*2.54; detpos.yoff[2]=0.0; detpos.zoff[2]=308.123*2.54;
53 detpos.xoff[3]= 8.380*2.54; detpos.yoff[3]=0.0; detpos.zoff[3]=308.123*2.54;
55 if(
data.Contains(
"run21May20")){
56 storeTime =
"2021-05-20 18:00:00"; flavor=
"ofl";
57 detpos.xoff[0]=-6.850*2.54-50; detpos.yoff[0]=0.0; detpos.zoff[0]=279.592*2.54;
58 detpos.xoff[1]= 6.850*2.54+50; detpos.yoff[1]=0.0; detpos.zoff[1]=279.592*2.54;
59 detpos.xoff[2]=-8.380*2.54; detpos.yoff[2]=0.0; detpos.zoff[2]=308.123*2.54;
60 detpos.xoff[3]= 8.380*2.54; detpos.yoff[3]=0.0; detpos.zoff[3]=308.123*2.54;
62 if(
data.Contains(
"run21May24")){
63 storeTime =
"2021-05-24 15:00:00"; flavor=
"ofl";
64 detpos.xoff[0]=-6.850*2.54-50; detpos.yoff[0]=0.0; detpos.zoff[0]=279.592*2.54;
65 detpos.xoff[1]= 6.850*2.54+50; detpos.yoff[1]=0.0; detpos.zoff[1]=279.592*2.54;
66 detpos.xoff[2]=-8.380*2.54-50; detpos.yoff[2]=0.0; detpos.zoff[2]=308.123*2.54;
67 detpos.xoff[3]= 8.380*2.54+50; detpos.yoff[3]=0.0; detpos.zoff[3]=308.123*2.54;
69 if(
data.Contains(
"run21Jun27")){
70 storeTime =
"2021-06-27 15:00:00"; flavor=
"ofl";
71 detpos.xoff[0]=-6.850*2.54; detpos.yoff[0]=0.0; detpos.zoff[0]=279.592*2.54;
72 detpos.xoff[1]= 6.850*2.54; detpos.yoff[1]=0.0; detpos.zoff[1]=279.592*2.54;
73 detpos.xoff[2]=-8.380*2.54; detpos.yoff[2]=0.0; detpos.zoff[2]=308.123*2.54;
74 detpos.xoff[3]= 8.380*2.54; detpos.yoff[3]=0.0; detpos.zoff[3]=308.123*2.54;
76 if(
data.Contains(
"run22sim")){
77 storeTime =
"2021-10-15 00:00:00"; flavor=
"sim";
78 detpos.xoff[0]=-6.850*2.54; detpos.yoff[0]=0.0; detpos.zoff[0]=279.592*2.54;
79 detpos.xoff[1]= 6.850*2.54; detpos.yoff[1]=0.0; detpos.zoff[1]=279.592*2.54;
80 detpos.xoff[2]=-8.380*2.54; detpos.yoff[2]=0.0; detpos.zoff[2]=308.123*2.54;
81 detpos.xoff[3]= 8.380*2.54; detpos.yoff[3]=0.0; detpos.zoff[3]=308.123*2.54;
83 if(
data.Contains(
"run22simA")){
84 storeTime =
"2021-10-15 00:01:00"; flavor=
"sim";
85 detpos.xoff[0]=-6.850*2.54; detpos.yoff[0]=-5.26; detpos.zoff[0]=279.592*2.54;
86 detpos.xoff[1]= 6.850*2.54; detpos.yoff[1]=-5.26; detpos.zoff[1]=279.592*2.54;
87 detpos.xoff[2]=-8.380*2.54; detpos.yoff[2]=+1.80; detpos.zoff[2]=308.123*2.54;
88 detpos.xoff[3]= 8.380*2.54; detpos.yoff[3]=+1.80; detpos.zoff[3]=308.123*2.54;
90 if(
data.Contains(
"run22ofl")){
91 storeTime =
"2021-10-25 00:00:00"; flavor=
"ofl";
92 detpos.xoff[0]=-6.850*2.54; detpos.yoff[0]=0.0; detpos.zoff[0]=279.592*2.54;
93 detpos.xoff[1]= 6.850*2.54; detpos.yoff[1]=0.0; detpos.zoff[1]=279.592*2.54;
94 detpos.xoff[2]=-8.380*2.54; detpos.yoff[2]=0.0; detpos.zoff[2]=308.123*2.54;
95 detpos.xoff[3]= 8.380*2.54; detpos.yoff[3]=0.0; detpos.zoff[3]=308.123*2.54;
97 if(
data.Contains(
"run22oflA")){
98 storeTime =
"2021-10-25 00:01:00"; flavor=
"ofl";
99 detpos.xoff[0]=-6.850*2.54; detpos.yoff[0]=-5.26; detpos.zoff[0]=279.592*2.54;
100 detpos.xoff[1]= 6.850*2.54; detpos.yoff[1]=-5.26; detpos.zoff[1]=279.592*2.54;
101 detpos.xoff[2]=-8.380*2.54; detpos.yoff[2]=+1.80; detpos.zoff[2]=308.123*2.54;
102 detpos.xoff[3]= 8.380*2.54; detpos.yoff[3]=+1.80; detpos.zoff[3]=308.123*2.54;
104 if(
data.Contains(
"run22Dec01")){
105 storeTime =
"2021-12-01 00:00:00"; flavor=
"ofl";
106 detpos.xoff[0]=-6.850*2.54-50; detpos.yoff[0]=0.0; detpos.zoff[0]=279.592*2.54;
107 detpos.xoff[1]= 6.850*2.54+50; detpos.yoff[1]=0.0; detpos.zoff[1]=279.592*2.54;
108 detpos.xoff[2]=-8.380*2.54-50; detpos.yoff[2]=0.0; detpos.zoff[2]=308.123*2.54;
109 detpos.xoff[3]= 8.380*2.54+50; detpos.yoff[3]=0.0; detpos.zoff[3]=308.123*2.54;
111 if(
data.Contains(
"run22Dec01A")){
112 storeTime =
"2021-12-01 00:01:00"; flavor=
"ofl";
113 detpos.xoff[0]=-6.850*2.54-50; detpos.yoff[0]=-5.26; detpos.zoff[0]=279.592*2.54;
114 detpos.xoff[1]= 6.850*2.54+50; detpos.yoff[1]=-5.26; detpos.zoff[1]=279.592*2.54;
115 detpos.xoff[2]=-8.380*2.54-50; detpos.yoff[2]=+1.80; detpos.zoff[2]=308.123*2.54;
116 detpos.xoff[3]= 8.380*2.54+50; detpos.yoff[3]=+1.80; detpos.zoff[3]=308.123*2.54;
118 if(
data.Contains(
"run22Dec20")){
119 storeTime =
"2021-12-20 16:30:00"; flavor=
"ofl";
120 detpos.xoff[0]=-6.850*2.54; detpos.yoff[0]=0.0; detpos.zoff[0]=279.592*2.54;
121 detpos.xoff[1]= 6.850*2.54; detpos.yoff[1]=0.0; detpos.zoff[1]=279.592*2.54;
122 detpos.xoff[2]=-8.380*2.54; detpos.yoff[2]=0.0; detpos.zoff[2]=308.123*2.54;
123 detpos.xoff[3]= 8.380*2.54; detpos.yoff[3]=0.0; detpos.zoff[3]=308.123*2.54;
125 if(
data.Contains(
"run22Dec20A")){
126 storeTime =
"2021-12-20 16:30:10"; flavor=
"ofl";
127 detpos.xoff[0]=-6.850*2.54; detpos.yoff[0]=-5.26; detpos.zoff[0]=279.592*2.54;
128 detpos.xoff[1]= 6.850*2.54; detpos.yoff[1]=-5.26; detpos.zoff[1]=279.592*2.54;
129 detpos.xoff[2]=-8.380*2.54; detpos.yoff[2]=+1.80; detpos.zoff[2]=308.123*2.54;
130 detpos.xoff[3]= 8.380*2.54; detpos.yoff[3]=+1.80; detpos.zoff[3]=308.123*2.54;
134 std::cout<<
"Invalid year range"<<std::endl;
137 std::cout <<
"StoreTime="<<storeTime<<endl;
138 std::cout <<
"Flavor ="<<flavor<<endl;
139 for(
int det=0; det<4; det++){
140 printf(
"INPUT det=%2d xoff=%8.3f yoff=%8.3f zoff=%8.3f\n",
141 det,detpos.xoff[det],detpos.yoff[det],detpos.zoff[det]);
144 if(option.Contains(
"writedb")) {
145 gSystem->Setenv(
"DB_ACCESS_MODE",
"write");
146 cout <<
"DB_ACCESS_MODE="<<gSystem->Getenv(
"DB_ACCESS_MODE")<<endl;
149 StDbTable* table = node->addDbTable(
"fcsDetectorPosition");
150 mgr->setStoreTime(storeTime.Data());
152 table->setFlavor(flavor.Data());
153 mgr->storeDbTable(table);
154 gSystem->Unsetenv(
"DB_ACCESS_MODE");
155 std::cout <<
"Done with database upload \n";
158 gSystem->Load(
"StChain");
159 gSystem->Load(
"StBFChain");
160 gSystem->Load(
"StUtilities");
161 gSystem->Load(
"StIOMaker");
162 gSystem->Load(
"StarClassLibrary");
163 gSystem->Load(
"St_Tables");
164 gSystem->Load(
"StDbLib");
165 gSystem->Load(
"StDbBroker");
166 gSystem->Load(
"St_db_Maker");
168 int date,time,from=0,n=0;
169 TString datetime(storeTime),token;
170 datetime.ReplaceAll(
"-",
"");
171 datetime.ReplaceAll(
":",
"");
172 while(datetime.Tokenize(token,from,
" ")){
173 if(n==0) date=atoi(token.Data());
174 if(n==1) time=atoi(token.Data());
177 std::cout <<
"Readout time="<<datetime<<
" Date="<<date<<
" Time="<<time<<endl;
181 dbMk->SetDateTime(date,time);
182 dbMk->SetFlavor(flavor.Data());
187 DB = dbMk->GetInputDB(
"Geometry/fcs");
188 if(!DB){std::cout <<
"ERROR: no db maker or Geometry/fcs" << std::endl; }
189 St_fcsDetectorPosition *
dbTable = (St_fcsDetectorPosition*) DB->
Find(
"fcsDetectorPosition");
191 std::cout <<
"Reading fcsDetectorPosition table from DB\n";
192 fcsDetectorPosition_st *dbSt = dbTable->GetTable();
193 Int_t rows = dbTable->GetNRows();
194 for(
int i=0; i<rows; i++){
195 for(
int det=0; det<4; det++){
196 printf(
"DbRead row=%2d det=%2d xoff=%8.3f yoff=%8.3f zoff=%8.3f\n",
197 i,det,dbSt[i].xoff[det],dbSt[i].yoff[det],dbSt[i].zoff[det]);
200 memcpy(detpos,dbSt,
sizeof(detpos));
202 std::cout <<
"WARNING: No data in fcsDetectorPosition table\n";
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