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
28 #include <Riostream.h>
39 #include <AliRawReaderDate.h>
40 #include <AliRawEventHeaderBase.h>
41 #include <AliZDCRawStream.h>
45 Arguments: list of DATE raw data files
47 int main(int argc, char **argv) {
51 /* log start of process */
52 printf("\nZDC MAPPING program started\n");
54 /* check that we got some arguments = list of files */
56 printf("Wrong number of arguments\n");
60 /* open result file */
62 fp=fopen("./result.txt","a");
64 printf("Failed to open file\n");
68 FILE *mapFile4Shuttle;
69 const char *mapfName = "ZDCChMapping.dat";
73 daqDA_progressReport(10);
76 /* init some counters */
77 int nevents_physics=0;
80 /* read the data files */
84 status=monitorSetDataSource( argv[n] );
86 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
91 /* in this example, indexed on the number of files */
92 daqDA_progressReport(10+80*n/argc);
96 struct eventHeaderStruct *event;
100 status=monitorGetEventDynamic((void **)&event);
101 if(status==MON_ERR_EOF) break; /* end of monitoring file has been reached */
103 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
107 /* retry if got no event */
112 // Initalize raw-data reading and decoding
113 AliRawReader *reader = new AliRawReaderDate((void*)event);
114 reader->Select("ZDC");
115 // --- Reading event header
116 //UInt_t evtype = reader->GetType();
117 //printf("\n\t ZDCPEDESTALda -> ev. type %d\n",evtype);
118 //printf("\t ZDCPEDESTALda -> run # %d\n",reader->GetRunNumber());
120 AliZDCRawStream *rawStreamZDC = new AliZDCRawStream(reader);
123 /* use event - here, just write event id to result file */
124 eventT=event->eventType;
126 Int_t ich=0, adcMod[48], adcCh[48], sigCode[48], det[48], sec[48];
127 if(eventT==START_OF_DATA){
129 if(!rawStreamZDC->Next()) printf(" \t No raw data found!! \n");
131 while(rawStreamZDC->Next()){
132 if(rawStreamZDC->IsChMapping()){
133 adcMod[ich] = rawStreamZDC->GetADCModFromMap(ich);
134 adcCh[ich] = rawStreamZDC->GetADCChFromMap(ich);
135 sigCode[ich] = rawStreamZDC->GetADCSignFromMap(ich);
136 det[ich] = rawStreamZDC->GetDetectorFromMap(ich);
137 sec[ich] = rawStreamZDC->GetTowerFromMap(ich);
142 // --------------------------------------------------------
143 // --- Writing ascii data file for the Shuttle preprocessor
144 mapFile4Shuttle = fopen(mapfName,"w");
145 for(Int_t i=0; i<ich; i++){
146 fprintf(mapFile4Shuttle,"\t%d\t%d\t%d\t%d\t%d\t%d\n",i,
147 adcMod[i],adcCh[i],sigCode[i],det[i],sec[i]);
149 //printf("ZDCPEDESTALDA.cxx -> ch.%d mod %d, ch %d, code %d det %d, sec %d\n",
150 // i,adcMod[i],adcCh[i],sigCode[i],det[i],sec[i]);
152 fclose(mapFile4Shuttle);
164 fprintf(fp,"Run #%s, received %d physics events out of %d\n",getenv("DATE_RUN_NUMBER"),nevents_physics,nevents_total);
166 /* close result file */
169 /* report progress */
170 daqDA_progressReport(90);
172 /* store the result files on FES */
173 status = daqDA_FES_storeFile(mapfName,"ZDCCHMAPPING_data");
175 printf("Failed to export file : %d\n",status);
179 /* report progress */
180 daqDA_progressReport(100);