]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFDecoder.cxx
Added macro to lauch TOF QA task with extended functionality via plugin
[u/mrichter/AliRoot.git] / TOF / AliTOFDecoder.cxx
index 50889ff61c64b949b9d8c1359834d5f505c02305..48cf58215caaf9a111eb148d80a113ddfb46f6cc 100644 (file)
@@ -50,6 +50,7 @@ TOF Raw Data decoder
 #include "AliTOFDecoder.h"
 #include "AliTOFGeometry.h"
 #include "AliRawDataHeader.h"
+#include "AliTOFRawDataFormat.h"
 
 ClassImp(AliTOFDecoder)
 
@@ -61,20 +62,24 @@ AliTOFDecoder::AliTOFDecoder() :
   fV2718Patch(kFALSE),
   fDataBuffer(0x0),
   fPackedDataBuffer(0x0),
-  fTRMGlobalHeader(0x0),
-  fTRMGlobalTrailer(0x0),
-  fTRMChainHeader(0x0),
-  fTRMChainTrailer(0x0),
-  fTDCPackedHit(0x0),
-  fTDCUnpackedHit(0x0),
-  fTRMTDCError(0x0),
-  fTRMDiagnosticErrorWord1(0x0),
-  fTRMDiagnosticErrorWord2(0x0),
+  //fTRMGlobalHeader(0x0),
+  //fTRMGlobalTrailer(0x0),
+  //fTRMChainHeader(0x0),
+  //fTRMChainTrailer(0x0),
+  //fTDCPackedHit(0x0),
+  //fTDCUnpackedHit(0x0),
+  //fTRMTDCError(0x0),
+  //fTRMDiagnosticErrorWord1(0x0),
+  //fTRMDiagnosticErrorWord2(0x0),
   fSpiderCurrentSlotID(-1),
   fSpiderCurrentChain(-1),
   fSpiderCurrentTDC(-1)
 {
   //default constructor
+
+  for (Int_t chan=0;chan<N_CHANNEL;chan++)
+    fSpiderLeadingFlag[chan] = kFALSE;
+
 }
 
 //_________________________________________________________________
