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 author: Roberto Preghenella (R+), preghenella@bo.infn.it
22 /*********************************************************************
25 * Class for raw data decoding *
28 ********************************************************************/
33 #include "AliTOFHitData.h"
34 #include "AliTOFDecoder.h"
36 ClassImp(AliTOFDecoder)
38 //_________________________________________________________________
40 AliTOFDecoder::AliTOFDecoder() :
45 fPackedDataBuffer(0x0),
46 fTRMGlobalHeader(0x0),
47 fTRMGlobalTrailer(0x0),
49 fTRMChainTrailer(0x0),
53 fTRMDiagnosticErrorWord1(0x0),
54 fTRMDiagnosticErrorWord2(0x0),
55 fSpiderCurrentSlotID(-1),
56 fSpiderCurrentChain(-1),
62 //_________________________________________________________________
64 AliTOFDecoder::AliTOFDecoder(AliTOFHitDataBuffer *DataBuffer, AliTOFHitDataBuffer *PackedDataBuffer) :
68 fDataBuffer(DataBuffer),
69 fPackedDataBuffer(PackedDataBuffer),
70 fTRMGlobalHeader(0x0),
71 fTRMGlobalTrailer(0x0),
73 fTRMChainTrailer(0x0),
77 fTRMDiagnosticErrorWord1(0x0),
78 fTRMDiagnosticErrorWord2(0x0),
79 fSpiderCurrentSlotID(-1),
80 fSpiderCurrentChain(-1),
86 //_________________________________________________________________
88 AliTOFDecoder::AliTOFDecoder(const AliTOFDecoder &source) :
93 fPackedDataBuffer(0x0),
94 fTRMGlobalHeader(0x0),
95 fTRMGlobalTrailer(0x0),
97 fTRMChainTrailer(0x0),
101 fTRMDiagnosticErrorWord1(0x0),
102 fTRMDiagnosticErrorWord2(0x0),
103 fSpiderCurrentSlotID(-1),
104 fSpiderCurrentChain(-1),
105 fSpiderCurrentTDC(-1)
109 this->fVerbose = source.fVerbose;
110 this->fV2718Patch = source.fV2718Patch;
111 this->fDataBuffer = source.fDataBuffer;
112 this->fPackedDataBuffer = source.fPackedDataBuffer;
113 this->fTRMGlobalHeader = source.fTRMGlobalHeader;
114 this->fTRMGlobalTrailer = source.fTRMGlobalTrailer;
115 this->fTRMChainHeader = source.fTRMChainHeader;
116 this->fTRMChainTrailer = source.fTRMChainTrailer;
117 this->fTDCPackedHit = source.fTDCPackedHit;
118 this->fTDCUnpackedHit = source.fTDCUnpackedHit;
119 this->fTRMTDCError = source.fTRMTDCError;
120 this->fTRMDiagnosticErrorWord1 = source.fTRMDiagnosticErrorWord1;
121 this->fTRMDiagnosticErrorWord2 = source.fTRMDiagnosticErrorWord2;
122 this->fSpiderCurrentSlotID = source.fSpiderCurrentSlotID;
123 this->fSpiderCurrentChain = source.fSpiderCurrentChain;
124 this->fSpiderCurrentTDC = source.fSpiderCurrentTDC;
127 //_________________________________________________________________
130 AliTOFDecoder::operator = (const AliTOFDecoder &source)
134 this->fVerbose = source.fVerbose;
135 this->fV2718Patch = source.fV2718Patch;
136 this->fDataBuffer = source.fDataBuffer;
137 this->fPackedDataBuffer = source.fPackedDataBuffer;
138 this->fTRMGlobalHeader = source.fTRMGlobalHeader;
139 this->fTRMGlobalTrailer = source.fTRMGlobalTrailer;
140 this->fTRMChainHeader = source.fTRMChainHeader;
141 this->fTRMChainTrailer = source.fTRMChainTrailer;
142 this->fTDCPackedHit = source.fTDCPackedHit;
143 this->fTDCUnpackedHit = source.fTDCUnpackedHit;
144 this->fTRMTDCError = source.fTRMTDCError;
145 this->fTRMDiagnosticErrorWord1 = source.fTRMDiagnosticErrorWord1;
146 this->fTRMDiagnosticErrorWord2 = source.fTRMDiagnosticErrorWord2;
147 this->fSpiderCurrentSlotID = source.fSpiderCurrentSlotID;
148 this->fSpiderCurrentChain = source.fSpiderCurrentChain;
149 this->fSpiderCurrentTDC = source.fSpiderCurrentTDC;
153 AliTOFDecoder::~AliTOFDecoder()
156 //_________________________________________________________________
159 AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords)
161 /* main decoding routine.
162 * it loops over nWords 32-bit words
163 * starting at *rawData and decodes them.
164 * it also fills some buffers in order to
165 * have the decoded data available for other
169 AliTOFHitData hitData;
174 Float_t tempTOT; //ns
175 Int_t tempTOTBin; //TOT_BIN_WIDTH
178 UShort_t decodeStatus = 0x0;
179 Short_t currentDDL = -1;
180 Short_t currentSlotID = -1;
181 Short_t currentACQ = -1;
182 Short_t currentChain = -1;
183 Short_t currentBunchID = -1;
185 /*** V2718 patch ***/
187 decodeStatus = decodeStatus | DRM_BIT;
189 AliInfo("DRM not present: - V2718 patch decoding -");
191 /*** V2718 patch ***/
194 AliInfo("Initialize SPIDER function");
195 status = InitializeSpider();
198 AliInfo("Start decoding");
201 AliInfo("Loop over the data and decode");
204 AliInfo(" St Hex Word \t Decoded Word");
207 for (Int_t iWord = 0; iWord < nWords; iWord++, rawData++){
210 switch (*rawData & WORD_TYPE_MASK){
215 switch (*rawData & SLOT_ID_MASK){
217 //DRM global header (slotID=1)
219 //check decode status
220 if ( decodeStatus != DRM_HEADER_STATUS ){
221 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected DRM global header",decodeStatus,*rawData));
226 AliInfo(Form(" %02x - 0x%08x \t DRM global header",decodeStatus,*rawData));
227 //change decode status
228 decodeStatus = decodeStatus | DRM_BIT;
231 for (Int_t i = 0; i < DRM_DATA_WORDS; i++, iWord++, rawData++){
233 AliInfo(Form(" %02x - 0x%08x \t DRM data",decodeStatus,*rawData));
237 //LTM global header (slotID=2)
239 //check decode status
240 if ( decodeStatus != LTM_HEADER_STATUS ){
241 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected LTM global header",decodeStatus,*rawData));
246 AliInfo(Form(" %02x - 0x%08x \t LTM global header",decodeStatus,*rawData));
247 //change decode status
248 decodeStatus = decodeStatus | LTM_BIT;
251 for (Int_t i = 0; i < LTM_DATA_WORDS; i++, iWord++, rawData++){
253 AliInfo(Form(" %02x - 0x%08x \t LTM data",decodeStatus,*rawData));
257 //TRM global header (slotID=3-12)
258 case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12:
259 //check decode status
260 if ( decodeStatus != TRM_HEADER_STATUS ){
261 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM global header",decodeStatus,*rawData));
265 //set TRM global header
266 fTRMGlobalHeader = (AliTOFTRMGlobalHeader *)rawData;
268 currentSlotID = fTRMGlobalHeader->GetSlotID();
269 currentACQ = fTRMGlobalHeader->GetACQBits();
271 AliInfo(Form(" %02x - 0x%08x \t TRM global header \t slotID=%02d ACQ=%01d L=%01d",decodeStatus,*rawData,fTRMGlobalHeader->GetSlotID(),fTRMGlobalHeader->GetACQBits(),fTRMGlobalHeader->GetLBit()));
272 //change decode status
273 decodeStatus = decodeStatus | TRM_BIT;
278 AliError(Form(" %02x - 0x%08x [ERROR] Not valid slotID in global header",decodeStatus,*rawData));
289 switch (*rawData & SLOT_ID_MASK){
291 //DRM global trailer (slotID=1)
293 //check decode status
294 if ( decodeStatus != DRM_TRAILER_STATUS ){
295 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected DRM global trailer",decodeStatus,*rawData));
300 AliInfo(Form(" %02x - 0x%08x \t DRM global trailer",decodeStatus,*rawData));
301 //change decode status
302 decodeStatus = decodeStatus & ~DRM_BIT;
305 //LTM global trailer (slotID=2)
307 //check decode status
308 if ( decodeStatus != LTM_TRAILER_STATUS ){
309 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected LTM global trailer",decodeStatus,*rawData));
314 AliInfo(Form(" %02x - 0x%08x \t LTM global trailer",decodeStatus,*rawData));
315 //change decode status
316 decodeStatus = decodeStatus & ~LTM_BIT;
319 //TRM global trailer (slotID=15)
321 //check decode status
322 if ( decodeStatus != TRM_TRAILER_STATUS ){
323 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM global trailer",decodeStatus,*rawData));
327 //set TRM global trailer
328 fTRMGlobalTrailer = (AliTOFTRMGlobalTrailer *)rawData;
330 AliInfo(Form(" %02x - 0x%08x \t TRM global trailer \t CRC=%04d eventCounter=%04d",decodeStatus,*rawData,fTRMGlobalTrailer->GetEventCRC(),fTRMGlobalTrailer->GetEventCounter()));
331 //change decode status
332 decodeStatus = decodeStatus & ~TRM_BIT;
337 AliError(Form(" %02x - 0x%08x [ERROR] Not valid slotID/pattern in global trailer",decodeStatus,*rawData));
344 //check decode status
345 if ( (decodeStatus != CHAIN_A_HEADER_STATUS) ){
346 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain A header",decodeStatus,*rawData));
350 fTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
352 currentBunchID = fTRMChainHeader->GetBunchID();
354 AliInfo(Form(" %02x - 0x%08x \t TRM chain A header \t chain=%01d bunchID=%04d",decodeStatus,*rawData,currentChain,currentBunchID));
355 //change decode status
356 decodeStatus = decodeStatus | CHAIN_A_BIT;
359 case CHAIN_A_TRAILER:
360 //check decode status
361 if ( decodeStatus != CHAIN_A_TRAILER_STATUS ){
362 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain A trailer",decodeStatus,*rawData));
367 AliInfo(Form(" %02x - 0x%08x \t TRM chain A trailer",decodeStatus,*rawData));
368 //change decode status
369 decodeStatus = decodeStatus & ~CHAIN_A_BIT;
373 //check decode status
374 if ( decodeStatus != CHAIN_B_HEADER_STATUS ){
375 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain B header",decodeStatus,*rawData));
379 fTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
381 currentBunchID = fTRMChainHeader->GetBunchID();
383 AliInfo(Form(" %02x - 0x%08x \t TRM chain B header \t chain=%01d bunchID=%04d",decodeStatus,*rawData,currentChain,currentBunchID));
384 //change decode status
385 decodeStatus = decodeStatus | CHAIN_B_BIT;
388 case CHAIN_B_TRAILER:
389 //check decode status
390 if ( decodeStatus != CHAIN_B_TRAILER_STATUS ){
391 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain B trailer",decodeStatus,*rawData));
396 AliInfo(Form(" %02x - 0x%08x \t TRM chain B trailer",decodeStatus,*rawData));
397 //change decode status
398 decodeStatus = decodeStatus & ~CHAIN_B_BIT;
403 AliInfo(Form(" %02x - 0x%08x \t TDC error",decodeStatus,*rawData));
408 AliInfo(Form(" %02x - 0x%08x \t Filler",decodeStatus,*rawData));
412 //check decode status
413 if ( decodeStatus != CHAIN_A_TDC_HIT_STATUS &&
414 decodeStatus != CHAIN_B_TDC_HIT_STATUS ){
415 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected or unknown word",decodeStatus,*rawData));
423 case PACKING_ENABLED_ACQ:
424 //decode TDC packed hit
425 fTDCPackedHit = (AliTOFTDCPackedHit *)rawData;
426 fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
427 //set hit in the equipment data
428 hitData.SetDDLID(currentDDL);
429 hitData.SetSlotID(currentSlotID);
430 hitData.SetACQ(currentACQ);
431 hitData.SetChain(currentChain);
432 hitData.SetPS(fTDCPackedHit->GetPSBits());
433 hitData.SetTDC(fTDCPackedHit->GetTDCID());
434 hitData.SetChan(fTDCPackedHit->GetChan());
435 hitData.SetTime((float)fTDCPackedHit->GetHitTime() * TIME_BIN_WIDTH);
436 hitData.SetTimeBin(fTDCPackedHit->GetHitTime());
437 hitData.SetTOT((float)fTDCPackedHit->GetTOTWidth() * TOT_BIN_WIDTH);
438 hitData.SetTOTBin(fTDCPackedHit->GetTOTWidth());
439 //orphane leading hit
440 if (hitData.GetPS()==LEADING_HIT_PS){
441 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
442 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
445 hitData.SetTOTBin(0);
446 //push hit data in packed data buffer
447 if (fPackedDataBuffer != 0x0)
448 fPackedDataBuffer->Add(hitData);
449 //set TOT to not measured
451 hitData.SetTOTBin(-1);
452 //push hit data in packed data buffer
453 if (fDataBuffer != 0x0)
454 fDataBuffer->Add(hitData);
456 //orphane trailing hit
457 else if (hitData.GetPS()==TRAILING_HIT_PS){
458 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
459 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
460 //set TOT to not measured
462 hitData.SetTOTBin(-1);
463 //push hit data in data buffer
464 if (fDataBuffer != 0x0)
465 fDataBuffer->Add(hitData);
469 //push hit data in packed data buffer
470 if (fPackedDataBuffer != 0x0)
471 fPackedDataBuffer->Add(hitData);
473 tempPS = hitData.GetPS();
475 tempTOT = hitData.GetTOT();
476 tempTOTBin = hitData.GetTOTBin();
477 //unpack the hit: leading hit
478 hitData.SetPS(LEADING_HIT_PS);
479 //set TOT to not measured
481 hitData.SetTOTBin(-1);
482 //push leading hit data in data buffer
483 if (fDataBuffer != 0x0)
484 fDataBuffer->Add(hitData);
485 //unpack the hit: trailing hit
486 hitData.SetPS(TRAILING_HIT_PS);
487 hitData.SetTime(hitData.GetTime() + tempTOT);
488 hitData.SetTimeBin(hitData.GetTimeBin() + (Int_t)(tempTOTBin * TOT_TO_TIME_BIN_WIDTH));
489 //push trailing hit data in data buffer
490 if (fDataBuffer != 0x0)
491 fDataBuffer->Add(hitData);
493 hitData.SetPS(tempPS);
494 hitData.SetTime(hitData.GetTime() - tempTOT);
495 hitData.SetTimeBin(hitData.GetTimeBin() - (Int_t)(tempTOTBin * TOT_TO_TIME_BIN_WIDTH));
496 hitData.SetTOT(tempTOT);
497 hitData.SetTOTBin(tempTOTBin);
501 switch (hitData.GetPS()){
503 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()));
506 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()));
508 case TRAILING_HIT_PS:
509 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()));
512 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()));
517 case LEADING_ONLY_ACQ: case TRAILING_ONLY_ACQ:
518 //decode TDC unpacked hit
519 fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
520 //set hit in the equipment data
521 hitData.SetDDLID(currentDDL);
522 hitData.SetSlotID(currentSlotID);
523 hitData.SetACQ(currentACQ);
524 hitData.SetChain(currentChain);
525 hitData.SetPS(fTDCUnpackedHit->GetPSBits());
526 hitData.SetTDC(fTDCUnpackedHit->GetTDCID());
527 hitData.SetChan(fTDCUnpackedHit->GetChan());
528 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
529 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
531 hitData.SetTOTBin(-1);
532 //push hit data in data buffer
533 if (fDataBuffer != 0x0)
534 fDataBuffer->Add(hitData);
537 switch (hitData.GetPS()){
539 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()));
542 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()));
544 case TRAILING_HIT_PS:
545 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()));
548 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()));
553 case PACKING_DISABLED_ACQ:
554 //decode TDC unpacked hit
555 fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
556 //set hit in the equipment data
557 hitData.SetDDLID(currentDDL);
558 hitData.SetSlotID(currentSlotID);
559 hitData.SetACQ(currentACQ);
560 hitData.SetChain(currentChain);
561 hitData.SetPS(fTDCUnpackedHit->GetPSBits());
562 hitData.SetTDC(fTDCUnpackedHit->GetTDCID());
563 hitData.SetChan(fTDCUnpackedHit->GetChan());
564 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
565 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
567 hitData.SetTOTBin(-1);
568 //push hit data in data buffer
569 if (fDataBuffer != 0x0)
570 fDataBuffer->Add(hitData);
573 switch (hitData.GetPS()){
575 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()));
578 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()));
580 case TRAILING_HIT_PS:
581 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()));
584 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()));
587 //call spider function
589 AliInfo("Calling SPIDER function");
597 //end switch word type
600 //end equipment data loop
603 AliInfo("End of data loop");
606 AliInfo("Reset SPIDER function");
607 status = ResetSpider();
610 AliInfo("Decoder is exiting succesfully.");
615 //_________________________________________________________________
618 AliTOFDecoder::InitializeSpider(){
620 /* SPIDER initialization routine.
621 it initializes SPIDER variables in order
622 to have SPIDER ready to pack tof data
623 in packed data objects
627 AliInfo("Initializing SPIDER");
629 fSpiderCurrentSlotID=-1;
630 fSpiderCurrentChain=-1;
631 fSpiderCurrentTDC=-1;
633 for (Int_t chan=0;chan<N_CHANNEL;chan++)
634 fSpiderLeadingFlag[chan] = kFALSE;
639 //_________________________________________________________________
642 AliTOFDecoder::ResetSpider(){
644 /* SPIDER reset routine.
645 it resets SPIDER buffers and
646 variables in order to empty full
647 buffers a set up SIPDER for new
652 AliInfo("Resetting SPIDER buffers");
654 for (Int_t chan=0;chan<N_CHANNEL;chan++){
655 if (fSpiderLeadingFlag[chan]){
657 AliInfo("Buffer non empty: put leading hit into buffer as orphane");
659 fSpiderLeadingHit[chan].SetACQ(4);
660 fSpiderLeadingHit[chan].SetPS(1);
661 fSpiderLeadingHit[chan].SetTOT(0);
662 fSpiderLeadingHit[chan].SetTOTBin(0);
663 //push hit into packed buffer
664 if (fPackedDataBuffer != 0x0)
665 fPackedDataBuffer->Add(fSpiderLeadingHit[chan]);
667 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()));
670 fSpiderLeadingFlag[chan]=kFALSE;
676 //_________________________________________________________________
679 AliTOFDecoder::Spider(AliTOFHitData hitData){
681 /* main SPIDER routine.
682 it receives, reads, stores and packs
683 unpacked HPTDC data in packed data
684 object. it also fills buffers.
690 AliInfo("Hit data received");
692 //check if TDC is changed (slotID,chain,TDC triplet)
693 if (fSpiderCurrentSlotID!=hitData.GetSlotID() ||
694 fSpiderCurrentChain!=hitData.GetChain() ||
695 fSpiderCurrentTDC!=hitData.GetTDC() ){
697 AliInfo("Data coming from a new TDC: reset buffers");
699 status = ResetSpider();
701 fSpiderCurrentSlotID=hitData.GetSlotID();
702 fSpiderCurrentChain=hitData.GetChain();
703 fSpiderCurrentTDC=hitData.GetTDC();
707 switch (hitData.GetPS()){
711 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()));
712 //check spider leading flag
713 if (fSpiderLeadingFlag[hitData.GetChan()]){
715 AliInfo("Leading hit: buffer full, put previous in buffers as orphane and keep current");
716 //set TOT at zero for previous hit
717 fSpiderLeadingHit[hitData.GetChan()].SetACQ(4);
718 fSpiderLeadingHit[hitData.GetChan()].SetPS(1);
719 fSpiderLeadingHit[hitData.GetChan()].SetTOT(0);
720 fSpiderLeadingHit[hitData.GetChan()].SetTOTBin(0);
721 //push previous hit into packed buffer
722 if (fPackedDataBuffer != 0x0)
723 fPackedDataBuffer->Add(fSpiderLeadingHit[hitData.GetChan()]);
725 fSpiderLeadingHit[hitData.GetChan()]=hitData;
727 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()));
731 AliInfo("Leading hit: buffer empty, keep current hit and set flag");
732 fSpiderLeadingHit[hitData.GetChan()]=hitData;
733 //set spider leading flag
734 fSpiderLeadingFlag[hitData.GetChan()]=kTRUE;
738 case TRAILING_HIT_PS:
740 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()));
741 //check spider leading flag
742 if (fSpiderLeadingFlag[hitData.GetChan()]){
744 AliInfo("Trailing hit: buffer full, pack leading and trailing");
747 hitData.SetTOT(hitData.GetTime()-fSpiderLeadingHit[hitData.GetChan()].GetTime());
748 hitData.SetTOTBin((Int_t)((hitData.GetTimeBin()-fSpiderLeadingHit[hitData.GetChan()].GetTimeBin())*TIME_TO_TOT_BIN_WIDTH));
749 hitData.SetTime(fSpiderLeadingHit[hitData.GetChan()].GetTime());
750 hitData.SetTimeBin(fSpiderLeadingHit[hitData.GetChan()].GetTimeBin());
751 //check TOT and set TOT overflow if TOT < 0
752 if (hitData.GetTOT() < 0){
755 hitData.SetTOTBin(0);
757 if (fPackedDataBuffer != 0x0)
758 fPackedDataBuffer->Add(hitData);
760 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()));
761 //unset spider leading flag
762 fSpiderLeadingFlag[hitData.GetChan()]=kFALSE;
766 AliInfo("Trailing hit: buffer empty, throw hit away");