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