]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | ||
3 | This program reads the DAQ data files passed as argument using the monitoring library. | |
4 | ||
5 | The program reports about its processing progress. | |
6 | ||
7 | Messages on stdout are exported to DAQ log system. | |
8 | ||
9 | DA to write mapping for ADC modules and VME scaler | |
10 | ||
11 | Contact: Chiara.Oppedisano@to.infn.it | |
12 | Link: | |
13 | Run Type: PHYSICS, CALIBRATION_BC, CALIBRATION_CENTRAL, | |
14 | CALIBRATION_MB, CALIBRATION_SEMICENTRAL, CALIBRATION_COSMIC | |
15 | DA Type: MON | |
16 | Number of events needed: 1 (SOD is read) | |
17 | Input Files: none | |
18 | Output Files: ZDCChMapping.dat | |
19 | Trigger Types Used: different trigger types are used | |
20 | ||
21 | */ | |
22 | ||
23 | #define MAPDATA_FILE "ZDCChMapping.dat" | |
24 | ||
25 | #include <stdio.h> | |
26 | #include <stdlib.h> | |
27 | #include <Riostream.h> | |
28 | ||
29 | // DATE | |
30 | #include <event.h> | |
31 | #include <monitor.h> | |
32 | #include <daqDA.h> | |
33 | ||
34 | //ROOT | |
35 | #include <TFile.h> | |
36 | ||
37 | //AliRoot | |
38 | #include <AliRawReaderDate.h> | |
39 | #include <AliRawEventHeaderBase.h> | |
40 | #include <AliZDCRawStream.h> | |
41 | ||
42 | int main(int argc, char **argv) { | |
43 | ||
44 | const Char_t* tableSOD[] = {"ALL", "no", "SOD", "all", NULL, NULL}; | |
45 | monitorDeclareTable(const_cast<char**>(tableSOD)); | |
46 | ||
47 | int status = 0; | |
48 | int const kNModules = 10; | |
49 | int const kNChannels = 24; | |
50 | int const kNScChannels = 32; | |
51 | ||
52 | /* log start of process */ | |
53 | printf("\n ZDC MAPPING program started\n"); | |
54 | ||
55 | /* check that we got some arguments = list of files */ | |
56 | if (argc<2) { | |
57 | printf("Wrong number of arguments\n"); | |
58 | return -1; | |
59 | } | |
60 | ||
61 | FILE *mapFile4Shuttle; | |
62 | ||
63 | /* read the data files */ | |
64 | int n; | |
65 | for(n=1;n<argc;n++){ | |
66 | ||
67 | status=monitorSetDataSource( argv[n] ); | |
68 | if (status!=0) { | |
69 | printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status)); | |
70 | return -1; | |
71 | } | |
72 | ||
73 | /* declare monitoring program */ | |
74 | status=monitorDeclareMp( __FILE__ ); | |
75 | if (status!=0) { | |
76 | printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status)); | |
77 | return -1; | |
78 | } | |
79 | monitorSetNowait(); | |
80 | monitorSetNoWaitNetworkTimeout(1000); | |
81 | ||
82 | struct eventHeaderStruct *event; | |
83 | eventTypeType eventT; | |
84 | ||
85 | Int_t iev = 0; | |
86 | Bool_t sodRead = kFALSE; | |
87 | while(!sodRead && iev<1000){ | |
88 | ||
89 | /* check shutdown condition */ | |
90 | if (daqDA_checkShutdown()) {break;} | |
91 | ||
92 | /* get next event */ | |
93 | status=monitorGetEventDynamic((void **)&event); | |
94 | if(status==MON_ERR_EOF){ | |
95 | printf ("End of File detected\n"); | |
96 | break; /* end of monitoring file has been reached */ | |
97 | } | |
98 | if(status!=0) { | |
99 | printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status)); | |
100 | return -1; | |
101 | } | |
102 | ||
103 | /* retry if got no event */ | |
104 | if(event==NULL) continue; | |
105 | ||
106 | // Initalize raw-data reading and decoding | |
107 | AliRawReader *reader = new AliRawReaderDate((void*)event); | |
108 | reader->Select("ZDC"); | |
109 | // --- Reading event header | |
110 | //UInt_t evtype = reader->GetType(); | |
111 | //printf("\t ZDCMAPPINGda -> run # %d\n",reader->GetRunNumber()); | |
112 | // | |
113 | AliZDCRawStream *rawStreamZDC = new AliZDCRawStream(reader); | |
114 | ||
115 | ||
116 | /* use event - here, just write event id to result file */ | |
117 | eventT=event->eventType; | |
118 | ||
119 | if(eventT==START_OF_DATA){ | |
120 | ||
121 | ||
122 | Int_t iMod=-1; | |
123 | Int_t modGeo[kNModules], modType[kNModules],modNCh[kNModules]; | |
124 | for(Int_t kl=0; kl<kNModules; kl++){ | |
125 | modGeo[kl]=modType[kl]=modNCh[kl]=0; | |
126 | } | |
127 | ||
128 | Int_t ich=0; | |
129 | Int_t adcMod[2*kNChannels], adcCh[2*kNChannels], sigCode[2*kNChannels]; | |
130 | Int_t det[2*kNChannels], sec[2*kNChannels]; | |
131 | for(Int_t y=0; y<2*kNChannels; y++){ | |
132 | adcMod[y]=adcCh[y]=sigCode[y]=det[y]=sec[y]=-1; | |
133 | } | |
134 | ||
135 | Int_t iScCh=0; | |
136 | Int_t scMod[kNScChannels], scCh[kNScChannels], scSigCode[kNScChannels]; | |
137 | Int_t scDet[kNScChannels], scSec[kNScChannels]; | |
138 | for(Int_t y=0; y<kNScChannels; y++){ | |
139 | scMod[y]=scCh[y]=scSigCode[y]=scDet[y]=scSec[y]=-1; | |
140 | } | |
141 | ||
142 | Int_t itdcCh=0; | |
143 | Int_t tdcMod[kNScChannels], tdcCh[kNScChannels], tdcSigCode[kNScChannels]; | |
144 | Int_t tdcDet[kNScChannels], tdcSec[kNScChannels]; | |
145 | for(Int_t y=0; y<kNScChannels; y++){ | |
146 | tdcMod[y]=tdcCh[y]=tdcSigCode[y]=tdcDet[y]=tdcSec[y]=-1; | |
147 | } | |
148 | ||
149 | rawStreamZDC->SetSODReading(kTRUE); | |
150 | ||
151 | // -------------------------------------------------------- | |
152 | // --- Writing ascii data file for the Shuttle preprocessor | |
153 | mapFile4Shuttle = fopen(MAPDATA_FILE,"w"); | |
154 | if(!rawStreamZDC->Next()) printf(" \t No raw data found!! \n"); | |
155 | else{ | |
156 | while((rawStreamZDC->Next())){ | |
157 | if(rawStreamZDC->IsHeaderMapping()){ // mapping header | |
158 | iMod++; | |
159 | modGeo[iMod] = rawStreamZDC->GetADCModule(); | |
160 | modType[iMod] = rawStreamZDC->GetModType(); | |
161 | modNCh[iMod] = rawStreamZDC->GetADCNChannels(); | |
162 | } | |
163 | if(rawStreamZDC->IsChMapping()){ | |
164 | if(modType[iMod]==1){ // ADC mapping ---------------------- | |
165 | adcMod[ich] = rawStreamZDC->GetADCModFromMap(ich); | |
166 | adcCh[ich] = rawStreamZDC->GetADCChFromMap(ich); | |
167 | sigCode[ich] = rawStreamZDC->GetADCSignFromMap(ich); | |
168 | det[ich] = rawStreamZDC->GetDetectorFromMap(ich); | |
169 | sec[ich] = rawStreamZDC->GetTowerFromMap(ich); | |
170 | ich++; | |
171 | } | |
172 | else if(modType[iMod]==2){ // VME scaler mapping ------------- | |
173 | scMod[iScCh] = rawStreamZDC->GetScalerModFromMap(iScCh); | |
174 | scCh[iScCh] = rawStreamZDC->GetScalerChFromMap(iScCh); | |
175 | scSigCode[iScCh] = rawStreamZDC->GetScalerSignFromMap(iScCh); | |
176 | scDet[iScCh] = rawStreamZDC->GetScDetectorFromMap(iScCh); | |
177 | scSec[iScCh] = rawStreamZDC->GetScTowerFromMap(iScCh); | |
178 | iScCh++; | |
179 | } | |
180 | else if(modType[iMod]==6 && modGeo[iMod]==4){ // ZDC TDC mapping -------------------- | |
181 | tdcMod[itdcCh] = rawStreamZDC->GetTDCModFromMap(itdcCh); | |
182 | tdcCh[itdcCh] = rawStreamZDC->GetTDCChFromMap(itdcCh); | |
183 | tdcSigCode[itdcCh] = rawStreamZDC->GetTDCSignFromMap(itdcCh); | |
184 | itdcCh++; | |
185 | } | |
186 | } | |
187 | } | |
188 | // Writing data on output FXS file | |
189 | for(Int_t is=0; is<2*kNChannels; is++){ | |
190 | fprintf(mapFile4Shuttle,"\t%d\t%d\t%d\t%d\t%d\t%d\n", | |
191 | is,adcMod[is],adcCh[is],sigCode[is],det[is],sec[is]); | |
192 | //printf(" Mapping DA -> %d ADC: mod %d ch %d, code %d det %d, sec %d\n", | |
193 | // is,adcMod[is],adcCh[is],sigCode[is],det[is],sec[is]); | |
194 | } | |
195 | for(Int_t is=0; is<kNScChannels; is++){ | |
196 | fprintf(mapFile4Shuttle,"\t%d\t%d\t%d\t%d\t%d\t%d\n", | |
197 | is,scMod[is],scCh[is],scSigCode[is],scDet[is],scSec[is]); | |
198 | //if(scMod[is]!=-1) printf(" Mapping DA -> %d Scaler: mod %d ch %d, code %d det %d, sec %d\n", | |
199 | // is,scMod[is],scCh[is],scSigCode[is],scDet[is],scSec[is]); | |
200 | } | |
201 | for(Int_t is=0; is<kNScChannels; is++){ | |
202 | fprintf(mapFile4Shuttle,"\t%d\t%d\t%d\t%d\n", | |
203 | is,tdcMod[is],tdcCh[is],tdcSigCode[is]); | |
204 | //if(tdcMod[is]!=-1) printf(" Mapping DA -> %d TDC: mod %d ch %d, code %d\n", | |
205 | // is,tdcMod[is],tdcCh[is],tdcSigCode[is]); | |
206 | } | |
207 | for(Int_t is=0; is<kNModules; is++){ | |
208 | fprintf(mapFile4Shuttle,"\t%d\t%d\t%d\n", | |
209 | modGeo[is],modType[is],modNCh[is]); | |
210 | //printf(" Mapping DA -> Module mapping: geo %d type %d #ch %d\n", | |
211 | // modGeo[is],modType[is],modNCh[is]); | |
212 | } | |
213 | ||
214 | } | |
215 | fclose(mapFile4Shuttle); | |
216 | }// SOD event | |
217 | else{ | |
218 | if(sodRead){ | |
219 | printf("\t SOR read -> exiting from DA\n"); | |
220 | break; | |
221 | } | |
222 | else continue; | |
223 | } | |
224 | ||
225 | iev++; | |
226 | ||
227 | /* free resources */ | |
228 | free(event); | |
229 | } | |
230 | ||
231 | } | |
232 | ||
233 | /* store the result files on FES */ | |
234 | status = daqDA_FES_storeFile(MAPDATA_FILE, "MAPPING"); | |
235 | if(status){ | |
236 | printf("Failed to export file : %d\n",status); | |
237 | return -1; | |
238 | } | |
239 | ||
240 | return status; | |
241 | } |