may 17 and 22, 20071 alice offline tutorial markus oldenburg – cern [email protected] may...

31
May 17 and 22, 2007 1 ALICE Offline Tutorial Markus Oldenburg – CERN [email protected] May 17 and 22, 2007 – University of Sao Paulo

Upload: sarah-campbell

Post on 27-Mar-2015

219 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: May 17 and 22, 20071 ALICE Offline Tutorial Markus Oldenburg – CERN Markus.Oldenburg@cern.ch May 17 and 22, 2007 – University of Sao Paulo

May 17 and 22, 2007 1

ALICE Offline Tutorial

Markus Oldenburg – [email protected]

May 17 and 22, 2007 – University of Sao Paulo

Page 2: May 17 and 22, 20071 ALICE Offline Tutorial Markus Oldenburg – CERN Markus.Oldenburg@cern.ch May 17 and 22, 2007 – University of Sao Paulo

May 17 and 22, 2007 2

ALICE Offline Tutorial

F.Carminati, P.Christakoglou, J.F.Grosse-Oetringhaus, P.Hristov, A.Peters, P.Saiz

April 13, 2007 – v1.3

based on:

Page 3: May 17 and 22, 20071 ALICE Offline Tutorial Markus Oldenburg – CERN Markus.Oldenburg@cern.ch May 17 and 22, 2007 – University of Sao Paulo

May 17 and 22, 2007 3

Part IV: PROOFHands on training

available online at: http://cern.ch/Oldenburg -> Seminars

for more information (and more available data): http://aliceinfo.cern.ch/Offline/Analysis/CAF/index.html

Page 4: May 17 and 22, 20071 ALICE Offline Tutorial Markus Oldenburg – CERN Markus.Oldenburg@cern.ch May 17 and 22, 2007 – University of Sao Paulo

May 17 and 22, 2007 4

Warm up

Preconditionslogin to lxslc3.cern.ch make sure you are using the bash shell, otherwise switch to it

• echo $SHELL, bashset the correct environment (this works only for bash)

• source /afs/cern.ch/user/j/jgrosseo/public/set-env.sh Copy file from http://cern.ch/jgrosseo/proof-tutorial/tut_proof.tgzto a local directory and extract it

Check AliROOTStart AliROOT. Does it show ROOT version 5.15/04?$ALICE_ROOT/STEER/AliSelector.h available?

Add AliROOT include pathTo ~/.rootrc add ACLiC.IncludePaths: -I$(ALICE_ROOT)/includeGo to the local directory from aboveOpen AliROOT and load the TTree library: gSystem->Load(“libTree”)test if selector can be compiled.L AliMultiplicityESDSelector.cxx+

Page 5: May 17 and 22, 20071 ALICE Offline Tutorial Markus Oldenburg – CERN Markus.Oldenburg@cern.ch May 17 and 22, 2007 – University of Sao Paulo

May 17 and 22, 2007 5

Some of the prerequisites of the last slide will not be necessary in the future!

We needed to setup a working environment for now (Scientific Linux 3, correct Root version in combination with ‘working’ ESD library in order to access PDC06 data).In general (in the ideal case ) you should be able to log in to lxplus.cern.ch (SLx4) and upload your current ESD library.In the near future the same versions of ROOT/AliRoot will be provided on lxplus as they are on CAF.

Page 6: May 17 and 22, 20071 ALICE Offline Tutorial Markus Oldenburg – CERN Markus.Oldenburg@cern.ch May 17 and 22, 2007 – University of Sao Paulo

May 17 and 22, 2007 6

Files to be used

CreateESDChain.C Creates a chain from a list of file namesESD100_110_v2.txt List of prod2006_2 PDC06 files distributed on the CAFESD.par Par archive for PDC06 dataProofEnableAliRoot.C Enables an installed AliROOT on the CAF clusterAliMultiplicityESDSelector.{cxx,h} Selector that creates a uncorrected multiplicity histogram from the ESDAliMultiplicityMCSelector.{cxx,h} Selector that creates a multiplicity histogram from the MCAliEmptySelector.{cxx,h} Empty selector that can be used as a skeleton for your own analysis