@@ -85,61 +90,52 @@ AliTOFDecoder::AliTOFDecoder(AliTOFHitDataBuffer *DataBuffer, AliTOFHitDataBuffe
   fV2718Patch(kFALSE),
   fDataBuffer(DataBuffer),
   fPackedDataBuffer(PackedDataBuffer),
-  fTRMGlobalHeader(0x0),
-  fTRMGlobalTrailer(0x0),
-  fTRMChainHeader(0x0),
-  fTRMChainTrailer(0x0),
-  fTDCPackedHit(0x0),
-  fTDCUnpackedHit(0x0),
-  fTRMTDCError(0x0),
-  fTRMDiagnosticErrorWord1(0x0),
-  fTRMDiagnosticErrorWord2(0x0),
+  //fTRMGlobalHeader(0x0),
+  //fTRMGlobalTrailer(0x0),
+  //fTRMChainHeader(0x0),
+  //fTRMChainTrailer(0x0),
+  //fTDCPackedHit(0x0),
+  //fTDCUnpackedHit(0x0),
+  //fTRMTDCError(0x0),
+  //fTRMDiagnosticErrorWord1(0x0),
+  //fTRMDiagnosticErrorWord2(0x0),
   fSpiderCurrentSlotID(-1),
   fSpiderCurrentChain(-1),
   fSpiderCurrentTDC(-1)
 {
   //another constructor
+
+  for (Int_t chan=0;chan<N_CHANNEL;chan++)
+    fSpiderLeadingFlag[chan] = kFALSE;
+
 }
 
 //_________________________________________________________________
 
 AliTOFDecoder::AliTOFDecoder(const AliTOFDecoder &source) : 
-  TObject(),
-  fVerbose(0),
-  fV2718Patch(kFALSE),
-  fDataBuffer(0x0),
-  fPackedDataBuffer(0x0),
-  fTRMGlobalHeader(0x0),
-  fTRMGlobalTrailer(0x0),
-  fTRMChainHeader(0x0),
-  fTRMChainTrailer(0x0),
-  fTDCPackedHit(0x0),
-  fTDCUnpackedHit(0x0),
-  fTRMTDCError(0x0),
-  fTRMDiagnosticErrorWord1(0x0),
-  fTRMDiagnosticErrorWord2(0x0),
-  fSpiderCurrentSlotID(-1),
-  fSpiderCurrentChain(-1),
-  fSpiderCurrentTDC(-1)
+  TObject(source),
+  fVerbose(source.fVerbose),
+  fV2718Patch(source.fV2718Patch),
+  fDataBuffer(source.fDataBuffer),
+  fPackedDataBuffer(source.fPackedDataBuffer),
+  //fTRMGlobalHeader(source.fTRMGlobalHeader),
+  //fTRMGlobalTrailer(source.fTRMGlobalTrailer),
+  //fTRMChainHeader(source.fTRMChainHeader),
+  //fTRMChainTrailer(source.fTRMChainTrailer),
+  //fTDCPackedHit(source.fTDCPackedHit),
+  //fTDCUnpackedHit(source.fTDCUnpackedHit),
+  //fTRMTDCError(source.fTRMTDCError),
+  //fTRMDiagnosticErrorWord1(source.fTRMDiagnosticErrorWord1),
+  //fTRMDiagnosticErrorWord2(source.fTRMDiagnosticErrorWord2),
+  fSpiderCurrentSlotID(source.fSpiderCurrentSlotID),
+  fSpiderCurrentChain(source.fSpiderCurrentChain),
+  fSpiderCurrentTDC(source.fSpiderCurrentTDC)
 {
   //copy constructor
+
+  for (Int_t chan=0;chan<N_CHANNEL;chan++)
+    fSpiderLeadingFlag[chan] = source.fSpiderLeadingFlag[chan];
   
-  this->fVerbose = source.fVerbose;
-  this->fV2718Patch = source.fV2718Patch;
-  this->fDataBuffer = source.fDataBuffer;
-  this->fPackedDataBuffer = source.fPackedDataBuffer;
-  this->fTRMGlobalHeader = source.fTRMGlobalHeader;
-  this->fTRMGlobalTrailer = source.fTRMGlobalTrailer;
-  this->fTRMChainHeader = source.fTRMChainHeader;
-  this->fTRMChainTrailer = source.fTRMChainTrailer;
-  this->fTDCPackedHit = source.fTDCPackedHit;
-  this->fTDCUnpackedHit = source.fTDCUnpackedHit;
-  this->fTRMTDCError = source.fTRMTDCError;
-  this->fTRMDiagnosticErrorWord1 = source.fTRMDiagnosticErrorWord1;
-  this->fTRMDiagnosticErrorWord2 = source.fTRMDiagnosticErrorWord2;
-  this->fSpiderCurrentSlotID = source.fSpiderCurrentSlotID;
-  this->fSpiderCurrentChain = source.fSpiderCurrentChain;
-  this->fSpiderCurrentTDC = source.fSpiderCurrentTDC;
 }
 
 //_________________________________________________________________
@@ -149,22 +145,29 @@ AliTOFDecoder::operator = (const AliTOFDecoder &source)
 {
   //operator =
 
-  this->fVerbose = source.fVerbose;
-  this->fV2718Patch = source.fV2718Patch;
-  this->fDataBuffer = source.fDataBuffer;
-  this->fPackedDataBuffer = source.fPackedDataBuffer;
-  this->fTRMGlobalHeader = source.fTRMGlobalHeader;
-  this->fTRMGlobalTrailer = source.fTRMGlobalTrailer;
-  this->fTRMChainHeader = source.fTRMChainHeader;
-  this->fTRMChainTrailer = source.fTRMChainTrailer;
-  this->fTDCPackedHit = source.fTDCPackedHit;
-  this->fTDCUnpackedHit = source.fTDCUnpackedHit;
-  this->fTRMTDCError = source.fTRMTDCError;
-  this->fTRMDiagnosticErrorWord1 = source.fTRMDiagnosticErrorWord1;
-  this->fTRMDiagnosticErrorWord2 = source.fTRMDiagnosticErrorWord2;
-  this->fSpiderCurrentSlotID = source.fSpiderCurrentSlotID;
-  this->fSpiderCurrentChain = source.fSpiderCurrentChain;
-  this->fSpiderCurrentTDC = source.fSpiderCurrentTDC;
+  if (this == &source)
+    return *this;
+
+  TObject::operator=(source);
+  fVerbose = source.fVerbose;
+  fV2718Patch = source.fV2718Patch;
+  fDataBuffer = source.fDataBuffer;
+  fPackedDataBuffer = source.fPackedDataBuffer;
+  //fTRMGlobalHeader = source.fTRMGlobalHeader;
+  //fTRMGlobalTrailer = source.fTRMGlobalTrailer;
+  //fTRMChainHeader = source.fTRMChainHeader;
+  //fTRMChainTrailer = source.fTRMChainTrailer;
+  //fTDCPackedHit = source.fTDCPackedHit;
+  //fTDCUnpackedHit = source.fTDCUnpackedHit;
+  //fTRMTDCError = source.fTRMTDCError;
+  //fTRMDiagnosticErrorWord1 = source.fTRMDiagnosticErrorWord1;
+  //fTRMDiagnosticErrorWord2 = source.fTRMDiagnosticErrorWord2;
+  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;
 }
 
@@ -174,7 +177,7 @@ AliTOFDecoder::~AliTOFDecoder()
 //_________________________________________________________________
 
 Bool_t
-AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh)
+AliTOFDecoder::Decode(const UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh)
 {
   /* main decoding routine.
    * it loops over nWords 32-bit words 
@@ -184,6 +187,18 @@ AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh
    * classes.
    */
 
+  AliTOFDRMStatusHeader3 *lDRMStatusHeader3;
+  AliTOFTRMGlobalHeader          *lTRMGlobalHeader; //TRM global header
+  AliTOFTRMGlobalTrailer         *lTRMGlobalTrailer; //TRM global trailer
+  AliTOFTRMChainHeader           *lTRMChainHeader; //TRM chain header
+  //AliTOFTRMChainTrailer          *lTRMChainTrailer; //TRM chain trailer
+  AliTOFTDCPackedHit             *lTDCPackedHit; //TDC packed hit
+  AliTOFTDCUnpackedHit           *lTDCUnpackedHit; //TDC unpacked hit
+  //AliTOFTRMTDCError              *lTRMTDCError; //TRM TDC error
+  //AliTOFTRMDiagnosticErrorWord1  *lTRMDiagnosticErrorWord1; //TRM diagnostic error word 1
+  //AliTOFTRMDiagnosticErrorWord2  *lTRMDiagnosticErrorWord2; //TRM diagnostica error word 2
+
+
   AliTOFHitData hitData;
   
   //useful variables
@@ -199,7 +214,10 @@ AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh
   Short_t  currentACQ = -1;
   Short_t  currentChain = -1;
   Short_t  currentBunchID = -1;
-  Short_t  currentMiniEventID = cdh ? cdh->GetMiniEventID() : (Short_t)-1;
+  Short_t  currentL0BCID = -1;
+  Short_t  currentMiniEventID = cdh ? cdh->GetMiniEventID() : (Short_t)(-1);
+  Short_t  currentEventID1 = cdh ? cdh->GetEventID1() : (Short_t)(-1);
+  AliDebug(1, Form("EvID1 = %d, EvID2 = %d, currentMiniEventID = %d", currentEventID1, cdh->GetEventID2(), currentMiniEventID));
   if (!cdh)
     AliWarning("CDH not valid: deltaBunchID not reliable ");
 
@@ -249,9 +267,18 @@ AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh
        decodeStatus = decodeStatus | DRM_BIT;
        
        //skip DRM data
-       for (Int_t i = 0; i < DRM_DATA_WORDS; i++, iWord++, rawData++){
+       for (Int_t i = 0; i < DRM_DATA_WORDS; i++, iWord++){
+         rawData++;
          if (fVerbose)
-           AliInfo(Form("  %02x - 0x%08x \t  DRM data",decodeStatus,*rawData));
+             AliInfo(Form("  %02x - 0x%08x \t  DRM data",decodeStatus,*rawData));
+         switch (i) {
+         case 2:
+           lDRMStatusHeader3 = (AliTOFDRMStatusHeader3*)rawData;
+           currentL0BCID = lDRMStatusHeader3->GetL0BCID();
+           break;
+         default:
+           break;
+         }
        }
        break;
        
@@ -269,7 +296,8 @@ AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh
        decodeStatus = decodeStatus | LTM_BIT;
        
        //skip LTM data
-       for (Int_t i = 0; i < LTM_DATA_WORDS; i++, iWord++, rawData++){
+       for (Int_t i = 0; i < LTM_DATA_WORDS; i++, iWord++){
+         rawData++;
          if (fVerbose)
            AliInfo(Form("  %02x - 0x%08x \t  LTM data",decodeStatus,*rawData));
        }
@@ -284,12 +312,12 @@ AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh
        }
        //decode status ok
        //set TRM global header
-       fTRMGlobalHeader = (AliTOFTRMGlobalHeader *)rawData;    
+       lTRMGlobalHeader = (AliTOFTRMGlobalHeader*)rawData;     
        //set current TRM
-       currentSlotID = fTRMGlobalHeader->GetSlotID();
-       currentACQ = fTRMGlobalHeader->GetACQBits();
+       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,fTRMGlobalHeader->GetSlotID(),fTRMGlobalHeader->GetACQBits(),fTRMGlobalHeader->GetLBit()));
+         AliInfo(Form("  %02x - 0x%08x \t  TRM global header \t slotID=%02d ACQ=%01d L=%01d",decodeStatus,*rawData,lTRMGlobalHeader->GetSlotID(),lTRMGlobalHeader->GetACQBits(),lTRMGlobalHeader->GetLBit()));
        //change decode status
        decodeStatus = decodeStatus | TRM_BIT;
        break;
