]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RAW/AliRawReader.cxx
SDD QA updated in order to deal with acquisition through HLT (M. Siciliano)
[u/mrichter/AliRoot.git] / RAW / AliRawReader.cxx
index 9656644c68273386406033177bd52dec71548009..f00be9863e915b30b2f3a31d92a913998c4ae7a9 100644 (file)
@@ -45,6 +45,7 @@
 #include "AliRawReaderFile.h"
 #include "AliRawReaderDate.h"
 #include "AliRawReaderRoot.h"
+#include "AliRawReaderChain.h"
 #include "AliDAQ.h"
 #include "AliLog.h"
 
@@ -66,7 +67,8 @@ AliRawReader::AliRawReader() :
   fErrorCode(0),
   fEventNumber(-1),
   fErrorLogs("AliRawDataErrorLog",100),
-  fHeaderSwapped(NULL)
+  fHeaderSwapped(NULL),
+  fIsValid(kTRUE)
 {
 // default constructor: initialize data members
 // Allocate the swapped header in case of Mac
@@ -123,7 +125,8 @@ AliRawReader::AliRawReader(const AliRawReader& rawReader) :
   fErrorCode(0),
   fEventNumber(-1),
   fErrorLogs("AliRawDataErrorLog",100),
-  fHeaderSwapped(NULL)
+  fHeaderSwapped(NULL),
+  fIsValid(rawReader.fIsValid)
 {
 // copy constructor
 // Allocate the swapped header in case of Mac
@@ -153,6 +156,8 @@ AliRawReader& AliRawReader::operator = (const AliRawReader& rawReader)
   fEventNumber = rawReader.fEventNumber;
   fErrorLogs = *((TClonesArray*)rawReader.fErrorLogs.Clone());
 
+  fIsValid = rawReader.fIsValid;
+
   return *this;
 }
 
@@ -184,20 +189,13 @@ AliRawReader* AliRawReader::Create(const char *uri)
     return NULL;
   }
 
+  TObjArray *fields = strURI.Tokenize("?");
+  TString &fileURI = ((TObjString*)fields->At(0))->String();
+
   AliRawReader *rawReader = NULL;
-  if (!strURI.BeginsWith("mem://")) {
-    AliInfoClass(Form("Creating raw-reader in order to read raw-data file: %s",strURI.Data()));
-    if (strURI.EndsWith("/")) {
-      rawReader = new AliRawReaderFile(strURI);
-    } else if (strURI.EndsWith(".root")) {
-      rawReader = new AliRawReaderRoot(strURI);
-    } else {
-      rawReader = new AliRawReaderDate(strURI);
-    }
-  }
-  else {
-    strURI.ReplaceAll("mem://","");
-    AliInfoClass(Form("Creating raw-reader in order to read events in shared memory (option=%s)",strURI.Data()));
+  if (fileURI.BeginsWith("mem://")) {
+    fileURI.ReplaceAll("mem://","");
+    AliInfoClass(Form("Creating raw-reader in order to read events in shared memory (option=%s)",fileURI.Data()));
 
     TPluginManager* pluginManager = gROOT->GetPluginManager();
     TString rawReaderName = "AliRawReaderDateOnline";
@@ -209,12 +207,63 @@ AliRawReader* AliRawReader::Create(const char *uri)
       pluginHandler = pluginManager->FindHandler("AliRawReader", "online");
     }
     if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
-      rawReader = (AliRawReader*)pluginHandler->ExecPlugin(1,strURI.Data());
+      rawReader = (AliRawReader*)pluginHandler->ExecPlugin(1,fileURI.Data());
     }
     else {
+      delete fields;
       return NULL;
     }
   }
+  else if (fileURI.BeginsWith("collection://")) {
+    fileURI.ReplaceAll("collection://","");
+    AliInfoClass(Form("Creating raw-reader in order to read raw-data files collection defined in %s",fileURI.Data()));
+    rawReader = new AliRawReaderChain(fileURI);
+  }
+  else {
+    AliInfoClass(Form("Creating raw-reader in order to read raw-data file: %s",fileURI.Data()));
+    if (fileURI.EndsWith("/")) {
+      rawReader = new AliRawReaderFile(fileURI);
+    } else if (fileURI.EndsWith(".root")) {
+      rawReader = new AliRawReaderRoot(fileURI);
+    } else {
+      rawReader = new AliRawReaderDate(fileURI);
+    }
+  }
+
+  if (!rawReader->IsRawReaderValid()) {
+    AliErrorClass(Form("Raw-reader is invalid - check the input URI (%s)",fileURI.Data()));
+    delete rawReader;
+    fields->Delete();
+    delete fields;
+    return NULL;
+  }
+
+  // Now apply event selection criteria (if specified)
+  if (fields->GetEntries() > 1) {
+    Int_t eventType = -1;
+    ULong64_t triggerMask = 0;
+    for(Int_t i = 1; i < fields->GetEntries(); i++) {
+      if (!fields->At(i)) continue;
+      TString &option = ((TObjString*)fields->At(i))->String();
+      if (option.BeginsWith("EventType=",TString::kIgnoreCase)) {
+       option.ReplaceAll("EventType=","");
+       eventType = option.Atoi();
+       continue;
+      }
+      if (option.BeginsWith("Trigger=",TString::kIgnoreCase)) {
+       option.ReplaceAll("Trigger=","");
+       triggerMask = option.Atoll();
+       continue;
+      }
+      AliWarningClass(Form("Ignoring invalid event selection option: %s",option.Data()));
+    }
+    AliInfoClass(Form("Event selection criteria specified:   eventype=%d   trigger mask=%llx",
+                eventType,triggerMask));
+    rawReader->SelectEvents(eventType,triggerMask);
+  }
+
+  fields->Delete();
+  delete fields;
 
   return rawReader;
 }
@@ -444,6 +493,11 @@ Bool_t AliRawReader::ReadNextChar(UChar_t& data)
   return kTRUE;
 }
 
+Bool_t  AliRawReader::GotoEvent(Int_t event)
+{
+  Error("GotoEvent","Method not implemented! Nothing done");
+  return kFALSE;
+}
 
 Int_t AliRawReader::CheckData() const
 {