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