How to Read Remote Files?

Not only local ROOT files can be read, but also remote ones. The right TFile specialisation is chosen at runtime automatically by ROOT. The reccomended way of accessing remote files is to use the TFile::Open static function:

In [1]:
auto myFile = TFile::Open("http://root.cern.ch/files/usa.root")

In this case, ROOT automatically recognised from the string "http://" that the class to be used was TWebFile and chose the right plugin. This technique can be applied to a variety of protocols, such as for files on:

  • EOS: TFile::Open("root://eosatlas.cern.ch//eos/atlas/user/t/test/histo.root");
  • Web: TFile::Open("http://root.cern.ch/files/usa.root");
  • Amazon S3: TFile::Open("s3://s3-eu-west-1.amazonaws.com/roots3/hsimple.root");
  • Google Storage: TFile::Open("gs://commondatastorage.googleapis.com/roots3/hsimple.root");

Authenticate on Amazon S3

Here follows a step-by-step recipe for authentication configuration between ROOT and Amazon S3:

  • Go to the main Amazon S3 website and login into your account.
  • Once you are logged in, click on Security Credentials on the left panel.
  • In the section Access Credentials, tab Access Keys retrieve both Access Key ID and Secret Access Key.
  • Set the following two environment variables: S3_ACCESS_KEY="your access key id" and S3_SECRET_KEY="your secret access key"

Authenticate on Google Storage

Here follows a step-by-step recipe for authentication configuration between ROOT and Google Storage:

  • Enable Legacy Access for Google Storage.
  • Once you have generated both Legacy Storage Access Keys, retrieve both Access Key and Secret.
  • Set the following two environment variables: GS_ACCESS_ID="your access id" and GS_ACCESS_KEY="your access secret key"