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(" -deps file shows dependencies of the given file\n"); |
44 |
|
printf(" -splitat file shows dependenices of the given file and the following files (given by -nsplit)\n"); |
45 |
|
printf(" -nsplit number number of files to be shown by -splitat [default 20]\n"); |
46 |
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"); |
47 |
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"); |
48 |
printf(" -runat date returns run number which contains the given date,\n"); |
printf(" -runat date returns run number which contains the given date,\n"); |
72 |
// |
// |
73 |
TString filename = ""; |
TString filename = ""; |
74 |
TString l2filename = ""; |
TString l2filename = ""; |
75 |
|
TString splitat = ""; |
76 |
|
UInt_t nsplit = 20; |
77 |
// |
// |
78 |
TSQLServer *dbc = 0; |
TSQLServer *dbc = 0; |
79 |
TString host = "mysql://localhost/pamelaprod"; |
TString host = "mysql://localhost/pamelaprod"; |
112 |
// |
// |
113 |
TSQLResult *pResult; |
TSQLResult *pResult; |
114 |
TSQLRow *Row; |
TSQLRow *Row; |
115 |
|
TSQLResult *pResult2 = 0; |
116 |
|
TSQLRow *Row2; |
117 |
int t; |
int t; |
118 |
int r; |
int r; |
119 |
stringstream myquery; |
stringstream myquery; |
148 |
}; |
}; |
149 |
filename = (TString)inps[i+1]; |
filename = (TString)inps[i+1]; |
150 |
}; |
}; |
151 |
|
if ( !strcmp(inps[i],"-splitat") ) { |
152 |
|
if ( numinp-1 < i+1 ){ |
153 |
|
r2d2usage(); |
154 |
|
exit(-3); |
155 |
|
}; |
156 |
|
splitat = (TString)inps[i+1]; |
157 |
|
}; |
158 |
|
// |
159 |
|
if ( !strcmp(inps[i],"-nsplit") ) { |
160 |
|
if ( numinp-1 < i+1 ){ |
161 |
|
r2d2usage(); |
162 |
|
exit(-3); |
163 |
|
}; |
164 |
|
nsplit = (UInt_t)atoll(inps[i+1]); |
165 |
|
}; |
166 |
|
if ( !strcmp(inps[i],"-deps") ) { |
167 |
|
if ( numinp-1 < i+1 ){ |
168 |
|
r2d2usage(); |
169 |
|
exit(-3); |
170 |
|
}; |
171 |
|
nsplit = 1; |
172 |
|
splitat = (TString)inps[i+1]; |
173 |
|
}; |
174 |
if ( !strcmp(inps[i],"-l2filename") ) { |
if ( !strcmp(inps[i],"-l2filename") ) { |
175 |
if ( numinp-1 < i+1 ){ |
if ( numinp-1 < i+1 ){ |
176 |
r2d2usage(); |
r2d2usage(); |
692 |
}; |
}; |
693 |
}; |
}; |
694 |
// |
// |
695 |
|
// |
696 |
|
// Show relationship between files around file "splitat" |
697 |
|
// |
698 |
|
if ( strcmp(splitat.Data(),"") ){ |
699 |
|
// ---------------- |
700 |
|
Int_t ID = 0; |
701 |
|
Int_t IDR = 0; |
702 |
|
TString PATH; |
703 |
|
TString NAME; |
704 |
|
UInt_t atime1 = 0; |
705 |
|
UInt_t atime2 = 0; |
706 |
|
UInt_t minid = 0; |
707 |
|
UInt_t maxid = 0; |
708 |
|
// |
709 |
|
myquery.str(""); |
710 |
|
myquery << " select ID,PATH,NAME from GL_ROOT where NAME>=\"" << splitat.Data() << "\" order by NAME asc limit " << nsplit << ";"; |
711 |
|
// printf(" myquery is %s \n",myquery.str().c_str()); |
712 |
|
pResult = dbc->Query(myquery.str().c_str()); |
713 |
|
GL_TIMESYNC *dbtime; |
714 |
|
GL_S4_CALIB *glS4calib; |
715 |
|
GL_ROOT *glroot; |
716 |
|
for( r=0; r < 1000; r++){ |
717 |
|
Row = pResult->Next(); |
718 |
|
if( Row == NULL ) break; |
719 |
|
printf("\n\n#################################################\n"); |
720 |
|
Int_t s=0; |
721 |
|
Int_t t=0; |
722 |
|
Int_t c=0; |
723 |
|
TString *s4files[500]; |
724 |
|
TString *tfiles[500]; |
725 |
|
TString *cfiles[2000]; |
726 |
|
ID = atoi(Row->GetField(0)); |
727 |
|
PATH = Row->GetField(1); |
728 |
|
NAME = Row->GetField(2); |
729 |
|
printf("\n FILE: %s/%s \n",PATH.Data(),NAME.Data()); |
730 |
|
myquery.str(""); |
731 |
|
myquery << " select ID,RUNHEADER_OBT,RUNTRAILER_OBT from GL_RUN where ID_ROOT_L0=" << ID << " order by ID;"; |
732 |
|
pResult2 = dbc->Query(myquery.str().c_str()); |
733 |
|
for( Int_t run=0; run < pResult2->GetRowCount(); run++){ |
734 |
|
Row2 = pResult2->Next(); |
735 |
|
if( Row2 == NULL ) break; |
736 |
|
IDR = atoi(Row2->GetField(0)); |
737 |
|
if ( run == 0 ) minid = IDR; |
738 |
|
if ( run == pResult2->GetRowCount()-1 ) maxid = IDR; |
739 |
|
// |
740 |
|
// here we make queries to DB looking for needed files and print results |
741 |
|
// |
742 |
|
dbtime = new GL_TIMESYNC(ID,"ID",dbc); |
743 |
|
// |
744 |
|
atime1 = dbtime->DBabsTime((UInt_t)atoll(Row2->GetField(1))); |
745 |
|
atime2 = dbtime->DBabsTime((UInt_t)atoll(Row2->GetField(2))); |
746 |
|
// printf(" atime1 %u atime2 %u field 1 %s field2 %s \n",atime1,atime2,Row2->GetField(1),Row2->GetField(2)); |
747 |
|
// |
748 |
|
// S4 |
749 |
|
// |
750 |
|
glS4calib = new GL_S4_CALIB(); |
751 |
|
glS4calib->Query_GL_S4_CALIB(atime1, dbc); |
752 |
|
glroot = new GL_ROOT(); |
753 |
|
glroot->Query_GL_ROOT(glS4calib->ID_ROOT_L0,dbc); |
754 |
|
// |
755 |
|
if ( s > 0 ){ |
756 |
|
Bool_t found = false; |
757 |
|
for (Int_t g=0; g<s; g++){ |
758 |
|
if ( !strcmp(glroot->NAME.Data(),s4files[g]->Data()) ){ |
759 |
|
found = true; |
760 |
|
}; |
761 |
|
}; |
762 |
|
if ( !found && strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
763 |
|
s4files[s] = new TString(glroot->NAME.Data()); |
764 |
|
s++; |
765 |
|
}; |
766 |
|
} else { |
767 |
|
if ( strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
768 |
|
s4files[s] = new TString(glroot->NAME.Data()); |
769 |
|
s++; |
770 |
|
}; |
771 |
|
}; |
772 |
|
// |
773 |
|
delete glS4calib; |
774 |
|
delete dbtime; |
775 |
|
delete glroot; |
776 |
|
// |
777 |
|
// TRACKER |
778 |
|
// |
779 |
|
GL_TRK_CALIB q2; |
780 |
|
q2.Query_GL_TRK_CALIB(atime1,dbc); |
781 |
|
GL_ROOT q3; |
782 |
|
q3.Query_GL_ROOT(q2.ID_ROOT_L0,dbc); |
783 |
|
// |
784 |
|
if ( t > 0 ){ |
785 |
|
Bool_t found = false; |
786 |
|
for (Int_t gt=0; gt<t; gt++){ |
787 |
|
if ( !strcmp(q3.NAME.Data(),tfiles[gt]->Data()) ){ |
788 |
|
found = true; |
789 |
|
}; |
790 |
|
}; |
791 |
|
if ( !found && strcmp(q3.NAME.Data(),NAME.Data()) ){ |
792 |
|
tfiles[t] = new TString(q3.NAME.Data()); |
793 |
|
t++; |
794 |
|
}; |
795 |
|
} else { |
796 |
|
if ( strcmp(q3.NAME.Data(),NAME.Data()) ){ |
797 |
|
tfiles[t] = new TString(q3.NAME.Data()); |
798 |
|
t++; |
799 |
|
}; |
800 |
|
}; |
801 |
|
// |
802 |
|
// CALO |
803 |
|
// |
804 |
|
GL_CALO_CALIB *glcalo = new GL_CALO_CALIB(); |
805 |
|
GL_CALOPULSE_CALIB *glp = new GL_CALOPULSE_CALIB(); |
806 |
|
GL_ROOT *glroot = new GL_ROOT(); |
807 |
|
// |
808 |
|
for (Int_t sc=0; sc<4; sc++){ |
809 |
|
// |
810 |
|
UInt_t pampli = 0; |
811 |
|
glcalo->Query_GL_CALO_CALIB(atime1,pampli,sc,dbc); |
812 |
|
glroot->Query_GL_ROOT(glcalo->ID_ROOT_L0,dbc); |
813 |
|
if ( c > 0 ){ |
814 |
|
Bool_t found = false; |
815 |
|
for (Int_t gt=0; gt<c; gt++){ |
816 |
|
if ( !strcmp(glroot->NAME.Data(),cfiles[gt]->Data()) ){ |
817 |
|
found = true; |
818 |
|
}; |
819 |
|
}; |
820 |
|
if ( !found && strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
821 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
822 |
|
c++; |
823 |
|
}; |
824 |
|
} else { |
825 |
|
if ( strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
826 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
827 |
|
c++; |
828 |
|
}; |
829 |
|
}; |
830 |
|
// |
831 |
|
pampli = 0; |
832 |
|
glcalo->Query_GL_CALO_CALIB(atime2,pampli,sc,dbc); |
833 |
|
glroot->Query_GL_ROOT(glcalo->ID_ROOT_L0,dbc); |
834 |
|
if ( c > 0 ){ |
835 |
|
Bool_t found = false; |
836 |
|
for (Int_t gt=0; gt<c; gt++){ |
837 |
|
if ( !strcmp(glroot->NAME.Data(),cfiles[gt]->Data()) ){ |
838 |
|
found = true; |
839 |
|
}; |
840 |
|
}; |
841 |
|
if ( !found && strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
842 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
843 |
|
c++; |
844 |
|
}; |
845 |
|
} else { |
846 |
|
if ( strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
847 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
848 |
|
c++; |
849 |
|
}; |
850 |
|
}; |
851 |
|
// |
852 |
|
pampli = 2; |
853 |
|
glp->Query_GL_CALOPULSE_CALIB(atime1,sc,pampli,dbc); |
854 |
|
glroot->Query_GL_ROOT(glp->ID_ROOT_L0,dbc); |
855 |
|
if ( c > 0 ){ |
856 |
|
Bool_t found = false; |
857 |
|
for (Int_t gt=0; gt<c; gt++){ |
858 |
|
if ( !strcmp(glroot->NAME.Data(),cfiles[gt]->Data()) ){ |
859 |
|
found = true; |
860 |
|
}; |
861 |
|
}; |
862 |
|
if ( !found && strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
863 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
864 |
|
c++; |
865 |
|
}; |
866 |
|
} else { |
867 |
|
if ( strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
868 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
869 |
|
c++; |
870 |
|
}; |
871 |
|
}; |
872 |
|
// |
873 |
|
pampli = 0; |
874 |
|
glp->Query_GL_CALOPULSE_CALIB(atime1,sc,pampli,dbc); |
875 |
|
glroot->Query_GL_ROOT(glp->ID_ROOT_L0,dbc); |
876 |
|
if ( c > 0 ){ |
877 |
|
Bool_t found = false; |
878 |
|
for (Int_t gt=0; gt<c; gt++){ |
879 |
|
if ( !strcmp(glroot->NAME.Data(),cfiles[gt]->Data()) ){ |
880 |
|
found = true; |
881 |
|
}; |
882 |
|
}; |
883 |
|
if ( !found && strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
884 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
885 |
|
c++; |
886 |
|
}; |
887 |
|
} else { |
888 |
|
if ( strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
889 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
890 |
|
c++; |
891 |
|
}; |
892 |
|
}; |
893 |
|
// |
894 |
|
pampli = 2; |
895 |
|
glp->Query_GL_CALOPULSE_CALIB(atime2,sc,pampli,dbc); |
896 |
|
glroot->Query_GL_ROOT(glp->ID_ROOT_L0,dbc); |
897 |
|
if ( c > 0 ){ |
898 |
|
Bool_t found = false; |
899 |
|
for (Int_t gt=0; gt<c; gt++){ |
900 |
|
if ( !strcmp(glroot->NAME.Data(),cfiles[gt]->Data()) ){ |
901 |
|
found = true; |
902 |
|
}; |
903 |
|
}; |
904 |
|
if ( !found && strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
905 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
906 |
|
c++; |
907 |
|
}; |
908 |
|
} else { |
909 |
|
if ( strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
910 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
911 |
|
c++; |
912 |
|
}; |
913 |
|
}; |
914 |
|
// |
915 |
|
pampli = 0; |
916 |
|
glp->Query_GL_CALOPULSE_CALIB(atime2,sc,pampli,dbc); |
917 |
|
glroot->Query_GL_ROOT(glp->ID_ROOT_L0,dbc); |
918 |
|
if ( c > 0 ){ |
919 |
|
Bool_t found = false; |
920 |
|
for (Int_t gt=0; gt<c; gt++){ |
921 |
|
if ( !strcmp(glroot->NAME.Data(),cfiles[gt]->Data()) ){ |
922 |
|
found = true; |
923 |
|
}; |
924 |
|
}; |
925 |
|
if ( !found && strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
926 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
927 |
|
c++; |
928 |
|
}; |
929 |
|
} else { |
930 |
|
if ( strcmp(glroot->NAME.Data(),NAME.Data()) ){ |
931 |
|
cfiles[c] = new TString(glroot->NAME.Data()); |
932 |
|
c++; |
933 |
|
}; |
934 |
|
}; |
935 |
|
// |
936 |
|
}; |
937 |
|
}; |
938 |
|
printf(" S4 requires:"); |
939 |
|
for (Int_t f=0;f<s; f++){ |
940 |
|
printf(" %s",s4files[f]->Data()); |
941 |
|
delete s4files[f]; |
942 |
|
}; |
943 |
|
printf("\n"); |
944 |
|
printf(" Tracker requires:"); |
945 |
|
for (Int_t f=0;f<t; f++){ |
946 |
|
printf(" %s",tfiles[f]->Data()); |
947 |
|
delete tfiles[f]; |
948 |
|
}; |
949 |
|
printf("\n"); |
950 |
|
printf(" Calorimeter requires:"); |
951 |
|
for (Int_t f=0;f<c; f++){ |
952 |
|
printf(" %s",cfiles[f]->Data()); |
953 |
|
delete cfiles[f]; |
954 |
|
}; |
955 |
|
printf("\n\n"); |
956 |
|
printf(" Minimum ID number in the file: %u \n",minid); |
957 |
|
printf(" Maximum ID number in the file: %u \n",maxid); |
958 |
|
printf("\n#################################################\n"); |
959 |
|
// |
960 |
|
}; |
961 |
|
delete pResult; |
962 |
|
if ( pResult2 ) delete pResult2; |
963 |
|
}; |
964 |
|
// |
965 |
// Close the DB connection |
// Close the DB connection |
966 |
// |
// |
967 |
if ( dbc ) dbc->Close(); |
if ( dbc ) dbc->Close(); |