1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 ***************************************************************************/
18 Revision 1.3 2007/05/08 11:56:05 arcelli
19 improved verbosity in verbose mode (R.Preghenella)
21 Revision 1.2 2007/05/03 11:34:43 decaro
22 Coding convention: RS1 violation -> suppression
24 Revision 1.1 2007/04/27 11:00:32 arcelli
27 author: Roberto Preghenella (R+), preghenella@bo.infn.it
31 //////////////////////////////////////////////////////////////////////
34 // Class for raw data decoding //
37 //////////////////////////////////////////////////////////////////////
42 #include "AliTOFHitData.h"
43 #include "AliTOFDecoder.h"
45 ClassImp(AliTOFDecoder)
47 //_________________________________________________________________
49 AliTOFDecoder::AliTOFDecoder() :
54 fPackedDataBuffer(0x0),
55 fTRMGlobalHeader(0x0),
56 fTRMGlobalTrailer(0x0),
58 fTRMChainTrailer(0x0),
62 fTRMDiagnosticErrorWord1(0x0),
63 fTRMDiagnosticErrorWord2(0x0),
64 fSpiderCurrentSlotID(-1),
65 fSpiderCurrentChain(-1),
71 //_________________________________________________________________
73 AliTOFDecoder::AliTOFDecoder(AliTOFHitDataBuffer *DataBuffer, AliTOFHitDataBuffer *PackedDataBuffer) :
77 fDataBuffer(DataBuffer),
78 fPackedDataBuffer(PackedDataBuffer),
79 fTRMGlobalHeader(0x0),
80 fTRMGlobalTrailer(0x0),
82 fTRMChainTrailer(0x0),
86 fTRMDiagnosticErrorWord1(0x0),
87 fTRMDiagnosticErrorWord2(0x0),
88 fSpiderCurrentSlotID(-1),
89 fSpiderCurrentChain(-1),
95 //_________________________________________________________________
97 AliTOFDecoder::AliTOFDecoder(const AliTOFDecoder &source) :
102 fPackedDataBuffer(0x0),
103 fTRMGlobalHeader(0x0),
104 fTRMGlobalTrailer(0x0),
105 fTRMChainHeader(0x0),
106 fTRMChainTrailer(0x0),
108 fTDCUnpackedHit(0x0),
110 fTRMDiagnosticErrorWord1(0x0),
111 fTRMDiagnosticErrorWord2(0x0),
112 fSpiderCurrentSlotID(-1),
113 fSpiderCurrentChain(-1),
114 fSpiderCurrentTDC(-1)
118 this->fVerbose = source.fVerbose;
119 this->fV2718Patch = source.fV2718Patch;
120 this->fDataBuffer = source.fDataBuffer;
121 this->fPackedDataBuffer = source.fPackedDataBuffer;
122 this->fTRMGlobalHeader = source.fTRMGlobalHeader;
123 this->fTRMGlobalTrailer = source.fTRMGlobalTrailer;
124 this->fTRMChainHeader = source.fTRMChainHeader;
125 this->fTRMChainTrailer = source.fTRMChainTrailer;
126 this->fTDCPackedHit = source.fTDCPackedHit;
127 this->fTDCUnpackedHit = source.fTDCUnpackedHit;
128 this->fTRMTDCError = source.fTRMTDCError;
129 this->fTRMDiagnosticErrorWord1 = source.fTRMDiagnosticErrorWord1;
130 this->fTRMDiagnosticErrorWord2 = source.fTRMDiagnosticErrorWord2;
131 this->fSpiderCurrentSlotID = source.fSpiderCurrentSlotID;
132 this->fSpiderCurrentChain = source.fSpiderCurrentChain;
133 this->fSpiderCurrentTDC = source.fSpiderCurrentTDC;
136 //_________________________________________________________________
139 AliTOFDecoder::operator = (const AliTOFDecoder &source)
143 this->fVerbose = source.fVerbose;
144 this->fV2718Patch = source.fV2718Patch;
145 this->fDataBuffer = source.fDataBuffer;
146 this->fPackedDataBuffer = source.fPackedDataBuffer;
147 this->fTRMGlobalHeader = source.fTRMGlobalHeader;
148 this->fTRMGlobalTrailer = source.fTRMGlobalTrailer;
149 this->fTRMChainHeader = source.fTRMChainHeader;
150 this->fTRMChainTrailer = source.fTRMChainTrailer;
151 this->fTDCPackedHit = source.fTDCPackedHit;
152 this->fTDCUnpackedHit = source.fTDCUnpackedHit;
153 this->fTRMTDCError = source.fTRMTDCError;
154 this->fTRMDiagnosticErrorWord1 = source.fTRMDiagnosticErrorWord1;
155 this->fTRMDiagnosticErrorWord2 = source.fTRMDiagnosticErrorWord2;
156 this->fSpiderCurrentSlotID = source.fSpiderCurrentSlotID;
157 this->fSpiderCurrentChain = source.fSpiderCurrentChain;
158 this->fSpiderCurrentTDC = source.fSpiderCurrentTDC;
162 AliTOFDecoder::~AliTOFDecoder()
165 //_________________________________________________________________
168 AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords)
170 /* main decoding routine.
171 * it loops over nWords 32-bit words
172 * starting at *rawData and decodes them.
173 * it also fills some buffers in order to
174 * have the decoded data available for other
178 AliTOFHitData hitData;
183 Float_t tempTOT; //ns
184 Int_t tempTOTBin; //TOT_BIN_WIDTH
187 UShort_t decodeStatus = 0x0;
188 Short_t currentDDL = -1;
189 Short_t currentSlotID = -1;
190 Short_t currentACQ = -1;
191 Short_t currentChain = -1;
192 Short_t currentBunchID = -1;
194 /*** V2718 patch ***/
196 decodeStatus = decodeStatus | DRM_BIT;
198 AliInfo("DRM not present: - V2718 patch decoding -");
200 /*** V2718 patch ***/
203 AliInfo("Initialize SPIDER function");
204 status = InitializeSpider();
207 AliInfo("Start decoding");
210 AliInfo("Loop over the data and decode");
213 AliInfo(" St Hex Word \t Decoded Word");
216 for (Int_t iWord = 0; iWord < nWords; iWord++, rawData++){
219 switch (*rawData & WORD_TYPE_MASK){
224 switch (*rawData & SLOT_ID_MASK){
226 //DRM global header (slotID=1)
228 //check decode status
229 if ( decodeStatus != DRM_HEADER_STATUS ){
230 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected DRM global header",decodeStatus,*rawData));
235 AliInfo(Form(" %02x - 0x%08x \t DRM global header",decodeStatus,*rawData));
236 //change decode status
237 decodeStatus = decodeStatus | DRM_BIT;
240 for (Int_t i = 0; i < DRM_DATA_WORDS; i++, iWord++, rawData++){
242 AliInfo(Form(" %02x - 0x%08x \t DRM data",decodeStatus,*rawData));
246 //LTM global header (slotID=2)
248 //check decode status
249 if ( decodeStatus != LTM_HEADER_STATUS ){
250 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected LTM global header",decodeStatus,*rawData));
255 AliInfo(Form(" %02x - 0x%08x \t LTM global header",decodeStatus,*rawData));
256 //change decode status
257 decodeStatus = decodeStatus | LTM_BIT;
260 for (Int_t i = 0; i < LTM_DATA_WORDS; i++, iWord++, rawData++){
262 AliInfo(Form(" %02x - 0x%08x \t LTM data",decodeStatus,*rawData));
266 //TRM global header (slotID=3-12)
267 case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12:
268 //check decode status
269 if ( decodeStatus != TRM_HEADER_STATUS ){
270 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM global header",decodeStatus,*rawData));
274 //set TRM global header
275 fTRMGlobalHeader = (AliTOFTRMGlobalHeader *)rawData;
277 currentSlotID = fTRMGlobalHeader->GetSlotID();
278 currentACQ = fTRMGlobalHeader->GetACQBits();
280 AliInfo(Form(" %02x - 0x%08x \t TRM global header \t slotID=%02d ACQ=%01d L=%01d",decodeStatus,*rawData,fTRMGlobalHeader->GetSlotID(),fTRMGlobalHeader->GetACQBits(),fTRMGlobalHeader->GetLBit()));
281 //change decode status
282 decodeStatus = decodeStatus | TRM_BIT;
286 AliError(Form(" %02x - 0x%08x [ERROR] Not valid slotID in global header",decodeStatus,*rawData));
297 switch (*rawData & SLOT_ID_MASK){
299 //DRM global trailer (slotID=1)
301 //check decode status
302 if ( decodeStatus != DRM_TRAILER_STATUS ){
303 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected DRM global trailer",decodeStatus,*rawData));
308 AliInfo(Form(" %02x - 0x%08x \t DRM global trailer",decodeStatus,*rawData));
309 //change decode status
310 decodeStatus = decodeStatus & ~DRM_BIT;
313 //LTM global trailer (slotID=2)
315 //check decode status
316 if ( decodeStatus != LTM_TRAILER_STATUS ){
317 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected LTM global trailer",decodeStatus,*rawData));
322 AliInfo(Form(" %02x - 0x%08x \t LTM global trailer",decodeStatus,*rawData));
323 //change decode status
324 decodeStatus = decodeStatus & ~LTM_BIT;
327 //TRM global trailer (slotID=15)
329 //check decode status
330 if ( decodeStatus != TRM_TRAILER_STATUS ){
331 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM global trailer",decodeStatus,*rawData));
335 //set TRM global trailer
336 fTRMGlobalTrailer = (AliTOFTRMGlobalTrailer *)rawData;
338 AliInfo(Form(" %02x - 0x%08x \t TRM global trailer \t CRC=%04d eventCounter=%04d",decodeStatus,*rawData,fTRMGlobalTrailer->GetEventCRC(),fTRMGlobalTrailer->GetEventCounter()));
339 //change decode status
340 decodeStatus = decodeStatus & ~TRM_BIT;
344 AliError(Form(" %02x - 0x%08x [ERROR] Not valid slotID/pattern in global trailer",decodeStatus,*rawData));
351 //check decode status
352 if ( (decodeStatus != CHAIN_A_HEADER_STATUS) ){
353 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain A header",decodeStatus,*rawData));
357 fTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
359 currentBunchID = fTRMChainHeader->GetBunchID();
361 AliInfo(Form(" %02x - 0x%08x \t TRM chain A header \t chain=%01d bunchID=%04d",decodeStatus,*rawData,currentChain,currentBunchID));
362 //change decode status
363 decodeStatus = decodeStatus | CHAIN_A_BIT;
366 case CHAIN_A_TRAILER:
367 //check decode status
368 if ( decodeStatus != CHAIN_A_TRAILER_STATUS ){
369 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain A trailer",decodeStatus,*rawData));
374 AliInfo(Form(" %02x - 0x%08x \t TRM chain A trailer",decodeStatus,*rawData));
375 //change decode status
376 decodeStatus = decodeStatus & ~CHAIN_A_BIT;
380 //check decode status
381 if ( decodeStatus != CHAIN_B_HEADER_STATUS ){
382 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain B header",decodeStatus,*rawData));
386 fTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
388 currentBunchID = fTRMChainHeader->GetBunchID();
390 AliInfo(Form(" %02x - 0x%08x \t TRM chain B header \t chain=%01d bunchID=%04d",decodeStatus,*rawData,currentChain,currentBunchID));
391 //change decode status
392 decodeStatus = decodeStatus | CHAIN_B_BIT;
395 case CHAIN_B_TRAILER:
396 //check decode status
397 if ( decodeStatus != CHAIN_B_TRAILER_STATUS ){
398 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain B trailer",decodeStatus,*rawData));
403 AliInfo(Form(" %02x - 0x%08x \t TRM chain B trailer",decodeStatus,*rawData));
404 //change decode status
405 decodeStatus = decodeStatus & ~CHAIN_B_BIT;
410 AliInfo(Form(" %02x - 0x%08x \t TDC error",decodeStatus,*rawData));
415 AliInfo(Form(" %02x - 0x%08x \t Filler",decodeStatus,*rawData));
419 //check decode status
420 if ( decodeStatus != CHAIN_A_TDC_HIT_STATUS &&
421 decodeStatus != CHAIN_B_TDC_HIT_STATUS ){
422 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected or unknown word",decodeStatus,*rawData));
430 case PACKING_ENABLED_ACQ:
431 //decode TDC packed hit
432 fTDCPackedHit = (AliTOFTDCPackedHit *)rawData;
433 fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
434 //set hit in the equipment data
435 hitData.SetDDLID(currentDDL);
436 hitData.SetSlotID(currentSlotID);
437 hitData.SetACQ(currentACQ);
438 hitData.SetChain(currentChain);
439 hitData.SetPS(fTDCPackedHit->GetPSBits());
440 hitData.SetTDC(fTDCPackedHit->GetTDCID());
441 hitData.SetChan(fTDCPackedHit->GetChan());
442 hitData.SetTime((float)fTDCPackedHit->GetHitTime() * TIME_BIN_WIDTH);
443 hitData.SetTimeBin(fTDCPackedHit->GetHitTime());
444 hitData.SetTOT((float)fTDCPackedHit->GetTOTWidth() * TOT_BIN_WIDTH);
445 hitData.SetTOTBin(fTDCPackedHit->GetTOTWidth());
446 //orphane leading hit
447 if (hitData.GetPS()==LEADING_HIT_PS){
448 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
449 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
452 hitData.SetTOTBin(0);
453 //push hit data in packed data buffer
454 if (fPackedDataBuffer != 0x0)
455 fPackedDataBuffer->Add(hitData);
456 //set TOT to not measured
458 hitData.SetTOTBin(-1);
459 //push hit data in packed data buffer
460 if (fDataBuffer != 0x0)
461 fDataBuffer->Add(hitData);
463 //orphane trailing hit
464 else if (hitData.GetPS()==TRAILING_HIT_PS){
465 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
466 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
467 //set TOT to not measured
469 hitData.SetTOTBin(-1);
470 //push hit data in data buffer
471 if (fDataBuffer != 0x0)
472 fDataBuffer->Add(hitData);
476 //push hit data in packed data buffer
477 if (fPackedDataBuffer != 0x0)
478 fPackedDataBuffer->Add(hitData);
480 tempPS = hitData.GetPS();
482 tempTOT = hitData.GetTOT();
483 tempTOTBin = hitData.GetTOTBin();
484 //unpack the hit: leading hit
485 hitData.SetPS(LEADING_HIT_PS);
486 //set TOT to not measured
488 hitData.SetTOTBin(-1);
489 //push leading hit data in data buffer
490 if (fDataBuffer != 0x0)
491 fDataBuffer->Add(hitData);
492 //unpack the hit: trailing hit
493 hitData.SetPS(TRAILING_HIT_PS);
494 hitData.SetTime(hitData.GetTime() + tempTOT);
495 hitData.SetTimeBin(hitData.GetTimeBin() + (Int_t)(tempTOTBin * TOT_TO_TIME_BIN_WIDTH));
496 //push trailing hit data in data buffer
497 if (fDataBuffer != 0x0)
498 fDataBuffer->Add(hitData);
500 hitData.SetPS(tempPS);
501 hitData.SetTime(hitData.GetTime() - tempTOT);
502 hitData.SetTimeBin(hitData.GetTimeBin() - (Int_t)(tempTOTBin * TOT_TO_TIME_BIN_WIDTH));
503 hitData.SetTOT(tempTOT);
504 hitData.SetTOTBin(tempTOTBin);
508 switch (hitData.GetPS()){
510 AliInfo(Form(" %02x - 0x%08x \t TDC hit [packed] \t PS=%01d TDC=%01d chan=%01d TOT=%3.1fns (%d) time=%4.1fns (%d)",decodeStatus,*rawData,hitData.GetPS(),hitData.GetTDC(),hitData.GetChan(),hitData.GetTOT(),hitData.GetTOTBin(),hitData.GetTime(),hitData.GetTimeBin()));
513 AliInfo(Form(" %02x - 0x%08x \t TDC hit [orp.lead] \t PS=%01d TDC=%01d chan=%01d time=%4.1fns (%d)",decodeStatus,*rawData,hitData.GetPS(),hitData.GetTDC(),hitData.GetChan(),hitData.GetTime(),hitData.GetTimeBin()));
515 case TRAILING_HIT_PS:
516 AliInfo(Form(" %02x - 0x%08x \t TDC hit [orp.trai] \t PS=%01d TDC=%01d chan=%01d time=%4.1fns (%d)",decodeStatus,*rawData,hitData.GetPS(),hitData.GetTDC(),hitData.GetChan(),hitData.GetTime(),hitData.GetTimeBin()));
519 AliInfo(Form(" %02x - 0x%08x \t TDC hit [TOT ovfl] \t PS=%01d TDC=%01d chan=%01d TOT=%3.1fns (%d) time=%4.1fns (%d)",decodeStatus,*rawData,hitData.GetPS(),hitData.GetTDC(),hitData.GetChan(),hitData.GetTOT(),hitData.GetTOTBin(),hitData.GetTime(),hitData.GetTimeBin()));
524 case LEADING_ONLY_ACQ: case TRAILING_ONLY_ACQ:
525 //decode TDC unpacked hit
526 fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
527 //set hit in the equipment data
528 hitData.SetDDLID(currentDDL);
529 hitData.SetSlotID(currentSlotID);
530 hitData.SetACQ(currentACQ);
531 hitData.SetChain(currentChain);
532 hitData.SetPS(fTDCUnpackedHit->GetPSBits());
533 hitData.SetTDC(fTDCUnpackedHit->GetTDCID());
534 hitData.SetChan(fTDCUnpackedHit->GetChan());
535 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
536 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
538 hitData.SetTOTBin(-1);
539 //push hit data in data buffer
540 if (fDataBuffer != 0x0)
541 fDataBuffer->Add(hitData);
544 switch (hitData.GetPS()){
546 AliInfo(Form(" %02x - 0x%08x \t TDC hit [packed] \t PS=%01d TDC=%01d chan=%01d TOT=%3.1fns (%d) time=%4.1fns (%d)",decodeStatus,*rawData,hitData.GetPS(),hitData.GetTDC(),hitData.GetChan(),hitData.GetTOT(),hitData.GetTOTBin(),hitData.GetTime(),hitData.GetTimeBin()));
549 AliInfo(Form(" %02x - 0x%08x \t TDC hit [leading] \t PS=%01d TDC=%01d chan=%01d time=%4.1fns (%d)",decodeStatus,*rawData,hitData.GetPS(),hitData.GetTDC(),hitData.GetChan(),hitData.GetTime(),hitData.GetTimeBin()));
551 case TRAILING_HIT_PS:
552 AliInfo(Form(" %02x - 0x%08x \t TDC hit [trailing] \t PS=%01d TDC=%01d chan=%01d time=%4.1fns (%d)",decodeStatus,*rawData,hitData.GetPS(),hitData.GetTDC(),hitData.GetChan(),hitData.GetTime(),hitData.GetTimeBin()));
555 AliInfo(Form(" %02x - 0x%08x \t TDC hit [TOT ovfl] \t PS=%01d TDC=%01d chan=%01d TOT=%3.1fns (%d) time=%4.1fns (%d)",decodeStatus,*rawData,hitData.GetPS(),hitData.GetTDC(),hitData.GetChan(),hitData.GetTOT(),hitData.GetTOTBin(),hitData.GetTime(),hitData.GetTimeBin()));
560 case PACKING_DISABLED_ACQ:
561 //decode TDC unpacked hit
562 fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
563 //set hit in the equipment data
564 hitData.SetDDLID(currentDDL);
565 hitData.SetSlotID(currentSlotID);
566 hitData.SetACQ(currentACQ);
567 hitData.SetChain(currentChain);
568 hitData.SetPS(fTDCUnpackedHit->GetPSBits());
569 hitData.SetTDC(fTDCUnpackedHit->GetTDCID());
570 hitData.SetChan(fTDCUnpackedHit->GetChan());
571 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
572 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
574 hitData.SetTOTBin(-1);
575 //push hit data in data buffer
576 if (fDataBuffer != 0x0)
577 fDataBuffer->Add(hitData);
580 switch (hitData.GetPS()){
582 AliInfo(Form(" %02x - 0x%08x \t TDC hit [packed] \t PS=%01d TDC=%01d chan=%01d TOT=%3.1fns (%d) time=%4.1fns (%d)",decodeStatus,*rawData,hitData.GetPS(),hitData.GetTDC(),hitData.GetChan(),hitData.GetTOT(),hitData.GetTOTBin(),hitData.GetTime(),hitData.GetTimeBin()));
585 AliInfo(Form(" %02x - 0x%08x \t TDC hit [leading] \t PS=%01d TDC=%01d chan=%01d time=%4.1fns (%d)",decodeStatus,*rawData,hitData.GetPS(),hitData.GetTDC(),hitData.GetChan(),hitData.GetTime(),hitData.GetTimeBin()));
587 case TRAILING_HIT_PS:
588 AliInfo(Form(" %02x - 0x%08x \t TDC hit [trailing] \t PS=%01d TDC=%01d chan=%01d time=%4.1fns (%d)",decodeStatus,*rawData,hitData.GetPS(),hitData.GetTDC(),hitData.GetChan(),hitData.GetTime(),hitData.GetTimeBin()));
591 AliInfo(Form(" %02x - 0x%08x \t TDC hit [TOT ovfl] \t PS=%01d TDC=%01d chan=%01d TOT=%3.1fns (%d) time=%4.1fns (%d)",decodeStatus,*rawData,hitData.GetPS(),hitData.GetTDC(),hitData.GetChan(),hitData.GetTOT(),hitData.GetTOTBin(),hitData.GetTime(),hitData.GetTimeBin()));
594 //call spider function
596 AliInfo("Calling SPIDER function");
604 //end switch word type
607 //end equipment data loop
610 AliInfo("End of data loop");
613 AliInfo("Reset SPIDER function");
614 status = ResetSpider();
617 AliInfo("Decoder is exiting succesfully.");
622 //_________________________________________________________________
625 AliTOFDecoder::InitializeSpider(){
627 /* SPIDER initialization routine.
628 it initializes SPIDER variables in order
629 to have SPIDER ready to pack tof data
630 in packed data objects
634 AliInfo("Initializing SPIDER");
636 fSpiderCurrentSlotID=-1;
637 fSpiderCurrentChain=-1;
638 fSpiderCurrentTDC=-1;
640 for (Int_t chan=0;chan<N_CHANNEL;chan++)
641 fSpiderLeadingFlag[chan] = kFALSE;
646 //_________________________________________________________________
649 AliTOFDecoder::ResetSpider(){
651 /* SPIDER reset routine.
652 it resets SPIDER buffers and
653 variables in order to empty full
654 buffers a set up SIPDER for new
659 AliInfo("Resetting SPIDER buffers");
661 for (Int_t chan=0;chan<N_CHANNEL;chan++){
662 if (fSpiderLeadingFlag[chan]){
664 AliInfo("Buffer non empty: put leading hit into buffer as orphane");
666 fSpiderLeadingHit[chan].SetACQ(4);
667 fSpiderLeadingHit[chan].SetPS(1);
668 fSpiderLeadingHit[chan].SetTOT(0);
669 fSpiderLeadingHit[chan].SetTOTBin(0);
670 //push hit into packed buffer
671 if (fPackedDataBuffer != 0x0)
672 fPackedDataBuffer->Add(fSpiderLeadingHit[chan]);
674 AliInfo(Form("Packed hit: slotID=%d chain=%d PS=%01d TDC=%01d chan=%01d TOT=%3.1fns (%d) time=%4.1fns (%d)",fSpiderLeadingHit[chan].GetSlotID(),fSpiderLeadingHit[chan].GetChain(),fSpiderLeadingHit[chan].GetPS(),fSpiderLeadingHit[chan].GetTDC(),fSpiderLeadingHit[chan].GetChan(),fSpiderLeadingHit[chan].GetTOT(),fSpiderLeadingHit[chan].GetTOTBin(),fSpiderLeadingHit[chan].GetTime(),fSpiderLeadingHit[chan].GetTimeBin()));
677 fSpiderLeadingFlag[chan]=kFALSE;
683 //_________________________________________________________________
686 AliTOFDecoder::Spider(AliTOFHitData hitData){
688 /* main SPIDER routine.
689 it receives, reads, stores and packs
690 unpacked HPTDC data in packed data
691 object. it also fills buffers.
697 AliInfo("Hit data received");
699 //check if TDC is changed (slotID,chain,TDC triplet)
700 if (fSpiderCurrentSlotID!=hitData.GetSlotID() ||
701 fSpiderCurrentChain!=hitData.GetChain() ||
702 fSpiderCurrentTDC!=hitData.GetTDC() ){
704 AliInfo("Data coming from a new TDC: reset buffers");
706 status = ResetSpider();
708 fSpiderCurrentSlotID=hitData.GetSlotID();
709 fSpiderCurrentChain=hitData.GetChain();
710 fSpiderCurrentTDC=hitData.GetTDC();
714 switch (hitData.GetPS()){
718 AliInfo(Form("Leading hit: slotID=%d chain=%d PS=%01d TDC=%01d chan=%01d TOT=%3.1fns (%d) time=%4.1fns (%d)",hitData.GetSlotID(),hitData.GetChain(),hitData.GetPS(),hitData.GetTDC(),hitData.GetChan(),hitData.GetTOT(),hitData.GetTOTBin(),hitData.GetTime(),hitData.GetTimeBin()));
719 //check spider leading flag
720 if (fSpiderLeadingFlag[hitData.GetChan()]){
722 AliInfo("Leading hit: buffer full, put previous in buffers as orphane and keep current");
723 //set TOT at zero for previous hit
724 fSpiderLeadingHit[hitData.GetChan()].SetACQ(4);
725 fSpiderLeadingHit[hitData.GetChan()].SetPS(1);
726 fSpiderLeadingHit[hitData.GetChan()].SetTOT(0);
727 fSpiderLeadingHit[hitData.GetChan()].SetTOTBin(0);
728 //push previous hit into packed buffer
729 if (fPackedDataBuffer != 0x0)
730 fPackedDataBuffer->Add(fSpiderLeadingHit[hitData.GetChan()]);
732 fSpiderLeadingHit[hitData.GetChan()]=hitData;
734 AliInfo(Form("Packed hit: slotID=%d chain=%d PS=%01d TDC=%01d chan=%01d TOT=%3.1fns (%d) time=%4.1fns (%d)",fSpiderLeadingHit[hitData.GetChan()].GetSlotID(),fSpiderLeadingHit[hitData.GetChan()].GetChain(),fSpiderLeadingHit[hitData.GetChan()].GetPS(),fSpiderLeadingHit[hitData.GetChan()].GetTDC(),fSpiderLeadingHit[hitData.GetChan()].GetChan(),fSpiderLeadingHit[hitData.GetChan()].GetTOT(),fSpiderLeadingHit[hitData.GetChan()].GetTOTBin(),fSpiderLeadingHit[hitData.GetChan()].GetTime(),fSpiderLeadingHit[hitData.GetChan()].GetTimeBin()));
738 AliInfo("Leading hit: buffer empty, keep current hit and set flag");
739 fSpiderLeadingHit[hitData.GetChan()]=hitData;
740 //set spider leading flag
741 fSpiderLeadingFlag[hitData.GetChan()]=kTRUE;
745 case TRAILING_HIT_PS:
747 AliInfo(Form("Trailing hit: slotID=%d chain=%d PS=%01d TDC=%01d chan=%01d TOT=%3.1fns (%d) time=%4.1fns (%d)",hitData.GetSlotID(),hitData.GetChain(),hitData.GetPS(),hitData.GetTDC(),hitData.GetChan(),hitData.GetTOT(),hitData.GetTOTBin(),hitData.GetTime(),hitData.GetTimeBin()));
748 //check spider leading flag
749 if (fSpiderLeadingFlag[hitData.GetChan()]){
751 AliInfo("Trailing hit: buffer full, pack leading and trailing");
754 hitData.SetTOT(hitData.GetTime()-fSpiderLeadingHit[hitData.GetChan()].GetTime());
755 hitData.SetTOTBin((Int_t)((hitData.GetTimeBin()-fSpiderLeadingHit[hitData.GetChan()].GetTimeBin())*TIME_TO_TOT_BIN_WIDTH));
756 hitData.SetTime(fSpiderLeadingHit[hitData.GetChan()].GetTime());
757 hitData.SetTimeBin(fSpiderLeadingHit[hitData.GetChan()].GetTimeBin());
758 //check TOT and set TOT overflow if TOT < 0
759 if (hitData.GetTOT() < 0){
762 hitData.SetTOTBin(0);
764 if (fPackedDataBuffer != 0x0)
765 fPackedDataBuffer->Add(hitData);
767 AliInfo(Form("Packed hit: slotID=%d chain=%d PS=%01d TDC=%01d chan=%01d TOT=%3.1fns (%d) time=%4.1fns (%d)",hitData.GetSlotID(),hitData.GetChain(),hitData.GetPS(),hitData.GetTDC(),hitData.GetChan(),hitData.GetTOT(),hitData.GetTOTBin(),hitData.GetTime(),hitData.GetTimeBin()));
768 //unset spider leading flag
769 fSpiderLeadingFlag[hitData.GetChan()]=kFALSE;
773 AliInfo("Trailing hit: buffer empty, throw hit away");