]>
Commit | Line | Data |
---|---|---|
8309c1ab | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | /////////////////////////////////////////////////////////////////////////////// | |
83347831 | 19 | // // |
20 | // This class provides access to ZDC digits in raw data. // | |
21 | // // | |
22 | // It loops over all ZDC digits in the raw data given by the AliRawReader. // | |
23 | // The Next method goes to the next digit. If there are no digits left // | |
24 | // it returns kFALSE. // | |
25 | // Getters provide information about the current digit. // | |
26 | // // | |
8309c1ab | 27 | /////////////////////////////////////////////////////////////////////////////// |
28 | ||
11b06725 | 29 | #include <TSystem.h> |
8309c1ab | 30 | #include "AliZDCRawStream.h" |
31 | #include "AliRawReader.h" | |
1ee299a5 | 32 | #include "AliRawDataHeader.h" |
33 | #include "AliRawEventHeaderBase.h" | |
cc2abffd | 34 | #include "AliLog.h" |
8309c1ab | 35 | |
36 | ClassImp(AliZDCRawStream) | |
37 | ||
38 | ||
39 | //_____________________________________________________________________________ | |
40 | AliZDCRawStream::AliZDCRawStream(AliRawReader* rawReader) : | |
41 | fRawReader(rawReader), | |
1ee299a5 | 42 | fBuffer(0), |
43 | fEvType(0), | |
44 | fPosition(0), | |
45 | fIsCalib(kFALSE), | |
46 | fIsDARCHeader(kFALSE), | |
47 | fIsChMapping(kFALSE), | |
48 | fIsADCDataWord(kFALSE), | |
49 | fIsADCHeader(kFALSE), | |
50 | fIsADCEOB(kFALSE), | |
51 | fDARCEvBlockLenght(0), | |
52 | fDARCBlockAttributes(0), | |
53 | fDeadfaceOffset(0), | |
54 | fDeadbeefOffset(0), | |
55 | fDataOffset(0), | |
56 | fModType(-1), | |
57 | fADCModule(-1), | |
58 | fADCNChannels(-1), | |
786b72f5 | 59 | fADCChannel(-1), |
cc2abffd | 60 | fADCValue(-1), |
1ee299a5 | 61 | fADCGain(-1), |
e42bdf10 | 62 | fScNWords(0), |
63 | fScGeo(-1), | |
64 | fScTS(0), | |
65 | fScTriggerNumber(0), | |
66 | fIsScEventGood(kFALSE), | |
1ee299a5 | 67 | fNConnCh(-1), |
68 | fCabledSignal(-1) | |
8309c1ab | 69 | { |
abf60186 | 70 | // Create an object to read ZDC raw digits |
1ee299a5 | 71 | fRawReader->Reset(); |
362c9d61 | 72 | fRawReader->Select("ZDC"); |
1ee299a5 | 73 | // |
74 | for(Int_t i=0; i<48; i++){ | |
c93c022b | 75 | for(Int_t j=0; j<5; j++) fMapADC[i][j]=-1; |
1ee299a5 | 76 | } |
77 | ||
8309c1ab | 78 | } |
79 | ||
80 | //_____________________________________________________________________________ | |
81 | AliZDCRawStream::AliZDCRawStream(const AliZDCRawStream& stream) : | |
a718c993 | 82 | TObject(stream), |
c61a7285 | 83 | fRawReader(stream.fRawReader), |
1ee299a5 | 84 | fBuffer(stream.GetRawBuffer()), |
85 | fEvType(stream.fEvType), | |
86 | fPosition(stream.fPosition), | |
87 | fIsCalib(stream.fIsCalib), | |
88 | fIsDARCHeader(stream.fIsDARCHeader), | |
89 | fIsChMapping(stream.fIsChMapping), | |
90 | fIsADCDataWord(stream.fIsADCDataWord), | |
91 | fIsADCHeader(stream.fIsADCHeader), | |
92 | fIsADCEOB(stream.fIsADCEOB), | |
93 | fDARCEvBlockLenght(stream.fDARCEvBlockLenght), | |
94 | fDARCBlockAttributes(stream.fDARCBlockAttributes), | |
95 | fDeadfaceOffset(stream.GetDeadfaceOffset()), | |
96 | fDeadbeefOffset(stream.GetDeadbeefOffset()), | |
97 | fDataOffset(stream.GetDataOffset()), | |
98 | fModType(stream.GetModType()), | |
a718c993 | 99 | fADCModule(stream.GetADCModule()), |
1ee299a5 | 100 | fADCNChannels(stream.GetADCNChannels()), |
a718c993 | 101 | fADCChannel(stream.GetADCChannel()), |
102 | fADCValue(stream.GetADCValue()), | |
103 | fADCGain(stream.GetADCGain()), | |
e42bdf10 | 104 | fScNWords(stream.GetScNWords()), |
105 | fScGeo(stream.GetScGeo()), | |
106 | fScTS(stream.GetScTS()), | |
22fe5e66 | 107 | fScTriggerNumber(stream.fScTriggerNumber), |
e42bdf10 | 108 | fIsScEventGood(stream.fIsScEventGood), |
1ee299a5 | 109 | fNConnCh(stream.fNConnCh), |
110 | fCabledSignal(stream.GetCabledSignal()) | |
8309c1ab | 111 | { |
abf60186 | 112 | // Copy constructor |
c0aec6f6 | 113 | for(Int_t j=0; j<2; j++) fSector[j] = stream.GetSector(j); |
1ee299a5 | 114 | for(Int_t i=0; i<48; i++){ |
c93c022b | 115 | for(Int_t j=0; j<5; j++) fMapADC[i][j] = stream.fMapADC[i][j]; |
1ee299a5 | 116 | } |
8309c1ab | 117 | } |
118 | ||
119 | //_____________________________________________________________________________ | |
120 | AliZDCRawStream& AliZDCRawStream::operator = (const AliZDCRawStream& | |
121 | /* stream */) | |
122 | { | |
abf60186 | 123 | // Assignment operator |
8309c1ab | 124 | Fatal("operator =", "assignment operator not implemented"); |
125 | return *this; | |
126 | } | |
127 | ||
128 | //_____________________________________________________________________________ | |
129 | AliZDCRawStream::~AliZDCRawStream() | |
130 | { | |
abf60186 | 131 | // Destructor |
8309c1ab | 132 | |
133 | } | |
134 | ||
c93c022b | 135 | //_____________________________________________________________________________ |
136 | void AliZDCRawStream::ReadChMap() | |
137 | { | |
138 | // Reading channel map | |
139 | } | |
140 | ||
1ee299a5 | 141 | //_____________________________________________________________________________ |
142 | void AliZDCRawStream::ReadCDHHeader() | |
143 | { | |
144 | // Reading CDH | |
145 | const AliRawDataHeader* header = fRawReader->GetDataHeader(); | |
146 | if(!header) { | |
147 | AliError("\t No CDH in raw data streaming\n"); | |
148 | fRawReader->AddMajorErrorLog(kCDHError); | |
149 | // | |
150 | // For the moment to debug the classe the event is read | |
151 | // also if the CDH is not present in the data buffer | |
152 | // ******* TO BE CHANGED!!! *************************** | |
153 | //return; | |
154 | } | |
155 | else{ | |
156 | //printf("\t AliZDCRawStream::ReadCDHHeader -> Data Size = %d\n",fRawReader->GetDataSize()); | |
157 | ||
158 | fDARCEvBlockLenght = header->fSize; | |
159 | //printf("\t AliZDCRawStream::ReadCDHHeader -> fDARCEvBlockLenght = %d\n",fDARCEvBlockLenght); | |
160 | ||
161 | //UChar_t message = header->GetAttributes(); | |
162 | //printf("\t AliZDCRawStream::ReadCDHHeader -> Attributes %x\n",message); | |
163 | ||
164 | /*if(message & 0x10){ // COSMIC RUN | |
165 | printf("\t STANDALONE_COSMIC RUN raw data found\n"); | |
166 | } | |
167 | else if(message & 0x20){ // PEDESTAL RUN | |
168 | printf("\t STANDALONE_PEDESTAL RUN raw data found\n"); | |
169 | } | |
170 | else if(message & 0x30){ // LASER RUN | |
171 | printf("\t STANDALONE_LASER RUN raw data found\n"); | |
172 | }*/ | |
173 | ||
174 | if(header->GetL1TriggerMessage() & 0x1){ // Calibration bit set in CDH | |
175 | fIsCalib = kTRUE; | |
176 | } | |
177 | //printf("\t AliZDCRawStream::ReadCDHHeader -> L1TriggerMessage %x\n",header->GetL1TriggerMessage()); | |
c93c022b | 178 | //printf("\t AliZDCRawStream::ReadCDHHeader -> Calibration bit = %d\n",fIsCalib); |
1ee299a5 | 179 | |
180 | UInt_t status = header->GetStatus(); | |
181 | //printf("\t AliZDCRawStream::ReadCDHHeader -> status = %d\n",status); | |
182 | if(status & 0x000f == 0x0001){ | |
183 | AliWarning("CDH -> DARC trg0 overlap error\n"); | |
184 | fRawReader->AddMajorErrorLog(kDARCError); | |
185 | } | |
186 | if(status & 0x000f == 0x0002){ | |
187 | AliWarning("CDH -> DARC trg0 missing error\n"); | |
188 | fRawReader->AddMajorErrorLog(kDARCError); | |
189 | } | |
190 | if(status & 0x000f == 0x0004){ | |
191 | AliWarning("CDH -> DARC data parity error\n"); | |
192 | fRawReader->AddMajorErrorLog(kDARCError); | |
193 | } | |
194 | if(status & 0x000f == 0x0008){ | |
195 | AliWarning("CDH -> DARC ctrl parity error\n"); | |
196 | fRawReader->AddMajorErrorLog(kDARCError); | |
197 | } | |
198 | // | |
199 | if(status & 0x00f0 == 0x0010){ | |
200 | AliWarning("CDH -> DARC trg unavailable\n"); | |
201 | fRawReader->AddMajorErrorLog(kDARCError); | |
202 | } | |
203 | if(status & 0x00f0 == 0x0020){ | |
204 | AliWarning("CDH -> DARC FEE error\n"); | |
205 | fRawReader->AddMajorErrorLog(kDARCError); | |
206 | } | |
207 | // | |
208 | if(status & 0x0f00 == 0x0200){ | |
209 | AliWarning("CDH -> DARC L1 time violation\n"); | |
210 | fRawReader->AddMajorErrorLog(kDARCError); | |
211 | } | |
212 | if(status & 0x0f00 == 0x0400){ | |
213 | AliWarning("CDH -> DARC L2 time-out\n"); | |
214 | fRawReader->AddMajorErrorLog(kDARCError); | |
215 | } | |
216 | if(status & 0x0f00 == 0x0800){ | |
217 | AliWarning("CDH -> DARC prepulse time violation\n"); | |
218 | fRawReader->AddMajorErrorLog(kDARCError); | |
219 | } | |
220 | // | |
221 | if(status & 0xf000 == 0x1000){ | |
222 | AliWarning("CDH -> DARC other error\n"); | |
223 | fRawReader->AddMajorErrorLog(kDARCError); | |
224 | } | |
225 | } | |
226 | // | |
227 | fIsDARCHeader = kTRUE; | |
228 | } | |
229 | ||
8309c1ab | 230 | //_____________________________________________________________________________ |
231 | Bool_t AliZDCRawStream::Next() | |
232 | { | |
abf60186 | 233 | // Read the next raw digit |
234 | // Returns kFALSE if there is no digit left | |
8309c1ab | 235 | |
1ee299a5 | 236 | if(!fRawReader->ReadNextInt((UInt_t&) fBuffer)) return kFALSE; |
237 | fIsChMapping = kFALSE; fIsADCHeader = kFALSE; | |
238 | fIsADCDataWord = kFALSE; fIsADCEOB = kFALSE; | |
239 | ||
240 | fEvType = fRawReader->GetType(); | |
241 | //printf("\n\t AliZDCRawStream::Next() -> ev. type %d\n",fEvType); | |
242 | ||
243 | if(fPosition==0){ | |
244 | //if(fEvType==7 || fEvType ==8){ //Physics or calibration event | |
245 | //ReadEventHeader(); | |
246 | ReadCDHHeader(); | |
247 | //} | |
248 | fNConnCh=0; | |
249 | } | |
250 | //printf("\n AliZDCRawStream::Next() - fBuffer[%d] = %x\n",fPosition, fBuffer); | |
251 | ||
252 | // ------------------------------------------- | |
1069e28d | 253 | // --- DARC header |
1ee299a5 | 254 | // ------------------------------------------- |
255 | if(fIsDARCHeader){ | |
84d2abc2 | 256 | //printf("\t ---- DARC header ----\n"); |
1ee299a5 | 257 | if(fIsCalib){ |
258 | fDeadfaceOffset = 9; | |
259 | fDeadbeefOffset = 25; | |
260 | } | |
261 | else{ | |
262 | fDeadfaceOffset = 1; | |
263 | fDeadbeefOffset = 7; | |
264 | } | |
265 | fDataOffset = 1+fDeadbeefOffset; | |
266 | fIsDARCHeader = kFALSE; | |
abf60186 | 267 | } |
1ee299a5 | 268 | |
269 | ||
270 | // ------------------------------------------- | |
271 | // --- Start of data event | |
272 | // --- decoding mapping of connected ADC ch. | |
273 | // ------------------------------------------- | |
274 | if(fEvType==10){ | |
275 | if(fPosition>fDataOffset){ | |
276 | if((fBuffer&0xff000000) == 0xff000000){ | |
277 | if(fPosition==(fDataOffset+1)){ | |
278 | printf("\n\n\t Reading ZDC mapping from StartOfData event\n"); | |
279 | fNConnCh=0; | |
6006df88 | 280 | } |
1ee299a5 | 281 | else{ |
84d2abc2 | 282 | //printf("\n\t End of StartOfData event\n\n"); |
1ee299a5 | 283 | return kTRUE; |
284 | } | |
285 | } | |
286 | else if((fBuffer&0x80000000)>>31 == 1){ | |
287 | // Mapping identification | |
288 | fADCModule = ((fBuffer & 0x7f000000)>>24); | |
289 | fModType = ((fBuffer & 0xfff000)>>8); | |
290 | fADCNChannels = (fBuffer & 0xff); | |
291 | // | |
292 | //printf("\tGEO %d, mod. type %d, #ch. %d\n",fADCModule,fModType,fADCNChannels); | |
6006df88 | 293 | } |
1ee299a5 | 294 | else if(fModType==0 && (fBuffer&0x80000000)>>31 == 0){ |
295 | // Channel signal | |
296 | if((fBuffer&0x40000000)>>30==0){ // high range chain ADC | |
297 | fIsChMapping = kTRUE; | |
298 | fADCChannel = ((fBuffer & 0x3fff0000)>>16); | |
299 | fCabledSignal = (fBuffer&0xffff); | |
300 | fMapADC[fNConnCh][0] = fADCModule; | |
301 | fMapADC[fNConnCh][1] = fADCChannel; | |
302 | fMapADC[fNConnCh][2] = fCabledSignal; | |
c93c022b | 303 | // |
304 | // Determining detector and sector | |
305 | // ----------------------------------------- | |
306 | // For the decoding of the following lines | |
307 | // look the enum in AliZDCRawStream.h file | |
308 | // ----------------------------------------- | |
309 | if((fCabledSignal>=2 && fCabledSignal<=6) || (fCabledSignal>=26 && fCabledSignal<=30) | |
310 | || fCabledSignal==24 || fCabledSignal==48){ | |
c677d80e | 311 | fMapADC[fNConnCh][3] = 4; //ZNA |
c93c022b | 312 | // |
313 | if(fCabledSignal==2 || fCabledSignal==26) fMapADC[fNConnCh][4]=0; | |
314 | else if(fCabledSignal==3 || fCabledSignal==27) fMapADC[fNConnCh][4]=1; | |
315 | else if(fCabledSignal==4 || fCabledSignal==28) fMapADC[fNConnCh][4]=2; | |
316 | else if(fCabledSignal==5 || fCabledSignal==29) fMapADC[fNConnCh][4]=3; | |
317 | else if(fCabledSignal==6 || fCabledSignal==30) fMapADC[fNConnCh][4]=4; | |
318 | else if(fCabledSignal==24 || fCabledSignal==48) fMapADC[fNConnCh][4]=5; | |
319 | } | |
320 | else if((fCabledSignal>=7 && fCabledSignal<=11) || (fCabledSignal>=31 && fCabledSignal<=35)){ | |
c677d80e | 321 | fMapADC[fNConnCh][3] = 5; //ZPA |
c93c022b | 322 | // |
323 | if(fCabledSignal==7 || fCabledSignal==31) fMapADC[fNConnCh][4]=0; | |
324 | else if(fCabledSignal==8 || fCabledSignal==32) fMapADC[fNConnCh][4]=1; | |
325 | else if(fCabledSignal==9 || fCabledSignal==33) fMapADC[fNConnCh][4]=2; | |
326 | else if(fCabledSignal==10 || fCabledSignal==34) fMapADC[fNConnCh][4]=3; | |
327 | else if(fCabledSignal==11 || fCabledSignal==35) fMapADC[fNConnCh][4]=4; | |
328 | } | |
329 | else if((fCabledSignal>=12 && fCabledSignal<=16) || (fCabledSignal>=36 && fCabledSignal<=40) | |
330 | || fCabledSignal==25 || fCabledSignal==49){ | |
c677d80e | 331 | fMapADC[fNConnCh][3] = 1; //ZNC |
c93c022b | 332 | // |
333 | if(fCabledSignal==12 || fCabledSignal==36) fMapADC[fNConnCh][4]=0; | |
334 | else if(fCabledSignal==13 || fCabledSignal==37) fMapADC[fNConnCh][4]=1; | |
335 | else if(fCabledSignal==14 || fCabledSignal==38) fMapADC[fNConnCh][4]=2; | |
336 | else if(fCabledSignal==15 || fCabledSignal==39) fMapADC[fNConnCh][4]=3; | |
337 | else if(fCabledSignal==16 || fCabledSignal==40) fMapADC[fNConnCh][4]=4; | |
338 | else if(fCabledSignal==25 || fCabledSignal==49) fMapADC[fNConnCh][4]=5; | |
339 | } | |
340 | else if((fCabledSignal>=17 && fCabledSignal<=21) || (fCabledSignal>=41 && fCabledSignal<=45)){ | |
c677d80e | 341 | fMapADC[fNConnCh][3] = 2; //ZPC |
c93c022b | 342 | // |
343 | if(fCabledSignal==17 || fCabledSignal==41) fMapADC[fNConnCh][4]=0; | |
344 | else if(fCabledSignal==18 || fCabledSignal==42) fMapADC[fNConnCh][4]=1; | |
345 | else if(fCabledSignal==19 || fCabledSignal==43) fMapADC[fNConnCh][4]=2; | |
346 | else if(fCabledSignal==20 || fCabledSignal==44) fMapADC[fNConnCh][4]=3; | |
347 | else if(fCabledSignal==21 || fCabledSignal==45) fMapADC[fNConnCh][4]=4; | |
348 | } | |
349 | else if(fCabledSignal==22 || fCabledSignal==23 || fCabledSignal==46 || fCabledSignal==47){ | |
c677d80e | 350 | fMapADC[fNConnCh][3] = 3; |
c93c022b | 351 | // |
352 | if(fCabledSignal==22 || fCabledSignal==46) fMapADC[fNConnCh][4]=1; | |
353 | else if(fCabledSignal==23 || fCabledSignal==47) fMapADC[fNConnCh][4]=2; | |
354 | } | |
355 | // | |
356 | //printf("AliZDCRawStream -> datum %d mod. %d ch. %d signal %d, det %d, tow %d\n", | |
357 | // fNConnCh,fADCModule,fADCChannel,fBuffer&0xffff,fMapADC[fNConnCh][3],fMapADC[fNConnCh][4]); | |
1ee299a5 | 358 | // |
359 | fNConnCh++; | |
360 | if(fNConnCh>48){ | |
361 | // Protection manually set since it returns: | |
362 | // RawData48 mod. 3 ch. 2048 signal 515 | |
363 | // to be checked with Pietro!!!!!!!!!!!!!!!!!!!!!!! | |
364 | AliWarning("\t AliZDCRawStream -> ERROR: no. of cabled channels > 48!!!\n"); | |
365 | return kFALSE; | |
366 | } | |
367 | } | |
1069e28d | 368 | } |
1ee299a5 | 369 | } |
370 | fPosition++; | |
371 | return kTRUE; | |
372 | } | |
373 | ||
374 | // ------------------------------------------- | |
375 | // --- DARC data | |
376 | // ------------------------------------------- | |
377 | if(fPosition<fDeadfaceOffset){ | |
378 | fPosition++; | |
379 | return kTRUE; | |
380 | } | |
381 | else if(fPosition==fDeadfaceOffset){ | |
382 | if(fBuffer != 0xdeadface){ | |
383 | AliWarning("AliZDCRawStream -> NO deadface after DARC data\n"); | |
384 | fRawReader->AddMajorErrorLog(kDARCError); | |
385 | } | |
386 | else{ | |
387 | fPosition++; | |
388 | return kTRUE; | |
389 | } | |
390 | } | |
391 | ||
392 | // ------------------------------------------- | |
393 | // --- DARC global data | |
394 | // ------------------------------------------- | |
395 | else if(fPosition>fDeadfaceOffset && fPosition<fDeadbeefOffset){ | |
396 | fPosition++; | |
397 | return kTRUE; | |
398 | } | |
399 | else if(fPosition==fDeadbeefOffset){ | |
400 | if(fBuffer != 0xdeadbeef){ | |
401 | AliWarning("AliZDCRawStream -> NO deadbeef after DARC global data\n"); | |
402 | fRawReader->AddMajorErrorLog(kDARCError); | |
403 | } | |
404 | else{ | |
405 | fPosition++; | |
406 | return kTRUE; | |
407 | } | |
408 | } | |
409 | ||
410 | // ------------------------------------------- | |
411 | // --- ZDC data | |
412 | // --- ADC buffer + scaler | |
413 | // ------------------------------------------- | |
414 | else if(fPosition>=fDataOffset){ | |
415 | ||
416 | // Not valid datum before the event | |
417 | // there MUST be a NOT valid datum before the event!!! | |
418 | if(fPosition==fDataOffset){ | |
84d2abc2 | 419 | //printf("\t **** ZDC data begin ****\n"); |
1ee299a5 | 420 | if((fBuffer & 0x07000000) == 0x06000000){ |
421 | //printf(" AliZDCRawStream -> Not valid datum in ADC %d," | |
422 | // "position %d in word data buffer\n",fADCModule,fPosition); | |
423 | } | |
424 | else fRawReader->AddMajorErrorLog(kZDCDataError); | |
425 | } | |
426 | ||
427 | // If the not valid datum isn't followed by the 1st ADC header | |
428 | // the event is corrupted (i.e., 2 gates arrived before trigger) | |
429 | else if(fPosition==fDataOffset+1){ | |
430 | if((fBuffer & 0x07000000) != 0x02000000){ | |
431 | AliWarning("ZDC ADC -> The not valid datum is NOT followed by an ADC header!\n"); | |
432 | fRawReader->AddMajorErrorLog(kZDCDataError); | |
433 | } | |
434 | } | |
435 | ||
436 | // Get geo address of current word to determine | |
437 | // if it is a scaler word (geo address == kScalerAddress) | |
438 | // if it is an ADC word (geo address != 8) | |
439 | Int_t kScalerAddress=8; | |
440 | fADCModule = ((fBuffer & 0xf8000000)>>27); | |
441 | if(fADCModule == kScalerAddress){ | |
442 | DecodeScaler(); | |
443 | } | |
444 | else{//ADC module | |
445 | // *** End of event | |
446 | if(fBuffer == 0xcafefade){ | |
84d2abc2 | 447 | //printf(" AliZDCRawStream -> End of ZDC event!\n"); |
1ee299a5 | 448 | } |
449 | // *** ADC header | |
450 | else if((fBuffer & 0x07000000) == 0x02000000){ | |
451 | fIsADCHeader = kTRUE; | |
452 | fADCNChannels = ((fBuffer & 0x00003f00)>>8); | |
84d2abc2 | 453 | //printf(" AliZDCRawStream -> HEADER: ADC mod.%d has %d ch. \n",fADCModule,fADCNChannels); |
1ee299a5 | 454 | } |
455 | // *** ADC data word | |
456 | else if((fBuffer & 0x07000000) == 0x00000000){ | |
457 | fIsADCDataWord = kTRUE; | |
458 | fADCChannel = ((fBuffer & 0x1e0000) >> 17); | |
459 | fADCGain = ((fBuffer & 0x10000) >> 16); | |
460 | fADCValue = (fBuffer & 0xfff); | |
461 | ||
84d2abc2 | 462 | //printf(" AliZDCRawStream -> DATA: ADC mod. %d ch. %d gain %d value %d\n", |
463 | // fADCModule,fADCChannel,fADCGain,fADCValue); | |
1ee299a5 | 464 | |
465 | // Valid ADC data (not underflow nor overflow) | |
466 | if(!(fBuffer & 0x1000) && !(fBuffer & 0x2000)){ | |
c93c022b | 467 | |
468 | // Checking if the channel map for the ADCs has been provided/read | |
469 | if(fMapADC[0][0]==-1){ | |
11b06725 | 470 | // Temporary solution (to be changed!!!!) |
471 | //printf("\t ATTENTION!!! No ADC mapping has been found/provided!!!\n"); | |
472 | //return kFALSE; | |
473 | char * mapFileName=gSystem->ExpandPathName("$ALICE_ROOT/ZDC/ShuttleInput/ZDCChMapping.dat"); | |
474 | FILE *file; | |
475 | Int_t ival[48][6]; | |
476 | if((file = fopen(mapFileName,"r")) != NULL){ | |
477 | for(Int_t j=0; j<48; j++){ | |
478 | for(Int_t k=0; k<6; k++){ | |
479 | fscanf(file,"%d",&ival[j][k]); | |
480 | } | |
481 | fMapADC[j][0] = ival[j][1]; | |
482 | fMapADC[j][1] = ival[j][2]; | |
483 | fMapADC[j][2] = ival[j][3]; | |
484 | fMapADC[j][3] = ival[j][4]; | |
485 | fMapADC[j][4] = ival[j][5]; | |
486 | } | |
487 | } | |
488 | else{ | |
489 | printf("File %s not found\n",mapFileName); | |
490 | return kFALSE; | |
491 | } | |
492 | ||
c93c022b | 493 | } |
494 | // | |
495 | //printf("\n Reading map!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); | |
496 | /*for(Int_t ci=0; ci<48; ci++){ | |
497 | printf(" %d mod. %d ch. %d signal %d\n",ci,fMapADC[ci][0], | |
498 | fMapADC[ci][1], fMapADC[ci][2]); | |
499 | } | |
500 | */ | |
1ee299a5 | 501 | for(Int_t k=0; k<48; k++){ |
c93c022b | 502 | if(fADCModule==fMapADC[k][0] && fADCChannel==fMapADC[k][1]){ |
503 | fSector[0] = fMapADC[k][3]; | |
504 | fSector[1] = fMapADC[k][4]; | |
1ee299a5 | 505 | break; |
506 | } | |
507 | } | |
1ee299a5 | 508 | // |
c93c022b | 509 | //printf("AliZDCRawStream -> ADCmod. %d ADCch %d det %d, sec %d\n", |
510 | // fADCModule,fADCChannel,fSector[0],fSector[1]); | |
1ee299a5 | 511 | |
512 | if(fADCModule<0 || fADCModule>3){ | |
513 | AliWarning(Form(" AliZDCRawStream -> No valid ADC module: %d\n",fADCModule)); | |
514 | fRawReader->AddMajorErrorLog(kInvalidADCModule); | |
515 | } | |
516 | ||
517 | }//No underflow nor overflow | |
518 | }//ADC data word | |
519 | // *** ADC EOB | |
520 | else if((fBuffer & 0x07000000) == 0x04000000){ | |
521 | fIsADCEOB = kTRUE; | |
522 | //printf(" AliZDCRawStream -> EOB --------------------------\n"); | |
523 | } | |
524 | }//ADC module | |
525 | ||
526 | ||
527 | } | |
528 | fPosition++; | |
83347831 | 529 | |
8309c1ab | 530 | return kTRUE; |
531 | } | |
e42bdf10 | 532 | |
533 | //_____________________________________________________________________________ | |
534 | void AliZDCRawStream::DecodeScaler() | |
535 | { | |
536 | // Decoding scaler event | |
537 | ||
538 | if(!fBuffer & 0x04000000){ | |
539 | AliWarning(" AliZDCRawStream -> Scaler header corrupted\n"); | |
540 | fIsScEventGood = kFALSE; | |
541 | } | |
22fe5e66 | 542 | Int_t scNwords = (Int_t) fScNWords; |
543 | if(fPosition==scNwords && fBuffer != 0x0){ | |
e42bdf10 | 544 | AliWarning(" AliZDCRawStream -> Scaler trailer corrupted\n"); |
545 | fIsScEventGood = kFALSE; | |
546 | } | |
547 | fIsScEventGood = kTRUE; | |
548 | ||
549 | if(fPosition==0){ | |
550 | fScNWords = (fBuffer & 0x00fc0000)>>18; | |
551 | fScGeo = (fBuffer & 0xf8000000)>>27; | |
552 | fScTS = (fBuffer & 0x00030000)>>16; | |
553 | fScTriggerNumber = (fBuffer & 0x0000ffff); | |
554 | } | |
555 | ||
556 | fPosition++; | |
557 | ||
558 | } |