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