Accessing ROOT Files Remotely via RFIO


Reading and writing ROOT files over the net can be done by creating a TRFIOFile object instead of a TFile object. Since the TRFIOFile class inherits from the TFile class it has exactly the same interface and behaviour. The only difference is that it reads and writes to a remote rfiod daemon.

TRFIOFile URL

TRFIOFile file names are in standard URL format with protocol "rfio". The following are valid TRFIOFile URL's:

rfio:/afs/cern.ch/user/r/rdm/galice.root
rfio:na49db1:/data1/raw.root

The only difference with the well known httpd URL's is that after the protocol specifier (rfio) the files are specified in RFIO format. In the first example given above the file galice.root is a symlink of the type /shift/.../... and this in turn will trigger the RFIO system to open the remote file. The second example is an explicit RFIO remote path name. The expansion of the standard shell characters, like ~, $, .., etc. is handled as expected.

Using the General TFile::Open() Function

To make life simple we provide a general function to open any type of file (except shared memory files of class TMapFile). This functionality is provided by the static TFile::Open() function:

         TFile *TFile::Open(const Text_t *name, Option_t *option="",
                       const Text_t *title="",

Depending on the name argument the function returns either a TFile, a TNetFile, a TWebFile or a TRFIOFile object. The arguments of the Open() function are the same as the ones for the TFile constructor.

A Simple Session

root [0] TFile *f1 = TFile::Open("local/file.root", "update")
root [1] TFile *f2 = TFile::Open("rfio:hpsssrv1.cern.ch:/data/file.root") 
root [2] f2.ls()
TRFIOFile** hpsssrv1.cern.ch:/data/file.root
TRFIOFile* hpsssrv1.cern.ch:/data/file.root
KEY: TH1F hpx;1 This is the px distribution
KEY: TH2F hpxpy;1 py vs px
KEY: TProfile hprof;1 Profile of pz versus px
KEY: TNtuple ntuple;1 Demo ntuple
root [2] hpx.Draw()


Rene Brun, Fons Rademakers
Last update 15/4/99 by FR