]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ZDC/ZDCMAPPINGda.cxx
Scaler mapping deoding from SOD event
[u/mrichter/AliRoot.git] / ZDC / ZDCMAPPINGda.cxx
CommitLineData
967dda6e 1/*
2
3This program reads the DAQ data files passed as argument using the monitoring library.
4
967dda6e 5The program reports about its processing progress.
6
7Messages on stdout are exported to DAQ log system.
8
27afc0c8 9DA to write mapping for ADC modules and VME scaler
967dda6e 10
11Contact: Chiara.Oppedisano@to.infn.it
12Link:
f9641c3b 13Run Type: PHYSICS, CALIBRATION_BC, CALIBRATION_CENTRAL,
14 CALIBRATION_MB, CALIBRATION_SEMICENTRAL, CALIBRATION_COSMIC
1af38adf 15DA Type: MON
16Number of events needed: 1 (SOD is read)
17Input Files: none
967dda6e 18Output Files: ZDCChMapping.dat
1af38adf 19Trigger 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 42int 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;
f9641c3b 48 int const kNChannels = 24;
27afc0c8 49 int const kNScChannels = 32;
967dda6e 50
51 /* log start of process */
3b1e0ac9 52 printf("\nZDC MAPPING program started\n");
967dda6e 53
54 /* check that we got some arguments = list of files */
55 if (argc<2) {
56 printf("Wrong number of arguments\n");
57 return -1;
58 }
967dda6e 59
60 FILE *mapFile4Shuttle;
967dda6e 61
62 /* read the data files */
63 int n;
64 for(n=1;n<argc;n++){
65
66 status=monitorSetDataSource( argv[n] );
67 if (status!=0) {
68 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
69 return -1;
70 }
1af38adf 71
72 /* declare monitoring program */
73 status=monitorDeclareMp( __FILE__ );
74 if (status!=0) {
75 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
76 return -1;
77 }
78 monitorSetNowait();
79 monitorSetNoWaitNetworkTimeout(1000);
967dda6e 80
1af38adf 81 struct eventHeaderStruct *event;
82 eventTypeType eventT;
967dda6e 83
1af38adf 84 Int_t iev = 0;
85 Bool_t sodRead = kFALSE;
86 while(!sodRead && iev<1000){
87
88 /* check shutdown condition */
89 if (daqDA_checkShutdown()) {break;}
967dda6e 90
91 /* get next event */
92 status=monitorGetEventDynamic((void **)&event);
1af38adf 93 if(status==MON_ERR_EOF){
94 printf ("End of File detected\n");
95 break; /* end of monitoring file has been reached */
96 }
967dda6e 97 if(status!=0) {
98 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
99 return -1;
100 }
101
102 /* retry if got no event */
ac84d2fc 103 if(event==NULL) continue;
967dda6e 104
105 // Initalize raw-data reading and decoding
106 AliRawReader *reader = new AliRawReaderDate((void*)event);
27afc0c8 107 reader->Select("ZDC");
967dda6e 108 // --- Reading event header
7f4bde92 109 //UInt_t evtype = reader->GetType();
ac84d2fc 110 //printf("\t ZDCMAPPINGda -> run # %d\n",reader->GetRunNumber());
967dda6e 111 //
112 AliZDCRawStream *rawStreamZDC = new AliZDCRawStream(reader);
113
1af38adf 114
967dda6e 115 /* use event - here, just write event id to result file */
116 eventT=event->eventType;
117
27afc0c8 118
ac84d2fc 119 Int_t ich=0;
f9641c3b 120 Int_t adcMod[2*kNChannels], adcCh[2*kNChannels], sigCode[2*kNChannels];
121 Int_t det[2*kNChannels], sec[2*kNChannels];
27afc0c8 122 for(Int_t y=0; y<2*kNChannels; y++){
123 adcMod[y]=adcCh[y]=sigCode[y]=det[y]=sec[y]=0;
124 }
125
126 Int_t iScCh=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;
131 }
132 //
133 Int_t modNum=-1, modType=-1;
1af38adf 134
967dda6e 135 if(eventT==START_OF_DATA){
27afc0c8 136
7f4bde92 137 rawStreamZDC->SetSODReading(kTRUE);
138
ac84d2fc 139 // --------------------------------------------------------
140 // --- Writing ascii data file for the Shuttle preprocessor
141 mapFile4Shuttle = fopen(MAPDATA_FILE,"w");
967dda6e 142 if(!rawStreamZDC->Next()) printf(" \t No raw data found!! \n");
143 else{
27afc0c8 144 while((rawStreamZDC->Next())){
145 if(rawStreamZDC->IsHeaderMapping()){ // mapping header
146 modNum = rawStreamZDC->GetADCModule();
147 modType = rawStreamZDC->GetModType();
148 }
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);
156 //
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]);
159 //
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]);
162 //
163 ich++;
164 }
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);
171 //
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]);
174 //
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]);
177 //
178 iScCh++;
179 }
967dda6e 180 }
181 }
182 }
967dda6e 183 fclose(mapFile4Shuttle);
27afc0c8 184 }// SOD event
1af38adf 185 else{
186 if(sodRead){
187 printf("\t SOR read -> exiting from DA\n");
188 break;
189 }
190 else continue;
967dda6e 191 }
1af38adf 192
193 iev++;
194 }
195
7f4bde92 196 /* free resources */
197 //free(event);
1af38adf 198 }
967dda6e 199
967dda6e 200 /* store the result files on FES */
218f916a 201 status = daqDA_FES_storeFile(MAPDATA_FILE, MAPDATA_FILE);
967dda6e 202 if(status){
203 printf("Failed to export file : %d\n",status);
204 return -1;
205 }
206
967dda6e 207 return status;
208}