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