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 "AliTOFDecoder.h"
50 #include "AliTOFGeometry.h"
52 ClassImp(AliTOFDecoder)
54 //_________________________________________________________________
56 AliTOFDecoder::AliTOFDecoder() :
61 fPackedDataBuffer(0x0),
62 fTRMGlobalHeader(0x0),
63 fTRMGlobalTrailer(0x0),
65 fTRMChainTrailer(0x0),
69 fTRMDiagnosticErrorWord1(0x0),
70 fTRMDiagnosticErrorWord2(0x0),
71 fSpiderCurrentSlotID(-1),
72 fSpiderCurrentChain(-1),
78 //_________________________________________________________________
80 AliTOFDecoder::AliTOFDecoder(AliTOFHitDataBuffer *DataBuffer, AliTOFHitDataBuffer *PackedDataBuffer) :
84 fDataBuffer(DataBuffer),
85 fPackedDataBuffer(PackedDataBuffer),
86 fTRMGlobalHeader(0x0),
87 fTRMGlobalTrailer(0x0),
89 fTRMChainTrailer(0x0),
93 fTRMDiagnosticErrorWord1(0x0),
94 fTRMDiagnosticErrorWord2(0x0),
95 fSpiderCurrentSlotID(-1),
96 fSpiderCurrentChain(-1),
102 //_________________________________________________________________
104 AliTOFDecoder::AliTOFDecoder(const AliTOFDecoder &source) :
109 fPackedDataBuffer(0x0),
110 fTRMGlobalHeader(0x0),
111 fTRMGlobalTrailer(0x0),
112 fTRMChainHeader(0x0),
113 fTRMChainTrailer(0x0),
115 fTDCUnpackedHit(0x0),
117 fTRMDiagnosticErrorWord1(0x0),
118 fTRMDiagnosticErrorWord2(0x0),
119 fSpiderCurrentSlotID(-1),
120 fSpiderCurrentChain(-1),
121 fSpiderCurrentTDC(-1)
125 this->fVerbose = source.fVerbose;
126 this->fV2718Patch = source.fV2718Patch;
127 this->fDataBuffer = source.fDataBuffer;
128 this->fPackedDataBuffer = source.fPackedDataBuffer;
129 this->fTRMGlobalHeader = source.fTRMGlobalHeader;
130 this->fTRMGlobalTrailer = source.fTRMGlobalTrailer;
131 this->fTRMChainHeader = source.fTRMChainHeader;
132 this->fTRMChainTrailer = source.fTRMChainTrailer;
133 this->fTDCPackedHit = source.fTDCPackedHit;
134 this->fTDCUnpackedHit = source.fTDCUnpackedHit;
135 this->fTRMTDCError = source.fTRMTDCError;
136 this->fTRMDiagnosticErrorWord1 = source.fTRMDiagnosticErrorWord1;
137 this->fTRMDiagnosticErrorWord2 = source.fTRMDiagnosticErrorWord2;
138 this->fSpiderCurrentSlotID = source.fSpiderCurrentSlotID;
139 this->fSpiderCurrentChain = source.fSpiderCurrentChain;
140 this->fSpiderCurrentTDC = source.fSpiderCurrentTDC;
143 //_________________________________________________________________
146 AliTOFDecoder::operator = (const AliTOFDecoder &source)
150 this->fVerbose = source.fVerbose;
151 this->fV2718Patch = source.fV2718Patch;
152 this->fDataBuffer = source.fDataBuffer;
153 this->fPackedDataBuffer = source.fPackedDataBuffer;
154 this->fTRMGlobalHeader = source.fTRMGlobalHeader;
155 this->fTRMGlobalTrailer = source.fTRMGlobalTrailer;
156 this->fTRMChainHeader = source.fTRMChainHeader;
157 this->fTRMChainTrailer = source.fTRMChainTrailer;
158 this->fTDCPackedHit = source.fTDCPackedHit;
159 this->fTDCUnpackedHit = source.fTDCUnpackedHit;
160 this->fTRMTDCError = source.fTRMTDCError;
161 this->fTRMDiagnosticErrorWord1 = source.fTRMDiagnosticErrorWord1;
162 this->fTRMDiagnosticErrorWord2 = source.fTRMDiagnosticErrorWord2;
163 this->fSpiderCurrentSlotID = source.fSpiderCurrentSlotID;
164 this->fSpiderCurrentChain = source.fSpiderCurrentChain;
165 this->fSpiderCurrentTDC = source.fSpiderCurrentTDC;
169 AliTOFDecoder::~AliTOFDecoder()
172 //_________________________________________________________________
175 AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords)
177 /* main decoding routine.
178 * it loops over nWords 32-bit words
179 * starting at *rawData and decodes them.
180 * it also fills some buffers in order to
181 * have the decoded data available for other
185 AliTOFHitData hitData;
190 Float_t tempTOT; //ns
191 Int_t tempTOTBin; //TOT_BIN_WIDTH
194 UShort_t decodeStatus = 0x0;
195 Short_t currentDDL = -1;
196 Short_t currentSlotID = -1;
197 Short_t currentACQ = -1;
198 Short_t currentChain = -1;
199 Short_t currentBunchID = -1;
201 /*** V2718 patch ***/
203 decodeStatus = decodeStatus | DRM_BIT;
205 AliInfo("DRM not present: - V2718 patch decoding -");
207 /*** V2718 patch ***/
210 AliInfo("Initialize SPIDER function");
211 status = InitializeSpider();
214 AliInfo("Start decoding");
217 AliInfo("Loop over the data and decode");
220 AliInfo(" St Hex Word \t Decoded Word");
223 for (Int_t iWord = 0; iWord < nWords; iWord++, rawData++){
226 switch (*rawData & WORD_TYPE_MASK){
231 switch (*rawData & SLOT_ID_MASK){
233 //DRM global header (slotID=1)
235 //check decode status
236 if ( decodeStatus != DRM_HEADER_STATUS ){
237 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected DRM global header",decodeStatus,*rawData));
242 AliInfo(Form(" %02x - 0x%08x \t DRM global header",decodeStatus,*rawData));
243 //change decode status
244 decodeStatus = decodeStatus | DRM_BIT;
247 for (Int_t i = 0; i < DRM_DATA_WORDS; i++, iWord++, rawData++){
249 AliInfo(Form(" %02x - 0x%08x \t DRM data",decodeStatus,*rawData));
253 //LTM global header (slotID=2)
255 //check decode status
256 if ( decodeStatus != LTM_HEADER_STATUS ){
257 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected LTM global header",decodeStatus,*rawData));
262 AliInfo(Form(" %02x - 0x%08x \t LTM global header",decodeStatus,*rawData));
263 //change decode status
264 decodeStatus = decodeStatus | LTM_BIT;
267 for (Int_t i = 0; i < LTM_DATA_WORDS; i++, iWord++, rawData++){
269 AliInfo(Form(" %02x - 0x%08x \t LTM data",decodeStatus,*rawData));
273 //TRM global header (slotID=3-12)
274 case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12:
275 //check decode status
276 if ( decodeStatus != TRM_HEADER_STATUS ){
277 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM global header",decodeStatus,*rawData));
281 //set TRM global header
282 fTRMGlobalHeader = (AliTOFTRMGlobalHeader *)rawData;
284 currentSlotID = fTRMGlobalHeader->GetSlotID();
285 currentACQ = fTRMGlobalHeader->GetACQBits();
287 AliInfo(Form(" %02x - 0x%08x \t TRM global header \t slotID=%02d ACQ=%01d L=%01d",decodeStatus,*rawData,fTRMGlobalHeader->GetSlotID(),fTRMGlobalHeader->GetACQBits(),fTRMGlobalHeader->GetLBit()));
288 //change decode status
289 decodeStatus = decodeStatus | TRM_BIT;
293 AliError(Form(" %02x - 0x%08x [ERROR] Not valid slotID in global header",decodeStatus,*rawData));
304 switch (*rawData & SLOT_ID_MASK){
306 //DRM global trailer (slotID=1)
308 //check decode status
309 if ( decodeStatus != DRM_TRAILER_STATUS ){
310 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected DRM global trailer",decodeStatus,*rawData));
315 AliInfo(Form(" %02x - 0x%08x \t DRM global trailer",decodeStatus,*rawData));
316 //change decode status
317 decodeStatus = decodeStatus & ~DRM_BIT;
320 //LTM global trailer (slotID=2)
322 //check decode status
323 if ( decodeStatus != LTM_TRAILER_STATUS ){
324 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected LTM global trailer",decodeStatus,*rawData));
329 AliInfo(Form(" %02x - 0x%08x \t LTM global trailer",decodeStatus,*rawData));
330 //change decode status
331 decodeStatus = decodeStatus & ~LTM_BIT;
334 //TRM global trailer (slotID=15)
336 //check decode status
337 if ( decodeStatus != TRM_TRAILER_STATUS ){
338 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM global trailer",decodeStatus,*rawData));
342 //set TRM global trailer
343 fTRMGlobalTrailer = (AliTOFTRMGlobalTrailer *)rawData;
345 AliInfo(Form(" %02x - 0x%08x \t TRM global trailer \t CRC=%04d eventCounter=%04d",decodeStatus,*rawData,fTRMGlobalTrailer->GetEventCRC(),fTRMGlobalTrailer->GetEventCounter()));
346 //change decode status
347 decodeStatus = decodeStatus & ~TRM_BIT;
351 AliError(Form(" %02x - 0x%08x [ERROR] Not valid slotID/pattern in global trailer",decodeStatus,*rawData));
358 //check decode status
359 if ( (decodeStatus != CHAIN_A_HEADER_STATUS) ){
360 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain A header",decodeStatus,*rawData));
364 fTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
366 currentBunchID = fTRMChainHeader->GetBunchID();
368 AliInfo(Form(" %02x - 0x%08x \t TRM chain A header \t chain=%01d bunchID=%04d",decodeStatus,*rawData,currentChain,currentBunchID));
369 //change decode status
370 decodeStatus = decodeStatus | CHAIN_A_BIT;
373 case CHAIN_A_TRAILER:
374 //check decode status
375 if ( decodeStatus != CHAIN_A_TRAILER_STATUS ){
376 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain A trailer",decodeStatus,*rawData));
381 AliInfo(Form(" %02x - 0x%08x \t TRM chain A trailer",decodeStatus,*rawData));
382 //change decode status
383 decodeStatus = decodeStatus & ~CHAIN_A_BIT;
387 //check decode status
388 if ( decodeStatus != CHAIN_B_HEADER_STATUS ){
389 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain B header",decodeStatus,*rawData));
393 fTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
395 currentBunchID = fTRMChainHeader->GetBunchID();
397 AliInfo(Form(" %02x - 0x%08x \t TRM chain B header \t chain=%01d bunchID=%04d",decodeStatus,*rawData,currentChain,currentBunchID));
398 //change decode status
399 decodeStatus = decodeStatus | CHAIN_B_BIT;
402 case CHAIN_B_TRAILER:
403 //check decode status
404 if ( decodeStatus != CHAIN_B_TRAILER_STATUS ){
405 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain B trailer",decodeStatus,*rawData));
410 AliInfo(Form(" %02x - 0x%08x \t TRM chain B trailer",decodeStatus,*rawData));
411 //change decode status
412 decodeStatus = decodeStatus & ~CHAIN_B_BIT;
417 AliInfo(Form(" %02x - 0x%08x \t TDC error",decodeStatus,*rawData));
422 AliInfo(Form(" %02x - 0x%08x \t Filler",decodeStatus,*rawData));
426 //check decode status
427 if ( decodeStatus != CHAIN_A_TDC_HIT_STATUS &&
428 decodeStatus != CHAIN_B_TDC_HIT_STATUS ){
429 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected or unknown word",decodeStatus,*rawData));
437 case PACKING_ENABLED_ACQ:
438 //decode TDC packed hit
439 fTDCPackedHit = (AliTOFTDCPackedHit *)rawData;
440 fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
441 //set hit in the equipment data
442 hitData.SetDDLID(currentDDL);
443 hitData.SetSlotID(currentSlotID);
444 hitData.SetACQ(currentACQ);
445 hitData.SetChain(currentChain);
446 hitData.SetPS(fTDCPackedHit->GetPSBits());
447 hitData.SetTDC(fTDCPackedHit->GetTDCID());
448 hitData.SetChan(fTDCPackedHit->GetChan());
449 hitData.SetTime((float)fTDCPackedHit->GetHitTime() * TIME_BIN_WIDTH);
450 hitData.SetTimeBin(fTDCPackedHit->GetHitTime());
451 hitData.SetTOT((float)fTDCPackedHit->GetTOTWidth() * TOT_BIN_WIDTH);
452 hitData.SetTOTBin(fTDCPackedHit->GetTOTWidth());
453 //orphane leading hit
454 if (hitData.GetPS()==LEADING_HIT_PS){
455 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
456 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
459 hitData.SetTOTBin(0);
460 //push hit data in packed data buffer
461 if (fPackedDataBuffer != 0x0)
462 fPackedDataBuffer->Add(hitData);
463 //set TOT to not measured
465 hitData.SetTOTBin(-1);
466 //push hit data in packed data buffer
467 if (fDataBuffer != 0x0)
468 fDataBuffer->Add(hitData);
470 //orphane trailing hit
471 else if (hitData.GetPS()==TRAILING_HIT_PS){
472 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
473 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
474 //set TOT to not measured
476 hitData.SetTOTBin(-1);
477 //push hit data in data buffer
478 if (fDataBuffer != 0x0)
479 fDataBuffer->Add(hitData);
483 //push hit data in packed data buffer
484 if (fPackedDataBuffer != 0x0)
485 fPackedDataBuffer->Add(hitData);
487 tempPS = hitData.GetPS();
489 tempTOT = hitData.GetTOT();
490 tempTOTBin = hitData.GetTOTBin();
491 //unpack the hit: leading hit
492 hitData.SetPS(LEADING_HIT_PS);
493 //set TOT to not measured
495 hitData.SetTOTBin(-1);
496 //push leading hit data in data buffer
497 if (fDataBuffer != 0x0)
498 fDataBuffer->Add(hitData);
499 //unpack the hit: trailing hit
500 hitData.SetPS(TRAILING_HIT_PS);
501 hitData.SetTime(hitData.GetTime() + tempTOT);
502 hitData.SetTimeBin(hitData.GetTimeBin() + (Int_t)(tempTOTBin * TOT_TO_TIME_BIN_WIDTH));
503 //push trailing hit data in data buffer
504 if (fDataBuffer != 0x0)
505 fDataBuffer->Add(hitData);
507 hitData.SetPS(tempPS);
508 hitData.SetTime(hitData.GetTime() - tempTOT);
509 hitData.SetTimeBin(hitData.GetTimeBin() - (Int_t)(tempTOTBin * TOT_TO_TIME_BIN_WIDTH));
510 hitData.SetTOT(tempTOT);
511 hitData.SetTOTBin(tempTOTBin);
515 switch (hitData.GetPS()){
517 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()));
520 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()));
522 case TRAILING_HIT_PS:
523 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()));
526 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()));
531 case LEADING_ONLY_ACQ: case TRAILING_ONLY_ACQ:
532 //decode TDC unpacked hit
533 fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
534 //set hit in the equipment data
535 hitData.SetDDLID(currentDDL);
536 hitData.SetSlotID(currentSlotID);
537 hitData.SetACQ(currentACQ);
538 hitData.SetChain(currentChain);
539 hitData.SetPS(fTDCUnpackedHit->GetPSBits());
540 hitData.SetTDC(fTDCUnpackedHit->GetTDCID());
541 hitData.SetChan(fTDCUnpackedHit->GetChan());
542 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
543 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
545 hitData.SetTOTBin(-1);
546 //push hit data in data buffer
547 if (fDataBuffer != 0x0)
548 fDataBuffer->Add(hitData);
551 switch (hitData.GetPS()){
553 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()));
556 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()));
558 case TRAILING_HIT_PS:
559 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()));
562 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()));
567 case PACKING_DISABLED_ACQ:
568 //decode TDC unpacked hit
569 fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
570 //set hit in the equipment data
571 hitData.SetDDLID(currentDDL);
572 hitData.SetSlotID(currentSlotID);
573 hitData.SetACQ(currentACQ);
574 hitData.SetChain(currentChain);
575 hitData.SetPS(fTDCUnpackedHit->GetPSBits());
576 hitData.SetTDC(fTDCUnpackedHit->GetTDCID());
577 hitData.SetChan(fTDCUnpackedHit->GetChan());
578 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
579 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
581 hitData.SetTOTBin(-1);
582 //push hit data in data buffer
583 if (fDataBuffer != 0x0)
584 fDataBuffer->Add(hitData);
587 switch (hitData.GetPS()){
589 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()));
592 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()));
594 case TRAILING_HIT_PS:
595 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()));
598 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()));
601 //call spider function
603 AliInfo("Calling SPIDER function");
611 //end switch word type
614 //end equipment data loop
617 AliInfo("End of data loop");
620 AliInfo("Reset SPIDER function");
621 status = ResetSpider();
624 AliInfo("Decoder is exiting succesfully.");
629 //_________________________________________________________________
632 AliTOFDecoder::InitializeSpider(){
634 /* SPIDER initialization routine.
635 it initializes SPIDER variables in order
636 to have SPIDER ready to pack tof data
637 in packed data objects
641 AliInfo("Initializing SPIDER");
643 fSpiderCurrentSlotID=-1;
644 fSpiderCurrentChain=-1;
645 fSpiderCurrentTDC=-1;
647 for (Int_t chan=0;chan<N_CHANNEL;chan++)
648 fSpiderLeadingFlag[chan] = kFALSE;
653 //_________________________________________________________________
656 AliTOFDecoder::ResetSpider(){
658 /* SPIDER reset routine.
659 it resets SPIDER buffers and
660 variables in order to empty full
661 buffers a set up SIPDER for new
666 AliInfo("Resetting SPIDER buffers");
668 for (Int_t chan=0;chan<N_CHANNEL;chan++){
669 if (fSpiderLeadingFlag[chan]){
671 AliInfo("Buffer non empty: put leading hit into buffer as orphane");
673 fSpiderLeadingHit[chan].SetACQ(4);
674 fSpiderLeadingHit[chan].SetPS(1);
675 fSpiderLeadingHit[chan].SetTOT(0);
676 fSpiderLeadingHit[chan].SetTOTBin(0);
677 //push hit into packed buffer
678 if (fPackedDataBuffer != 0x0)
679 fPackedDataBuffer->Add(fSpiderLeadingHit[chan]);
681 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()));
684 fSpiderLeadingFlag[chan]=kFALSE;
690 //_________________________________________________________________
693 AliTOFDecoder::Spider(AliTOFHitData hitData){
695 /* main SPIDER routine.
696 it receives, reads, stores and packs
697 unpacked HPTDC data in packed data
698 object. it also fills buffers.
704 AliInfo("Hit data received");
706 //check if TDC is changed (slotID,chain,TDC triplet)
707 if (fSpiderCurrentSlotID!=hitData.GetSlotID() ||
708 fSpiderCurrentChain!=hitData.GetChain() ||
709 fSpiderCurrentTDC!=hitData.GetTDC() ){
711 AliInfo("Data coming from a new TDC: reset buffers");
713 status = ResetSpider();
715 fSpiderCurrentSlotID=hitData.GetSlotID();
716 fSpiderCurrentChain=hitData.GetChain();
717 fSpiderCurrentTDC=hitData.GetTDC();
721 switch (hitData.GetPS()){
725 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()));
726 //check spider leading flag
727 if (fSpiderLeadingFlag[hitData.GetChan()]){
729 AliInfo("Leading hit: buffer full, put previous in buffers as orphane and keep current");
730 //set TOT at zero for previous hit
731 fSpiderLeadingHit[hitData.GetChan()].SetACQ(4);
732 fSpiderLeadingHit[hitData.GetChan()].SetPS(1);
733 fSpiderLeadingHit[hitData.GetChan()].SetTOT(0);
734 fSpiderLeadingHit[hitData.GetChan()].SetTOTBin(0);
735 //push previous hit into packed buffer
736 if (fPackedDataBuffer != 0x0)
737 fPackedDataBuffer->Add(fSpiderLeadingHit[hitData.GetChan()]);
739 fSpiderLeadingHit[hitData.GetChan()]=hitData;
741 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()));
745 AliInfo("Leading hit: buffer empty, keep current hit and set flag");
746 fSpiderLeadingHit[hitData.GetChan()]=hitData;
747 //set spider leading flag
748 fSpiderLeadingFlag[hitData.GetChan()]=kTRUE;
752 case TRAILING_HIT_PS:
754 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()));
755 //check spider leading flag
756 if (fSpiderLeadingFlag[hitData.GetChan()]){
758 AliInfo("Trailing hit: buffer full, pack leading and trailing");
761 hitData.SetTOT(hitData.GetTime()-fSpiderLeadingHit[hitData.GetChan()].GetTime());
762 hitData.SetTOTBin((Int_t)((hitData.GetTimeBin()-fSpiderLeadingHit[hitData.GetChan()].GetTimeBin())*TIME_TO_TOT_BIN_WIDTH));
763 hitData.SetTime(fSpiderLeadingHit[hitData.GetChan()].GetTime());
764 hitData.SetTimeBin(fSpiderLeadingHit[hitData.GetChan()].GetTimeBin());
765 //check TOT and set TOT overflow if TOT < 0
766 if (hitData.GetTOT() < 0){
769 hitData.SetTOTBin(0);
771 if (fPackedDataBuffer != 0x0)
772 fPackedDataBuffer->Add(hitData);
774 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()));
775 //unset spider leading flag
776 fSpiderLeadingFlag[hitData.GetChan()]=kFALSE;
780 AliInfo("Trailing hit: buffer empty, throw hit away");
788 //_____________________________________________________________________________
789 void AliTOFDecoder::GetArrayDDL(Int_t* array, Int_t ddl){
791 // method that fills array with the
792 // TOF channels indexes corresponding
795 AliTOFGeometry *geom = new AliTOFGeometry();
796 Int_t indexDDL = ddl%4;
797 Int_t iSector = Int_t(ddl/4);
798 //AliInfo(Form(" Sector = %i, DDL within sector = %i",iSector, indexDDL));
800 AliInfo(Form(" Sector = %i, DDL within sector = %i",iSector, indexDDL));
804 Int_t minPlate=0, maxPlate=0, minStrip2=0, maxStrip2=0, minPadz=0, maxPadz=0, minPadx=0, maxPadx=0;
809 minStrip2=kMinStrip0;
810 maxStrip2=kMaxStrip0;
817 else if (indexDDL==1){
820 minStrip2=kMinStrip1;
821 maxStrip2=kMaxStrip1;
828 else if (indexDDL==2){
831 minStrip2=kMinStrip2;
832 maxStrip2=kMaxStrip2;
839 else if (indexDDL==3){
842 minStrip2=kMinStrip3;
843 maxStrip2=kMaxStrip3;
854 for (Int_t iPlate=minPlate;iPlate<=maxPlate;iPlate++){
856 maxStrip = maxStrip2;
857 minStrip = minStrip2;
863 for (Int_t iStrip=minStrip;iStrip<=maxStrip;iStrip++){
864 for (Int_t iPadz=minPadz;iPadz<=maxPadz;iPadz++){
865 for (Int_t iPadx=minPadx;iPadx<=maxPadx;iPadx++){
871 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]));
873 if (indexDDL==0 || indexDDL==2){
874 array[ichTOF]=geom->GetIndex(volume);
876 AliInfo(Form(" ichTOF = %i, TOFChannel = %i",ichTOF,array[ichTOF]));
880 array[ichTOF]=geom->GetIndex(volume);
882 AliInfo(Form(" ichTOF = %i, TOFChannel = %i",ichTOF,array[ichTOF]));
890 //AliInfo(Form("ichTOF = %i",ichTOF));
891 if (((indexDDL==0 || indexDDL==2)&ichTOF!=2160) || ((indexDDL==1 || indexDDL==3)&ichTOF!=2208)){
892 AliWarning(Form("Something strange occurred, number of entries in array different from expected! Please, check! ichTOF = %i",ichTOF));