#include "AliLog.h"
#include "AliTOFHitData.h"
#include "AliTOFHitDataBuffer.h"
#include "AliTOFDecoder.h"
#include "AliTOFGeometry.h"
#include "AliRawDataHeader.h"
#include "AliRawDataHeaderV3.h"
#include "AliTOFRawDataFormat.h"
ClassImp(AliTOFDecoder)
AliTOFDecoder::AliTOFDecoder() :
TObject(),
fVerbose(0),
fV2718Patch(kFALSE),
fDataBuffer(0x0),
fPackedDataBuffer(0x0),
fSpiderCurrentSlotID(-1),
fSpiderCurrentChain(-1),
fSpiderCurrentTDC(-1)
{
for (Int_t chan=0;chan<N_CHANNEL;chan++)
fSpiderLeadingFlag[chan] = kFALSE;
}
AliTOFDecoder::AliTOFDecoder(AliTOFHitDataBuffer *DataBuffer, AliTOFHitDataBuffer *PackedDataBuffer) :
TObject(),
fVerbose(0),
fV2718Patch(kFALSE),
fDataBuffer(DataBuffer),
fPackedDataBuffer(PackedDataBuffer),
fSpiderCurrentSlotID(-1),
fSpiderCurrentChain(-1),
fSpiderCurrentTDC(-1)
{
for (Int_t chan=0;chan<N_CHANNEL;chan++)
fSpiderLeadingFlag[chan] = kFALSE;
}
AliTOFDecoder::AliTOFDecoder(const AliTOFDecoder &source) :
TObject(source),
fVerbose(source.fVerbose),
fV2718Patch(source.fV2718Patch),
fDataBuffer(source.fDataBuffer),
fPackedDataBuffer(source.fPackedDataBuffer),
fSpiderCurrentSlotID(source.fSpiderCurrentSlotID),
fSpiderCurrentChain(source.fSpiderCurrentChain),
fSpiderCurrentTDC(source.fSpiderCurrentTDC)
{
for (Int_t chan=0;chan<N_CHANNEL;chan++)
fSpiderLeadingFlag[chan] = source.fSpiderLeadingFlag[chan];
}
AliTOFDecoder &
AliTOFDecoder::operator = (const AliTOFDecoder &source)
{
if (this == &source)
return *this;
TObject::operator=(source);
fVerbose = source.fVerbose;
fV2718Patch = source.fV2718Patch;
fDataBuffer = source.fDataBuffer;
fPackedDataBuffer = source.fPackedDataBuffer;
fSpiderCurrentSlotID = source.fSpiderCurrentSlotID;
fSpiderCurrentChain = source.fSpiderCurrentChain;
fSpiderCurrentTDC = source.fSpiderCurrentTDC;
for (Int_t chan=0;chan<N_CHANNEL;chan++)
fSpiderLeadingFlag[chan] = source.fSpiderLeadingFlag[chan];
return *this;
}
AliTOFDecoder::~AliTOFDecoder()
{}
Bool_t
AliTOFDecoder::Decode(const UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh, const AliRawDataHeaderV3 *cdhV3)
{
AliTOFDRMStatusHeader3 *lDRMStatusHeader3;
AliTOFTRMGlobalHeader *lTRMGlobalHeader;
AliTOFTRMGlobalTrailer *lTRMGlobalTrailer;
AliTOFTRMChainHeader *lTRMChainHeader;
AliTOFTDCPackedHit *lTDCPackedHit;
AliTOFTDCUnpackedHit *lTDCUnpackedHit;
AliTOFHitData hitData;
Int_t status;
Short_t tempPS;
Float_t tempTOT;
Int_t tempTOTBin;
UShort_t decodeStatus = 0x0;
Short_t currentDDL = -1;
Short_t currentSlotID = -1;
Short_t currentACQ = -1;
Short_t currentChain = -1;
Short_t currentBunchID = -1;
Short_t currentL0BCID = -1;
Short_t currentMiniEventID = cdh ? cdh->GetMiniEventID() : (Short_t)(-1);
currentMiniEventID = cdhV3 ? cdhV3->GetMiniEventID() : currentMiniEventID;
Short_t currentEventID1 = cdh ? cdh->GetEventID1() : (Short_t)(-1);
currentEventID1 = cdhV3 ? cdhV3->GetEventID1() : currentEventID1;
if (!cdh && !cdhV3)
AliWarning("CDH not valid: deltaBunchID not reliable ");
else
AliDebug(1, Form("EvID1 = %d, EvID2 = %d, currentMiniEventID = %d", currentEventID1, cdh? cdh->GetEventID2() : cdhV3->GetEventID2(), currentMiniEventID));
if (fV2718Patch){
decodeStatus = decodeStatus | DRM_BIT;
if (fVerbose)
AliInfo("DRM not present: - V2718 patch decoding -");
}
if (fVerbose==2)
AliInfo("Initialize SPIDER function");
status = InitializeSpider();
if (fVerbose)
AliInfo("Start decoding");
if (fVerbose)
AliInfo("Loop over the data and decode");
if (fVerbose)
AliInfo(" St Hex Word \t Decoded Word");
for (Int_t iWord = 0; iWord < nWords; iWord++, rawData++){
switch (*rawData & WORD_TYPE_MASK){
case GLOBAL_HEADER:
switch (*rawData & SLOT_ID_MASK){
case 1:
if ( decodeStatus != DRM_HEADER_STATUS ){
AliError(Form(" %02x - 0x%08x [ERROR] Unexpected DRM global header",decodeStatus,*rawData));
return kTRUE;
}
if (fVerbose)
AliInfo(Form(" %02x - 0x%08x \t DRM global header",decodeStatus,*rawData));
decodeStatus = decodeStatus | DRM_BIT;
for (Int_t i = 0; i < DRM_DATA_WORDS; i++, iWord++){
rawData++;
if (fVerbose)
AliInfo(Form(" %02x - 0x%08x \t DRM data",decodeStatus,*rawData));
switch (i) {
case 2:
lDRMStatusHeader3 = (AliTOFDRMStatusHeader3*)rawData;
currentL0BCID = lDRMStatusHeader3->GetL0BCID();
break;
default:
break;
}
}
break;
case 2:
if ( decodeStatus != LTM_HEADER_STATUS ){
AliError(Form(" %02x - 0x%08x [ERROR] Unexpected LTM global header",decodeStatus,*rawData));
return kTRUE;
}
if (fVerbose)
AliInfo(Form(" %02x - 0x%08x \t LTM global header",decodeStatus,*rawData));
decodeStatus = decodeStatus | LTM_BIT;
for (Int_t i = 0; i < LTM_DATA_WORDS; i++, iWord++){
rawData++;
if (fVerbose)
AliInfo(Form(" %02x - 0x%08x \t LTM data",decodeStatus,*rawData));
}
break;
case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12:
if ( decodeStatus != TRM_HEADER_STATUS ){
AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM global header",decodeStatus,*rawData));
return kTRUE;
}
lTRMGlobalHeader = (AliTOFTRMGlobalHeader*)rawData;
currentSlotID = lTRMGlobalHeader->GetSlotID();
currentACQ = lTRMGlobalHeader->GetACQBits();
if (fVerbose)
AliInfo(Form(" %02x - 0x%08x \t TRM global header \t slotID=%02d ACQ=%01d L=%01d",decodeStatus,*rawData,lTRMGlobalHeader->GetSlotID(),lTRMGlobalHeader->GetACQBits(),lTRMGlobalHeader->GetLBit()));
decodeStatus = decodeStatus | TRM_BIT;
break;
default:
AliError(Form(" %02x - 0x%08x [ERROR] Not valid slotID in global header",decodeStatus,*rawData));
return kTRUE;
break;
}
break;
case GLOBAL_TRAILER:
switch (*rawData & SLOT_ID_MASK){
case 1:
if ( decodeStatus != DRM_TRAILER_STATUS ){
AliError(Form(" %02x - 0x%08x [ERROR] Unexpected DRM global trailer",decodeStatus,*rawData));
return kTRUE;
}
if (fVerbose)
AliInfo(Form(" %02x - 0x%08x \t DRM global trailer",decodeStatus,*rawData));
decodeStatus = decodeStatus & ~DRM_BIT;
break;
case 2:
if ( decodeStatus != LTM_TRAILER_STATUS ){
AliError(Form(" %02x - 0x%08x [ERROR] Unexpected LTM global trailer",decodeStatus,*rawData));
return kTRUE;
}
if (fVerbose)
AliInfo(Form(" %02x - 0x%08x \t LTM global trailer",decodeStatus,*rawData));
decodeStatus = decodeStatus & ~LTM_BIT;
break;
case 15:
if ( decodeStatus != TRM_TRAILER_STATUS ){
AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM global trailer",decodeStatus,*rawData));
return kTRUE;
}
lTRMGlobalTrailer = (AliTOFTRMGlobalTrailer *)rawData;
if (fVerbose)
AliInfo(Form(" %02x - 0x%08x \t TRM global trailer \t CRC=%04d eventCounter=%04d",decodeStatus,*rawData,lTRMGlobalTrailer->GetEventCRC(),lTRMGlobalTrailer->GetEventCounter()));
decodeStatus = decodeStatus & ~TRM_BIT;
break;
default:
AliError(Form(" %02x - 0x%08x [ERROR] Not valid slotID/pattern in global trailer",decodeStatus,*rawData));
return kTRUE;
break;
}
break;
case CHAIN_A_HEADER:
if ( (decodeStatus != CHAIN_A_HEADER_STATUS) ){
AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain A header",decodeStatus,*rawData));
return kTRUE;
}
lTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
currentChain = 0;
currentBunchID = lTRMChainHeader->GetBunchID();
if (fVerbose)
AliInfo(Form(" %02x - 0x%08x \t TRM chain A header \t chain=%01d bunchID=%04d",decodeStatus,*rawData,currentChain,currentBunchID));
decodeStatus = decodeStatus | CHAIN_A_BIT;
break;
case CHAIN_A_TRAILER:
if ( decodeStatus != CHAIN_A_TRAILER_STATUS ){
AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain A trailer",decodeStatus,*rawData));
return kTRUE;
}
if (fVerbose)
AliInfo(Form(" %02x - 0x%08x \t TRM chain A trailer",decodeStatus,*rawData));
decodeStatus = decodeStatus & ~CHAIN_A_BIT;
break;
case CHAIN_B_HEADER:
if ( decodeStatus != CHAIN_B_HEADER_STATUS ){
AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain B header",decodeStatus,*rawData));
return kTRUE;
}
lTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
currentChain = 1;
currentBunchID = lTRMChainHeader->GetBunchID();
if (fVerbose)
AliInfo(Form(" %02x - 0x%08x \t TRM chain B header \t chain=%01d bunchID=%04d",decodeStatus,*rawData,currentChain,currentBunchID));
decodeStatus = decodeStatus | CHAIN_B_BIT;
break;
case CHAIN_B_TRAILER:
if ( decodeStatus != CHAIN_B_TRAILER_STATUS ){
AliError(Form(" %02x - 0x%08x [ERROR] Unexpected TRM chain B trailer",decodeStatus,*rawData));
return kTRUE;
}
if (fVerbose)
AliInfo(Form(" %02x - 0x%08x \t TRM chain B trailer",decodeStatus,*rawData));
decodeStatus = decodeStatus & ~CHAIN_B_BIT;
break;
case ERROR:
if (fVerbose)
AliInfo(Form(" %02x - 0x%08x \t TDC error",decodeStatus,*rawData));
break;
case FILLER:
if (fVerbose)
AliInfo(Form(" %02x - 0x%08x \t Filler",decodeStatus,*rawData));
break;
default:
if ( decodeStatus != CHAIN_A_TDC_HIT_STATUS &&
decodeStatus != CHAIN_B_TDC_HIT_STATUS ){
AliError(Form(" %02x - 0x%08x [ERROR] Unexpected or unknown word",decodeStatus,*rawData));
return kTRUE;
}
switch (currentACQ){
case PACKING_ENABLED_ACQ:
lTDCPackedHit = (AliTOFTDCPackedHit *)rawData;
lTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
hitData.SetDDLID(currentDDL);
hitData.SetSlotID(currentSlotID);
hitData.SetACQ(currentACQ);
hitData.SetChain(currentChain);
hitData.SetPS(lTDCPackedHit->GetPSBits());
hitData.SetTDC(lTDCPackedHit->GetTDCID());
hitData.SetChan(lTDCPackedHit->GetChan());
hitData.SetTime((float)lTDCPackedHit->GetHitTime() * TIME_BIN_WIDTH);
hitData.SetTimeBin(lTDCPackedHit->GetHitTime());
hitData.SetTOT((float)lTDCPackedHit->GetTOTWidth() * TOT_BIN_WIDTH);
hitData.SetTOTBin(lTDCPackedHit->GetTOTWidth());
hitData.SetDeltaBunchID(currentBunchID - currentEventID1);
hitData.SetL0L1Latency(currentMiniEventID - currentL0BCID);
if (hitData.GetPS()==LEADING_HIT_PS){
hitData.SetTime((float)lTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
hitData.SetTimeBin(lTDCUnpackedHit->GetHitTime());
hitData.SetTOT(0);
hitData.SetTOTBin(0);
if (fPackedDataBuffer != 0x0)
fPackedDataBuffer->Add(hitData);
hitData.SetTOT(-1);
hitData.SetTOTBin(-1);
if (fDataBuffer != 0x0)
fDataBuffer->Add(hitData);
}
else if (hitData.GetPS()==TRAILING_HIT_PS){
hitData.SetTime((float)lTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
hitData.SetTimeBin(lTDCUnpackedHit->GetHitTime());
hitData.SetTOT(-1);
hitData.SetTOTBin(-1);
if (fDataBuffer != 0x0)
fDataBuffer->Add(hitData);
}
else{
if (fPackedDataBuffer != 0x0)
fPackedDataBuffer->Add(hitData);
tempPS = hitData.GetPS();
tempTOT = hitData.GetTOT();
tempTOTBin = hitData.GetTOTBin();
hitData.SetPS(LEADING_HIT_PS);
hitData.SetTOT(-1);
hitData.SetTOTBin(-1);
if (fDataBuffer != 0x0)
fDataBuffer->Add(hitData);
hitData.SetPS(TRAILING_HIT_PS);
hitData.SetTime(hitData.GetTime() + tempTOT);
hitData.SetTimeBin(hitData.GetTimeBin() + (Int_t)(tempTOTBin * TOT_TO_TIME_BIN_WIDTH));
if (fDataBuffer != 0x0)
fDataBuffer->Add(hitData);
hitData.SetPS(tempPS);
hitData.SetTime(hitData.GetTime() - tempTOT);
hitData.SetTimeBin(hitData.GetTimeBin() - (Int_t)(tempTOTBin * TOT_TO_TIME_BIN_WIDTH));
hitData.SetTOT(tempTOT);
hitData.SetTOTBin(tempTOTBin);
}
if (fVerbose)
switch (hitData.GetPS()){
case PACKED_HIT_PS:
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()));
break;
case LEADING_HIT_PS:
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()));
break;
case TRAILING_HIT_PS:
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()));
break;
case TOT_OVF_HIT_PS:
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()));
break;
}
break;
case LEADING_ONLY_ACQ: case TRAILING_ONLY_ACQ:
lTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
hitData.SetDDLID(currentDDL);
hitData.SetSlotID(currentSlotID);
hitData.SetACQ(currentACQ);
hitData.SetChain(currentChain);
hitData.SetPS(lTDCUnpackedHit->GetPSBits());
hitData.SetTDC(lTDCUnpackedHit->GetTDCID());
hitData.SetChan(lTDCUnpackedHit->GetChan());
hitData.SetTime((float)lTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
hitData.SetTimeBin(lTDCUnpackedHit->GetHitTime());
hitData.SetTOT(-1.);
hitData.SetTOTBin(-1);
hitData.SetDeltaBunchID(currentBunchID - currentEventID1);
hitData.SetL0L1Latency(currentMiniEventID - currentL0BCID);
if (fDataBuffer != 0x0)
fDataBuffer->Add(hitData);
if (fVerbose)
switch (hitData.GetPS()){
case PACKED_HIT_PS:
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()));
break;
case LEADING_HIT_PS:
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()));
break;
case TRAILING_HIT_PS:
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()));
break;
case TOT_OVF_HIT_PS:
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()));
break;
}
break;
case PACKING_DISABLED_ACQ:
lTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
hitData.SetDDLID(currentDDL);
hitData.SetSlotID(currentSlotID);
hitData.SetACQ(currentACQ);
hitData.SetChain(currentChain);
hitData.SetPS(lTDCUnpackedHit->GetPSBits());
hitData.SetTDC(lTDCUnpackedHit->GetTDCID());
hitData.SetChan(lTDCUnpackedHit->GetChan());
hitData.SetTime((float)lTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
hitData.SetTimeBin(lTDCUnpackedHit->GetHitTime());
hitData.SetTOT(-1.);
hitData.SetTOTBin(-1);
hitData.SetDeltaBunchID(currentBunchID - currentEventID1);
hitData.SetL0L1Latency(currentMiniEventID - currentL0BCID);
if (fDataBuffer != 0x0)
fDataBuffer->Add(hitData);
if (fVerbose)
switch (hitData.GetPS()){
case PACKED_HIT_PS:
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()));
break;
case LEADING_HIT_PS:
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()));
break;
case TRAILING_HIT_PS:
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()));
break;
case TOT_OVF_HIT_PS:
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()));
break;
}
if (fVerbose==2)
AliInfo("Calling SPIDER function");
Spider(hitData);
break;
}
}
}
if (fVerbose)
AliInfo("End of data loop");
if (fVerbose==2)
AliInfo("Reset SPIDER function");
status = ResetSpider();
if (fVerbose)
AliInfo("Decoder is exiting succesfully.");
return kFALSE;
}
Bool_t
AliTOFDecoder::InitializeSpider(){
if (fVerbose==2)
AliInfo("Initializing SPIDER");
fSpiderCurrentSlotID=-1;
fSpiderCurrentChain=-1;
fSpiderCurrentTDC=-1;
for (Int_t chan=0;chan<N_CHANNEL;chan++)
fSpiderLeadingFlag[chan] = kFALSE;
return kFALSE;
}
Bool_t
AliTOFDecoder::ResetSpider(){
if (fVerbose==2)
AliInfo("Resetting SPIDER buffers");
for (Int_t chan=0;chan<N_CHANNEL;chan++){
if (fSpiderLeadingFlag[chan]){
if (fVerbose==2)
AliInfo("Buffer non empty: put leading hit into buffer as orphane");
fSpiderLeadingHit[chan].SetACQ(4);
fSpiderLeadingHit[chan].SetPS(1);
fSpiderLeadingHit[chan].SetTOT(0);
fSpiderLeadingHit[chan].SetTOTBin(0);
if (fPackedDataBuffer != 0x0)
fPackedDataBuffer->Add(fSpiderLeadingHit[chan]);
if (fVerbose==2)
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()));
}
fSpiderLeadingFlag[chan]=kFALSE;
}
return kFALSE;
}
Bool_t
AliTOFDecoder::Spider(AliTOFHitData &hitData){
Int_t status;
if (fVerbose==2)
AliInfo("Hit data received");
if (fSpiderCurrentSlotID!=hitData.GetSlotID() ||
fSpiderCurrentChain!=hitData.GetChain() ||
fSpiderCurrentTDC!=hitData.GetTDC() ){
if (fVerbose==2)
AliInfo("Data coming from a new TDC: reset buffers");
status = ResetSpider();
fSpiderCurrentSlotID=hitData.GetSlotID();
fSpiderCurrentChain=hitData.GetChain();
fSpiderCurrentTDC=hitData.GetTDC();
}
switch (hitData.GetPS()){
case LEADING_HIT_PS:
if (fVerbose==2)
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()));
if (fSpiderLeadingFlag[hitData.GetChan()]){
if (fVerbose==2)
AliInfo("Leading hit: buffer full, put previous in buffers as orphane and keep current");
fSpiderLeadingHit[hitData.GetChan()].SetACQ(4);
fSpiderLeadingHit[hitData.GetChan()].SetPS(1);
fSpiderLeadingHit[hitData.GetChan()].SetTOT(0);
fSpiderLeadingHit[hitData.GetChan()].SetTOTBin(0);
if (fPackedDataBuffer != 0x0)
fPackedDataBuffer->Add(fSpiderLeadingHit[hitData.GetChan()]);
fSpiderLeadingHit[hitData.GetChan()]=hitData;
if (fVerbose==2)
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()));
}
else{
if (fVerbose==2)
AliInfo("Leading hit: buffer empty, keep current hit and set flag");
fSpiderLeadingHit[hitData.GetChan()]=hitData;
fSpiderLeadingFlag[hitData.GetChan()]=kTRUE;
}
break;
case TRAILING_HIT_PS:
if (fVerbose==2)
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()));
if (fSpiderLeadingFlag[hitData.GetChan()]){
if (fVerbose==2)
AliInfo("Trailing hit: buffer full, pack leading and trailing");
hitData.SetACQ(4);
hitData.SetPS(0);
hitData.SetTOT(hitData.GetTime()-fSpiderLeadingHit[hitData.GetChan()].GetTime());
hitData.SetTOTBin((Int_t)((hitData.GetTimeBin()-fSpiderLeadingHit[hitData.GetChan()].GetTimeBin())*TIME_TO_TOT_BIN_WIDTH));
hitData.SetTime(fSpiderLeadingHit[hitData.GetChan()].GetTime());
hitData.SetTimeBin(fSpiderLeadingHit[hitData.GetChan()].GetTimeBin());
if (hitData.GetTOT() < 0){
hitData.SetPS(3);
hitData.SetTOT(0);
hitData.SetTOTBin(0);
}
if (fPackedDataBuffer != 0x0)
fPackedDataBuffer->Add(hitData);
if (fVerbose==2)
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()));
fSpiderLeadingFlag[hitData.GetChan()]=kFALSE;
}
else{
if (fVerbose==2)
AliInfo("Trailing hit: buffer empty, throw hit away");
}
break;
}
return kFALSE;
}
void AliTOFDecoder::GetArrayDDL(Int_t* array, Int_t ddl){
AliTOFGeometry *geom = new AliTOFGeometry();
Int_t indexDDL = ddl%4;
Int_t iSector = Int_t(ddl/4);
if (fVerbose)
AliInfo(Form(" Sector = %i, DDL within sector = %i",iSector, indexDDL));
Int_t volume[5];
volume[0]=iSector;
Int_t minPlate=0, maxPlate=0, minStrip2=0, maxStrip2=0, minPadz=0, maxPadz=0, minPadx=0, maxPadx=0;
if (indexDDL==0){
minPlate=kMinPlate0;
maxPlate=kMaxPlate0;
minStrip2=kMinStrip0;
maxStrip2=kMaxStrip0;
minPadz=kMinPadz0;
maxPadz=kMaxPadz0;
minPadx=kMinPadx0;
maxPadx=kMaxPadx0;
}
else if (indexDDL==1){
minPlate=kMinPlate1;
maxPlate=kMaxPlate1;
minStrip2=kMinStrip1;
maxStrip2=kMaxStrip1;
minPadz=kMinPadz1;
maxPadz=kMaxPadz1;
minPadx=kMinPadx1;
maxPadx=kMaxPadx1;
}
else if (indexDDL==2){
minPlate=kMinPlate2;
maxPlate=kMaxPlate2;
minStrip2=kMinStrip2;
maxStrip2=kMaxStrip2;
minPadz=kMinPadz2;
maxPadz=kMaxPadz2;
minPadx=kMinPadx2;
maxPadx=kMaxPadx2;
}
else if (indexDDL==3){
minPlate=kMinPlate3;
maxPlate=kMaxPlate3;
minStrip2=kMinStrip3;
maxStrip2=kMaxStrip3;
minPadz=kMinPadz3;
maxPadz=kMaxPadz3;
minPadx=kMinPadx3;
maxPadx=kMaxPadx3;
}
Int_t ichTOF=0;
Int_t minStrip=0;
Int_t maxStrip=18;
for (Int_t iPlate=minPlate;iPlate<=maxPlate;iPlate++){
if (iPlate==2) {
maxStrip = maxStrip2;
minStrip = minStrip2;
}
else {
maxStrip = 18;
minStrip = 0;
}
for (Int_t iStrip=minStrip;iStrip<=maxStrip;iStrip++){
for (Int_t iPadz=minPadz;iPadz<=maxPadz;iPadz++){
for (Int_t iPadx=minPadx;iPadx<=maxPadx;iPadx++){
volume[1]=iPlate;
volume[2]=iStrip;
volume[3]=iPadz;
volume[4]=iPadx;
if (fVerbose)
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]));
if (indexDDL==0 || indexDDL==2){
array[ichTOF]=geom->GetIndex(volume);
if (fVerbose)
AliInfo(Form(" ichTOF = %i, TOFChannel = %i",ichTOF,array[ichTOF]));
}
else {
array[ichTOF]=geom->GetIndex(volume);
if (fVerbose)
AliInfo(Form(" ichTOF = %i, TOFChannel = %i",ichTOF,array[ichTOF]));
}
ichTOF++;
}
}
}
}
if ((indexDDL%2==0 && ichTOF!=2160) ||
(indexDDL%2==1 && ichTOF!=2208)) {
AliWarning(Form("Something strange occurred, number of entries in array different from expected! Please, check! ichTOF = %i",ichTOF));
}
return;
}
void AliTOFDecoder::PrintStack(const UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh, const AliRawDataHeaderV3 *cdhV3)
{
Short_t currentMiniEventID = cdh ? cdh->GetMiniEventID() : (Short_t)(-1);
currentMiniEventID = cdhV3 ? cdhV3->GetMiniEventID() : currentMiniEventID;
Short_t currentEventID1 = cdh ? cdh->GetEventID1() : (Short_t)(-1);
currentEventID1 = cdhV3 ? cdhV3->GetEventID1() : currentEventID1;
if (!cdh && !cdhV3)
AliWarning("CDH not valid: deltaBunchID not reliable ");
else
AliDebug(1, Form("EvID1 = %d, EvID2 = %d, currentMiniEventID = %d", currentEventID1, cdh ? cdh->GetEventID2() : cdhV3->GetEventID2(), currentMiniEventID));
AliInfo("Printing raw data stack for current equipment\n");
AliInfo(" wordN - Hex Word ");
for (Int_t iWord = 0; iWord < nWords; iWord++, rawData++){
if (iWord<10) AliInfo(Form(" %i - 0x%08x",iWord,*rawData));
if (iWord>9 &&iWord<100) AliInfo(Form(" %i - 0x%08x",iWord,*rawData));
if (iWord>99) AliInfo(Form(" %i - 0x%08x",iWord,*rawData));
}
return;
}