LHCb Software At Nikhef: Prepare for Workshop 22-24 June 2009
Introduction
The B-Fys workshop will not take place at a high energy physics lab. For these reasons, it is recommended that people install a virtual machine on their laptops in order to be able to run LHCb software locally, without necessity of an internet connection. Whereas this is not a "standard" way of performing analysis at the moment, it might be beneficial to set this up anyway. In what follows, there are explanations on how to run either with an internet connection to nikhef, or with a local virtual machine. Once the installation has been done and the environment set correctly, running on the virtual machine should be the same as running at Nikhef.
Running at Nikhef
Logon at Nikhef
ssh user@ribble.nikhef.nl ssh stbc-16 (on stoomboot)
Set the DaVinci environment
Here we set the environment for DaVinci, but it could also another LHCb application, like Bender or Panoramix.
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 SetupProject --build-env DaVinci v23r1 # makes a DaVinci_v23r1 directory if one doesn't already exist SetupProject DaVinci v23r1 # exports environment variables to the shell
(NB: zsh-users should add 'setopt SH_WORD_SPLIT' to their .zshrc )
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.
Log onto your CernVM
If you need access to CERN AFS areas,
klog user@CERN>CH
Where user is your CERN AFS username. Note the upper case for the domain name.
The next step is to set the enviromennt, which is the same as in the remote login to Nikhef:
SetupProject --build-env DaVinci v23r1 # makes a DaVinci_v23r1 directory if one doesn't already exist SetupProject DaVinci v23r1 # exports environment variables to the shell
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.
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.
getpack -p anonymous Ex/MicroDSTExample v2r5
cd ~/cmtuser/DaVinci_v23r1/Ex/MicroDSTExample/scripts python -i MicroDSTReadingExample.py --input /data/bfys/h71/Workshop/SeqDC06selBs2JpsiPhiWithMC_50.0_Kevt_NoPVReFit.dst
Plot some of the histograms made by the script
>>> massPlots[443].plot() >>> massPlots[531].plot() >>> massResPlots[531].plot() >>> propTimePlots[531].plot() >>> Ctrl-D
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.
Extensive tutorial: Tutorial
Cheat Sheet: Cheat Sheet
/user/h71> python >>> hello = "Hello world" >>> print hello >>> Ctrl-D
Install a Virtual Machine on your laptop: CernVM
See talk by Pere Mato, slide 14: 17 March 2009
CernVM beginner's guide: CernVM beginner's guide
1) Windows
1a) Download vmware player here
Unzip and put CernVM in fixed place. For example C:\Program Files\CernVM Start vmplayer from desktop Open CernVM from C:\Program Files\CernVM Open in browser: http://192.168.204.128:8004/ (your number might be different!) Create account. For example: use lxplus username and password Virtual organization: lhcb Change memory allocation in vmware player -> troubleshoot -> change memory allocation -> 1024 MB
1b) Start CernVM
Follow CernVM beginner's guide step by step: CernVM beginner's guide
1c) Start Exceed + SSH
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!)
1d) Configure CernVM
(once for configuring cernvm:) back to instructions afs sudo conary update openafs=1.4.8-1-1 sudo conary update openafs-client=1.4.8-1-1 sudo conary update openafs-kernel=1.4.8-1-1 sudo /etc/init.d/afs start
1e) CernVM session on ssh
Never do: ls /opt/ !! (It could start caching all atlas software...) kinit user@CERN.CH (capitals!) cd /opt/lhcb source /opt/lhcb/LbLogin.csh SetupProject Gaudi v21r0 python $GAUDIEXAMPLESROOT/python/HistoEx.py SetupProject Bender v12r0 cd $BENDEREXAMPLEROOT/python/BenderExample/ ./Phi.py
1f) Create shared data folder on your laptop
Make folder C:\Data Change properties of C:\Data -> sharing -> network sharing without wizard V share name: Data V allow
Edit the 2kB VMware configuration file (in C:\Program Files\CernVM\ ) and add: sharedFolder.maxNum = "1" sharedFolder0.present = "TRUE" sharedFolder0.enabled = "TRUE" sharedFolder0.readAccess = "TRUE" sharedFolder0.writeAccess = "TRUE" sharedFolder0.hostPath = "C:\Data" sharedFolder0.guestName = "data" sharedFolder0.expiration = "session" usb.autoConnect.device1 = "" NB: after editing the configuration file, restart VMware Player
In VMware: -> Share folders -> o always enabled
Add the following line to /etc/fstab: sudo emacs -nw /etc/fstab .host:/ /mnt/hgfs vmhgfs defaults 0 0 sudo ln -s /usr/sbin/mount.vmhgfs /sbin I edited Phi.py and put input data location: /mnt/hgfs/data/Bs2DsK_1.dst ) Data can be found here: /afs/cern.ch/lhcb/group/calo/ecal/vol10/DATA (or ask Niels or Vanya for a copy...)
Once everything is installed... Start CernVM
Start VMware Player (don't select 'Open', but 'Recent') Login to your CernVM with your SSH. source /opt/lhcb/LbLogin.csh SetupProject Bender v12r1 ./Phi.py root TBrowser f .q
2) MAC
I have succesfully tried using VirtualBox, from Sun Microsystems. It is free, it works. Follow more or less the instructions in [[ATLAS CernVM wiki][1]]
Download and untar CernVM 1.20 Get the one for VirtualBox from [2] Unzip and untar it. And figure out where in your file system it is. This will be the boot image "disk" for the operating system so VirtualBox will need it for booting. This must be done *before* the VirtualBox step.
Get VirtualBox http://www.virtualbox.org/wiki/Downloads Install it following instructions run it and follow https://twiki.cern.ch/twiki/bin/view/Atlas/CernVMGuideVirtualBox I went for ~1542MB memory
Name: CernVM OS Type: Linux 2.6 Base Memory: 1532 MB Video Memory: 6 MB Hard Disks IDE Primary Master: cernvm-1.2.0-x86.vmdk (Normal, 5.24 GB)
I had some problems getting it to find the disk image. I did lots of clicking around and it worked in the end. I cannot replicate the "locate the vmdk file" snapshots in the wiki exactly. Maybe I'll try again to see.
For network setup, I used NAT following these instructions
Then I followed the rest of the steps here
After starting a session, it is necessary to source the LHCb login script:
source /opt/lhcb/LbLogin.csh
(check what shell you have set) I added it to my login script. Then, to cache lots of software,
SetupProject DaVinci v23r1 (no v23r1p1 yet) SetupProject Panoramix v17r0 (no v17r1 yet)
Hubert has given me instructions on how to set the login scripts properly, so I'll try them and update this document later.
Juan
3) Linux
Configuration of CernVM
This configuration of CernVM is platform independent. A few things need to be set up before we can start playing
Login scripts
If you want the LHCb environment to be correctly set by default each time you login, the following is necessary:
/opt/lhcb/group_login.sh (csh) has to be sourced at the end of the .bash_profile (.login)for bash (tcsh).
/opt/lhcb/group_shell.sh (.csh) SHOULD be sourced at the end of the .bashrc (.tcshrc). However, this doesn't work at the moment and Hubert claims it doesn't really make a difference for now.
The most important one for us, /opt/lhcb/LbLogin.sh (csh), should be sourced, I do this in my .bashrc (.tcshrc).
Installing missing software
I found that I was missing SVN, CVS and, less importantly for the workshop, AFS. To install these, it is necessary to get the packages:
sudo conary update cvs sudo conary update subversion sudo conary update openafs=1.4.8-1-1 sudo conary update openafs-client=1.4.8-1-1 sudo conary update openafs-kernel=1.4.8-1-1
AFS has to be started:
sudo /etc/init.d/afs start
If you are using C-shell, remember to do type
rehash
to update the paths, otherwise you won't see cvs, klog, etc. until the next time you log it.