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