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.5 2007/11/24 14:58:34 zampolli
19 New Method implemented (#DDL <-> TOF channels)
21 Revision 1.4 2007/05/18 13:08:57 decaro
22 Coding convention: RS1 violation -> suppression
24 Revision 1.3 2007/05/08 11:56:05 arcelli
25 improved verbosity in verbose mode (R.Preghenella)
27 Revision 1.2 2007/05/03 11:34:43 decaro
28 Coding convention: RS1 violation -> suppression
30 Revision 1.1 2007/04/27 11:00:32 arcelli
33 author: Roberto Preghenella (R+), preghenella@bo.infn.it
37 //////////////////////////////////////////////////////////////////////
40 // Class for raw data decoding //
43 //////////////////////////////////////////////////////////////////////
48 #include "AliTOFHitData.h"
49 #include "AliTOFHitDataBuffer.h"
50 #include "AliTOFDecoder.h"
51 #include "AliTOFGeometry.h"
53 ClassImp(AliTOFDecoder)
55 //_________________________________________________________________
57 AliTOFDecoder::AliTOFDecoder() :
62 fPackedDataBuffer(0x0),
63 fTRMGlobalHeader(0x0),
64 fTRMGlobalTrailer(0x0),
66 fTRMChainTrailer(0x0),
70 fTRMDiagnosticErrorWord1(0x0),
71 fTRMDiagnosticErrorWord2(0x0),
72 fSpiderCurrentSlotID(-1),
73 fSpiderCurrentChain(-1),
79 //_________________________________________________________________
81 AliTOFDecoder::AliTOFDecoder(AliTOFHitDataBuffer *DataBuffer, AliTOFHitDataBuffer *PackedDataBuffer) :
85 fDataBuffer(DataBuffer),
86 fPackedDataBuffer(PackedDataBuffer),
87 fTRMGlobalHeader(0x0),
88 fTRMGlobalTrailer(0x0),
90 fTRMChainTrailer(0x0),
94 fTRMDiagnosticErrorWord1(0x0),
95 fTRMDiagnosticErrorWord2(0x0),
96 fSpiderCurrentSlotID(-1),
97 fSpiderCurrentChain(-1),
100 //another constructor
103 //_________________________________________________________________
105 AliTOFDecoder::AliTOFDecoder(const AliTOFDecoder &source) :
110 fPackedDataBuffer(0x0),
111 fTRMGlobalHeader(0x0),
112 fTRMGlobalTrailer(0x0),
113 fTRMChainHeader(0x0),
114 fTRMChainTrailer(0x0),
116 fTDCUnpackedHit(0x0),
118 fTRMDiagnosticErrorWord1(0x0),
119 fTRMDiagnosticErrorWord2(0x0),
120 fSpiderCurrentSlotID(-1),
121 fSpiderCurrentChain(-1),
122 fSpiderCurrentTDC(-1)
126 this->fVerbose = source.fVerbose;
127 this->fV2718Patch = source.fV2718Patch;
128 this->fDataBuffer = source.fDataBuffer;
129 this->fPackedDataBuffer = source.fPackedDataBuffer;
130 this->fTRMGlobalHeader = source.fTRMGlobalHeader;
131 this->fTRMGlobalTrailer = source.fTRMGlobalTrailer;
132 this->fTRMChainHeader = source.fTRMChainHeader;
133 this->fTRMChainTrailer = source.fTRMChainTrailer;
134 this->fTDCPackedHit = source.fTDCPackedHit;
135 this->fTDCUnpackedHit = source.fTDCUnpackedHit;
136 this->fTRMTDCError = source.fTRMTDCError;
137 this->fTRMDiagnosticErrorWord1 = source.fTRMDiagnosticErrorWord1;
138 this->fTRMDiagnosticErrorWord2 = source.fTRMDiagnosticErrorWord2;
139 this->fSpiderCurrentSlotID = source.fSpiderCurrentSlotID;
140 this->fSpiderCurrentChain = source.fSpiderCurrentChain;
141 this->fSpiderCurrentTDC = source.fSpiderCurrentTDC;
144 //_________________________________________________________________
147 AliTOFDecoder::operator = (const AliTOFDecoder &source)
151 this->fVerbose = source.fVerbose;
152 this->fV2718Patch = source.fV2718Patch;
153 this->fDataBuffer = source.fDataBuffer;
154 this->fPackedDataBuffer = source.fPackedDataBuffer;
155 this->fTRMGlobalHeader = source.fTRMGlobalHeader;
156 this->fTRMGlobalTrailer = source.fTRMGlobalTrailer;
157 this->fTRMChainHeader = source.fTRMChainHeader;
158 this->fTRMChainTrailer = source.fTRMChainTrailer;
159 this->fTDCPackedHit = source.fTDCPackedHit;
160 this->fTDCUnpackedHit = source.fTDCUnpackedHit;
161 this->fTRMTDCError = source.fTRMTDCError;
162 this->fTRMDiagnosticErrorWord1 = source.fTRMDiagnosticErrorWord1;
163 this->fTRMDiagnosticErrorWord2 = source.fTRMDiagnosticErrorWord2;
164 this->fSpiderCurrentSlotID = source.fSpiderCurrentSlotID;
165 this->fSpiderCurrentChain = source.fSpiderCurrentChain;
166 this->fSpiderCurrentTDC = source.fSpiderCurrentTDC;
170 AliTOFDecoder::~AliTOFDecoder()
173 //_________________________________________________________________
176 AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords)
178 /* main decoding routine.
179 * it loops over nWords 32-bit words
180 * starting at *rawData and decodes them.
181 * it also fills some buffers in order to
182 * have the decoded data available for other
186 AliTOFHitData hitData;
191 Float_t tempTOT; //ns
192 Int_t tempTOTBin; //TOT_BIN_WIDTH
195 UShort_t decodeStatus = 0x0;
196 Short_t currentDDL = -1;
197 Short_t currentSlotID = -1;
198 Short_t currentACQ = -1;
199 Short_t currentChain = -1;
200 Short_t currentBunchID = -1;
202 /*** V2718 patch ***/
204 decodeStatus = decodeStatus | DRM_BIT;
206 AliInfo("DRM not present: - V2718 patch decoding -");
208 /*** V2718 patch ***/
211 AliInfo("Initialize SPIDER function");
212 status = InitializeSpider();
215 AliInfo("Start decoding");
218 AliInfo("Loop over the data and decode");
221 AliInfo(" St Hex Word \t Decoded Word");
224 for (Int_t iWord = 0; iWord < nWords; iWord++, rawData++){
227 switch (*rawData & WORD_TYPE_MASK){
232 switch (*rawData & SLOT_ID_MASK){
234 //DRM global header (slotID=1)
236 //check decode status
237 if ( decodeStatus != DRM_HEADER_STATUS ){
238 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected DRM global header",decodeStatus,*rawData));
243 AliInfo(Form(" %02x - 0x%08x \t DRM global header",decodeStatus,*rawData));
244 //change decode status
245 decodeStatus = decodeStatus | DRM_BIT;
248 for (Int_t i = 0; i < DRM_DATA_WORDS; i++, iWord++, rawData++){
250 AliInfo(Form(" %02x - 0x%08x \t DRM data",decodeStatus,*rawData));
254 //LTM global header (slotID=2)
256 //check decode status
257 if ( decodeStatus != LTM_HEADER_STATUS ){
258 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected LTM global header",decodeStatus,*rawData));
263 AliInfo(Form(" %02x - 0x%08x \t LTM global header",decodeStatus,*rawData));
264 //change decode status
265 decodeStatus = decodeStatus | LTM_BIT;
268 for (Int_t i = 0; i < LTM_DATA_WORDS; i++, iWord++, rawData++){
270 AliInfo(Form(" %02x - 0x%08x \t LTM data",decodeStatus,*rawData));
274 //TRM global header (slotID=3-12)
275 case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12:
276 //check decode status
277 if ( decodeStatus != TRM_HEADER_STATUS ){
278 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM global header",decodeStatus,*rawData));
282 //set TRM global header
283 fTRMGlobalHeader = (AliTOFTRMGlobalHeader *)rawData;
285 currentSlotID = fTRMGlobalHeader->GetSlotID();
286 currentACQ = fTRMGlobalHeader->GetACQBits();
288 AliInfo(Form(" %02x - 0x%08x \t TRM global header \t slotID=%02d ACQ=%01d L=%01d",decodeStatus,*rawData,fTRMGlobalHeader->GetSlotID(),fTRMGlobalHeader->GetACQBits(),fTRMGlobalHeader->GetLBit()));
289 //change decode status
290 decodeStatus = decodeStatus | TRM_BIT;
294 AliError(Form(" %02x - 0x%08x [ERROR] Not valid slotID in global header",decodeStatus,*rawData));
305 switch (*rawData & SLOT_ID_MASK){
307 //DRM global trailer (slotID=1)
309 //check decode status
310 if ( decodeStatus != DRM_TRAILER_STATUS ){
311 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected DRM global trailer",decodeStatus,*rawData));
316 AliInfo(Form(" %02x - 0x%08x \t DRM global trailer",decodeStatus,*rawData));
317 //change decode status
318 decodeStatus = decodeStatus & ~DRM_BIT;
321 //LTM global trailer (slotID=2)
323 //check decode status
324 if ( decodeStatus != LTM_TRAILER_STATUS ){
325 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected LTM global trailer",decodeStatus,*rawData));
330 AliInfo(Form(" %02x - 0x%08x \t LTM global trailer",decodeStatus,*rawData));
331 //change decode status
332 decodeStatus = decodeStatus & ~LTM_BIT;
335 //TRM global trailer (slotID=15)
337 //check decode status
338 if ( decodeStatus != TRM_TRAILER_STATUS ){
339 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM global trailer",decodeStatus,*rawData));
343 //set TRM global trailer
344 fTRMGlobalTrailer = (AliTOFTRMGlobalTrailer *)rawData;
346 AliInfo(Form(" %02x - 0x%08x \t TRM global trailer \t CRC=%04d eventCounter=%04d",decodeStatus,*rawData,fTRMGlobalTrailer->GetEventCRC(),fTRMGlobalTrailer->GetEventCounter()));
347 //change decode status
348 decodeStatus = decodeStatus & ~TRM_BIT;
352 AliError(Form(" %02x - 0x%08x [ERROR] Not valid slotID/pattern in global trailer",decodeStatus,*rawData));
359 //check decode status
360 if ( (decodeStatus != CHAIN_A_HEADER_STATUS) ){
361 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain A header",decodeStatus,*rawData));
365 fTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
367 currentBunchID = fTRMChainHeader->GetBunchID();
369 AliInfo(Form(" %02x - 0x%08x \t TRM chain A header \t chain=%01d bunchID=%04d",decodeStatus,*rawData,currentChain,currentBunchID));
370 //change decode status
371 decodeStatus = decodeStatus | CHAIN_A_BIT;
374 case CHAIN_A_TRAILER:
375 //check decode status
376 if ( decodeStatus != CHAIN_A_TRAILER_STATUS ){
377 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain A trailer",decodeStatus,*rawData));
382 AliInfo(Form(" %02x - 0x%08x \t TRM chain A trailer",decodeStatus,*rawData));
383 //change decode status
384 decodeStatus = decodeStatus & ~CHAIN_A_BIT;
388 //check decode status
389 if ( decodeStatus != CHAIN_B_HEADER_STATUS ){
390 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain B header",decodeStatus,*rawData));
394 fTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
396 currentBunchID = fTRMChainHeader->GetBunchID();
398 AliInfo(Form(" %02x - 0x%08x \t TRM chain B header \t chain=%01d bunchID=%04d",decodeStatus,*rawData,currentChain,currentBunchID));
399 //change decode status
400 decodeStatus = decodeStatus | CHAIN_B_BIT;
403 case CHAIN_B_TRAILER:
404 //check decode status
405 if ( decodeStatus != CHAIN_B_TRAILER_STATUS ){
406 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain B trailer",decodeStatus,*rawData));
411 AliInfo(Form(" %02x - 0x%08x \t TRM chain B trailer",decodeStatus,*rawData));
412 //change decode status
413 decodeStatus = decodeStatus & ~CHAIN_B_BIT;
418 AliInfo(Form(" %02x - 0x%08x \t TDC error",decodeStatus,*rawData));
423 AliInfo(Form(" %02x - 0x%08x \t Filler",decodeStatus,*rawData));
427 //check decode status
428 if ( decodeStatus != CHAIN_A_TDC_HIT_STATUS &&
429 decodeStatus != CHAIN_B_TDC_HIT_STATUS ){
430 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected or unknown word",decodeStatus,*rawData));
438 case PACKING_ENABLED_ACQ:
439 //decode TDC packed hit
440 fTDCPackedHit = (AliTOFTDCPackedHit *)rawData;
441 fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
442 //set hit in the equipment data
443 hitData.SetDDLID(currentDDL);
444 hitData.SetSlotID(currentSlotID);
445 hitData.SetACQ(currentACQ);
446 hitData.SetChain(currentChain);
447 hitData.SetPS(fTDCPackedHit->GetPSBits());
448 hitData.SetTDC(fTDCPackedHit->GetTDCID());
449 hitData.SetChan(fTDCPackedHit->GetChan());
450 hitData.SetTime((float)fTDCPackedHit->GetHitTime() * TIME_BIN_WIDTH);
451 hitData.SetTimeBin(fTDCPackedHit->GetHitTime());
452 hitData.SetTOT((float)fTDCPackedHit->GetTOTWidth() * TOT_BIN_WIDTH);
453 hitData.SetTOTBin(fTDCPackedHit->GetTOTWidth());
454 //orphane leading hit
455 if (hitData.GetPS()==LEADING_HIT_PS){
456 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
457 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
460 hitData.SetTOTBin(0);
461 //push hit data in packed data buffer
462 if (fPackedDataBuffer != 0x0)
463 fPackedDataBuffer->Add(hitData);
464 //set TOT to not measured
466 hitData.SetTOTBin(-1);
467 //push hit data in packed data buffer
468 if (fDataBuffer != 0x0)
469 fDataBuffer->Add(hitData);
471 //orphane trailing hit
472 else if (hitData.GetPS()==TRAILING_HIT_PS){
473 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
474 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
475 //set TOT to not measured
477 hitData.SetTOTBin(-1);
478 //push hit data in data buffer
479 if (fDataBuffer != 0x0)
480 fDataBuffer->Add(hitData);
484 //push hit data in packed data buffer
485 if (fPackedDataBuffer != 0x0)
486 fPackedDataBuffer->Add(hitData);
488 tempPS = hitData.GetPS();
490 tempTOT = hitData.GetTOT();
491 tempTOTBin = hitData.GetTOTBin();
492 //unpack the hit: leading hit
493 hitData.SetPS(LEADING_HIT_PS);
494 //set TOT to not measured
496 hitData.SetTOTBin(-1);
497 //push leading hit data in data buffer
498 if (fDataBuffer != 0x0)
499 fDataBuffer->Add(hitData);
500 //unpack the hit: trailing hit
501 hitData.SetPS(TRAILING_HIT_PS);
502 hitData.SetTime(hitData.GetTime() + tempTOT);
503 hitData.SetTimeBin(hitData.GetTimeBin() + (Int_t)(tempTOTBin * TOT_TO_TIME_BIN_WIDTH));
504 //push trailing hit data in data buffer
505 if (fDataBuffer != 0x0)
506 fDataBuffer->Add(hitData);
508 hitData.SetPS(tempPS);
509 hitData.SetTime(hitData.GetTime() - tempTOT);
510 hitData.SetTimeBin(hitData.GetTimeBin() - (Int_t)(tempTOTBin * TOT_TO_TIME_BIN_WIDTH));
511 hitData.SetTOT(tempTOT);
512 hitData.SetTOTBin(tempTOTBin);
516 switch (hitData.GetPS()){
518 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()));
521 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()));
523 case TRAILING_HIT_PS:
524 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()));
527 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()));
532 case LEADING_ONLY_ACQ: case TRAILING_ONLY_ACQ:
533 //decode TDC unpacked hit
534 fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
535 //set hit in the equipment data
536 hitData.SetDDLID(currentDDL);
537 hitData.SetSlotID(currentSlotID);
538 hitData.SetACQ(currentACQ);
539 hitData.SetChain(currentChain);
540 hitData.SetPS(fTDCUnpackedHit->GetPSBits());
541 hitData.SetTDC(fTDCUnpackedHit->GetTDCID());
542 hitData.SetChan(fTDCUnpackedHit->GetChan());
543 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
544 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
546 hitData.SetTOTBin(-1);
547 //push hit data in data buffer
548 if (fDataBuffer != 0x0)
549 fDataBuffer->Add(hitData);
552 switch (hitData.GetPS()){
554 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()));
557 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()));
559 case TRAILING_HIT_PS:
560 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()));
563 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()));
568 case PACKING_DISABLED_ACQ:
569 //decode TDC unpacked hit
570 fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
571 //set hit in the equipment data
572 hitData.SetDDLID(currentDDL);
573 hitData.SetSlotID(currentSlotID);
574 hitData.SetACQ(currentACQ);
575 hitData.SetChain(currentChain);
576 hitData.SetPS(fTDCUnpackedHit->GetPSBits());
577 hitData.SetTDC(fTDCUnpackedHit->GetTDCID());
578 hitData.SetChan(fTDCUnpackedHit->GetChan());
579 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
580 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
582 hitData.SetTOTBin(-1);
583 //push hit data in data buffer
584 if (fDataBuffer != 0x0)
585 fDataBuffer->Add(hitData);
588 switch (hitData.GetPS()){
590 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()));
593 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()));
595 case TRAILING_HIT_PS:
596 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()));
599 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()));
602 //call spider function
604 AliInfo("Calling SPIDER function");
612 //end switch word type
615 //end equipment data loop
618 AliInfo("End of data loop");
621 AliInfo("Reset SPIDER function");
622 status = ResetSpider();
625 AliInfo("Decoder is exiting succesfully.");
630 //_________________________________________________________________
633 AliTOFDecoder::InitializeSpider(){
635 /* SPIDER initialization routine.
636 it initializes SPIDER variables in order
637 to have SPIDER ready to pack tof data
638 in packed data objects
642 AliInfo("Initializing SPIDER");
644 fSpiderCurrentSlotID=-1;
645 fSpiderCurrentChain=-1;
646 fSpiderCurrentTDC=-1;
648 for (Int_t chan=0;chan<N_CHANNEL;chan++)
649 fSpiderLeadingFlag[chan] = kFALSE;
654 //_________________________________________________________________
657 AliTOFDecoder::ResetSpider(){
659 /* SPIDER reset routine.
660 it resets SPIDER buffers and
661 variables in order to empty full
662 buffers a set up SIPDER for new
667 AliInfo("Resetting SPIDER buffers");
669 for (Int_t chan=0;chan<N_CHANNEL;chan++){
670 if (fSpiderLeadingFlag[chan]){
672 AliInfo("Buffer non empty: put leading hit into buffer as orphane");
674 fSpiderLeadingHit[chan].SetACQ(4);
675 fSpiderLeadingHit[chan].SetPS(1);
676 fSpiderLeadingHit[chan].SetTOT(0);
677 fSpiderLeadingHit[chan].SetTOTBin(0);
678 //push hit into packed buffer
679 if (fPackedDataBuffer != 0x0)
680 fPackedDataBuffer->Add(fSpiderLeadingHit[chan]);
682 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()));
685 fSpiderLeadingFlag[chan]=kFALSE;
691 //_________________________________________________________________
694 AliTOFDecoder::Spider(AliTOFHitData hitData){
696 /* main SPIDER routine.
697 it receives, reads, stores and packs
698 unpacked HPTDC data in packed data
699 object. it also fills buffers.
705 AliInfo("Hit data received");
707 //check if TDC is changed (slotID,chain,TDC triplet)
708 if (fSpiderCurrentSlotID!=hitData.GetSlotID() ||
709 fSpiderCurrentChain!=hitData.GetChain() ||
710 fSpiderCurrentTDC!=hitData.GetTDC() ){
712 AliInfo("Data coming from a new TDC: reset buffers");
714 status = ResetSpider();
716 fSpiderCurrentSlotID=hitData.GetSlotID();
717 fSpiderCurrentChain=hitData.GetChain();
718 fSpiderCurrentTDC=hitData.GetTDC();
722 switch (hitData.GetPS()){
726 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()));
727 //check spider leading flag
728 if (fSpiderLeadingFlag[hitData.GetChan()]){
730 AliInfo("Leading hit: buffer full, put previous in buffers as orphane and keep current");
731 //set TOT at zero for previous hit
732 fSpiderLeadingHit[hitData.GetChan()].SetACQ(4);
733 fSpiderLeadingHit[hitData.GetChan()].SetPS(1);
734 fSpiderLeadingHit[hitData.GetChan()].SetTOT(0);
735 fSpiderLeadingHit[hitData.GetChan()].SetTOTBin(0);
736 //push previous hit into packed buffer
737 if (fPackedDataBuffer != 0x0)
738 fPackedDataBuffer->Add(fSpiderLeadingHit[hitData.GetChan()]);
740 fSpiderLeadingHit[hitData.GetChan()]=hitData;
742 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()));
746 AliInfo("Leading hit: buffer empty, keep current hit and set flag");
747 fSpiderLeadingHit[hitData.GetChan()]=hitData;
748 //set spider leading flag
749 fSpiderLeadingFlag[hitData.GetChan()]=kTRUE;
753 case TRAILING_HIT_PS:
755 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()));
756 //check spider leading flag
757 if (fSpiderLeadingFlag[hitData.GetChan()]){
759 AliInfo("Trailing hit: buffer full, pack leading and trailing");
762 hitData.SetTOT(hitData.GetTime()-fSpiderLeadingHit[hitData.GetChan()].GetTime());
763 hitData.SetTOTBin((Int_t)((hitData.GetTimeBin()-fSpiderLeadingHit[hitData.GetChan()].GetTimeBin())*TIME_TO_TOT_BIN_WIDTH));
764 hitData.SetTime(fSpiderLeadingHit[hitData.GetChan()].GetTime());
765 hitData.SetTimeBin(fSpiderLeadingHit[hitData.GetChan()].GetTimeBin());
766 //check TOT and set TOT overflow if TOT < 0
767 if (hitData.GetTOT() < 0){
770 hitData.SetTOTBin(0);
772 if (fPackedDataBuffer != 0x0)
773 fPackedDataBuffer->Add(hitData);
775 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()));
776 //unset spider leading flag
777 fSpiderLeadingFlag[hitData.GetChan()]=kFALSE;
781 AliInfo("Trailing hit: buffer empty, throw hit away");
789 //_____________________________________________________________________________
790 void AliTOFDecoder::GetArrayDDL(Int_t* array, Int_t ddl){
792 // method that fills array with the
793 // TOF channels indexes corresponding
796 AliTOFGeometry *geom = new AliTOFGeometry();
797 Int_t indexDDL = ddl%4;
798 Int_t iSector = Int_t(ddl/4);
799 //AliInfo(Form(" Sector = %i, DDL within sector = %i",iSector, indexDDL));
801 AliInfo(Form(" Sector = %i, DDL within sector = %i",iSector, indexDDL));
805 Int_t minPlate=0, maxPlate=0, minStrip2=0, maxStrip2=0, minPadz=0, maxPadz=0, minPadx=0, maxPadx=0;
810 minStrip2=kMinStrip0;
811 maxStrip2=kMaxStrip0;
818 else if (indexDDL==1){
821 minStrip2=kMinStrip1;
822 maxStrip2=kMaxStrip1;
829 else if (indexDDL==2){
832 minStrip2=kMinStrip2;
833 maxStrip2=kMaxStrip2;
840 else if (indexDDL==3){
843 minStrip2=kMinStrip3;
844 maxStrip2=kMaxStrip3;
855 for (Int_t iPlate=minPlate;iPlate<=maxPlate;iPlate++){
857 maxStrip = maxStrip2;
858 minStrip = minStrip2;
864 for (Int_t iStrip=minStrip;iStrip<=maxStrip;iStrip++){
865 for (Int_t iPadz=minPadz;iPadz<=maxPadz;iPadz++){
866 for (Int_t iPadx=minPadx;iPadx<=maxPadx;iPadx++){
872 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]));
874 if (indexDDL==0 || indexDDL==2){
875 array[ichTOF]=geom->GetIndex(volume);
877 AliInfo(Form(" ichTOF = %i, TOFChannel = %i",ichTOF,array[ichTOF]));
881 array[ichTOF]=geom->GetIndex(volume);
883 AliInfo(Form(" ichTOF = %i, TOFChannel = %i",ichTOF,array[ichTOF]));
891 //AliInfo(Form("ichTOF = %i",ichTOF));
892 if (((indexDDL==0 || indexDDL==2)&ichTOF!=2160) || ((indexDDL==1 || indexDDL==3)&ichTOF!=2208)){
893 AliWarning(Form("Something strange occurred, number of entries in array different from expected! Please, check! ichTOF = %i",ichTOF));