]>
Commit | Line | Data |
---|---|---|
967dda6e | 1 | /* |
2 | ||
3 | This program reads the DAQ data files passed as argument using the monitoring library. | |
4 | ||
5 | It computes the average event size and populates local "./result.txt" file with the | |
6 | result. | |
7 | ||
8 | The program reports about its processing progress. | |
9 | ||
10 | Messages on stdout are exported to DAQ log system. | |
11 | ||
12 | DA for ZDC standalone pedestal runs | |
13 | ||
14 | Contact: Chiara.Oppedisano@to.infn.it | |
15 | Link: | |
16 | Run Type: PHYSICS, STANDALONE_BC, STANDALONE_COSMIC, STANDALONE_CENTRAL, | |
17 | STANDALONE_MB, STANDALONE_SEMICENTRAL | |
18 | DA Type: LDC | |
19 | Number of events needed: no constraint | |
20 | Input Files: | |
21 | Output Files: ZDCChMapping.dat | |
22 | Trigger Types Used: | |
23 | ||
24 | */ | |
25 | ||
26 | #include <stdio.h> | |
27 | #include <stdlib.h> | |
28 | #include <Riostream.h> | |
29 | ||
30 | // DATE | |
31 | #include <event.h> | |
32 | #include <monitor.h> | |
33 | #include <daqDA.h> | |
34 | ||
35 | //ROOT | |
36 | #include <TFile.h> | |
37 | ||
38 | //AliRoot | |
39 | #include <AliRawReaderDate.h> | |
40 | #include <AliRawEventHeaderBase.h> | |
41 | #include <AliZDCRawStream.h> | |
42 | ||
43 | ||
44 | /* Main routine | |
45 | Arguments: list of DATE raw data files | |
46 | */ | |
47 | int main(int argc, char **argv) { | |
48 | ||
49 | int status = 0; | |
50 | ||
51 | /* log start of process */ | |
3b1e0ac9 | 52 | printf("\nZDC MAPPING program started\n"); |
967dda6e | 53 | |
54 | /* check that we got some arguments = list of files */ | |
55 | if (argc<2) { | |
56 | printf("Wrong number of arguments\n"); | |
57 | return -1; | |
58 | } | |
59 | ||
60 | /* open result file */ | |
61 | FILE *fp=NULL; | |
62 | fp=fopen("./result.txt","a"); | |
63 | if (fp==NULL) { | |
64 | printf("Failed to open file\n"); | |
65 | return -1; | |
66 | } | |
67 | ||
68 | FILE *mapFile4Shuttle; | |
69 | const char *mapfName = "ZDCChMapping.dat"; | |
70 | ||
71 | ||
72 | /* report progress */ | |
73 | daqDA_progressReport(10); | |
74 | ||
75 | ||
76 | /* init some counters */ | |
77 | int nevents_physics=0; | |
78 | int nevents_total=0; | |
79 | ||
80 | /* read the data files */ | |
81 | int n; | |
82 | for(n=1;n<argc;n++){ | |
83 | ||
84 | status=monitorSetDataSource( argv[n] ); | |
85 | if (status!=0) { | |
86 | printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status)); | |
87 | return -1; | |
88 | } | |
89 | ||
90 | /* report progress */ | |
91 | /* in this example, indexed on the number of files */ | |
92 | daqDA_progressReport(10+80*n/argc); | |
93 | ||
94 | /* read the file */ | |
95 | for(;;) { | |
96 | struct eventHeaderStruct *event; | |
97 | eventTypeType eventT; | |
98 | ||
99 | /* get next event */ | |
100 | status=monitorGetEventDynamic((void **)&event); | |
101 | if(status==MON_ERR_EOF) break; /* end of monitoring file has been reached */ | |
102 | if(status!=0) { | |
103 | printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status)); | |
104 | return -1; | |
105 | } | |
106 | ||
107 | /* retry if got no event */ | |
108 | if(event==NULL) { | |
109 | break; | |
110 | } | |
111 | ||
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()); | |
119 | // | |
120 | AliZDCRawStream *rawStreamZDC = new AliZDCRawStream(reader); | |
121 | ||
122 | ||
123 | /* use event - here, just write event id to result file */ | |
124 | eventT=event->eventType; | |
125 | ||
126 | Int_t ich=0, adcMod[48], adcCh[48], sigCode[48], det[48], sec[48]; | |
127 | if(eventT==START_OF_DATA){ | |
128 | ||
129 | if(!rawStreamZDC->Next()) printf(" \t No raw data found!! \n"); | |
130 | else{ | |
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); | |
138 | ich++; | |
139 | } | |
140 | } | |
141 | } | |
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]); | |
148 | // | |
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]); | |
151 | } | |
152 | fclose(mapFile4Shuttle); | |
153 | } | |
154 | ||
155 | nevents_total++; | |
156 | ||
157 | /* free resources */ | |
158 | free(event); | |
159 | ||
160 | } | |
161 | } | |
162 | ||
163 | /* write report */ | |
164 | fprintf(fp,"Run #%s, received %d physics events out of %d\n",getenv("DATE_RUN_NUMBER"),nevents_physics,nevents_total); | |
165 | ||
166 | /* close result file */ | |
167 | fclose(fp); | |
168 | ||
169 | /* report progress */ | |
170 | daqDA_progressReport(90); | |
171 | ||
172 | /* store the result files on FES */ | |
173 | status = daqDA_FES_storeFile(mapfName,"ZDCCHMAPPING_data"); | |
174 | if(status){ | |
175 | printf("Failed to export file : %d\n",status); | |
176 | return -1; | |
177 | } | |
178 | ||
179 | /* report progress */ | |
180 | daqDA_progressReport(100); | |
181 | ||
182 | return status; | |
183 | } |