@@ -345,9 +373,9 @@ AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh
        }
        //decode status ok
        //set TRM global trailer
-       fTRMGlobalTrailer = (AliTOFTRMGlobalTrailer *)rawData;  
+       lTRMGlobalTrailer = (AliTOFTRMGlobalTrailer *)rawData;  
        if (fVerbose)
-         AliInfo(Form("  %02x - 0x%08x \t  TRM global trailer \t CRC=%04d eventCounter=%04d",decodeStatus,*rawData,fTRMGlobalTrailer->GetEventCRC(),fTRMGlobalTrailer->GetEventCounter()));
+         AliInfo(Form("  %02x - 0x%08x \t  TRM global trailer \t CRC=%04d eventCounter=%04d",decodeStatus,*rawData,lTRMGlobalTrailer->GetEventCRC(),lTRMGlobalTrailer->GetEventCounter()));
        //change decode status
        decodeStatus = decodeStatus & ~TRM_BIT;
        break; 
@@ -366,9 +394,9 @@ AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh
        return kTRUE;
       }
       //decode status ok
-      fTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
+      lTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
       currentChain = 0;
-      currentBunchID = fTRMChainHeader->GetBunchID();
+      currentBunchID = lTRMChainHeader->GetBunchID();
       if (fVerbose)
        AliInfo(Form("  %02x - 0x%08x \t  TRM chain A header \t chain=%01d bunchID=%04d",decodeStatus,*rawData,currentChain,currentBunchID));
       //change decode status
