/[PAMELA software]/YodaProfiler/src/R2-D2.cpp
ViewVC logotype

Contents of /YodaProfiler/src/R2-D2.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.10 - (show annotations) (download)
Thu Jan 11 16:04:16 2007 UTC (17 years, 11 months ago) by mocchiut
Branch: MAIN
CVS Tags: v3r04, v3r05, v3r00, v3r03, v4r01, v4r00
Changes since 1.9: +2 -2 lines
Small bug in R2-D2 fixed

1 //
2 // C/C++ headers
3 //
4 #include <iostream>
5 #include <iomanip>
6 #include <fstream>
7 #include <sstream>
8 //
9 // ROOT headers
10 //
11 #include <TString.h>
12 #include <TTimeStamp.h>
13 #include <TSQLServer.h>
14 #include <TFile.h>
15 #include <TSystem.h>
16 //
17 // Detector's package headers
18 //
19 #include <GLTables.h>
20 //
21 using namespace std;
22 //
23 //
24 //
25 #include <YodaProfilerVerl2.h>
26 //
27 // Usage subroutine
28 //
29 void r2d2usage(){
30 printf("\nUsage:\n");
31 printf("\n R2-D2 [ options ]\n");
32 printf("\n Options are:\n\n");
33 printf(" --version print informations about compilation and exit\n");
34 printf(" -h | --help print this help and exit \n");
35 printf(" -v | --verbose be verbose [default: print nothing on STDOUT]\n");
36 printf(" -idRun run ID_RUN: ID number of the run \n");
37 printf(" -filename file output yoda filename \n");
38 printf(" -l2filename file output amidala filename \n");
39 printf(" -host name of the DB host [default = $PAM_DBHOST or mysql://localhost/pamelaprod]\n");
40 printf(" -user username for the DB connection [default = $PAM_DBUSER or \"anonymous\"] \n");
41 printf(" -psw password for the DB connection [default = $PAM_DBPSW or \"\"]\n");
42 printf(" -tzone timezone the time zone: UTC,GMT,MSK,MSD,CET,CEST are accepted \n");
43 printf(" -convert dbtime convert the dbtime given in seconds (from the DB) to a string\n");
44 printf(" -runat date returns run number which contains the given date,\n");
45 printf(" for date use the SQL format \"yyyy-mm-dd hh:mm:ss\" \n");
46 printf(" -runatDB time returns run number which contains the given DB time\n");
47 printf(" -tsfile file yoda filename for the time sync (to be used with -obt)\n");
48 printf(" -obt OBT OBT in ms returns a date (to be used with -tsfile)\n");
49 printf(" -getRTime OBT OBT in ms returns Resurs time (to be used with -tsfile)\n");
50 printf(" -dumpTLEfor date save into file tle.txt the TLE for the given date,\n");
51 printf(" for date use the SQL format \"yyyy-mm-dd hh:mm:ss\" \n");
52 printf("\nExamples: \n");
53 printf(" R2-D2 -idRun 1085 \n");
54 printf(" R2-D2 -filename DW_050208_00900.root \n");
55 printf(" R2-D2 -idRun 1085 -filename DW_050208_00900.root \n\n");
56 };
57 //
58 // Here the main
59 //
60 int main(int numinp, char *inps[]){
61 //
62 // Variables booking
63 //
64 TString message;
65 Int_t error = 0;
66 //
67 UInt_t run = 0ULL;
68 //
69 TString filename = "";
70 TString l2filename = "";
71 //
72 TSQLServer *dbc = 0;
73 TString host = "mysql://localhost/pamelaprod";
74 TString user = "anonymous";
75 TString psw = "";
76 //
77 const char *pamdbhost=gSystem->Getenv("PAM_DBHOST");
78 const char *pamdbuser=gSystem->Getenv("PAM_DBUSER");
79 const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW");
80 if ( !pamdbhost ) pamdbhost = "";
81 if ( !pamdbuser ) pamdbuser = "";
82 if ( !pamdbpsw ) pamdbpsw = "";
83 if ( strcmp(pamdbhost,"") ) host = pamdbhost;
84 if ( strcmp(pamdbuser,"") ) user = pamdbuser;
85 if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;
86 //
87 // printf(" host %s user %s psw %s \n",host.Data(),user.Data(),psw.Data());
88 //
89 TString tzone = "UTC";
90 TString runtime = "1970-01-01 00:00:00";
91 TString tletime = "1970-01-01 00:00:00";
92 UInt_t dbti = 0;
93 Bool_t convert = false;
94 Bool_t convres = false;
95 Bool_t ruti = false;
96 Bool_t dtle = false;
97 Bool_t ruti2 = false;
98 Bool_t convobt = false;
99 Bool_t convobtts = false;
100 //
101 UInt_t runtime2 = 0;
102 UInt_t obt = 0;
103 UInt_t res = 0;
104 TString tsfile = "";
105 //
106 TSQLResult *pResult;
107 TSQLRow *Row;
108 int t;
109 int r;
110 stringstream myquery;
111 //
112 // Checking input parameters
113 //
114 Int_t i = 0;
115 if ( numinp > 1 ){
116 while ( i < numinp ){
117 if ( !strcmp(inps[i],"--version") ){
118 YodaProfilerInfo(true);
119 exit(0);
120 };
121 if ( !strcmp(inps[i],"-h") || !strcmp(inps[i],"--help") ){
122 r2d2usage();
123 exit(0);
124 };
125 if ( !strcmp(inps[i],"-idRun") ) {
126 if ( numinp-1 < i+1 ) {
127 r2d2usage();
128 exit(-3);
129 };
130 run = (UInt_t)atoll(inps[i+1]);
131 };
132 if ( !strcmp(inps[i],"-filename") ) {
133 if ( numinp-1 < i+1 ){
134 r2d2usage();
135 exit(-3);
136 };
137 filename = (TString)inps[i+1];
138 };
139 if ( !strcmp(inps[i],"-l2filename") ) {
140 if ( numinp-1 < i+1 ){
141 r2d2usage();
142 exit(-3);
143 };
144 l2filename = (TString)inps[i+1];
145 };
146 if ( !strcmp(inps[i],"-host") ) {
147 if ( numinp-1 < i+1 ){
148 r2d2usage();
149 exit(-3);
150 };
151 host = (TString)inps[i+1];
152 };
153 if ( !strcmp(inps[i],"-user") ) {
154 if ( numinp-1 < i+1 ){
155 r2d2usage();
156 exit(-3);
157 };
158 user = (TString)inps[i+1];
159 };
160 if ( !strcmp(inps[i],"-psw") ) {
161 if ( numinp-1 < i+1 ){
162 r2d2usage();
163 exit(-3);
164 };
165 psw = (TString)inps[i+1];
166 };
167 //
168 if ( !strcmp(inps[i],"-tsfile") ) {
169 convobtts = true;
170 if ( numinp-1 < i+1 ){
171 r2d2usage();
172 exit(-3);
173 };
174 tsfile = (TString)inps[i+1];
175 };
176 //
177 if ( !strcmp(inps[i],"-obt") ) {
178 convobt = true;
179 if ( numinp-1 < i+1 ){
180 r2d2usage();
181 exit(-3);
182 };
183 obt = (UInt_t)atoll(inps[i+1]);
184 };
185 //
186 if ( !strcmp(inps[i],"-getRTime") ) {
187 convres = true;
188 if ( numinp-1 < i+1 ){
189 r2d2usage();
190 exit(-3);
191 };
192 res = (UInt_t)atoll(inps[i+1]);
193 };
194 //
195 //
196 if ( !strcmp(inps[i],"-tzone") ) {
197 if ( numinp-1 < i+1 ){
198 r2d2usage();
199 exit(-3);
200 };
201 tzone = (TString)inps[i+1];
202 };
203 //
204 if ( !strcmp(inps[i],"-convert") ) {
205 convert = true;
206 if ( numinp-1 < i+1 ){
207 r2d2usage();
208 exit(-3);
209 };
210 dbti = (UInt_t)atoll(inps[i+1]);
211 };
212 //
213 if ( !strcmp(inps[i],"-runat") ) {
214 ruti = true;
215 if ( numinp-1 < i+1 ){
216 r2d2usage();
217 exit(-3);
218 };
219 runtime = (TString)inps[i+1];
220 };
221 //
222 if ( !strcmp(inps[i],"-dumpTLEfor") ) {
223 dtle = true;
224 if ( numinp-1 < i+1 ){
225 r2d2usage();
226 exit(-3);
227 };
228 tletime = (TString)inps[i+1];
229 };
230 //
231 //
232 if ( !strcmp(inps[i],"-runatDB") ) {
233 ruti2 = true;
234 if ( numinp-1 < i+1 ){
235 r2d2usage();
236 exit(-3);
237 };
238 runtime2 = (UInt_t)atoll(inps[i+1]);
239 };
240 //
241 i++;
242 };
243 //
244 } else {
245 //
246 // no input parameters exit with error, we need at least the run id.
247 //
248 r2d2usage();
249 exit(-2);
250 };
251 //
252 // Connect to the DB
253 //
254 dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
255 if( !dbc ) throw -2;
256 //
257 bool connect = dbc->IsConnected();
258 //
259 if( !connect ){
260 printf(" Error, not connected to DB\n");
261 exit(-1);
262 };
263 //
264 myquery.str("");
265 myquery << "SET time_zone='+0:00'";
266 dbc->Query(myquery.str().c_str());
267 //
268 GL_ROOT *glroot = new GL_ROOT();
269 GL_RUN *glrun = new GL_RUN();
270 GL_TIMESYNC *dbtime = new GL_TIMESYNC();
271 UInt_t nr = 0;
272 UInt_t rlist[500];
273 //
274 // At which date correspond the DB time "dbti"?
275 //
276 if ( convert ){
277 printf("\n DB time %u is %s %s \n",dbti,dbtime->ConvertTime(tzone,dbti).Data(),tzone.Data());
278 };
279 //
280 // convert OBT to date
281 //
282 if ( convobt && convobtts ){
283 UInt_t id = 0;
284 myquery.str("");
285 myquery << "select ";
286 myquery << " ID";
287 myquery << " from GL_ROOT where NAME=\"" << tsfile.Data() << "\";";
288 pResult = dbc->Query(myquery.str().c_str());
289 if ( pResult ){
290 Row = pResult->Next();
291 if ( Row ){
292 id = (UInt_t)atoll(Row->GetField(0));
293 delete pResult;
294 GL_TIMESYNC *ctime = new GL_TIMESYNC(id,"ID",dbc);
295 UInt_t abtime = ctime->DBabsTime(obt);
296 TString thetime = dbtime->ConvertTime(tzone,abtime);
297 printf("\n OBT %u in the file %s corresponds to DBtime %u and date %s %s \n",obt,tsfile.Data(),abtime,thetime.Data(),tzone.Data());
298 delete ctime;
299 };
300 };
301 };
302 if ( (convobt && !convobtts) ){
303 printf("\n To convert a OBT to a date you must provide both OBT and file to be used for time sync \n");
304 };
305 //
306 // convert OBT to Resurs seconds
307 //
308 if ( convres && convobtts ){
309 UInt_t id = 0;
310 myquery.str("");
311 myquery << "select ";
312 myquery << " ID";
313 myquery << " from GL_ROOT where NAME=\"" << tsfile.Data() << "\";";
314 pResult = dbc->Query(myquery.str().c_str());
315 if ( pResult ){
316 Row = pResult->Next();
317 if ( Row ){
318 id = (UInt_t)atoll(Row->GetField(0));
319 delete pResult;
320 GL_TIMESYNC *ctime = new GL_TIMESYNC(id,"ID",dbc);
321 UInt_t restime = ctime->ResursTime(res);
322 //UInt_t abtime = ctime->DBabsTime(obt);
323 //
324 // TString thetime = dbtime->ConvertTime(tzone,abtime);
325 printf("\n OBT %u in the file %s corresponds to Resurs time %u \n",res,tsfile.Data(),restime);
326 delete ctime;
327 };
328 };
329 };
330 if ( (convres && !convobtts) ){
331 printf("\n To convert a OBT to the Resurs time you must provide both OBT and file to be used for time sync \n");
332 };
333 //
334 // Which run contains the date "runtime"?
335 //
336 if ( ruti ){
337 //
338 TDatime ti = TDatime(runtime.Data());
339 //
340 TTimeStamp *time = new TTimeStamp((UInt_t)ti.GetYear(),(UInt_t)ti.GetMonth(),(UInt_t)ti.GetDay(),(UInt_t)ti.GetHour(),(UInt_t)ti.GetMinute(),(UInt_t)ti.GetSecond(),0,true,0);
341 //
342 UInt_t dbti = time->GetSec();
343 //
344 TString thetime = dbtime->UnConvertTime(tzone,dbti);
345 //
346 ti = TDatime(thetime.Data());
347 TTimeStamp *time2 = new TTimeStamp((UInt_t)ti.GetYear(),(UInt_t)ti.GetMonth(),(UInt_t)ti.GetDay(),(UInt_t)ti.GetHour(),(UInt_t)ti.GetMinute(),(UInt_t)ti.GetSecond(),0,true,0);
348 //
349 UInt_t mytime = time2->GetSec();
350 //
351 Bool_t found = false;
352 //
353 myquery.str("");
354 myquery << "select ";
355 myquery << " ID ";
356 myquery << " from GL_RUN where RUNHEADER_TIME<=" << mytime << " AND "
357 << " RUNTRAILER_TIME>=" << mytime << " ;";
358 // printf("myquery is %s \n",myquery.str().c_str());
359 pResult = dbc->Query(myquery.str().c_str());
360 for( r=0; r < 1000; r++){
361 Row = pResult->Next();
362 if( Row == NULL ) break;
363 found = true;
364 printf("\n Date %s %s (DB time %u ) is contained in run %u \n",runtime.Data(),tzone.Data(),mytime,(UInt_t)atoll(Row->GetField(0)));
365 };
366 myquery.str("");
367 myquery << "select ";
368 myquery << " ID ";
369 myquery << " from GL_RUN_TRASH where BELONGED_TO='GL_RUN' AND RUNHEADER_TIME<=" << mytime << " AND "
370 << " RUNTRAILER_TIME>=" << mytime << " ;";
371 // printf("myquery is %s \n",myquery.str().c_str());
372 pResult = dbc->Query(myquery.str().c_str());
373 for( r=0; r < 1000; r++){
374 Row = pResult->Next();
375 if( Row == NULL ) break;
376 printf("\n Date %s %s (DB time %u ) is contained in run %u in the GL_RUN_TRASH table \n",runtime.Data(),tzone.Data(),mytime,(UInt_t)atoll(Row->GetField(0)));
377 found = true;
378 };
379 //
380 if ( !found ){
381 printf("\n No run contains date %s %s (DB time %u )\n",runtime.Data(),tzone.Data(),mytime);
382 };
383 //
384 };
385 //
386 // Which tle must be used for the date "tletime"?
387 //
388 if ( dtle ){
389 //
390 //
391 TDatime ti = TDatime(tletime.Data());
392 //
393 TTimeStamp *time = new TTimeStamp((UInt_t)ti.GetYear(),(UInt_t)ti.GetMonth(),(UInt_t)ti.GetDay(),(UInt_t)ti.GetHour(),(UInt_t)ti.GetMinute(),(UInt_t)ti.GetSecond(),0,true,0);
394 //
395 UInt_t dbti = time->GetSec();
396 //
397 TString thetime = dbtime->UnConvertTime(tzone,dbti);
398 //
399 ti = TDatime(thetime.Data());
400 TTimeStamp *time2 = new TTimeStamp((UInt_t)ti.GetYear(),(UInt_t)ti.GetMonth(),(UInt_t)ti.GetDay(),(UInt_t)ti.GetHour(),(UInt_t)ti.GetMinute(),(UInt_t)ti.GetSecond(),0,true,0);
401 //
402 UInt_t mytime = time2->GetSec();
403 //
404 myquery.str("");
405 myquery << " select ID,TLE1,TLE2,TLE3 from GL_TLE where FROM_TIME<='" << time2->AsString("s") << "' ORDER BY FROM_TIME DESC LIMIT 1;";
406 // myquery << " from GL_TLE where FROM_TIME>=" << mytime << " ORDER BY FROM_TIME ASC LIMIT 1;";
407 // printf("myquery is %s \n",myquery.str().c_str());
408 pResult = dbc->Query(myquery.str().c_str());
409 Row = pResult->Next();
410 if ( !Row ){
411 printf("\n No TLE in the DB for date %s %s (DB time %u )\n",tletime.Data(),tzone.Data(),mytime);
412 };
413 printf("\n Date %s %s (DB time %u ) is contained in TLE %u \n",tletime.Data(),tzone.Data(),mytime,(UInt_t)atoll(Row->GetField(0)));
414 printf("\n%s\n",Row->GetField(1));
415 printf("%s\n",Row->GetField(2));
416 printf("%s\n",Row->GetField(3));
417 //
418 FILE *tlefile;
419 tlefile = fopen("tle.txt","w");
420 fprintf(tlefile,"%s\n",Row->GetField(1));
421 fprintf(tlefile,"%s\n",Row->GetField(2));
422 fprintf(tlefile,"%s\n",Row->GetField(3));
423 fclose (tlefile);
424 //
425 printf("\n TLE has been dumped in file tle.txt \n");
426 };
427 //
428 // Which run contains the dbtime "runtime2"?
429 //
430 if ( ruti2 ){
431 //
432 UInt_t mytime = runtime2;
433 //
434 Bool_t found = false;
435 myquery.str("");
436 myquery << "select ";
437 myquery << " ID ";
438 myquery << " from GL_RUN where RUNHEADER_TIME<=" << mytime << " AND "
439 << " RUNTRAILER_TIME>=" << mytime << " ;";
440 // printf("myquery is %s \n",myquery.str().c_str());
441 pResult = dbc->Query(myquery.str().c_str());
442 for( r=0; r < 1000; r++){
443 Row = pResult->Next();
444 if( Row == NULL ) break;
445 printf("\n DB time %u is contained in run %u \n",mytime,(UInt_t)atoll(Row->GetField(0)));
446 found = true;
447 };
448 //
449 myquery.str("");
450 myquery << "select ";
451 myquery << " ID ";
452 myquery << " from GL_RUN_TRASH where BELONGED_TO='GL_RUN' AND RUNHEADER_TIME<=" << mytime << " AND "
453 << " RUNTRAILER_TIME>=" << mytime << " ;";
454 // printf("myquery is %s \n",myquery.str().c_str());
455 pResult = dbc->Query(myquery.str().c_str());
456 for( r=0; r < 1000; r++){
457 Row = pResult->Next();
458 if( Row == NULL ) break;
459 printf("\n DB time %u is contained in run %u in the GL_RUN_TRASH table \n",mytime,(UInt_t)atoll(Row->GetField(0)));
460 found = true;
461 };
462 //
463 if ( !found ){
464 printf("\n No run contains DB time %u \n",mytime);
465 };
466 //
467 };
468 //
469 // To which file the run "run" belongs?
470 //
471 if ( run != 0 ){
472 Bool_t found = false;
473 glrun->Clear();
474 error = glrun->Query_GL_RUN(run,dbc);
475 glroot->Clear();
476 error = glroot->Query_GL_ROOT(glrun->ID_ROOT_L0,dbc);
477 if ( glrun->ID_ROOT_L0 ){
478 if ( error ){
479 printf(" Error querying the DB! \n");
480 exit(-4);
481 };
482 printf("\n Run %u belongs to file %s \n",run,(glroot->PATH+glroot->NAME).Data());
483 //filename = glroot->NAME;
484 found = true;
485 };
486 //
487 myquery.str("");
488 myquery << "select ";
489 myquery << " ID,FILENAMEL0,FILENAMEL2 ";
490 myquery << " from GL_RUN_TRASH where BELONGED_TO='GL_RUN' AND ID=" << run << "; ";
491 pResult = dbc->Query(myquery.str().c_str());
492 for( r=0; r < 1000; r++){
493 Row = pResult->Next();
494 if( Row == NULL ) break;
495 printf("\n RUN %u has been deleted and now is contained in the GL_RUN_TRASH table \n",run);
496 printf("\n RUN %u belonged to L0 file %s and L2 file %s \n",run,Row->GetField(1),Row->GetField(2));
497 found = true;
498 };
499 //
500 if ( !found ) printf("\n No run with ID=%u in the DB!\n",run);
501 };
502 //
503 // Which runs are contained in the file "filename"?
504 //
505 if ( strcmp(filename.Data(),"") ){
506 // ----------------
507 Bool_t found = false;
508 Int_t ID = 0;
509 Int_t ID_RAW = 0;
510 //
511 const char *rawpath = "";
512 const char *rawname = "";
513 //
514 myquery.str("");
515 myquery << "select ";
516 myquery << " ID";
517 myquery << ",ID_RAW";
518 myquery << ",PATH";
519 myquery << ",NAME";
520 myquery << " from GL_ROOT where NAME=\"" << filename.Data() << "\";";
521 pResult = dbc->Query(myquery.str().c_str());
522 for( r=0; r < 1000; r++){
523 Row = pResult->Next();
524 if( Row == NULL ) break;
525 for( t = 0; t < pResult->GetFieldCount(); t++){
526 if(t==0) ID = atoi(Row->GetField(t));
527 if(t==1) ID_RAW = atoi(Row->GetField(t));
528 };
529 };
530 delete pResult;
531 if ( !ID && !ID_RAW ){
532 printf("\n No file with name %s in the DB!\n",filename.Data());
533 } else {
534 myquery.str("");
535 myquery << "select ";
536 myquery << " ID,RUNHEADER_TIME,RUNTRAILER_TIME,NEVENTS ";
537 myquery << " from GL_RUN where ID_ROOT_L0=" << ID << ";";
538 pResult = dbc->Query(myquery.str().c_str());
539 for( r=0; r < 1000; r++){
540 Row = pResult->Next();
541 if( Row == NULL ) break;
542 found = true;
543 if ( !r ) printf("\n File %s contains the following runs: \n\n",filename.Data());
544 TString UTC=tzone.Data();
545 printf(" => ID = %i --> the run started at %s %s ended at %s %s NEV = %u \n\n",(UInt_t)atoll(Row->GetField(0)),dbtime->ConvertTime(UTC,(UInt_t)atoll(Row->GetField(1))).Data(),tzone.Data(),dbtime->ConvertTime(UTC,(UInt_t)atoll(Row->GetField(2))).Data(),tzone.Data(),(UInt_t)atoll(Row->GetField(3)));
546 };
547 delete pResult;
548 myquery.str("");
549 myquery << "select ";
550 myquery << " ID,RUNHEADER_TIME,RUNTRAILER_TIME ";
551 myquery << " from GL_RUN_TRASH where BELONGED_TO='GL_RUN' AND FILENAMEL0='" << filename.Data() << "' ;";
552 pResult = dbc->Query(myquery.str().c_str());
553 for( r=0; r < 1000; r++){
554 Row = pResult->Next();
555 if( Row == NULL ) break;
556 if ( !r ) printf("\n File %s contains the following DELETED runs: \n\n",filename.Data());
557 TString UTC=tzone.Data();
558 printf(" => ID = %i --> the run started at %s %s ended at %s %s \n\n",(UInt_t)atoll(Row->GetField(0)),dbtime->ConvertTime(UTC,(UInt_t)atoll(Row->GetField(1))).Data(),tzone.Data(),dbtime->ConvertTime(UTC,(UInt_t)atoll(Row->GetField(2))).Data(),tzone.Data());
559 };
560 //
561 if ( !found ){
562 printf("\n No run associated to the file %s \n",filename.Data());
563 };
564 myquery.str("");
565 myquery << "select ";
566 myquery << " PATH,NAME";
567 myquery << " from GL_RAW where ID=" << ID_RAW << ";";
568 pResult = dbc->Query(myquery.str().c_str());
569 for( r=0; r < 1000; r++){
570 Row = pResult->Next();
571 if( Row == NULL ) break;
572 for( t = 0; t < pResult->GetFieldCount(); t++){
573 if(t==0) rawpath = Row->GetField(t);
574 if(t==1) rawname = Row->GetField(t);
575 };
576 };
577 delete pResult;
578 printf("\n File %s belongs to raw data file %s/%s \n",filename.Data(),rawpath,rawname);
579 };
580 };
581 //
582 // Which runs are contained in the file "l2filename"?
583 //
584 if ( strcmp(l2filename.Data(),"") ){
585 // ----------------
586 Bool_t found = false;
587 Int_t ID = 0;
588 Int_t ID_RAW = 0;
589 //
590 const char *rawpath = "";
591 const char *rawname = "";
592 //
593 myquery.str("");
594 myquery << "select ";
595 myquery << " ID";
596 myquery << ",ID_RAW";
597 myquery << ",PATH";
598 myquery << ",NAME";
599 myquery << " from GL_ROOT where NAME=\"" << l2filename.Data() << "\";";
600 pResult = dbc->Query(myquery.str().c_str());
601 for( r=0; r < 1000; r++){
602 Row = pResult->Next();
603 if( Row == NULL ) break;
604 for( t = 0; t < pResult->GetFieldCount(); t++){
605 if(t==0) ID = atoi(Row->GetField(t));
606 if(t==1) ID_RAW = atoi(Row->GetField(t));
607 };
608 };
609 delete pResult;
610 if ( !ID ){
611 printf("\n No file with name %s in the DB!\n",l2filename.Data());
612 } else {
613 nr = 0;
614 rlist[0] = 0;
615 myquery.str("");
616 myquery << "select ";
617 myquery << " ID,ID_ROOT_L0 ";
618 myquery << " from GL_RUN where ID_ROOT_L2=" << ID << ";";
619 pResult = dbc->Query(myquery.str().c_str());
620 for( r=0; r < pResult->GetRowCount(); r++){
621 Row = pResult->Next();
622 if( Row == NULL ) break;
623 found = true;
624 if ( !r ) printf("\n File %s contains the following runs: \n\n",l2filename.Data());
625 printf(" %u ",(UInt_t)atoll(Row->GetField(0)));
626 if ( r < (pResult->GetRowCount()-1) ){
627 printf("-");
628 } else {
629 printf("\n\n");
630 };
631 if ( (UInt_t)atoll(Row->GetField(1)) != rlist[nr] ){
632 nr++;
633 rlist[nr] = (UInt_t)atoll(Row->GetField(1));
634 };
635 };
636 delete pResult;
637 //
638 printf("\n File %s contains runs from L0 files: \n\n",l2filename.Data());
639 for (UInt_t l=1; l<nr+1; l++){
640 myquery.str("");
641 myquery << "select ";
642 myquery << " PATH,NAME";
643 myquery << " from GL_ROOT where ID=" << rlist[l] << ";";
644 pResult = dbc->Query(myquery.str().c_str());
645 for( r=0; r < pResult->GetRowCount(); r++){
646 Row = pResult->Next();
647 if( Row == NULL ) break;
648 for( t = 0; t < pResult->GetFieldCount(); t++){
649 if(t==0) rawpath = Row->GetField(t);
650 if(t==1) rawname = Row->GetField(t);
651 };
652 printf(" %s/%s \n",rawpath,rawname);
653 };
654 delete pResult;
655 };
656 };
657 };
658 //
659 // Close the DB connection
660 //
661 if ( dbc ) dbc->Close();
662 //
663 printf("\n");
664 //
665 exit(0);
666 }

  ViewVC Help
Powered by ViewVC 1.1.23