]>
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 | ||
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 | } | |
27afc0c8 | 127 | |
ac84d2fc | 128 | Int_t ich=0; |
f9641c3b | 129 | Int_t adcMod[2*kNChannels], adcCh[2*kNChannels], sigCode[2*kNChannels]; |
130 | Int_t det[2*kNChannels], sec[2*kNChannels]; | |
27afc0c8 | 131 | for(Int_t y=0; y<2*kNChannels; y++){ |
132 | adcMod[y]=adcCh[y]=sigCode[y]=det[y]=sec[y]=0; | |
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]=0; | |
140 | } | |
198f612a | 141 | |
7f4bde92 | 142 | rawStreamZDC->SetSODReading(kTRUE); |
143 | ||
ac84d2fc | 144 | // -------------------------------------------------------- |
145 | // --- Writing ascii data file for the Shuttle preprocessor | |
146 | mapFile4Shuttle = fopen(MAPDATA_FILE,"w"); | |
967dda6e | 147 | if(!rawStreamZDC->Next()) printf(" \t No raw data found!! \n"); |
148 | else{ | |
27afc0c8 | 149 | while((rawStreamZDC->Next())){ |
150 | if(rawStreamZDC->IsHeaderMapping()){ // mapping header | |
198f612a | 151 | iMod++; |
152 | modGeo[iMod] = rawStreamZDC->GetADCModule(); | |
153 | modType[iMod] = rawStreamZDC->GetModType(); | |
154 | modNCh[iMod] = rawStreamZDC->GetADCNChannels(); | |
27afc0c8 | 155 | } |
156 | if(rawStreamZDC->IsChMapping()){ | |
198f612a | 157 | if(modType[iMod]==1){ // ADC mapping ---------------------- |
27afc0c8 | 158 | adcMod[ich] = rawStreamZDC->GetADCModFromMap(ich); |
159 | adcCh[ich] = rawStreamZDC->GetADCChFromMap(ich); | |
160 | sigCode[ich] = rawStreamZDC->GetADCSignFromMap(ich); | |
161 | det[ich] = rawStreamZDC->GetDetectorFromMap(ich); | |
162 | sec[ich] = rawStreamZDC->GetTowerFromMap(ich); | |
27afc0c8 | 163 | ich++; |
164 | } | |
198f612a | 165 | else if(modType[iMod]==2){ //VME scaler mapping -------------------- |
27afc0c8 | 166 | scMod[iScCh] = rawStreamZDC->GetScalerModFromMap(iScCh); |
167 | scCh[iScCh] = rawStreamZDC->GetScalerChFromMap(iScCh); | |
168 | scSigCode[iScCh] = rawStreamZDC->GetScalerSignFromMap(iScCh); | |
169 | scDet[iScCh] = rawStreamZDC->GetScDetectorFromMap(iScCh); | |
170 | scSec[iScCh] = rawStreamZDC->GetScTowerFromMap(iScCh); | |
27afc0c8 | 171 | iScCh++; |
172 | } | |
967dda6e | 173 | } |
198f612a | 174 | } |
175 | // Writing data on output FXS file | |
198f612a | 176 | for(Int_t is=0; is<2*kNChannels; is++){ |
177 | fprintf(mapFile4Shuttle,"\t%d\t%d\t%d\t%d\t%d\t%d\n", | |
178 | is,adcMod[is],adcCh[is],sigCode[is],det[is],sec[is]); | |
179 | //printf(" Mapping DA -> %d ADC: mod %d ch %d, code %d det %d, sec %d\n", | |
180 | // is,adcMod[is],adcCh[is],sigCode[is],det[is],sec[is]); | |
181 | } | |
182 | for(Int_t is=0; is<kNScChannels; is++){ | |
183 | fprintf(mapFile4Shuttle,"\t%d\t%d\t%d\t%d\t%d\t%d\n", | |
184 | is,scMod[is],scCh[is],scSigCode[is],scDet[is],scSec[is]); | |
185 | //if(scMod[is]!=0) printf(" Mapping DA -> %d Scaler: mod %d ch %d, code %d det %d, sec %d\n", | |
186 | // is,scMod[is],scCh[is],scSigCode[is],scDet[is],scSec[is]); | |
967dda6e | 187 | } |
608444fb | 188 | for(Int_t is=0; is<kNModules; is++){ |
189 | fprintf(mapFile4Shuttle,"\t%d\t%d\t%d\n", | |
190 | modGeo[is],modType[is],modNCh[is]); | |
191 | //printf(" Mapping DA -> Module mapping: geo %d type %d #ch %d\n", | |
192 | // modGeo[is],modType[is],modNCh[is]); | |
193 | } | |
198f612a | 194 | |
967dda6e | 195 | } |
967dda6e | 196 | fclose(mapFile4Shuttle); |
27afc0c8 | 197 | }// SOD event |
1af38adf | 198 | else{ |
199 | if(sodRead){ | |
200 | printf("\t SOR read -> exiting from DA\n"); | |
201 | break; | |
202 | } | |
203 | else continue; | |
967dda6e | 204 | } |
1af38adf | 205 | |
206 | iev++; | |
d3f256ca | 207 | |
208 | /* free resources */ | |
209 | free(event); | |
1af38adf | 210 | } |
211 | ||
1af38adf | 212 | } |
967dda6e | 213 | |
967dda6e | 214 | /* store the result files on FES */ |
a8eaff64 | 215 | status = daqDA_FES_storeFile(MAPDATA_FILE, "MAPPING"); |
967dda6e | 216 | if(status){ |
217 | printf("Failed to export file : %d\n",status); | |
218 | return -1; | |
219 | } | |
220 | ||
967dda6e | 221 | return status; |
222 | } |