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.deAccounts:
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
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
- 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() ... - Create an analysis skeleton:
root[.] pythiaEvents->MakeSelector("Analyzer") - Edit
Analyzer.handAnalyzer.Cto create/fill/display the number of particles per event:- In
Analyzer.hsetkMaxparticles = 4000;
and add a data memberTH1F * histo;
- In
Analyzer.Cadd to functionvoid Analyzer::SlaveBegin(TTree *tree)histo = new TH1F("nParticles", "Number of particles per event", 1000,0,1000); fOutput->Add(histo);and add to functionBool_t Analyzer::Process(Long64_t entry)fChain->GetTree()->GetEntry(entry); histo->Fill(header_nParticles);
orb_header->GetEntry(entry); histo->Fill(header_nParticles);
and add to functionvoid Analyzer::Terminate()fOutput->FindObject("nParticles")->Draw();or it is possible to iterate overfOutpute.g.TIter next(fOutput); TObject *obj; while(obj=next()) obj->Print();
- In
- Analyze the tree with
Analyzer.C:root[.] pythiaEvents->Process("Analyzer.C") - 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 themroot[.] 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")
- Create a chain to analyze a tree called "pythiaEvents"
2. Analyze with PROOF
- Start the PROOF demon on local host:
> proofd -p UID -noauth
- Create a file
$HOME/.proof.confwith master and two slaves on localhost port UID:node localhost port=UID slave localhost port=UID slave localhost port=UID
- Start ROOT and load the needed library:
root[.] gSystem->Load("libTreePlayer") - Start PROOF:
root[.] gROOT->Proof("localhost:UID") - Create a
TDSet:root[.] TDSet *set = new TDSet("TTree", "pythiaEvents") root[.] set->Add("/grid/fzk.de/alice/software/PROOFtutorial/data/N10MSEL16Events_0.root") root[.] ... - Analyze the set with
Analyzer.C:root[.] set->Process("Analyzer.C"); ... - Don't forget to kill the proof demon when you finished:
> pkill proofd
3. Analyze with PROOF on the batch farm
- Run a script to submit jobs on the farm to start PROOF demons:
> /grid/fzk.de/alice/software/PROOFtutorial/bin/submit.sh
- The scripts writes a file
$HOME/.proof.confand starts ROOT, if you leave ROOT it removes the demons. Don't forget to loadlibTreePlayer.root[.] gSystem->Load("libTreePlayer") - Start PROOF and browse
$HOME/.proof.confto find the master:root[.] gROOT->Proof("masterhost:port") - Create a
TDSet:root[.] TDSet *set = new TDSet("TTree", "pythiaEvents") root[.] set->Add("/grid/fzk.de/alice/software/PROOFtutorial/data/N10MSEL16Events_0.root") root[.] ... - 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():
- Try it first with ROOT (without PROOF):
root[.] ... root[.] .L Analyzer.C+
- 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"intoAnalyzer.hretry. You can rerun a compiled selector script (e.g. for larger files) by using the class name:root[.] pythiaEvents->Process("Analyzer") - 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
- Create a new directory for all files you want to upload.
- Move all files you need into this directory.
- Create a subdirectory with name
PROOF-INF. - Write the shell script
PROOF-INF/BUILD.shto create/compile everything you need on the target machine. - Write the macro
PROOF-INF/SETUP.C. - Tar your director to a par file, e.g. is the directory name is
LIBRARY> tar -czf LIBRARY.par LIBRARY
- 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") - Enable the package, this will call first the optional
BUILD.shand thenSETUP.Cand use it:root[.] gProof->EnablePackage("$HOME/LIBRARY")
Example: Upload a library
- Create a directory
LIBRARY1copyAnalyzer_C.sointo it (this has been created by ACLiC before). - Create the
PROOF-INFsubdirectory. - Create file
PROOF-INF/SETUP.Cwith the following content:{ gSystem->Load("Analyzer_C"); } - Tar the directory:
> tar -czf LIBRARY1.par LIBRARY1
- 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
- Create a copy of
LIBRARY1namedLIBRARY2. - Remove
Analyzer_C.so. - Copy
Analyzer.CandAnalyzer.hinto it. - Create an executable file
PROOF-INF/BUILD.shwith the content:root -b -q -x PROOF-INF/COMPILE.C
- Run a ROOT job in batch, to execute the script
PROOF-INF/COMPILE.Cwith the contents:{ gROOT->ProcessLine(".L Analyzer.C+"); } - Do it with
LIBRARY2instead ofLIBRARY1.
6. Benchmark PROOF
- Switch on the timer in ROOT:
gROOT->Time()
- Check CPU and real time for different PROOF setups.
- If the datafiles in directory
/grid/fzk.de/alice/software/PROOFtutorial/data/are not enough create new files. - 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 ACLiCroot[.] .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: InlibEG 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 ofTLorentzVector
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-gksChanges to previous versions of ROOT:
libTreePlayeris loaded by default.- No need for
TDSetyou can useTChainalso with PROOF.
> . 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)