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