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.4 2007/05/18 13:08:57 decaro
19 Coding convention: RS1 violation -> suppression
21 Revision 1.3 2007/05/08 11:56:05 arcelli
22 improved verbosity in verbose mode (R.Preghenella)
24 Revision 1.2 2007/05/03 11:34:43 decaro
25 Coding convention: RS1 violation -> suppression
27 Revision 1.1 2007/04/27 11:00:32 arcelli
30 author: Roberto Preghenella (R+), preghenella@bo.infn.it
34 //////////////////////////////////////////////////////////////////////
37 // Class for raw data decoding //
40 //////////////////////////////////////////////////////////////////////
45 #include "AliTOFHitData.h"
46 #include "AliTOFDecoder.h"
47 #include "AliTOFGeometry.h"
49 ClassImp(AliTOFDecoder)
51 //_________________________________________________________________
53 AliTOFDecoder::AliTOFDecoder() :
58 fPackedDataBuffer(0x0),
59 fTRMGlobalHeader(0x0),
60 fTRMGlobalTrailer(0x0),
62 fTRMChainTrailer(0x0),
66 fTRMDiagnosticErrorWord1(0x0),
67 fTRMDiagnosticErrorWord2(0x0),
68 fSpiderCurrentSlotID(-1),
69 fSpiderCurrentChain(-1),
75 //_________________________________________________________________
77 AliTOFDecoder::AliTOFDecoder(AliTOFHitDataBuffer *DataBuffer, AliTOFHitDataBuffer *PackedDataBuffer) :
81 fDataBuffer(DataBuffer),
82 fPackedDataBuffer(PackedDataBuffer),
83 fTRMGlobalHeader(0x0),
84 fTRMGlobalTrailer(0x0),
86 fTRMChainTrailer(0x0),
90 fTRMDiagnosticErrorWord1(0x0),
91 fTRMDiagnosticErrorWord2(0x0),
92 fSpiderCurrentSlotID(-1),
93 fSpiderCurrentChain(-1),
99 //_________________________________________________________________
101 AliTOFDecoder::AliTOFDecoder(const AliTOFDecoder &source) :
106 fPackedDataBuffer(0x0),
107 fTRMGlobalHeader(0x0),
108 fTRMGlobalTrailer(0x0),
109 fTRMChainHeader(0x0),
110 fTRMChainTrailer(0x0),
112 fTDCUnpackedHit(0x0),
114 fTRMDiagnosticErrorWord1(0x0),
115 fTRMDiagnosticErrorWord2(0x0),
116 fSpiderCurrentSlotID(-1),
117 fSpiderCurrentChain(-1),
118 fSpiderCurrentTDC(-1)
122 this->fVerbose = source.fVerbose;
123 this->fV2718Patch = source.fV2718Patch;
124 this->fDataBuffer = source.fDataBuffer;
125 this->fPackedDataBuffer = source.fPackedDataBuffer;
126 this->fTRMGlobalHeader = source.fTRMGlobalHeader;
127 this->fTRMGlobalTrailer = source.fTRMGlobalTrailer;
128 this->fTRMChainHeader = source.fTRMChainHeader;
129 this->fTRMChainTrailer = source.fTRMChainTrailer;
130 this->fTDCPackedHit = source.fTDCPackedHit;
131 this->fTDCUnpackedHit = source.fTDCUnpackedHit;
132 this->fTRMTDCError = source.fTRMTDCError;
133 this->fTRMDiagnosticErrorWord1 = source.fTRMDiagnosticErrorWord1;
134 this->fTRMDiagnosticErrorWord2 = source.fTRMDiagnosticErrorWord2;
135 this->fSpiderCurrentSlotID = source.fSpiderCurrentSlotID;
136 this->fSpiderCurrentChain = source.fSpiderCurrentChain;
137 this->fSpiderCurrentTDC = source.fSpiderCurrentTDC;
140 //_________________________________________________________________
143 AliTOFDecoder::operator = (const AliTOFDecoder &source)
147 this->fVerbose = source.fVerbose;
148 this->fV2718Patch = source.fV2718Patch;
149 this->fDataBuffer = source.fDataBuffer;
150 this->fPackedDataBuffer = source.fPackedDataBuffer;
151 this->fTRMGlobalHeader = source.fTRMGlobalHeader;
152 this->fTRMGlobalTrailer = source.fTRMGlobalTrailer;
153 this->fTRMChainHeader = source.fTRMChainHeader;
154 this->fTRMChainTrailer = source.fTRMChainTrailer;
155 this->fTDCPackedHit = source.fTDCPackedHit;
156 this->fTDCUnpackedHit = source.fTDCUnpackedHit;
157 this->fTRMTDCError = source.fTRMTDCError;
158 this->fTRMDiagnosticErrorWord1 = source.fTRMDiagnosticErrorWord1;
159 this->fTRMDiagnosticErrorWord2 = source.fTRMDiagnosticErrorWord2;
160 this->fSpiderCurrentSlotID = source.fSpiderCurrentSlotID;
161 this->fSpiderCurrentChain = source.fSpiderCurrentChain;
162 this->fSpiderCurrentTDC = source.fSpiderCurrentTDC;
166 AliTOFDecoder::~AliTOFDecoder()
169 //_________________________________________________________________
172 AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords)
174 /* main decoding routine.
175 * it loops over nWords 32-bit words
176 * starting at *rawData and decodes them.
177 * it also fills some buffers in order to
178 * have the decoded data available for other
182 AliTOFHitData hitData;
187 Float_t tempTOT; //ns
188 Int_t tempTOTBin; //TOT_BIN_WIDTH
191 UShort_t decodeStatus = 0x0;
192 Short_t currentDDL = -1;
193 Short_t currentSlotID = -1;
194 Short_t currentACQ = -1;
195 Short_t currentChain = -1;
196 Short_t currentBunchID = -1;
198 /*** V2718 patch ***/
200 decodeStatus = decodeStatus | DRM_BIT;
202 AliInfo("DRM not present: - V2718 patch decoding -");
204 /*** V2718 patch ***/
207 AliInfo("Initialize SPIDER function");
208 status = InitializeSpider();
211 AliInfo("Start decoding");
214 AliInfo("Loop over the data and decode");
217 AliInfo(" St Hex Word \t Decoded Word");
220 for (Int_t iWord = 0; iWord < nWords; iWord++, rawData++){
223 switch (*rawData & WORD_TYPE_MASK){
228 switch (*rawData & SLOT_ID_MASK){
230 //DRM global header (slotID=1)
232 //check decode status
233 if ( decodeStatus != DRM_HEADER_STATUS ){
234 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected DRM global header",decodeStatus,*rawData));
239 AliInfo(Form(" %02x - 0x%08x \t DRM global header",decodeStatus,*rawData));
240 //change decode status
241 decodeStatus = decodeStatus | DRM_BIT;
244 for (Int_t i = 0; i < DRM_DATA_WORDS; i++, iWord++, rawData++){
246 AliInfo(Form(" %02x - 0x%08x \t DRM data",decodeStatus,*rawData));
250 //LTM global header (slotID=2)
252 //check decode status
253 if ( decodeStatus != LTM_HEADER_STATUS ){
254 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected LTM global header",decodeStatus,*rawData));
259 AliInfo(Form(" %02x - 0x%08x \t LTM global header",decodeStatus,*rawData));
260 //change decode status
261 decodeStatus = decodeStatus | LTM_BIT;
264 for (Int_t i = 0; i < LTM_DATA_WORDS; i++, iWord++, rawData++){
266 AliInfo(Form(" %02x - 0x%08x \t LTM data",decodeStatus,*rawData));
270 //TRM global header (slotID=3-12)
271 case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12:
272 //check decode status
273 if ( decodeStatus != TRM_HEADER_STATUS ){
274 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM global header",decodeStatus,*rawData));
278 //set TRM global header
279 fTRMGlobalHeader = (AliTOFTRMGlobalHeader *)rawData;
281 currentSlotID = fTRMGlobalHeader->GetSlotID();
282 currentACQ = fTRMGlobalHeader->GetACQBits();
284 AliInfo(Form(" %02x - 0x%08x \t TRM global header \t slotID=%02d ACQ=%01d L=%01d",decodeStatus,*rawData,fTRMGlobalHeader->GetSlotID(),fTRMGlobalHeader->GetACQBits(),fTRMGlobalHeader->GetLBit()));
285 //change decode status
286 decodeStatus = decodeStatus | TRM_BIT;
290 AliError(Form(" %02x - 0x%08x [ERROR] Not valid slotID in global header",decodeStatus,*rawData));
301 switch (*rawData & SLOT_ID_MASK){
303 //DRM global trailer (slotID=1)
305 //check decode status
306 if ( decodeStatus != DRM_TRAILER_STATUS ){
307 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected DRM global trailer",decodeStatus,*rawData));
312 AliInfo(Form(" %02x - 0x%08x \t DRM global trailer",decodeStatus,*rawData));
313 //change decode status
314 decodeStatus = decodeStatus & ~DRM_BIT;
317 //LTM global trailer (slotID=2)
319 //check decode status
320 if ( decodeStatus != LTM_TRAILER_STATUS ){
321 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected LTM global trailer",decodeStatus,*rawData));
326 AliInfo(Form(" %02x - 0x%08x \t LTM global trailer",decodeStatus,*rawData));
327 //change decode status
328 decodeStatus = decodeStatus & ~LTM_BIT;
331 //TRM global trailer (slotID=15)
333 //check decode status
334 if ( decodeStatus != TRM_TRAILER_STATUS ){
335 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM global trailer",decodeStatus,*rawData));
339 //set TRM global trailer
340 fTRMGlobalTrailer = (AliTOFTRMGlobalTrailer *)rawData;
342 AliInfo(Form(" %02x - 0x%08x \t TRM global trailer \t CRC=%04d eventCounter=%04d",decodeStatus,*rawData,fTRMGlobalTrailer->GetEventCRC(),fTRMGlobalTrailer->GetEventCounter()));
343 //change decode status
344 decodeStatus = decodeStatus & ~TRM_BIT;
348 AliError(Form(" %02x - 0x%08x [ERROR] Not valid slotID/pattern in global trailer",decodeStatus,*rawData));
355 //check decode status
356 if ( (decodeStatus != CHAIN_A_HEADER_STATUS) ){
357 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain A header",decodeStatus,*rawData));
361 fTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
363 currentBunchID = fTRMChainHeader->GetBunchID();
365 AliInfo(Form(" %02x - 0x%08x \t TRM chain A header \t chain=%01d bunchID=%04d",decodeStatus,*rawData,currentChain,currentBunchID));
366 //change decode status
367 decodeStatus = decodeStatus | CHAIN_A_BIT;
370 case CHAIN_A_TRAILER:
371 //check decode status
372 if ( decodeStatus != CHAIN_A_TRAILER_STATUS ){
373 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain A trailer",decodeStatus,*rawData));
378 AliInfo(Form(" %02x - 0x%08x \t TRM chain A trailer",decodeStatus,*rawData));
379 //change decode status
380 decodeStatus = decodeStatus & ~CHAIN_A_BIT;
384 //check decode status
385 if ( decodeStatus != CHAIN_B_HEADER_STATUS ){
386 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain B header",decodeStatus,*rawData));
390 fTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
392 currentBunchID = fTRMChainHeader->GetBunchID();
394 AliInfo(Form(" %02x - 0x%08x \t TRM chain B header \t chain=%01d bunchID=%04d",decodeStatus,*rawData,currentChain,currentBunchID));
395 //change decode status
396 decodeStatus = decodeStatus | CHAIN_B_BIT;
399 case CHAIN_B_TRAILER:
400 //check decode status
401 if ( decodeStatus != CHAIN_B_TRAILER_STATUS ){
402 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain B trailer",decodeStatus,*rawData));
407 AliInfo(Form(" %02x - 0x%08x \t TRM chain B trailer",decodeStatus,*rawData));
408 //change decode status
409 decodeStatus = decodeStatus & ~CHAIN_B_BIT;
414 AliInfo(Form(" %02x - 0x%08x \t TDC error",decodeStatus,*rawData));
419 AliInfo(Form(" %02x - 0x%08x \t Filler",decodeStatus,*rawData));
423 //check decode status
424 if ( decodeStatus != CHAIN_A_TDC_HIT_STATUS &&
425 decodeStatus != CHAIN_B_TDC_HIT_STATUS ){
426 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected or unknown word",decodeStatus,*rawData));
434 case PACKING_ENABLED_ACQ:
435 //decode TDC packed hit
436 fTDCPackedHit = (AliTOFTDCPackedHit *)rawData;
437 fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
438 //set hit in the equipment data
439 hitData.SetDDLID(currentDDL);
440 hitData.SetSlotID(currentSlotID);
441 hitData.SetACQ(currentACQ);
442 hitData.SetChain(currentChain);
443 hitData.SetPS(fTDCPackedHit->GetPSBits());
444 hitData.SetTDC(fTDCPackedHit->GetTDCID());
445 hitData.SetChan(fTDCPackedHit->GetChan());
446 hitData.SetTime((float)fTDCPackedHit->GetHitTime() * TIME_BIN_WIDTH);
447 hitData.SetTimeBin(fTDCPackedHit->GetHitTime());
448 hitData.SetTOT((float)fTDCPackedHit->GetTOTWidth() * TOT_BIN_WIDTH);
449 hitData.SetTOTBin(fTDCPackedHit->GetTOTWidth());
450 //orphane leading hit
451 if (hitData.GetPS()==LEADING_HIT_PS){
452 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
453 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
456 hitData.SetTOTBin(0);
457 //push hit data in packed data buffer
458 if (fPackedDataBuffer != 0x0)
459 fPackedDataBuffer->Add(hitData);
460 //set TOT to not measured
462 hitData.SetTOTBin(-1);
463 //push hit data in packed data buffer
464 if (fDataBuffer != 0x0)
465 fDataBuffer->Add(hitData);
467 //orphane trailing hit
468 else if (hitData.GetPS()==TRAILING_HIT_PS){
469 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
470 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
471 //set TOT to not measured
473 hitData.SetTOTBin(-1);
474 //push hit data in data buffer
475 if (fDataBuffer != 0x0)
476 fDataBuffer->Add(hitData);
480 //push hit data in packed data buffer
481 if (fPackedDataBuffer != 0x0)
482 fPackedDataBuffer->Add(hitData);
484 tempPS = hitData.GetPS();
486 tempTOT = hitData.GetTOT();
487 tempTOTBin = hitData.GetTOTBin();
488 //unpack the hit: leading hit
489 hitData.SetPS(LEADING_HIT_PS);
490 //set TOT to not measured
492 hitData.SetTOTBin(-1);
493 //push leading hit data in data buffer
494 if (fDataBuffer != 0x0)
495 fDataBuffer->Add(hitData);
496 //unpack the hit: trailing hit
497 hitData.SetPS(TRAILING_HIT_PS);
498 hitData.SetTime(hitData.GetTime() + tempTOT);
499 hitData.SetTimeBin(hitData.GetTimeBin() + (Int_t)(tempTOTBin * TOT_TO_TIME_BIN_WIDTH));
500 //push trailing hit data in data buffer
501 if (fDataBuffer != 0x0)
502 fDataBuffer->Add(hitData);
504 hitData.SetPS(tempPS);
505 hitData.SetTime(hitData.GetTime() - tempTOT);
506 hitData.SetTimeBin(hitData.GetTimeBin() - (Int_t)(tempTOTBin * TOT_TO_TIME_BIN_WIDTH));
507 hitData.SetTOT(tempTOT);
508 hitData.SetTOTBin(tempTOTBin);
512 switch (hitData.GetPS()){
514 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()));
517 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()));
519 case TRAILING_HIT_PS:
520 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()));
523 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()));
528 case LEADING_ONLY_ACQ: case TRAILING_ONLY_ACQ:
529 //decode TDC unpacked hit
530 fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
531 //set hit in the equipment data
532 hitData.SetDDLID(currentDDL);
533 hitData.SetSlotID(currentSlotID);
534 hitData.SetACQ(currentACQ);
535 hitData.SetChain(currentChain);
536 hitData.SetPS(fTDCUnpackedHit->GetPSBits());
537 hitData.SetTDC(fTDCUnpackedHit->GetTDCID());
538 hitData.SetChan(fTDCUnpackedHit->GetChan());
539 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
540 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
542 hitData.SetTOTBin(-1);
543 //push hit data in data buffer
544 if (fDataBuffer != 0x0)
545 fDataBuffer->Add(hitData);
548 switch (hitData.GetPS()){
550 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()));
553 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()));
555 case TRAILING_HIT_PS:
556 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()));
559 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()));
564 case PACKING_DISABLED_ACQ:
565 //decode TDC unpacked hit
566 fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
567 //set hit in the equipment data
568 hitData.SetDDLID(currentDDL);
569 hitData.SetSlotID(currentSlotID);
570 hitData.SetACQ(currentACQ);
571 hitData.SetChain(currentChain);
572 hitData.SetPS(fTDCUnpackedHit->GetPSBits());
573 hitData.SetTDC(fTDCUnpackedHit->GetTDCID());
574 hitData.SetChan(fTDCUnpackedHit->GetChan());
575 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
576 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
578 hitData.SetTOTBin(-1);
579 //push hit data in data buffer
580 if (fDataBuffer != 0x0)
581 fDataBuffer->Add(hitData);
584 switch (hitData.GetPS()){
586 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()));
589 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()));
591 case TRAILING_HIT_PS:
592 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()));
595 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()));
598 //call spider function
600 AliInfo("Calling SPIDER function");
608 //end switch word type
611 //end equipment data loop
614 AliInfo("End of data loop");
617 AliInfo("Reset SPIDER function");
618 status = ResetSpider();
621 AliInfo("Decoder is exiting succesfully.");
626 //_________________________________________________________________
629 AliTOFDecoder::InitializeSpider(){
631 /* SPIDER initialization routine.
632 it initializes SPIDER variables in order
633 to have SPIDER ready to pack tof data
634 in packed data objects
638 AliInfo("Initializing SPIDER");
640 fSpiderCurrentSlotID=-1;
641 fSpiderCurrentChain=-1;
642 fSpiderCurrentTDC=-1;
644 for (Int_t chan=0;chan<N_CHANNEL;chan++)
645 fSpiderLeadingFlag[chan] = kFALSE;
650 //_________________________________________________________________
653 AliTOFDecoder::ResetSpider(){
655 /* SPIDER reset routine.
656 it resets SPIDER buffers and
657 variables in order to empty full
658 buffers a set up SIPDER for new
663 AliInfo("Resetting SPIDER buffers");
665 for (Int_t chan=0;chan<N_CHANNEL;chan++){
666 if (fSpiderLeadingFlag[chan]){
668 AliInfo("Buffer non empty: put leading hit into buffer as orphane");
670 fSpiderLeadingHit[chan].SetACQ(4);
671 fSpiderLeadingHit[chan].SetPS(1);
672 fSpiderLeadingHit[chan].SetTOT(0);
673 fSpiderLeadingHit[chan].SetTOTBin(0);
674 //push hit into packed buffer
675 if (fPackedDataBuffer != 0x0)
676 fPackedDataBuffer->Add(fSpiderLeadingHit[chan]);
678 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()));
681 fSpiderLeadingFlag[chan]=kFALSE;
687 //_________________________________________________________________
690 AliTOFDecoder::Spider(AliTOFHitData hitData){
692 /* main SPIDER routine.
693 it receives, reads, stores and packs
694 unpacked HPTDC data in packed data
695 object. it also fills buffers.
701 AliInfo("Hit data received");
703 //check if TDC is changed (slotID,chain,TDC triplet)
704 if (fSpiderCurrentSlotID!=hitData.GetSlotID() ||
705 fSpiderCurrentChain!=hitData.GetChain() ||
706 fSpiderCurrentTDC!=hitData.GetTDC() ){
708 AliInfo("Data coming from a new TDC: reset buffers");
710 status = ResetSpider();
712 fSpiderCurrentSlotID=hitData.GetSlotID();
713 fSpiderCurrentChain=hitData.GetChain();
714 fSpiderCurrentTDC=hitData.GetTDC();
718 switch (hitData.GetPS()){
722 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()));
723 //check spider leading flag
724 if (fSpiderLeadingFlag[hitData.GetChan()]){
726 AliInfo("Leading hit: buffer full, put previous in buffers as orphane and keep current");
727 //set TOT at zero for previous hit
728 fSpiderLeadingHit[hitData.GetChan()].SetACQ(4);
729 fSpiderLeadingHit[hitData.GetChan()].SetPS(1);
730 fSpiderLeadingHit[hitData.GetChan()].SetTOT(0);
731 fSpiderLeadingHit[hitData.GetChan()].SetTOTBin(0);
732 //push previous hit into packed buffer
733 if (fPackedDataBuffer != 0x0)
734 fPackedDataBuffer->Add(fSpiderLeadingHit[hitData.GetChan()]);
736 fSpiderLeadingHit[hitData.GetChan()]=hitData;
738 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()));
742 AliInfo("Leading hit: buffer empty, keep current hit and set flag");
743 fSpiderLeadingHit[hitData.GetChan()]=hitData;
744 //set spider leading flag
745 fSpiderLeadingFlag[hitData.GetChan()]=kTRUE;
749 case TRAILING_HIT_PS:
751 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()));
752 //check spider leading flag
753 if (fSpiderLeadingFlag[hitData.GetChan()]){
755 AliInfo("Trailing hit: buffer full, pack leading and trailing");
758 hitData.SetTOT(hitData.GetTime()-fSpiderLeadingHit[hitData.GetChan()].GetTime());
759 hitData.SetTOTBin((Int_t)((hitData.GetTimeBin()-fSpiderLeadingHit[hitData.GetChan()].GetTimeBin())*TIME_TO_TOT_BIN_WIDTH));
760 hitData.SetTime(fSpiderLeadingHit[hitData.GetChan()].GetTime());
761 hitData.SetTimeBin(fSpiderLeadingHit[hitData.GetChan()].GetTimeBin());
762 //check TOT and set TOT overflow if TOT < 0
763 if (hitData.GetTOT() < 0){
766 hitData.SetTOTBin(0);
768 if (fPackedDataBuffer != 0x0)
769 fPackedDataBuffer->Add(hitData);
771 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()));
772 //unset spider leading flag
773 fSpiderLeadingFlag[hitData.GetChan()]=kFALSE;
777 AliInfo("Trailing hit: buffer empty, throw hit away");
785 //_____________________________________________________________________________
786 void AliTOFDecoder::GetArrayDDL(Int_t* array, Int_t ddl){
788 // method that fills array with the
789 // TOF channels indexes corresponding
792 AliTOFGeometry *geom = new AliTOFGeometry();
793 Int_t indexDDL = ddl%4;
794 Int_t iSector = Int_t(ddl/4);
795 //AliInfo(Form(" Sector = %i, DDL within sector = %i",iSector, indexDDL));
797 AliInfo(Form(" Sector = %i, DDL within sector = %i",iSector, indexDDL));
801 Int_t minPlate=0, maxPlate=0, minStrip2=0, maxStrip2=0, minPadz=0, maxPadz=0, minPadx=0, maxPadx=0;
806 minStrip2=kMinStrip0;
807 maxStrip2=kMaxStrip0;
814 else if (indexDDL==1){
817 minStrip2=kMinStrip1;
818 maxStrip2=kMaxStrip1;
825 else if (indexDDL==2){
828 minStrip2=kMinStrip2;
829 maxStrip2=kMaxStrip2;
836 else if (indexDDL==3){
839 minStrip2=kMinStrip3;
840 maxStrip2=kMaxStrip3;
851 for (Int_t iPlate=minPlate;iPlate<=maxPlate;iPlate++){
853 maxStrip = maxStrip2;
854 minStrip = minStrip2;
860 for (Int_t iStrip=minStrip;iStrip<=maxStrip;iStrip++){
861 for (Int_t iPadz=minPadz;iPadz<=maxPadz;iPadz++){
862 for (Int_t iPadx=minPadx;iPadx<=maxPadx;iPadx++){
868 AliInfo(Form(" Volume[0] = %i, Volume[1] = %i, Volume[2] = %i, Volume[3] = %i, Volume[4] = %i",Volume[0],Volume[1],Volume[2],Volume[3],Volume[4]));
870 if (indexDDL==0 || indexDDL==2){
871 array[ichTOF]=geom->GetIndex(Volume);
873 AliInfo(Form(" ichTOF = %i, TOFChannel = %i",ichTOF,array[ichTOF]));
877 array[ichTOF]=geom->GetIndex(Volume);
879 AliInfo(Form(" ichTOF = %i, TOFChannel = %i",ichTOF,array[ichTOF]));
887 //AliInfo(Form("ichTOF = %i",ichTOF));
888 if (((indexDDL==0 || indexDDL==2)&ichTOF!=2160) || ((indexDDL==1 || indexDDL==3)&ichTOF!=2208)){
889 AliWarning(Form("Something strange occurred, number of entries in array different from expected! Please, check! ichTOF = %i",ichTOF));