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 "AliRawDataHeaderV3.h"
54 #include "AliTOFRawDataFormat.h"
56 ClassImp(AliTOFDecoder)
58 //_________________________________________________________________
60 AliTOFDecoder::AliTOFDecoder() :
65 fPackedDataBuffer(0x0),
66 //fTRMGlobalHeader(0x0),
67 //fTRMGlobalTrailer(0x0),
68 //fTRMChainHeader(0x0),
69 //fTRMChainTrailer(0x0),
71 //fTDCUnpackedHit(0x0),
73 //fTRMDiagnosticErrorWord1(0x0),
74 //fTRMDiagnosticErrorWord2(0x0),
75 fSpiderCurrentSlotID(-1),
76 fSpiderCurrentChain(-1),
81 for (Int_t chan=0;chan<N_CHANNEL;chan++)
82 fSpiderLeadingFlag[chan] = kFALSE;
86 //_________________________________________________________________
88 AliTOFDecoder::AliTOFDecoder(AliTOFHitDataBuffer *DataBuffer, AliTOFHitDataBuffer *PackedDataBuffer) :
92 fDataBuffer(DataBuffer),
93 fPackedDataBuffer(PackedDataBuffer),
94 //fTRMGlobalHeader(0x0),
95 //fTRMGlobalTrailer(0x0),
96 //fTRMChainHeader(0x0),
97 //fTRMChainTrailer(0x0),
99 //fTDCUnpackedHit(0x0),
101 //fTRMDiagnosticErrorWord1(0x0),
102 //fTRMDiagnosticErrorWord2(0x0),
103 fSpiderCurrentSlotID(-1),
104 fSpiderCurrentChain(-1),
105 fSpiderCurrentTDC(-1)
107 //another constructor
109 for (Int_t chan=0;chan<N_CHANNEL;chan++)
110 fSpiderLeadingFlag[chan] = kFALSE;
114 //_________________________________________________________________
116 AliTOFDecoder::AliTOFDecoder(const AliTOFDecoder &source) :
118 fVerbose(source.fVerbose),
119 fV2718Patch(source.fV2718Patch),
120 fDataBuffer(source.fDataBuffer),
121 fPackedDataBuffer(source.fPackedDataBuffer),
122 //fTRMGlobalHeader(source.fTRMGlobalHeader),
123 //fTRMGlobalTrailer(source.fTRMGlobalTrailer),
124 //fTRMChainHeader(source.fTRMChainHeader),
125 //fTRMChainTrailer(source.fTRMChainTrailer),
126 //fTDCPackedHit(source.fTDCPackedHit),
127 //fTDCUnpackedHit(source.fTDCUnpackedHit),
128 //fTRMTDCError(source.fTRMTDCError),
129 //fTRMDiagnosticErrorWord1(source.fTRMDiagnosticErrorWord1),
130 //fTRMDiagnosticErrorWord2(source.fTRMDiagnosticErrorWord2),
131 fSpiderCurrentSlotID(source.fSpiderCurrentSlotID),
132 fSpiderCurrentChain(source.fSpiderCurrentChain),
133 fSpiderCurrentTDC(source.fSpiderCurrentTDC)
137 for (Int_t chan=0;chan<N_CHANNEL;chan++)
138 fSpiderLeadingFlag[chan] = source.fSpiderLeadingFlag[chan];
142 //_________________________________________________________________
145 AliTOFDecoder::operator = (const AliTOFDecoder &source)
152 TObject::operator=(source);
153 fVerbose = source.fVerbose;
154 fV2718Patch = source.fV2718Patch;
155 fDataBuffer = source.fDataBuffer;
156 fPackedDataBuffer = source.fPackedDataBuffer;
157 //fTRMGlobalHeader = source.fTRMGlobalHeader;
158 //fTRMGlobalTrailer = source.fTRMGlobalTrailer;
159 //fTRMChainHeader = source.fTRMChainHeader;
160 //fTRMChainTrailer = source.fTRMChainTrailer;
161 //fTDCPackedHit = source.fTDCPackedHit;
162 //fTDCUnpackedHit = source.fTDCUnpackedHit;
163 //fTRMTDCError = source.fTRMTDCError;
164 //fTRMDiagnosticErrorWord1 = source.fTRMDiagnosticErrorWord1;
165 //fTRMDiagnosticErrorWord2 = source.fTRMDiagnosticErrorWord2;
166 fSpiderCurrentSlotID = source.fSpiderCurrentSlotID;
167 fSpiderCurrentChain = source.fSpiderCurrentChain;
168 fSpiderCurrentTDC = source.fSpiderCurrentTDC;
169 for (Int_t chan=0;chan<N_CHANNEL;chan++)
170 fSpiderLeadingFlag[chan] = source.fSpiderLeadingFlag[chan];
175 AliTOFDecoder::~AliTOFDecoder()
178 //_________________________________________________________________
181 AliTOFDecoder::Decode(const UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh, const AliRawDataHeaderV3 *cdhV3)
183 /* main decoding routine.
184 * it loops over nWords 32-bit words
185 * starting at *rawData and decodes them.
186 * it also fills some buffers in order to
187 * have the decoded data available for other
191 AliTOFDRMStatusHeader3 *lDRMStatusHeader3;
192 AliTOFTRMGlobalHeader *lTRMGlobalHeader; //TRM global header
193 AliTOFTRMGlobalTrailer *lTRMGlobalTrailer; //TRM global trailer
194 AliTOFTRMChainHeader *lTRMChainHeader; //TRM chain header
195 //AliTOFTRMChainTrailer *lTRMChainTrailer; //TRM chain trailer
196 AliTOFTDCPackedHit *lTDCPackedHit; //TDC packed hit
197 AliTOFTDCUnpackedHit *lTDCUnpackedHit; //TDC unpacked hit
198 //AliTOFTRMTDCError *lTRMTDCError; //TRM TDC error
199 //AliTOFTRMDiagnosticErrorWord1 *lTRMDiagnosticErrorWord1; //TRM diagnostic error word 1
200 //AliTOFTRMDiagnosticErrorWord2 *lTRMDiagnosticErrorWord2; //TRM diagnostica error word 2
203 AliTOFHitData hitData;
208 Float_t tempTOT; //ns
209 Int_t tempTOTBin; //TOT_BIN_WIDTH
212 UShort_t decodeStatus = 0x0;
213 Short_t currentDDL = -1;
214 Short_t currentSlotID = -1;
215 Short_t currentACQ = -1;
216 Short_t currentChain = -1;
217 Short_t currentBunchID = -1;
218 Short_t currentL0BCID = -1;
219 Short_t currentMiniEventID = cdh ? cdh->GetMiniEventID() : (Short_t)(-1);
220 currentMiniEventID = cdhV3 ? cdhV3->GetMiniEventID() : currentMiniEventID;
221 Short_t currentEventID1 = cdh ? cdh->GetEventID1() : (Short_t)(-1);
222 currentEventID1 = cdhV3 ? cdhV3->GetEventID1() : currentEventID1;
224 AliWarning("CDH not valid: deltaBunchID not reliable ");
226 AliDebug(1, Form("EvID1 = %d, EvID2 = %d, currentMiniEventID = %d", currentEventID1, cdh? cdh->GetEventID2() : cdhV3->GetEventID2(), currentMiniEventID));
228 /*** V2718 patch ***/
230 decodeStatus = decodeStatus | DRM_BIT;
232 AliInfo("DRM not present: - V2718 patch decoding -");
234 /*** V2718 patch ***/
237 AliInfo("Initialize SPIDER function");
238 status = InitializeSpider();
241 AliInfo("Start decoding");
244 AliInfo("Loop over the data and decode");
247 AliInfo(" St Hex Word \t Decoded Word");
250 for (Int_t iWord = 0; iWord < nWords; iWord++, rawData++){
253 switch (*rawData & WORD_TYPE_MASK){
258 switch (*rawData & SLOT_ID_MASK){
260 //DRM global header (slotID=1)
262 //check decode status
263 if ( decodeStatus != DRM_HEADER_STATUS ){
264 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected DRM global header",decodeStatus,*rawData));
269 AliInfo(Form(" %02x - 0x%08x \t DRM global header",decodeStatus,*rawData));
270 //change decode status
271 decodeStatus = decodeStatus | DRM_BIT;
274 for (Int_t i = 0; i < DRM_DATA_WORDS; i++, iWord++){
277 AliInfo(Form(" %02x - 0x%08x \t DRM data",decodeStatus,*rawData));
280 lDRMStatusHeader3 = (AliTOFDRMStatusHeader3*)rawData;
281 currentL0BCID = lDRMStatusHeader3->GetL0BCID();
289 //LTM global header (slotID=2)
291 //check decode status
292 if ( decodeStatus != LTM_HEADER_STATUS ){
293 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected LTM global header",decodeStatus,*rawData));
298 AliInfo(Form(" %02x - 0x%08x \t LTM global header",decodeStatus,*rawData));
299 //change decode status
300 decodeStatus = decodeStatus | LTM_BIT;
303 for (Int_t i = 0; i < LTM_DATA_WORDS; i++, iWord++){
306 AliInfo(Form(" %02x - 0x%08x \t LTM data",decodeStatus,*rawData));
310 //TRM global header (slotID=3-12)
311 case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12:
312 //check decode status
313 if ( decodeStatus != TRM_HEADER_STATUS ){
314 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM global header",decodeStatus,*rawData));
318 //set TRM global header
319 lTRMGlobalHeader = (AliTOFTRMGlobalHeader*)rawData;
321 currentSlotID = lTRMGlobalHeader->GetSlotID();
322 currentACQ = lTRMGlobalHeader->GetACQBits();
324 AliInfo(Form(" %02x - 0x%08x \t TRM global header \t slotID=%02d ACQ=%01d L=%01d",decodeStatus,*rawData,lTRMGlobalHeader->GetSlotID(),lTRMGlobalHeader->GetACQBits(),lTRMGlobalHeader->GetLBit()));
325 //change decode status
326 decodeStatus = decodeStatus | TRM_BIT;
330 AliError(Form(" %02x - 0x%08x [ERROR] Not valid slotID in global header",decodeStatus,*rawData));
341 switch (*rawData & SLOT_ID_MASK){
343 //DRM global trailer (slotID=1)
345 //check decode status
346 if ( decodeStatus != DRM_TRAILER_STATUS ){
347 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected DRM global trailer",decodeStatus,*rawData));
352 AliInfo(Form(" %02x - 0x%08x \t DRM global trailer",decodeStatus,*rawData));
353 //change decode status
354 decodeStatus = decodeStatus & ~DRM_BIT;
357 //LTM global trailer (slotID=2)
359 //check decode status
360 if ( decodeStatus != LTM_TRAILER_STATUS ){
361 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected LTM global trailer",decodeStatus,*rawData));
366 AliInfo(Form(" %02x - 0x%08x \t LTM global trailer",decodeStatus,*rawData));
367 //change decode status
368 decodeStatus = decodeStatus & ~LTM_BIT;
371 //TRM global trailer (slotID=15)
373 //check decode status
374 if ( decodeStatus != TRM_TRAILER_STATUS ){
375 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM global trailer",decodeStatus,*rawData));
379 //set TRM global trailer
380 lTRMGlobalTrailer = (AliTOFTRMGlobalTrailer *)rawData;
382 AliInfo(Form(" %02x - 0x%08x \t TRM global trailer \t CRC=%04d eventCounter=%04d",decodeStatus,*rawData,lTRMGlobalTrailer->GetEventCRC(),lTRMGlobalTrailer->GetEventCounter()));
383 //change decode status
384 decodeStatus = decodeStatus & ~TRM_BIT;
388 AliError(Form(" %02x - 0x%08x [ERROR] Not valid slotID/pattern in global trailer",decodeStatus,*rawData));
395 //check decode status
396 if ( (decodeStatus != CHAIN_A_HEADER_STATUS) ){
397 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain A header",decodeStatus,*rawData));
401 lTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
403 currentBunchID = lTRMChainHeader->GetBunchID();
405 AliInfo(Form(" %02x - 0x%08x \t TRM chain A header \t chain=%01d bunchID=%04d",decodeStatus,*rawData,currentChain,currentBunchID));
406 //change decode status
407 decodeStatus = decodeStatus | CHAIN_A_BIT;
410 case CHAIN_A_TRAILER:
411 //check decode status
412 if ( decodeStatus != CHAIN_A_TRAILER_STATUS ){
413 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain A trailer",decodeStatus,*rawData));
418 AliInfo(Form(" %02x - 0x%08x \t TRM chain A trailer",decodeStatus,*rawData));
419 //change decode status
420 decodeStatus = decodeStatus & ~CHAIN_A_BIT;
424 //check decode status
425 if ( decodeStatus != CHAIN_B_HEADER_STATUS ){
426 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain B header",decodeStatus,*rawData));
430 lTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
432 currentBunchID = lTRMChainHeader->GetBunchID();
434 AliInfo(Form(" %02x - 0x%08x \t TRM chain B header \t chain=%01d bunchID=%04d",decodeStatus,*rawData,currentChain,currentBunchID));
435 //change decode status
436 decodeStatus = decodeStatus | CHAIN_B_BIT;
439 case CHAIN_B_TRAILER:
440 //check decode status
441 if ( decodeStatus != CHAIN_B_TRAILER_STATUS ){
442 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain B trailer",decodeStatus,*rawData));
447 AliInfo(Form(" %02x - 0x%08x \t TRM chain B trailer",decodeStatus,*rawData));
448 //change decode status
449 decodeStatus = decodeStatus & ~CHAIN_B_BIT;
454 AliInfo(Form(" %02x - 0x%08x \t TDC error",decodeStatus,*rawData));
459 AliInfo(Form(" %02x - 0x%08x \t Filler",decodeStatus,*rawData));
463 //check decode status
464 if ( decodeStatus != CHAIN_A_TDC_HIT_STATUS &&
465 decodeStatus != CHAIN_B_TDC_HIT_STATUS ){
466 AliError(Form(" %02x - 0x%08x [ERROR] Unexpected or unknown word",decodeStatus,*rawData));
474 case PACKING_ENABLED_ACQ:
475 //decode TDC packed hit
476 lTDCPackedHit = (AliTOFTDCPackedHit *)rawData;
477 lTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
478 //set hit in the equipment data
479 hitData.SetDDLID(currentDDL);
480 hitData.SetSlotID(currentSlotID);
481 hitData.SetACQ(currentACQ);
482 hitData.SetChain(currentChain);
483 hitData.SetPS(lTDCPackedHit->GetPSBits());
484 hitData.SetTDC(lTDCPackedHit->GetTDCID());
485 hitData.SetChan(lTDCPackedHit->GetChan());
486 hitData.SetTime((float)lTDCPackedHit->GetHitTime() * TIME_BIN_WIDTH);
487 hitData.SetTimeBin(lTDCPackedHit->GetHitTime());
488 hitData.SetTOT((float)lTDCPackedHit->GetTOTWidth() * TOT_BIN_WIDTH);
489 hitData.SetTOTBin(lTDCPackedHit->GetTOTWidth());
490 hitData.SetDeltaBunchID(currentBunchID - currentEventID1);
491 hitData.SetL0L1Latency(currentMiniEventID - currentL0BCID);
492 //orphane leading hit
493 if (hitData.GetPS()==LEADING_HIT_PS){
494 hitData.SetTime((float)lTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
495 hitData.SetTimeBin(lTDCUnpackedHit->GetHitTime());
498 hitData.SetTOTBin(0);
499 //push hit data in packed data buffer
500 if (fPackedDataBuffer != 0x0)
501 fPackedDataBuffer->Add(hitData);
502 //set TOT to not measured
504 hitData.SetTOTBin(-1);
505 //push hit data in packed data buffer
506 if (fDataBuffer != 0x0)
507 fDataBuffer->Add(hitData);
509 //orphane trailing hit
510 else if (hitData.GetPS()==TRAILING_HIT_PS){
511 hitData.SetTime((float)lTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
512 hitData.SetTimeBin(lTDCUnpackedHit->GetHitTime());
513 //set TOT to not measured
515 hitData.SetTOTBin(-1);
516 //push hit data in data buffer
517 if (fDataBuffer != 0x0)
518 fDataBuffer->Add(hitData);
522 //push hit data in packed data buffer
523 if (fPackedDataBuffer != 0x0)
524 fPackedDataBuffer->Add(hitData);
526 tempPS = hitData.GetPS();
528 tempTOT = hitData.GetTOT();
529 tempTOTBin = hitData.GetTOTBin();
530 //unpack the hit: leading hit
531 hitData.SetPS(LEADING_HIT_PS);
532 //set TOT to not measured
534 hitData.SetTOTBin(-1);
535 //push leading hit data in data buffer
536 if (fDataBuffer != 0x0)
537 fDataBuffer->Add(hitData);
538 //unpack the hit: trailing hit
539 hitData.SetPS(TRAILING_HIT_PS);
540 hitData.SetTime(hitData.GetTime() + tempTOT);
541 hitData.SetTimeBin(hitData.GetTimeBin() + (Int_t)(tempTOTBin * TOT_TO_TIME_BIN_WIDTH));
542 //push trailing hit data in data buffer
543 if (fDataBuffer != 0x0)
544 fDataBuffer->Add(hitData);
546 hitData.SetPS(tempPS);
547 hitData.SetTime(hitData.GetTime() - tempTOT);
548 hitData.SetTimeBin(hitData.GetTimeBin() - (Int_t)(tempTOTBin * TOT_TO_TIME_BIN_WIDTH));
549 hitData.SetTOT(tempTOT);
550 hitData.SetTOTBin(tempTOTBin);
554 switch (hitData.GetPS()){
556 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()));
559 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()));
561 case TRAILING_HIT_PS:
562 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()));
565 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()));
570 case LEADING_ONLY_ACQ: case TRAILING_ONLY_ACQ:
571 //decode TDC unpacked hit
572 lTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
573 //set hit in the equipment data
574 hitData.SetDDLID(currentDDL);
575 hitData.SetSlotID(currentSlotID);
576 hitData.SetACQ(currentACQ);
577 hitData.SetChain(currentChain);
578 hitData.SetPS(lTDCUnpackedHit->GetPSBits());
579 hitData.SetTDC(lTDCUnpackedHit->GetTDCID());
580 hitData.SetChan(lTDCUnpackedHit->GetChan());
581 hitData.SetTime((float)lTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
582 hitData.SetTimeBin(lTDCUnpackedHit->GetHitTime());
584 hitData.SetTOTBin(-1);
585 hitData.SetDeltaBunchID(currentBunchID - currentEventID1);
586 hitData.SetL0L1Latency(currentMiniEventID - currentL0BCID);
587 //push hit data in data buffer
588 if (fDataBuffer != 0x0)
589 fDataBuffer->Add(hitData);
592 switch (hitData.GetPS()){
594 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()));
597 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()));
599 case TRAILING_HIT_PS:
600 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()));
603 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()));
608 case PACKING_DISABLED_ACQ:
609 //decode TDC unpacked hit
610 lTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
611 //set hit in the equipment data
612 hitData.SetDDLID(currentDDL);
613 hitData.SetSlotID(currentSlotID);
614 hitData.SetACQ(currentACQ);
615 hitData.SetChain(currentChain);
616 hitData.SetPS(lTDCUnpackedHit->GetPSBits());
617 hitData.SetTDC(lTDCUnpackedHit->GetTDCID());
618 hitData.SetChan(lTDCUnpackedHit->GetChan());
619 hitData.SetTime((float)lTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
620 hitData.SetTimeBin(lTDCUnpackedHit->GetHitTime());
622 hitData.SetTOTBin(-1);
623 hitData.SetDeltaBunchID(currentBunchID - currentEventID1);
624 hitData.SetL0L1Latency(currentMiniEventID - currentL0BCID);
625 //push hit data in data buffer
626 if (fDataBuffer != 0x0)
627 fDataBuffer->Add(hitData);
630 switch (hitData.GetPS()){
632 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()));
635 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()));
637 case TRAILING_HIT_PS:
638 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()));
641 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()));
644 //call spider function
646 AliInfo("Calling SPIDER function");
654 //end switch word type
657 //end equipment data loop
660 AliInfo("End of data loop");
663 AliInfo("Reset SPIDER function");
664 status = ResetSpider();
667 AliInfo("Decoder is exiting succesfully.");
672 //_________________________________________________________________
675 AliTOFDecoder::InitializeSpider(){
677 /* SPIDER initialization routine.
678 it initializes SPIDER variables in order
679 to have SPIDER ready to pack tof data
680 in packed data objects
684 AliInfo("Initializing SPIDER");
686 fSpiderCurrentSlotID=-1;
687 fSpiderCurrentChain=-1;
688 fSpiderCurrentTDC=-1;
690 for (Int_t chan=0;chan<N_CHANNEL;chan++)
691 fSpiderLeadingFlag[chan] = kFALSE;
696 //_________________________________________________________________
699 AliTOFDecoder::ResetSpider(){
701 /* SPIDER reset routine.
702 it resets SPIDER buffers and
703 variables in order to empty full
704 buffers a set up SIPDER for new
709 AliInfo("Resetting SPIDER buffers");
711 for (Int_t chan=0;chan<N_CHANNEL;chan++){
712 if (fSpiderLeadingFlag[chan]){
714 AliInfo("Buffer non empty: put leading hit into buffer as orphane");
716 fSpiderLeadingHit[chan].SetACQ(4);
717 fSpiderLeadingHit[chan].SetPS(1);
718 fSpiderLeadingHit[chan].SetTOT(0);
719 fSpiderLeadingHit[chan].SetTOTBin(0);
720 //push hit into packed buffer
721 if (fPackedDataBuffer != 0x0)
722 fPackedDataBuffer->Add(fSpiderLeadingHit[chan]);
724 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()));
727 fSpiderLeadingFlag[chan]=kFALSE;
733 //_________________________________________________________________
736 AliTOFDecoder::Spider(AliTOFHitData &hitData){
738 /* main SPIDER routine.
739 it receives, reads, stores and packs
740 unpacked HPTDC data in packed data
741 object. it also fills buffers.
747 AliInfo("Hit data received");
749 //check if TDC is changed (slotID,chain,TDC triplet)
750 if (fSpiderCurrentSlotID!=hitData.GetSlotID() ||
751 fSpiderCurrentChain!=hitData.GetChain() ||
752 fSpiderCurrentTDC!=hitData.GetTDC() ){
754 AliInfo("Data coming from a new TDC: reset buffers");
756 status = ResetSpider();
758 fSpiderCurrentSlotID=hitData.GetSlotID();
759 fSpiderCurrentChain=hitData.GetChain();
760 fSpiderCurrentTDC=hitData.GetTDC();
764 switch (hitData.GetPS()){
768 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()));
769 //check spider leading flag
770 if (fSpiderLeadingFlag[hitData.GetChan()]){
772 AliInfo("Leading hit: buffer full, put previous in buffers as orphane and keep current");
773 //set TOT at zero for previous hit
774 fSpiderLeadingHit[hitData.GetChan()].SetACQ(4);
775 fSpiderLeadingHit[hitData.GetChan()].SetPS(1);
776 fSpiderLeadingHit[hitData.GetChan()].SetTOT(0);
777 fSpiderLeadingHit[hitData.GetChan()].SetTOTBin(0);
778 //push previous hit into packed buffer
779 if (fPackedDataBuffer != 0x0)
780 fPackedDataBuffer->Add(fSpiderLeadingHit[hitData.GetChan()]);
782 fSpiderLeadingHit[hitData.GetChan()]=hitData;
784 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()));
788 AliInfo("Leading hit: buffer empty, keep current hit and set flag");
789 fSpiderLeadingHit[hitData.GetChan()]=hitData;
790 //set spider leading flag
791 fSpiderLeadingFlag[hitData.GetChan()]=kTRUE;
795 case TRAILING_HIT_PS:
797 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()));
798 //check spider leading flag
799 if (fSpiderLeadingFlag[hitData.GetChan()]){
801 AliInfo("Trailing hit: buffer full, pack leading and trailing");
804 hitData.SetTOT(hitData.GetTime()-fSpiderLeadingHit[hitData.GetChan()].GetTime());
805 hitData.SetTOTBin((Int_t)((hitData.GetTimeBin()-fSpiderLeadingHit[hitData.GetChan()].GetTimeBin())*TIME_TO_TOT_BIN_WIDTH));
806 hitData.SetTime(fSpiderLeadingHit[hitData.GetChan()].GetTime());
807 hitData.SetTimeBin(fSpiderLeadingHit[hitData.GetChan()].GetTimeBin());
808 //check TOT and set TOT overflow if TOT < 0
809 if (hitData.GetTOT() < 0){
812 hitData.SetTOTBin(0);
814 if (fPackedDataBuffer != 0x0)
815 fPackedDataBuffer->Add(hitData);
817 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()));
818 //unset spider leading flag
819 fSpiderLeadingFlag[hitData.GetChan()]=kFALSE;
823 AliInfo("Trailing hit: buffer empty, throw hit away");
831 //_____________________________________________________________________________
832 void AliTOFDecoder::GetArrayDDL(Int_t* array, Int_t ddl){
834 // method that fills array with the
835 // TOF channels indexes corresponding
838 AliTOFGeometry *geom = new AliTOFGeometry();
839 Int_t indexDDL = ddl%4;
840 Int_t iSector = Int_t(ddl/4);
842 AliInfo(Form(" Sector = %i, DDL within sector = %i",iSector, indexDDL));
846 Int_t minPlate=0, maxPlate=0, minStrip2=0, maxStrip2=0, minPadz=0, maxPadz=0, minPadx=0, maxPadx=0;
851 minStrip2=kMinStrip0;
852 maxStrip2=kMaxStrip0;
859 else if (indexDDL==1){
862 minStrip2=kMinStrip1;
863 maxStrip2=kMaxStrip1;
870 else if (indexDDL==2){
873 minStrip2=kMinStrip2;
874 maxStrip2=kMaxStrip2;
881 else if (indexDDL==3){
884 minStrip2=kMinStrip3;
885 maxStrip2=kMaxStrip3;
896 for (Int_t iPlate=minPlate;iPlate<=maxPlate;iPlate++){
898 maxStrip = maxStrip2;
899 minStrip = minStrip2;
905 for (Int_t iStrip=minStrip;iStrip<=maxStrip;iStrip++){
906 for (Int_t iPadz=minPadz;iPadz<=maxPadz;iPadz++){
907 for (Int_t iPadx=minPadx;iPadx<=maxPadx;iPadx++){
913 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]));
915 if (indexDDL==0 || indexDDL==2){
916 array[ichTOF]=geom->GetIndex(volume);
918 AliInfo(Form(" ichTOF = %i, TOFChannel = %i",ichTOF,array[ichTOF]));
922 array[ichTOF]=geom->GetIndex(volume);
924 AliInfo(Form(" ichTOF = %i, TOFChannel = %i",ichTOF,array[ichTOF]));
932 //AliInfo(Form("ichTOF = %i",ichTOF));
933 if ((indexDDL%2==0 && ichTOF!=2160) ||
934 (indexDDL%2==1 && ichTOF!=2208)) {
935 AliWarning(Form("Something strange occurred, number of entries in array different from expected! Please, check! ichTOF = %i",ichTOF));
940 //------------------------------------------------------------
941 void AliTOFDecoder::PrintStack(const UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh, const AliRawDataHeaderV3 *cdhV3)
943 /* It loops over nWords 32-bit words
944 * starting at *rawData and prints them in 0x format.
945 * It does not decode them!
948 Short_t currentMiniEventID = cdh ? cdh->GetMiniEventID() : (Short_t)(-1);
949 currentMiniEventID = cdhV3 ? cdhV3->GetMiniEventID() : currentMiniEventID;
950 Short_t currentEventID1 = cdh ? cdh->GetEventID1() : (Short_t)(-1);
951 currentEventID1 = cdhV3 ? cdhV3->GetEventID1() : currentEventID1;
953 AliWarning("CDH not valid: deltaBunchID not reliable ");
955 AliDebug(1, Form("EvID1 = %d, EvID2 = %d, currentMiniEventID = %d", currentEventID1, cdh ? cdh->GetEventID2() : cdhV3->GetEventID2(), currentMiniEventID));
957 AliInfo("Printing raw data stack for current equipment\n");
958 AliInfo(" wordN - Hex Word ");
960 for (Int_t iWord = 0; iWord < nWords; iWord++, rawData++){
961 if (iWord<10) AliInfo(Form(" %i - 0x%08x",iWord,*rawData));
962 if (iWord>9 &&iWord<100) AliInfo(Form(" %i - 0x%08x",iWord,*rawData));
963 if (iWord>99) AliInfo(Form(" %i - 0x%08x",iWord,*rawData));