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