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