]>
Commit | Line | Data |
---|---|---|
967dda6e | 1 | /* |
2 | ||
3 | This program reads the DAQ data files passed as argument using the monitoring library. | |
4 | ||
5 | It computes the average event size and populates local "./result.txt" file with the | |
6 | result. | |
7 | ||
8 | The program reports about its processing progress. | |
9 | ||
10 | Messages on stdout are exported to DAQ log system. | |
11 | ||
1af38adf | 12 | DA to write mapping for the ZDC ADCs |
967dda6e | 13 | |
14 | Contact: Chiara.Oppedisano@to.infn.it | |
15 | Link: | |
f9641c3b | 16 | Run Type: PHYSICS, CALIBRATION_BC, CALIBRATION_CENTRAL, |
17 | CALIBRATION_MB, CALIBRATION_SEMICENTRAL, CALIBRATION_COSMIC | |
1af38adf | 18 | DA Type: MON |
19 | Number of events needed: 1 (SOD is read) | |
20 | Input Files: none | |
967dda6e | 21 | Output Files: ZDCChMapping.dat |
1af38adf | 22 | Trigger Types Used: different trigger types are used |
967dda6e | 23 | |
24 | */ | |
1af38adf | 25 | |
218f916a | 26 | #define MAPDATA_FILE "ZDCChMapping.dat" |
967dda6e | 27 | |
28 | #include <stdio.h> | |
29 | #include <stdlib.h> | |
30 | #include <Riostream.h> | |
31 | ||
32 | // DATE | |
33 | #include <event.h> | |
34 | #include <monitor.h> | |
35 | #include <daqDA.h> | |
36 | ||
37 | //ROOT | |
38 | #include <TFile.h> | |
39 | ||
40 | //AliRoot | |
41 | #include <AliRawReaderDate.h> | |
42 | #include <AliRawEventHeaderBase.h> | |
43 | #include <AliZDCRawStream.h> | |
44 | ||
967dda6e | 45 | int main(int argc, char **argv) { |
1af38adf | 46 | |
47 | const Char_t* tableSOD[] = {"ALL", "no", "SOD", "all", NULL, NULL}; | |
48 | monitorDeclareTable(const_cast<char**>(tableSOD)); | |
967dda6e | 49 | |
50 | int status = 0; | |
f9641c3b | 51 | int const kNChannels = 24; |
967dda6e | 52 | |
53 | /* log start of process */ | |
3b1e0ac9 | 54 | printf("\nZDC MAPPING program started\n"); |
967dda6e | 55 | |
56 | /* check that we got some arguments = list of files */ | |
57 | if (argc<2) { | |
58 | printf("Wrong number of arguments\n"); | |
59 | return -1; | |
60 | } | |
967dda6e | 61 | |
62 | FILE *mapFile4Shuttle; | |
967dda6e | 63 | |
64 | /* read the data files */ | |
65 | int n; | |
66 | for(n=1;n<argc;n++){ | |
67 | ||
68 | status=monitorSetDataSource( argv[n] ); | |
69 | if (status!=0) { | |
70 | printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status)); | |
71 | return -1; | |
72 | } | |
1af38adf | 73 | |
74 | /* declare monitoring program */ | |
75 | status=monitorDeclareMp( __FILE__ ); | |
76 | if (status!=0) { | |
77 | printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status)); | |
78 | return -1; | |
79 | } | |
80 | monitorSetNowait(); | |
81 | monitorSetNoWaitNetworkTimeout(1000); | |
967dda6e | 82 | |
1af38adf | 83 | struct eventHeaderStruct *event; |
84 | eventTypeType eventT; | |
967dda6e | 85 | |
1af38adf | 86 | Int_t iev = 0; |
87 | Bool_t sodRead = kFALSE; | |
88 | while(!sodRead && iev<1000){ | |
89 | ||
90 | /* check shutdown condition */ | |
91 | if (daqDA_checkShutdown()) {break;} | |
967dda6e | 92 | |
93 | /* get next event */ | |
94 | status=monitorGetEventDynamic((void **)&event); | |
1af38adf | 95 | if(status==MON_ERR_EOF){ |
96 | printf ("End of File detected\n"); | |
97 | break; /* end of monitoring file has been reached */ | |
98 | } | |
967dda6e | 99 | if(status!=0) { |
100 | printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status)); | |
101 | return -1; | |
102 | } | |
103 | ||
104 | /* retry if got no event */ | |
ac84d2fc | 105 | if(event==NULL) continue; |
967dda6e | 106 | |
107 | // Initalize raw-data reading and decoding | |
108 | AliRawReader *reader = new AliRawReaderDate((void*)event); | |
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 | ||
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]; | |
1af38adf | 122 | |
967dda6e | 123 | if(eventT==START_OF_DATA){ |
1af38adf | 124 | sodRead = kTRUE; |
7f4bde92 | 125 | rawStreamZDC->SetSODReading(kTRUE); |
126 | ||
ac84d2fc | 127 | // -------------------------------------------------------- |
128 | // --- Writing ascii data file for the Shuttle preprocessor | |
129 | mapFile4Shuttle = fopen(MAPDATA_FILE,"w"); | |
967dda6e | 130 | if(!rawStreamZDC->Next()) printf(" \t No raw data found!! \n"); |
131 | else{ | |
f9641c3b | 132 | while((rawStreamZDC->Next()) && (ich<2*kNChannels)){ |
133 | if(rawStreamZDC->IsChMapping()){ | |
967dda6e | 134 | adcMod[ich] = rawStreamZDC->GetADCModFromMap(ich); |
135 | adcCh[ich] = rawStreamZDC->GetADCChFromMap(ich); | |
136 | sigCode[ich] = rawStreamZDC->GetADCSignFromMap(ich); | |
137 | det[ich] = rawStreamZDC->GetDetectorFromMap(ich); | |
138 | sec[ich] = rawStreamZDC->GetTowerFromMap(ich); | |
ac84d2fc | 139 | // |
140 | fprintf(mapFile4Shuttle,"\t%d\t%d\t%d\t%d\t%d\t%d\n", | |
141 | ich,adcMod[ich],adcCh[ich],sigCode[ich],det[ich],sec[ich]); | |
142 | // | |
9d0b658a | 143 | //printf("ZDCMAPPINGda.cxx -> %d mod %d ch %d code %d det %d sec %d\n", |
ac84d2fc | 144 | // ich,adcMod[ich],adcCh[ich],sigCode[ich],det[ich],sec[ich]); |
145 | // | |
967dda6e | 146 | ich++; |
147 | } | |
148 | } | |
149 | } | |
967dda6e | 150 | fclose(mapFile4Shuttle); |
1af38adf | 151 | } // SOD event |
152 | else{ | |
153 | if(sodRead){ | |
154 | printf("\t SOR read -> exiting from DA\n"); | |
155 | break; | |
156 | } | |
157 | else continue; | |
967dda6e | 158 | } |
1af38adf | 159 | |
160 | iev++; | |
161 | } | |
162 | ||
7f4bde92 | 163 | /* free resources */ |
164 | //free(event); | |
1af38adf | 165 | } |
967dda6e | 166 | |
967dda6e | 167 | /* store the result files on FES */ |
218f916a | 168 | status = daqDA_FES_storeFile(MAPDATA_FILE, MAPDATA_FILE); |
967dda6e | 169 | if(status){ |
170 | printf("Failed to export file : %d\n",status); | |
171 | return -1; | |
172 | } | |
173 | ||
967dda6e | 174 | return status; |
175 | } |