Difference between revisions of "LHCb Software At Nikhef: Prepare for Workshop 22-24 June 2009"

From LHCb Wiki
Jump to navigation Jump to search
Line 41: Line 41:
  
 
=== Set the environment ===
 
=== Set the environment ===
 
+
Before setting the application environment as explained in section ??? it is necessary to set the LHCb login environment:
Here we set the environment for DaVinci, but it could also another LHCb application, like Bender or Panoramix.
 
 
<pre>
 
<pre>
 
mkdir cmtuser
 
mkdir cmtuser
Line 48: Line 47:
 
source /project/bfys/lhcb/sw/setup.sh  # for sh, bash, ksh, zsh
 
source /project/bfys/lhcb/sw/setup.sh  # for sh, bash, ksh, zsh
 
source /project/bfys/lhcb/sw/setup.csh  # for csh, tcsh
 
source /project/bfys/lhcb/sw/setup.csh  # for csh, tcsh
SetupProject --build-env DaVinci v23r1p1 # makes a DaVinci_v23r1 directory if one doesn't already exist
 
SetupProject DaVinci v23r1p1 # exports environment variables to the shell
 
 
</pre>
 
</pre>
 
 
(NB: zsh-users should add 'setopt SH_WORD_SPLIT' to their .zshrc )
 
(NB: zsh-users should add 'setopt SH_WORD_SPLIT' to their .zshrc )
 +
After this, follow the steps outlined in ???
  
 
== Running on Workshop Server ==
 
== Running on Workshop Server ==
Line 71: Line 68:
 
</pre>
 
</pre>
  
=== Setup Environment ===
+
=== Set the Environment ===
  
(At startup, the script /opt/LHCb/LbLogin.sh is executed for all users.  
+
At startup, the script /opt/LHCb/LbLogin.sh is executed for all users. It sets up the LHCb environment. After this, follow the steps described in ???
It sets up the necessary environment.)
 
  
<pre>
 
# this line in case ~/cmtuser/DaVinci_v23r1p1 doesn't exist yet
 
SetupProject DaVinci v23r1p1 --build-env
 
# this exports environment variables to the shell. Some people might not like doing this
 
SetupProject DaVinci v23r1p1
 
</pre>
 
  
 
Run over events as described in section [].
 
Run over events as described in section [].
Line 119: Line 109:
 
=== Set the environment ===
 
=== Set the environment ===
  
This is the same as in the remote login to Nikhef, except that the LHCb environment should be set when you log in if you have set up your CernVM correctly.
+
If you have followed the instructions for setting up CernVM and added the necessary group login scripts to your own login scripts, the LHCb environment should be set. If this is not the case,
 +
<pre>
 +
# for sh, bash, ksh, zsh
 +
. /opt/lhcb/group_login.sh
 +
# for csh, tcsh
 +
source /lhcb/group_login.csh
 +
</pre>
 +
