]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/MUONTimeRawStreamTracker.C
Fix from for producing a dataset via the alien plugin. Redirecting the alien 'find...
[u/mrichter/AliRoot.git] / MUON / MUONTimeRawStreamTracker.C
index d0c96748f9c36e90da8aa61d6986eda0e2900cc2..3b90aea2f16b6a80dac994700569b6205358a218 100644 (file)
@@ -37,6 +37,8 @@
 
 #if !defined(__CINT__) || defined(__MAKECINT__)
 
+#include "AliCodeTimer.h"
+
 // MUON includes
 #include "AliMUONRawStreamTracker.h"
 #include "AliMUONRawStreamTrackerHP.h"
@@ -46,9 +48,7 @@
 #include "AliMUONDDLTracker.h"
 
 // RAW includes
-#include "AliRawReaderDate.h"
-#include "AliRawReaderFile.h"
-#include "AliRawReaderRoot.h"
+#include "AliRawReader.h"
 #include "AliRawReaderMemory.h"
 #include "AliRawDataHeader.h"
 
@@ -82,21 +82,7 @@ UInt_t LoadFiles(AliBufferInfo*& list, TString fileName = "./", Int_t maxEvent =
 {
        /// Reads in the DDL files into memory buffers as a linked list.
 
-       AliRawReader* rawReader = NULL;
-  
-       // 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()); 
 
        if (rawReader == NULL)
        {
@@ -157,7 +143,7 @@ UInt_t LoadFiles(AliBufferInfo*& list, TString fileName = "./", Int_t maxEvent =
 
 UInt_t CountMaxDigits(AliBufferInfo* list)
 {
-       /// Deletes the memory allocated for the linked list of buffers.
+       /// Counts the maximum number of digits possible in all the buffers.
 
        UInt_t total = 0;
        AliBufferInfo* current = list;
@@ -191,6 +177,7 @@ Double_t TimeUsingOldDecoder(AliBufferInfo* list, AliDigitInfo* buffer, UInt_t m
 
        AliRawReaderMemory rawReader;
        AliMUONRawStreamTracker rawStream(&rawReader);
+       rawReader.NextEvent();
 
        TStopwatch timer;
        timer.Start(kTRUE);
@@ -213,9 +200,9 @@ Double_t TimeUsingOldDecoder(AliBufferInfo* list, AliDigitInfo* buffer, UInt_t m
                {
                        if (i < maxBufferSize)
                        {
-                               buffer->fManuId = manuId;
-                               buffer->fAdc = adc;
-                               buffer->fChannelId = manuChannel;
+                               buffer[i].fManuId = manuId;
+                               buffer[i].fAdc = adc;
+                               buffer[i].fChannelId = manuChannel;
                                i++;
                        }
                }
@@ -233,6 +220,7 @@ Double_t TimeUsingNewDecoder(AliBufferInfo* list, AliDigitInfo* buffer, UInt_t m
 
        AliRawReaderMemory rawReader;
        AliMUONRawStreamTrackerHP rawStream(&rawReader);
+       rawReader.NextEvent();
 
        TStopwatch timer;
        timer.Start(kTRUE);
@@ -258,9 +246,9 @@ Double_t TimeUsingNewDecoder(AliBufferInfo* list, AliDigitInfo* buffer, UInt_t m
                                buspatch->GetData(j, manuId, manuChannel, adc);
                                if (i < maxBufferSize)
                                {
-                                       buffer->fManuId = manuId;
-                                       buffer->fAdc = adc;
-                                       buffer->fChannelId = manuChannel;
+                                       buffer[i].fManuId = manuId;
+                                       buffer[i].fAdc = adc;
+                                       buffer[i].fChannelId = manuChannel;
                                        i++;
                                }
                        }
@@ -280,6 +268,7 @@ Double_t TimeUsingNewDecoderOldInterface(AliBufferInfo* list, AliDigitInfo* buff
 
        AliRawReaderMemory rawReader;
        AliMUONRawStreamTrackerHP rawStream(&rawReader);
+       rawReader.NextEvent();
 
        TStopwatch timer;
        timer.Start(kTRUE);
@@ -302,9 +291,9 @@ Double_t TimeUsingNewDecoderOldInterface(AliBufferInfo* list, AliDigitInfo* buff
                {
                        if (i < maxBufferSize)
                        {
-                               buffer->fManuId = manuId;
-                               buffer->fAdc = adc;
-                               buffer->fChannelId = manuChannel;
+                               buffer[i].fManuId = manuId;
+                               buffer[i].fAdc = adc;
+                               buffer[i].fChannelId = manuChannel;
                                i++;
                        }
                }
@@ -316,6 +305,65 @@ Double_t TimeUsingNewDecoderOldInterface(AliBufferInfo* list, AliDigitInfo* buff
 }
 
 
+void Loop(const char* filename, Bool_t newDecoder)
+{
+  AliCodeTimerAutoGeneral(Form("Loop %s",(newDecoder ? "NEW":"OLD")));
+  
+  AliRawReader* reader = AliRawReader::Create(filename);
+  
+  AliMUONVRawStreamTracker* stream;
+  
+  if ( newDecoder ) 
+  {
+    stream = new AliMUONRawStreamTrackerHP(reader);
+  }
+  else
+  {
+    stream = new AliMUONRawStreamTracker(reader);
+  }
+
+  Int_t busPatch;
+  UShort_t manuId, adc;
+  UChar_t manuChannel;
+  
+  while ( reader->NextEvent() ) 
+  {
+    stream->First();
+    
+    while ( stream->Next(busPatch,manuId,manuChannel,adc) ) 
+    {
+      adc *= 2;
+    }
+  }
+  
+  delete stream;
+  delete reader;
+}
+
+
+void MUONTimeRawStreamTrackerDumb(TString fileName)
+{
+  AliCodeTimer::Instance()->Reset();
+  
+  // first check we can open the stream
+  AliRawReader* reader = AliRawReader::Create(fileName.Data());
+  if (!reader)
+  {
+    cerr << "Cannot create reader from " << fileName.Data() << endl;
+    return;
+  }
+  delete reader;
+  
+  // now start the timing per se
+  
+  Loop(fileName,kFALSE);
+  
+  Loop(fileName,kTRUE);
+  
+  AliCodeTimer::Instance()->Print();
+}
+
+
 void MUONTimeRawStreamTracker(TString fileName = "./", Int_t maxEvent = 1000)
 {
        /// Performs a timing of old and new decoders and reports this.