Search
uscms.org  uscms.fnal.gov  www 

LPC Computing

Accessing .ROOT files in dCache via ROOT

Introduction

This is meant to explain by example how to access files in dCache.  Before we begin, connect to the UAF, if you don't know how then check this page.  Then we will walk through setting up and using ROOT.  After that we will use our own ROOT files through the dCache system.

Getting started

To set up ROOT we set up ORCA which comes with Root version 3.22.  Use the following script as an example.  Download it or paste it in a text editor and name it setcms.csh:

 setenv SCRAM_ARCH slc3_ia32_gcc323
 if (!(${?CMS_PATH}))
 then
        source /afs/fnal.gov/files/code/cms/setup/cshrc uaf
 endif
 if ($#argv > 0) then
        set Version=$1
 else
        set Version="ORCA_8_7_3"
 endif
 eval `scram setroot -csh ORCA  ${Version}`
 eval `scram runtime -csh`

After you've made the file, it's time to run it using the following command:

 source setcms.csh

Then set a few environment variables which enable the read ahead and should improve performance:

 setenv DCACHE_RAHEAD true
setenv DCACHE_RA_BUFFER 104851000

Now download these files into your working directory and we'll be ready to get started
Higgs.C  Higgs.h plot_Higgs.C

Using ROOT

Now we can open ROOT to proceed with the example:

 root.exe

Give ROOT the following three commands:

 gSystem->Load("libPhysics");
.L Higgs.C++
.x plot_Higgs.C++

Now you should get some pretty output like this:

ROOT output
(Click image for larger version)

Create a ROOT class for accessing files in dCache

To create the classes we used the Root MakeClass method. Since MakeClass can't handle files in dCache we copy one root file over to the local disk, run our MakeClass, and then edit the header file to point to the .root files in dCache.

Quit, and copy over our ROOT file:

 .q
dccp /pnfs/cms/WAX/2/wenzel/newtutorial/h300eemm/rootfiles/h300eemm_1000.root .

Now we'll get back into ROOT:

 root.exe

 TChain h101("h101");
h101.Add("h300eemm*.root");
h101.MakeClass("Higgs");
.q

Now, edit the file Higgs.h and about halfway through you will see the following line:

 chain->Add("/afs/fnal.gov/files/home/room3/wenzel/junk/h300eemm_1000.root/h101");

You want to replace this with all of these lines:

chain->Add("dcap:/pnfs/cms/WAX/2/wenzel/newtutorial/h300eemm/rootfiles/h300eemm_1000.root/h101");
chain->Add("dcap:/pnfs/cms/WAX/2/wenzel/newtutorial/h300eemm/rootfiles/h300eemm_10000.root/h101")
chain->Add("dcap:/pnfs/cms/WAX/2/wenzel/newtutorial/h300eemm/rootfiles/h300eemm_1001.root/h101");
chain->Add("dcap:/pnfs/cms/WAX/2/wenzel/newtutorial/h300eemm/rootfiles/h300eemm_1002.root/h101");
chain->Add("dcap:/pnfs/cms/WAX/2/wenzel/newtutorial/h300eemm/rootfiles/h300eemm_1003.root/h101");
chain->Add("dcap:/pnfs/cms/WAX/2/wenzel/newtutorial/h300eemm/rootfiles/h300eemm_1004.root/h101");
chain->Add("dcap:/pnfs/cms/WAX/2/wenzel/newtutorial/h300eemm/rootfiles/h300eemm_1005.root/h101");
chain->Add("dcap:/pnfs/cms/WAX/2/wenzel/newtutorial/h300eemm/rootfiles/h300eemm_1006.root/h101");
chain->Add("dcap:/pnfs/cms/WAX/2/wenzel/newtutorial/h300eemm/rootfiles/h300eemm_1007.root/h101");
chain->Add("dcap:/pnfs/cms/WAX/2/wenzel/newtutorial/h300eemm/rootfiles/h300eemm_1008.root/h101");
chain->Add("dcap:/pnfs/cms/WAX/2/wenzel/newtutorial/h300eemm/rootfiles/h300eemm_1009.root/h101");
chain->Add("dcap:/pnfs/cms/WAX/2/wenzel/newtutorial/h300eemm/rootfiles/h300eemm_1010.root/h101");
chain->Add("dcap:/pnfs/cms/WAX/2/wenzel/newtutorial/h300eemm/rootfiles/h300eemm_1011.root/h101");
chain->Add("dcap:/pnfs/cms/WAX/2/wenzel/newtutorial/h300eemm/rootfiles/h300eemm_1012.root/h101");
chain->Add("dcap:/pnfs/cms/WAX/2/wenzel/newtutorial/h300eemm/rootfiles/h300eemm_1013.root/h101");
chain->Add("dcap:/pnfs/cms/WAX/2/wenzel/newtutorial/h300eemm/rootfiles/h300eemm_1014.root/h101");
chain->Add("dcap:/pnfs/cms/WAX/2/wenzel/newtutorial/h300eemm/rootfiles/h300eemm_1015.root/h101");
chain->Add("dcap:/pnfs/cms/WAX/2/wenzel/newtutorial/h300eemm/rootfiles/h300eemm_1016.root/h101");
chain->Add("dcap:/pnfs/cms/WAX/2/wenzel/newtutorial/h300eemm/rootfiles/h300eemm_1017.root/h101");
chain->Add("dcap:/pnfs/cms/WAX/2/wenzel/newtutorial/h300eemm/rootfiles/h300eemm_1018.root/h101");
chain->Add("dcap:/pnfs/cms/WAX/2/wenzel/newtutorial/h300eemm/rootfiles/h300eemm_1019.root/h101");
chain->Add("dcap:/pnfs/cms/WAX/2/wenzel/newtutorial/h300eemm/rootfiles/h300eemm_1020.root/h101");
chain->Add("dcap:/pnfs/cms/WAX/2/wenzel/newtutorial/h300eemm/rootfiles/h300eemm_1021.root/h101");
chain->Add("dcap:/pnfs/cms/WAX/2/wenzel/newtutorial/h300eemm/rootfiles/h300eemm_1022.root/h101");
chain->Add("dcap:/pnfs/cms/WAX/2/wenzel/newtutorial/h300eemm/rootfiles/h300eemm_1023.root/h101");
chain->Add("dcap:/pnfs/cms/WAX/2/wenzel/newtutorial/h300eemm/rootfiles/h300eemm_1024.root/h101");
chain->Add("dcap:/pnfs/cms/WAX/2/wenzel/newtutorial/h300eemm/rootfiles/h300eemm_1025.root/h101");
chain->Add("dcap:/pnfs/cms/WAX/2/wenzel/newtutorial/h300eemm/rootfiles/h300eemm_1026.root/h101");
chain->Add("dcap:/pnfs/cms/WAX/2/wenzel/newtutorial/h300eemm/rootfiles/h300eemm_1027.root/h101");
chain->Add("dcap:/pnfs/cms/WAX/2/wenzel/newtutorial/h300eemm/rootfiles/h300eemm_1028.root/h101");
chain->Add("dcap:/pnfs/cms/WAX/2/wenzel/newtutorial/h300eemm/rootfiles/h300eemm_1029.root/h101");

Now the files are accessed directly from dCache.  Wasn't that fun?

Alternatively, you can set up ORCA with Root version 4.04. The script below will set up this version, once again, copy and paste it, or download it

 setenv SCRAM_ARCH slc3_ia32_gcc323
 if (!(${?CMS_PATH})) then
     source /afs/fnal.gov/files/code/cms/setup/cshrc uaf
 endif
 if ($#argv > 0) then
     set Version=$1
 else
     set Version="ORCA_8_10_1"
 endif
 cd /uscms/prod/sw/cms/Releases/ORCA/ORCA_8_10_1/src
 #eval `scramv1 setroot -csh  ORCA     ${Version}`
 #echo $LOCALRT
 eval `scramv1 runtime -csh`
 cd -

You will also need to add another library.

 setenv LD_LIBRARY_PATH /opt/d-cache/dcap/lib/:$LD_LIBRARY_PATH 

The rest works as above.


Last updated: August 2, 2005.
This document is maintained by Hans Wenzel (wenzel@fnal.gov)
Webmaster | Last modified: Wednesday, 09-Jan-2008 14:15:48 CST