3 This program reads the DAQ data files passed as argument using the monitoring library.
5 The program reports about its processing progress.
7 Messages on stdout are exported to DAQ log system.
9 DA to write mapping for ADC modules and VME scaler
11 Contact: Chiara.Oppedisano@to.infn.it
13 Run Type: PHYSICS, CALIBRATION_BC, CALIBRATION_CENTRAL,
14 CALIBRATION_MB, CALIBRATION_SEMICENTRAL, CALIBRATION_COSMIC
16 Number of events needed: 1 (SOD is read)
18 Output Files: ZDCChMapping.dat
19 Trigger Types Used: different trigger types are used
23 #define MAPDATA_FILE "ZDCChMapping.dat"
27 #include <Riostream.h>
38 #include <AliRawReaderDate.h>
39 #include <AliRawEventHeaderBase.h>
40 #include <AliZDCRawStream.h>
42 int main(int argc, char **argv) {
44 const Char_t* tableSOD[] = {"ALL", "no", "SOD", "all", NULL, NULL};
45 monitorDeclareTable(const_cast<char**>(tableSOD));
48 int const kNModules = 10;
49 int const kNChannels = 24;
50 int const kNScChannels = 32;
52 /* log start of process */
53 printf("\n ZDC MAPPING program started\n");
55 /* check that we got some arguments = list of files */
57 printf("Wrong number of arguments\n");
61 FILE *mapFile4Shuttle;
63 /* read the data files */
67 status=monitorSetDataSource( argv[n] );
69 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
73 /* declare monitoring program */
74 status=monitorDeclareMp( __FILE__ );
76 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
80 monitorSetNoWaitNetworkTimeout(1000);
82 struct eventHeaderStruct *event;
86 Bool_t sodRead = kFALSE;
87 while(!sodRead && iev<1000){
89 /* check shutdown condition */
90 if (daqDA_checkShutdown()) {break;}
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 */
99 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
103 /* retry if got no event */
104 if(event==NULL) continue;
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());
113 AliZDCRawStream *rawStreamZDC = new AliZDCRawStream(reader);
116 /* use event - here, just write event id to result file */
117 eventT=event->eventType;
119 if(eventT==START_OF_DATA){
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;
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;
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;
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;
149 rawStreamZDC->SetSODReading(kTRUE);
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");
156 while((rawStreamZDC->Next())){
157 if(rawStreamZDC->IsHeaderMapping()){ // mapping header
159 modGeo[iMod] = rawStreamZDC->GetADCModule();
160 modType[iMod] = rawStreamZDC->GetModType();
161 modNCh[iMod] = rawStreamZDC->GetADCNChannels();
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);
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);
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);
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]);
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]);
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]);
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]);
215 fclose(mapFile4Shuttle);
219 printf("\t SOR read -> exiting from DA\n");
233 /* store the result files on FES */
234 status = daqDA_FES_storeFile(MAPDATA_FILE, "MAPPING");
236 printf("Failed to export file : %d\n",status);