]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RAW/AliRawReader.cxx
bugfix
[u/mrichter/AliRoot.git] / RAW / AliRawReader.cxx
index 1fc4a0576980bb20b2ce986fe68cc89dd39a1b0d..1cdf94c39c607668d22f6688b91d6aaef2f494f4 100644 (file)
@@ -219,11 +219,30 @@ AliRawReader* AliRawReader::Create(const char *uri)
       return NULL;
     }
   }
+  else if (fileURI.BeginsWith("amore://")) {
+    // A special raw-data URL used in case
+    // the raw-data reading is steered from
+    // ouside, i.e. from AMORE
+    fileURI.ReplaceAll("amore://","");
+    AliInfoClass("Creating raw-reader in order to read events sent by AMORE");
+    rawReader = new AliRawReaderDate((void *)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 if (fileURI.BeginsWith("raw://run")) {
+    fileURI.ReplaceAll("raw://run","");
+    if (fileURI.IsDigit()) {
+      rawReader = new AliRawReaderChain(fileURI.Atoi());
+    }
+    else {
+      AliErrorClass(Form("Invalid syntax: %s",fileURI.Data()));
+      fields->Delete();
+      return NULL;
+    }
+  }
   else {
     AliInfoClass(Form("Creating raw-reader in order to read raw-data file: %s",fileURI.Data()));
     TString filename(gSystem->ExpandPathName(fileURI.Data()));
@@ -455,6 +474,8 @@ Bool_t AliRawReader::IsEventSelected() const
        expr.ReplaceAll(Form("[%d]",itrigger),"0");
       }
     }
+    // Possibility to introduce downscaling
+    expr.ReplaceAll("%",Form("&& !%d %%",GetEventIndex()));
     Int_t error;
     if ((gROOT->ProcessLineFast(expr.Data(),&error) == 0) &&
        (error == TInterpreter::kNoError)) {
@@ -541,10 +562,19 @@ Bool_t AliRawReader::ReadNextChar(UChar_t& data)
   return kTRUE;
 }
 
-Bool_t  AliRawReader::GotoEvent(Int_t /*event*/)
+Bool_t  AliRawReader::GotoEvent(Int_t event)
 {
-  Error("GotoEvent","Method not implemented! Nothing done");
-  return kFALSE;
+  // Random access to certain
+  // event index. Could be very slow
+  // for some non-root raw-readers.
+  // So it should be reimplemented there.
+  if (event < fEventNumber) RewindEvents();
+
+  while (fEventNumber < event) {
+    if (!NextEvent()) return kFALSE;
+  }
+
+  return kTRUE;
 }
 
 Int_t AliRawReader::CheckData() const
@@ -650,7 +680,7 @@ void AliRawReader::DumpData(Int_t limit)
        line[pos+offset] = '.';
       }
       char hex[3];
-      sprintf(hex, "%2.2x", byte);
+      snprintf(hex, 3, "%2.2x", byte);
       line[max+max/4+3+2*pos+offset] = hex[0];
       line[max+max/4+4+2*pos+offset] = hex[1];
       pos++;
@@ -701,3 +731,25 @@ void AliRawReader::AddErrorLog(AliRawDataErrorLog::ERawDataErrorLevel level,
     if (prevLog) prevLog->AddCount();
 
 }
+
+Bool_t AliRawReader::GotoEventWithID(Int_t event, 
+                                    UInt_t period,
+                                    UInt_t orbitID,
+                                    UShort_t bcID)
+{
+  // Go to certain event number by
+  // checking the event ID.
+  // Useful in case event-selection
+  // is applied and the 'event' is
+  // relative
+  if (!GotoEvent(event)) return kFALSE;
+
+  while (GetBCID()    != period  ||
+        GetOrbitID() != orbitID ||
+        GetPeriod()  != bcID) {
+    if (!NextEvent()) return kFALSE;
+  }
+
+  return kTRUE;
+}
+