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"
53 #include "AliTOFRawDataFormat.h"
55 ClassImp(AliTOFDecoder)
57 //_________________________________________________________________
59 AliTOFDecoder::AliTOFDecoder() :
64 fPackedDataBuffer(0x0),
65 //fTRMGlobalHeader(0x0),
66 //fTRMGlobalTrailer(0x0),
67 //fTRMChainHeader(0x0),
68 //fTRMChainTrailer(0x0),
70 //fTDCUnpackedHit(0x0),
72 //fTRMDiagnosticErrorWord1(0x0),
73 //fTRMDiagnosticErrorWord2(0x0),
74 fSpiderCurrentSlotID(-1),
75 fSpiderCurrentChain(-1),
81 //_________________________________________________________________
83 AliTOFDecoder::AliTOFDecoder(AliTOFHitDataBuffer *DataBuffer, AliTOFHitDataBuffer *PackedDataBuffer) :
87 fDataBuffer(DataBuffer),
88 fPackedDataBuffer(PackedDataBuffer),
89 //fTRMGlobalHeader(0x0),
90 //fTRMGlobalTrailer(0x0),
91 //fTRMChainHeader(0x0),
92 //fTRMChainTrailer(0x0),
94 //fTDCUnpackedHit(0x0),
96 //fTRMDiagnosticErrorWord1(0x0),
97 //fTRMDiagnosticErrorWord2(0x0),
98 fSpiderCurrentSlotID(-1),
99 fSpiderCurrentChain(-1),
100 fSpiderCurrentTDC(-1)
102 //another constructor
105 //_________________________________________________________________
107 AliTOFDecoder::AliTOFDecoder(const AliTOFDecoder &source) :
109 fVerbose(source.fVerbose),
110 fV2718Patch(source.fV2718Patch),
111 fDataBuffer(source.fDataBuffer),
112 fPackedDataBuffer(source.fPackedDataBuffer),
113 //fTRMGlobalHeader(source.fTRMGlobalHeader),
114 //fTRMGlobalTrailer(source.fTRMGlobalTrailer),
115 //fTRMChainHeader(source.fTRMChainHeader),
116 //fTRMChainTrailer(source.fTRMChainTrailer),
117 //fTDCPackedHit(source.fTDCPackedHit),
118 //fTDCUnpackedHit(source.fTDCUnpackedHit),
119 //fTRMTDCError(source.fTRMTDCError),
120 //fTRMDiagnosticErrorWord1(source.fTRMDiagnosticErrorWord1),
121 //fTRMDiagnosticErrorWord2(source.fTRMDiagnosticErrorWord2),
122 fSpiderCurrentSlotID(source.fSpiderCurrentSlotID),
123 fSpiderCurrentChain(source.fSpiderCurrentChain),
124 fSpiderCurrentTDC(source.fSpiderCurrentTDC)
130 //_________________________________________________________________
133 AliTOFDecoder::operator = (const AliTOFDecoder &source)
140 TObject::operator=(source);
141 fVerbose = source.fVerbose;
142 fV2718Patch = source.fV2718Patch;
143 fDataBuffer = source.fDataBuffer;
144 fPackedDataBuffer = source.fPackedDataBuffer;
145 //fTRMGlobalHeader = source.fTRMGlobalHeader;
146 //fTRMGlobalTrailer = source.fTRMGlobalTrailer;
147 //fTRMChainHeader = source.fTRMChainHeader;
148 //fTRMChainTrailer = source.fTRMChainTrailer;
149 //fTDCPackedHit = source.fTDCPackedHit;
150 //fTDCUnpackedHit = source.fTDCUnpackedHit;
151 //fTRMTDCError = source.fTRMTDCError;
152 //fTRMDiagnosticErrorWord1 = source.fTRMDiagnosticErrorWord1;
153 //fTRMDiagnosticErrorWord2 = source.fTRMDiagnosticErrorWord2;
154 fSpiderCurrentSlotID = source.fSpiderCurrentSlotID;
155 fSpiderCurrentChain = source.fSpiderCurrentChain;
156 fSpiderCurrentTDC = source.fSpiderCurrentTDC;
160 AliTOFDecoder::~AliTOFDecoder()
163 //_________________________________________________________________
166 AliTOFDecoder::Decode(const UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh)
168 /* main decoding routine.
169 * it loops over nWords 32-bit words
170 * starting at *rawData and decodes them.
171 * it also fills some buffers in order to
172 * have the decoded data available for other
176 AliTOFTRMGlobalHeader *lTRMGlobalHeader; //TRM global header
177 AliTOFTRMGlobalTrailer *lTRMGlobalTrailer; //TRM global trailer
178 AliTOFTRMChainHeader *lTRMChainHeader; //TRM chain header
179 //AliTOFTRMChainTrailer *lTRMChainTrailer; //TRM chain trailer
180 AliTOFTDCPackedHit *lTDCPackedHit; //TDC packed hit
181 AliTOFTDCUnpackedHit *lTDCUnpackedHit; //TDC unpacked hit
182 //AliTOFTRMTDCError *lTRMTDCError; //TRM TDC error
183 //AliTOFTRMDiagnosticErrorWord1 *lTRMDiagnosticErrorWord1; //TRM diagnostic error word 1
184 //AliTOFTRMDiagnosticErrorWord2 *lTRMDiagnosticErrorWord2; //TRM diagnostica error word 2
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;
203 Short_t currentEventID1 = cdh ? cdh->GetEventID1() : (Short_t)-1;
204 AliDebug(1, Form("EvID1 = %d, EvID2 = %d, currentMiniEventID = %d", currentEventID1, cdh->GetEventID2(), currentMiniEventID));
206 AliWarning("CDH not valid: deltaBunchID not reliable ");
208 /*** V2718 patch ***/
210 decodeStatus = decodeStatus | DRM_BIT;
212 AliInfo("DRM not present: - V2718 patch decoding -");
214 /*** V2718 patch ***/
217 AliInfo("Initialize SPIDER function");
218 status = InitializeSpider();
221 AliInfo("Start decoding");
224 AliInfo("Loop over the data and decode");
227 AliInfo(" St Hex Word \t Decoded Word");
230 for (Int_t iWord = 0; iWord < nWords; iWord++, rawData++){
233 switch (*rawData & WORD_TYPE_MASK){
238 switch (*rawData & SLOT_ID_MASK){
240 //DRM global header (slotID=1)
242 //check decode status
243 if ( decodeStatus != DRM_HEADER_STATUS ){
244 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected DRM global header",decodeStatus,*rawData));
249 AliInfo(Form(" %02x - 0x%08x \t DRM global header",decodeStatus,*rawData));
250 //change decode status
251 decodeStatus = decodeStatus | DRM_BIT;
254 for (Int_t i = 0; i < DRM_DATA_WORDS; i++, iWord++, rawData++){
256 AliInfo(Form(" %02x - 0x%08x \t DRM data",decodeStatus,*rawData));
260 //LTM global header (slotID=2)
262 //check decode status
263 if ( decodeStatus != LTM_HEADER_STATUS ){
264 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected LTM global header",decodeStatus,*rawData));
269 AliInfo(Form(" %02x - 0x%08x \t LTM global header",decodeStatus,*rawData));
270 //change decode status
271 decodeStatus = decodeStatus | LTM_BIT;
274 for (Int_t i = 0; i < LTM_DATA_WORDS; i++, iWord++, rawData++){
276 AliInfo(Form(" %02x - 0x%08x \t LTM data",decodeStatus,*rawData));
280 //TRM global header (slotID=3-12)
281 case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12:
282 //check decode status
283 if ( decodeStatus != TRM_HEADER_STATUS ){
284 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM global header",decodeStatus,*rawData));
288 //set TRM global header
289 lTRMGlobalHeader = (AliTOFTRMGlobalHeader*)rawData;
291 currentSlotID = lTRMGlobalHeader->GetSlotID();
292 currentACQ = lTRMGlobalHeader->GetACQBits();
294 AliInfo(Form(" %02x - 0x%08x \t TRM global header \t slotID=%02d ACQ=%01d L=%01d",decodeStatus,*rawData,lTRMGlobalHeader->GetSlotID(),lTRMGlobalHeader->GetACQBits(),lTRMGlobalHeader->GetLBit()));
295 //change decode status
296 decodeStatus = decodeStatus | TRM_BIT;
300 AliError(Form(" %02x - 0x%08x [ERROR] Not valid slotID in global header",decodeStatus,*rawData));
311 switch (*rawData & SLOT_ID_MASK){
313 //DRM global trailer (slotID=1)
315 //check decode status
316 if ( decodeStatus != DRM_TRAILER_STATUS ){
317 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected DRM global trailer",decodeStatus,*rawData));
322 AliInfo(Form(" %02x - 0x%08x \t DRM global trailer",decodeStatus,*rawData));
323 //change decode status
324 decodeStatus = decodeStatus & ~DRM_BIT;
327 //LTM global trailer (slotID=2)
329 //check decode status
330 if ( decodeStatus != LTM_TRAILER_STATUS ){
331 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected LTM global trailer",decodeStatus,*rawData));
336 AliInfo(Form(" %02x - 0x%08x \t LTM global trailer",decodeStatus,*rawData));
337 //change decode status
338 decodeStatus = decodeStatus & ~LTM_BIT;
341 //TRM global trailer (slotID=15)
343 //check decode status
344 if ( decodeStatus != TRM_TRAILER_STATUS ){
345 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM global trailer",decodeStatus,*rawData));
349 //set TRM global trailer
350 lTRMGlobalTrailer = (AliTOFTRMGlobalTrailer *)rawData;
352 AliInfo(Form(" %02x - 0x%08x \t TRM global trailer \t CRC=%04d eventCounter=%04d",decodeStatus,*rawData,lTRMGlobalTrailer->GetEventCRC(),lTRMGlobalTrailer->GetEventCounter()));
353 //change decode status
354 decodeStatus = decodeStatus & ~TRM_BIT;
358 AliError(Form(" %02x - 0x%08x [ERROR] Not valid slotID/pattern in global trailer",decodeStatus,*rawData));
365 //check decode status
366 if ( (decodeStatus != CHAIN_A_HEADER_STATUS) ){
367 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain A header",decodeStatus,*rawData));
371 lTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
373 currentBunchID = lTRMChainHeader->GetBunchID();
375 AliInfo(Form(" %02x - 0x%08x \t TRM chain A header \t chain=%01d bunchID=%04d",decodeStatus,*rawData,currentChain,currentBunchID));
376 //change decode status
377 decodeStatus = decodeStatus | CHAIN_A_BIT;
380 case CHAIN_A_TRAILER:
381 //check decode status
382 if ( decodeStatus != CHAIN_A_TRAILER_STATUS ){
383 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain A trailer",decodeStatus,*rawData));
388 AliInfo(Form(" %02x - 0x%08x \t TRM chain A trailer",decodeStatus,*rawData));
389 //change decode status
390 decodeStatus = decodeStatus & ~CHAIN_A_BIT;
394 //check decode status
395 if ( decodeStatus != CHAIN_B_HEADER_STATUS ){
396 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain B header",decodeStatus,*rawData));
400 lTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
402 currentBunchID = lTRMChainHeader->GetBunchID();
404 AliInfo(Form(" %02x - 0x%08x \t TRM chain B header \t chain=%01d bunchID=%04d",decodeStatus,*rawData,currentChain,currentBunchID));
405 //change decode status
406 decodeStatus = decodeStatus | CHAIN_B_BIT;
409 case CHAIN_B_TRAILER:
410 //check decode status
411 if ( decodeStatus != CHAIN_B_TRAILER_STATUS ){
412 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain B trailer",decodeStatus,*rawData));
417 AliInfo(Form(" %02x - 0x%08x \t TRM chain B trailer",decodeStatus,*rawData));
418 //change decode status
419 decodeStatus = decodeStatus & ~CHAIN_B_BIT;
424 AliInfo(Form(" %02x - 0x%08x \t TDC error",decodeStatus,*rawData));
429 AliInfo(Form(" %02x - 0x%08x \t Filler",decodeStatus,*rawData));
433 //check decode status
434 if ( decodeStatus != CHAIN_A_TDC_HIT_STATUS &&
435 decodeStatus != CHAIN_B_TDC_HIT_STATUS ){
436 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected or unknown word",decodeStatus,*rawData));
444 case PACKING_ENABLED_ACQ:
445 //decode TDC packed hit
446 lTDCPackedHit = (AliTOFTDCPackedHit *)rawData;
447 lTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
448 //set hit in the equipment data
449 hitData.SetDDLID(currentDDL);
450 hitData.SetSlotID(currentSlotID);
451 hitData.SetACQ(currentACQ);
452 hitData.SetChain(currentChain);
453 hitData.SetPS(lTDCPackedHit->GetPSBits());
454 hitData.SetTDC(lTDCPackedHit->GetTDCID());
455 hitData.SetChan(lTDCPackedHit->GetChan());
456 hitData.SetTime((float)lTDCPackedHit->GetHitTime() * TIME_BIN_WIDTH);
457 hitData.SetTimeBin(lTDCPackedHit->GetHitTime());
458 hitData.SetTOT((float)lTDCPackedHit->GetTOTWidth() * TOT_BIN_WIDTH);
459 hitData.SetTOTBin(lTDCPackedHit->GetTOTWidth());
460 hitData.SetDeltaBunchID(currentBunchID - currentEventID1);
461 //orphane leading hit
462 if (hitData.GetPS()==LEADING_HIT_PS){
463 hitData.SetTime((float)lTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
464 hitData.SetTimeBin(lTDCUnpackedHit->GetHitTime());
467 hitData.SetTOTBin(0);
468 //push hit data in packed data buffer
469 if (fPackedDataBuffer != 0x0)
470 fPackedDataBuffer->Add(hitData);
471 //set TOT to not measured
473 hitData.SetTOTBin(-1);
474 //push hit data in packed data buffer
475 if (fDataBuffer != 0x0)
476 fDataBuffer->Add(hitData);
478 //orphane trailing hit
479 else if (hitData.GetPS()==TRAILING_HIT_PS){
480 hitData.SetTime((float)lTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
481 hitData.SetTimeBin(lTDCUnpackedHit->GetHitTime());
482 //set TOT to not measured
484 hitData.SetTOTBin(-1);
485 //push hit data in data buffer
486 if (fDataBuffer != 0x0)
487 fDataBuffer->Add(hitData);
491 //push hit data in packed data buffer
492 if (fPackedDataBuffer != 0x0)
493 fPackedDataBuffer->Add(hitData);
495 tempPS = hitData.GetPS();
497 tempTOT = hitData.GetTOT();
498 tempTOTBin = hitData.GetTOTBin();
499 //unpack the hit: leading hit
500 hitData.SetPS(LEADING_HIT_PS);
501 //set TOT to not measured
503 hitData.SetTOTBin(-1);
504 //push leading hit data in data buffer
505 if (fDataBuffer != 0x0)
506 fDataBuffer->Add(hitData);
507 //unpack the hit: trailing hit
508 hitData.SetPS(TRAILING_HIT_PS);
509 hitData.SetTime(hitData.GetTime() + tempTOT);
510 hitData.SetTimeBin(hitData.GetTimeBin() + (Int_t)(tempTOTBin * TOT_TO_TIME_BIN_WIDTH));
511 //push trailing hit data in data buffer
512 if (fDataBuffer != 0x0)
513 fDataBuffer->Add(hitData);
515 hitData.SetPS(tempPS);
516 hitData.SetTime(hitData.GetTime() - tempTOT);
517 hitData.SetTimeBin(hitData.GetTimeBin() - (Int_t)(tempTOTBin * TOT_TO_TIME_BIN_WIDTH));
518 hitData.SetTOT(tempTOT);
519 hitData.SetTOTBin(tempTOTBin);
523 switch (hitData.GetPS()){
525 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()));
528 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()));
530 case TRAILING_HIT_PS:
531 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()));
534 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()));
539 case LEADING_ONLY_ACQ: case TRAILING_ONLY_ACQ:
540 //decode TDC unpacked hit
541 lTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
542 //set hit in the equipment data
543 hitData.SetDDLID(currentDDL);
544 hitData.SetSlotID(currentSlotID);
545 hitData.SetACQ(currentACQ);
546 hitData.SetChain(currentChain);
547 hitData.SetPS(lTDCUnpackedHit->GetPSBits());
548 hitData.SetTDC(lTDCUnpackedHit->GetTDCID());
549 hitData.SetChan(lTDCUnpackedHit->GetChan());
550 hitData.SetTime((float)lTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
551 hitData.SetTimeBin(lTDCUnpackedHit->GetHitTime());
553 hitData.SetTOTBin(-1);
554 hitData.SetDeltaBunchID(currentBunchID - currentEventID1);
555 //push hit data in data buffer
556 if (fDataBuffer != 0x0)
557 fDataBuffer->Add(hitData);
560 switch (hitData.GetPS()){
562 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()));
565 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()));
567 case TRAILING_HIT_PS:
568 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()));
571 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()));
576 case PACKING_DISABLED_ACQ:
577 //decode TDC unpacked hit
578 lTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
579 //set hit in the equipment data
580 hitData.SetDDLID(currentDDL);
581 hitData.SetSlotID(currentSlotID);
582 hitData.SetACQ(currentACQ);
583 hitData.SetChain(currentChain);
584 hitData.SetPS(lTDCUnpackedHit->GetPSBits());
585 hitData.SetTDC(lTDCUnpackedHit->GetTDCID());
586 hitData.SetChan(lTDCUnpackedHit->GetChan());
587 hitData.SetTime((float)lTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
588 hitData.SetTimeBin(lTDCUnpackedHit->GetHitTime());
590 hitData.SetTOTBin(-1);
591 hitData.SetDeltaBunchID(currentBunchID - currentEventID1);
592 //push hit data in data buffer
593 if (fDataBuffer != 0x0)
594 fDataBuffer->Add(hitData);
597 switch (hitData.GetPS()){
599 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()));
602 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()));
604 case TRAILING_HIT_PS:
605 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()));
608 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()));
611 //call spider function
613 AliInfo("Calling SPIDER function");
621 //end switch word type
624 //end equipment data loop
627 AliInfo("End of data loop");
630 AliInfo("Reset SPIDER function");
631 status = ResetSpider();
634 AliInfo("Decoder is exiting succesfully.");
639 //_________________________________________________________________
642 AliTOFDecoder::InitializeSpider(){
644 /* SPIDER initialization routine.
645 it initializes SPIDER variables in order
646 to have SPIDER ready to pack tof data
647 in packed data objects
651 AliInfo("Initializing SPIDER");
653 fSpiderCurrentSlotID=-1;
654 fSpiderCurrentChain=-1;
655 fSpiderCurrentTDC=-1;
657 for (Int_t chan=0;chan<N_CHANNEL;chan++)
658 fSpiderLeadingFlag[chan] = kFALSE;
663 //_________________________________________________________________
666 AliTOFDecoder::ResetSpider(){
668 /* SPIDER reset routine.
669 it resets SPIDER buffers and
670 variables in order to empty full
671 buffers a set up SIPDER for new
676 AliInfo("Resetting SPIDER buffers");
678 for (Int_t chan=0;chan<N_CHANNEL;chan++){
679 if (fSpiderLeadingFlag[chan]){
681 AliInfo("Buffer non empty: put leading hit into buffer as orphane");
683 fSpiderLeadingHit[chan].SetACQ(4);
684 fSpiderLeadingHit[chan].SetPS(1);
685 fSpiderLeadingHit[chan].SetTOT(0);
686 fSpiderLeadingHit[chan].SetTOTBin(0);
687 //push hit into packed buffer
688 if (fPackedDataBuffer != 0x0)
689 fPackedDataBuffer->Add(fSpiderLeadingHit[chan]);
691 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()));
694 fSpiderLeadingFlag[chan]=kFALSE;
700 //_________________________________________________________________
703 AliTOFDecoder::Spider(AliTOFHitData &hitData){
705 /* main SPIDER routine.
706 it receives, reads, stores and packs
707 unpacked HPTDC data in packed data
708 object. it also fills buffers.
714 AliInfo("Hit data received");
716 //check if TDC is changed (slotID,chain,TDC triplet)
717 if (fSpiderCurrentSlotID!=hitData.GetSlotID() ||
718 fSpiderCurrentChain!=hitData.GetChain() ||
719 fSpiderCurrentTDC!=hitData.GetTDC() ){
721 AliInfo("Data coming from a new TDC: reset buffers");
723 status = ResetSpider();
725 fSpiderCurrentSlotID=hitData.GetSlotID();
726 fSpiderCurrentChain=hitData.GetChain();
727 fSpiderCurrentTDC=hitData.GetTDC();
731 switch (hitData.GetPS()){
735 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()));
736 //check spider leading flag
737 if (fSpiderLeadingFlag[hitData.GetChan()]){
739 AliInfo("Leading hit: buffer full, put previous in buffers as orphane and keep current");
740 //set TOT at zero for previous hit
741 fSpiderLeadingHit[hitData.GetChan()].SetACQ(4);
742 fSpiderLeadingHit[hitData.GetChan()].SetPS(1);
743 fSpiderLeadingHit[hitData.GetChan()].SetTOT(0);
744 fSpiderLeadingHit[hitData.GetChan()].SetTOTBin(0);
745 //push previous hit into packed buffer
746 if (fPackedDataBuffer != 0x0)
747 fPackedDataBuffer->Add(fSpiderLeadingHit[hitData.GetChan()]);
749 fSpiderLeadingHit[hitData.GetChan()]=hitData;
751 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()));
755 AliInfo("Leading hit: buffer empty, keep current hit and set flag");
756 fSpiderLeadingHit[hitData.GetChan()]=hitData;
757 //set spider leading flag
758 fSpiderLeadingFlag[hitData.GetChan()]=kTRUE;
762 case TRAILING_HIT_PS:
764 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()));
765 //check spider leading flag
766 if (fSpiderLeadingFlag[hitData.GetChan()]){
768 AliInfo("Trailing hit: buffer full, pack leading and trailing");
771 hitData.SetTOT(hitData.GetTime()-fSpiderLeadingHit[hitData.GetChan()].GetTime());
772 hitData.SetTOTBin((Int_t)((hitData.GetTimeBin()-fSpiderLeadingHit[hitData.GetChan()].GetTimeBin())*TIME_TO_TOT_BIN_WIDTH));
773 hitData.SetTime(fSpiderLeadingHit[hitData.GetChan()].GetTime());
774 hitData.SetTimeBin(fSpiderLeadingHit[hitData.GetChan()].GetTimeBin());
775 //check TOT and set TOT overflow if TOT < 0
776 if (hitData.GetTOT() < 0){
779 hitData.SetTOTBin(0);
781 if (fPackedDataBuffer != 0x0)
782 fPackedDataBuffer->Add(hitData);
784 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()));
785 //unset spider leading flag
786 fSpiderLeadingFlag[hitData.GetChan()]=kFALSE;
790 AliInfo("Trailing hit: buffer empty, throw hit away");
798 //_____________________________________________________________________________
799 void AliTOFDecoder::GetArrayDDL(Int_t* array, Int_t ddl){
801 // method that fills array with the
802 // TOF channels indexes corresponding
805 AliTOFGeometry *geom = new AliTOFGeometry();
806 Int_t indexDDL = ddl%4;
807 Int_t iSector = Int_t(ddl/4);
809 AliInfo(Form(" Sector = %i, DDL within sector = %i",iSector, indexDDL));
813 Int_t minPlate=0, maxPlate=0, minStrip2=0, maxStrip2=0, minPadz=0, maxPadz=0, minPadx=0, maxPadx=0;
818 minStrip2=kMinStrip0;
819 maxStrip2=kMaxStrip0;
826 else if (indexDDL==1){
829 minStrip2=kMinStrip1;
830 maxStrip2=kMaxStrip1;
837 else if (indexDDL==2){
840 minStrip2=kMinStrip2;
841 maxStrip2=kMaxStrip2;
848 else if (indexDDL==3){
851 minStrip2=kMinStrip3;
852 maxStrip2=kMaxStrip3;
863 for (Int_t iPlate=minPlate;iPlate<=maxPlate;iPlate++){
865 maxStrip = maxStrip2;
866 minStrip = minStrip2;
872 for (Int_t iStrip=minStrip;iStrip<=maxStrip;iStrip++){
873 for (Int_t iPadz=minPadz;iPadz<=maxPadz;iPadz++){
874 for (Int_t iPadx=minPadx;iPadx<=maxPadx;iPadx++){
880 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]));
882 if (indexDDL==0 || indexDDL==2){
883 array[ichTOF]=geom->GetIndex(volume);
885 AliInfo(Form(" ichTOF = %i, TOFChannel = %i",ichTOF,array[ichTOF]));
889 array[ichTOF]=geom->GetIndex(volume);
891 AliInfo(Form(" ichTOF = %i, TOFChannel = %i",ichTOF,array[ichTOF]));
899 //AliInfo(Form("ichTOF = %i",ichTOF));
900 if ((indexDDL%2==0 && ichTOF!=2160) ||
901 (indexDDL%2==1 && ichTOF!=2208)) {
902 AliWarning(Form("Something strange occurred, number of entries in array different from expected! Please, check! ichTOF = %i",ichTOF));