]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/MUONRawStreamTracker.C
Adding AliMUONQAIndices in base
[u/mrichter/AliRoot.git] / MUON / MUONRawStreamTracker.C
index 8f98aa31b3f9e1cc365f54d155439a9081f5baf0..995f4b73379a793b403977912c0473b021169d9a 100644 (file)
 /// - and one, using an iterator, where we're directly accessing the pad informations 
 /// (charge).
 ///
-/// The different stucture of the payload are readout and stored in TClonesArray
-/// with AliMUONRawStreamTracker class.
-/// The macro just simply reads again the TClonesArray contents.
-/// The parameters of each structure could be seen in the container classes
-/// AliMUONBlockHeader, AliMUONBlockHeader, AliMUONBusStruct.
-/// The class AliMUONDDLTracker manages the structure containers.
-/// The number of structures in the rawdata file could be set.
 
 
 #if !defined(__CINT__) || defined(__MAKECINT__)
 
 // RAW includes
-#include "AliRawReaderDate.h"
-#include "AliRawReaderFile.h"
-#include "AliRawReaderRoot.h"
+#include "AliRawReader.h"
 
 // MUON includes
-#include "AliMUONRawStreamTracker.h"
 #include "AliMUONRawStreamTrackerHP.h"
-#include "AliMUONDspHeader.h"
-#include "AliMUONBlockHeader.h"
-#include "AliMUONBusStruct.h"
-#include "AliMUONDDLTracker.h"
-
 #include "TStopwatch.h"
