From 43787b8e9c0d31403330c9a4a5df58b17c01951f Mon Sep 17 00:00:00 2001 From: cvetan Date: Wed, 2 Apr 2008 14:15:43 +0000 Subject: [PATCH] New AliRawReader factory method. It uses plugin handler in order to load the raw-reader for the online reco --- RAW/AliRawReader.cxx | 59 ++++++++++++++++++++++++++++++++++++++++++++ RAW/AliRawReader.h | 2 ++ 2 files changed, 61 insertions(+) diff --git a/RAW/AliRawReader.cxx b/RAW/AliRawReader.cxx index cb626f33526..91195ceea9a 100644 --- a/RAW/AliRawReader.cxx +++ b/RAW/AliRawReader.cxx @@ -36,8 +36,15 @@ /// /////////////////////////////////////////////////////////////////////////////// +#include +#include +#include + #include #include "AliRawReader.h" +#include "AliRawReaderFile.h" +#include "AliRawReaderDate.h" +#include "AliRawReaderRoot.h" #include "AliDAQ.h" #include "AliLog.h" @@ -157,6 +164,58 @@ AliRawReader::~AliRawReader() if (fHeaderSwapped) delete fHeaderSwapped; } +AliRawReader* AliRawReader::Create(const char *uri) +{ + // RawReader's factory + // It instantiate corresponding raw-reader implementation class object + // depending on the URI provided + // Normal URIs point to files, while the URI starting with + // 'mem://:' or 'mem://' will create + // AliRawReaderDateOnline object which is supposed to be used + // in the online reconstruction + + TString strURI = uri; + + if (strURI.IsNull()) { + AliWarningClass("No raw-reader created"); + return NULL; + } + + 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())); + + TPluginManager* pluginManager = gROOT->GetPluginManager(); + TString rawReaderName = "AliRawReaderDateOnline"; + TPluginHandler* pluginHandler = pluginManager->FindHandler("AliRawReader", "online"); + // if not, add a plugin for it + if (!pluginHandler) { + pluginManager->AddHandler("AliRawReader", "online", + "AliRawReaderDateOnline", "RAWDatarecOnline", "AliRawReaderDateOnline(const char*)"); + pluginHandler = pluginManager->FindHandler("AliRawReader", "online"); + } + if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) { + rawReader = (AliRawReader*)pluginHandler->ExecPlugin(1,strURI.Data()); + } + else { + return NULL; + } + } + + return rawReader; +} + Int_t AliRawReader::GetMappedEquipmentId() const { if (!fEquipmentIdsIn || !fEquipmentIdsOut) { diff --git a/RAW/AliRawReader.h b/RAW/AliRawReader.h index 4a219ec132b..c97494ac722 100644 --- a/RAW/AliRawReader.h +++ b/RAW/AliRawReader.h @@ -27,6 +27,8 @@ class AliRawReader: public TObject { AliRawReader& operator = (const AliRawReader& rawReader); virtual ~AliRawReader(); + static AliRawReader* Create(const char *uri); + virtual void Select(Int_t detectorID, Int_t minDDLID = -1, Int_t maxDDLID = -1); virtual void Select(const char *detectorName, -- 2.39.3