d2e2f542 |
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 | /////////////////////////////////////////////////////////////////////////////// |
17 | /// |
18 | /// This is a class for reading the HMPID raw data |
19 | /// The format of the raw data corresponds to the one |
20 | /// which was documented by Paolo Martinengo. |
21 | /// |
22 | /////////////////////////////////////////////////////////////////////////////// |
23 | |
24 | #include "AliHMPIDRawStream.h" |
25 | #include "AliRawReader.h" |
26 | #include "AliLog.h" |
21f61e25 |
27 | |
d2e2f542 |
28 | ClassImp(AliHMPIDRawStream) |
29 | |
e96561a3 |
30 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
d2e2f542 |
31 | AliHMPIDRawStream::AliHMPIDRawStream(AliRawReader* rawReader) : |
a66fe5e5 |
32 | fNPads(0), |
33 | fCharge(0x0), |
34 | fPad(0x0), |
d2e2f542 |
35 | fDDLNumber(-1), |
0cd503a3 |
36 | fnDDLInStream(0x0), |
37 | fnDDLOutStream(0x0), |
3c8e86a0 |
38 | fLDCNumber( 0), |
39 | fTimeStamp( 0), |
d2e2f542 |
40 | fRawReader(rawReader), |
a66fe5e5 |
41 | fData(0x0), |
42 | fNumOfErr(0x0), |
43 | fPosition(-1), |
44 | fWord(0), |
45 | fZeroSup(kTRUE), |
46 | fPos(0x0), |
cb9b108e |
47 | fiPos(0), |
48 | fTurbo(kFALSE) |
d2e2f542 |
49 | { |
3c8e86a0 |
50 | // |
d2e2f542 |
51 | // Constructor |
3c8e86a0 |
52 | // |
53 | fNumOfErr = new Int_t*[kNDDL]; // Store the numner of errors for a given error type and a given DD |
54 | for(Int_t i=0;i<kNDDL;i++) { |
55 | fNumOfErr[i] = new Int_t [kSumErr]; |
56 | } |
57 | |
0cd503a3 |
58 | fnDDLInStream=new Int_t[kNDDL]; |
59 | fnDDLOutStream=new Int_t[kNDDL]; |
60 | for(Int_t iddl=0;iddl<kNDDL;iddl++) { fnDDLInStream[iddl]=-1;fnDDLOutStream[iddl]=-1;} |
61 | |
3c8e86a0 |
62 | for(Int_t iddl=0;iddl<kNDDL;iddl++) |
63 | for(Int_t ierr=0; ierr < kSumErr; ierr++) fNumOfErr[iddl][ierr]=0; //reset errors |
d2e2f542 |
64 | fRawReader->Reset(); |
65 | fRawReader->Select("HMPID"); |
38f3076a |
66 | |
67 | |
68 | |
d2e2f542 |
69 | } |
e96561a3 |
70 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
21f61e25 |
71 | AliHMPIDRawStream::AliHMPIDRawStream() : |
a66fe5e5 |
72 | fNPads(0), |
73 | fCharge(0x0), |
74 | fPad(0x0), |
21f61e25 |
75 | fDDLNumber(-1), |
0cd503a3 |
76 | fnDDLInStream(0x0), |
77 | fnDDLOutStream(0x0), |
3c8e86a0 |
78 | fLDCNumber( 0), |
79 | fTimeStamp( 0), |
d3917810 |
80 | fRawReader(0x0), |
a66fe5e5 |
81 | fData(0x0), |
3c8e86a0 |
82 | fNumOfErr(0x0), |
a66fe5e5 |
83 | fPosition(-1), |
84 | fWord(0), |
85 | fZeroSup(kTRUE), |
86 | fPos(0x0), |
cb9b108e |
87 | fiPos(0), |
88 | fTurbo(kFALSE) |
21f61e25 |
89 | { |
3c8e86a0 |
90 | // |
91 | // Constructor |
92 | // |
93 | fNumOfErr = new Int_t*[kNDDL]; // Store the numner of errors for a given error type and a given DD |
94 | for(Int_t i=0;i<kNDDL;i++) { |
95 | fNumOfErr[i] = new Int_t [kSumErr]; |
96 | } |
0cd503a3 |
97 | fnDDLInStream=new Int_t[kNDDL]; |
98 | fnDDLOutStream=new Int_t[kNDDL]; |
99 | for(Int_t iddl=0;iddl<kNDDL;iddl++) { fnDDLInStream[iddl]=-1;fnDDLOutStream[iddl]=-1;} |
100 | |
101 | |
3c8e86a0 |
102 | for(Int_t iddl=0;iddl<kNDDL;iddl++) |
103 | for(Int_t ierr=0; ierr < kSumErr; ierr++) fNumOfErr[iddl][ierr]=0; //reset errors |
104 | |
21f61e25 |
105 | } |
e96561a3 |
106 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
d2e2f542 |
107 | AliHMPIDRawStream::~AliHMPIDRawStream() |
108 | { |
3c8e86a0 |
109 | // |
d2e2f542 |
110 | // destructor |
3c8e86a0 |
111 | // |
112 | DelVars(); |
38f3076a |
113 | |
114 | |
115 | fDDLNumber=0; |
116 | fLDCNumber=0; |
117 | fTimeStamp=0; |
118 | fPosition=0; |
119 | fWord=0; |
120 | fZeroSup=0; |
cb9b108e |
121 | fTurbo=0; |
bc6cefce |
122 | for(Int_t i=0;i<kNDDL;i++) delete [] fNumOfErr[i]; |
38f3076a |
123 | delete [] fNumOfErr; |
124 | |
bc6cefce |
125 | delete [] fnDDLInStream; |
126 | delete [] fnDDLOutStream; |
d2e2f542 |
127 | } |
fd8bfa30 |
128 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
d2e2f542 |
129 | void AliHMPIDRawStream::Reset() |
130 | { |
131 | // reset raw stream params |
d2e2f542 |
132 | // Reinitalize the containers |
d2e2f542 |
133 | fDDLNumber = -1; |
3c8e86a0 |
134 | fLDCNumber = 0; |
135 | fTimeStamp = 0; |
d2e2f542 |
136 | fPosition = -1; |
137 | fData = NULL; |
d2e2f542 |
138 | if (fRawReader) fRawReader->Reset(); |
139 | } |
fd8bfa30 |
140 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
cb9b108e |
141 | Bool_t AliHMPIDRawStream::Turbo() |
142 | { |
143 | |
144 | Int_t row,dilogic;UInt_t pad; |
145 | Int_t cntGlob = fRawReader->GetDataSize()/4; |
146 | fPosition=0; |
147 | fNPads=0; |
148 | // Int_t gw=0; |
149 | for(Int_t i=1;i<cntGlob;i++) { |
803dcdb1 |
150 | if(!GetWord(1)) return kFALSE; |
cb9b108e |
151 | if (((fWord >> kbit27) & 1)) continue; |
152 | UInt_t statusControlRow = 0x32a8; |
153 | UInt_t rowControlWord = fWord >> kbit0 & 0xfbff; |
154 | if(rowControlWord == statusControlRow) continue; |
155 | |
156 | row = (fWord >> kbit22) & 0x1f; |
157 | dilogic = (fWord >> kbit18) & 0xf; //dilogic info in raw word is between bits: 18...21 |
158 | |
159 | pad = (fWord >> kbit12) & 0x3f; //pad info in raw word is between bits: 12...17 |
160 | if(!CheckPad(pad)) continue; |
161 | Int_t charge = fWord & 0xfff; |
162 | if(GetPad(fDDLNumber,row,dilogic,pad)<0) continue; |
163 | fPad[fNPads] = GetPad(fDDLNumber,row,dilogic,pad); |
164 | fCharge[fNPads] = charge; |
165 | fNPads++; |
166 | if(charge==0) fNumOfErr[fDDLNumber][kPedQZero]++; |
167 | }//word loop |
168 | //Printf("Size: %i DDL %i row %i dilogic %i pad %i fPos %i fNPads: %i Charge: %d Word %4.4x GoodW: %i",cntGlob,fDDLNumber,row,dilogic,pad,fPosition,fNPads,fCharge[fNPads-1],fWord,gw++); |
169 | return kTRUE; |
170 | }//Turbo() |
171 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
d2e2f542 |
172 | Bool_t AliHMPIDRawStream::Next() |
173 | { |
21f61e25 |
174 | // read next DDL raw data from the HMPID raw data stream |
d2e2f542 |
175 | // return kFALSE in case of error or no data left |
21f61e25 |
176 | AliDebug(1,"Start."); |
d2e2f542 |
177 | do { |
178 | if (!fRawReader->ReadNextData(fData)) return kFALSE; |
179 | } while (fRawReader->GetDataSize() == 0); |
21f61e25 |
180 | |
fd8bfa30 |
181 | |
843bde9a |
182 | /* |
183 | Event type is selected as in $ALICE_ROOT/RAW/event.h |
184 | #define START_OF_RUN ((eventTypeType) 1) |
185 | #define END_OF_RUN ((eventTypeType) 2) |
186 | #define START_OF_RUN_FILES ((eventTypeType) 3) |
187 | #define END_OF_RUN_FILES ((eventTypeType) 4) |
188 | #define START_OF_BURST ((eventTypeType) 5) |
189 | #define END_OF_BURST ((eventTypeType) 6) |
190 | #define PHYSICS_EVENT ((eventTypeType) 7) <<--------------- |
191 | #define CALIBRATION_EVENT ((eventTypeType) 8) |
192 | #define EVENT_FORMAT_ERROR ((eventTypeType) 9) |
193 | #define START_OF_DATA ((eventTypeType)10) |
194 | #define END_OF_DATA ((eventTypeType)11) |
195 | #define SYSTEM_SOFTWARE_TRIGGER_EVENT ((eventTypeType)12) |
196 | #define DETECTOR_SOFTWARE_TRIGGER_EVENT ((eventTypeType)13) |
197 | #define EVENT_TYPE_MIN 1 |
198 | #define EVENT_TYPE_MAX 13 |
199 | */ |
fd8bfa30 |
200 | |
201 | fPosition = 0; |
c61a7285 |
202 | Bool_t status=kTRUE; |
3c8e86a0 |
203 | Int_t rawDataSize=0; |
77e40af5 |
204 | if(fRawReader->GetType() == 7 || fRawReader->GetType() == 8 ) { //New: Select Physics events, Old: Raw data size is not 0 and not 47148 (pedestal) |
21f61e25 |
205 | fDDLNumber = fRawReader->GetDDLID(); |
0cd503a3 |
206 | fnDDLInStream[fDDLNumber]=1; fnDDLOutStream[fDDLNumber]=0; |
0cd503a3 |
207 | |
3c8e86a0 |
208 | fLDCNumber = fRawReader->GetLDCId(); |
209 | fTimeStamp = fRawReader->GetTimestamp(); |
0cd503a3 |
210 | |
b38ac33a |
211 | AliDebug(1,Form("DDL %i started to be decoded!",fDDLNumber)); |
3c8e86a0 |
212 | rawDataSize=fRawReader->GetDataSize()/4; |
38f3076a |
213 | DelVars(); //We have to delete the variables initialized in the InitVars before recall IntiVars!!! |
214 | InitVars(rawDataSize); //To read the charge and pads we cannot delete before the status return |
3c8e86a0 |
215 | |
cb9b108e |
216 | if(fTurbo==kTRUE) status=Turbo(); |
217 | else status = ReadHMPIDRawData(); |
e96561a3 |
218 | |
b38ac33a |
219 | if(status) AliDebug(1,Form("Event DDL %i successfully decoded!.",fDDLNumber)); |
220 | else AliDebug(1,Form("Event DDL %i ERROR in decoding!.",fDDLNumber)); |
e96561a3 |
221 | // DumpData(fRawReader->GetDataSize()); |
38f3076a |
222 | |
223 | |
224 | } |
0cd503a3 |
225 | if(status==kTRUE) {fnDDLOutStream[fDDLNumber]++; }//Printf("fnDDLOutStream[%d]=%d",fDDLNumber,fnDDLOutStream[fDDLNumber]); } //Count the number of events when the DDL was succesfully decoded |
38f3076a |
226 | |
b38ac33a |
227 | // return status; // temporary solution... |
228 | return kTRUE; |
fd8bfa30 |
229 | } |
56c73976 |
230 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
231 | void AliHMPIDRawStream::InitVars(Int_t n) |
232 | { |
3c8e86a0 |
233 | // |
234 | // |
235 | // |
56c73976 |
236 | fNPads = 0; |
38f3076a |
237 | fCharge = new Int_t[n]; |
3c8e86a0 |
238 | fPad = new Int_t[n]; |
56c73976 |
239 | //for debug purpose |
3c8e86a0 |
240 | fPos = new Int_t[4*n+4]; //reset debug |
241 | fiPos = 0; |
56c73976 |
242 | } |
243 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
244 | void AliHMPIDRawStream::DelVars() |
245 | { |
3c8e86a0 |
246 | // |
247 | // |
248 | // |
38f3076a |
249 | //Clean the initvars!!!!!!!! |
250 | fNPads = 0; |
251 | if (fCharge) { delete [] fCharge; fCharge = 0x0; } |
3c8e86a0 |
252 | if (fPad) { delete [] fPad; fPad = 0x0; } |
253 | if (fPos) { delete [] fPos; fPos = 0x0; } |
38f3076a |
254 | |
255 | fiPos=0; |
256 | |
0cd503a3 |
257 | |
56c73976 |
258 | } |
fd8bfa30 |
259 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
260 | Bool_t AliHMPIDRawStream::ReadHMPIDRawData() |
261 | { |
b38ac33a |
262 | //Here the loop on the decoding the raw bank |
263 | //for one ddl starts. |
264 | //It returns: kFALSE if any error occurs |
265 | // kTRUE if all OK |
fd8bfa30 |
266 | Int_t cntGlob = fRawReader->GetDataSize()/4; |
3c8e86a0 |
267 | if(cntGlob==0) {fNumOfErr[fDDLNumber][kRawDataSizeErr]++; return kFALSE; } |
268 | |
fd8bfa30 |
269 | Int_t cnt = cntGlob; |
fd8bfa30 |
270 | Int_t nwSeg; |
271 | Int_t cntSegment; |
272 | |
3c8e86a0 |
273 | if(!GetWord(cnt)) return kFALSE; |
274 | cnt--; |
fd8bfa30 |
275 | |
276 | |
277 | while (cnt>0) { |
278 | |
56c73976 |
279 | nwSeg = (fWord >> kbit8) & 0xfff; |
280 | if(!CheckSegment()) return kFALSE; |
281 | if(!ReadSegment(cntSegment)) return kFALSE; |
fd8bfa30 |
282 | |
b38ac33a |
283 | if(nwSeg != cntSegment) {AliDebug(1,Form("Error in Segment counters: %i different wrt %i",nwSeg,cntSegment)); return kFALSE;} |
3c8e86a0 |
284 | if(!GetWord(cntSegment+1,kBwd)) return kFALSE; |
fd8bfa30 |
285 | cnt-=cntSegment+1; |
286 | } |
21f61e25 |
287 | |
d2e2f542 |
288 | return kTRUE; |
fd8bfa30 |
289 | |
d2e2f542 |
290 | } |
fd8bfa30 |
291 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
56c73976 |
292 | Bool_t AliHMPIDRawStream::ReadSegment(Int_t &cntSegment) |
fd8bfa30 |
293 | { |
b38ac33a |
294 | //Read the segment |
295 | //It returns: kFALSE if any error occurs |
296 | // kTRUE if all OK |
56c73976 |
297 | cntSegment = (fWord >> kbit8) & 0xfff; |
fd8bfa30 |
298 | Int_t cnt = cntSegment; |
299 | Int_t cntRow; |
300 | Int_t nwRow; |
d2e2f542 |
301 | |
3c8e86a0 |
302 | if(!GetWord(cnt,kBwd)) return kFALSE; |
fd8bfa30 |
303 | |
304 | while (cnt>0) { |
305 | |
56c73976 |
306 | cntRow = (fWord >> kbit16) & 0xfff; |
307 | if(!CheckRowMarker()) return kFALSE; |
308 | if(!ReadRow(nwRow)) return kFALSE; |
fd8bfa30 |
309 | |
b38ac33a |
310 | if(nwRow != cntRow) {AliDebug(1,Form("Error in Row counters: %i different wrt %i",nwRow,cntRow)); return kFALSE;} |
3c8e86a0 |
311 | if(!GetWord(cntRow+1)) return kFALSE; |
fd8bfa30 |
312 | cnt -= cntRow+1; |
313 | |
314 | } |
315 | |
316 | cntSegment -= cnt; |
317 | |
318 | return kTRUE; |
319 | |
320 | } |
321 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
56c73976 |
322 | Bool_t AliHMPIDRawStream::ReadRow(Int_t &cntRow) |
fd8bfa30 |
323 | { |
b38ac33a |
324 | // Read the row |
325 | //It returns: kFALSE if any error occurs |
326 | // kTRUE if all OK |
327 | |
fd8bfa30 |
328 | Int_t cnt; |
329 | Int_t cntDilogic; |
330 | Int_t nwDil; |
331 | |
56c73976 |
332 | cntRow = (fWord >> kbit16) & 0xfff; |
fd8bfa30 |
333 | cnt = cntRow; |
334 | |
3c8e86a0 |
335 | if(!GetWord(cntRow)) return kFALSE; |
fd8bfa30 |
336 | |
337 | while (cnt>0) { |
338 | |
56c73976 |
339 | if(!CheckEoE(nwDil)) return kFALSE; |
340 | if(!ReadDilogic(cntDilogic)) return kFALSE; |
fd8bfa30 |
341 | |
b38ac33a |
342 | if(nwDil != cntDilogic) {AliDebug(1,Form("Error in Dilogic counters: %i different wrt %i",nwDil,cntDilogic));return kFALSE;} |
fd8bfa30 |
343 | cnt -= cntDilogic; |
3c8e86a0 |
344 | if(!GetWord(1,kBwd)) return kFALSE; // go to next Dilogic bank... |
fd8bfa30 |
345 | cnt--; |
346 | // Printf(" cnt %i cntDilogic %i ",cnt,cntDilogic); |
347 | } |
348 | |
349 | cntRow -= cnt; |
350 | |
351 | return kTRUE; |
352 | |
353 | } |
354 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
56c73976 |
355 | Bool_t AliHMPIDRawStream::ReadDilogic(Int_t &cntDilogic) |
fd8bfa30 |
356 | { |
b38ac33a |
357 | // Read the dilogic bank |
358 | //It returns: kFALSE if any error occurs |
359 | // kTRUE if all OK |
360 | |
56c73976 |
361 | cntDilogic = fWord & 0x7f; |
fd8bfa30 |
362 | |
363 | Int_t cnt = cntDilogic; |
56c73976 |
364 | |
365 | // Printf(" cnt DILOGIC %i at %i word %08X",cnt,fPosition,fWord); |
fd8bfa30 |
366 | |
367 | for(Int_t iDil=0;iDil<cntDilogic;iDil++) { |
368 | UInt_t dilogic = 0, row = 0; |
3c8e86a0 |
369 | if(!GetWord(1,kBwd)) return kFALSE; |
fd8bfa30 |
370 | //check on row number |
371 | cnt--; |
56c73976 |
372 | row = (fWord >> kbit22) & 0x1f; |
fd8bfa30 |
373 | if(!CheckRow(row)) continue; |
374 | //check dilogic number |
56c73976 |
375 | dilogic = (fWord >> kbit18) & 0xf; //dilogic info in raw word is between bits: 18...21 |
fd8bfa30 |
376 | if(!CheckDilogic(dilogic)) continue; |
377 | //check pad number |
56c73976 |
378 | UInt_t pad = (fWord >> kbit12) & 0x3f; //pad info in raw word is between bits: 12...17 |
fd8bfa30 |
379 | if(!CheckPad(pad)) continue; |
56c73976 |
380 | Int_t charge = fWord & 0xfff; |
df8ff88a |
381 | if(GetPad(fDDLNumber,row,dilogic,pad)<0) continue; |
56c73976 |
382 | fPad[fNPads] = GetPad(fDDLNumber,row,dilogic,pad); |
0cd503a3 |
383 | fCharge[fNPads] = charge; |
56c73976 |
384 | fNPads++; |
0cd503a3 |
385 | |
386 | if(charge==0) |
387 | { |
2df59c26 |
388 | AliDebug(1,Form("If PEDESTAL run -> WARNING: ZERO charge is read from DDL: %d row: %d dil: %d pad: %d",fDDLNumber,row,dilogic,pad)); |
0cd503a3 |
389 | fNumOfErr[fDDLNumber][kPedQZero]++; |
390 | } |
391 | |
392 | }//iDil |
fd8bfa30 |
393 | |
394 | cntDilogic -= cnt; |
395 | return kTRUE; |
396 | } |
397 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
56c73976 |
398 | Bool_t AliHMPIDRawStream::CheckSegment() |
d2e2f542 |
399 | { |
b38ac33a |
400 | // Check the segment marker |
401 | //It returns: kFALSE if any error occurs |
402 | // kTRUE if all OK |
403 | |
fd8bfa30 |
404 | UInt_t markSegment = 0xAB0; |
405 | /* |
406 | if (iRow%8 == 0) { |
407 | UInt_t segWord = GetWord(); |
408 | if ((segWord >> 20) != statusSegWord) { |
409 | fRawReader->AddMajorErrorLog(kBadSegWordErr); |
f1d82833 |
410 | AliDebug(1,Form("Wrong segment word signature: %x, expected 0xab0!",(segWord >> 20))); |
fd8bfa30 |
411 | fNumOfErr[kBadSegWordErr]++; |
412 | return kTRUE; |
413 | } |
414 | */ |
56c73976 |
415 | UInt_t segMarker = (fWord >> kbit20) & 0xfff; |
fd8bfa30 |
416 | if (segMarker != markSegment ) { |
e96561a3 |
417 | //fRawReader->AddMajorErrorLog(kWrongSegErr,Form("Segment marker %0X wrong (expected %0X) at %i in word %0X!",segMarker,markSegment,fPosition,fWord)); |
f1d82833 |
418 | AliDebug(1,Form("Segment marker %X wrong (expected %0X)! at %i in word %0X!",segMarker,markSegment,fPosition,fWord)); |
e96561a3 |
419 | fNumOfErr[fDDLNumber][kWrongSegErr]++; |
fd8bfa30 |
420 | return kFALSE; |
421 | } |
422 | |
56c73976 |
423 | UInt_t segAddress = fWord & 0xff; |
fd8bfa30 |
424 | if (segAddress<1 ||segAddress>3) { |
e96561a3 |
425 | //fRawReader->AddMajorErrorLog(kWrongSegErr,Form("Segment address %d not in the valid range [1-3] at %i in word %0X",segAddress,fPosition,fWord)); |
f1d82833 |
426 | AliDebug(1,Form("Segment address %d not in the valid range [1-3]",segAddress)); |
e96561a3 |
427 | fNumOfErr[fDDLNumber][kWrongSegErr]++; |
fd8bfa30 |
428 | return kFALSE; |
429 | } |
56c73976 |
430 | // Printf("Segment Marker found at %i! Number of segment is %i",fPosition,segAddress); |
fd8bfa30 |
431 | return kTRUE; |
432 | } |
433 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
434 | Bool_t AliHMPIDRawStream::CheckRow(UInt_t row) |
435 | { |
b38ac33a |
436 | //check on row number |
437 | //It returns: kFALSE if any error occurs |
438 | // kTRUE if all OK |
56c73976 |
439 | // Printf("ROW %i word %0X",row,fWord); |
fd8bfa30 |
440 | if(row>=1 && row <=kNRows) return kTRUE; |
441 | |
e96561a3 |
442 | //fRawReader->AddMajorErrorLog(kWrongRowErr,Form("row %d",row)); |
f1d82833 |
443 | AliDebug(1,Form("Wrong row index: %d, expected (1 -> %d) word %0X at %i...",row,kNRows,fWord,fPosition)); |
e96561a3 |
444 | fNumOfErr[fDDLNumber][kWrongRowErr]++; |
fd8bfa30 |
445 | return kFALSE; |
446 | } |
447 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
448 | Bool_t AliHMPIDRawStream::CheckDilogic(UInt_t dilogic) |
449 | { |
450 | //check dilogic number |
b38ac33a |
451 | //It returns: kFALSE if any error occurs |
452 | // kTRUE if all OK |
fd8bfa30 |
453 | if (dilogic>= 1 && dilogic <=kNDILOGICAdd) return kTRUE; |
454 | |
e96561a3 |
455 | //fRawReader->AddMajorErrorLog(kWrongDilogicErr,Form("dil %d",dilogic)); |
f1d82833 |
456 | AliDebug(1,Form("Wrong DILOGIC index: %d, expected (1 -> %d)!",dilogic,kNDILOGICAdd)); |
e96561a3 |
457 | fNumOfErr[fDDLNumber][kWrongDilogicErr]++; |
fd8bfa30 |
458 | //dilogic = iDILOGIC; |
459 | return kFALSE; |
460 | } |
461 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
462 | Bool_t AliHMPIDRawStream::CheckPad(UInt_t pad) |
463 | { |
464 | //check pad number |
b38ac33a |
465 | //It returns: kFALSE if any error occurs |
466 | // kTRUE if all OK |
fd8bfa30 |
467 | if (pad < kNPadAdd) return kTRUE; |
468 | |
e96561a3 |
469 | //fRawReader->AddMajorErrorLog(kWrongPadErr,Form("pad %d",pad)); |
f1d82833 |
470 | AliDebug(1,Form("Wrong pad index: %d, expected (0 -> %d)!",pad,kNPadAdd)); |
e96561a3 |
471 | fNumOfErr[fDDLNumber][kWrongPadErr]++; |
fd8bfa30 |
472 | return kFALSE; |
473 | } |
474 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
56c73976 |
475 | Bool_t AliHMPIDRawStream::CheckEoE(Int_t &nDil) |
fd8bfa30 |
476 | { |
b38ac33a |
477 | //check the End of Event |
478 | //It returns: kFALSE if any error occurs |
479 | // kTRUE if all OK |
56c73976 |
480 | if (!((fWord >> kbit27) & 0x1)) { //check 27th bit in EoE. It must be 1! |
e96561a3 |
481 | //fRawReader->AddMajorErrorLog(kEoEFlagErr); |
f1d82833 |
482 | AliDebug(1,Form("Missing end-of-event flag! (%08X) at %i",fWord,fPosition)); |
e96561a3 |
483 | fNumOfErr[fDDLNumber][kEoEFlagErr]++; |
fd8bfa30 |
484 | return kFALSE; |
485 | } |
e96561a3 |
486 | nDil = fWord & 0x7f; //nDil=EoE word count |
487 | if(nDil < 0 || nDil > 48 ) { |
488 | |
489 | //fRawReader->AddMajorErrorLog(kEoESizeErr,Form("EoE size=%d",nDil)); |
f1d82833 |
490 | AliDebug(1,Form("Wrong end-of-event word-count: %08X",fWord)); |
e96561a3 |
491 | fNumOfErr[fDDLNumber][kEoESizeErr]++; |
fd8bfa30 |
492 | return kFALSE; |
493 | } |
494 | // UInt_t da = (eOfEvent >> 18) & 0xf; |
495 | // if (cntData!=0 && da != dilogic) { |
496 | // fRawReader->AddMajorErrorLog(kEoEDILOGICErr,Form("eoe dil %d != %d",da,dilogic)); |
f1d82833 |
497 | // AliDebug(1,Form("Wrong DILOGIC address found in end-of-event: %d, expected %d!",da,dilogic)); |
fd8bfa30 |
498 | // fNumOfErr[kEoEDILOGICErr]++; |
4e25ac79 |
499 | // return kFALSE; AliQAChecker::Instance()->Run(AliQAv1::kHMPID, task, obj) ; |
fd8bfa30 |
500 | |
501 | // } |
502 | // UInt_t ca = (eOfEvent >> 22) & 0x1f; |
503 | // if (cntData!=0 && ca != row) { |
504 | // fRawReader->AddMajorErrorLog(kEoERowErr,Form("eoe row %d != %d",ca,row)); |
f1d82833 |
505 | // AliDebug(1,Form("Wrong row index found in end-of-event: %d, expected %d!",ca,row)); |
fd8bfa30 |
506 | // fNumOfErr[kEoERowErr]++; |
507 | // return kFALSE; |
508 | // } |
509 | return kTRUE; |
510 | } |
511 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
56c73976 |
512 | Bool_t AliHMPIDRawStream::CheckRowMarker() |
fd8bfa30 |
513 | { |
b38ac33a |
514 | //check the row marker |
515 | //It returns: kFALSE if any error occurs |
516 | // kTRUE if all OK |
fd8bfa30 |
517 | UInt_t nMAXwordsInRow = 0x1EA; |
518 | UInt_t statusControlRow = 0x32a8; // 0x36a8 for zero suppression |
519 | //First check on row marker |
56c73976 |
520 | UInt_t rowControlWord = fWord >> kbit0 & 0xfbff; |
fd8bfa30 |
521 | |
522 | if(rowControlWord != statusControlRow) { |
e96561a3 |
523 | //fRawReader->AddMajorErrorLog(kRowMarkerErr); |
f1d82833 |
524 | AliDebug(1,Form("Wrong row marker %x expected 0x32a8!",rowControlWord)); |
e96561a3 |
525 | fNumOfErr[fDDLNumber][kRowMarkerErr]++; |
b38ac33a |
526 | return kFALSE; |
e96561a3 |
527 | } |
fd8bfa30 |
528 | //Second check on row marker |
e96561a3 |
529 | UInt_t wordsInRow = fWord >> kbit16 & 0x0fff; // Number of words after the row marker, bit 10 is skipped in this check |
fd8bfa30 |
530 | |
531 | if (wordsInRow > nMAXwordsInRow) { |
e96561a3 |
532 | //fRawReader->AddMajorErrorLog(kRowMarkerSizeErr); |
f1d82833 |
533 | AliDebug(1,Form(" FATAL: Number of words %x in a row exceeds the expected value: 0x1EA !",wordsInRow)); |
e96561a3 |
534 | fNumOfErr[fDDLNumber][kRowMarkerSizeErr]++; |
fd8bfa30 |
535 | return kFALSE; |
536 | } |
537 | |
538 | return kTRUE; |
539 | } |
540 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
3c8e86a0 |
541 | Bool_t AliHMPIDRawStream::GetWord(Int_t n,EDirection dir) |
fd8bfa30 |
542 | { |
543 | // This method returns the n-th 32 bit word |
d2e2f542 |
544 | // inside the raw data payload. |
545 | // The method is supposed to be endian (platform) |
546 | // independent. |
fd8bfa30 |
547 | |
3c8e86a0 |
548 | fWord = 0; |
803dcdb1 |
549 | if (fPosition < 0) { |
824b2ad9 |
550 | AliError("fPosition < 0 !!! Event skipped."); |
803dcdb1 |
551 | fRawReader->AddMajorErrorLog(kRawDataSizeErr,"fPosition<0"); |
552 | return kFALSE; |
553 | } |
3c8e86a0 |
554 | |
fd8bfa30 |
555 | if(dir==kBwd) n = -n; |
556 | fPosition+=4*n-4; |
3c8e86a0 |
557 | |
558 | if(fPosition==-4) return kTRUE; |
fd8bfa30 |
559 | |
3c8e86a0 |
560 | if(fPosition<0 || fPosition > fRawReader->GetDataSize()) { |
824b2ad9 |
561 | AliWarning(Form("fPosition out of boundaries %i",fPosition)); |
3c8e86a0 |
562 | return kFALSE; |
563 | } |
564 | |
fd8bfa30 |
565 | StorePosition(); |
566 | |
3c8e86a0 |
567 | fWord |= fData[fPosition++]; |
568 | fWord |= fData[fPosition++] << 8; |
569 | fWord |= fData[fPosition++] << 16; |
570 | fWord |= fData[fPosition++] << 24; |
fd8bfa30 |
571 | |
3c8e86a0 |
572 | return kTRUE; |
d2e2f542 |
573 | } |
fd8bfa30 |
574 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
575 | void AliHMPIDRawStream::DumpData(Int_t nw) |
576 | { |
b38ac33a |
577 | //just a simple raw data dump |
578 | // in () is the position in bytes |
579 | //-- |
fd8bfa30 |
580 | for(Int_t i=0;i<nw;i+=4) { |
581 | if(!(i%16)) printf(" \n %8i) ",i); |
582 | printf("%02X%02X%02X%02X [ %06i ] ",fData[i+3],fData[i+2],fData[i+1],fData[i+0],fPos[i]); |
583 | } |
584 | Printf(" \n -----end of dump ----------- "); |
585 | } |
586 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
587 | void AliHMPIDRawStream::StorePosition() |
588 | { |
b38ac33a |
589 | //just for debug purpose |
590 | // it stores the position |
591 | //read for the first time |
3c8e86a0 |
592 | // Printf("@@@@@@@@@ fPos: %x fPosition: %d",fPos,fPosition); |
56c73976 |
593 | if(fPos[fPosition]!=0) { |
594 | // Printf("Position already stored!!! Value %i at address %i",fPos[fPosition],fPosition); |
595 | return; |
596 | } |
3c8e86a0 |
597 | fiPos++; |
598 | fPos[fPosition] = fiPos; |
fd8bfa30 |
599 | // if(stDeb)Printf("%i - Actual position %i",iPos,fPosition); |
600 | } |
e96561a3 |
601 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |