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