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.1 2007/04/27 11:00:32 arcelli
21 author: Roberto Preghenella (R+), preghenella@bo.infn.it
25 //////////////////////////////////////////////////////////////////////
28 // Class for raw data decoding //
31 //////////////////////////////////////////////////////////////////////
36 #include "AliTOFHitData.h"
37 #include "AliTOFDecoder.h"
39 ClassImp(AliTOFDecoder)
41 //_________________________________________________________________
43 AliTOFDecoder::AliTOFDecoder() :
48 fPackedDataBuffer(0x0),
49 fTRMGlobalHeader(0x0),
50 fTRMGlobalTrailer(0x0),
52 fTRMChainTrailer(0x0),
56 fTRMDiagnosticErrorWord1(0x0),
57 fTRMDiagnosticErrorWord2(0x0),
58 fSpiderCurrentSlotID(-1),
59 fSpiderCurrentChain(-1),
65 //_________________________________________________________________
67 AliTOFDecoder::AliTOFDecoder(AliTOFHitDataBuffer *DataBuffer, AliTOFHitDataBuffer *PackedDataBuffer) :
71 fDataBuffer(DataBuffer),
72 fPackedDataBuffer(PackedDataBuffer),
73 fTRMGlobalHeader(0x0),
74 fTRMGlobalTrailer(0x0),
76 fTRMChainTrailer(0x0),
80 fTRMDiagnosticErrorWord1(0x0),
81 fTRMDiagnosticErrorWord2(0x0),
82 fSpiderCurrentSlotID(-1),
83 fSpiderCurrentChain(-1),
89 //_________________________________________________________________
91 AliTOFDecoder::AliTOFDecoder(const AliTOFDecoder &source) :
96 fPackedDataBuffer(0x0),
97 fTRMGlobalHeader(0x0),
98 fTRMGlobalTrailer(0x0),
100 fTRMChainTrailer(0x0),
102 fTDCUnpackedHit(0x0),
104 fTRMDiagnosticErrorWord1(0x0),
105 fTRMDiagnosticErrorWord2(0x0),
106 fSpiderCurrentSlotID(-1),
107 fSpiderCurrentChain(-1),
108 fSpiderCurrentTDC(-1)
112 this->fVerbose = source.fVerbose;
113 this->fV2718Patch = source.fV2718Patch;
114 this->fDataBuffer = source.fDataBuffer;
115 this->fPackedDataBuffer = source.fPackedDataBuffer;
116 this->fTRMGlobalHeader = source.fTRMGlobalHeader;
117 this->fTRMGlobalTrailer = source.fTRMGlobalTrailer;
118 this->fTRMChainHeader = source.fTRMChainHeader;
119 this->fTRMChainTrailer = source.fTRMChainTrailer;
120 this->fTDCPackedHit = source.fTDCPackedHit;
121 this->fTDCUnpackedHit = source.fTDCUnpackedHit;
122 this->fTRMTDCError = source.fTRMTDCError;
123 this->fTRMDiagnosticErrorWord1 = source.fTRMDiagnosticErrorWord1;
124 this->fTRMDiagnosticErrorWord2 = source.fTRMDiagnosticErrorWord2;
125 this->fSpiderCurrentSlotID = source.fSpiderCurrentSlotID;
126 this->fSpiderCurrentChain = source.fSpiderCurrentChain;
127 this->fSpiderCurrentTDC = source.fSpiderCurrentTDC;
130 //_________________________________________________________________
133 AliTOFDecoder::operator = (const AliTOFDecoder &source)
137 this->fVerbose = source.fVerbose;
138 this->fV2718Patch = source.fV2718Patch;
139 this->fDataBuffer = source.fDataBuffer;
140 this->fPackedDataBuffer = source.fPackedDataBuffer;
141 this->fTRMGlobalHeader = source.fTRMGlobalHeader;
142 this->fTRMGlobalTrailer = source.fTRMGlobalTrailer;
143 this->fTRMChainHeader = source.fTRMChainHeader;
144 this->fTRMChainTrailer = source.fTRMChainTrailer;
145 this->fTDCPackedHit = source.fTDCPackedHit;
146 this->fTDCUnpackedHit = source.fTDCUnpackedHit;
147 this->fTRMTDCError = source.fTRMTDCError;
148 this->fTRMDiagnosticErrorWord1 = source.fTRMDiagnosticErrorWord1;
149 this->fTRMDiagnosticErrorWord2 = source.fTRMDiagnosticErrorWord2;
150 this->fSpiderCurrentSlotID = source.fSpiderCurrentSlotID;
151 this->fSpiderCurrentChain = source.fSpiderCurrentChain;
152 this->fSpiderCurrentTDC = source.fSpiderCurrentTDC;
156 AliTOFDecoder::~AliTOFDecoder()
159 //_________________________________________________________________
162 AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords)
164 /* main decoding routine.
165 * it loops over nWords 32-bit words
166 * starting at *rawData and decodes them.
167 * it also fills some buffers in order to
168 * have the decoded data available for other
172 AliTOFHitData hitData;
177 Float_t tempTOT; //ns
178 Int_t tempTOTBin; //TOT_BIN_WIDTH
181 UShort_t decodeStatus = 0x0;
182 Short_t currentDDL = -1;
183 Short_t currentSlotID = -1;
184 Short_t currentACQ = -1;
185 Short_t currentChain = -1;
186 Short_t currentBunchID = -1;
188 /*** V2718 patch ***/
190 decodeStatus = decodeStatus | DRM_BIT;
192 AliInfo("DRM not present: - V2718 patch decoding -");
194 /*** V2718 patch ***/
197 AliInfo("Initialize SPIDER function");
198 status = InitializeSpider();
201 AliInfo("Start decoding");
204 AliInfo("Loop over the data and decode");
207 AliInfo(" St Hex Word \t Decoded Word");
210 for (Int_t iWord = 0; iWord < nWords; iWord++, rawData++){
213 switch (*rawData & WORD_TYPE_MASK){
218 switch (*rawData & SLOT_ID_MASK){
220 //DRM global header (slotID=1)
222 //check decode status
223 if ( decodeStatus != DRM_HEADER_STATUS ){
224 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected DRM global header",decodeStatus,*rawData));
229 AliInfo(Form(" %02x - 0x%08x \t DRM global header",decodeStatus,*rawData));
230 //change decode status
231 decodeStatus = decodeStatus | DRM_BIT;
234 for (Int_t i = 0; i < DRM_DATA_WORDS; i++, iWord++, rawData++){
236 AliInfo(Form(" %02x - 0x%08x \t DRM data",decodeStatus,*rawData));
240 //LTM global header (slotID=2)
242 //check decode status
243 if ( decodeStatus != LTM_HEADER_STATUS ){
244 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected LTM global header",decodeStatus,*rawData));
249 AliInfo(Form(" %02x - 0x%08x \t LTM global header",decodeStatus,*rawData));
250 //change decode status
251 decodeStatus = decodeStatus | LTM_BIT;
254 for (Int_t i = 0; i < LTM_DATA_WORDS; i++, iWord++, rawData++){
256 AliInfo(Form(" %02x - 0x%08x \t LTM data",decodeStatus,*rawData));
260 //TRM global header (slotID=3-12)
261 case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12:
262 //check decode status
263 if ( decodeStatus != TRM_HEADER_STATUS ){
264 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM global header",decodeStatus,*rawData));
268 //set TRM global header
269 fTRMGlobalHeader = (AliTOFTRMGlobalHeader *)rawData;
271 currentSlotID = fTRMGlobalHeader->GetSlotID();
272 currentACQ = fTRMGlobalHeader->GetACQBits();
274 AliInfo(Form(" %02x - 0x%08x \t TRM global header \t slotID=%02d ACQ=%01d L=%01d",decodeStatus,*rawData,fTRMGlobalHeader->GetSlotID(),fTRMGlobalHeader->GetACQBits(),fTRMGlobalHeader->GetLBit()));
275 //change decode status
276 decodeStatus = decodeStatus | TRM_BIT;
281 AliError(Form(" %02x - 0x%08x [ERROR] Not valid slotID in global header",decodeStatus,*rawData));
292 switch (*rawData & SLOT_ID_MASK){
294 //DRM global trailer (slotID=1)
296 //check decode status
297 if ( decodeStatus != DRM_TRAILER_STATUS ){
298 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected DRM global trailer",decodeStatus,*rawData));
303 AliInfo(Form(" %02x - 0x%08x \t DRM global trailer",decodeStatus,*rawData));
304 //change decode status
305 decodeStatus = decodeStatus & ~DRM_BIT;
308 //LTM global trailer (slotID=2)
310 //check decode status
311 if ( decodeStatus != LTM_TRAILER_STATUS ){
312 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected LTM global trailer",decodeStatus,*rawData));
317 AliInfo(Form(" %02x - 0x%08x \t LTM global trailer",decodeStatus,*rawData));
318 //change decode status
319 decodeStatus = decodeStatus & ~LTM_BIT;
322 //TRM global trailer (slotID=15)
324 //check decode status
325 if ( decodeStatus != TRM_TRAILER_STATUS ){
326 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM global trailer",decodeStatus,*rawData));
330 //set TRM global trailer
331 fTRMGlobalTrailer = (AliTOFTRMGlobalTrailer *)rawData;
333 AliInfo(Form(" %02x - 0x%08x \t TRM global trailer \t CRC=%04d eventCounter=%04d",decodeStatus,*rawData,fTRMGlobalTrailer->GetEventCRC(),fTRMGlobalTrailer->GetEventCounter()));
334 //change decode status
335 decodeStatus = decodeStatus & ~TRM_BIT;
340 AliError(Form(" %02x - 0x%08x [ERROR] Not valid slotID/pattern in global trailer",decodeStatus,*rawData));
347 //check decode status
348 if ( (decodeStatus != CHAIN_A_HEADER_STATUS) ){
349 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain A header",decodeStatus,*rawData));
353 fTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
355 currentBunchID = fTRMChainHeader->GetBunchID();
357 AliInfo(Form(" %02x - 0x%08x \t TRM chain A header \t chain=%01d bunchID=%04d",decodeStatus,*rawData,currentChain,currentBunchID));
358 //change decode status
359 decodeStatus = decodeStatus | CHAIN_A_BIT;
362 case CHAIN_A_TRAILER:
363 //check decode status
364 if ( decodeStatus != CHAIN_A_TRAILER_STATUS ){
365 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain A trailer",decodeStatus,*rawData));
370 AliInfo(Form(" %02x - 0x%08x \t TRM chain A trailer",decodeStatus,*rawData));
371 //change decode status
372 decodeStatus = decodeStatus & ~CHAIN_A_BIT;
376 //check decode status
377 if ( decodeStatus != CHAIN_B_HEADER_STATUS ){
378 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain B header",decodeStatus,*rawData));
382 fTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
384 currentBunchID = fTRMChainHeader->GetBunchID();
386 AliInfo(Form(" %02x - 0x%08x \t TRM chain B header \t chain=%01d bunchID=%04d",decodeStatus,*rawData,currentChain,currentBunchID));
387 //change decode status
388 decodeStatus = decodeStatus | CHAIN_B_BIT;
391 case CHAIN_B_TRAILER:
392 //check decode status
393 if ( decodeStatus != CHAIN_B_TRAILER_STATUS ){
394 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain B trailer",decodeStatus,*rawData));
399 AliInfo(Form(" %02x - 0x%08x \t TRM chain B trailer",decodeStatus,*rawData));
400 //change decode status
401 decodeStatus = decodeStatus & ~CHAIN_B_BIT;
406 AliInfo(Form(" %02x - 0x%08x \t TDC error",decodeStatus,*rawData));
411 AliInfo(Form(" %02x - 0x%08x \t Filler",decodeStatus,*rawData));
415 //check decode status
416 if ( decodeStatus != CHAIN_A_TDC_HIT_STATUS &&
417 decodeStatus != CHAIN_B_TDC_HIT_STATUS ){
418 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected or unknown word",decodeStatus,*rawData));
426 case PACKING_ENABLED_ACQ:
427 //decode TDC packed hit
428 fTDCPackedHit = (AliTOFTDCPackedHit *)rawData;
429 fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
430 //set hit in the equipment data
431 hitData.SetDDLID(currentDDL);
432 hitData.SetSlotID(currentSlotID);
433 hitData.SetACQ(currentACQ);
434 hitData.SetChain(currentChain);
435 hitData.SetPS(fTDCPackedHit->GetPSBits());
436 hitData.SetTDC(fTDCPackedHit->GetTDCID());
437 hitData.SetChan(fTDCPackedHit->GetChan());
438 hitData.SetTime((float)fTDCPackedHit->GetHitTime() * TIME_BIN_WIDTH);
439 hitData.SetTimeBin(fTDCPackedHit->GetHitTime());
440 hitData.SetTOT((float)fTDCPackedHit->GetTOTWidth() * TOT_BIN_WIDTH);
441 hitData.SetTOTBin(fTDCPackedHit->GetTOTWidth());
442 //orphane leading hit
443 if (hitData.GetPS()==LEADING_HIT_PS){
444 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
445 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
448 hitData.SetTOTBin(0);
449 //push hit data in packed data buffer
450 if (fPackedDataBuffer != 0x0)
451 fPackedDataBuffer->Add(hitData);
452 //set TOT to not measured
454 hitData.SetTOTBin(-1);
455 //push hit data in packed data buffer
456 if (fDataBuffer != 0x0)
457 fDataBuffer->Add(hitData);
459 //orphane trailing hit
460 else if (hitData.GetPS()==TRAILING_HIT_PS){
461 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
462 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
463 //set TOT to not measured
465 hitData.SetTOTBin(-1);
466 //push hit data in data buffer
467 if (fDataBuffer != 0x0)
468 fDataBuffer->Add(hitData);
472 //push hit data in packed data buffer
473 if (fPackedDataBuffer != 0x0)
474 fPackedDataBuffer->Add(hitData);
476 tempPS = hitData.GetPS();
478 tempTOT = hitData.GetTOT();
479 tempTOTBin = hitData.GetTOTBin();
480 //unpack the hit: leading hit
481 hitData.SetPS(LEADING_HIT_PS);
482 //set TOT to not measured
484 hitData.SetTOTBin(-1);
485 //push leading hit data in data buffer
486 if (fDataBuffer != 0x0)
487 fDataBuffer->Add(hitData);
488 //unpack the hit: trailing hit
489 hitData.SetPS(TRAILING_HIT_PS);
490 hitData.SetTime(hitData.GetTime() + tempTOT);
491 hitData.SetTimeBin(hitData.GetTimeBin() + (Int_t)(tempTOTBin * TOT_TO_TIME_BIN_WIDTH));
492 //push trailing hit data in data buffer
493 if (fDataBuffer != 0x0)
494 fDataBuffer->Add(hitData);
496 hitData.SetPS(tempPS);
497 hitData.SetTime(hitData.GetTime() - tempTOT);
498 hitData.SetTimeBin(hitData.GetTimeBin() - (Int_t)(tempTOTBin * TOT_TO_TIME_BIN_WIDTH));
499 hitData.SetTOT(tempTOT);
500 hitData.SetTOTBin(tempTOTBin);
504 switch (hitData.GetPS()){
506 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()));
509 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()));
511 case TRAILING_HIT_PS:
512 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()));
515 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()));
520 case LEADING_ONLY_ACQ: case TRAILING_ONLY_ACQ:
521 //decode TDC unpacked hit
522 fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
523 //set hit in the equipment data
524 hitData.SetDDLID(currentDDL);
525 hitData.SetSlotID(currentSlotID);
526 hitData.SetACQ(currentACQ);
527 hitData.SetChain(currentChain);
528 hitData.SetPS(fTDCUnpackedHit->GetPSBits());
529 hitData.SetTDC(fTDCUnpackedHit->GetTDCID());
530 hitData.SetChan(fTDCUnpackedHit->GetChan());
531 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
532 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
534 hitData.SetTOTBin(-1);
535 //push hit data in data buffer
536 if (fDataBuffer != 0x0)
537 fDataBuffer->Add(hitData);
540 switch (hitData.GetPS()){
542 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()));
545 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()));
547 case TRAILING_HIT_PS:
548 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()));
551 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()));
556 case PACKING_DISABLED_ACQ:
557 //decode TDC unpacked hit
558 fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
559 //set hit in the equipment data
560 hitData.SetDDLID(currentDDL);
561 hitData.SetSlotID(currentSlotID);
562 hitData.SetACQ(currentACQ);
563 hitData.SetChain(currentChain);
564 hitData.SetPS(fTDCUnpackedHit->GetPSBits());
565 hitData.SetTDC(fTDCUnpackedHit->GetTDCID());
566 hitData.SetChan(fTDCUnpackedHit->GetChan());
567 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
568 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
570 hitData.SetTOTBin(-1);
571 //push hit data in data buffer
572 if (fDataBuffer != 0x0)
573 fDataBuffer->Add(hitData);
576 switch (hitData.GetPS()){
578 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()));
581 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()));
583 case TRAILING_HIT_PS:
584 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()));
587 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()));
590 //call spider function
592 AliInfo("Calling SPIDER function");
600 //end switch word type
603 //end equipment data loop
606 AliInfo("End of data loop");
609 AliInfo("Reset SPIDER function");
610 status = ResetSpider();
613 AliInfo("Decoder is exiting succesfully.");
618 //_________________________________________________________________
621 AliTOFDecoder::InitializeSpider(){
623 /* SPIDER initialization routine.
624 it initializes SPIDER variables in order
625 to have SPIDER ready to pack tof data
626 in packed data objects
630 AliInfo("Initializing SPIDER");
632 fSpiderCurrentSlotID=-1;
633 fSpiderCurrentChain=-1;
634 fSpiderCurrentTDC=-1;
636 for (Int_t chan=0;chan<N_CHANNEL;chan++)
637 fSpiderLeadingFlag[chan] = kFALSE;
642 //_________________________________________________________________
645 AliTOFDecoder::ResetSpider(){
647 /* SPIDER reset routine.
648 it resets SPIDER buffers and
649 variables in order to empty full
650 buffers a set up SIPDER for new
655 AliInfo("Resetting SPIDER buffers");
657 for (Int_t chan=0;chan<N_CHANNEL;chan++){
658 if (fSpiderLeadingFlag[chan]){
660 AliInfo("Buffer non empty: put leading hit into buffer as orphane");
662 fSpiderLeadingHit[chan].SetACQ(4);
663 fSpiderLeadingHit[chan].SetPS(1);
664 fSpiderLeadingHit[chan].SetTOT(0);
665 fSpiderLeadingHit[chan].SetTOTBin(0);
666 //push hit into packed buffer
667 if (fPackedDataBuffer != 0x0)
668 fPackedDataBuffer->Add(fSpiderLeadingHit[chan]);
670 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()));
673 fSpiderLeadingFlag[chan]=kFALSE;
679 //_________________________________________________________________
682 AliTOFDecoder::Spider(AliTOFHitData hitData){
684 /* main SPIDER routine.
685 it receives, reads, stores and packs
686 unpacked HPTDC data in packed data
687 object. it also fills buffers.
693 AliInfo("Hit data received");
695 //check if TDC is changed (slotID,chain,TDC triplet)
696 if (fSpiderCurrentSlotID!=hitData.GetSlotID() ||
697 fSpiderCurrentChain!=hitData.GetChain() ||
698 fSpiderCurrentTDC!=hitData.GetTDC() ){
700 AliInfo("Data coming from a new TDC: reset buffers");
702 status = ResetSpider();
704 fSpiderCurrentSlotID=hitData.GetSlotID();
705 fSpiderCurrentChain=hitData.GetChain();
706 fSpiderCurrentTDC=hitData.GetTDC();
710 switch (hitData.GetPS()){
714 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()));
715 //check spider leading flag
716 if (fSpiderLeadingFlag[hitData.GetChan()]){
718 AliInfo("Leading hit: buffer full, put previous in buffers as orphane and keep current");
719 //set TOT at zero for previous hit
720 fSpiderLeadingHit[hitData.GetChan()].SetACQ(4);
721 fSpiderLeadingHit[hitData.GetChan()].SetPS(1);
722 fSpiderLeadingHit[hitData.GetChan()].SetTOT(0);
723 fSpiderLeadingHit[hitData.GetChan()].SetTOTBin(0);
724 //push previous hit into packed buffer
725 if (fPackedDataBuffer != 0x0)
726 fPackedDataBuffer->Add(fSpiderLeadingHit[hitData.GetChan()]);
728 fSpiderLeadingHit[hitData.GetChan()]=hitData;
730 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()));
734 AliInfo("Leading hit: buffer empty, keep current hit and set flag");
735 fSpiderLeadingHit[hitData.GetChan()]=hitData;
736 //set spider leading flag
737 fSpiderLeadingFlag[hitData.GetChan()]=kTRUE;
741 case TRAILING_HIT_PS:
743 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()));
744 //check spider leading flag
745 if (fSpiderLeadingFlag[hitData.GetChan()]){
747 AliInfo("Trailing hit: buffer full, pack leading and trailing");
750 hitData.SetTOT(hitData.GetTime()-fSpiderLeadingHit[hitData.GetChan()].GetTime());
751 hitData.SetTOTBin((Int_t)((hitData.GetTimeBin()-fSpiderLeadingHit[hitData.GetChan()].GetTimeBin())*TIME_TO_TOT_BIN_WIDTH));
752 hitData.SetTime(fSpiderLeadingHit[hitData.GetChan()].GetTime());
753 hitData.SetTimeBin(fSpiderLeadingHit[hitData.GetChan()].GetTimeBin());
754 //check TOT and set TOT overflow if TOT < 0
755 if (hitData.GetTOT() < 0){
758 hitData.SetTOTBin(0);
760 if (fPackedDataBuffer != 0x0)
761 fPackedDataBuffer->Add(hitData);
763 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()));
764 //unset spider leading flag
765 fSpiderLeadingFlag[hitData.GetChan()]=kFALSE;
769 AliInfo("Trailing hit: buffer empty, throw hit away");