PROOF course @ GridKA

General Information

Login hosts use port 24 to connect with SSH:

   gks02.fzk.de 
   gks03.fzk.de
   gks04.fzk.de 
   alice.fzk.de
   Accounts:
   NAME     UID

   gks01   (21001)
   gks02   (21002)
   gks03   (21003)
   ...
   gks40   (21040)
   Example:
  > ssh -p 24 gks01@gks02.fzk.de

For files used during the exercises see /grid/fzk.de/alice/software/PROOFtutorial/.

Batch machines c01-001-101 till c01-001-130. On all machines data files are put in the /tmp/data/ directory.

Exercises

1. Analysis with TSelector
2. Analyze with PROOF
3. Analyze with PROOF on the batch farm
4. Compile the analyze script with ACLiC (Automatic Compiler for Libraries CINT)
5. Upload a PROOF archive (PAR file) to PROOF
6. Benchmark PROOF

Students which want to use a (slightly) more complicated script can try the following exercises:

7. Create and run a selector to create a list of particle names in the events
8. Create and run a selector to display a histogram of the energy or transversal momentum pt of the muons
9. Create a new file with all events containing muons with vertex(0,0,0,0)
10. Try it with the new ROOT version

Useful Links

ROOT Users Guide: http://root.cern.ch/root/doc/RootDoc.html
ROOT Reference Guide v5: http://root.cern.ch/root/htmldoc/ClassIndex.html
PROOF Documentation by GSI: http://wiki.gsi.de/cgi-bin/view/Grid/TheParallelRootFacility_GUI

1. Analysis with TSelector

  1. Start ROOT and open a file with a tree:
      > . alilogin v5-02-00-gks
      > root
      root[0] TFile f("/grid/fzk.de/alice/software/PROOFtutorial/data/pythiaEvents.root") 
      root[.] f.ls()
      root[.] pythiaEvents->StartViewer()
      ...  
    
  2. Create an analysis skeleton:
      root[.] pythiaEvents->MakeSelector("Analyzer")
    
  3. Edit Analyzer.h and Analyzer.C to create/fill/display the number of particles per event:
    • In Analyzer.h set
        kMaxparticles = 4000;
      
         and add a data member
        TH1F * histo;
      
    • In Analyzer.C add to function void Analyzer::SlaveBegin(TTree *tree)
        histo = new TH1F("nParticles", "Number of particles per event", 1000,0,1000);
        fOutput->Add(histo);
      
         and add to function Bool_t Analyzer::Process(Long64_t entry)
        fChain->GetTree()->GetEntry(entry); 
        histo->Fill(header_nParticles);
      
         or
        b_header->GetEntry(entry);
        histo->Fill(header_nParticles);
      
         and add to function void Analyzer::Terminate()
        fOutput->FindObject("nParticles")->Draw();
      
         or it is possible to iterate over fOutput e.g.
        TIter next(fOutput);
        TObject *obj;
        while(obj=next()) obj->Print();
      
  4. Analyze the tree with Analyzer.C:
      root[.] pythiaEvents->Process("Analyzer.C")
    
  5. Analyze a chain of files with Analyzer.C:
    • Create a chain to analyze a tree called "pythiaEvents"
        root[.] TChain *chain = new TChain("pythiaEvents")
      
    • Add files to the chain
        root[.] chain->Add("/grid/fzk.de/alice/software/PROOFtutorial/data/N10MSEL16Events_0.root")
        root[.] chain->Add("/grid/fzk.de/alice/software/PROOFtutorial/data/N10MSEL16Events_1.root")
        ...
        root[.] chain->Add("/grid/fzk.de/alice/software/PROOFtutorial/data/N10MSEL16Events_9.root")
      
         and analyze them
        root[.] chain->Process("Analyzer.C")
      
    • It's also possible to add files via the root protocol
        root[.] chain->Add("root://c01-001-101//tmp/data/N10MSEL16Events_0.root")
      

