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"; |
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; |
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(); |
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(); |