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 kNChannels = 24;
49 int const kNScChannels = 32;
51 /* log start of process */
52 printf("\nZDC MAPPING program started\n");
54 /* check that we got some arguments = list of files */
56 printf("Wrong number of arguments\n");
60 FILE *mapFile4Shuttle;
62 /* read the data files */
66 status=monitorSetDataSource( argv[n] );
68 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
72 /* declare monitoring program */
73 status=monitorDeclareMp( __FILE__ );
75 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
79 monitorSetNoWaitNetworkTimeout(1000);
81 struct eventHeaderStruct *event;
85 Bool_t sodRead = kFALSE;
86 while(!sodRead && iev<1000){
88 /* check shutdown condition */
89 if (daqDA_checkShutdown()) {break;}
92 status=monitorGetEventDynamic((void **)&event);
93 if(status==MON_ERR_EOF){
94 printf ("End of File detected\n");
95 break; /* end of monitoring file has been reached */
98 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
102 /* retry if got no event */
103 if(event==NULL) continue;
105 // Initalize raw-data reading and decoding
106 AliRawReader *reader = new AliRawReaderDate((void*)event);
107 reader->Select("ZDC");
108 // --- Reading event header
109 //UInt_t evtype = reader->GetType();
110 //printf("\t ZDCMAPPINGda -> run # %d\n",reader->GetRunNumber());
112 AliZDCRawStream *rawStreamZDC = new AliZDCRawStream(reader);
115 /* use event - here, just write event id to result file */
116 eventT=event->eventType;
120 Int_t adcMod[2*kNChannels], adcCh[2*kNChannels], sigCode[2*kNChannels];
121 Int_t det[2*kNChannels], sec[2*kNChannels];
122 for(Int_t y=0; y<2*kNChannels; y++){
123 adcMod[y]=adcCh[y]=sigCode[y]=det[y]=sec[y]=0;
127 Int_t scMod[kNScChannels], scCh[kNScChannels], scSigCode[kNScChannels];
128 Int_t scDet[kNScChannels], scSec[kNScChannels];
129 for(Int_t y=0; y<kNScChannels; y++){
130 scMod[y]=scCh[y]=scSigCode[y]=scDet[y]=scSec[y]=0;
133 Int_t modNum=-1, modType=-1;
135 if(eventT==START_OF_DATA){
137 rawStreamZDC->SetSODReading(kTRUE);
139 // --------------------------------------------------------
140 // --- Writing ascii data file for the Shuttle preprocessor
141 mapFile4Shuttle = fopen(MAPDATA_FILE,"w");
142 if(!rawStreamZDC->Next()) printf(" \t No raw data found!! \n");
144 while((rawStreamZDC->Next())){
145 if(rawStreamZDC->IsHeaderMapping()){ // mapping header
146 modNum = rawStreamZDC->GetADCModule();
147 modType = rawStreamZDC->GetModType();
149 if(rawStreamZDC->IsChMapping()){
150 if(modType==1){ // ADC mapping ----------------------
151 adcMod[ich] = rawStreamZDC->GetADCModFromMap(ich);
152 adcCh[ich] = rawStreamZDC->GetADCChFromMap(ich);
153 sigCode[ich] = rawStreamZDC->GetADCSignFromMap(ich);
154 det[ich] = rawStreamZDC->GetDetectorFromMap(ich);
155 sec[ich] = rawStreamZDC->GetTowerFromMap(ich);
157 fprintf(mapFile4Shuttle,"\t%d\t%d\t%d\t%d\t%d\t%d\n",
158 ich,adcMod[ich],adcCh[ich],sigCode[ich],det[ich],sec[ich]);
160 //printf(" Mapping DA -> %d ADC: mod %d ch %d, code %d det %d, sec %d\n",
161 // ich,adcMod[ich],adcCh[ich],sigCode[ich],det[ich],sec[ich]);
165 else if(modType==2){ //VME scaler mapping --------------------
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);
172 fprintf(mapFile4Shuttle,"\t%d\t%d\t%d\t%d\t%d\t%d\n",
173 iScCh,scMod[iScCh],scCh[iScCh],scSigCode[iScCh],scDet[iScCh],scSec[iScCh]);
175 //printf(" Mapping DA -> %d Scaler: mod %d ch %d, code %d det %d, sec %d\n",
176 // iScCh,scMod[iScCh],scCh[iScCh],scSigCode[iScCh],scDet[iScCh],scSec[iScCh]);
183 fclose(mapFile4Shuttle);
187 printf("\t SOR read -> exiting from DA\n");
201 /* store the result files on FES */
202 status = daqDA_FES_storeFile(MAPDATA_FILE, MAPDATA_FILE);
204 printf("Failed to export file : %d\n",status);