@@ -395,9 +423,9 @@ AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh
        return kTRUE;
       }
       //decode status ok
-      fTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
+      lTRMChainHeader = (AliTOFTRMChainHeader *)rawData;
       currentChain = 1;
-      currentBunchID = fTRMChainHeader->GetBunchID();
+      currentBunchID = lTRMChainHeader->GetBunchID();
       if (fVerbose)
        AliInfo(Form("  %02x - 0x%08x \t  TRM chain B header \t chain=%01d bunchID=%04d",decodeStatus,*rawData,currentChain,currentBunchID));
       //change decode status
@@ -441,25 +469,26 @@ AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh
        
       case PACKING_ENABLED_ACQ:
        //decode TDC packed hit
-       fTDCPackedHit = (AliTOFTDCPackedHit *)rawData;
-       fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
+       lTDCPackedHit = (AliTOFTDCPackedHit *)rawData;
+       lTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
        //set hit in the equipment data
        hitData.SetDDLID(currentDDL);
        hitData.SetSlotID(currentSlotID);
        hitData.SetACQ(currentACQ);
        hitData.SetChain(currentChain);
-       hitData.SetPS(fTDCPackedHit->GetPSBits());
-       hitData.SetTDC(fTDCPackedHit->GetTDCID());
-       hitData.SetChan(fTDCPackedHit->GetChan());
-       hitData.SetTime((float)fTDCPackedHit->GetHitTime() * TIME_BIN_WIDTH);
-       hitData.SetTimeBin(fTDCPackedHit->GetHitTime());
-       hitData.SetTOT((float)fTDCPackedHit->GetTOTWidth() * TOT_BIN_WIDTH);
-       hitData.SetTOTBin(fTDCPackedHit->GetTOTWidth());
-       hitData.SetDeltaBunchID(currentBunchID - currentMiniEventID);
+       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);
        //orphane leading hit
        if (hitData.GetPS()==LEADING_HIT_PS){
-         hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
-         hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
+         hitData.SetTime((float)lTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
+         hitData.SetTimeBin(lTDCUnpackedHit->GetHitTime());
          //set TOT to zero
          hitData.SetTOT(0);
          hitData.SetTOTBin(0);
@@ -475,8 +504,8 @@ AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh
        }
        //orphane trailing hit
        else if (hitData.GetPS()==TRAILING_HIT_PS){
-         hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
-         hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
+         hitData.SetTime((float)lTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
+         hitData.SetTimeBin(lTDCUnpackedHit->GetHitTime());
          //set TOT to not measured
          hitData.SetTOT(-1);
          hitData.SetTOTBin(-1);
@@ -536,20 +565,21 @@ AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh
        
       case LEADING_ONLY_ACQ: case TRAILING_ONLY_ACQ:
        //decode TDC unpacked hit
-       fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
+       lTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
        //set hit in the equipment data
        hitData.SetDDLID(currentDDL);
        hitData.SetSlotID(currentSlotID);
        hitData.SetACQ(currentACQ);
        hitData.SetChain(currentChain);
-       hitData.SetPS(fTDCUnpackedHit->GetPSBits());
-       hitData.SetTDC(fTDCUnpackedHit->GetTDCID());
-       hitData.SetChan(fTDCUnpackedHit->GetChan());
-       hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
-       hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
+       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 - currentMiniEventID);
+       hitData.SetDeltaBunchID(currentBunchID - currentEventID1);
+       hitData.SetL0L1Latency(currentMiniEventID - currentL0BCID);
        //push hit data in data buffer
          if (fDataBuffer != 0x0)
            fDataBuffer->Add(hitData);
@@ -573,20 +603,21 @@ AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh
        
       case PACKING_DISABLED_ACQ:
        //decode TDC unpacked hit
-       fTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
+       lTDCUnpackedHit = (AliTOFTDCUnpackedHit *)rawData;
        //set hit in the equipment data
        hitData.SetDDLID(currentDDL);
        hitData.SetSlotID(currentSlotID);
        hitData.SetACQ(currentACQ);
        hitData.SetChain(currentChain);
-       hitData.SetPS(fTDCUnpackedHit->GetPSBits());
-       hitData.SetTDC(fTDCUnpackedHit->GetTDCID());
-       hitData.SetChan(fTDCUnpackedHit->GetChan());
-       hitData.SetTime((float)fTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
-       hitData.SetTimeBin(fTDCUnpackedHit->GetHitTime());
+       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 - currentMiniEventID);
+       hitData.SetDeltaBunchID(currentBunchID - currentEventID1);
+       hitData.SetL0L1Latency(currentMiniEventID - currentL0BCID);
        //push hit data in data buffer
          if (fDataBuffer != 0x0)
            fDataBuffer->Add(hitData);
@@ -803,10 +834,9 @@ 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);
-  //AliInfo(Form(" Sector = %i, DDL within sector = %i",iSector, indexDDL));
-  if (fVerbose){
+  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;
@@ -875,20 +905,20 @@ void AliTOFDecoder::GetArrayDDL(Int_t* array, Int_t ddl){
          volume[2]=iStrip;
          volume[3]=iPadz;
          volume[4]=iPadx;
-         if (fVerbose){
+         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){
+           if (fVerbose)
              AliInfo(Form(" ichTOF = %i, TOFChannel = %i",ichTOF,array[ichTOF]));
-           }
+
          }
          else {
            array[ichTOF]=geom->GetIndex(volume);
-           if (fVerbose){
+           if (fVerbose)
              AliInfo(Form(" ichTOF = %i, TOFChannel = %i",ichTOF,array[ichTOF]));
-           }
+
          }
          ichTOF++;
        }
@@ -896,12 +926,34 @@ void AliTOFDecoder::GetArrayDDL(Int_t* array, Int_t ddl){
     }
   }
   //AliInfo(Form("ichTOF = %i",ichTOF));
-  if (((indexDDL==0 || indexDDL==2)&ichTOF!=2160) || ((indexDDL==1 || indexDDL==3)&ichTOF!=2208)){
+  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)
+{
+  /* It loops over nWords 32-bit words 
+   * starting at *rawData and prints them in 0x format.
+   * It does not decode them!
+   */
 
-
-  
+ Short_t  currentMiniEventID = cdh ? cdh->GetMiniEventID() : (Short_t)(-1);
+ Short_t  currentEventID1 = cdh ? cdh->GetEventID1() : (Short_t)(-1);
+ AliDebug(1, Form("EvID1 = %d, EvID2 = %d, currentMiniEventID = %d", currentEventID1, cdh->GetEventID2(), currentMiniEventID));
+ if (!cdh)
+   AliWarning("CDH not valid: deltaBunchID not reliable ");
+
+ AliInfo("Printing raw data stack for current equipment\n");
+ AliInfo("  wordN  -  Hex Word "); 
+ //loop over raw data
+ 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;
+}