28 |
// |
// |
29 |
void r2d2usage(){ |
void r2d2usage(){ |
30 |
printf("\nUsage:\n"); |
printf("\nUsage:\n"); |
31 |
printf("\n R2-D2 [-h | --help] [--version] [-idRun ID_RUN] [-filename filename]\n"); |
printf("\n R2-D2 [ options ]\n"); |
32 |
printf("\n [-host host] [-user username] [-psw password] \n"); |
printf("\n Options are:\n\n"); |
33 |
printf("\n --version print informations about compilation and exit\n"); |
printf(" --version print informations about compilation and exit\n"); |
34 |
printf("\n -h | --help print this help and exit \n"); |
printf(" -h | --help print this help and exit \n"); |
35 |
printf("\n -v | --verbose be verbose [default: print nothing on STDOUT]\n"); |
printf(" -v | --verbose be verbose [default]\n"); |
36 |
printf("\n -idRun run ID_RUN: ID number of the run \n"); |
printf(" -n | --neat used with '-filename' returns only the run ID number\n"); |
37 |
printf("\n -filename file output yoda filename \n"); |
printf(" -idRun run ID_RUN: ID number of the run \n"); |
38 |
printf("\n -host name for the host [default = $PAM_DBHOST or mysql://localhost/pamelaprod]\n"); |
printf(" -filename file output yoda filename \n"); |
39 |
printf("\n -user username for the DB [default = $PAM_DBUSER or \"anonymous\"] \n"); |
printf(" -l2filename file output amidala filename \n"); |
40 |
printf("\n -psw password for the DB [default = $PAM_DBPSW or \"\"]\n"); |
printf(" -host name of the DB host [default = $PAM_DBHOST or mysql://localhost/pamelaprod]\n"); |
41 |
printf("\n -tzone timezone the time zone: UTC,GMT,MSK,MSD,CET,CEST are accepted \n"); |
printf(" -user username for the DB connection [default = $PAM_DBUSER or \"anonymous\"] \n"); |
42 |
printf("\n -convert dbtime convert the dbtime given in seconds (from the DB) to a string\n"); |
printf(" -psw password for the DB connection [default = $PAM_DBPSW or \"\"]\n"); |
43 |
printf("\n -runat date returns run number which contains the given date,\n"); |
printf(" -splitat file shows relationship between files around the given file\n"); |
44 |
printf("\n for date use the SQL format \"yyyy-mm-dd hh:mm:ss\" \n"); |
printf(" -tzone timezone the time zone: UTC,GMT,MSK,MSD,CET,CEST are accepted \n"); |
45 |
printf("\n -runatDB time returns run number which contains the given DB time\n"); |
printf(" -convert dbtime convert the dbtime given in seconds (from the DB) to a string\n"); |
46 |
printf("\n -tsfile file yoda filename for the time sync (to be used with -obt)\n"); |
printf(" -runat date returns run number which contains the given date,\n"); |
47 |
printf("\n -obt OBT OBT in ms returns a date (to be used with -tsfile)\n"); |
printf(" for date use the SQL format \"yyyy-mm-dd hh:mm:ss\" \n"); |
48 |
printf("\n -dumpTLEfor date save into file tle.txt the TLE for the given date,\n"); |
printf(" -runatDB time returns run number which contains the given DB time\n"); |
49 |
printf("\n for date use the SQL format \"yyyy-mm-dd hh:mm:ss\" \n"); |
printf(" -tsfile file yoda filename for the time sync (to be used with -obt)\n"); |
50 |
|
printf(" -obt OBT OBT in ms returns a date (to be used with -tsfile)\n"); |
51 |
|
printf(" -getRTime OBT OBT in ms returns Resurs time (to be used with -tsfile)\n"); |
52 |
|
printf(" -dumpTLEfor date save into file tle.txt the TLE for the given date,\n"); |
53 |
|
printf(" for date use the SQL format \"yyyy-mm-dd hh:mm:ss\" \n"); |
54 |
printf("\nExamples: \n"); |
printf("\nExamples: \n"); |
55 |
printf("\n R2-D2 -idRun 1085 \n"); |
printf(" R2-D2 -idRun 1085 \n"); |
56 |
printf("\n R2-D2 -filename DW_050208_00900.root \n"); |
printf(" R2-D2 -filename DW_050208_00900.root \n"); |
57 |
printf("\n R2-D2 -idRun 1085 -filename DW_050208_00900.root \n"); |
printf(" R2-D2 -idRun 1085 -filename DW_050208_00900.root \n\n"); |
58 |
}; |
}; |
59 |
// |
// |
60 |
// Here the main |
// Here the main |
69 |
UInt_t run = 0ULL; |
UInt_t run = 0ULL; |
70 |
// |
// |
71 |
TString filename = ""; |
TString filename = ""; |
72 |
|
TString l2filename = ""; |
73 |
|
TString splitat = ""; |
74 |
// |
// |
75 |
TSQLServer *dbc = 0; |
TSQLServer *dbc = 0; |
76 |
TString host = "mysql://localhost/pamelaprod"; |
TString host = "mysql://localhost/pamelaprod"; |
94 |
TString tletime = "1970-01-01 00:00:00"; |
TString tletime = "1970-01-01 00:00:00"; |
95 |
UInt_t dbti = 0; |
UInt_t dbti = 0; |
96 |
Bool_t convert = false; |
Bool_t convert = false; |
97 |
|
Bool_t convres = false; |
98 |
Bool_t ruti = false; |
Bool_t ruti = false; |
99 |
Bool_t dtle = false; |
Bool_t dtle = false; |
100 |
Bool_t ruti2 = false; |
Bool_t ruti2 = false; |
101 |
Bool_t convobt = false; |
Bool_t convobt = false; |
102 |
Bool_t convobtts = false; |
Bool_t convobtts = false; |
103 |
|
Bool_t neat = false; |
104 |
// |
// |
105 |
UInt_t runtime2 = 0; |
UInt_t runtime2 = 0; |
106 |
UInt_t obt = 0; |
UInt_t obt = 0; |
107 |
|
UInt_t res = 0; |
108 |
TString tsfile = ""; |
TString tsfile = ""; |
109 |
// |
// |
110 |
TSQLResult *pResult; |
TSQLResult *pResult; |
111 |
TSQLRow *Row; |
TSQLRow *Row; |
112 |
|
TSQLResult *pResult2 = 0; |
113 |
|
TSQLRow *Row2; |
114 |
int t; |
int t; |
115 |
int r; |
int r; |
116 |
stringstream myquery; |
stringstream myquery; |
128 |
r2d2usage(); |
r2d2usage(); |
129 |
exit(0); |
exit(0); |
130 |
}; |
}; |
131 |
|
if ( !strcmp(inps[i],"-n") || !strcmp(inps[i],"--neat") ){ |
132 |
|
neat = true; |
133 |
|
}; |
134 |
if ( !strcmp(inps[i],"-idRun") ) { |
if ( !strcmp(inps[i],"-idRun") ) { |
135 |
if ( numinp-1 < i+1 ) { |
if ( numinp-1 < i+1 ) { |
136 |
r2d2usage(); |
r2d2usage(); |
145 |
}; |
}; |
146 |
filename = (TString)inps[i+1]; |
filename = (TString)inps[i+1]; |
147 |
}; |
}; |
148 |
|
if ( !strcmp(inps[i],"-splitat") ) { |
149 |
|
if ( numinp-1 < i+1 ){ |
150 |
|
r2d2usage(); |
151 |
|
exit(-3); |
152 |
|
}; |
153 |
|
splitat = (TString)inps[i+1]; |
154 |
|
}; |
155 |
|
if ( !strcmp(inps[i],"-l2filename") ) { |
156 |
|
if ( numinp-1 < i+1 ){ |
157 |
|
r2d2usage(); |
158 |
|
exit(-3); |
159 |
|
}; |
160 |
|
l2filename = (TString)inps[i+1]; |
161 |
|
}; |
162 |
if ( !strcmp(inps[i],"-host") ) { |
if ( !strcmp(inps[i],"-host") ) { |
163 |
if ( numinp-1 < i+1 ){ |
if ( numinp-1 < i+1 ){ |
164 |
r2d2usage(); |
r2d2usage(); |
199 |
obt = (UInt_t)atoll(inps[i+1]); |
obt = (UInt_t)atoll(inps[i+1]); |
200 |
}; |
}; |
201 |
// |
// |
202 |
|
if ( !strcmp(inps[i],"-getRTime") ) { |
203 |
|
convres = true; |
204 |
|
if ( numinp-1 < i+1 ){ |
205 |
|
r2d2usage(); |
206 |
|
exit(-3); |
207 |
|
}; |
208 |
|
res = (UInt_t)atoll(inps[i+1]); |
209 |
|
}; |
210 |
|
// |
211 |
// |
// |
212 |
if ( !strcmp(inps[i],"-tzone") ) { |
if ( !strcmp(inps[i],"-tzone") ) { |
213 |
if ( numinp-1 < i+1 ){ |
if ( numinp-1 < i+1 ){ |
284 |
GL_ROOT *glroot = new GL_ROOT(); |
GL_ROOT *glroot = new GL_ROOT(); |
285 |
GL_RUN *glrun = new GL_RUN(); |
GL_RUN *glrun = new GL_RUN(); |
286 |
GL_TIMESYNC *dbtime = new GL_TIMESYNC(); |
GL_TIMESYNC *dbtime = new GL_TIMESYNC(); |
287 |
|
UInt_t nr = 0; |
288 |
|
UInt_t rlist[500]; |
289 |
// |
// |
290 |
// At which date correspond the DB time "dbti"? |
// At which date correspond the DB time "dbti"? |
291 |
// |
// |
293 |
printf("\n DB time %u is %s %s \n",dbti,dbtime->ConvertTime(tzone,dbti).Data(),tzone.Data()); |
printf("\n DB time %u is %s %s \n",dbti,dbtime->ConvertTime(tzone,dbti).Data(),tzone.Data()); |
294 |
}; |
}; |
295 |
// |
// |
296 |
// |
// convert OBT to date |
297 |
// |
// |
298 |
if ( convobt && convobtts ){ |
if ( convobt && convobtts ){ |
299 |
UInt_t id = 0; |
UInt_t id = 0; |
309 |
delete pResult; |
delete pResult; |
310 |
GL_TIMESYNC *ctime = new GL_TIMESYNC(id,"ID",dbc); |
GL_TIMESYNC *ctime = new GL_TIMESYNC(id,"ID",dbc); |
311 |
UInt_t abtime = ctime->DBabsTime(obt); |
UInt_t abtime = ctime->DBabsTime(obt); |
|
TString UTC="UTC"; |
|
312 |
TString thetime = dbtime->ConvertTime(tzone,abtime); |
TString thetime = dbtime->ConvertTime(tzone,abtime); |
313 |
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()); |
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()); |
314 |
delete ctime; |
delete ctime; |
315 |
}; |
}; |
316 |
}; |
}; |
317 |
}; |
}; |
318 |
if ( (convobt && !convobtts) || (convobtts && !convobt) ){ |
if ( (convobt && !convobtts) ){ |
319 |
printf("\n To convert a OBT to a date you must provide both OBT and file to be used for time sync \n"); |
printf("\n To convert a OBT to a date you must provide both OBT and file to be used for time sync \n"); |
320 |
}; |
}; |
321 |
// |
// |
322 |
|
// convert OBT to Resurs seconds |
323 |
|
// |
324 |
|
if ( convres && convobtts ){ |
325 |
|
UInt_t id = 0; |
326 |
|
myquery.str(""); |
327 |
|
myquery << "select "; |
328 |
|
myquery << " ID"; |
329 |
|
myquery << " from GL_ROOT where NAME=\"" << tsfile.Data() << "\";"; |
330 |
|
pResult = dbc->Query(myquery.str().c_str()); |
331 |
|
if ( pResult ){ |
332 |
|
Row = pResult->Next(); |
333 |
|
if ( Row ){ |
334 |
|
id = (UInt_t)atoll(Row->GetField(0)); |
335 |
|
delete pResult; |
336 |
|
GL_TIMESYNC *ctime = new GL_TIMESYNC(id,"ID",dbc); |
337 |
|
UInt_t restime = ctime->ResursTime(res); |
338 |
|
//UInt_t abtime = ctime->DBabsTime(obt); |
339 |
|
// |
340 |
|
// TString thetime = dbtime->ConvertTime(tzone,abtime); |
341 |
|
printf("\n OBT %u in the file %s corresponds to Resurs time %u \n",res,tsfile.Data(),restime); |
342 |
|
delete ctime; |
343 |
|
}; |
344 |
|
}; |
345 |
|
}; |
346 |
|
if ( (convres && !convobtts) ){ |
347 |
|
printf("\n To convert a OBT to the Resurs time you must provide both OBT and file to be used for time sync \n"); |
348 |
|
}; |
349 |
|
// |
350 |
// Which run contains the date "runtime"? |
// Which run contains the date "runtime"? |
351 |
// |
// |
352 |
if ( ruti ){ |
if ( ruti ){ |
404 |
if ( dtle ){ |
if ( dtle ){ |
405 |
// |
// |
406 |
// |
// |
407 |
TDatime ti = TDatime(runtime.Data()); |
TDatime ti = TDatime(tletime.Data()); |
408 |
// |
// |
409 |
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); |
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); |
410 |
// |
// |
496 |
exit(-4); |
exit(-4); |
497 |
}; |
}; |
498 |
printf("\n Run %u belongs to file %s \n",run,(glroot->PATH+glroot->NAME).Data()); |
printf("\n Run %u belongs to file %s \n",run,(glroot->PATH+glroot->NAME).Data()); |
499 |
|
//filename = glroot->NAME; |
500 |
found = true; |
found = true; |
501 |
}; |
}; |
502 |
// |
// |
545 |
}; |
}; |
546 |
delete pResult; |
delete pResult; |
547 |
if ( !ID && !ID_RAW ){ |
if ( !ID && !ID_RAW ){ |
548 |
printf("\n No file with name %s in the DB!\n",filename.Data()); |
if ( !neat ) printf("\n No file with name %s in the DB!\n",filename.Data()); |
549 |
} else { |
} else { |
550 |
myquery.str(""); |
myquery.str(""); |
551 |
myquery << "select "; |
myquery << "select "; |
552 |
myquery << " ID,RUNHEADER_TIME,RUNTRAILER_TIME "; |
myquery << " ID,RUNHEADER_TIME,RUNTRAILER_TIME,NEVENTS "; |
553 |
myquery << " from GL_RUN where ID_ROOT_L0=" << ID << ";"; |
myquery << " from GL_RUN where ID_ROOT_L0=" << ID << ";"; |
554 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
555 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
556 |
Row = pResult->Next(); |
Row = pResult->Next(); |
557 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
558 |
found = true; |
found = true; |
559 |
if ( !r ) printf("\n File %s contains the following runs: \n\n",filename.Data()); |
if ( !r && !neat ) printf("\n File %s contains the following runs: \n\n",filename.Data()); |
560 |
TString UTC="UTC"; |
TString UTC=tzone.Data(); |
561 |
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()); |
if ( !neat ) printf(" => ID = %u --> 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))); |
562 |
|
if ( neat ) printf("%u\n",(UInt_t)atoll(Row->GetField(0))); |
563 |
}; |
}; |
564 |
delete pResult; |
delete pResult; |
565 |
myquery.str(""); |
myquery.str(""); |
570 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
571 |
Row = pResult->Next(); |
Row = pResult->Next(); |
572 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
573 |
if ( !r ) printf("\n File %s contains the following DELETED runs: \n\n",filename.Data()); |
if ( !r && !neat ) printf("\n File %s contains the following DELETED runs: \n\n",filename.Data()); |
574 |
TString UTC="UTC"; |
TString UTC=tzone.Data(); |
575 |
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()); |
if ( !neat ) 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()); |
576 |
}; |
}; |
577 |
// |
// |
578 |
if ( !found ){ |
if ( !found ){ |
579 |
printf("\n No run associated to the file %s \n",filename.Data()); |
if ( !neat ) printf("\n No run associated to the file %s \n",filename.Data()); |
580 |
}; |
}; |
581 |
myquery.str(""); |
myquery.str(""); |
582 |
myquery << "select "; |
myquery << "select "; |
592 |
}; |
}; |
593 |
}; |
}; |
594 |
delete pResult; |
delete pResult; |
595 |
printf("\n File %s belongs to raw data file %s/%s \n",filename.Data(),rawpath,rawname); |
if ( !neat ) printf("\n File %s belongs to raw data file %s/%s \n",filename.Data(),rawpath,rawname); |
596 |
}; |
}; |
597 |
}; |
}; |
598 |
// |
// |
599 |
|
// Which runs are contained in the file "l2filename"? |
600 |
|
// |
601 |
|
if ( strcmp(l2filename.Data(),"") ){ |
602 |
|
// ---------------- |
603 |
|
Bool_t found = false; |
604 |
|
Int_t ID = 0; |
605 |
|
Int_t ID_RAW = 0; |
606 |
|
// |
607 |
|
const char *rawpath = ""; |
608 |
|
const char *rawname = ""; |
609 |
|
// |
610 |
|
myquery.str(""); |
611 |
|
myquery << "select "; |
612 |
|
myquery << " ID"; |
613 |
|
myquery << ",ID_RAW"; |
614 |
|
myquery << ",PATH"; |
615 |
|
myquery << ",NAME"; |
616 |
|
myquery << " from GL_ROOT where NAME=\"" << l2filename.Data() << "\" order by INSERT_TIME desc limit 1;"; |
617 |
|
pResult = dbc->Query(myquery.str().c_str()); |
618 |
|
for( r=0; r < 1000; r++){ |
619 |
|
Row = pResult->Next(); |
620 |
|
if( Row == NULL ) break; |
621 |
|
for( t = 0; t < pResult->GetFieldCount(); t++){ |
622 |
|
if(t==0) ID = atoi(Row->GetField(t)); |
623 |
|
if(t==1) ID_RAW = atoi(Row->GetField(t)); |
624 |
|
}; |
625 |
|
}; |
626 |
|
delete pResult; |
627 |
|
if ( !ID ){ |
628 |
|
printf("\n No file with name %s in the DB!\n",l2filename.Data()); |
629 |
|
} else { |
630 |
|
nr = 0; |
631 |
|
rlist[0] = 0; |
632 |
|
myquery.str(""); |
633 |
|
myquery << "select "; |
634 |
|
myquery << " ID,ID_ROOT_L0 "; |
635 |
|
myquery << " from GL_RUN where ID_ROOT_L2=" << ID << ";"; |
636 |
|
pResult = dbc->Query(myquery.str().c_str()); |
637 |
|
for( r=0; r < pResult->GetRowCount(); r++){ |
638 |
|
Row = pResult->Next(); |
639 |
|
if( Row == NULL ) break; |
640 |
|
found = true; |
641 |
|
if ( !r ) printf("\n File %s contains the following runs: \n\n",l2filename.Data()); |
642 |
|
printf(" %u ",(UInt_t)atoll(Row->GetField(0))); |
643 |
|
if ( r < (pResult->GetRowCount()-1) ){ |
644 |
|
printf("-"); |
645 |
|
} else { |
646 |
|
printf("\n\n"); |
647 |
|
}; |
648 |
|
if ( (UInt_t)atoll(Row->GetField(1)) != rlist[nr] ){ |
649 |
|
nr++; |
650 |
|
rlist[nr] = (UInt_t)atoll(Row->GetField(1)); |
651 |
|
}; |
652 |
|
}; |
653 |
|
delete pResult; |
654 |
|
// |
655 |
|
printf("\n File %s contains runs from L0 files: \n\n",l2filename.Data()); |
656 |
|
for (UInt_t l=1; l<nr+1; l++){ |
657 |
|
myquery.str(""); |
658 |
|
myquery << "select "; |
659 |
|
myquery << " PATH,NAME"; |
660 |
|
myquery << " from GL_ROOT where ID=" << rlist[l] << ";"; |
661 |
|
pResult = dbc->Query(myquery.str().c_str()); |
662 |
|
for( r=0; r < pResult->GetRowCount(); r++){ |
663 |
|
Row = pResult->Next(); |
664 |
|
if( Row == NULL ) break; |
665 |
|
for( t = 0; t < pResult->GetFieldCount(); t++){ |
666 |
|
if(t==0) rawpath = Row->GetField(t); |
667 |
|
if(t==1) rawname = Row->GetField(t); |
668 |
|
}; |
669 |
|
printf(" %s/%s \n",rawpath,rawname); |
670 |
|
}; |
671 |
|
delete pResult; |
672 |
|
}; |
673 |
|
}; |
674 |
|
}; |
675 |
|
// |
676 |
|
// |
677 |
|
// Show relationship between files around file "splitat" |
678 |
|
// |
679 |
|
if ( strcmp(splitat.Data(),"") ){ |
680 |
|
// ---------------- |
681 |
|
Int_t ID = 0; |
682 |
|
Int_t IDR = 0; |
683 |
|
TString PATH; |
684 |
|
TString NAME; |
685 |
|
UInt_t atime1 = 0; |
686 |
|
UInt_t atime2 = 0; |
687 |
|
// |
688 |
|
myquery.str(""); |
689 |
|
myquery << " select ID,PATH,NAME from GL_ROOT where NAME>=\"" << splitat.Data() << "\" order by NAME asc limit 20;"; |
690 |
|
// printf(" myquery is %s \n",myquery.str().c_str()); |
691 |
|
pResult = dbc->Query(myquery.str().c_str()); |
692 |
|
GL_TIMESYNC *dbtime; |
693 |
|
GL_S4_CALIB *glS4calib; |
694 |
|
GL_ROOT *glroot; |
695 |
|
for( r=0; r < 1000; r++){ |
696 |
|
Row = pResult->Next(); |
697 |
|
if( Row == NULL ) break; |
698 |
|
Int_t s=0; |
699 |
|
Int_t t=0; |
700 |
|
Int_t c=0; |
701 |
|
TString *s4files[500]; |
702 |
|
TString *tfiles[500]; |
703 |
|
TString *cfiles[2000]; |
704 |
|
ID = atoi(Row->GetField(0)); |
705 |
|
PATH = Row->GetField(1); |
706 |
|
NAME = Row->GetField(2); |
707 |
|
printf("\n FILE: %s/%s \n",PATH.Data(),NAME.Data()); |
708 |
|
myquery.str(""); |
709 |
|
myquery << " select ID,RUNHEADER_OBT,RUNTRAILER_OBT from GL_RUN where ID_ROOT_L0=" << ID << ";"; |
710 |
|
pResult2 = dbc->Query(myquery.str().c_str()); |
711 |
|
for( Int_t run=0; run < pResult2->GetRowCount(); run++){ |
712 |
|
Row2 = pResult2->Next(); |
713 |
|
if( Row2 == NULL ) break; |
714 |
|
IDR = atoi(Row2->GetField(0)); |
715 |
|
// |
716 |
|
// here we make queries to DB looking for needed files and print results |
717 |
|
// |
718 |
|
dbtime = new GL_TIMESYNC(ID,"ID",dbc); |
719 |
|
// |
720 |
|
atime1 = dbtime->DBabsTime(atoi(Row2->GetField(1))); |
721 |
|
atime2 = dbtime->DBabsTime(atoi(Row2->GetField(2))); |
722 |
|
// |
723 |
|
// S4 |
724 |
|
// |
725 |
|
glS4calib = new GL_S4_CALIB(); |
726 |
|
glS4calib->Query_GL_S4_CALIB(atime1, dbc); |
727 |
|
glroot = new GL_ROOT(); |
728 |
|
glroot->Query_GL_ROOT(glS4calib->ID_ROOT_L0,dbc); |
729 |
|
// |
730 |
|
if ( s > 0 ){ |
731 |
|
Bool_t found = false; |
732 |
|
for (Int_t g=0; g<s; g++){ |
733 |
|
if ( !strcmp(glroot->NAME.Data(),s4files[g]->Data()) ){ |
734 |
|
found = true; |
735 |
|
}; |
736 |
|
}; |
737 |
|
if ( !found && strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
738 |
|
s4files[s] = new TString(glroot->NAME.Data()); |
739 |
|
s++; |
740 |
|
}; |
741 |
|
} else { |
742 |
|
if ( strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
743 |
|
s4files[s] = new TString(glroot->NAME.Data()); |
744 |
|
s++; |
745 |
|
}; |
746 |
|
}; |
747 |
|
// |
748 |
|
delete glS4calib; |
749 |
|
delete dbtime; |
750 |
|
delete glroot; |
751 |
|
// |
752 |
|
// TRACKER |
753 |
|
// |
754 |
|
GL_TRK_CALIB q2; |
755 |
|
q2.Query_GL_TRK_CALIB(atime1,dbc); |
756 |
|
GL_ROOT q3; |
757 |
|
q3.Query_GL_ROOT(q2.ID_ROOT_L0,dbc); |
758 |
|
// |
759 |
|
if ( t > 0 ){ |
760 |
|
Bool_t found = false; |
761 |
|
for (Int_t gt=0; gt<t; gt++){ |
762 |
|
if ( !strcmp(q3.NAME.Data(),tfiles[gt]->Data()) ){ |
763 |
|
found = true; |
764 |
|
}; |
765 |
|
}; |
766 |
|
if ( !found && strcmp(q3.NAME.Data(),NAME.Data()) ){ |
767 |
|
tfiles[t] = new TString(q3.NAME.Data()); |
768 |
|
t++; |
769 |
|
}; |
770 |
|
} else { |
771 |
|
if ( strcmp(q3.NAME.Data(),NAME.Data()) ){ |
772 |
|
tfiles[t] = new TString(q3.NAME.Data()); |
773 |
|
t++; |
774 |
|
}; |
775 |
|
}; |
776 |
|
// |
777 |
|
// CALO |
778 |
|
// |
779 |
|
GL_CALO_CALIB *glcalo = new GL_CALO_CALIB(); |
780 |
|
GL_CALOPULSE_CALIB *glp = new GL_CALOPULSE_CALIB(); |
781 |
|
GL_ROOT *glroot = new GL_ROOT(); |
782 |
|
// |
783 |
|
for (Int_t sc=0; sc<4; sc++){ |
784 |
|
// |
785 |
|
UInt_t pampli = 0; |
786 |
|
glcalo->Query_GL_CALO_CALIB(atime1,pampli,sc,dbc); |
787 |
|
glroot->Query_GL_ROOT(glcalo->ID_ROOT_L0,dbc); |
788 |
|
if ( c > 0 ){ |
789 |
|
Bool_t found = false; |
790 |
|
for (Int_t gt=0; gt<c; gt++){ |
791 |
|
if ( !strcmp(glroot->NAME.Data(),cfiles[gt]->Data()) ){ |
792 |
|
found = true; |
793 |
|
}; |
794 |
|
}; |
795 |
|
if ( !found && strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
796 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
797 |
|
c++; |
798 |
|
}; |
799 |
|
} else { |
800 |
|
if ( strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
801 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
802 |
|
c++; |
803 |
|
}; |
804 |
|
}; |
805 |
|
// |
806 |
|
pampli = 0; |
807 |
|
glcalo->Query_GL_CALO_CALIB(atime2,pampli,sc,dbc); |
808 |
|
glroot->Query_GL_ROOT(glcalo->ID_ROOT_L0,dbc); |
809 |
|
if ( c > 0 ){ |
810 |
|
Bool_t found = false; |
811 |
|
for (Int_t gt=0; gt<c; gt++){ |
812 |
|
if ( !strcmp(glroot->NAME.Data(),cfiles[gt]->Data()) ){ |
813 |
|
found = true; |
814 |
|
}; |
815 |
|
}; |
816 |
|
if ( !found && strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
817 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
818 |
|
c++; |
819 |
|
}; |
820 |
|
} else { |
821 |
|
if ( strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
822 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
823 |
|
c++; |
824 |
|
}; |
825 |
|
}; |
826 |
|
// |
827 |
|
pampli = 2; |
828 |
|
glp->Query_GL_CALOPULSE_CALIB(atime1,sc,pampli,dbc); |
829 |
|
glroot->Query_GL_ROOT(glp->ID_ROOT_L0,dbc); |
830 |
|
if ( c > 0 ){ |
831 |
|
Bool_t found = false; |
832 |
|
for (Int_t gt=0; gt<c; gt++){ |
833 |
|
if ( !strcmp(glroot->NAME.Data(),cfiles[gt]->Data()) ){ |
834 |
|
found = true; |
835 |
|
}; |
836 |
|
}; |
837 |
|
if ( !found && strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
838 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
839 |
|
c++; |
840 |
|
}; |
841 |
|
} else { |
842 |
|
if ( strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
843 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
844 |
|
c++; |
845 |
|
}; |
846 |
|
}; |
847 |
|
// |
848 |
|
pampli = 0; |
849 |
|
glp->Query_GL_CALOPULSE_CALIB(atime1,sc,pampli,dbc); |
850 |
|
glroot->Query_GL_ROOT(glp->ID_ROOT_L0,dbc); |
851 |
|
if ( c > 0 ){ |
852 |
|
Bool_t found = false; |
853 |
|
for (Int_t gt=0; gt<c; gt++){ |
854 |
|
if ( !strcmp(glroot->NAME.Data(),cfiles[gt]->Data()) ){ |
855 |
|
found = true; |
856 |
|
}; |
857 |
|
}; |
858 |
|
if ( !found && strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
859 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
860 |
|
c++; |
861 |
|
}; |
862 |
|
} else { |
863 |
|
if ( strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
864 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
865 |
|
c++; |
866 |
|
}; |
867 |
|
}; |
868 |
|
// |
869 |
|
pampli = 2; |
870 |
|
glp->Query_GL_CALOPULSE_CALIB(atime2,sc,pampli,dbc); |
871 |
|
glroot->Query_GL_ROOT(glp->ID_ROOT_L0,dbc); |
872 |
|
if ( c > 0 ){ |
873 |
|
Bool_t found = false; |
874 |
|
for (Int_t gt=0; gt<c; gt++){ |
875 |
|
if ( !strcmp(glroot->NAME.Data(),cfiles[gt]->Data()) ){ |
876 |
|
found = true; |
877 |
|
}; |
878 |
|
}; |
879 |
|
if ( !found && strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
880 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
881 |
|
c++; |
882 |
|
}; |
883 |
|
} else { |
884 |
|
if ( strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
885 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
886 |
|
c++; |
887 |
|
}; |
888 |
|
}; |
889 |
|
// |
890 |
|
pampli = 0; |
891 |
|
glp->Query_GL_CALOPULSE_CALIB(atime2,sc,pampli,dbc); |
892 |
|
glroot->Query_GL_ROOT(glp->ID_ROOT_L0,dbc); |
893 |
|
if ( c > 0 ){ |
894 |
|
Bool_t found = false; |
895 |
|
for (Int_t gt=0; gt<c; gt++){ |
896 |
|
if ( !strcmp(glroot->NAME.Data(),cfiles[gt]->Data()) ){ |
897 |
|
found = true; |
898 |
|
}; |
899 |
|
}; |
900 |
|
if ( !found && strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
901 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
902 |
|
c++; |
903 |
|
}; |
904 |
|
} else { |
905 |
|
if ( strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
906 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
907 |
|
c++; |
908 |
|
}; |
909 |
|
}; |
910 |
|
// |
911 |
|
}; |
912 |
|
}; |
913 |
|
printf(" S4 requires:"); |
914 |
|
for (Int_t f=0;f<s; f++){ |
915 |
|
printf(" %s",s4files[f]->Data()); |
916 |
|
delete s4files[f]; |
917 |
|
}; |
918 |
|
printf("\n"); |
919 |
|
printf(" Tracker requires:"); |
920 |
|
for (Int_t f=0;f<t; f++){ |
921 |
|
printf(" %s",tfiles[f]->Data()); |
922 |
|
delete tfiles[f]; |
923 |
|
}; |
924 |
|
printf("\n"); |
925 |
|
printf(" Calorimeter requires:"); |
926 |
|
for (Int_t f=0;f<c; f++){ |
927 |
|
printf(" %s",cfiles[f]->Data()); |
928 |
|
delete cfiles[f]; |
929 |
|
}; |
930 |
|
printf("\n\n#################################################\n"); |
931 |
|
// |
932 |
|
}; |
933 |
|
delete pResult; |
934 |
|
if ( pResult2 ) delete pResult2; |
935 |
|
}; |
936 |
|
// |
937 |
// Close the DB connection |
// Close the DB connection |
938 |
// |
// |
939 |
if ( dbc ) dbc->Close(); |
if ( dbc ) dbc->Close(); |
940 |
// |
// |
941 |
printf("\n"); |
if ( !neat ) printf("\n"); |
942 |
// |
// |
943 |
exit(0); |
exit(0); |
944 |
} |
} |