00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 #include <stdio.h>
00084 #include <unistd.h>
00085 #include <errno.h>
00086 #include <sys/types.h>
00087 #include <sys/stat.h>
00088 #include <fcntl.h>
00089 #include <assert.h>
00090 #include "Stiostream.h"
00091
00092 #include "StDaqLib/GENERIC/EventReader.hh"
00093 #include "StDaqLib/EMC/EMC_Reader.hh"
00094 #include "StDaqLib/RICH/RICH_Reader.hh"
00095 #include "StDaqLib/TRG/TRG_Reader.hh"
00096
00097 #include "StDaqLib/TPC/trans_table.hh"
00098
00099
00100
00101
00102
00103 char logfile[80];
00104
00105
00106 char *convert_name_to_logfile(const char *filename)
00107 {
00108 static char locfile[80];
00109 strcpy(locfile,filename);
00110 strcat(locfile,".log");
00111 char *t1;
00112 char *t2 = locfile;
00113 t1 = strtok(locfile,"/");
00114 while (t1!=NULL) {
00115 t2 = t1;
00116 t1 = strtok(NULL,"/");
00117 }
00118 strcpy(locfile,t2);
00119 return locfile;
00120 }
00121
00122 int main(int argc, char *argv[])
00123 {
00124 int fd;
00125 string filename;
00126
00127
00128 u_char *(padlist[TPC_PADROWS]);
00129 long offset = 0L;
00130 int histogram[50] = {50*0};
00131
00132
00133 if (argc==3) offset = atol(argv[2]);
00134
00135 if(argc<2)
00136 {
00137 printf("Usage: %s file.daq [offset]\n",argv[0]);
00138 printf("Example: %s /scratch/2sbWith2Rcv_from_Tape.dat\n",argv[0]);
00139 exit(2);
00140 }
00141 else
00142 {
00143 filename = argv[1];
00144 }
00145
00146 strcpy(logfile,convert_name_to_logfile(filename.c_str()));
00147
00148 printf(" opening log file: %s\n",logfile);
00149
00150 fd = open(filename.c_str(),O_RDONLY);
00151
00152 if (fd == -1)
00153 {
00154 perror("FormatClient");
00155 }
00156
00157 while(offset != -1)
00158 {
00159 EventReader *er = getEventReader(fd,offset,(const char *)logfile,0);
00160 if(!er)
00161 {
00162 cout << "============================================" << endl;
00163 cout << "Error creating ER" << endl;
00164 cout << "This may be simply the end of the .daq file." << endl;
00165 close(fd);
00166 assert(0);
00167 }
00168
00169 er->printEventInfo();
00170
00171
00172
00173 if(offset != -1)
00174 offset = er->NextEventOffset();
00175 else
00176 offset = -1;
00177
00178 TRG_Reader *tr = getTRGReader(er);
00179 if(!tr) {
00180 cout << "Error creating TRG_Reader: " << er->errstr() << endl;
00181 close(fd);
00182 assert(0);
00183 }
00184 else printf("created TRG_Reader!!!\n");
00185
00186
00187
00188
00189
00190 #ifdef DOTPC
00191
00192 DetectorReader *dr = getDetectorReader(er, "TPCV2P0");
00193 if(!dr) {
00194 cout << "Error creating TPC_Reader: " << er->errstr() << endl;
00195 close(fd);
00196 assert(0);
00197 }
00198 else printf("created TPC_Reader!!!\n");
00199 #ifdef DO_SECTORS
00200 for(int sector=1;sector <= 24;sector++)
00201 {
00202
00203 int nSeq[TPC_MAXPADS];
00204 Sequence *Seq[TPC_MAXPADS];
00205
00206
00207 PedestalReader *pedr = dr->getPedestalReader(sector);
00208 if(!pedr)
00209 {
00210 cout << "Error creating pedestal reader: " << dr->errstr() << endl;
00211 close(fd);
00212 assert(0);
00213 }
00214
00215 PedestalRMSReader *rmsr = dr->getPedestalRMSReader(sector);
00216 if(!rmsr)
00217 {
00218 cout << "Error creating pedestal RMS reader: " << dr->errstr() << endl;
00219 close(fd);
00220 assert(0);
00221 }
00222
00223
00224 if (pedr->getNumberOfEvents()==0) continue;
00225 #ifdef PEDS
00226 for(int row=1;row <= TPC_PADROWS; row++)
00227 {
00228 int count = pedr->getPadList(row, &padlist[row-1]);
00229 if (count){
00230 printf("%2d -- pad list\n",row);
00231 for(int i=0;i<count;i++)
00232 {
00233 printf("%4d",padlist[row-1][i]);
00234 }
00235 printf("\n");
00236 }
00237 }
00238
00239 for(int row=1;row <= TPC_PADROWS; row++)
00240 {
00241 int count = pedr->getPadList(row, &padlist[row-1]);
00242
00243 for(int i=0;i<count;i++)
00244 {
00245 int length;
00246 u_char *Array[TPC_MAXPADS];
00247 u_char thispad = padlist[row-1][i];
00248 int nseq = pedr->getSequences(row, thispad, &length, &Array[thispad-1]);
00249
00250 if (!nseq) continue;
00251 printf("pedestal values for row %d, pad %d:\n",row,thispad);
00252 for(int j=0; j<length; j++)
00253 {
00254 printf("%d ", Array[thispad-1][j]);
00255 if (j%16==0) printf("\n");
00256 }
00257 printf("\n");
00258 }
00259 }
00260 #endif
00261 for(int row=1;row <= TPC_PADROWS; row++)
00262 {
00263 int count = rmsr->getPadList(row, &padlist[row-1]);
00264
00265 for(int i=0;i<count;i++)
00266 {
00267 int length;
00268 u_char *Array[TPC_MAXPADS];
00269 u_char thispad = padlist[row-1][i];
00270 int nseq = rmsr->getSequences(row, thispad, &length, &Array[thispad-1]);
00271
00272 if (!nseq) continue;
00273 printf("pedestal RMS values for row %d, pad %d:\n",row,thispad);
00274 for(int j=0; j<length; j++)
00275 {
00276 printf("%4.1f ", (float)Array[thispad-1][j]/16.0);
00277 if (j%16==0) printf("\n");
00278 }
00279 printf("\n");
00280 }
00281 }
00282
00283 delete pedr;
00284 delete rmsr;
00285 }
00286 #endif
00287 delete dr;
00288 #endif
00289 delete tr;
00290 delete er;
00291 }
00292 close(fd);
00293 }
00294