38 |
printf("\n -convert [ -tzone timezone -dbtime dbtime ] \n"); |
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"); |
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"); |
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"); |
printf("\n -runat [ -tzone timezone -time \"yyyy-mm-dd hh:mm:ss\" ] \n"); |
42 |
printf("\n returns run number which contain the given date in MSK (if any)\n"); |
printf("\n returns run number which contains the given date in the given time zone \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"); |
64 |
TString user = "anonymous"; |
TString user = "anonymous"; |
65 |
TString psw = ""; |
TString psw = ""; |
66 |
TString tzone = "MSK"; |
TString tzone = "MSK"; |
67 |
|
TString tzone2 = "MSK"; |
68 |
TString runtime = "1970-01-01 00:00:00"; |
TString runtime = "1970-01-01 00:00:00"; |
69 |
UInt_t dbti = 0; |
UInt_t dbti = 0; |
70 |
Bool_t convert = false; |
Bool_t convert = false; |
71 |
Bool_t ruti = false; |
Bool_t ruti = false; |
72 |
// |
// |
73 |
|
TSQLResult *pResult; |
74 |
|
TSQLRow *Row; |
75 |
|
int t; |
76 |
|
int r; |
77 |
|
stringstream myquery; |
78 |
// |
// |
79 |
// Checking input parameters |
// Checking input parameters |
80 |
// |
// |
125 |
psw = (TString)inps[i+1]; |
psw = (TString)inps[i+1]; |
126 |
}; |
}; |
127 |
// |
// |
|
if ( !strcmp(inps[i],"-runat") ) { |
|
|
ruti = true; |
|
|
if ( numinp-1 < i+1 ){ |
|
|
r2d2usage(); |
|
|
exit(-3); |
|
|
}; |
|
|
runtime = (TString)inps[i+1]; |
|
|
}; |
|
|
// |
|
128 |
if ( !strcmp(inps[i],"-convert") ) { |
if ( !strcmp(inps[i],"-convert") ) { |
129 |
convert = true; |
convert = true; |
130 |
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
157 |
}; |
}; |
158 |
}; |
}; |
159 |
// |
// |
160 |
|
if ( !strcmp(inps[i],"-runat") ) { |
161 |
|
ruti = true; |
162 |
|
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
163 |
|
if ( numinp < i+2 ){ |
164 |
|
r2d2usage(); |
165 |
|
throw -3; |
166 |
|
}; |
167 |
|
i += 2; |
168 |
|
while ( strcmp(inps[i],"]") ){ |
169 |
|
if ( !strcmp(inps[i],"-tzone") ) { |
170 |
|
if ( numinp-1 < i+1 ){ |
171 |
|
r2d2usage(); |
172 |
|
exit(-3); |
173 |
|
}; |
174 |
|
tzone2 = (TString)inps[i+1]; |
175 |
|
}; |
176 |
|
if ( !strcmp(inps[i],"-time") ) { |
177 |
|
if ( numinp-1 < i+1 ){ |
178 |
|
r2d2usage(); |
179 |
|
exit(-3); |
180 |
|
}; |
181 |
|
runtime = (TString)inps[i+1]; |
182 |
|
}; |
183 |
|
i++; |
184 |
|
if ( i > numinp-1 ){ |
185 |
|
r2d2usage(); |
186 |
|
throw -3; |
187 |
|
}; |
188 |
|
}; |
189 |
|
}; |
190 |
|
}; |
191 |
|
// |
192 |
i++; |
i++; |
193 |
}; |
}; |
194 |
// |
// |
219 |
// At which date correspond the DB time "dbti"? |
// At which date correspond the DB time "dbti"? |
220 |
// |
// |
221 |
if ( convert ){ |
if ( convert ){ |
222 |
printf("\n Time %u is %s %s \n",dbti,dbtime->ConvertTime(tzone.Data(),dbti).Data(),tzone.Data()); |
printf("\n DB time %u is %s %s \n",dbti,dbtime->ConvertTime(tzone.Data(),dbti).Data(),tzone.Data()); |
223 |
}; |
}; |
224 |
// |
// |
225 |
// Which run contains the date "runtime"? |
// Which run contains the date "runtime"? |
226 |
// |
// |
227 |
if ( ruti ){ |
if ( ruti ){ |
228 |
|
// |
229 |
|
TDatime *time = new TDatime(runtime.Data()); |
230 |
|
UInt_t dbti = time->Convert(); |
231 |
|
// |
232 |
|
TString thetime = dbtime->UnConvertTime(tzone2.Data(),dbti); |
233 |
|
// |
234 |
|
TDatime *time2 = new TDatime(thetime.Data()); |
235 |
|
UInt_t mytime = time2->Convert(); |
236 |
|
// |
237 |
|
myquery.str(""); |
238 |
|
myquery << "select "; |
239 |
|
myquery << " ID "; |
240 |
|
myquery << " from GL_RUN where RUNHEADER_TIME<=" << mytime << " AND " |
241 |
|
<< " RUNTRAILER_TIME>=" << mytime << " ;"; |
242 |
|
// printf("myquery is %s \n",myquery.str().c_str()); |
243 |
|
pResult = dbc->Query(myquery.str().c_str()); |
244 |
|
for( r=0; r < 1000; r++){ |
245 |
|
Row = pResult->Next(); |
246 |
|
if ( !r && !Row ){ |
247 |
|
printf("\n No run contains date %s %s (DB time %u )\n",runtime.Data(),tzone2.Data(),mytime); |
248 |
|
}; |
249 |
|
if( Row == NULL ) break; |
250 |
|
printf("\n Date %s %s (DB time %u ) is contained in run %u \n",runtime.Data(),tzone2.Data(),mytime,(UInt_t)atoll(Row->GetField(0))); |
251 |
|
}; |
252 |
}; |
}; |
253 |
// |
// |
254 |
// To which file the run "run" belongs? |
// To which file the run "run" belongs? |
272 |
// Which runs are contained in the file "filename"? |
// Which runs are contained in the file "filename"? |
273 |
// |
// |
274 |
if ( strcmp(filename.Data(),"") ){ |
if ( strcmp(filename.Data(),"") ){ |
|
TSQLResult *pResult; |
|
|
TSQLRow *Row; |
|
|
int t; |
|
|
int r; |
|
|
stringstream myquery; |
|
275 |
// ---------------- |
// ---------------- |
276 |
Int_t ID = 0; |
Int_t ID = 0; |
277 |
Int_t ID_RAW = 0; |
Int_t ID_RAW = 0; |
287 |
myquery << ",NAME"; |
myquery << ",NAME"; |
288 |
myquery << " from GL_ROOT where NAME=\"" << filename.Data() << "\";"; |
myquery << " from GL_ROOT where NAME=\"" << filename.Data() << "\";"; |
289 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
|
if(!pResult->GetRowCount()) return (-51); |
|
290 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
291 |
Row = pResult->Next(); |
Row = pResult->Next(); |
292 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
304 |
myquery << " ID,RUNHEADER_TIME,RUNTRAILER_TIME "; |
myquery << " ID,RUNHEADER_TIME,RUNTRAILER_TIME "; |
305 |
myquery << " from GL_RUN where ID_ROOT_L0=" << ID << ";"; |
myquery << " from GL_RUN where ID_ROOT_L0=" << ID << ";"; |
306 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
|
if(!pResult->GetRowCount()) return (-51); |
|
307 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
308 |
Row = pResult->Next(); |
Row = pResult->Next(); |
309 |
if ( !r && !Row ){ |
if ( !r && !Row ){ |
310 |
printf(" No run associated to the file %s \n",filename.Data()); |
printf("\n No run associated to the file %s \n",filename.Data()); |
311 |
}; |
}; |
312 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
313 |
if ( !r ) printf("\n File %s contains the following runs: \n",filename.Data()); |
if ( !r ) printf("\n File %s contains the following runs: \n\n",filename.Data()); |
314 |
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()); |
printf(" => ID = %i _-_-_ the run started at %s UTC ended at %s UTC \n\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()); |
315 |
}; |
}; |
316 |
delete pResult; |
delete pResult; |
317 |
myquery.str(""); |
myquery.str(""); |
319 |
myquery << " PATH,NAME"; |
myquery << " PATH,NAME"; |
320 |
myquery << " from GL_RAW where ID=" << ID_RAW << ";"; |
myquery << " from GL_RAW where ID=" << ID_RAW << ";"; |
321 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
|
if(!pResult->GetRowCount()) return (-51); |
|
322 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
323 |
Row = pResult->Next(); |
Row = pResult->Next(); |
324 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
328 |
}; |
}; |
329 |
}; |
}; |
330 |
delete pResult; |
delete pResult; |
331 |
printf(" File %s belongs to raw data file %s/%s \n",filename.Data(),rawpath,rawname); |
printf("\n File %s belongs to raw data file %s/%s \n",filename.Data(),rawpath,rawname); |
332 |
}; |
}; |
333 |
}; |
}; |
334 |
// |
// |