]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFDecoder.cxx
Enabled option for selecting tree name in trneding macro
[u/mrichter/AliRoot.git] / TOF / AliTOFDecoder.cxx
index 68146d367e608890bb4b26f73cd4187fc4cc2692..c71d00a75c33cacd04c46b55648f8bfea723aac2 100644 (file)
@@ -50,6 +50,7 @@ TOF Raw Data decoder
 #include "AliTOFDecoder.h"
 #include "AliTOFGeometry.h"
 #include "AliRawDataHeader.h"
+#include "AliRawDataHeaderV3.h"
 #include "AliTOFRawDataFormat.h"
 
 ClassImp(AliTOFDecoder)
@@ -76,6 +77,10 @@ AliTOFDecoder::AliTOFDecoder() :
   fSpiderCurrentTDC(-1)
 {
   //default constructor
+
+  for (Int_t chan=0;chan<N_CHANNEL;chan++)
+    fSpiderLeadingFlag[chan] = kFALSE;
+
 }
 
 //_________________________________________________________________
@@ -100,6 +105,10 @@ AliTOFDecoder::AliTOFDecoder(AliTOFHitDataBuffer *DataBuffer, AliTOFHitDataBuffe
   fSpiderCurrentTDC(-1)
 {
   //another constructor
+
+  for (Int_t chan=0;chan<N_CHANNEL;chan++)
+    fSpiderLeadingFlag[chan] = kFALSE;
+
 }
 
 //_________________________________________________________________
@@ -124,6 +133,9 @@ AliTOFDecoder::AliTOFDecoder(const AliTOFDecoder &source) :
   fSpiderCurrentTDC(source.fSpiderCurrentTDC)
 {
   //copy constructor
+
+  for (Int_t chan=0;chan<N_CHANNEL;chan++)
+    fSpiderLeadingFlag[chan] = source.fSpiderLeadingFlag[chan];
   
 }
 
@@ -154,6 +166,9 @@ AliTOFDecoder::operator = (const AliTOFDecoder &source)
   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;
 }
 
@@ -163,7 +178,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, const AliRawDataHeaderV3 *cdhV3)
 {
   /* main decoding routine.
    * it loops over nWords 32-bit words 
@@ -173,6 +188,7 @@ 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
@@ -199,11 +215,15 @@ 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  currentEventID1 = cdh ? cdh->GetEventID1() : (Short_t)-1;
-  AliDebug(1, Form("EvID1 = %d, EvID2 = %d, currentMiniEventID = %d", currentEventID1, cdh->GetEventID2(), currentMiniEventID));
-  if (!cdh)
+  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));
 
   /*** V2718 patch ***/
   if (fV2718Patch){
@@ -251,9 +271,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;
        
@@ -271,7 +300,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));
        }
@@ -458,6 +488,7 @@ AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh
        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)lTDCUnpackedHit->GetHitTime() * TIME_BIN_WIDTH);
@@ -552,6 +583,7 @@ AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh
        hitData.SetTOT(-1.);
        hitData.SetTOTBin(-1);
        hitData.SetDeltaBunchID(currentBunchID - currentEventID1);
+       hitData.SetL0L1Latency(currentMiniEventID - currentL0BCID);
        //push hit data in data buffer
          if (fDataBuffer != 0x0)
            fDataBuffer->Add(hitData);
@@ -589,6 +621,7 @@ AliTOFDecoder::Decode(UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh
        hitData.SetTOT(-1.);
        hitData.SetTOTBin(-1);
        hitData.SetDeltaBunchID(currentBunchID - currentEventID1);
+       hitData.SetL0L1Latency(currentMiniEventID - currentL0BCID);
        //push hit data in data buffer
          if (fDataBuffer != 0x0)
            fDataBuffer->Add(hitData);
@@ -903,3 +936,31 @@ void AliTOFDecoder::GetArrayDDL(Int_t* array, Int_t ddl){
   }
   return;
 }
+
+//------------------------------------------------------------
+void AliTOFDecoder::PrintStack(const UInt_t *rawData, Int_t nWords, const AliRawDataHeader *cdh, const AliRawDataHeaderV3 *cdhV3)
+{
+  /* 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);
+ 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 "); 
+ //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;
+}