Page 7: May 17 and 22, 20071 ALICE Offline Tutorial Markus Oldenburg – CERN Markus.Oldenburg@cern.ch May 17 and 22, 2007 – University of Sao Paulo

May 17 and 22, 2007 7

Run selector locally

Start AliRootgSystem->Load(“libTree”)

Create a chainchain = new TChain(“esdTree”)chain->Add(“root://lxb6046.cern.ch

//proofpool/pdc06/100/002/root_archive.zip#AliESDs.root”)

chain->GetEntries()// Should return 100

Execute a selector locallychain->Process(“AliMultiplicity

ESDSelector.cxx++”)

NB: Instead of AliRoot, use root androot [0] gSystem->Load("libGeom")

// pointer to geometryroot [1] gSystem->Load("libEG")

// pointer to PDG databaseroot [2] gSystem->Load("libTree”)

// TTree library root [3] gSystem->Load("libESD”)

// ESD library

Page 8: May 17 and 22, 20071 ALICE Offline Tutorial Markus Oldenburg – CERN Markus.Oldenburg@cern.ch May 17 and 22, 2007 – University of Sao Paulo

May 17 and 22, 2007 8

Run selector with PROOF

Start ROOT and create chain as beforechain = new TChain(“esdTree”)chain->Add(“root://lxb6046.cern.ch//proofpool/ pdc06/100/002/root_archive.zip#AliESDs.root”)

Connect to PROOF serverproof = TProof::Open(“<username>@lxb6046”)

Upload the ESD packageproof->UploadPackage(“ESD.par”)proof->EnablePackage(“ESD”)

Execute with PROOFchain->SetProof()chain->Process(“AliMultiplicity

ESDSelector.cxx++”)

Page 9: May 17 and 22, 20071 ALICE Offline Tutorial Markus Oldenburg – CERN Markus.Oldenburg@cern.ch May 17 and 22, 2007 – University of Sao Paulo

May 17 and 22, 2007 9

Run with a long chain

Create longer chain.L CreateESDChain.Cchain = CreateESDChain(“ESD100_110_v2.txt”)

Execute the selector with PROOFchain->SetProof()chain->Process(“AliMultiplicityESDSelector.cxx+

+”)

NB: Without CreateESDChain.C, do the following:chain = new TChain("esdTree")int count=0; TString file; ifstream in;in.open("ESD100_110_v2.txt")while((++count<201) && (in>>file)) chain->Add(file.Data());

Page 10: May 17 and 22, 20071 ALICE Offline Tutorial Markus Oldenburg – CERN Markus.Oldenburg@cern.ch May 17 and 22, 2007 – University of Sao Paulo

May 17 and 22, 2007 10

Looking at the Selector

SlaveBeginCalled once per Slave before processingMultiplicity histogram is created

ProcessCalled once per eventTracks are counted, histogram filled

SlaveTerminateCalled once per Slave after processingMultiplicity histogram is filled into the output list

TerminateCalled once on the client (your laptop/PC)Multiplicity histogram is read from the output list and displayed

Page 11: May 17 and 22, 20071 ALICE Offline Tutorial Markus Oldenburg – CERN Markus.Oldenburg@cern.ch May 17 and 22, 2007 – University of Sao Paulo

May 17 and 22, 2007 11

Changing the Selector

Add a || < 0.5 cutInt_t nGoodTracks = 0;for (Int_t i=0; i<fESD->GetNumberOfTracks(); ++i) { AliESDtrack* track = fESD->GetTrack(i); Double_t p[3]; track->GetConstrainedPxPyPz(p); TVector3 vector(p); Float_t eta = vector.Eta(); if (TMath::Abs(eta) < 0.5)

nGoodTracks++; }fMultiplicity->Fill(nGoodTracks);

Page 12: May 17 and 22, 20071 ALICE Offline Tutorial Markus Oldenburg – CERN Markus.Oldenburg@cern.ch May 17 and 22, 2007 – University of Sao Paulo

May 17 and 22, 2007 12

Changing the Selector (2)

Add a second plot: distributionHeader file (.h file)

• Add new member: TH1F* fEta; // eta distribution

Constructor• Initialize member: fEta(0)

SlaveBegin• Create histogram

fEta = new TH1F("fEta", "#eta distribution", 20, -2., 2.);

Process• Get like in previous example• Fill histogram: fEta->Fill(eta);

Page 13: May 17 and 22, 20071 ALICE Offline Tutorial Markus Oldenburg – CERN Markus.Oldenburg@cern.ch May 17 and 22, 2007 – University of Sao Paulo

May 17 and 22, 2007 13

Changing the Selector (3)

SlaveTerminateAdd histogram to the output list: fOutput->Add(fEta);

Terminate Read histogram from the output listfEta = dynamic_cast<TH1F*> (fOutput->FindObject("fEta"));Introduce an if statement if the object was retrievedif (!fEta) { AliDebug(AliLog::kError, “fEta was not found”); return; }Draw the histogramnew TCanvas;fEta->DrawCopy();

Page 14: May 17 and 22, 20071 ALICE Offline Tutorial Markus Oldenburg – CERN Markus.Oldenburg@cern.ch May 17 and 22, 2007 – University of Sao Paulo

May 17 and 22, 2007 14

Learning about Branches

The ESD tree consists of several branchesSwitching off not needed branches increases speed of analysis significantlyLooking at the available brancheschain = new TChain(“esdTree”)chain->Add(“root://lxb6046.cern.ch//pool/proofpool/

pdc06/100/002/root_archive.zip#AliESDs.root”)chain->Print()

Disable all branches (in Init)tree->SetBranchStatus("*", 0)

Enable a needed branch (in Init)tree->SetBranchStatus(“fTracks.fCp”, 1)

Try this! What is the increase in processing speed?

Page 15: May 17 and 22, 20071 ALICE Offline Tutorial Markus Oldenburg – CERN Markus.Oldenburg@cern.ch May 17 and 22, 2007 – University of Sao Paulo

May 17 and 22, 2007 15

Running with full AliROOT

Start AliROOTConnect to PROOF serverproof = TProof::Open(“<username>@lxb6046”)

Enable AliROOT.x ProofEnableAliRoot.C

Create Chain.L CreateESDChain.Cchain = CreateESDChain(

“ESD100_110_v2.txt”)Execute the selector that accesses MCchain->SetProof()chain->Process(“AliMultiplicity

MCSelector.cxx++”)

Page 16: May 17 and 22, 20071 ALICE Offline Tutorial Markus Oldenburg – CERN Markus.Oldenburg@cern.ch May 17 and 22, 2007 – University of Sao Paulo

May 17 and 22, 2007 16

Accessing the event header

AliSelectorRL::GetHeader returns the headerMake AliHeader known to the class#include <AliHeader.h> Retrieve the header (in Process)AliHeader* header = GetHeader();if (!header) { AliDebug(AliLog::kError, "Header not available"); return kFALSE;}

Retrieve a value from the headerprintf("This is run %d.\n", header->GetRun());

Run it and look at the log

Page 17: May 17 and 22, 20071 ALICE Offline Tutorial Markus Oldenburg – CERN Markus.Oldenburg@cern.ch May 17 and 22, 2007 – University of Sao Paulo

May 17 and 22, 2007 17

Your own selector

Start from AliEmptySelector

Find a nameCopy AliEmptySelector.h/.cxx to <yourSelector>.h/.cxx

Replace class names, define statement

Put in your analysis code

Page 18: May 17 and 22, 20071 ALICE Offline Tutorial Markus Oldenburg – CERN Markus.Oldenburg@cern.ch May 17 and 22, 2007 – University of Sao Paulo

May 17 and 22, 2007 18

Reading log files

When your selector crashesYou cannot access the output via the PROOF progress windowUsually you have to restart the ROOT session

Reading output from last queryOpen ROOTGet a PROOF manager objectmgr = TProof::Mgr(“<username>@lxb6046”)Get the log files from the last sessionlogs = mgr->GetSessionLogs(0)Display themlogs->Display()Search for a special word (e.g. segmentation violation)logs->Grep(“segmentation violation”)Save them to a filelogs->Save(“*”, “logs.txt”)

Page 19: May 17 and 22, 20071 ALICE Offline Tutorial Markus Oldenburg – CERN Markus.Oldenburg@cern.ch May 17 and 22, 2007 – University of Sao Paulo

May 17 and 22, 2007 19

Some Goodies...

Resetting environmentTProof::Reset(“<username>@lxb6046”)

Run with debugProcess(“<selector>”, “debug”)Process(“<selector>”, “moredebug”)

Compile with debugProcess(“<selector>+g”)

Create a package from AliROOT“make ESD.par” in your $ALICE_ROOT directory

Page 20: May 17 and 22, 20071 ALICE Offline Tutorial Markus Oldenburg – CERN Markus.Oldenburg@cern.ch May 17 and 22, 2007 – University of Sao Paulo

May 17 and 22, 2007 20

Backup

Page 21: May 17 and 22, 20071 ALICE Offline Tutorial Markus Oldenburg – CERN Markus.Oldenburg@cern.ch May 17 and 22, 2007 – University of Sao Paulo

May 17 and 22, 2007 21

PROOF Handout

Connect to PROOF serverproof = TProof::Open(“<username>@lxb6046”)

Upload the ESD packageproof->UploadPackage(“ESD.par”)proof->EnablePackage(“ESD”)

Enable AliROOT.x ProofEnableAliRoot.C

Create small chain manuallychain = new TChain(“esdTree”)chain->Add(“root://lxb6046//proofpool/pdc06/100/

002/root_archive.zip#AliESDs.root”)Create long chain.L CreateESDChain.Cchain = CreateESDChain(“ESD100_110_v2.txt”)Execute a selector with PROOFchain->SetProof()chain->Process(“AliMultiplicityESDSelector.cxx+”)

Page 22: May 17 and 22, 20071 ALICE Offline Tutorial Markus Oldenburg – CERN Markus.Oldenburg@cern.ch May 17 and 22, 2007 – University of Sao Paulo

May 17 and 22, 2007 22

Analysis with Selectors

Create a selectorTFile *fESD = TFile::Open(“AliESDs.root”);TTree *tESD = (TTree *)fESD->Get(“esdTree”);tESD->MakeSelector();Info in <TTreePlayer::MakeClass>: Files: esdTree.h and esdTree.C generated

from TTree: esdTree

Modify the selector accordingly and run it.! emacs esdTree.{C,h}&tESD->Process(“esdTree.C”);

Use an existing example and modify it accordingly

For further information on selectors:Check the analysis user guide provided by A.PetersPresentation of M.Biskup at the Root workshop 2005

Page 23: May 17 and 22, 20071 ALICE Offline Tutorial Markus Oldenburg – CERN Markus.Oldenburg@cern.ch May 17 and 22, 2007 – University of Sao Paulo

May 17 and 22, 2007 23

Entries are processed in an arbitrary order

Only the needed data is

read

Skeleton can be

generated from a Tree

Basics of Selectors

Selectors contain skeleton of processing systemPreprocessing and initialization Processing each eventPost processing and clean-up

Page 24: May 17 and 22, 20071 ALICE Offline Tutorial Markus Oldenburg – CERN Markus.Oldenburg@cern.ch May 17 and 22, 2007 – University of Sao Paulo

May 17 and 22, 2007 24

TSelector::SlaveBegin();TSelector::SlaveTerminate();

TSelector::Init(TTree*)

TList* fInput, fOutput;

InputList OutputList

resultsinput data

InputList OutputList

PROOF

network network

Selectors

More complicated in a distributed environment

Many computers to initialize and clean-up

Many trees in a chain

Input and output results should be transparently sent over network

Page 25: May 17 and 22, 20071 ALICE Offline Tutorial Markus Oldenburg – CERN Markus.Oldenburg@cern.ch May 17 and 22, 2007 – University of Sao Paulo

May 17 and 22, 2007 25

PROOF and Selectors

No user’s control on the order

Many Trees are being processed

Initialize each Slave

The same code works also without

PROOF (of course!)

Client

Client

Slaves

Slaves

Slaves

Slaves

Page 26: May 17 and 22, 20071 ALICE Offline Tutorial Markus Oldenburg – CERN Markus.Oldenburg@cern.ch May 17 and 22, 2007 – University of Sao Paulo

May 17 and 22, 2007 26

Selectors - summary

Skeletons generated from a tree

Only methods need to be filled

Simplify program structure

Can be used for parallel processing as well as for local analysis

More about the selectors during the PROOF tutorial

Page 27: May 17 and 22, 20071 ALICE Offline Tutorial Markus Oldenburg – CERN Markus.Oldenburg@cern.ch May 17 and 22, 2007 – University of Sao Paulo

May 17 and 22, 2007 27

PROOF Installation

Install ROOT with PROOF enabled (default)

More information: http://root.cern.ch

Configuration (see next slides)xrootd config file: xrd.cfPROOF config file: proof.conf

Start xrootd serviceRequires unprivileged user account

Page 28: May 17 and 22, 20071 ALICE Offline Tutorial Markus Oldenburg – CERN Markus.Oldenburg@cern.ch May 17 and 22, 2007 – University of Sao Paulo

May 17 and 22, 2007 28

xrd.cf

## Load the XrdProofd protocol:

xrd.protocol xproofd:1093 /opt/root/lib/libXrdProofd.so

## Set ROOTSYS

xpd.rootsys /opt/root

## Working directory for sessions

xpd.workdir /pool/proofbox

Page 29: May 17 and 22, 20071 ALICE Offline Tutorial Markus Oldenburg – CERN Markus.Oldenburg@cern.ch May 17 and 22, 2007 – University of Sao Paulo

May 17 and 22, 2007 29

xrd.cf (2)

## xpd.resource static [<cfg_file>] [ucfg:<user_cfg_opt>] [wmx:<max_workers>] [selopt:<selection_mode>]

xpd.resource static /etc/proof/proof.conf wmx:-1 selopt:roundrobin

## Server role (master, worker) [default: any]

xpd.role worker if lxb*.cern.ch

xpd.role master if lxb6046.cern.ch

## Master(s) allowed to connect. By default all connections are allowed.

xpd.allow lxb6046.cern.ch

Page 30: May 17 and 22, 20071 ALICE Offline Tutorial Markus Oldenburg – CERN Markus.Oldenburg@cern.ch May 17 and 22, 2007 – University of Sao Paulo

May 17 and 22, 2007 30

proof.conf

## machine running the mastermaster lxb6046.cern.ch## machine(s) running Workers, dual

CPU machines have to be listed twice

worker lxb6047.cern.chworker lxb6047.cern.chworker lxb6048.cern.chworker lxb6048.cern.ch...

Page 31: May 17 and 22, 20071 ALICE Offline Tutorial Markus Oldenburg – CERN Markus.Oldenburg@cern.ch May 17 and 22, 2007 – University of Sao Paulo

May 17 and 22, 2007 31

Starting xrootd Service

xrootd -b -l xrootd.log -R proofaccount -c xrd.cf -dOptions:-b : background (skip for debugging)-l : log file-R <useraccount> : user account that

runs xrootd service-c <configfile> : configuration file-d : debug flag

Do not forget full paths to the files