35 |
printf("\n -host name for the host [default = mysql://localhost/pamelaprod]\n"); |
printf("\n -host name for the host [default = mysql://localhost/pamelaprod]\n"); |
36 |
printf("\n -user username for the DB [default = anonymous] \n"); |
printf("\n -user username for the DB [default = anonymous] \n"); |
37 |
printf("\n -psw password for the DB [default = \"\"]\n"); |
printf("\n -psw password for the DB [default = \"\"]\n"); |
38 |
|
printf("\n -convert [ -tzone timezone -dbtime dbtime ] \n"); |
39 |
|
printf("\n convert the dbtime given in seconds (from the DB) to a string for\n"); |
40 |
|
printf("\n the given time zone (UTC,GMT,MSK,MSD,CET,CEST are accepted) \n"); |
41 |
|
printf("\n -runat \"yyyy-mm-dd hh:mm:ss\" \n"); |
42 |
|
printf("\n returns run number which contain the given date in MSK (if any)\n"); |
43 |
printf("\nExamples: \n"); |
printf("\nExamples: \n"); |
44 |
printf("\n R2-D2 -idRun 1085 \n"); |
printf("\n R2-D2 -idRun 1085 \n"); |
45 |
printf("\n R2-D2 -filename DW_050208_00900.root \n"); |
printf("\n R2-D2 -filename DW_050208_00900.root \n"); |
53 |
// Variables booking |
// Variables booking |
54 |
// |
// |
55 |
TString message; |
TString message; |
|
int nul = 0; |
|
56 |
Int_t error = 0; |
Int_t error = 0; |
57 |
// |
// |
58 |
ULong64_t run = 0ULL; |
UInt_t run = 0ULL; |
59 |
// |
// |
60 |
TString filename = ""; |
TString filename = ""; |
61 |
// |
// |
63 |
TString host = "mysql://localhost/pamelaprod"; |
TString host = "mysql://localhost/pamelaprod"; |
64 |
TString user = "anonymous"; |
TString user = "anonymous"; |
65 |
TString psw = ""; |
TString psw = ""; |
66 |
|
TString tzone = "MSK"; |
67 |
|
TString runtime = "1970-01-01 00:00:00"; |
68 |
|
UInt_t dbti = 0; |
69 |
|
Bool_t convert = false; |
70 |
|
Bool_t ruti = false; |
71 |
// |
// |
72 |
// |
// |
73 |
// Checking input parameters |
// Checking input parameters |
88 |
r2d2usage(); |
r2d2usage(); |
89 |
exit(-3); |
exit(-3); |
90 |
}; |
}; |
91 |
char *pEnd; |
run = (UInt_t)atoll(inps[i+1]); |
|
run = strtoull(inps[i+1],&pEnd,0); |
|
92 |
}; |
}; |
93 |
if ( !strcmp(inps[i],"-filename") ) { |
if ( !strcmp(inps[i],"-filename") ) { |
94 |
if ( numinp-1 < i+1 ){ |
if ( numinp-1 < i+1 ){ |
118 |
}; |
}; |
119 |
psw = (TString)inps[i+1]; |
psw = (TString)inps[i+1]; |
120 |
}; |
}; |
121 |
|
// |
122 |
|
if ( !strcmp(inps[i],"-runat") ) { |
123 |
|
ruti = true; |
124 |
|
if ( numinp-1 < i+1 ){ |
125 |
|
r2d2usage(); |
126 |
|
exit(-3); |
127 |
|
}; |
128 |
|
runtime = (TString)inps[i+1]; |
129 |
|
}; |
130 |
|
// |
131 |
|
if ( !strcmp(inps[i],"-convert") ) { |
132 |
|
convert = true; |
133 |
|
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
134 |
|
if ( numinp < i+2 ){ |
135 |
|
r2d2usage(); |
136 |
|
throw -3; |
137 |
|
}; |
138 |
|
i += 2; |
139 |
|
while ( strcmp(inps[i],"]") ){ |
140 |
|
if ( !strcmp(inps[i],"-tzone") ) { |
141 |
|
if ( numinp-1 < i+1 ){ |
142 |
|
r2d2usage(); |
143 |
|
exit(-3); |
144 |
|
}; |
145 |
|
tzone = (TString)inps[i+1]; |
146 |
|
}; |
147 |
|
if ( !strcmp(inps[i],"-dbtime") ) { |
148 |
|
if ( numinp-1 < i+1 ){ |
149 |
|
r2d2usage(); |
150 |
|
exit(-3); |
151 |
|
}; |
152 |
|
dbti = (UInt_t)atoll(inps[i+1]); |
153 |
|
}; |
154 |
|
i++; |
155 |
|
if ( i > numinp-1 ){ |
156 |
|
r2d2usage(); |
157 |
|
throw -3; |
158 |
|
}; |
159 |
|
}; |
160 |
|
}; |
161 |
|
}; |
162 |
|
// |
163 |
i++; |
i++; |
164 |
}; |
}; |
165 |
// |
// |
185 |
// |
// |
186 |
GL_ROOT *glroot = new GL_ROOT(); |
GL_ROOT *glroot = new GL_ROOT(); |
187 |
GL_RUN *glrun = new GL_RUN(); |
GL_RUN *glrun = new GL_RUN(); |
188 |
|
GL_TIMESYNC *dbtime = new GL_TIMESYNC(); |
189 |
|
// |
190 |
|
// At which date correspond the DB time "dbti"? |
191 |
|
// |
192 |
|
if ( convert ){ |
193 |
|
printf("\n Time %u is %s %s \n",dbti,dbtime->ConvertTime(tzone.Data(),dbti).Data(),tzone.Data()); |
194 |
|
}; |
195 |
// |
// |
196 |
if ( run != 0ULL ){ |
// Which run contains the date "runtime"? |
197 |
|
// |
198 |
|
if ( ruti ){ |
199 |
|
|
200 |
|
}; |
201 |
|
// |
202 |
|
// To which file the run "run" belongs? |
203 |
|
// |
204 |
|
if ( run != 0 ){ |
205 |
|
glrun->Clear(); |
206 |
error = glrun->Query_GL_RUN(run,dbc); |
error = glrun->Query_GL_RUN(run,dbc); |
207 |
error = glroot->Query_GL_ROOT(glrun->ID_REG_RUN,dbc); |
glroot->Clear(); |
208 |
|
error = glroot->Query_GL_ROOT(glrun->ID_ROOT_L0,dbc); |
209 |
if ( error ){ |
if ( error ){ |
210 |
printf(" Error querying the DB! \n"); |
printf(" Error querying the DB! \n"); |
211 |
exit(-4); |
exit(-4); |
212 |
}; |
}; |
213 |
printf("\n Run %llu belongs to file %s \n",run,(glroot->PATH+glroot->NAME).Data()); |
if ( !glrun->ID ){ |
214 |
|
printf("\n No run with ID=%u in the DB!\n",run); |
215 |
|
} else { |
216 |
|
printf("\n Run %u belongs to file %s \n",run,(glroot->PATH+glroot->NAME).Data()); |
217 |
|
}; |
218 |
}; |
}; |
219 |
|
// |
220 |
|
// Which runs are contained in the file "filename"? |
221 |
|
// |
222 |
if ( strcmp(filename.Data(),"") ){ |
if ( strcmp(filename.Data(),"") ){ |
223 |
TSQLResult *pResult; |
TSQLResult *pResult; |
224 |
TSQLRow *Row; |
TSQLRow *Row; |
229 |
Int_t ID = 0; |
Int_t ID = 0; |
230 |
Int_t ID_RAW = 0; |
Int_t ID_RAW = 0; |
231 |
// |
// |
232 |
const char *rawpath; |
const char *rawpath = ""; |
233 |
const char *rawname; |
const char *rawname = ""; |
234 |
// |
// |
235 |
myquery.str(""); |
myquery.str(""); |
236 |
myquery << "select "; |
myquery << "select "; |
250 |
}; |
}; |
251 |
}; |
}; |
252 |
delete pResult; |
delete pResult; |
253 |
printf("\n File %s contains the following runs: \n",filename.Data()); |
if ( !ID && !ID_RAW ){ |
254 |
myquery.str(""); |
printf("\n No file with name %s in the DB!\n",filename.Data()); |
255 |
myquery << "select "; |
} else { |
256 |
myquery << " ID"; |
myquery.str(""); |
257 |
myquery << " from GL_RUN where ID_REG_RUN=" << ID << ";"; |
myquery << "select "; |
258 |
pResult = dbc->Query(myquery.str().c_str()); |
myquery << " ID,RUNHEADER_TIME,RUNTRAILER_TIME "; |
259 |
if(!pResult->GetRowCount()) return (-51); |
myquery << " from GL_RUN where ID_ROOT_L0=" << ID << ";"; |
260 |
for( r=0; r < 1000; r++){ |
pResult = dbc->Query(myquery.str().c_str()); |
261 |
Row = pResult->Next(); |
if(!pResult->GetRowCount()) return (-51); |
262 |
if( Row == NULL ) break; |
for( r=0; r < 1000; r++){ |
263 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
Row = pResult->Next(); |
264 |
if (t==0) printf(" => %i \n",atoi(Row->GetField(t))); |
if ( !r && !Row ){ |
265 |
|
printf(" No run associated to the file %s \n",filename.Data()); |
266 |
|
}; |
267 |
|
if( Row == NULL ) break; |
268 |
|
if ( !r ) printf("\n File %s contains the following runs: \n",filename.Data()); |
269 |
|
printf(" => %i -> Start at %s UTC end at %s UTC \n",(UInt_t)atoll(Row->GetField(0)),dbtime->ConvertTime("UTC",(UInt_t)atoll(Row->GetField(1))).Data(),dbtime->ConvertTime("UTC",(UInt_t)atoll(Row->GetField(2))).Data()); |
270 |
}; |
}; |
271 |
}; |
delete pResult; |
272 |
delete pResult; |
myquery.str(""); |
273 |
myquery.str(""); |
myquery << "select "; |
274 |
myquery << "select "; |
myquery << " PATH,NAME"; |
275 |
myquery << " PATH,NAME"; |
myquery << " from GL_RAW where ID=" << ID_RAW << ";"; |
276 |
myquery << " from GL_RAW where ID=" << ID_RAW << ";"; |
pResult = dbc->Query(myquery.str().c_str()); |
277 |
pResult = dbc->Query(myquery.str().c_str()); |
if(!pResult->GetRowCount()) return (-51); |
278 |
if(!pResult->GetRowCount()) return (-51); |
for( r=0; r < 1000; r++){ |
279 |
for( r=0; r < 1000; r++){ |
Row = pResult->Next(); |
280 |
Row = pResult->Next(); |
if( Row == NULL ) break; |
281 |
if( Row == NULL ) break; |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
282 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
if(t==0) rawpath = Row->GetField(t); |
283 |
if(t==0) rawpath = Row->GetField(t); |
if(t==1) rawname = Row->GetField(t); |
284 |
if(t==1) rawname = Row->GetField(t); |
}; |
285 |
}; |
}; |
286 |
|
delete pResult; |
287 |
|
printf(" File %s belongs to raw data file %s/%s \n",filename.Data(),rawpath,rawname); |
288 |
}; |
}; |
|
delete pResult; |
|
|
printf(" and belongs to raw data file %s/%s \n",rawpath,rawname); |
|
289 |
}; |
}; |
290 |
// |
// |
291 |
// Close the DB connection |
// Close the DB connection |