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