3 This program reads the DAQ data files passed as argument using the monitoring library.
5 It computes the average event size and populates local "./result.txt" file with the
8 The program reports about its processing progress.
10 Messages on stdout are exported to DAQ log system.
12 DA for ZDC standalone pedestal runs
14 Contact: Chiara.Oppedisano@to.infn.it
16 Run Type: PHYSICS, STANDALONE_BC, STANDALONE_COSMIC, STANDALONE_CENTRAL,
17 STANDALONE_MB, STANDALONE_SEMICENTRAL
19 Number of events needed: no constraint
21 Output Files: ZDCChMapping.dat
25 #define MAPDATA_FILE "ZDCChMapping.dat"
29 #include <Riostream.h>
40 #include <AliRawReaderDate.h>
41 #include <AliRawEventHeaderBase.h>
42 #include <AliZDCRawStream.h>
46 Arguments: list of DATE raw data files
48 int main(int argc, char **argv) {
52 /* log start of process */
53 printf("\nZDC MAPPING program started\n");
55 /* check that we got some arguments = list of files */
57 printf("Wrong number of arguments\n");
61 /* open result file */
63 fp=fopen("./result.txt","a");
65 printf("Failed to open file\n");
69 FILE *mapFile4Shuttle;
72 daqDA_progressReport(10);
75 /* init some counters */
76 int nevents_physics=0;
79 /* read the data files */
83 status=monitorSetDataSource( argv[n] );
85 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
90 /* in this example, indexed on the number of files */
91 daqDA_progressReport(10+80*n/argc);
95 struct eventHeaderStruct *event;
99 status=monitorGetEventDynamic((void **)&event);
100 if(status==MON_ERR_EOF) break; /* end of monitoring file has been reached */
102 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
106 /* retry if got no event */
111 // Initalize raw-data reading and decoding
112 AliRawReader *reader = new AliRawReaderDate((void*)event);
113 reader->Select("ZDC");
114 // --- Reading event header
115 //UInt_t evtype = reader->GetType();
116 //printf("\n\t ZDCPEDESTALda -> ev. type %d\n",evtype);
117 //printf("\t ZDCPEDESTALda -> run # %d\n",reader->GetRunNumber());
119 AliZDCRawStream *rawStreamZDC = new AliZDCRawStream(reader);
122 /* use event - here, just write event id to result file */
123 eventT=event->eventType;
125 Int_t ich=0, adcMod[48], adcCh[48], sigCode[48], det[48], sec[48];
126 if(eventT==START_OF_DATA){
128 if(!rawStreamZDC->Next()) printf(" \t No raw data found!! \n");
130 while(rawStreamZDC->Next()){
131 if(rawStreamZDC->IsChMapping()){
132 adcMod[ich] = rawStreamZDC->GetADCModFromMap(ich);
133 adcCh[ich] = rawStreamZDC->GetADCChFromMap(ich);
134 sigCode[ich] = rawStreamZDC->GetADCSignFromMap(ich);
135 det[ich] = rawStreamZDC->GetDetectorFromMap(ich);
136 sec[ich] = rawStreamZDC->GetTowerFromMap(ich);
141 // --------------------------------------------------------
142 // --- Writing ascii data file for the Shuttle preprocessor
143 mapFile4Shuttle = fopen(MAPDATA_FILE,"w");
144 for(Int_t i=0; i<ich; i++){
145 fprintf(mapFile4Shuttle,"\t%d\t%d\t%d\t%d\t%d\t%d\n",i,
146 adcMod[i],adcCh[i],sigCode[i],det[i],sec[i]);
148 //printf("ZDCPEDESTALDA.cxx -> ch.%d mod %d, ch %d, code %d det %d, sec %d\n",
149 // i,adcMod[i],adcCh[i],sigCode[i],det[i],sec[i]);
151 fclose(mapFile4Shuttle);
163 fprintf(fp,"Run #%s, received %d physics events out of %d\n",getenv("DATE_RUN_NUMBER"),nevents_physics,nevents_total);
165 /* close result file */
168 /* report progress */
169 daqDA_progressReport(90);
171 /* store the result files on FES */
172 status = daqDA_FES_storeFile(MAPDATA_FILE, MAPDATA_FILE);
174 printf("Failed to export file : %d\n",status);
178 /* report progress */
179 daqDA_progressReport(100);