32 |
printf("\n Options are:\n\n"); |
printf("\n Options are:\n\n"); |
33 |
printf(" --version print informations about compilation and exit\n"); |
printf(" --version print informations about compilation and exit\n"); |
34 |
printf(" -h | --help print this help and exit \n"); |
printf(" -h | --help print this help and exit \n"); |
35 |
printf(" -v | --verbose be verbose [default: print nothing on STDOUT]\n"); |
printf(" -v | --verbose be verbose [default]\n"); |
36 |
|
printf(" -n | --neat used with '-filename' returns only the run ID number\n"); |
37 |
printf(" -idRun run ID_RUN: ID number of the run \n"); |
printf(" -idRun run ID_RUN: ID number of the run \n"); |
38 |
printf(" -filename file output yoda filename \n"); |
printf(" -filename file output yoda filename \n"); |
39 |
printf(" -l2filename file output amidala filename \n"); |
printf(" -l2filename file output amidala filename \n"); |
40 |
printf(" -host name of the DB host [default = $PAM_DBHOST or mysql://localhost/pamelaprod]\n"); |
printf(" -host name of the DB host [default = $PAM_DBHOST or mysql://localhost/pamelaprod]\n"); |
41 |
printf(" -user username for the DB connection [default = $PAM_DBUSER or \"anonymous\"] \n"); |
printf(" -user username for the DB connection [default = $PAM_DBUSER or \"anonymous\"] \n"); |
42 |
printf(" -psw password for the DB connection [default = $PAM_DBPSW or \"\"]\n"); |
printf(" -psw password for the DB connection [default = $PAM_DBPSW or \"\"]\n"); |
43 |
|
printf(" -splitat file shows relationship between files around the given file\n"); |
44 |
printf(" -tzone timezone the time zone: UTC,GMT,MSK,MSD,CET,CEST are accepted \n"); |
printf(" -tzone timezone the time zone: UTC,GMT,MSK,MSD,CET,CEST are accepted \n"); |
45 |
printf(" -convert dbtime convert the dbtime given in seconds (from the DB) to a string\n"); |
printf(" -convert dbtime convert the dbtime given in seconds (from the DB) to a string\n"); |
46 |
printf(" -runat date returns run number which contains the given date,\n"); |
printf(" -runat date returns run number which contains the given date,\n"); |
70 |
// |
// |
71 |
TString filename = ""; |
TString filename = ""; |
72 |
TString l2filename = ""; |
TString l2filename = ""; |
73 |
|
TString splitat = ""; |
74 |
// |
// |
75 |
TSQLServer *dbc = 0; |
TSQLServer *dbc = 0; |
76 |
TString host = "mysql://localhost/pamelaprod"; |
TString host = "mysql://localhost/pamelaprod"; |
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; |
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") ) { |
if ( !strcmp(inps[i],"-l2filename") ) { |
156 |
if ( numinp-1 < i+1 ){ |
if ( numinp-1 < i+1 ){ |
157 |
r2d2usage(); |
r2d2usage(); |
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 "; |
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=tzone.Data(); |
TString UTC=tzone.Data(); |
561 |
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))); |
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=tzone.Data(); |
TString UTC=tzone.Data(); |
575 |
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()); |
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 |
// |
// |
613 |
myquery << ",ID_RAW"; |
myquery << ",ID_RAW"; |
614 |
myquery << ",PATH"; |
myquery << ",PATH"; |
615 |
myquery << ",NAME"; |
myquery << ",NAME"; |
616 |
myquery << " from GL_ROOT where NAME=\"" << l2filename.Data() << "\";"; |
myquery << " from GL_ROOT where NAME=\"" << l2filename.Data() << "\" order by INSERT_TIME desc limit 1;"; |
617 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
618 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
619 |
Row = pResult->Next(); |
Row = pResult->Next(); |
645 |
} else { |
} else { |
646 |
printf("\n\n"); |
printf("\n\n"); |
647 |
}; |
}; |
648 |
if ( (UInt_t)atoll(Row->GetField(0)) != rlist[nr] ){ |
if ( (UInt_t)atoll(Row->GetField(1)) != rlist[nr] ){ |
649 |
nr++; |
nr++; |
650 |
rlist[nr] = (UInt_t)atoll(Row->GetField(0)); |
rlist[nr] = (UInt_t)atoll(Row->GetField(1)); |
651 |
}; |
}; |
652 |
}; |
}; |
653 |
delete pResult; |
delete pResult; |
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((UInt_t)atoll(Row2->GetField(1))); |
721 |
|
atime2 = dbtime->DBabsTime((UInt_t)atoll(Row2->GetField(2))); |
722 |
|
// printf(" atime1 %u atime2 %u field 1 %s field2 %s \n",atime1,atime2,Row2->GetField(1),Row2->GetField(2)); |
723 |
|
// |
724 |
|
// S4 |
725 |
|
// |
726 |
|
glS4calib = new GL_S4_CALIB(); |
727 |
|
glS4calib->Query_GL_S4_CALIB(atime1, dbc); |
728 |
|
glroot = new GL_ROOT(); |
729 |
|
glroot->Query_GL_ROOT(glS4calib->ID_ROOT_L0,dbc); |
730 |
|
// |
731 |
|
if ( s > 0 ){ |
732 |
|
Bool_t found = false; |
733 |
|
for (Int_t g=0; g<s; g++){ |
734 |
|
if ( !strcmp(glroot->NAME.Data(),s4files[g]->Data()) ){ |
735 |
|
found = true; |
736 |
|
}; |
737 |
|
}; |
738 |
|
if ( !found && strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
739 |
|
s4files[s] = new TString(glroot->NAME.Data()); |
740 |
|
s++; |
741 |
|
}; |
742 |
|
} else { |
743 |
|
if ( strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
744 |
|
s4files[s] = new TString(glroot->NAME.Data()); |
745 |
|
s++; |
746 |
|
}; |
747 |
|
}; |
748 |
|
// |
749 |
|
delete glS4calib; |
750 |
|
delete dbtime; |
751 |
|
delete glroot; |
752 |
|
// |
753 |
|
// TRACKER |
754 |
|
// |
755 |
|
GL_TRK_CALIB q2; |
756 |
|
q2.Query_GL_TRK_CALIB(atime1,dbc); |
757 |
|
GL_ROOT q3; |
758 |
|
q3.Query_GL_ROOT(q2.ID_ROOT_L0,dbc); |
759 |
|
// |
760 |
|
if ( t > 0 ){ |
761 |
|
Bool_t found = false; |
762 |
|
for (Int_t gt=0; gt<t; gt++){ |
763 |
|
if ( !strcmp(q3.NAME.Data(),tfiles[gt]->Data()) ){ |
764 |
|
found = true; |
765 |
|
}; |
766 |
|
}; |
767 |
|
if ( !found && strcmp(q3.NAME.Data(),NAME.Data()) ){ |
768 |
|
tfiles[t] = new TString(q3.NAME.Data()); |
769 |
|
t++; |
770 |
|
}; |
771 |
|
} else { |
772 |
|
if ( strcmp(q3.NAME.Data(),NAME.Data()) ){ |
773 |
|
tfiles[t] = new TString(q3.NAME.Data()); |
774 |
|
t++; |
775 |
|
}; |
776 |
|
}; |
777 |
|
// |
778 |
|
// CALO |
779 |
|
// |
780 |
|
GL_CALO_CALIB *glcalo = new GL_CALO_CALIB(); |
781 |
|
GL_CALOPULSE_CALIB *glp = new GL_CALOPULSE_CALIB(); |
782 |
|
GL_ROOT *glroot = new GL_ROOT(); |
783 |
|
// |
784 |
|
for (Int_t sc=0; sc<4; sc++){ |
785 |
|
// |
786 |
|
UInt_t pampli = 0; |
787 |
|
glcalo->Query_GL_CALO_CALIB(atime1,pampli,sc,dbc); |
788 |
|
glroot->Query_GL_ROOT(glcalo->ID_ROOT_L0,dbc); |
789 |
|
if ( c > 0 ){ |
790 |
|
Bool_t found = false; |
791 |
|
for (Int_t gt=0; gt<c; gt++){ |
792 |
|
if ( !strcmp(glroot->NAME.Data(),cfiles[gt]->Data()) ){ |
793 |
|
found = true; |
794 |
|
}; |
795 |
|
}; |
796 |
|
if ( !found && strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
797 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
798 |
|
c++; |
799 |
|
}; |
800 |
|
} else { |
801 |
|
if ( strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
802 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
803 |
|
c++; |
804 |
|
}; |
805 |
|
}; |
806 |
|
// |
807 |
|
pampli = 0; |
808 |
|
glcalo->Query_GL_CALO_CALIB(atime2,pampli,sc,dbc); |
809 |
|
glroot->Query_GL_ROOT(glcalo->ID_ROOT_L0,dbc); |
810 |
|
if ( c > 0 ){ |
811 |
|
Bool_t found = false; |
812 |
|
for (Int_t gt=0; gt<c; gt++){ |
813 |
|
if ( !strcmp(glroot->NAME.Data(),cfiles[gt]->Data()) ){ |
814 |
|
found = true; |
815 |
|
}; |
816 |
|
}; |
817 |
|
if ( !found && strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
818 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
819 |
|
c++; |
820 |
|
}; |
821 |
|
} else { |
822 |
|
if ( strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
823 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
824 |
|
c++; |
825 |
|
}; |
826 |
|
}; |
827 |
|
// |
828 |
|
pampli = 2; |
829 |
|
glp->Query_GL_CALOPULSE_CALIB(atime1,sc,pampli,dbc); |
830 |
|
glroot->Query_GL_ROOT(glp->ID_ROOT_L0,dbc); |
831 |
|
if ( c > 0 ){ |
832 |
|
Bool_t found = false; |
833 |
|
for (Int_t gt=0; gt<c; gt++){ |
834 |
|
if ( !strcmp(glroot->NAME.Data(),cfiles[gt]->Data()) ){ |
835 |
|
found = true; |
836 |
|
}; |
837 |
|
}; |
838 |
|
if ( !found && strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
839 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
840 |
|
c++; |
841 |
|
}; |
842 |
|
} else { |
843 |
|
if ( strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
844 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
845 |
|
c++; |
846 |
|
}; |
847 |
|
}; |
848 |
|
// |
849 |
|
pampli = 0; |
850 |
|
glp->Query_GL_CALOPULSE_CALIB(atime1,sc,pampli,dbc); |
851 |
|
glroot->Query_GL_ROOT(glp->ID_ROOT_L0,dbc); |
852 |
|
if ( c > 0 ){ |
853 |
|
Bool_t found = false; |
854 |
|
for (Int_t gt=0; gt<c; gt++){ |
855 |
|
if ( !strcmp(glroot->NAME.Data(),cfiles[gt]->Data()) ){ |
856 |
|
found = true; |
857 |
|
}; |
858 |
|
}; |
859 |
|
if ( !found && strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
860 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
861 |
|
c++; |
862 |
|
}; |
863 |
|
} else { |
864 |
|
if ( strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
865 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
866 |
|
c++; |
867 |
|
}; |
868 |
|
}; |
869 |
|
// |
870 |
|
pampli = 2; |
871 |
|
glp->Query_GL_CALOPULSE_CALIB(atime2,sc,pampli,dbc); |
872 |
|
glroot->Query_GL_ROOT(glp->ID_ROOT_L0,dbc); |
873 |
|
if ( c > 0 ){ |
874 |
|
Bool_t found = false; |
875 |
|
for (Int_t gt=0; gt<c; gt++){ |
876 |
|
if ( !strcmp(glroot->NAME.Data(),cfiles[gt]->Data()) ){ |
877 |
|
found = true; |
878 |
|
}; |
879 |
|
}; |
880 |
|
if ( !found && strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
881 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
882 |
|
c++; |
883 |
|
}; |
884 |
|
} else { |
885 |
|
if ( strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
886 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
887 |
|
c++; |
888 |
|
}; |
889 |
|
}; |
890 |
|
// |
891 |
|
pampli = 0; |
892 |
|
glp->Query_GL_CALOPULSE_CALIB(atime2,sc,pampli,dbc); |
893 |
|
glroot->Query_GL_ROOT(glp->ID_ROOT_L0,dbc); |
894 |
|
if ( c > 0 ){ |
895 |
|
Bool_t found = false; |
896 |
|
for (Int_t gt=0; gt<c; gt++){ |
897 |
|
if ( !strcmp(glroot->NAME.Data(),cfiles[gt]->Data()) ){ |
898 |
|
found = true; |
899 |
|
}; |
900 |
|
}; |
901 |
|
if ( !found && strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
902 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
903 |
|
c++; |
904 |
|
}; |
905 |
|
} else { |
906 |
|
if ( strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
907 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
908 |
|
c++; |
909 |
|
}; |
910 |
|
}; |
911 |
|
// |
912 |
|
}; |
913 |
|
}; |
914 |
|
printf(" S4 requires:"); |
915 |
|
for (Int_t f=0;f<s; f++){ |
916 |
|
printf(" %s",s4files[f]->Data()); |
917 |
|
delete s4files[f]; |
918 |
|
}; |
919 |
|
printf("\n"); |
920 |
|
printf(" Tracker requires:"); |
921 |
|
for (Int_t f=0;f<t; f++){ |
922 |
|
printf(" %s",tfiles[f]->Data()); |
923 |
|
delete tfiles[f]; |
924 |
|
}; |
925 |
|
printf("\n"); |
926 |
|
printf(" Calorimeter requires:"); |
927 |
|
for (Int_t f=0;f<c; f++){ |
928 |
|
printf(" %s",cfiles[f]->Data()); |
929 |
|
delete cfiles[f]; |
930 |
|
}; |
931 |
|
printf("\n\n#################################################\n"); |
932 |
|
// |
933 |
|
}; |
934 |
|
delete pResult; |
935 |
|
if ( pResult2 ) delete pResult2; |
936 |
|
}; |
937 |
|
// |
938 |
// Close the DB connection |
// Close the DB connection |
939 |
// |
// |
940 |
if ( dbc ) dbc->Close(); |
if ( dbc ) dbc->Close(); |
941 |
// |
// |
942 |
printf("\n"); |
if ( !neat ) printf("\n"); |
943 |
// |
// |
944 |
exit(0); |
exit(0); |
945 |
} |
} |