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