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