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