2. Analyze with PROOF

  1. Start the PROOF demon on local host:
      > proofd -p UID -noauth
    
  2. Create a file $HOME/.proof.conf with master and two slaves on localhost port UID:
      node localhost port=UID
      slave localhost port=UID
      slave localhost port=UID
    
  3. Start ROOT and load the needed library:
      root[.] gSystem->Load("libTreePlayer")
    
  4. Start PROOF:
      root[.] gROOT->Proof("localhost:UID")
    
  5. Create a TDSet:
      root[.] TDSet *set = new TDSet("TTree", "pythiaEvents")
      root[.] set->Add("/grid/fzk.de/alice/software/PROOFtutorial/data/N10MSEL16Events_0.root")
      root[.] ...
    
  6. Analyze the set with Analyzer.C:
      root[.] set->Process("Analyzer.C");
      ...
    
  7. Don't forget to kill the proof demon when you finished:
      > pkill proofd
    

3. Analyze with PROOF on the batch farm

  1. Run a script to submit jobs on the farm to start PROOF demons:
      > /grid/fzk.de/alice/software/PROOFtutorial/bin/submit.sh
    
  2. The scripts writes a file $HOME/.proof.conf and starts ROOT, if you leave ROOT it removes the demons. Don't forget to load libTreePlayer.
      root[.] gSystem->Load("libTreePlayer")
    
  3. Start PROOF and browse $HOME/.proof.conf to find the master:
      root[.] gROOT->Proof("masterhost:port")
    
  4. Create a TDSet:
      root[.] TDSet *set = new TDSet("TTree", "pythiaEvents")
      root[.] set->Add("/grid/fzk.de/alice/software/PROOFtutorial/data/N10MSEL16Events_0.root")
      root[.] ...
    
  5. Analyze the set with Analyzer.C:
      root[.] set->Process("Analyzer.C") 
    

4. Compile the analyze script with ACLiC (Automatic Compiler for Libraries CINT)

Till now we used the interpreted mode. It is possible to compile it before execution. It will speed-up the execution considerably. Add just a "+" after the script name in the TTree::Process():

  1. Try it first with ROOT (without PROOF):
      root[.] ...
      root[.] .L Analyzer.C+
    
  2. Most probably this will fail; the compiler is not as sloppy as the interpreter. You have to provide the include statements for all classes you inserted. Put the statement #include "TH1.h" into Analyzer.h retry. You can rerun a compiled selector script (e.g. for larger files) by using the class name:
      root[.] pythiaEvents->Process("Analyzer")
    
  3. If successful try it with PROOF (see next exercise).

5. Upload a PROOF archive (PAR file) to PROOF

It is possible to upload libraries/source or data files to PROOF. In our simple example this is not needed but to explain the mechanism, we upload our Analyzer to proof.

Recipe

  1. Create a new directory for all files you want to upload.
  2. Move all files you need into this directory.
  3. Create a subdirectory with name PROOF-INF.
  4. Write the shell script PROOF-INF/BUILD.sh to create/compile everything you need on the target machine.
  5. Write the macro PROOF-INF/SETUP.C.
  6. Tar your director to a par file, e.g. is the directory name is LIBRARY
      > tar -czf LIBRARY.par LIBRARY
    
  7. In PROOF upload the package, remark prerequisite is that a rootd is running on the master host on port 1094:
      root[.] gProof->UploadPackage("$HOME/LIBRARY.par")
    
  8. Enable the package, this will call first the optional BUILD.sh and then SETUP.C and use it:
      root[.] gProof->EnablePackage("$HOME/LIBRARY")
    

Example: Upload a library

  1. Create a directory LIBRARY1 copy Analyzer_C.so into it (this has been created by ACLiC before).
  2. Create the PROOF-INF subdirectory.
  3. Create file PROOF-INF/SETUP.C with the following content:
      {
        gSystem->Load("Analyzer_C");
      }
    
  4. Tar the directory:
      > tar -czf LIBRARY1.par LIBRARY1 
    
  5. In PROOF:
      root[.] ...
      root[.] gSystem->Load("Analyzer_C")    // load it on the client
      root[.] gProof->UploadPackage("LIBRARY1.par")
      root[.] gProof->EnablePackage("LIBRARY1")
      root[.] set->Process("Analyzer")
    

