#include <TPluginManager.h>
#include <TROOT.h>
#include <TInterpreter.h>
+#include <TSystem.h>
#include <Riostream.h>
#include "AliRawReader.h"
TString &fileURI = ((TObjString*)fields->At(0))->String();
AliRawReader *rawReader = NULL;
- if (fileURI.BeginsWith("mem://")) {
- fileURI.ReplaceAll("mem://","");
+ if (fileURI.BeginsWith("mem://") || fileURI.BeginsWith("^")) {
+ 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();
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()));
- if (fileURI.EndsWith("/")) {
- rawReader = new AliRawReaderFile(fileURI);
- } else if (fileURI.EndsWith(".root")) {
- rawReader = new AliRawReaderRoot(fileURI);
+ TString filename(gSystem->ExpandPathName(fileURI.Data()));
+ if (filename.EndsWith("/")) {
+ rawReader = new AliRawReaderFile(filename);
+ } else if (filename.EndsWith(".root")) {
+ rawReader = new AliRawReaderRoot(filename);
} else {
- rawReader = new AliRawReaderDate(fileURI);
+ rawReader = new AliRawReaderDate(filename);
}
}
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)) {
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
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++;
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;
+}
+