+#include "AliRawDataErrorLog.h"
+#include "Riostream.h"
 
 #endif
 
 void MUONRawStreamTrackerExpert(TString fileName = "./", Int_t maxEvent = 1000,  
                                 Int_t minDDL = 0, Int_t maxDDL = 19)
 {
-  /// Reads the data from fileName, using an "expert" mode where all substructures
-  /// are looped upon.
+  /// This routine shows how to use the decoder's expert interface.
   
   TStopwatch timer;
   timer.Start(kTRUE);
   
-  AliRawReader* rawReader = 0x0;
-  
-  // check extention to choose the rawdata file format
-  if (fileName.EndsWith("/")) {
-    rawReader = new AliRawReaderFile(fileName); // DDL files
-  } else if (fileName.EndsWith(".root")) {
-    rawReader = new AliRawReaderRoot(fileName);
-  } else if (!fileName.IsNull()) {
-    rawReader = new AliRawReaderDate(fileName); // DATE file
-  }
+  AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
   
   // raw stream
-  AliMUONRawStreamTracker* rawStream  = new AliMUONRawStreamTracker(rawReader);    
-  
-  // set the number of DDL block Dsp & buspatch structures that are PRESENT in the rawdata file
-  // it's NOT the number to be read.
-  // default wise set to 20, 2, 5 ans 5 respectively.
-  //    rawStream->SetMaxDDL(xx);
-  //    rawStream->SetMaxBlock(xx);
-  //    rawStream->SetMaxDsp(xx);
-  //    rawStream->SetMaxBus(xx);
-  
-  // containers
-  AliMUONDDLTracker*       ddlTracker = 0x0;
-  AliMUONBlockHeader*      blkHeader  = 0x0;
-  AliMUONDspHeader*        dspHeader  = 0x0;
-  AliMUONBusStruct*        busStruct  = 0x0;
-  
-  //   Loop over events  
-  Int_t iEvent = 0;
-  Int_t dataSize;
-  
-  while (rawReader->NextEvent()) {
-    
-    if (iEvent == maxEvent)
-      break;
-    
-    printf("Event %d\n",iEvent++);
-    
-    // read DDL while < 20 DDL
-    while(rawStream->NextDDL()) {
-      
-      if (rawStream->GetDDL() < minDDL || rawStream->GetDDL() > maxDDL)
-        continue;
-      
-      printf("\niDDL %d\n", rawStream->GetDDL());
-      
-      ddlTracker =  rawStream->GetDDLTracker();
-      
-      // loop over block structure
-      Int_t nBlock = ddlTracker->GetBlkHeaderEntries();
-      for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){
-        
-        blkHeader = ddlTracker->GetBlkHeaderEntry(iBlock);
-        printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
-       
-        // loop over DSP structure
-        Int_t nDsp = blkHeader->GetDspHeaderEntries();
-        for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){   //DSP loop
-          
-          dspHeader =  blkHeader->GetDspHeaderEntry(iDsp);
-          printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord());
-          
-          // loop over BusPatch structure
-          Int_t nBusPatch = dspHeader->GetBusPatchEntries();
-          for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) {  
-            
-            busStruct = dspHeader->GetBusPatchEntry(iBusPatch);
-            
-            //      printf("busPatchId %d", busStruct->GetBusPatchId());
-            //      printf(" BlockId %d", busStruct->GetBlockId());
-            //      printf(" DspId %d\n", busStruct->GetDspId());
-            
-            // loop over data
-            dataSize = busStruct->GetLength();
-            for (Int_t iData = 0; iData < dataSize; iData++) {
-              
-              Int_t  manuId    = busStruct->GetManuId(iData);
-              Int_t  channelId = busStruct->GetChannelId(iData);
-              Int_t  charge    = busStruct->GetCharge(iData);
-              printf("buspatch %5d manuI %4d channel %3d charge %4d\n", 
-                     busStruct->GetBusPatchId(),
-                     manuId, 
-                     channelId, charge);
-            } // iData
-          } // iBusPatch
-        } // iDsp
-      } // iBlock
-    } // NextDDL
-  }// NextEvent
-  
-  delete rawReader;
-  delete rawStream;
-  timer.Print();
-}
-
-
-void MUONRawStreamTrackerHPExpert(TString fileName = "./", Int_t maxEvent = 1000,  
-                                Int_t minDDL = 0, Int_t maxDDL = 19)
-{
-  /// This routine shows how to use the high performance decoder's expert interface.
-  
-  TStopwatch timer;
-  timer.Start(kTRUE);
-  
-  AliRawReader* rawReader = 0x0;
-  
-  // check extention to choose the rawdata file format
-  if (fileName.EndsWith("/")) {
-    rawReader = new AliRawReaderFile(fileName); // DDL files
-  } else if (fileName.EndsWith(".root")) {
-    rawReader = new AliRawReaderRoot(fileName);
-  } else if (!fileName.IsNull()) {
-    rawReader = new AliRawReaderDate(fileName); // DATE file
-  }
-  
-  // raw stream
-  AliMUONRawStreamTrackerHP* rawStream  = new AliMUONRawStreamTrackerHP(rawReader);
+  AliMUONRawStreamTrackerHP rawStream(rawReader);
   
   // light weight interfaces to headers
   const AliMUONRawStreamTrackerHP::AliBlockHeader*      blkHeader  = 0x0;
@@ -205,29 +77,29 @@ void MUONRawStreamTrackerHPExpert(TString fileName = "./", Int_t maxEvent = 1000
     printf("Event %d\n",iEvent++);
     
     // read DDL while < 20 DDL
-    while(rawStream->NextDDL()) {
+    while(rawStream.NextDDL()) {
       
-      if (rawStream->GetDDL() < minDDL || rawStream->GetDDL() > maxDDL)
+      if (rawStream.GetDDL() < minDDL || rawStream.GetDDL() > maxDDL)
         continue;
       
-      printf("\niDDL %d\n", rawStream->GetDDL());
+      printf("\niDDL %d\n", rawStream.GetDDL());
       
       // loop over block structure
-      Int_t nBlock = rawStream->GetBlockCount();
+      Int_t nBlock = rawStream.GetBlockCount();
       for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){
         
-        blkHeader = rawStream->GetBlockHeader(iBlock);
+        blkHeader = rawStream.GetBlockHeader(iBlock);
         printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
        
         // loop over DSP structure
-        Int_t nDsp = rawStream->GetDspCount(iBlock);
+        Int_t nDsp = rawStream.GetDspCount(iBlock);
         for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){   //DSP loop
           
           dspHeader =  blkHeader->GetDspHeader(iDsp);
           printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord());
           
           // loop over BusPatch structure
-          Int_t nBusPatch = rawStream->GetBusPatchCount(iBlock, iDsp);
+          Int_t nBusPatch = rawStream.GetBusPatchCount(iBlock, iDsp);
           for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) {  
             
             busStruct = dspHeader->GetBusPatch(iBusPatch);
@@ -251,33 +123,23 @@ void MUONRawStreamTrackerHPExpert(TString fileName = "./", Int_t maxEvent = 1000
   }// NextEvent
   
   delete rawReader;
-  delete rawStream;
   timer.Print();
 }
 
 
-void MUONRawStreamTrackerHPExpert2(TString fileName = "./", Int_t maxEvent = 1000,  
+void MUONRawStreamTrackerExpert2(TString fileName = "./", Int_t maxEvent = 1000,  
                                 Int_t minDDL = 0, Int_t maxDDL = 19)
 {
   /// This routine shows an alternate way to iterate over the DDL structures
-  /// compared to MUONRawStreamTrackerHPExpert().
+  /// compared to MUONRawStreamTrackerExpert().
   
   TStopwatch timer;
   timer.Start(kTRUE);
   
-  AliRawReader* rawReader = 0x0;
-  
-  // check extention to choose the rawdata file format
-  if (fileName.EndsWith("/")) {
-    rawReader = new AliRawReaderFile(fileName); // DDL files
-  } else if (fileName.EndsWith(".root")) {
-    rawReader = new AliRawReaderRoot(fileName);
-  } else if (!fileName.IsNull()) {
-    rawReader = new AliRawReaderDate(fileName); // DATE file
-  }
+  AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
   
   // raw stream
-  AliMUONRawStreamTrackerHP* rawStream  = new AliMUONRawStreamTrackerHP(rawReader);
+  AliMUONRawStreamTrackerHP rawStream(rawReader);
   
   // light weight interfaces to headers
   const AliMUONRawStreamTrackerHP::AliBlockHeader*      blkHeader  = 0x0;
@@ -296,32 +158,32 @@ void MUONRawStreamTrackerHPExpert2(TString fileName = "./", Int_t maxEvent = 100
     printf("Event %d\n",iEvent++);
     
     // read DDL while < 20 DDL
-    while(rawStream->NextDDL()) {
+    while(rawStream.NextDDL()) {
       
-      if (rawStream->GetDDL() < minDDL || rawStream->GetDDL() > maxDDL)
+      if (rawStream.GetDDL() < minDDL || rawStream.GetDDL() > maxDDL)
         continue;
       
-      printf("\niDDL %d\n", rawStream->GetDDL());
+      printf("\niDDL %d\n", rawStream.GetDDL());
       
       // loop over block structure
-      Int_t nBlock = rawStream->GetBlockCount();
+      Int_t nBlock = rawStream.GetBlockCount();
       for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){
         
-        blkHeader = rawStream->GetBlockHeader(iBlock);
+        blkHeader = rawStream.GetBlockHeader(iBlock);
         printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
        
         // loop over DSP structure
-        Int_t nDsp = rawStream->GetDspCount(iBlock);
+        Int_t nDsp = rawStream.GetDspCount(iBlock);
         for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){   //DSP loop
           
-          dspHeader =  rawStream->GetDspHeader(iBlock, iDsp);
+          dspHeader =  rawStream.GetDspHeader(iBlock, iDsp);
           printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord());
           
           // loop over BusPatch structure
-          Int_t nBusPatch = rawStream->GetBusPatchCount(iBlock, iDsp);
+          Int_t nBusPatch = rawStream.GetBusPatchCount(iBlock, iDsp);
           for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) {  
             
-            busStruct = rawStream->GetBusPatch(iBlock, iDsp, iBusPatch);
+            busStruct = rawStream.GetBusPatch(iBlock, iDsp, iBusPatch);
             
             // loop over data
             dataSize = busStruct->GetLength();
@@ -342,33 +204,23 @@ void MUONRawStreamTrackerHPExpert2(TString fileName = "./", Int_t maxEvent = 100
   }// NextEvent
   
   delete rawReader;
-  delete rawStream;
   timer.Print();
 }
 
 
-void MUONRawStreamTrackerHPExpert3(TString fileName = "./", Int_t maxEvent = 1000,  
+void MUONRawStreamTrackerExpert3(TString fileName = "./", Int_t maxEvent = 1000,  
                                 Int_t minDDL = 0, Int_t maxDDL = 19)
 {
   /// This routine shows yet another alternate way to iterate over the DDL
-  /// structures compared to MUONRawStreamTrackerHPExpert().
+  /// structures compared to MUONRawStreamTrackerExpert().
   
   TStopwatch timer;
   timer.Start(kTRUE);
   
-  AliRawReader* rawReader = 0x0;
-  
-  // check extention to choose the rawdata file format
-  if (fileName.EndsWith("/")) {
-    rawReader = new AliRawReaderFile(fileName); // DDL files
-  } else if (fileName.EndsWith(".root")) {
-    rawReader = new AliRawReaderRoot(fileName);
-  } else if (!fileName.IsNull()) {
-    rawReader = new AliRawReaderDate(fileName); // DATE file
-  }
+  AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
   
   // raw stream
-  AliMUONRawStreamTrackerHP* rawStream  = new AliMUONRawStreamTrackerHP(rawReader);
+  AliMUONRawStreamTrackerHP rawStream(rawReader);
   
   // light weight interfaces to headers
   const AliMUONRawStreamTrackerHP::AliBlockHeader*      blkHeader  = 0x0;
@@ -387,16 +239,16 @@ void MUONRawStreamTrackerHPExpert3(TString fileName = "./", Int_t maxEvent = 100
     printf("Event %d\n",iEvent++);
     
     // read DDL while < 20 DDL
-    while(rawStream->NextDDL()) {
+    while(rawStream.NextDDL()) {
       
-      if (rawStream->GetDDL() < minDDL || rawStream->GetDDL() > maxDDL)
+      if (rawStream.GetDDL() < minDDL || rawStream.GetDDL() > maxDDL)
         continue;
       
-      printf("\niDDL %d\n", rawStream->GetDDL());
+      printf("\niDDL %d\n", rawStream.GetDDL());
       
       // loop over block structure
       Int_t iBlock = 0;
-      blkHeader = rawStream->GetFirstBlockHeader();
+      blkHeader = rawStream.GetFirstBlockHeader();
       while (blkHeader != NULL)
       {
         printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
@@ -438,31 +290,21 @@ void MUONRawStreamTrackerHPExpert3(TString fileName = "./", Int_t maxEvent = 100
   }// NextEvent
   
   delete rawReader;
-  delete rawStream;
   timer.Print();
 }
 
 
 void MUONRawStreamTrackerSimple(TString fileName = "./", Int_t maxEvent = 1000)
 {
-  /// Reads the raw data in fileName, using a simplified interface (iterator
-  /// over pads).
+  /// This routine shows how to use the high performance decoder's simple interface.
+
   TStopwatch timer;
   timer.Start(kTRUE);
   
-  AliRawReader* rawReader = 0x0;
-  
-  // check extention to choose the rawdata file format
-  if (fileName.EndsWith("/")) {
-    rawReader = new AliRawReaderFile(fileName); // DDL files
-  } else if (fileName.EndsWith(".root")) {
-    rawReader = new AliRawReaderRoot(fileName);
-  } else if (!fileName.IsNull()) {
-    rawReader = new AliRawReaderDate(fileName); // DATE file
-  }
+  AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
   
   // raw stream
-  AliMUONRawStreamTracker* rawStream  = new AliMUONRawStreamTracker(rawReader);    
+  AliMUONRawStreamTrackerHP rawStream(rawReader);    
   
   //   Loop over events  
   Int_t iEvent = 0;
@@ -478,9 +320,9 @@ void MUONRawStreamTrackerSimple(TString fileName = "./", Int_t maxEvent = 1000)
     UShort_t manuId, adc;
     UChar_t manuChannel;
     
-    rawStream->First();
+    rawStream.First();
     
-    while ( rawStream->Next(busPatch,manuId,manuChannel,adc) )
+    while ( rawStream.Next(busPatch,manuId,manuChannel,adc) )
     {      
       printf("buspatch %5d manuI %4d channel %3d charge %4d\n", 
              busPatch,manuId,manuChannel, adc);
@@ -488,31 +330,36 @@ void MUONRawStreamTrackerSimple(TString fileName = "./", Int_t maxEvent = 1000)
   }
   
   delete rawReader;
-  delete rawStream;
   timer.Print();
 }
 
 
-void MUONRawStreamTrackerHPSimple(TString fileName = "./", Int_t maxEvent = 1000)
+void ShowErrors(const AliRawReader& rawReader)
 {
-  /// This routine shows how to use the high performance decoder's simple interface.
+  for ( Int_t i = 0; i < rawReader.GetNumberOfErrorLogs(); ++i )
+  {
+    AliRawDataErrorLog* error = rawReader.GetErrorLog(i);
+    error->Print();
+  }
+
+  cout << Form("Number of error logs : %d (%d events)",
+               rawReader.GetNumberOfErrorLogs(),
+               rawReader.GetNumberOfEvents()) << endl;
+}
+
+
+void MUONRawStreamTrackerSimple2(TString fileName = "./", Int_t maxEvent = 1000)
+{
+  /// This routine is an alternative to MUONRawStreamTrackerSimple() which is even faster.
 
   TStopwatch timer;
   timer.Start(kTRUE);
   
-  AliRawReader* rawReader = 0x0;
-  
-  // check extention to choose the rawdata file format
-  if (fileName.EndsWith("/")) {
-    rawReader = new AliRawReaderFile(fileName); // DDL files
-  } else if (fileName.EndsWith(".root")) {
-    rawReader = new AliRawReaderRoot(fileName);
-  } else if (!fileName.IsNull()) {
-    rawReader = new AliRawReaderDate(fileName); // DATE file
-  }
+  AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
   
   // raw stream
-  AliMUONRawStreamTrackerHP* rawStream  = new AliMUONRawStreamTrackerHP(rawReader);    
+  AliMUONRawStreamTrackerHP rawStream(rawReader);
+  rawStream.EnableRawReaderErrorLogger();
   
   //   Loop over events  
   Int_t iEvent = 0;
@@ -524,74 +371,61 @@ void MUONRawStreamTrackerHPSimple(TString fileName = "./", Int_t maxEvent = 1000
     
     printf("Event %d\n",iEvent++);
     
-    Int_t busPatch;
     UShort_t manuId, adc;
     UChar_t manuChannel;
     
-    rawStream->First();
-    
-    while ( rawStream->Next(busPatch,manuId,manuChannel,adc) )
-    {      
-      printf("buspatch %5d manuI %4d channel %3d charge %4d\n", 
-             busPatch,manuId,manuChannel, adc);
+    rawStream.First();
+    const AliMUONRawStreamTrackerHP::AliBusPatch* buspatch = NULL;
+    while ((buspatch = rawStream.Next()) != NULL)
+    {
+      for (UInt_t i = 0; i < buspatch->GetDataCount(); i++)
+      {
+        buspatch->GetData(i, manuId, manuChannel, adc);
+        printf("buspatch %5d manuI %4d channel %3d charge %4d\n", 
+               buspatch->GetBusPatchId(), manuId, manuChannel, adc);
+      }
     }
   }
+
+  ShowErrors(*rawReader);
   
   delete rawReader;
-  delete rawStream;
   timer.Print();
 }
 
-
-void MUONRawStreamTrackerHPSimple2(TString fileName = "./", Int_t maxEvent = 1000)
+void MUONRawStreamTrackerErrorCount(TString fileName = "collection://filelist", Int_t maxEvent = -1)
 {
-  /// This routine is an alternative to MUONRawStreamTrackerHPSimple() which is even faster.
-
+  /// This routine is just a loop to get the error log at the end
+  
   TStopwatch timer;
   timer.Start(kTRUE);
   
-  AliRawReader* rawReader = 0x0;
-  
-  // check extention to choose the rawdata file format
-  if (fileName.EndsWith("/")) {
-    rawReader = new AliRawReaderFile(fileName); // DDL files
-  } else if (fileName.EndsWith(".root")) {
-    rawReader = new AliRawReaderRoot(fileName);
-  } else if (!fileName.IsNull()) {
-    rawReader = new AliRawReaderDate(fileName); // DATE file
-  }
+  AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
   
   // raw stream
-  AliMUONRawStreamTrackerHP* rawStream  = new AliMUONRawStreamTrackerHP(rawReader);    
+  AliMUONRawStreamTrackerHP rawStream(rawReader);
+  rawStream.EnableRawReaderErrorLogger();    
+  rawStream.DisableWarnings();    
   
   //   Loop over events  
   Int_t iEvent = 0;
   
-  while (rawReader->NextEvent()) {
-    
-    if (iEvent == maxEvent)
-      break;
-    
-    printf("Event %d\n",iEvent++);
-    
-    UShort_t manuId, adc;
-    UChar_t manuChannel;
+  while (rawReader->NextEvent()) 
+  {    
+    if (iEvent == maxEvent) break;
     
-    rawStream->First();
+    rawStream.First();
+
     const AliMUONRawStreamTrackerHP::AliBusPatch* buspatch = NULL;
-    while ((buspatch = rawStream->Next()) != NULL)
+    
+    while ((buspatch = rawStream.Next()) != NULL)
     {
-      for (UInt_t i = 0; i < buspatch->GetDataCount(); i++)
-      {
-        buspatch->GetData(i, manuId, manuChannel, adc);
-        printf("buspatch %5d manuI %4d channel %3d charge %4d\n", 
-               buspatch->GetBusPatchId(), manuId, manuChannel, adc);
-      }
     }
   }
   
+  ShowErrors(*rawReader);
+  
   delete rawReader;
-  delete rawStream;
   timer.Print();
 }