Example: Upload source and compile

  1. Create a copy of LIBRARY1 named LIBRARY2.
  2. Remove Analyzer_C.so.
  3. Copy Analyzer.C and Analyzer.h into it.
  4. Create an executable file PROOF-INF/BUILD.sh with the content:
      root -b -q -x PROOF-INF/COMPILE.C
    
  5. Run a ROOT job in batch, to execute the script PROOF-INF/COMPILE.C with the contents:
      {
       gROOT->ProcessLine(".L Analyzer.C+");
      }
    
  6. Do it with LIBRARY2 instead of LIBRARY1.

6. Benchmark PROOF

  1. Switch on the timer in ROOT:
      gROOT->Time()
    
  2. Check CPU and real time for different PROOF setups.
  3. If the datafiles in directory /grid/fzk.de/alice/software/PROOFtutorial/data/ are not enough create new files.
  4. Start ROOT:
      root[.] .x "/grid/fzk.de/alice/software/PROOFtutorial/pythia/LoadLibs.C"
      root[.] .x "/grid/fzk.de/alice/software/PROOFtutorial/pythia/generatePythiaEvents.C(numberOfEvents,"fileName.root")
    
        or with ACLiC
      root[.] .x "/grid/fzk.de/alice/software/PROOFtutorial/pythia/generatePythiaEvents.C+(numberOfEvents,"fileName.root")
    

7. Create and run a selector to create a list of particle names in the events

Hint: In libEG is a TDatabasePDG class.
  root [.] gSystem->Load("libEG")
  (int)0
  root [.] TDatabasePDG *pdgDB = TDatabasePDG::Instance()
  root [.] pdgDB->GetParticle(13)->ParticleClass()
  (const char* 0x8cf9b34)"Lepton"
  root [.] pdgDB->GetParticle(13)->GetName()
  (const char* 0x8cf9b04)"mu-"

8. Create and run a selector to display a histogram of the energy or transversal momentum pt of the muons

Hint: pdgCode of muons/antimuons is +/- 13, pt is a member function of TLorentzVector

9. Create a new file with all events containing muons with vertex(0,0,0,0)

10. Try it with the head ROOT version 5.04

To switch to the new version use:
 > . alilogin head-gks  
Changes to previous versions of ROOT:
 > . alilogin head-gks
 ...
 > root
 root[.] TChain *chain = new TChain("pythiaEvents")
 root[.] chain->Add("/grid/fzk.de/alice/software/PROOFtutorial/data/N10MSEL16Events_0.root")
 root[.] chain->Add("/grid/fzk.de/alice/software/PROOFtutorial/data/N10MSEL16Events_1.root")
 ...
 root[.] chain->Add("/grid/fzk.de/alice/software/PROOFtutorial/data/N10MSEL16Events_9.root")
 root[.] chain->Process("Analyzer.C")
 ...
 root[.] gROOT->Proof("masterhost:port")   // with PROOF
 root[.] chain->SetProof()
 root[.] chain->Process("Analyzer.C")
  

Here is a list of ROOT files which are used during the exercise :

N10MSEL16Events_0.root
N10MSEL16Events_1.root
N10MSEL16Events_2.root
N10MSEL16Events_3.root
N10MSEL16Events_4.root
N10MSEL16Events_5.root
N10MSEL16Events_6.root
N10MSEL16Events_7.root
N10MSEL16Events_8.root
N10MSEL16Events_9.root

Tutors

Kilian Schwarz (k.schwarz@gsi.de), Peters Andreas-Joachim (Andreas.Joachim.Peters@cern.ch), Penso Victor (v.penso@gsi.de), Manteufel Robert (r.manteufel@gsi.de), Manafov Anar (a.manafov@gsi.de), Malzacher Peter (p.malzacher@gsi.de)