Line data Source code
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 : $Log: AliTOFDecoder.cxx,v $
18 : Revision 1.4 2007/05/18 13:08:57 decaro
19 : Coding convention: RS1 violation -> suppression
20 :
21 : Revision 1.3 2007/05/08 11:56:05 arcelli
22 : improved verbosity in verbose mode (R.Preghenella)
23 :
24 : Revision 1.2 2007/05/03 11:34:43 decaro
25 : Coding convention: RS1 violation -> suppression
26 :
27 : Revision 1.1 2007/04/27 11:00:32 arcelli
28 : TOF Raw Data decoder
29 :
30 : author: Roberto Preghenella (R+), preghenella@bo.infn.it
31 : */
32 :
33 :
34 : //////////////////////////////////////////////////////////////////////
35 : // //
36 : // //
37 : // Class for raw data decoding //
38 : // //
39 : // //
40 : //////////////////////////////////////////////////////////////////////
41 :
42 :
43 : #include "AliLog.h"
44 : #include "AliTOFRawDataFormat.h"
45 : #include "AliTOFDecoderV2.h"
46 : #include "AliTOFTDCHit.h"
47 : #include "AliTOFDecoderSummaryData.h"
48 : #include "AliTOFDRMSummaryData.h"
49 : #include "AliTOFLTMSummaryData.h"
50 : #include "AliTOFTRMSummaryData.h"
51 : #include "AliTOFChainSummaryData.h"
52 : #include "AliTOFTDCHitBuffer.h"
53 : #include "AliTOFTDCErrorBuffer.h"
54 : #include "AliRawDataHeader.h"
55 :
56 26 : ClassImp(AliTOFDecoderV2)
57 :
58 : //_________________________________________________________________
59 :
60 170 : AliTOFDecoderV2::AliTOFDecoderV2(AliRawReader *reader) :
61 10 : TObject(),
62 10 : fRawReader(reader),
63 10 : fVerbose(kFALSE),
64 10 : fLogErrors(kFALSE),
65 10 : fV2718Patch(kFALSE),
66 10 : fRecoverError(kTRUE),
67 10 : fRecoverErrorThr(0),
68 10 : fSpider(kTRUE),
69 10 : fRunNumber(0),
70 10 : fEventNumber(0),
71 10 : fEquipmentID(0),
72 10 : fDecoderSummaryData(0x0),
73 10 : fDRMSummaryData(0x0),
74 10 : fLTMSummaryData(0x0),
75 10 : fTRMSummaryData(0x0),
76 10 : fChainSummaryData(0x0),
77 10 : fTDCHitBuffer(0x0),
78 10 : fTDCPackedHitBuffer(0x0),
79 10 : fTDCErrorBuffer(0x0),
80 10 : fDRMGlobalHeader(0x0),
81 10 : fDRMGlobalTrailer(0x0),
82 10 : fDRMStatusHeader1(0x0),
83 10 : fDRMStatusHeader2(0x0),
84 10 : fDRMStatusHeader3(0x0),
85 10 : fDRMStatusHeader4(0x0),
86 10 : fDRMEventCRC(0x0),
87 10 : fLTMGlobalHeader(0x0),
88 10 : fLTMGlobalTrailer(0x0),
89 10 : fLTMPDLData(0x0),
90 10 : fLTMADCData(0x0),
91 10 : fLTMORData(0x0),
92 10 : fTRMGlobalHeader(0x0),
93 10 : fTRMGlobalTrailer(0x0),
94 10 : fTRMChainHeader(0x0),
95 10 : fTRMChainTrailer(0x0),
96 10 : fTDCPackedHit(0x0),
97 10 : fTDCUnpackedHit(0x0),
98 10 : fTRMTDCError(0x0),
99 10 : fTRMDiagnosticErrorWord1(0x0),
100 10 : fTRMDiagnosticErrorWord2(0x0),
101 10 : fSpiderTDCID(-1),
102 10 : fSpiderTDCPackedHitBuffer(0x0)
103 50 : {
104 : //default constructor
105 10 : if (fRawReader)
106 0 : fRawReader->Select("TOF", 0, 71);
107 :
108 30 : fDecoderSummaryData = new AliTOFDecoderSummaryData();
109 :
110 180 : for (Int_t iChan = 0; iChan < N_CHANNEL; iChan++)
111 80 : fSpiderBufferFull[iChan] = kFALSE;
112 20 : }
113 :
114 : //_________________________________________________________________
115 :
116 0 : AliTOFDecoderV2::AliTOFDecoderV2(const AliTOFDecoderV2 &source) :
117 0 : TObject(),
118 0 : fRawReader(source.fRawReader),
119 0 : fVerbose(source.fVerbose),
120 0 : fLogErrors(source.fLogErrors),
121 0 : fV2718Patch(source.fV2718Patch),
122 0 : fRecoverError(source.fRecoverError),
123 0 : fRecoverErrorThr(source.fRecoverErrorThr),
124 0 : fSpider(source.fSpider),
125 0 : fRunNumber(source.fRunNumber),
126 0 : fEventNumber(source.fEventNumber),
127 0 : fEquipmentID(source.fEquipmentID),
128 0 : fDecoderSummaryData(0x0),
129 0 : fDRMSummaryData(0x0),
130 0 : fLTMSummaryData(0x0),
131 0 : fTRMSummaryData(0x0),
132 0 : fChainSummaryData(0x0),
133 0 : fTDCHitBuffer(0x0),
134 0 : fTDCPackedHitBuffer(0x0),
135 0 : fTDCErrorBuffer(0x0),
136 0 : fDRMGlobalHeader(0x0),
137 0 : fDRMGlobalTrailer(0x0),
138 0 : fDRMStatusHeader1(0x0),
139 0 : fDRMStatusHeader2(0x0),
140 0 : fDRMStatusHeader3(0x0),
141 0 : fDRMStatusHeader4(0x0),
142 0 : fDRMEventCRC(0x0),
143 0 : fLTMGlobalHeader(0x0),
144 0 : fLTMGlobalTrailer(0x0),
145 0 : fLTMPDLData(0x0),
146 0 : fLTMADCData(0x0),
147 0 : fLTMORData(0x0),
148 0 : fTRMGlobalHeader(0x0),
149 0 : fTRMGlobalTrailer(0x0),
150 0 : fTRMChainHeader(0x0),
151 0 : fTRMChainTrailer(0x0),
152 0 : fTDCPackedHit(0x0),
153 0 : fTDCUnpackedHit(0x0),
154 0 : fTRMTDCError(0x0),
155 0 : fTRMDiagnosticErrorWord1(0x0),
156 0 : fTRMDiagnosticErrorWord2(0x0),
157 0 : fSpiderTDCID(-1),
158 0 : fSpiderTDCPackedHitBuffer(0x0)
159 0 : {
160 : //copy constructor
161 0 : fDecoderSummaryData = new AliTOFDecoderSummaryData(*source.fDecoderSummaryData);
162 :
163 0 : for (Int_t iChan = 0; iChan < N_CHANNEL; iChan++)
164 0 : fSpiderBufferFull[iChan] = kFALSE;
165 0 : }
166 :
167 : //_________________________________________________________________
168 :
169 : AliTOFDecoderV2 &
170 : AliTOFDecoderV2::operator = (const AliTOFDecoderV2 &source)
171 : {
172 : //operator =
173 0 : if (this == &source) return *this;
174 0 : TObject::operator=(source);
175 0 : fRawReader = source.fRawReader;
176 0 : fVerbose = source.fVerbose;
177 0 : fLogErrors = source.fLogErrors;
178 0 : fV2718Patch = source.fV2718Patch;
179 0 : fRecoverError = source.fRecoverError;
180 0 : fRecoverErrorThr = source.fRecoverErrorThr;
181 0 : fSpider = source.fSpider;
182 0 : fRunNumber = source.fRunNumber;
183 0 : fEventNumber = source.fEventNumber;
184 0 : fEquipmentID = source.fEquipmentID;
185 0 : *fDecoderSummaryData = *source.fDecoderSummaryData;
186 0 : return *this;
187 0 : }
188 :
189 : AliTOFDecoderV2::~AliTOFDecoderV2()
190 48 : {
191 16 : delete fDecoderSummaryData;
192 96 : }
193 :
194 : //_________________________________________________________________
195 :
196 : Bool_t
197 : AliTOFDecoderV2::Decode(UInt_t *rawData, UInt_t nWords)
198 : {
199 : /* main decoding routine.
200 : * it loops over nWords 32-bit words
201 : * starting at *rawData and decodes them.
202 : * it also fills some buffers in order to
203 : * have the decoded data available for other
204 : * classes.
205 : */
206 :
207 : //reset decoder summary data
208 1152 : fDecoderSummaryData->Reset();
209 :
210 : //fill decoder summary data
211 576 : fDecoderSummaryData->SetRunNumber(fRunNumber);
212 576 : fDecoderSummaryData->SetEventNumber(fEventNumber);
213 576 : fDecoderSummaryData->SetEquipmentID(fEquipmentID);
214 576 : fDecoderSummaryData->SetInputWords(nWords);
215 576 : fDecoderSummaryData->SetRecoverError(fRecoverError);
216 576 : fDecoderSummaryData->SetSpider(fSpider);
217 :
218 576 : AliTOFTDCHit hit;
219 576 : AliTOFTDCError error;
220 :
221 : //decoder status
222 : UShort_t decoderStatus = 0x0;
223 :
224 : //CRC variables
225 : UInt_t drmCRC = 0x0;
226 : UInt_t ltmCRC = 0x0;
227 : UInt_t trmCRC = 0x0;
228 :
229 : // error warning counter
230 : Int_t errorWarning = 0;
231 :
232 1152 : if (fRecoverError && fVerbose)
233 0 : AliInfo("Recover error option enabled: potentially dangerous!");
234 :
235 : /*** V2718 patch ***/
236 576 : if (fV2718Patch){
237 : decoderStatus = decoderStatus | DRM_BIT;
238 0 : fDecoderSummaryData->SetDecoderStatus(decoderStatus);
239 0 : fDecoderSummaryData->SetCurrentDRMID(0x0);
240 0 : fDecoderSummaryData->SetV2718Patch(kTRUE);
241 0 : fDRMSummaryData = fDecoderSummaryData->GetDRMSummaryData();
242 0 : fDRMSummaryData->SetHeader(kTRUE);
243 0 : fDRMSummaryData->SetDRMID(0x0);
244 0 : if (fVerbose)
245 0 : AliInfo("DRM not present: - V2718 patch decoding -");
246 : }
247 : /*** V2718 patch ***/
248 :
249 576 : if (fVerbose)
250 0 : AliInfo("Start decoding");
251 :
252 576 : if (fVerbose)
253 0 : AliInfo("Loop over the data and decode");
254 :
255 576 : if (fVerbose)
256 0 : AliInfo(" St Hex Word \t Decoded Word");
257 :
258 : //loop over raw data
259 72800 : for (UInt_t iWord = 0;
260 36112 : iWord < nWords;
261 35536 : iWord++, rawData++, fDecoderSummaryData->SetDecodedWords(iWord)){
262 :
263 : //try to recover error
264 35536 : if (fDecoderSummaryData->GetRecoveringError() && fVerbose)
265 0 : AliInfo(Form(" %02x - 0x%08x",decoderStatus,*rawData));
266 :
267 : //compute CRC with current data
268 35536 : drmCRC ^= *rawData;
269 35536 : ltmCRC ^= *rawData;
270 35536 : trmCRC ^= *rawData;
271 :
272 : //switch word type
273 35536 : switch (*rawData & WORD_TYPE_MASK){
274 :
275 : case GLOBAL_HEADER:
276 :
277 : //switch slot ID
278 6624 : switch (*rawData & SLOT_ID_MASK){
279 :
280 : //DRM global header (slotID=1)
281 : case 1:
282 : //try to recover error
283 576 : if (fDecoderSummaryData->GetRecoveringError())
284 : continue;
285 : //check decode status
286 576 : if ( decoderStatus != DRM_HEADER_STATUS ){
287 0 : if (fLogErrors)
288 0 : AliError(Form(" %02x - 0x%08x [ERROR] Unexpected DRM global header (curslot=%d, eqID=%d)",decoderStatus,*rawData,fDecoderSummaryData->GetCurrentSlotID(), fEquipmentID));
289 0 : fDecoderSummaryData->SetErrorDetected(kTRUE);
290 0 : fDecoderSummaryData->SetErrorSlotID(fDecoderSummaryData->GetCurrentSlotID());
291 0 : errorWarning++;
292 : //try to recover error
293 0 : if (fRecoverError){
294 0 : if (errorWarning > fRecoverErrorThr) {
295 0 : if (fVerbose)
296 0 : AliInfo("Trying to recover the error: searching for the next header");
297 0 : fDecoderSummaryData->SetRecoveringError(kTRUE);
298 0 : continue;
299 : }
300 : else {
301 0 : if (fVerbose)
302 0 : AliInfo("Do not try to recover error yet, go on with decoding process");
303 : continue;
304 : }
305 : }
306 0 : return(fDecoderSummaryData->GetErrorDetected());
307 : }
308 : //decode status ok
309 : errorWarning = 0;
310 : //set DRM global header
311 576 : fDRMGlobalHeader = (AliTOFDRMGlobalHeader *)rawData;
312 : //reset DRM CRC
313 : drmCRC = 0x0;
314 : //fill decoder summary data
315 576 : fDecoderSummaryData->SetCurrentDRMID(fDRMGlobalHeader->GetDRMID());
316 576 : fDecoderSummaryData->SetCurrentSlotID(fDRMGlobalHeader->GetSlotID());
317 : //get DRM summary data
318 576 : fDRMSummaryData = fDecoderSummaryData->GetDRMSummaryData();
319 : //reset DRM summary data
320 576 : fDRMSummaryData->Reset();
321 : //fill DRM summary data
322 576 : FillDRMSummaryData(fDRMGlobalHeader);
323 : //print verbose
324 576 : if (fVerbose)
325 0 : AliInfo(Form(" %02x - 0x%08x \t DRM global header",decoderStatus,*rawData));
326 : //change decode status
327 576 : decoderStatus = decoderStatus | DRM_BIT;
328 576 : fDecoderSummaryData->SetDecoderStatus(decoderStatus);
329 : //decode DRM status headers
330 5760 : for (Int_t i = 0; i < DRM_STATUS_HEADER_WORDS; i++){
331 2304 : iWord++;
332 2304 : rawData++;
333 2304 : drmCRC ^= *rawData;
334 :
335 2304 : switch (i){
336 : case 0: //DRM status header 1
337 576 : fDRMStatusHeader1 = (AliTOFDRMStatusHeader1 *)rawData;
338 576 : FillDRMSummaryData(fDRMStatusHeader1);
339 576 : if (fVerbose)
340 0 : AliInfo(Form(" %02x - 0x%08x \t DRM status header 1",decoderStatus,*rawData));
341 : break;
342 : case 1: //DRM status header 2
343 576 : fDRMStatusHeader2 = (AliTOFDRMStatusHeader2 *)rawData;
344 576 : FillDRMSummaryData(fDRMStatusHeader2);
345 576 : if (fVerbose)
346 0 : AliInfo(Form(" %02x - 0x%08x \t DRM status header 2",decoderStatus,*rawData));
347 : break;
348 : case 2: //DRM status header 3
349 576 : fDRMStatusHeader3 = (AliTOFDRMStatusHeader3 *)rawData;
350 576 : FillDRMSummaryData(fDRMStatusHeader3);
351 576 : if (fVerbose)
352 0 : AliInfo(Form(" %02x - 0x%08x \t DRM status header 3",decoderStatus,*rawData));
353 : break;
354 : case 3: //DRM status header 4
355 576 : fDRMStatusHeader4 = (AliTOFDRMStatusHeader4 *)rawData;
356 576 : FillDRMSummaryData(fDRMStatusHeader4);
357 576 : if (fVerbose)
358 0 : AliInfo(Form(" %02x - 0x%08x \t DRM status header 4",decoderStatus,*rawData));
359 : break;
360 : }
361 : }
362 : //decode DRM event CRC
363 576 : iWord++;
364 576 : rawData++;
365 576 : drmCRC ^= *rawData;
366 : //remove DRM event CRC from DRM CRC
367 : drmCRC ^= *rawData;
368 576 : fDRMEventCRC = (AliTOFDRMEventCRC *)rawData;
369 576 : FillDRMSummaryData(fDRMEventCRC);
370 576 : if (fVerbose)
371 0 : AliInfo(Form(" %02x - 0x%08x \t DRM event CRC",decoderStatus,*rawData));
372 : break;
373 :
374 : //LTM global header (slotID=2)
375 : case 2:
376 : //recover error
377 576 : if (fDecoderSummaryData->GetRecoveringError()){
378 : //change decode status
379 : decoderStatus = LTM_HEADER_STATUS;
380 0 : fDecoderSummaryData->SetDecoderStatus(decoderStatus);
381 0 : fDecoderSummaryData->SetRecoveringError(kFALSE);
382 0 : if (fVerbose)
383 0 : AliInfo("LTM global header found: error probably recovered");
384 : }
385 : //check decode status
386 576 : if ( decoderStatus != LTM_HEADER_STATUS ){
387 0 : if (fLogErrors)
388 0 : AliError(Form(" %02x - 0x%08x [ERROR] Unexpected LTM global header (curslot=%d, eqID=%d)",decoderStatus,*rawData,fDecoderSummaryData->GetCurrentSlotID(), fEquipmentID));
389 0 : fDecoderSummaryData->SetErrorDetected(kTRUE);
390 0 : fDecoderSummaryData->SetErrorSlotID(fDecoderSummaryData->GetCurrentSlotID());
391 0 : errorWarning++;
392 : //try to recover error
393 0 : if (fRecoverError){
394 0 : if (errorWarning > fRecoverErrorThr) {
395 0 : if (fVerbose)
396 0 : AliInfo("Trying to recover the error: searching for the next header");
397 0 : fDecoderSummaryData->SetRecoveringError(kTRUE);
398 0 : continue;
399 : }
400 : else {
401 0 : if (fVerbose)
402 0 : AliInfo("Do not try to recover error yet, go on with decoding process");
403 : continue;
404 : }
405 : }
406 0 : return(fDecoderSummaryData->GetErrorDetected());
407 : }
408 : //decode status ok
409 : errorWarning = 0;
410 : //set LTM global header
411 576 : fLTMGlobalHeader = (AliTOFLTMGlobalHeader *)rawData;
412 : //reset LTM CRC
413 : ltmCRC = 0x0;
414 : //fill decoder summary data
415 576 : fDecoderSummaryData->SetCurrentSlotID(fLTMGlobalHeader->GetSlotID());
416 : //get LTM summary data
417 576 : fLTMSummaryData = fDRMSummaryData->GetLTMSummaryData();
418 : //reset LTM summary data
419 576 : fLTMSummaryData->Reset();
420 : //fill LTM summary data
421 576 : FillLTMSummaryData(fLTMGlobalHeader);
422 : //set DRM slot enable mask bit
423 576 : fDRMSummaryData->SetDecoderSlotEnableMaskBit(fLTMGlobalHeader->GetSlotID() - 2);
424 : //print verbose
425 576 : if (fVerbose)
426 0 : AliInfo(Form(" %02x - 0x%08x \t LTM global header",decoderStatus,*rawData));
427 : //change decode status
428 576 : decoderStatus = decoderStatus | LTM_BIT;
429 576 : fDecoderSummaryData->SetDecoderStatus(decoderStatus);
430 :
431 : //decode LTM PDL data
432 14976 : for (Int_t iPDLWord = 0; iPDLWord < LTM_PDL_DATA_WORDS; iPDLWord++){
433 6912 : iWord++;
434 6912 : rawData++;
435 6912 : drmCRC ^= *rawData;
436 6912 : ltmCRC ^= *rawData;
437 : //set LTM PDL data
438 6912 : fLTMPDLData = (AliTOFLTMPDLData *)rawData;
439 : //fill LTM summary data
440 6912 : FillLTMSummaryData(fLTMPDLData, iPDLWord);
441 : //print verbose
442 6912 : if (fVerbose)
443 0 : AliInfo(Form(" %02x - 0x%08x \t LTM PDL data \t\t PDL1=%03d PDL2=%03d PDL3=%03d PDL4=%03d",decoderStatus,*rawData,fLTMPDLData->GetPDLValue1(),fLTMPDLData->GetPDLValue2(),fLTMPDLData->GetPDLValue3(),fLTMPDLData->GetPDLValue4()));
444 : }
445 : //decode LTM ADC data
446 24192 : for (Int_t iADCWord = 0; iADCWord < LTM_ADC_DATA_WORDS; iADCWord++){
447 11520 : iWord++;
448 11520 : rawData++;
449 11520 : drmCRC ^= *rawData;
450 11520 : ltmCRC ^= *rawData;
451 : //set LTM ADC data
452 11520 : fLTMADCData = (AliTOFLTMADCData *)rawData;
453 : //fill LTM summary data
454 11520 : FillLTMSummaryData(fLTMADCData, iADCWord);
455 : //print verbose
456 11520 : if (fVerbose)
457 0 : AliInfo(Form(" %02x - 0x%08x \t LTM ADC data \t\t ADC1=%04d ADC2=%04d ADC3=%04d",decoderStatus,*rawData,fLTMADCData->GetADCValue1(),fLTMADCData->GetADCValue2(),fLTMADCData->GetADCValue3()));
458 : }
459 : //decode LTM OR data
460 19584 : for (Int_t iORWord = 0; iORWord < LTM_OR_DATA_WORDS; iORWord++){
461 9216 : iWord++;
462 9216 : rawData++;
463 9216 : drmCRC ^= *rawData;
464 9216 : ltmCRC ^= *rawData;
465 : //set LTM OR data
466 9216 : fLTMORData = (AliTOFLTMORData *)rawData;
467 : //fill LTM summary data
468 9216 : FillLTMSummaryData(fLTMORData, iORWord);
469 : //print verbose
470 9216 : if (fVerbose)
471 0 : AliInfo(Form(" %02x - 0x%08x \t LTM OR data \t\t ADC1=%04d ADC2=%04d ADC3=%04d",decoderStatus,*rawData,fLTMORData->GetORValue1(),fLTMORData->GetORValue2(),fLTMORData->GetORValue3()));
472 : }
473 576 : break;
474 :
475 : //TRM global header (slotID=3-12)
476 : case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12:
477 : //recover error
478 5472 : if (fDecoderSummaryData->GetRecoveringError()){
479 : //change decode status
480 : decoderStatus = TRM_HEADER_STATUS;
481 0 : fDecoderSummaryData->SetDecoderStatus(decoderStatus);
482 0 : fDecoderSummaryData->SetRecoveringError(kFALSE);
483 0 : if (fVerbose)
484 0 : AliInfo("TRM global header found: error probably recovered");
485 : }
486 : //check decode status
487 5472 : if ( decoderStatus != TRM_HEADER_STATUS ){
488 0 : if (fLogErrors)
489 0 : AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM global header (curslot=%d, eqID=%d)",decoderStatus,*rawData,fDecoderSummaryData->GetCurrentSlotID(), fEquipmentID));
490 0 : fDecoderSummaryData->SetErrorDetected(kTRUE);
491 0 : fDecoderSummaryData->SetErrorSlotID(fDecoderSummaryData->GetCurrentSlotID());
492 0 : errorWarning++;
493 : //try to recover error
494 0 : if (fRecoverError){
495 0 : if (errorWarning > fRecoverErrorThr) {
496 0 : if (fVerbose)
497 0 : AliInfo("Trying to recover the error: searching for the next header");
498 0 : fDecoderSummaryData->SetRecoveringError(kTRUE);
499 0 : continue;
500 : }
501 : else {
502 0 : if (fVerbose)
503 0 : AliInfo("Do not try to recover error yet, go on with decoding process");
504 : continue;
505 : }
506 : }
507 0 : return(fDecoderSummaryData->GetErrorDetected());
508 : }
509 : //decode status ok
510 : errorWarning = 0;
511 : //set TRM global header
512 5472 : fTRMGlobalHeader = (AliTOFTRMGlobalHeader *)rawData;
513 : //reset TRM CRC
514 : trmCRC = 0x0;
515 : //fill decoder summary data
516 5472 : fDecoderSummaryData->SetCurrentSlotID(fTRMGlobalHeader->GetSlotID());
517 : //get TRM summary data
518 5472 : fTRMSummaryData = fDRMSummaryData->GetTRMSummaryData(fTRMGlobalHeader->GetSlotID() - TRM_FIRST_SLOT_ID);
519 : //reset TRM summary data
520 5472 : fTRMSummaryData->Reset();
521 : //fill TRM summary data
522 5472 : FillTRMSummaryData(fTRMGlobalHeader);
523 : //set DRM slot enable mask bit
524 5472 : fDRMSummaryData->SetDecoderSlotEnableMaskBit(fTRMGlobalHeader->GetSlotID() - 2);
525 : //print verbose
526 5472 : if (fVerbose)
527 0 : AliInfo(Form(" %02x - 0x%08x \t TRM global header \t slotID=%02d ACQ=%01d L=%01d",decoderStatus,*rawData,fTRMGlobalHeader->GetSlotID(),fTRMGlobalHeader->GetACQBits(),fTRMGlobalHeader->GetLBit()));
528 : //change decode status
529 5472 : decoderStatus = decoderStatus | TRM_BIT;
530 5472 : fDecoderSummaryData->SetDecoderStatus(decoderStatus);
531 5472 : break;
532 :
533 : default:
534 0 : if (fLogErrors)
535 0 : AliError(Form(" %02x - 0x%08x [ERROR] Not valid slotID in global header (curslot=%d, eqID=%d)",decoderStatus,*rawData,fDecoderSummaryData->GetCurrentSlotID(), fEquipmentID));
536 0 : fDecoderSummaryData->SetErrorDetected(kTRUE);
537 0 : fDecoderSummaryData->SetErrorSlotID(fDecoderSummaryData->GetCurrentSlotID());
538 : //try to recover error
539 0 : if (fRecoverError){
540 0 : if (errorWarning > fRecoverErrorThr) {
541 0 : if (fVerbose)
542 0 : AliInfo("Trying to recover the error: searching for the next header");
543 0 : fDecoderSummaryData->SetRecoveringError(kTRUE);
544 0 : continue;
545 : }
546 : else {
547 0 : if (fVerbose)
548 0 : AliInfo("Do not try to recover error yet, go on with decoding process");
549 : continue;
550 : }
551 : }
552 0 : return(fDecoderSummaryData->GetErrorDetected());
553 : break;
554 :
555 : }
556 : //end switch slotID
557 : break;
558 :
559 : case GLOBAL_TRAILER:
560 :
561 : //switch slot ID
562 6624 : switch (*rawData & SLOT_ID_MASK){
563 :
564 : //DRM global trailer (slotID=1)
565 : case 1:
566 : //recover error
567 576 : if (fDecoderSummaryData->GetRecoveringError()){
568 : //change decode status
569 : decoderStatus = DRM_TRAILER_STATUS;
570 0 : fDecoderSummaryData->SetDecoderStatus(decoderStatus);
571 0 : fDecoderSummaryData->SetRecoveringError(kFALSE);
572 0 : if (fVerbose)
573 0 : AliInfo("DRM global trailer found: error probably recovered");
574 : }
575 : //check decode status
576 576 : if ( decoderStatus != DRM_TRAILER_STATUS ){
577 0 : if (fLogErrors)
578 0 : AliError(Form(" %02x - 0x%08x [ERROR] Unexpected DRM global trailer (curslot=%d, eqID=%d)",decoderStatus,*rawData,fDecoderSummaryData->GetCurrentSlotID(), fEquipmentID));
579 0 : fDecoderSummaryData->SetErrorDetected(kTRUE);
580 0 : fDecoderSummaryData->SetErrorSlotID(fDecoderSummaryData->GetCurrentSlotID());
581 0 : errorWarning++;
582 : //try to recover error
583 0 : if (fRecoverError){
584 0 : if (errorWarning > fRecoverErrorThr) {
585 0 : if (fVerbose)
586 0 : AliInfo("Trying to recover the error: searching for the next header");
587 0 : fDecoderSummaryData->SetRecoveringError(kTRUE);
588 0 : continue;
589 : }
590 : else {
591 0 : if (fVerbose)
592 0 : AliInfo("Do not try to recover error yet, go on with decoding process");
593 : continue;
594 : }
595 : }
596 0 : return(fDecoderSummaryData->GetErrorDetected());
597 : }
598 : //decode status ok
599 : errorWarning = 0;
600 : //set DRM global trailer
601 576 : fDRMGlobalTrailer = (AliTOFDRMGlobalTrailer *)rawData;
602 : //remove global trailer from DRM CRC
603 576 : drmCRC ^= *rawData;
604 : //fill DRM summary data
605 576 : FillDRMSummaryData(fDRMGlobalTrailer);
606 576 : fDRMSummaryData->SetDecoderCRC(COMPUTE_DRM_CRC(drmCRC));
607 : //print verbose
608 576 : if (fVerbose)
609 0 : AliInfo(Form(" %02x - 0x%08x \t DRM global trailer",decoderStatus,*rawData));
610 : //change decode status
611 576 : decoderStatus = decoderStatus & ~DRM_BIT;
612 576 : fDecoderSummaryData->SetDecoderStatus(decoderStatus);
613 576 : break;
614 :
615 : //LTM global trailer (slotID=2)
616 : case 2:
617 : //try to recover error
618 576 : if (fDecoderSummaryData->GetRecoveringError())
619 : continue;
620 : //check decode status
621 576 : if ( decoderStatus != LTM_TRAILER_STATUS ){
622 0 : if (fLogErrors)
623 0 : AliError(Form(" %02x - 0x%08x [ERROR] Unexpected LTM global trailer (curslot=%d, eqID=%d)",decoderStatus,*rawData,fDecoderSummaryData->GetCurrentSlotID(), fEquipmentID));
624 0 : fDecoderSummaryData->SetErrorDetected(kTRUE);
625 0 : fDecoderSummaryData->SetErrorSlotID(fDecoderSummaryData->GetCurrentSlotID());
626 0 : errorWarning++;
627 : //try to recover error
628 0 : if (fRecoverError){
629 0 : if (errorWarning > fRecoverErrorThr) {
630 0 : if (fVerbose)
631 0 : AliInfo("Trying to recover the error: searching for the next header");
632 0 : fDecoderSummaryData->SetRecoveringError(kTRUE);
633 0 : continue;
634 : }
635 : else {
636 0 : if (fVerbose)
637 0 : AliInfo("Do not try to recover error yet, go on with decoding process");
638 : continue;
639 : }
640 : }
641 0 : return(fDecoderSummaryData->GetErrorDetected());
642 : }
643 : //decode status ok
644 : errorWarning = 0;
645 : //set LTM global trailer
646 576 : fLTMGlobalTrailer = (AliTOFLTMGlobalTrailer *)rawData;
647 : //remove global trailer from LTM CRC
648 576 : ltmCRC ^= *rawData;
649 : //fill LTM summary data
650 576 : FillLTMSummaryData(fLTMGlobalTrailer);
651 576 : fLTMSummaryData->SetDecoderCRC(COMPUTE_LTM_CRC(ltmCRC));
652 : //print verbose
653 576 : if (fVerbose)
654 0 : AliInfo(Form(" %02x - 0x%08x \t LTM global trailer",decoderStatus,*rawData));
655 : //change decode status
656 576 : decoderStatus = decoderStatus & ~LTM_BIT;
657 576 : fDecoderSummaryData->SetDecoderStatus(decoderStatus);
658 576 : break;
659 :
660 : //TRM global trailer (slotID=15)
661 : case 15:
662 : //try to recover error
663 5472 : if (fDecoderSummaryData->GetRecoveringError())
664 : continue;
665 : //check decode status
666 5472 : if ( decoderStatus != TRM_TRAILER_STATUS ){
667 0 : if (fLogErrors)
668 0 : AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM global trailer (curslot=%d, eqID=%d)",decoderStatus,*rawData,fDecoderSummaryData->GetCurrentSlotID(), fEquipmentID));
669 0 : fDecoderSummaryData->SetErrorDetected(kTRUE);
670 0 : fDecoderSummaryData->SetErrorSlotID(fDecoderSummaryData->GetCurrentSlotID());
671 0 : errorWarning++;
672 : //try to recover error
673 0 : if (fRecoverError){
674 0 : if (errorWarning > fRecoverErrorThr) {
675 0 : if (fVerbose)
676 0 : AliInfo("Trying to recover the error: searching for the next header");
677 0 : fDecoderSummaryData->SetRecoveringError(kTRUE);
678 0 : continue;
679 : }
680 : else {
681 0 : if (fVerbose)
682 0 : AliInfo("Do not try to recover error yet, go on with decoding process");
683 : continue;
684 : }
685 : }
686 0 : return(fDecoderSummaryData->GetErrorDetected());
687 : }
688 : //decode status ok
689 : errorWarning = 0;
690 : //set TRM global trailer
691 5472 : fTRMGlobalTrailer = (AliTOFTRMGlobalTrailer *)rawData;
692 : //remove global trailer from TRM CRC
693 5472 : trmCRC ^= *rawData;
694 : //fill TRM summary data
695 5472 : FillTRMSummaryData(fTRMGlobalTrailer);
696 5472 : fTRMSummaryData->SetDecoderCRC(COMPUTE_TRM_CRC(trmCRC));
697 : //print verbose
698 5472 : if (fVerbose)
699 0 : AliInfo(Form(" %02x - 0x%08x \t TRM global trailer \t CRC=%04d eventCounter=%04d",decoderStatus,*rawData,fTRMGlobalTrailer->GetEventCRC(),fTRMGlobalTrailer->GetEventCounter()));
700 : //change decode status
701 5472 : decoderStatus = decoderStatus & ~TRM_BIT;
702 5472 : fDecoderSummaryData->SetDecoderStatus(decoderStatus);
703 5472 : break;
704 :
705 : default:
706 : //try to recover error
707 0 : if (fDecoderSummaryData->GetRecoveringError())
708 : continue;
709 0 : if (fLogErrors)
710 0 : AliError(Form(" %02x - 0x%08x [ERROR] Not valid slotID/pattern in global trailer (curslot=%d, eqID=%d)",decoderStatus,*rawData,fDecoderSummaryData->GetCurrentSlotID(), fEquipmentID));
711 0 : fDecoderSummaryData->SetErrorDetected(kTRUE);
712 0 : fDecoderSummaryData->SetErrorSlotID(fDecoderSummaryData->GetCurrentSlotID());
713 0 : errorWarning++;
714 : //try to recover error
715 0 : if (fRecoverError){
716 0 : if (fVerbose)
717 0 : AliInfo("Trying to recover the error: searching for the next header");
718 0 : fDecoderSummaryData->SetRecoveringError(kTRUE);
719 0 : continue;
720 : }
721 0 : return(fDecoderSummaryData->GetErrorDetected());
722 : break;
723 : }
724 : break;
725 :
726 : case CHAIN_A_HEADER:
727 :
728 : //try to recover error
729 5472 : if (fDecoderSummaryData->GetRecoveringError())
730 : continue;
731 : //check decode status
732 5472 : if ( decoderStatus != CHAIN_A_HEADER_STATUS && !fDecoderSummaryData->GetRecoveringError() ){
733 0 : if (fLogErrors)
734 0 : AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain A header (curslot=%d, eqID=%d)",decoderStatus,*rawData,fDecoderSummaryData->GetCurrentSlotID(), fEquipmentID));
735 0 : fDecoderSummaryData->SetErrorDetected(kTRUE);
736 0 : fDecoderSummaryData->SetErrorSlotID(fDecoderSummaryData->GetCurrentSlotID());
737 0 : errorWarning++;
738 : //try to recover error
739 0 : if (fRecoverError){
740 0 : if (errorWarning > fRecoverErrorThr) {
741 0 : if (fVerbose)
742 0 : AliInfo("Trying to recover the error: searching for the next header");
743 0 : fDecoderSummaryData->SetRecoveringError(kTRUE);
744 0 : continue;
745 : }
746 : else {
747 0 : if (fVerbose)
748 0 : AliInfo("Do not try to recover error yet, go on with decoding process");
749 : continue;
750 : }
751 : }
752 0 : return(fDecoderSummaryData->GetErrorDetected());
753 : }
754 : //decode status ok
755 : errorWarning = 0;
756 : //set TRM chain header
757 5472 : fTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
758 : //fill decoder summary data
759 5472 : fDecoderSummaryData->SetCurrentChain(0);
760 : //get chain summary data
761 5472 : fChainSummaryData = fTRMSummaryData->GetChainSummaryData(0);
762 : //reset chain summary data
763 5472 : fChainSummaryData->Reset();
764 : //fill chain summary data
765 5472 : FillChainSummaryData(fTRMChainHeader);
766 : //get tdc hit buffer
767 5472 : fTDCHitBuffer = fChainSummaryData->GetTDCHitBuffer();
768 : //reset tdc hit buffer
769 5472 : fTDCHitBuffer->Reset();
770 : //get tdc packed hit buffer
771 5472 : fTDCPackedHitBuffer = fChainSummaryData->GetTDCPackedHitBuffer();
772 : //reset tdc packed hit buffer
773 5472 : fTDCPackedHitBuffer->Reset();
774 : //get tdc error buffer
775 5472 : fTDCErrorBuffer = fChainSummaryData->GetTDCErrorBuffer();
776 : //reset tdc error buffer
777 5472 : fTDCErrorBuffer->Reset();
778 : //print verbose
779 5472 : if (fVerbose)
780 0 : AliInfo(Form(" %02x - 0x%08x \t TRM chain A header \t chain=%01d bunchID=%04d",decoderStatus,*rawData,0,fTRMChainHeader->GetBunchID()));
781 : //change decode status
782 5472 : decoderStatus = decoderStatus | CHAIN_A_BIT;
783 5472 : fDecoderSummaryData->SetDecoderStatus(decoderStatus);
784 : //reset spider
785 5472 : if (fSpider)
786 5472 : ResetSpider();
787 : break;
788 :
789 : case CHAIN_A_TRAILER:
790 :
791 : //try to recover error
792 5472 : if (fDecoderSummaryData->GetRecoveringError())
793 : continue;
794 : //check decode status
795 5472 : if ( decoderStatus != CHAIN_A_TRAILER_STATUS && !fDecoderSummaryData->GetRecoveringError()){
796 0 : if (fLogErrors)
797 0 : AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain A trailer (curslot=%d, eqID=%d)",decoderStatus,*rawData,fDecoderSummaryData->GetCurrentSlotID(), fEquipmentID));
798 0 : fDecoderSummaryData->SetErrorDetected(kTRUE);
799 0 : fDecoderSummaryData->SetErrorSlotID(fDecoderSummaryData->GetCurrentSlotID());
800 0 : errorWarning++;
801 : //try to recover error
802 0 : if (fRecoverError){
803 0 : if (errorWarning > fRecoverErrorThr) {
804 0 : if (fVerbose)
805 0 : AliInfo("Trying to recover the error: searching for the next header");
806 0 : fDecoderSummaryData->SetRecoveringError(kTRUE);
807 0 : continue;
808 : }
809 : else {
810 0 : if (fVerbose)
811 0 : AliInfo("Do not try to recover error yet, go on with decoding process");
812 : continue;
813 : }
814 : }
815 0 : return(fDecoderSummaryData->GetErrorDetected());
816 : }
817 : //decode status ok
818 : errorWarning = 0;
819 : //set TRM chain trailer
820 5472 : fTRMChainTrailer = (AliTOFTRMChainTrailer *)rawData;
821 : //fill chain summary data
822 5472 : FillChainSummaryData(fTRMChainTrailer);
823 : //print verbose
824 5472 : if (fVerbose)
825 0 : AliInfo(Form(" %02x - 0x%08x \t TRM chain A trailer",decoderStatus,*rawData));
826 : //change decode status
827 5472 : decoderStatus = decoderStatus & ~CHAIN_A_BIT;
828 5472 : fDecoderSummaryData->SetDecoderStatus(decoderStatus);
829 5472 : break;
830 :
831 : case CHAIN_B_HEADER:
832 :
833 : //try to recover error
834 5472 : if (fDecoderSummaryData->GetRecoveringError())
835 : continue;
836 : //check decode status
837 5472 : if ( decoderStatus != CHAIN_B_HEADER_STATUS && !fDecoderSummaryData->GetRecoveringError()){
838 0 : if (fLogErrors)
839 0 : AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain B header (curslot=%d, eqID=%d)",decoderStatus,*rawData,fDecoderSummaryData->GetCurrentSlotID(), fEquipmentID));
840 0 : fDecoderSummaryData->SetErrorDetected(kTRUE);
841 0 : fDecoderSummaryData->SetErrorSlotID(fDecoderSummaryData->GetCurrentSlotID());
842 0 : errorWarning++;
843 : //try to recover error
844 0 : if (fRecoverError){
845 0 : if (errorWarning > fRecoverErrorThr) {
846 0 : if (fVerbose)
847 0 : AliInfo("Trying to recover the error: searching for the next header");
848 0 : fDecoderSummaryData->SetRecoveringError(kTRUE);
849 0 : continue;
850 : }
851 : else {
852 0 : if (fVerbose)
853 0 : AliInfo("Do not try to recover error yet, go on with decoding process");
854 : continue;
855 : }
856 : }
857 0 : return(fDecoderSummaryData->GetErrorDetected());
858 : }
859 : //decode status ok
860 : errorWarning = 0;
861 : //set TRM chain header
862 5472 : fTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
863 : //fill decoder summary data
864 5472 : fDecoderSummaryData->SetCurrentChain(1);
865 : //get chain summary data
866 5472 : fChainSummaryData = fTRMSummaryData->GetChainSummaryData(1);
867 : //reset chain summary data
868 5472 : fChainSummaryData->Reset();
869 : //fill chain summary data
870 5472 : FillChainSummaryData(fTRMChainHeader);
871 : //get tdc hit buffer
872 5472 : fTDCHitBuffer = fChainSummaryData->GetTDCHitBuffer();
873 : //reset tdc hit buffer
874 5472 : fTDCHitBuffer->Reset();
875 : //get tdc packed hit buffer
876 5472 : fTDCPackedHitBuffer = fChainSummaryData->GetTDCPackedHitBuffer();
877 : //reset tdc packed hit buffer
878 5472 : fTDCPackedHitBuffer->Reset();
879 : //get tdc error buffer
880 5472 : fTDCErrorBuffer = fChainSummaryData->GetTDCErrorBuffer();
881 : //reset tdc error buffer
882 5472 : fTDCErrorBuffer->Reset();
883 : //print verbose
884 5472 : if (fVerbose)
885 0 : AliInfo(Form(" %02x - 0x%08x \t TRM chain B header \t chain=%01d bunchID=%04d",decoderStatus,*rawData,1,fTRMChainHeader->GetBunchID()));
886 : //change decode status
887 5472 : decoderStatus = decoderStatus | CHAIN_B_BIT;
888 5472 : fDecoderSummaryData->SetDecoderStatus(decoderStatus);
889 : //reset spider
890 5472 : if (fSpider)
891 5472 : ResetSpider();
892 : break;
893 :
894 : case CHAIN_B_TRAILER:
895 :
896 : //try to recover error
897 5472 : if (fDecoderSummaryData->GetRecoveringError())
898 : continue;
899 : //check decode status
900 5472 : if ( decoderStatus != CHAIN_B_TRAILER_STATUS && !fDecoderSummaryData->GetRecoveringError()){
901 0 : if (fLogErrors)
902 0 : AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain B trailer (curslot=%d, eqID=%d)",decoderStatus,*rawData,fDecoderSummaryData->GetCurrentSlotID(), fEquipmentID));
903 0 : fDecoderSummaryData->SetErrorDetected(kTRUE);
904 0 : fDecoderSummaryData->SetErrorSlotID(fDecoderSummaryData->GetCurrentSlotID());
905 0 : errorWarning++;
906 : //try to recover error
907 0 : if (fRecoverError){
908 0 : if (errorWarning > fRecoverErrorThr) {
909 0 : if (fVerbose)
910 0 : AliInfo("Trying to recover the error: searching for the next header");
911 0 : fDecoderSummaryData->SetRecoveringError(kTRUE);
912 0 : continue;
913 : }
914 : else {
915 0 : if (fVerbose)
916 0 : AliInfo("Do not try to recover error yet, go on with decoding process");
917 : continue;
918 : }
919 : }
920 0 : return(fDecoderSummaryData->GetErrorDetected());
921 : }
922 : //decode status ok
923 : errorWarning = 0;
924 : //set TRM chain trailer
925 5472 : fTRMChainTrailer = (AliTOFTRMChainTrailer *)rawData;
926 : //fill chain summary data
927 5472 : FillChainSummaryData(fTRMChainTrailer);
928 : //print verbose
929 5472 : if (fVerbose)
930 0 : AliInfo(Form(" %02x - 0x%08x \t TRM chain B trailer",decoderStatus,*rawData));
931 : //change decode status
932 5472 : decoderStatus = decoderStatus & ~CHAIN_B_BIT;
933 5472 : fDecoderSummaryData->SetDecoderStatus(decoderStatus);
934 5472 : break;
935 :
936 : case ERROR:
937 :
938 : //try to recover error
939 0 : if (fDecoderSummaryData->GetRecoveringError())
940 : continue;
941 : //check decode status
942 0 : if ( decoderStatus != TRM_ERROR_STATUS && !fDecoderSummaryData->GetRecoveringError()){
943 0 : if (fLogErrors)
944 0 : AliError(Form(" %02x - 0x%08x [ERROR] Unexpected ERROR word (curslot=%d, eqID=%d)",decoderStatus,*rawData,fDecoderSummaryData->GetCurrentSlotID(), fEquipmentID));
945 0 : fDecoderSummaryData->SetErrorDetected(kTRUE);
946 0 : fDecoderSummaryData->SetErrorSlotID(fDecoderSummaryData->GetCurrentSlotID());
947 0 : errorWarning++;
948 : //try to recover error
949 0 : if (fRecoverError){
950 0 : if (errorWarning > fRecoverErrorThr) {
951 0 : if (fVerbose)
952 0 : AliInfo("Trying to recover the error: searching for the next header");
953 0 : fDecoderSummaryData->SetRecoveringError(kTRUE);
954 0 : continue;
955 : }
956 : else {
957 0 : if (fVerbose)
958 0 : AliInfo("Do not try to recover error yet, go on with decoding process");
959 : continue;
960 : }
961 : }
962 0 : return(fDecoderSummaryData->GetErrorDetected());
963 : }
964 : //decode status ok
965 : errorWarning = 0;
966 :
967 : //decode TRM TDC error
968 0 : fTRMTDCError = (AliTOFTRMTDCError *)rawData;
969 : //check diagnostic word
970 0 : if (fTRMTDCError->GetTDCID() == 15) {
971 0 : if (fVerbose)
972 0 : AliInfo(Form(" %02x - 0x%08x \t Diagnostic error word",decoderStatus,*rawData));
973 : break;
974 : }
975 :
976 : //try to recover error
977 0 : if (fDecoderSummaryData->GetRecoveringError())
978 : continue;
979 : //check decode status
980 0 : if ( decoderStatus != CHAIN_A_TDCERROR_STATUS && decoderStatus != CHAIN_B_TDCERROR_STATUS && !fDecoderSummaryData->GetRecoveringError()){
981 0 : if (fLogErrors)
982 0 : AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TDC error (curslot=%d, eqID=%d)",decoderStatus,*rawData,fDecoderSummaryData->GetCurrentSlotID(), fEquipmentID));
983 0 : fDecoderSummaryData->SetErrorDetected(kTRUE);
984 0 : fDecoderSummaryData->SetErrorSlotID(fDecoderSummaryData->GetCurrentSlotID());
985 : errorWarning++;
986 : //try to recover error
987 0 : if (fRecoverError){
988 0 : if (errorWarning > fRecoverErrorThr) {
989 0 : if (fVerbose)
990 0 : AliInfo("Trying to recover the error: searching for the next header");
991 0 : fDecoderSummaryData->SetRecoveringError(kTRUE);
992 0 : continue;
993 : }
994 : else {
995 0 : if (fVerbose)
996 0 : AliInfo("Do not try to recover error yet, go on with decoding process");
997 : continue;
998 : }
999 : }
1000 0 : return(fDecoderSummaryData->GetErrorDetected());
1001 : }
1002 : //decode status ok
1003 : errorWarning = 0;
1004 :
1005 : //set error data
1006 0 : error.SetErrorFlags(fTRMTDCError->GetErrorFlags());
1007 0 : error.SetTDCID(fTRMTDCError->GetTDCID());
1008 : //fill TDC error buffer
1009 0 : if (fTDCErrorBuffer) fTDCErrorBuffer->Add(error);
1010 : else {
1011 0 : AliError("fTDCErrorBuffer is 0: no chain header was detected");
1012 : }
1013 0 : if (fVerbose)
1014 0 : AliInfo(Form(" %02x - 0x%08x \t TDC error",decoderStatus,*rawData));
1015 : break;
1016 :
1017 : case FILLER:
1018 :
1019 : //try to recover error
1020 0 : if (fDecoderSummaryData->GetRecoveringError())
1021 : continue;
1022 0 : if (fVerbose)
1023 0 : AliInfo(Form(" %02x - 0x%08x \t Filler",decoderStatus,*rawData));
1024 : break;
1025 :
1026 : default:
1027 :
1028 : //try to recover error
1029 400 : if (fDecoderSummaryData->GetRecoveringError())
1030 : continue;
1031 : //check decode status
1032 400 : if ( decoderStatus != CHAIN_A_TDC_HIT_STATUS &&
1033 220 : decoderStatus != CHAIN_B_TDC_HIT_STATUS && !fDecoderSummaryData->GetRecoveringError()){
1034 0 : if (fLogErrors)
1035 0 : AliError(Form(" %02x - 0x%08x [ERROR] Unexpected or unknown word (curslot=%d, eqID=%d)",decoderStatus,*rawData,fDecoderSummaryData->GetCurrentSlotID(), fEquipmentID));
1036 0 : fDecoderSummaryData->SetErrorDetected(kTRUE);
1037 0 : fDecoderSummaryData->SetErrorSlotID(fDecoderSummaryData->GetCurrentSlotID());
1038 0 : errorWarning++;
1039 : //try to recover error
1040 0 : if (fRecoverError){
1041 0 : if (errorWarning > fRecoverErrorThr) {
1042 0 : if (fVerbose)
1043 0 : AliInfo("Trying to recover the error: searching for the next header");
1044 0 : fDecoderSummaryData->SetRecoveringError(kTRUE);
1045 0 : continue;
1046 : }
1047 : else {
1048 0 : if (fVerbose)
1049 0 : AliInfo("Do not try to recover error yet, go on with decoding process");
1050 : continue;
1051 : }
1052 : }
1053 0 : return(fDecoderSummaryData->GetErrorDetected());
1054 : }
1055 : //decode status ok
1056 : errorWarning = 0;
1057 :
1058 : //switch TRM ACQ
1059 400 : switch (fTRMSummaryData->GetACQBits()){
1060 :
1061 : case PACKING_ENABLED_ACQ:
1062 : //decode TDC packed/unpacked hit
1063 0 : fTDCPackedHit = (AliTOFTDCPackedHit *)rawData;
1064 0 : fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
1065 : //set hit data
1066 0 : hit.SetChan(fTDCUnpackedHit->GetChan());
1067 0 : hit.SetTDCID(fTDCUnpackedHit->GetTDCID());
1068 0 : hit.SetEBit(fTDCUnpackedHit->GetEBit());
1069 0 : hit.SetPSBits(fTDCUnpackedHit->GetPSBits());
1070 : //switch PS bits
1071 0 : switch (hit.GetPSBits()){
1072 : //packed hit or overflow hit
1073 : case PACKED_HIT_PS: case TOT_OVF_HIT_PS:
1074 0 : hit.SetHitTime(fTDCPackedHit->GetHitTime());
1075 0 : hit.SetTOTWidth(fTDCPackedHit->GetTOTWidth());
1076 : //add hit
1077 0 : fTDCHitBuffer->Add(hit);
1078 0 : fTDCPackedHitBuffer->Add(hit);
1079 : break;
1080 : //orphane leading
1081 : case LEADING_HIT_PS:
1082 0 : hit.SetHitTime(fTDCUnpackedHit->GetHitTime());
1083 0 : hit.SetTOTWidth(0);
1084 : //add hit
1085 0 : fTDCHitBuffer->Add(hit);
1086 0 : fTDCPackedHitBuffer->Add(hit);
1087 : break;
1088 : //orphane trailing
1089 : case TRAILING_HIT_PS:
1090 0 : hit.SetHitTime(fTDCUnpackedHit->GetHitTime());
1091 0 : hit.SetTOTWidth(0);
1092 : //add hit
1093 0 : fTDCHitBuffer->Add(hit);
1094 : break;
1095 : }
1096 : //end switch PS bits
1097 : //print verbose
1098 0 : if (fVerbose)
1099 0 : switch (hit.GetPSBits()){
1100 : case PACKED_HIT_PS:
1101 0 : AliInfo(Form(" %02x - 0x%08x \t TDC hit [packed] \t PS=%1d TDC=%1d chan=%1d TOT=%3d time=%4d (%7.1f ns)",decoderStatus,*rawData,hit.GetPSBits(),hit.GetTDCID(),hit.GetChan(),hit.GetTOTWidth(),hit.GetHitTime(),hit.GetHitTime()*TIME_BIN_WIDTH));
1102 : break;
1103 : case LEADING_HIT_PS:
1104 0 : AliInfo(Form(" %02x - 0x%08x \t TDC hit [orp.lead] \t PS=%1d TDC=%1d chan=%1d time=%4d (%7.1f ns)",decoderStatus,*rawData,hit.GetPSBits(),hit.GetTDCID(),hit.GetChan(),hit.GetHitTime(),hit.GetHitTime()*TIME_BIN_WIDTH));
1105 : break;
1106 : case TRAILING_HIT_PS:
1107 0 : AliInfo(Form(" %02x - 0x%08x \t TDC hit [orp.trai] \t PS=%1d TDC=%1d chan=%1d time=%4d (%7.1f ns)",decoderStatus,*rawData,hit.GetPSBits(),hit.GetTDCID(),hit.GetChan(),hit.GetHitTime(),hit.GetHitTime()*TIME_BIN_WIDTH));
1108 : break;
1109 : case TOT_OVF_HIT_PS:
1110 0 : AliInfo(Form(" %02x - 0x%08x \t TDC hit [TOT ovfl] \t PS=%1d TDC=%1d chan=%1d TOT=%3d time=%4d (%7.1f ns)",decoderStatus,*rawData,hit.GetPSBits(),hit.GetTDCID(),hit.GetChan(),hit.GetTOTWidth(),hit.GetHitTime(),hit.GetHitTime()*TIME_BIN_WIDTH));
1111 : break;
1112 : }
1113 : break;
1114 :
1115 : case LEADING_ONLY_ACQ: case TRAILING_ONLY_ACQ:
1116 : //decode TDC unpacked hit
1117 0 : fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
1118 : //set hit data
1119 0 : hit.SetChan(fTDCUnpackedHit->GetChan());
1120 0 : hit.SetTDCID(fTDCUnpackedHit->GetTDCID());
1121 0 : hit.SetEBit(fTDCUnpackedHit->GetEBit());
1122 0 : hit.SetPSBits(fTDCUnpackedHit->GetPSBits());
1123 0 : hit.SetHitTime(fTDCUnpackedHit->GetHitTime());
1124 0 : hit.SetTOTWidth(0);
1125 : //add hit
1126 0 : fTDCHitBuffer->Add(hit);
1127 : //print verbose
1128 0 : if (fVerbose)
1129 0 : switch (hit.GetPSBits()){
1130 : case LEADING_HIT_PS:
1131 0 : AliInfo(Form(" %02x - 0x%08x \t TDC hit [leading] \t PS=%1d TDC=%1d chan=%1d time=%4d (%7.1f ns)",decoderStatus,*rawData,hit.GetPSBits(),hit.GetTDCID(),hit.GetChan(),hit.GetHitTime(),hit.GetHitTime()*TIME_BIN_WIDTH));
1132 : break;
1133 : case TRAILING_HIT_PS:
1134 0 : AliInfo(Form(" %02x - 0x%08x \t TDC hit [trailing] \t PS=%1d TDC=%1d chan=%1d time=%4d (%7.1f ns)",decoderStatus,*rawData,hit.GetPSBits(),hit.GetTDCID(),hit.GetChan(),hit.GetHitTime(),hit.GetHitTime()*TIME_BIN_WIDTH));
1135 : }
1136 : break;
1137 :
1138 : case PACKING_DISABLED_ACQ:
1139 : //decode TDC unpacked hit
1140 400 : fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
1141 : //set hit data
1142 400 : hit.SetChan(fTDCUnpackedHit->GetChan());
1143 400 : hit.SetTDCID(fTDCUnpackedHit->GetTDCID());
1144 400 : hit.SetEBit(fTDCUnpackedHit->GetEBit());
1145 400 : hit.SetPSBits(fTDCUnpackedHit->GetPSBits());
1146 400 : hit.SetHitTime(fTDCUnpackedHit->GetHitTime());
1147 400 : hit.SetTOTWidth(0);
1148 : //add hit
1149 400 : fTDCHitBuffer->Add(hit);
1150 : //print verbose
1151 400 : if (fVerbose)
1152 0 : switch (hit.GetPSBits()){
1153 : case LEADING_HIT_PS:
1154 0 : AliInfo(Form(" %02x - 0x%08x \t TDC hit [leading] \t PS=%1d TDC=%1d chan=%1d time=%4d (%7.1f ns)",decoderStatus,*rawData,hit.GetPSBits(),hit.GetTDCID(),hit.GetChan(),hit.GetHitTime(),hit.GetHitTime()*TIME_BIN_WIDTH));
1155 : break;
1156 : case TRAILING_HIT_PS:
1157 0 : AliInfo(Form(" %02x - 0x%08x \t TDC hit [trailing] \t PS=%1d TDC=%1d chan=%1d time=%4d (%7.1f ns)",decoderStatus,*rawData,hit.GetPSBits(),hit.GetTDCID(),hit.GetChan(),hit.GetHitTime(),hit.GetHitTime()*TIME_BIN_WIDTH));
1158 : } //print verbose
1159 : //spider
1160 400 : if (fSpider)
1161 400 : Spider(hit);
1162 :
1163 : break;
1164 : }
1165 : //end switch TRM ACQ
1166 :
1167 : break;
1168 :
1169 : }
1170 :
1171 : }
1172 : //end equipment data loop
1173 :
1174 576 : if (fVerbose)
1175 0 : AliInfo("End of data loop");
1176 :
1177 : //reset spider
1178 576 : if (fSpider)
1179 576 : ResetSpider();
1180 :
1181 : /*** V2718 patch ***/
1182 576 : if (fV2718Patch){
1183 0 : decoderStatus = decoderStatus & ~DRM_BIT;
1184 0 : fDecoderSummaryData->SetDecoderStatus(decoderStatus);
1185 0 : fDRMSummaryData->SetTrailer(kTRUE);
1186 0 : fDRMSummaryData->SetSlotEnableMask(fDRMSummaryData->GetDecoderSlotEnableMask());
1187 0 : fDRMSummaryData->SetCBit(1);
1188 0 : fDRMSummaryData->SetLocalEventCounter(fTRMSummaryData->GetEventCounter());
1189 0 : if (fVerbose)
1190 0 : AliInfo("DRM was not present: - V2718 end patch decoding -");
1191 : }
1192 : /*** V2718 patch ***/
1193 :
1194 576 : if (fVerbose)
1195 0 : AliInfo("Decoder is exiting succesfully.");
1196 :
1197 576 : return(fDecoderSummaryData->GetErrorDetected());
1198 576 : }
1199 :
1200 : //_________________________________________________________________
1201 :
1202 : void
1203 : AliTOFDecoderV2::FillDRMSummaryData(const AliTOFDRMGlobalHeader *DRMGlobalHeader)
1204 : {
1205 : /*
1206 : *
1207 : * FillDRMSummaryData
1208 : *
1209 : */
1210 :
1211 1152 : fDRMSummaryData->SetHeader(kTRUE);
1212 576 : fDRMSummaryData->SetSlotID(DRMGlobalHeader->GetSlotID());
1213 576 : fDRMSummaryData->SetEventWords(DRMGlobalHeader->GetEventWords());
1214 576 : fDRMSummaryData->SetDRMID(DRMGlobalHeader->GetDRMID());
1215 576 : }
1216 :
1217 : //_________________________________________________________________
1218 :
1219 : void
1220 : AliTOFDecoderV2::FillDRMSummaryData(const AliTOFDRMGlobalTrailer *DRMGlobalTrailer)
1221 : {
1222 : /*
1223 : *
1224 : * FillDRMSummaryData
1225 : *
1226 : */
1227 :
1228 1152 : fDRMSummaryData->SetTrailer(kTRUE);
1229 576 : fDRMSummaryData->SetLocalEventCounter(DRMGlobalTrailer->GetLocalEventCounter());
1230 576 : }
1231 :
1232 : //_________________________________________________________________
1233 :
1234 : void
1235 : AliTOFDecoderV2::FillDRMSummaryData(const AliTOFDRMStatusHeader1 *DRMStatusHeader1)
1236 : {
1237 : /*
1238 : *
1239 : * FillDRMSummaryData
1240 : *
1241 : */
1242 :
1243 1152 : fDRMSummaryData->SetPartecipatingSlotID(DRMStatusHeader1->GetPartecipatingSlotID());
1244 576 : fDRMSummaryData->SetCBit(DRMStatusHeader1->GetCBit());
1245 576 : fDRMSummaryData->SetVersID(DRMStatusHeader1->GetVersID());
1246 576 : fDRMSummaryData->SetDRMhSize(DRMStatusHeader1->GetDRMhSize());
1247 576 : }
1248 :
1249 : //_________________________________________________________________
1250 :
1251 : void
1252 : AliTOFDecoderV2::FillDRMSummaryData(const AliTOFDRMStatusHeader2 *DRMStatusHeader2)
1253 : {
1254 : /*
1255 : *
1256 : * FillDRMSummaryData
1257 : *
1258 : */
1259 :
1260 1152 : fDRMSummaryData->SetSlotEnableMask(DRMStatusHeader2->GetSlotEnableMask());
1261 576 : fDRMSummaryData->SetFaultID(DRMStatusHeader2->GetFaultID());
1262 576 : fDRMSummaryData->SetRTOBit(DRMStatusHeader2->GetRTOBit());
1263 576 : }
1264 :
1265 : //_________________________________________________________________
1266 :
1267 : void
1268 : AliTOFDecoderV2::FillDRMSummaryData(const AliTOFDRMStatusHeader3 *DRMStatusHeader3)
1269 : {
1270 : /*
1271 : *
1272 : * FillDRMSummaryData
1273 : *
1274 : */
1275 :
1276 1152 : fDRMSummaryData->SetL0BCID(DRMStatusHeader3->GetL0BCID());
1277 576 : fDRMSummaryData->SetRunTimeInfo(DRMStatusHeader3->GetRunTimeInfo());
1278 576 : }
1279 :
1280 : //_________________________________________________________________
1281 :
1282 : void
1283 : AliTOFDecoderV2::FillDRMSummaryData(const AliTOFDRMStatusHeader4 *DRMStatusHeader4)
1284 : {
1285 : /*
1286 : *
1287 : * FillDRMSummaryData
1288 : *
1289 : */
1290 :
1291 1152 : fDRMSummaryData->SetTemperature(DRMStatusHeader4->GetTemperature());
1292 576 : fDRMSummaryData->SetACKBit(DRMStatusHeader4->GetACKBit());
1293 576 : fDRMSummaryData->SetSensAD(DRMStatusHeader4->GetSensAD());
1294 576 : }
1295 :
1296 : //_________________________________________________________________
1297 :
1298 : void
1299 : AliTOFDecoderV2::FillDRMSummaryData(const AliTOFDRMEventCRC *DRMEventCRC)
1300 : {
1301 : /*
1302 : *
1303 : * FillDRMSummaryData
1304 : *
1305 : */
1306 :
1307 1152 : fDRMSummaryData->SetEventCRC(DRMEventCRC->GetEventCRC());
1308 576 : }
1309 :
1310 : //_________________________________________________________________
1311 :
1312 : void
1313 : AliTOFDecoderV2::FillLTMSummaryData(const AliTOFLTMGlobalHeader *LTMGlobalHeader)
1314 : {
1315 : /*
1316 : *
1317 : * FillLTMSummaryData
1318 : *
1319 : */
1320 :
1321 1152 : fLTMSummaryData->SetHeader(kTRUE);
1322 576 : fLTMSummaryData->SetSlotID(LTMGlobalHeader->GetSlotID());
1323 576 : fLTMSummaryData->SetEventWords(LTMGlobalHeader->GetEventWords());
1324 576 : fLTMSummaryData->SetCBit(LTMGlobalHeader->GetCBit());
1325 576 : fLTMSummaryData->SetFault(LTMGlobalHeader->GetFault());
1326 576 : }
1327 :
1328 : //_________________________________________________________________
1329 :
1330 : void
1331 : AliTOFDecoderV2::FillLTMSummaryData(const AliTOFLTMGlobalTrailer *LTMGlobalTrailer)
1332 : {
1333 : /*
1334 : *
1335 : * FillLTMSummaryData
1336 : *
1337 : */
1338 :
1339 1152 : fLTMSummaryData->SetTrailer(kTRUE);
1340 576 : fLTMSummaryData->SetEventCRC(LTMGlobalTrailer->GetEventCRC());
1341 576 : fLTMSummaryData->SetEventNumber(LTMGlobalTrailer->GetEventNumber());
1342 576 : }
1343 :
1344 : //_________________________________________________________________
1345 :
1346 : void
1347 : AliTOFDecoderV2::FillLTMSummaryData(const AliTOFLTMPDLData *LTMPDLData, Int_t PDLWord)
1348 : {
1349 : /*
1350 : *
1351 : * FillLTMSummaryData
1352 : *
1353 : */
1354 :
1355 13824 : fLTMSummaryData->SetPDL(4 * PDLWord + 0, LTMPDLData->GetPDLValue1());
1356 6912 : fLTMSummaryData->SetPDL(4 * PDLWord + 1, LTMPDLData->GetPDLValue2());
1357 6912 : fLTMSummaryData->SetPDL(4 * PDLWord + 2, LTMPDLData->GetPDLValue3());
1358 6912 : fLTMSummaryData->SetPDL(4 * PDLWord + 3, LTMPDLData->GetPDLValue4());
1359 6912 : }
1360 :
1361 : //_________________________________________________________________
1362 :
1363 : void
1364 : AliTOFDecoderV2::FillLTMSummaryData(const AliTOFLTMADCData *LTMADCData, Int_t ADCWord)
1365 : {
1366 : /*
1367 : *
1368 : * FillLTMSummaryData
1369 : *
1370 : */
1371 :
1372 23040 : fLTMSummaryData->SetADC(3 * ADCWord + 0, LTMADCData->GetADCValue1());
1373 11520 : fLTMSummaryData->SetADC(3 * ADCWord + 1, LTMADCData->GetADCValue2());
1374 11520 : fLTMSummaryData->SetADC(3 * ADCWord + 2, LTMADCData->GetADCValue3());
1375 11520 : }
1376 :
1377 : //_________________________________________________________________
1378 :
1379 : void
1380 : AliTOFDecoderV2::FillLTMSummaryData(const AliTOFLTMORData *LTMORData, Int_t ORWord)
1381 : {
1382 : /*
1383 : *
1384 : * FillLTMSummaryData
1385 : *
1386 : */
1387 :
1388 18432 : fLTMSummaryData->SetOR(3 * ORWord + 0, LTMORData->GetORValue1());
1389 9216 : fLTMSummaryData->SetOR(3 * ORWord + 1, LTMORData->GetORValue2());
1390 9216 : fLTMSummaryData->SetOR(3 * ORWord + 2, LTMORData->GetORValue3());
1391 9216 : }
1392 :
1393 : //_________________________________________________________________
1394 :
1395 : void
1396 : AliTOFDecoderV2::FillTRMSummaryData(const AliTOFTRMGlobalHeader *TRMGlobalHeader)
1397 : {
1398 : /*
1399 : *
1400 : * FillTRMSummaryData
1401 : *
1402 : */
1403 :
1404 10944 : fTRMSummaryData->SetHeader(kTRUE);
1405 5472 : fTRMSummaryData->SetSlotID(TRMGlobalHeader->GetSlotID());
1406 5472 : fTRMSummaryData->SetEventWords(TRMGlobalHeader->GetEventWords());
1407 5472 : fTRMSummaryData->SetACQBits(TRMGlobalHeader->GetACQBits());
1408 5472 : fTRMSummaryData->SetLBit(TRMGlobalHeader->GetLBit());
1409 5472 : fTRMSummaryData->SetEBit(TRMGlobalHeader->GetEBit());
1410 5472 : }
1411 :
1412 : //_________________________________________________________________
1413 :
1414 : void
1415 : AliTOFDecoderV2::FillTRMSummaryData(const AliTOFTRMGlobalTrailer *TRMGlobalTrailer)
1416 : {
1417 : /*
1418 : *
1419 : * FillTRMSummaryData
1420 : *
1421 : */
1422 :
1423 10944 : fTRMSummaryData->SetTrailer(kTRUE);
1424 5472 : fTRMSummaryData->SetEventCRC(TRMGlobalTrailer->GetEventCRC());
1425 5472 : fTRMSummaryData->SetEventCounter(TRMGlobalTrailer->GetEventCounter());
1426 5472 : }
1427 :
1428 : //_________________________________________________________________
1429 :
1430 : void
1431 : AliTOFDecoderV2::FillChainSummaryData(const AliTOFTRMChainHeader *TRMChainHeader)
1432 : {
1433 : /*
1434 : *
1435 : * FillChainSummaryData
1436 : *
1437 : */
1438 :
1439 32832 : fChainSummaryData->SetHeader(kTRUE);
1440 21888 : switch (*(UInt_t *)TRMChainHeader & WORD_TYPE_MASK){
1441 : case CHAIN_A_HEADER:
1442 5472 : fChainSummaryData->SetChain(0);
1443 5472 : break;
1444 : case CHAIN_B_HEADER:
1445 5472 : fChainSummaryData->SetChain(1);
1446 5472 : break;
1447 : }
1448 10944 : fChainSummaryData->SetBunchID(TRMChainHeader->GetBunchID());
1449 10944 : fChainSummaryData->SetPB24Temp(TRMChainHeader->GetPB24Temp());
1450 10944 : fChainSummaryData->SetPB24ID(TRMChainHeader->GetPB24ID());
1451 10944 : fChainSummaryData->SetTSBit(TRMChainHeader->GetTSBit());
1452 10944 : }
1453 :
1454 : //_________________________________________________________________
1455 :
1456 : void
1457 : AliTOFDecoderV2::FillChainSummaryData(const AliTOFTRMChainTrailer *TRMChainTrailer)
1458 : {
1459 : /*
1460 : *
1461 : * FillChainSummaryData
1462 : *
1463 : */
1464 :
1465 21888 : fChainSummaryData->SetTrailer(kTRUE);
1466 10944 : fChainSummaryData->SetStatus(TRMChainTrailer->GetStatus());
1467 10944 : fChainSummaryData->SetEventCounter(TRMChainTrailer->GetEventCounter());
1468 10944 : }
1469 :
1470 : //_________________________________________________________________
1471 :
1472 : void
1473 : AliTOFDecoderV2::ResetSpider()
1474 : {
1475 : //reset condition
1476 23040 : if (fVerbose)
1477 0 : AliInfo("Reset signal received, empty and reset buffer");
1478 207360 : for (Int_t iChan = 0; iChan < N_CHANNEL; iChan++){
1479 92160 : if (fSpiderBufferFull[iChan]) {
1480 0 : if (fVerbose)
1481 0 : AliInfo(Form("Spider buffer is full for channel %d", iChan));
1482 0 : fSpiderTDCPackedHitBuffer->Add(fSpiderBuffer[iChan]);
1483 0 : }
1484 92160 : fSpiderBufferFull[iChan] = kFALSE;
1485 : }
1486 11520 : fSpiderTDCID = -1;
1487 11520 : return;
1488 : }
1489 :
1490 : void
1491 : AliTOFDecoderV2::Spider(AliTOFTDCHit &hit){
1492 :
1493 800 : if (fVerbose)
1494 0 : AliInfo("Hit has been received from decode main routine");
1495 :
1496 : //check new TDC
1497 400 : if (fSpiderTDCID != hit.GetTDCID()){
1498 138 : if (fVerbose)
1499 0 : AliInfo("Data coming from a new TDC, empty and reset buffer");
1500 2484 : for (Int_t iChan = 0; iChan < N_CHANNEL; iChan++){
1501 1104 : if (fSpiderBufferFull[iChan])
1502 0 : fSpiderTDCPackedHitBuffer->Add(fSpiderBuffer[iChan]);
1503 1104 : fSpiderBufferFull[iChan] = kFALSE;
1504 : }
1505 138 : fSpiderTDCPackedHitBuffer = fTDCPackedHitBuffer;
1506 138 : fSpiderTDCID = hit.GetTDCID();
1507 138 : }
1508 :
1509 : //switch PS bits
1510 800 : switch(hit.GetPSBits()){
1511 : //leading hit
1512 : case LEADING_HIT_PS:
1513 : //check buffer status
1514 200 : if (fSpiderBufferFull[hit.GetChan()]){ //buffer full
1515 0 : fSpiderTDCPackedHitBuffer->Add(fSpiderBuffer[hit.GetChan()]); //buffered hit is orphane
1516 0 : fSpiderBuffer[hit.GetChan()] = hit; //current hit into buffer
1517 0 : if (fVerbose)
1518 0 : AliInfo("Leading hit and buffer full, buffered hit is a orphane leading hit");
1519 : }
1520 : else{ //buffer empty
1521 200 : fSpiderBuffer[hit.GetChan()] = hit; //current hit into buffer
1522 200 : fSpiderBufferFull[hit.GetChan()] = kTRUE; //set buffer full
1523 : }
1524 : break;
1525 : //trailing hit
1526 : case TRAILING_HIT_PS:
1527 : //check buffer status
1528 200 : if (fSpiderBufferFull[hit.GetChan()]){ //buffer full
1529 200 : fSpiderTDCPackedHitBuffer->Add(fSpiderBuffer[hit.GetChan()] << hit); //pack hits (Leading << Trailing) and save
1530 200 : fSpiderBufferFull[hit.GetChan()] = kFALSE; //unset buffer full
1531 200 : if (fVerbose)
1532 0 : AliInfo("Trailing hit and buffer full, pack leading and trailing hit");
1533 : }
1534 : else{ //buffer empty
1535 : ; //do nothing
1536 0 : if (fVerbose)
1537 0 : AliInfo("Trailing hit and buffer empty, trow trailing hit away");
1538 : }
1539 : break;
1540 : } //switch PS bits
1541 :
1542 400 : }
1543 :
1544 : //_________________________________________________________________
1545 :
1546 : Bool_t
1547 : AliTOFDecoderV2::DecodeNext()
1548 : {
1549 : /* decode next */
1550 :
1551 0 : if (!fRawReader || !fRawReader->ReadHeader())
1552 0 : return kFALSE;
1553 :
1554 0 : const Int_t size = fRawReader->GetDataSize();
1555 0 : UChar_t *data = new UChar_t[size];
1556 0 : if (fRawReader->ReadNext(data, size) != 1) {
1557 0 : delete [] data;
1558 0 : return kFALSE;
1559 : }
1560 :
1561 : /* decode equipment data */
1562 0 : SetEquipmentID(fRawReader->GetEquipmentId());
1563 0 : Decode((UInt_t *)data, size / 4);
1564 :
1565 0 : delete [] data;
1566 0 : return kTRUE;
1567 0 : }
|