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(" -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"; |
103 |
Bool_t ruti2 = false; |
Bool_t ruti2 = false; |
104 |
Bool_t convobt = false; |
Bool_t convobt = false; |
105 |
Bool_t convobtts = false; |
Bool_t convobtts = false; |
106 |
|
Bool_t neat = false; |
107 |
// |
// |
108 |
UInt_t runtime2 = 0; |
UInt_t runtime2 = 0; |
109 |
UInt_t obt = 0; |
UInt_t obt = 0; |
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; |
131 |
r2d2usage(); |
r2d2usage(); |
132 |
exit(0); |
exit(0); |
133 |
}; |
}; |
134 |
|
if ( !strcmp(inps[i],"-n") || !strcmp(inps[i],"--neat") ){ |
135 |
|
neat = true; |
136 |
|
}; |
137 |
if ( !strcmp(inps[i],"-idRun") ) { |
if ( !strcmp(inps[i],"-idRun") ) { |
138 |
if ( numinp-1 < i+1 ) { |
if ( numinp-1 < i+1 ) { |
139 |
r2d2usage(); |
r2d2usage(); |
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(); |
564 |
}; |
}; |
565 |
delete pResult; |
delete pResult; |
566 |
if ( !ID && !ID_RAW ){ |
if ( !ID && !ID_RAW ){ |
567 |
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()); |
568 |
} else { |
} else { |
569 |
myquery.str(""); |
myquery.str(""); |
570 |
myquery << "select "; |
myquery << "select "; |
575 |
Row = pResult->Next(); |
Row = pResult->Next(); |
576 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
577 |
found = true; |
found = true; |
578 |
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()); |
579 |
TString UTC=tzone.Data(); |
TString UTC=tzone.Data(); |
580 |
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))); |
581 |
|
if ( neat ) printf("%u\n",(UInt_t)atoll(Row->GetField(0))); |
582 |
}; |
}; |
583 |
delete pResult; |
delete pResult; |
584 |
myquery.str(""); |
myquery.str(""); |
589 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
590 |
Row = pResult->Next(); |
Row = pResult->Next(); |
591 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
592 |
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()); |
593 |
TString UTC=tzone.Data(); |
TString UTC=tzone.Data(); |
594 |
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()); |
595 |
}; |
}; |
596 |
// |
// |
597 |
if ( !found ){ |
if ( !found ){ |
598 |
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()); |
599 |
}; |
}; |
600 |
myquery.str(""); |
myquery.str(""); |
601 |
myquery << "select "; |
myquery << "select "; |
611 |
}; |
}; |
612 |
}; |
}; |
613 |
delete pResult; |
delete pResult; |
614 |
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); |
615 |
}; |
}; |
616 |
}; |
}; |
617 |
// |
// |
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(); |
968 |
// |
// |
969 |
printf("\n"); |
if ( !neat ) printf("\n"); |
970 |
// |
// |
971 |
exit(0); |
exit(0); |
972 |
} |
} |