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