Run a Simple ROOT Script

Last update: 03 Apr 2023 [History] [Edit]

It is also possible to set up ROOT, and run ROOT-based code on the grid.

First you should log out of lxplus, and then log back in. Create a new directory in GridTutorial:

mkdir RootGridTest 
cd RootGridTest

Next we will set up a standalone version of ROOT (and also the pandaclient tools). You can see which versions are available with:

lsetup 'root --help'

In our case, we will use the following version (see how we added panda as well, so that all steps are configured together):

lsetup "root 6.20.06-x86_64-centos7-gcc8-opt" panda

Next we will create a simple macro to create a root file, create a histogram, fill the histogram with random values, and write the output.

Create a file called HistTest.C and copy and paste the following lines into it:

void HistTest() {
  TFile * foo = TFile::Open("foo.root","recreate");
  TH1D * h = new TH1D("h_gaus","h_gaus",30,-5,5);
  TRandom3 rand(0);
  for (unsigned int i=0; i< 100000; ++i) {

As usual, we check that the code runs normally first locally:

root -b -q HistTest.C

You should see that a root file called foo.root was created with a single histogram.

We will now run the same command on the grid and retrieve the output into a rucio dataset.

warning Remove the local foo.root before launching the job.

Run the command:

prun --exec="root -b -q HistTest.C" --nJobs=1 --outputs=foo.root --outDS=user.<nickname>.prunroottest1 --rootVer=6.20/06 --cmtConfig=x86_64-centos7-gcc8-opt

Be sure to replace <nickname> again

We have added some arguments to the prun command, the root version and config. This ensure that the same version of root is instantiated on the grid worker node. Note that certain files (such as ROOT files – e.g., foo.root –) are not automatically uploaded to the grid with the grid job.

Once the job completes, you should be able to use rucio to download the dataset containing the root file output.

Unfortunately the job will probably take longer than the length of the tutorial but if it does finish and you are having trouble with this step, let the tutors know.