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"
52 #include "AliRawDataHeader.h"
54 ClassImp(AliTOFDecoder)
56 //_________________________________________________________________
58 AliTOFDecoder::AliTOFDecoder() :
63 fPackedDataBuffer(0x0),
64 fTRMGlobalHeader(0x0),
65 fTRMGlobalTrailer(0x0),
67 fTRMChainTrailer(0x0),
71 fTRMDiagnosticErrorWord1(0x0),
72 fTRMDiagnosticErrorWord2(0x0),
73 fSpiderCurrentSlotID(-1),
74 fSpiderCurrentChain(-1),
80 //_________________________________________________________________
82 AliTOFDecoder::AliTOFDecoder(AliTOFHitDataBuffer *DataBuffer, AliTOFHitDataBuffer *PackedDataBuffer) :
86 fDataBuffer(DataBuffer),
87 fPackedDataBuffer(PackedDataBuffer),
88 fTRMGlobalHeader(0x0),
89 fTRMGlobalTrailer(0x0),
91 fTRMChainTrailer(0x0),
95 fTRMDiagnosticErrorWord1(0x0),
96 fTRMDiagnosticErrorWord2(0x0),
97 fSpiderCurrentSlotID(-1),
98 fSpiderCurrentChain(-1),
101 //another constructor
104 //_________________________________________________________________
106 AliTOFDecoder::AliTOFDecoder(const AliTOFDecoder &source) :
111 fPackedDataBuffer(0x0),
112 fTRMGlobalHeader(0x0),
113 fTRMGlobalTrailer(0x0),
114 fTRMChainHeader(0x0),
115 fTRMChainTrailer(0x0),
117 fTDCUnpackedHit(0x0),
119 fTRMDiagnosticErrorWord1(0x0),
120 fTRMDiagnosticErrorWord2(0x0),
121 fSpiderCurrentSlotID(-1),
122 fSpiderCurrentChain(-1),
123 fSpiderCurrentTDC(-1)
127 this->fVerbose = source.fVerbose;
128 this->fV2718Patch = source.fV2718Patch;
129 this->fDataBuffer = source.fDataBuffer;
130 this->fPackedDataBuffer = source.fPackedDataBuffer;
131 this->fTRMGlobalHeader = source.fTRMGlobalHeader;
132 this->fTRMGlobalTrailer = source.fTRMGlobalTrailer;
133 this->fTRMChainHeader = source.fTRMChainHeader;
134 this->fTRMChainTrailer = source.fTRMChainTrailer;
135 this->fTDCPackedHit = source.fTDCPackedHit;
136 this->fTDCUnpackedHit = source.fTDCUnpackedHit;
137 this->fTRMTDCError = source.fTRMTDCError;
138 this->fTRMDiagnosticErrorWord1 = source.fTRMDiagnosticErrorWord1;
139 this->fTRMDiagnosticErrorWord2 = source.fTRMDiagnosticErrorWord2;
140 this->fSpiderCurrentSlotID = source.fSpiderCurrentSlotID;
141 this->fSpiderCurrentChain = source.fSpiderCurrentChain;
142 this->fSpiderCurrentTDC = source.fSpiderCurrentTDC;
145 //_________________________________________________________________
148 AliTOFDecoder::operator = (const AliTOFDecoder &source)
152 this->fVerbose = source.fVerbose;
153 this->fV2718Patch = source.fV2718Patch;
154 this->fDataBuffer = source.fDataBuffer;
155 this->fPackedDataBuffer = source.fPackedDataBuffer;
156 this->fTRMGlobalHeader = source.fTRMGlobalHeader;
157 this->fTRMGlobalTrailer = source.fTRMGlobalTrailer;
158 this->fTRMChainHeader = source.fTRMChainHeader;
159 this->fTRMChainTrailer = source.fTRMChainTrailer;
160 this->fTDCPackedHit = source.fTDCPackedHit;
161 this->fTDCUnpackedHit = source.fTDCUnpackedHit;
162 this->fTRMTDCError = source.fTRMTDCError;
163 this->fTRMDiagnosticErrorWord1 = source.fTRMDiagnosticErrorWord1;
164 this->fTRMDiagnosticErrorWord2 = source.fTRMDiagnosticErrorWord2;
165 this->fSpiderCurrentSlotID = source.fSpiderCurrentSlotID;
166 this->fSpiderCurrentChain = source.fSpiderCurrentChain;
167 this->fSpiderCurrentTDC = source.fSpiderCurrentTDC;
171 AliTOFDecoder::~AliTOFDecoder()
174 //_________________________________________________________________
177 AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh)
179 /* main decoding routine.
180 * it loops over nWords 32-bit words
181 * starting at *rawData and decodes them.
182 * it also fills some buffers in order to
183 * have the decoded data available for other
187 AliTOFHitData hitData;
192 Float_t tempTOT; //ns
193 Int_t tempTOTBin; //TOT_BIN_WIDTH
196 UShort_t decodeStatus = 0x0;
197 Short_t currentDDL = -1;
198 Short_t currentSlotID = -1;
199 Short_t currentACQ = -1;
200 Short_t currentChain = -1;
201 Short_t currentBunchID = -1;
202 Short_t currentMiniEventID = cdh ? cdh->GetMiniEventID() : (Short_t)-1;
204 AliWarning("CDH not valid: deltaBunchID not reliable ");
206 /*** V2718 patch ***/
208 decodeStatus = decodeStatus | DRM_BIT;
210 AliInfo("DRM not present: - V2718 patch decoding -");
212 /*** V2718 patch ***/
215 AliInfo("Initialize SPIDER function");
216 status = InitializeSpider();
219 AliInfo("Start decoding");
222 AliInfo("Loop over the data and decode");
225 AliInfo(" St Hex Word \t Decoded Word");
228 for (Int_t iWord = 0; iWord < nWords; iWord++, rawData++){
231 switch (*rawData & WORD_TYPE_MASK){
236 switch (*rawData & SLOT_ID_MASK){
238 //DRM global header (slotID=1)
240 //check decode status
241 if ( decodeStatus != DRM_HEADER_STATUS ){
242 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected DRM global header",decodeStatus,*rawData));
247 AliInfo(Form(" %02x - 0x%08x \t DRM global header",decodeStatus,*rawData));
248 //change decode status
249 decodeStatus = decodeStatus | DRM_BIT;
252 for (Int_t i = 0; i < DRM_DATA_WORDS; i++, iWord++, rawData++){
254 AliInfo(Form(" %02x - 0x%08x \t DRM data",decodeStatus,*rawData));
258 //LTM global header (slotID=2)
260 //check decode status
261 if ( decodeStatus != LTM_HEADER_STATUS ){
262 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected LTM global header",decodeStatus,*rawData));
267 AliInfo(Form(" %02x - 0x%08x \t LTM global header",decodeStatus,*rawData));
268 //change decode status
269 decodeStatus = decodeStatus | LTM_BIT;
272 for (Int_t i = 0; i < LTM_DATA_WORDS; i++, iWord++, rawData++){
274 AliInfo(Form(" %02x - 0x%08x \t LTM data",decodeStatus,*rawData));
278 //TRM global header (slotID=3-12)
279 case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12:
280 //check decode status
281 if ( decodeStatus != TRM_HEADER_STATUS ){
282 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM global header",decodeStatus,*rawData));
286 //set TRM global header
287 fTRMGlobalHeader = (AliTOFTRMGlobalHeader *)rawData;
289 currentSlotID = fTRMGlobalHeader->GetSlotID();
290 currentACQ = fTRMGlobalHeader->GetACQBits();
292 AliInfo(Form(" %02x - 0x%08x \t TRM global header \t slotID=%02d ACQ=%01d L=%01d",decodeStatus,*rawData,fTRMGlobalHeader->GetSlotID(),fTRMGlobalHeader->GetACQBits(),fTRMGlobalHeader->GetLBit()));
293 //change decode status
294 decodeStatus = decodeStatus | TRM_BIT;
298 AliError(Form(" %02x - 0x%08x [ERROR] Not valid slotID in global header",decodeStatus,*rawData));
309 switch (*rawData & SLOT_ID_MASK){
311 //DRM global trailer (slotID=1)
313 //check decode status
314 if ( decodeStatus != DRM_TRAILER_STATUS ){
315 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected DRM global trailer",decodeStatus,*rawData));
320 AliInfo(Form(" %02x - 0x%08x \t DRM global trailer",decodeStatus,*rawData));
321 //change decode status
322 decodeStatus = decodeStatus & ~DRM_BIT;
325 //LTM global trailer (slotID=2)
327 //check decode status
328 if ( decodeStatus != LTM_TRAILER_STATUS ){
329 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected LTM global trailer",decodeStatus,*rawData));
334 AliInfo(Form(" %02x - 0x%08x \t LTM global trailer",decodeStatus,*rawData));
335 //change decode status
336 decodeStatus = decodeStatus & ~LTM_BIT;
339 //TRM global trailer (slotID=15)
341 //check decode status
342 if ( decodeStatus != TRM_TRAILER_STATUS ){
343 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM global trailer",decodeStatus,*rawData));
347 //set TRM global trailer
348 fTRMGlobalTrailer = (AliTOFTRMGlobalTrailer *)rawData;
350 AliInfo(Form(" %02x - 0x%08x \t TRM global trailer \t CRC=%04d eventCounter=%04d",decodeStatus,*rawData,fTRMGlobalTrailer->GetEventCRC(),fTRMGlobalTrailer->GetEventCounter()));
351 //change decode status
352 decodeStatus = decodeStatus & ~TRM_BIT;
356 AliError(Form(" %02x - 0x%08x [ERROR] Not valid slotID/pattern in global trailer",decodeStatus,*rawData));
363 //check decode status
364 if ( (decodeStatus != CHAIN_A_HEADER_STATUS) ){
365 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain A header",decodeStatus,*rawData));
369 fTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
371 currentBunchID = fTRMChainHeader->GetBunchID();
373 AliInfo(Form(" %02x - 0x%08x \t TRM chain A header \t chain=%01d bunchID=%04d",decodeStatus,*rawData,currentChain,currentBunchID));
374 //change decode status
375 decodeStatus = decodeStatus | CHAIN_A_BIT;
378 case CHAIN_A_TRAILER:
379 //check decode status
380 if ( decodeStatus != CHAIN_A_TRAILER_STATUS ){
381 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain A trailer",decodeStatus,*rawData));
386 AliInfo(Form(" %02x - 0x%08x \t TRM chain A trailer",decodeStatus,*rawData));
387 //change decode status
388 decodeStatus = decodeStatus & ~CHAIN_A_BIT;
392 //check decode status
393 if ( decodeStatus != CHAIN_B_HEADER_STATUS ){
394 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain B header",decodeStatus,*rawData));
398 fTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
400 currentBunchID = fTRMChainHeader->GetBunchID();
402 AliInfo(Form(" %02x - 0x%08x \t TRM chain B header \t chain=%01d bunchID=%04d",decodeStatus,*rawData,currentChain,currentBunchID));
403 //change decode status
404 decodeStatus = decodeStatus | CHAIN_B_BIT;
407 case CHAIN_B_TRAILER:
408 //check decode status
409 if ( decodeStatus != CHAIN_B_TRAILER_STATUS ){
410 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain B trailer",decodeStatus,*rawData));
415 AliInfo(Form(" %02x - 0x%08x \t TRM chain B trailer",decodeStatus,*rawData));
416 //change decode status
417 decodeStatus = decodeStatus & ~CHAIN_B_BIT;
422 AliInfo(Form(" %02x - 0x%08x \t TDC error",decodeStatus,*rawData));
427 AliInfo(Form(" %02x - 0x%08x \t Filler",decodeStatus,*rawData));
431 //check decode status
432 if ( decodeStatus != CHAIN_A_TDC_HIT_STATUS &&
433 decodeStatus != CHAIN_B_TDC_HIT_STATUS ){
434 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected or unknown word",decodeStatus,*rawData));
442 case PACKING_ENABLED_ACQ:
443 //decode TDC packed hit
444 fTDCPackedHit = (AliTOFTDCPackedHit *)rawData;
445 fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
446 //set hit in the equipment data
447 hitData.SetDDLID(currentDDL);
448 hitData.SetSlotID(currentSlotID);
449 hitData.SetACQ(currentACQ);
450 hitData.SetChain(currentChain);
451 hitData.SetPS(fTDCPackedHit->GetPSBits());
452 hitData.SetTDC(fTDCPackedHit->GetTDCID());
453 hitData.SetChan(fTDCPackedHit->GetChan());
454 hitData.SetTime((float)fTDCPackedHit->GetHitTime() * TIME_BIN_WIDTH);
455 hitData.SetTimeBin(fTDCPackedHit->GetHitTime());
456 hitData.SetTOT((float)fTDCPackedHit->GetTOTWidth() * TOT_BIN_WIDTH);
457 hitData.SetTOTBin(fTDCPackedHit->GetTOTWidth());
458 hitData.SetDeltaBunchID(currentBunchID - currentMiniEventID);
459 //orphane leading hit
460 if (hitData.GetPS()==LEADING_HIT_PS){
461 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
462 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
465 hitData.SetTOTBin(0);
466 //push hit data in packed data buffer
467 if (fPackedDataBuffer != 0x0)
468 fPackedDataBuffer->Add(hitData);
469 //set TOT to not measured
471 hitData.SetTOTBin(-1);
472 //push hit data in packed data buffer
473 if (fDataBuffer != 0x0)
474 fDataBuffer->Add(hitData);
476 //orphane trailing hit
477 else if (hitData.GetPS()==TRAILING_HIT_PS){
478 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
479 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
480 //set TOT to not measured
482 hitData.SetTOTBin(-1);
483 //push hit data in data buffer
484 if (fDataBuffer != 0x0)
485 fDataBuffer->Add(hitData);
489 //push hit data in packed data buffer
490 if (fPackedDataBuffer != 0x0)
491 fPackedDataBuffer->Add(hitData);
493 tempPS = hitData.GetPS();
495 tempTOT = hitData.GetTOT();
496 tempTOTBin = hitData.GetTOTBin();
497 //unpack the hit: leading hit
498 hitData.SetPS(LEADING_HIT_PS);
499 //set TOT to not measured
501 hitData.SetTOTBin(-1);
502 //push leading hit data in data buffer
503 if (fDataBuffer != 0x0)
504 fDataBuffer->Add(hitData);
505 //unpack the hit: trailing hit
506 hitData.SetPS(TRAILING_HIT_PS);
507 hitData.SetTime(hitData.GetTime() + tempTOT);
508 hitData.SetTimeBin(hitData.GetTimeBin() + (Int_t)(tempTOTBin * TOT_TO_TIME_BIN_WIDTH));
509 //push trailing hit data in data buffer
510 if (fDataBuffer != 0x0)
511 fDataBuffer->Add(hitData);
513 hitData.SetPS(tempPS);
514 hitData.SetTime(hitData.GetTime() - tempTOT);
515 hitData.SetTimeBin(hitData.GetTimeBin() - (Int_t)(tempTOTBin * TOT_TO_TIME_BIN_WIDTH));
516 hitData.SetTOT(tempTOT);
517 hitData.SetTOTBin(tempTOTBin);
521 switch (hitData.GetPS()){
523 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()));
526 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()));
528 case TRAILING_HIT_PS:
529 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()));
532 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()));
537 case LEADING_ONLY_ACQ: case TRAILING_ONLY_ACQ:
538 //decode TDC unpacked hit
539 fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
540 //set hit in the equipment data
541 hitData.SetDDLID(currentDDL);
542 hitData.SetSlotID(currentSlotID);
543 hitData.SetACQ(currentACQ);
544 hitData.SetChain(currentChain);
545 hitData.SetPS(fTDCUnpackedHit->GetPSBits());
546 hitData.SetTDC(fTDCUnpackedHit->GetTDCID());
547 hitData.SetChan(fTDCUnpackedHit->GetChan());
548 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
549 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
551 hitData.SetTOTBin(-1);
552 hitData.SetDeltaBunchID(currentBunchID - currentMiniEventID);
553 //push hit data in data buffer
554 if (fDataBuffer != 0x0)
555 fDataBuffer->Add(hitData);
558 switch (hitData.GetPS()){
560 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()));
563 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()));
565 case TRAILING_HIT_PS:
566 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()));
569 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()));
574 case PACKING_DISABLED_ACQ:
575 //decode TDC unpacked hit
576 fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
577 //set hit in the equipment data
578 hitData.SetDDLID(currentDDL);
579 hitData.SetSlotID(currentSlotID);
580 hitData.SetACQ(currentACQ);
581 hitData.SetChain(currentChain);
582 hitData.SetPS(fTDCUnpackedHit->GetPSBits());
583 hitData.SetTDC(fTDCUnpackedHit->GetTDCID());
584 hitData.SetChan(fTDCUnpackedHit->GetChan());
585 hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
586 hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
588 hitData.SetTOTBin(-1);
589 hitData.SetDeltaBunchID(currentBunchID - currentMiniEventID);
590 //push hit data in data buffer
591 if (fDataBuffer != 0x0)
592 fDataBuffer->Add(hitData);
595 switch (hitData.GetPS()){
597 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()));
600 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()));
602 case TRAILING_HIT_PS:
603 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()));
606 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()));
609 //call spider function
611 AliInfo("Calling SPIDER function");
619 //end switch word type
622 //end equipment data loop
625 AliInfo("End of data loop");
628 AliInfo("Reset SPIDER function");
629 status = ResetSpider();
632 AliInfo("Decoder is exiting succesfully.");
637 //_________________________________________________________________
640 AliTOFDecoder::InitializeSpider(){
642 /* SPIDER initialization routine.
643 it initializes SPIDER variables in order
644 to have SPIDER ready to pack tof data
645 in packed data objects
649 AliInfo("Initializing SPIDER");
651 fSpiderCurrentSlotID=-1;
652 fSpiderCurrentChain=-1;
653 fSpiderCurrentTDC=-1;
655 for (Int_t chan=0;chan<N_CHANNEL;chan++)
656 fSpiderLeadingFlag[chan] = kFALSE;
661 //_________________________________________________________________
664 AliTOFDecoder::ResetSpider(){
666 /* SPIDER reset routine.
667 it resets SPIDER buffers and
668 variables in order to empty full
669 buffers a set up SIPDER for new
674 AliInfo("Resetting SPIDER buffers");
676 for (Int_t chan=0;chan<N_CHANNEL;chan++){
677 if (fSpiderLeadingFlag[chan]){
679 AliInfo("Buffer non empty: put leading hit into buffer as orphane");
681 fSpiderLeadingHit[chan].SetACQ(4);
682 fSpiderLeadingHit[chan].SetPS(1);
683 fSpiderLeadingHit[chan].SetTOT(0);
684 fSpiderLeadingHit[chan].SetTOTBin(0);
685 //push hit into packed buffer
686 if (fPackedDataBuffer != 0x0)
687 fPackedDataBuffer->Add(fSpiderLeadingHit[chan]);
689 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()));
692 fSpiderLeadingFlag[chan]=kFALSE;
698 //_________________________________________________________________
701 AliTOFDecoder::Spider(AliTOFHitData &hitData){
703 /* main SPIDER routine.
704 it receives, reads, stores and packs
705 unpacked HPTDC data in packed data
706 object. it also fills buffers.
712 AliInfo("Hit data received");
714 //check if TDC is changed (slotID,chain,TDC triplet)
715 if (fSpiderCurrentSlotID!=hitData.GetSlotID() ||
716 fSpiderCurrentChain!=hitData.GetChain() ||
717 fSpiderCurrentTDC!=hitData.GetTDC() ){
719 AliInfo("Data coming from a new TDC: reset buffers");
721 status = ResetSpider();
723 fSpiderCurrentSlotID=hitData.GetSlotID();
724 fSpiderCurrentChain=hitData.GetChain();
725 fSpiderCurrentTDC=hitData.GetTDC();
729 switch (hitData.GetPS()){
733 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()));
734 //check spider leading flag
735 if (fSpiderLeadingFlag[hitData.GetChan()]){
737 AliInfo("Leading hit: buffer full, put previous in buffers as orphane and keep current");
738 //set TOT at zero for previous hit
739 fSpiderLeadingHit[hitData.GetChan()].SetACQ(4);
740 fSpiderLeadingHit[hitData.GetChan()].SetPS(1);
741 fSpiderLeadingHit[hitData.GetChan()].SetTOT(0);
742 fSpiderLeadingHit[hitData.GetChan()].SetTOTBin(0);
743 //push previous hit into packed buffer
744 if (fPackedDataBuffer != 0x0)
745 fPackedDataBuffer->Add(fSpiderLeadingHit[hitData.GetChan()]);
747 fSpiderLeadingHit[hitData.GetChan()]=hitData;
749 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()));
753 AliInfo("Leading hit: buffer empty, keep current hit and set flag");
754 fSpiderLeadingHit[hitData.GetChan()]=hitData;
755 //set spider leading flag
756 fSpiderLeadingFlag[hitData.GetChan()]=kTRUE;
760 case TRAILING_HIT_PS:
762 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()));
763 //check spider leading flag
764 if (fSpiderLeadingFlag[hitData.GetChan()]){
766 AliInfo("Trailing hit: buffer full, pack leading and trailing");
769 hitData.SetTOT(hitData.GetTime()-fSpiderLeadingHit[hitData.GetChan()].GetTime());
770 hitData.SetTOTBin((Int_t)((hitData.GetTimeBin()-fSpiderLeadingHit[hitData.GetChan()].GetTimeBin())*TIME_TO_TOT_BIN_WIDTH));
771 hitData.SetTime(fSpiderLeadingHit[hitData.GetChan()].GetTime());
772 hitData.SetTimeBin(fSpiderLeadingHit[hitData.GetChan()].GetTimeBin());
773 //check TOT and set TOT overflow if TOT < 0
774 if (hitData.GetTOT() < 0){
777 hitData.SetTOTBin(0);
779 if (fPackedDataBuffer != 0x0)
780 fPackedDataBuffer->Add(hitData);
782 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()));
783 //unset spider leading flag
784 fSpiderLeadingFlag[hitData.GetChan()]=kFALSE;
788 AliInfo("Trailing hit: buffer empty, throw hit away");
796 //_____________________________________________________________________________
797 void AliTOFDecoder::GetArrayDDL(Int_t* array, Int_t ddl){
799 // method that fills array with the
800 // TOF channels indexes corresponding
803 AliTOFGeometry *geom = new AliTOFGeometry();
804 Int_t indexDDL = ddl%4;
805 Int_t iSector = Int_t(ddl/4);
806 //AliInfo(Form(" Sector = %i, DDL within sector = %i",iSector, indexDDL));
808 AliInfo(Form(" Sector = %i, DDL within sector = %i",iSector, indexDDL));
812 Int_t minPlate=0, maxPlate=0, minStrip2=0, maxStrip2=0, minPadz=0, maxPadz=0, minPadx=0, maxPadx=0;
817 minStrip2=kMinStrip0;
818 maxStrip2=kMaxStrip0;
825 else if (indexDDL==1){
828 minStrip2=kMinStrip1;
829 maxStrip2=kMaxStrip1;
836 else if (indexDDL==2){
839 minStrip2=kMinStrip2;
840 maxStrip2=kMaxStrip2;
847 else if (indexDDL==3){
850 minStrip2=kMinStrip3;
851 maxStrip2=kMaxStrip3;
862 for (Int_t iPlate=minPlate;iPlate<=maxPlate;iPlate++){
864 maxStrip = maxStrip2;
865 minStrip = minStrip2;
871 for (Int_t iStrip=minStrip;iStrip<=maxStrip;iStrip++){
872 for (Int_t iPadz=minPadz;iPadz<=maxPadz;iPadz++){
873 for (Int_t iPadx=minPadx;iPadx<=maxPadx;iPadx++){
879 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]));
881 if (indexDDL==0 || indexDDL==2){
882 array[ichTOF]=geom->GetIndex(volume);
884 AliInfo(Form(" ichTOF = %i, TOFChannel = %i",ichTOF,array[ichTOF]));
888 array[ichTOF]=geom->GetIndex(volume);
890 AliInfo(Form(" ichTOF = %i, TOFChannel = %i",ichTOF,array[ichTOF]));
898 //AliInfo(Form("ichTOF = %i",ichTOF));
899 if (((indexDDL==0 || indexDDL==2)&ichTOF!=2160) || ((indexDDL==1 || indexDDL==3)&ichTOF!=2208)){
900 AliWarning(Form("Something strange occurred, number of entries in array different from expected! Please, check! ichTOF = %i",ichTOF));