Then follow the steps outlined in section ???. If you can't find the required version of DaVinci or Bender, try refreshing the CernVM cache. '''You need an internet connection for this!'''
 
<pre>
 
<pre>
SetupProject --build-env DaVinci v23r1p1 # makes a DaVinci_v23r1p1 directory if one doesn't already exist
 
SetupProject DaVinci v23r1p1 # exports environment variables to the shell
 
# if it doesn't know the version, try this:
 
 
sudo /etc/init.d/cernvm restart
 
sudo /etc/init.d/cernvm restart
 
</pre>
 
</pre>
  
The main difference here is that if you do not have the necessary software installed, CernVM will pull it and cache it for you. So the first time you do this you should have an interned connection.
+
The main difference in setting the application environments here is that if you do not have the necessary software installed, CernVM will pull it and cache it for you. So the first time you do this you should have an interned connection.
 +
 
 +
== Setting the Environment ==
 +
 
 +
We use the LHCb script '''SetupProject'''. We don't need to care about details, other that when invoked with '''--build-env''' it doesn't set any environment variables in the shell, and it creates a folder
 +
<pre>
 +
~/cmtuser/ProjectName_vXrY
 +
</pre>
 +
where all the software should be built. In our case, this project will be either DaVinci v23r1p1 or Bender v12r1. In the examples that follow, we use DaVinci.
 +
 
 +
<pre>
 +
# this line in case ~/cmtuser/DaVinci_v23r1p1 doesn't exist yet
 +
SetupProject DaVinci v23r1p1 --build-env
 +
# this exports environment variables to the shell. Some people might not like doing this
 +
SetupProject DaVinci v23r1p1
 +
</pre>
 +
 
 +
This procedure is common to working at CERN, Nikhef, CernVM and the workshop server, provided the LHCb scripts have been set up correctly, be it automatically in the login scripts, or explicitly by sourcing some script. Details are in the subsetsions for each platform.
  
 
== Running over some events on a DST or MicroDST ==
 
== Running over some events on a DST or MicroDST ==
Line 148: Line 159:
 
<pre>
 
<pre>
 
# Run over events:
 
# Run over events:
python -i $MICRODSTEXMAPLEROOT/scripts/MicroDSTReadingExample.py --input <iamanidiot.mdst>
+
python -i $MICRODSTEXMAPLEROOT/scripts/MicroDSTReadingExample.py --input <filename>
  
# The datafile <iamanidiot.mdst> on the server is here:
+
# <filename> can take one of the following values depending on context:
# /data/bfys/lhcb/workshop/Bs2JpsiPhiWithMC_1.mdst
 
  
# The datafile <iamanidiot.mdst> for CernVM (windows) is here:
+
# Workshop Server: /data/bfys/lhcb/workshop/Bs2JpsiPhiWithMC_1.mdst
# /mnt/hgfs/data/Bs2JpsiPhiWithMC_1.mdst
+
# Windows CernVM: /mnt/hgfs/data/Bs2JpsiPhiWithMC_1.mdst
 
+
# Mac CernVM: /data/lhcb/Bs2JpsiPhiWithMC_1.mdst
# The datafile <iamanidiot.mdst> for CernVM (mac) is here:
 
# /data/lhcb/Bs2JpsiPhiWithMC_1.mdst
 
  
 
</pre>
 
</pre>
Line 183: Line 191:
 
</pre>
 
</pre>
  
== Setting the Environment ==
 
  
We use the LHCb script '''SetupProject'''. We don't need to care about details, other that when invoked with '''--build-env''' it doesn't set any environment variables in the shell, and it creates a folder
 
<pre>
 
~/cmtuser/ProjectName_vXrY
 
</pre>
 
where all the software should be built. In our case, this project will be either DaVinci v23r1p1 or Bender v12r1. In the examples that follow, we use DaVinci.
 
 
<pre>
 
# this line in case ~/cmtuser/DaVinci_v23r1p1 doesn't exist yet
 
SetupProject DaVinci v23r1p1 --build-env
 
# this exports environment variables to the shell. Some people might not like doing this
 
SetupProject DaVinci v23r1p1
 
</pre>
 
 
This procedure is common to working at CERN, Nikhef, CernVM and the workshop server, provided the LHCb scripts have been set up correctly, be it automatically in the login scripts, or explicitly by sourcing some script. Details are in the subsetsions for each platform.
 
  
 
== Introduction to Python ==
 
== Introduction to Python ==

Revision as of 10:41, 19 June 2009

Introduction

The Bfys workshop will not take place at a high energy physics lab. Wireless connection is available, but for the hands-on work, we will not rely on that. Instead we provide two solutions:

1) Connect to a computer/server. (See: Running on Workshop Server )

2) Install and configure virtual machine on your laptop, "CernVM". (How to install)

(This will give the possibility to run LHCb software locally, very much as if you logon to a computer inside your laptop...)


We ask you to try to run an example job on the server using your laptop, before the workshop starts on Monday. (See Running on Workshop Server)


In addition - to familiarize with the LHCb software jargon - we ask you to read through the following pages too:

1) Python Basics

2) Bender Tutorial (twiki) Tutorial (pdf)

3) Gaudi Basics (twiki)

Running at Nikhef

Logon at Nikhef

ssh user@ribble.nikhef.nl
ssh stbc-16   (on stoomboot)

Set the environment

Before setting the application environment as explained in section ??? it is necessary to set the LHCb login environment:

mkdir cmtuser
cd cmtuser
source /project/bfys/lhcb/sw/setup.sh   # for sh, bash, ksh, zsh
source /project/bfys/lhcb/sw/setup.csh  # for csh, tcsh

(NB: zsh-users should add 'setopt SH_WORD_SPLIT' to their .zshrc ) After this, follow the steps outlined in ???

Running on Workshop Server

Logon to server

Linux or mac:

ssh -Y u01@192.16.186.107    (# Available usernames: u01 - u15)
Password: (LHCb psswrd)

Windows:

Make sure you have Exceed running
ssh to 192.16.186.107       (# Available usernames: u01 - u15)
Password: (LHCb psswrd)

Set the Environment

At startup, the script /opt/LHCb/LbLogin.sh is executed for all users. It sets up the LHCb environment. After this, follow the steps described in ???


Run over events as described in section [].

Running on a virtual machine on your very own laptop

This assumes you have successfully installed a CernVM on your computer. The installation varies between Windows, Mac OS and Linux, so see section further down for instructions on how to set it up. It also assumes you have set up basic login scripts, and installed AFS, X11R6, CVS and SVN if necessary. Also note that you have to run an application like DaVinci, Bender or Panoramix at least once while connected to the network in order to cache the necessary software.

Log onto your CernVM

This could mean starting the virtual machine and CernVM, starting it and logging in "remotely" from a terminal (Linux, Mac) or Exceed (Windows). Linux/Mac login

ssh -Y -p 2222 CernVMUserName@localhost

Windows login

Start exceed
Start ssh
Connect to vm with ssh to 192.168.204.128
     (Your number might be different!)
     (fink tunnel x11 connections in ssh!)

AFS access (not necessary for workshop)

If you need access to CERN AFS areas (not necessary for the workshop),

klog user@CERN.CH

Where user is your CERN AFS username. Note the UPPER CASE for the domain name. Be careful: Never do: ls /opt/ !! (It could start caching all atlas software...).

Set the environment

If you have followed the instructions for setting up CernVM and added the necessary group login scripts to your own login scripts, the LHCb environment should be set. If this is not the case,

# for sh, bash, ksh, zsh
. /opt/lhcb/group_login.sh
# for csh, tcsh
source /lhcb/group_login.csh

Then follow the steps outlined in section ???. If you can't find the required version of DaVinci or Bender, try refreshing the CernVM cache. You need an internet connection for this!

sudo /etc/init.d/cernvm restart

The main difference in setting the application environments here is that if you do not have the necessary software installed, CernVM will pull it and cache it for you. So the first time you do this you should have an interned connection.

Setting the Environment

We use the LHCb script SetupProject. We don't need to care about details, other that when invoked with --build-env it doesn't set any environment variables in the shell, and it creates a folder

~/cmtuser/ProjectName_vXrY

where all the software should be built. In our case, this project will be either DaVinci v23r1p1 or Bender v12r1. In the examples that follow, we use DaVinci.

# this line in case ~/cmtuser/DaVinci_v23r1p1 doesn't exist yet
SetupProject DaVinci v23r1p1 --build-env
# this exports environment variables to the shell. Some people might not like doing this
SetupProject DaVinci v23r1p1

This procedure is common to working at CERN, Nikhef, CernVM and the workshop server, provided the LHCb scripts have been set up correctly, be it automatically in the login scripts, or explicitly by sourcing some script. Details are in the subsetsions for each platform.

Running over some events on a DST or MicroDST

After the environment has been set (either by remote login to Nikhef or CERN, or in the local CernVM on your laptop, we can start some simple analysis:

Get a nice package full of example scripts (new Bender Examples package exists too...)

If you haven't already got an examples package, get it, as you might need to perform modifications to some of the scripts. This has to be done when you have access to the internet.

cd ~/cmtuser/DaVinci_v23r1p1
getpack -p anonymous Ex/MicroDSTExample v2r5
# re-sets the $MICRODSTEXAMPLEROOT environment variable
SetupProject DaVinci_v23r1p1
cd Ex/MicroDSTExample/cmt/
make
# Run over events:
python -i $MICRODSTEXMAPLEROOT/scripts/MicroDSTReadingExample.py --input <filename>

# <filename> can take one of the following values depending on context:

# Workshop Server: /data/bfys/lhcb/workshop/Bs2JpsiPhiWithMC_1.mdst
# Windows CernVM: /mnt/hgfs/data/Bs2JpsiPhiWithMC_1.mdst
# Mac CernVM: /data/lhcb/Bs2JpsiPhiWithMC_1.mdst

Plot some of the histograms made by the script

>>> massPlots[443].plot()
>>> massPlots[531].plot()
>>> massResPlots[531].plot()
>>> propTimePlot.plot()
>>> propTimeResPlot.plot()
>>> refitPropTimeResPlot.plot()
>>> Ctrl-D

Some more examples, using Gaudi or Bender environments and example scripts. Note we run them directly without getpacking them.

SetupProject Gaudi v21r0
python $GAUDIEXAMPLESROOT/python/HistoEx.py
SetupProject Bender v12r1
cd $BENDEREXAMPLEROOT/python/BenderExample/
./Phi.py


Introduction to Python

It is important that attendees make themselves familiar with the python programming language, at least at the level of writing simple scripts.

Python Basics

Extensive tutorial: Tutorial

Cheat Sheet: Cheat Sheet

Example: myfirst.py

Execute:
python myfirst.py