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