]>
Commit | Line | Data |
---|---|---|
967dda6e | 1 | /* |
2 | ||
3 | This program reads the DAQ data files passed as argument using the monitoring library. | |
4 | ||
967dda6e | 5 | The program reports about its processing progress. |
6 | ||
7 | Messages on stdout are exported to DAQ log system. | |
8 | ||
27afc0c8 | 9 | DA to write mapping for ADC modules and VME scaler |
967dda6e | 10 | |
11 | Contact: Chiara.Oppedisano@to.infn.it | |
12 | Link: | |
f9641c3b | 13 | Run Type: PHYSICS, CALIBRATION_BC, CALIBRATION_CENTRAL, |
14 | CALIBRATION_MB, CALIBRATION_SEMICENTRAL, CALIBRATION_COSMIC | |
1af38adf | 15 | DA Type: MON |
16 | Number of events needed: 1 (SOD is read) | |
17 | Input Files: none | |
967dda6e | 18 | Output Files: ZDCChMapping.dat |
1af38adf | 19 | Trigger Types Used: different trigger types are used |
967dda6e | 20 | |
21 | */ | |
1af38adf | 22 | |
218f916a | 23 | #define MAPDATA_FILE "ZDCChMapping.dat" |
967dda6e | 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 | ||
967dda6e | 42 | int main(int argc, char **argv) { |
1af38adf | 43 | |
44 | const Char_t* tableSOD[] = {"ALL", "no", "SOD", "all", NULL, NULL}; | |
45 | monitorDeclareTable(const_cast<char**>(tableSOD)); | |
967dda6e | 46 | |
47 | int status = 0; | |
198f612a | 48 | int const kNModules = 10; |
f9641c3b | 49 | int const kNChannels = 24; |
27afc0c8 | 50 | int const kNScChannels = 32; |
967dda6e | 51 | |
52 | /* log start of process */ | |
198f612a | 53 | printf("\n ZDC MAPPING program started\n"); |
967dda6e | 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 | } | |
967dda6e | 60 | |
61 | FILE *mapFile4Shuttle; | |
967dda6e | 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 | } | |
1af38adf | 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); | |
967dda6e | 81 | |
1af38adf | 82 | struct eventHeaderStruct *event; |
83 | eventTypeType eventT; | |
967dda6e | 84 | |
1af38adf | 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;} | |
967dda6e | 91 | |
92 | /* get next event */ | |
93 | status=monitorGetEventDynamic((void **)&event); | |
1af38adf | 94 | if(status==MON_ERR_EOF){ |
95 | printf ("End of File detected\n"); | |
96 | break; /* end of monitoring file has been reached */ | |
97 | } | |
967dda6e | 98 | if(status!=0) { |
99 | printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status)); | |
100 | return -1; | |
101 | } | |
102 | ||
103 | /* retry if got no event */ | |
ac84d2fc | 104 | if(event==NULL) continue; |
967dda6e | 105 | |
106 | // Initalize raw-data reading and decoding | |
107 | AliRawReader *reader = new AliRawReaderDate((void*)event); | |
27afc0c8 | 108 | reader->Select("ZDC"); |
967dda6e | 109 | // --- Reading event header |
7f4bde92 | 110 | //UInt_t evtype = reader->GetType(); |
ac84d2fc | 111 | //printf("\t ZDCMAPPINGda -> run # %d\n",reader->GetRunNumber()); |
967dda6e | 112 | // |
113 | AliZDCRawStream *rawStreamZDC = new AliZDCRawStream(reader); | |
114 | ||
1af38adf | 115 | |
967dda6e | 116 | /* use event - here, just write event id to result file */ |
117 | eventT=event->eventType; | |
118 | ||
198f612a | 119 | if(eventT==START_OF_DATA){ |
120 | ||
121 | ||
82dffa48 | 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 | } | |
27afc0c8 | 134 | |
82dffa48 | 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 | } | |
198f612a | 148 | |
7f4bde92 | 149 | rawStreamZDC->SetSODReading(kTRUE); |
150 | ||
ac84d2fc | 151 | // -------------------------------------------------------- |
152 | // --- Writing ascii data file for the Shuttle preprocessor | |
153 | mapFile4Shuttle = fopen(MAPDATA_FILE,"w"); | |
967dda6e | 154 | if(!rawStreamZDC->Next()) printf(" \t No raw data found!! \n"); |
155 | else{ | |
27afc0c8 | 156 | while((rawStreamZDC->Next())){ |
157 | if(rawStreamZDC->IsHeaderMapping()){ // mapping header | |
198f612a | 158 | iMod++; |
159 | modGeo[iMod] = rawStreamZDC->GetADCModule(); | |
160 | modType[iMod] = rawStreamZDC->GetModType(); | |
161 | modNCh[iMod] = rawStreamZDC->GetADCNChannels(); | |
27afc0c8 | 162 | } |
163 | if(rawStreamZDC->IsChMapping()){ | |
198f612a | 164 | if(modType[iMod]==1){ // ADC mapping ---------------------- |
27afc0c8 | 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); | |
27afc0c8 | 170 | ich++; |
171 | } | |
82dffa48 | 172 | else if(modType[iMod]==2){ // VME scaler mapping ------------- |
27afc0c8 | 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); | |
27afc0c8 | 178 | iScCh++; |
179 | } | |
82dffa48 | 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 | } | |
967dda6e | 186 | } |
198f612a | 187 | } |
188 | // Writing data on output FXS file | |
198f612a | 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]); | |
82dffa48 | 198 | //if(scMod[is]!=-1) printf(" Mapping DA -> %d Scaler: mod %d ch %d, code %d det %d, sec %d\n", |
198f612a | 199 | // is,scMod[is],scCh[is],scSigCode[is],scDet[is],scSec[is]); |
967dda6e | 200 | } |
82dffa48 | 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 | } | |
608444fb | 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 | } | |
198f612a | 213 | |
967dda6e | 214 | } |
967dda6e | 215 | fclose(mapFile4Shuttle); |
27afc0c8 | 216 | }// SOD event |
1af38adf | 217 | else{ |
218 | if(sodRead){ | |
219 | printf("\t SOR read -> exiting from DA\n"); | |
220 | break; | |
221 | } | |
222 | else continue; | |
967dda6e | 223 | } |
1af38adf | 224 | |
225 | iev++; | |
d3f256ca | 226 | |
227 | /* free resources */ | |
228 | free(event); | |
1af38adf | 229 | } |
230 | ||
1af38adf | 231 | } |
967dda6e | 232 | |
967dda6e | 233 | /* store the result files on FES */ |
a8eaff64 | 234 | status = daqDA_FES_storeFile(MAPDATA_FILE, "MAPPING"); |
967dda6e | 235 | if(status){ |
236 | printf("Failed to export file : %d\n",status); | |
237 | return -1; | |
238 | } | |
239 | ||
967dda6e | 240 | return status; |
241 | } |