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
setupATLAS
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.32.06-x86_64-el9-gcc13-opt" panda
It’s good practice to set up all the tools you will need in one go with
lsetup
. The script has some built-in features that let it gracefully handle conflicts and give you a fully-functional environment.
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) {
h->Fill(rand.Gaus(0.2,1.0));
}
h->Write();
foo->Close();
}
As usual, we check that the code runs normally first locally:
root -b -q HistTest.C
The
-b
option in ROOT is for “batch mode”, which turns off graphics. The-q
option is for “quit”, which makes it exit after it has run the script.
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.
Remove the local
foo.root
before launching the job:rm foo.root
It’s generally good practice to have a very clean running area before you submit jobs to the grid, because all the files in your directory (with some exceptions) will be packed up and shipped to the grid.
Run the command:
prun --exec="root -b -q HistTest.C" --nJobs=1 --outputs=foo.root --outDS=user.$USER.prunroottest1 --rootVer=6.32.06 --cmtConfig=x86_64-el9-gcc13-opt
Be sure to replace $USER
if necessary.
We have added some arguments to the prun command: the root version and
config. This ensures that the same version of root is set up 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.
If you don’t remove
foo.root
before submitting your job, you will see thatprun
tells you it’s ignoring the file: “skip root file ./foo.root”
Once the job completes, you should be able to use rucio to download the
dataset containing the root file output. Follow the same steps you did
in the previous section, and make sure you look for the output ending in
.root
instead of .tgz
.
PanDA has lots of handy options for controlling output. In this job we told it to expect an output file called
foo.root
. If we hadn’t, or the output had a different name, it might have packed it up in the log file tarball that it saves with the job. When your job has many outputs, PanDA also has options for splitting up the outputs into different datasets. The documentation you can find on the website and via the command line (prun --help
) is quite extensive.
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.