Ganga is the be-all and end-all LHCb software submission tool. If you can do it on the command line, you can do it in Ganga and mostly with less hassle. If you want to submit a local test job, then a grid job without changing your environment, writing new scripts or whatever, Ganga's your freind.... Ctrl-D to exit wink

Daily Ganga

Instantly use ganga:

export CMTCONFIG=slc4_ia32_gcc34 #on 64-bit machines if you want to submit to the grid.

GangaEnv latest


In [1]: jobs

In [2]: j=Jobs(#).copy()

If you have changed your requirements file, or got any new packages:

In [3]: j.application.cmt('br cmt config')

If you have changed your code

In [4]: j.application.make()

Check your code works locally by setting the interactive backend, and setting your algorithm to give debug output:

In [5]: j.backend=Interactive()

In [6]: j.application.extraopts = 'MyAlgorithm.OutputLevel=2; //debug'

In [7]: j.submit()

Ganga quick-start guide

So, you're a new user and want to use Ganga for the first time?

GangaEnv latest


3-step quick start

  • Obtain Greig's ganga goodies,
  • edit your gangarc to automatically include and configure ganga_utils. This will automatically set ALL environment variables in ganga 5. You still need to edt your .bashrc though, depending what you're doing.
  • Use the function ganga_utils.first_time_user() to getpack, make and submit a test job.
You can then edit the jobs/packages this command creates as you see fit to run your code.. easy peasy.

32/64 bit, GANGA and the grid

It is still not advised to submit 64-bit versions of compiled code to the grid. Instead you should make sure you change to a 32-bit version by doing:

bash-$ export CMTCONFIG=slc4_ia32_gcc34 
tcsh-$ setenv CMTCONFIG slc4_ia32_gcc34

Then be sure to re-build your code.

No user code yet

If you already have code compiled, skip this step. If not, do you want to compile your own code at some point? Probably! In this case do the following:

In [1]: j=Job()

In [2]: j.application=DaVinci()

In [3]: j.application.getpack('Phys/DaVinci ' + j.application.version)

In [4]: j.application.cmt('config')

In [5]: j.application.cmt('make')

Submit a test job

Go to the directory cmtuser/Package_version/Head/Package/version/Job

In [6]: cd ~/cmtuser/DaVinci_v19r10/Phys/DaVinci/v19r10/job

In [7]: ls 

In [8]: execfile('')

This will submit a standard test job... it should work on Lxplus.

Now, if you want to submit a similar job, just copy this test job which will have everything pre-configured. Change what you want! You're ready to go!

Ganga and beyond

Ganga with local data files

There is a list of locally-stored datafiles in LHCbEdinburghGroupDataFiles. These use dCache and DPM access protocols which need special protocols and additions to your .bashrc. The easiest access method requires Greig's Ganga Goodies, which will also handle the configuration for you.

Ganga FAQ

A central ganga FAQ is maintained at GangaLHCbFAQ

Using ganga without retrieving job output

If you don't want to recover the output automatically of jobs when you start ganga use:

ganga -o'[PollThread]autostart=False'

How to use the Ganga Remote repository

The ganga remote repository lets you keep a central store of your job information. The output must still be recovered somewhere, if you want to look at/submit new jobs without collecting the output of previous jobs, use the hint above.

To gain access to the remote repository, send a request to Joel Closier, to have an account set up. After getting confirmation, edit your .gangarc file to:


# The type of the repository: Local (default) or Remote
type = Remote

# Your name in Ganga. Defaults to your user name.
user = gcowan

# Options for Remote repository (ARDA MD Server)
# Your authentication to the database
# Currently the access is not authenticated unless reqSSL is set to 1.
login = gcowan
host =
port = 8822

# Turn the authentication mode on.
# With reqSSL = 1, you should also set port = 8823 and login = user
reqSSL = 1

How to use ganga 4.X and 5.X at the same time

These two versions of ganga are compatible to be run in parallel but they use a different repository and need a different .gangarc

With a ganga 4.X gangarc:

> mv .gangarc .ganga4
> ganga --config=~/.ganga4

you can even define an alias such as:

alias Ganga4="LHCbEnv; sleep 1s; source /Disk/lochnagar0/lhcb/lhcb-soft/Ganga/install/etc/ 4.4.15; alias ganga='ganga --config=~/.ganga4'; ganga --config=~/.ganga4"

Then make a new gangarc for ganga 5:

>GangaEnv latest
>ganga -g
>emacs .gangarc #edit this file to what you want

you can even define an alias such as:

alias Ganga5="LHCbEnv; sleep 1s; source /Disk/lochnagar0/lhcb/lhcb-soft/Ganga/install/etc// latest; ganga"

How to import a LHCbDataset from an ascii file

  1. Easy: Use ][][greig's ganga goodies]]. gu.dataset_from_ascii('mydatfile.dat')
  2. Annoying: In an interactive Ganga session (just to practice, then you can do the same inside a Ganga script):

In [1]: dataset=[]
In [2]: afile = open("DC06BdphiKs_Local_Datafiles.dat")
ln [3]: for line in afile.readlines():
      ...:          dataset.append(line[:-1])
In [4]: datafiles = LHCbDataset(files=dataset)
In [5]: datafiles
Out[5]: LHCbDataset (
 cache_date = '' ,
 files = [ LHCbDataFile (
    name = '/Disk/lochnagar0/lhcb/DC06/00001655_00000002_5.dst' ,
    replicas = [] 
    ) , ........................................

  • You can now provide the datafile object (of type LHCbDataset ) to your DaVinci job, and do clever things like split your job by files (using the SplitByFiles() method or the DiracSplitter() if you submit to the Grid ):

In [10]: myjob.inputdata    = datafiles
In [11]: filesplitter  = SplitByFiles()
In [12]: filesplitter.filesPerJob   = 10
In [13]: myjob.splitter   = filesplitter

How to export to an ascii file a LHCbDataset

Suppose you need to make a copy of a LHCbDataset to pass around to one of your colleagues. Start an interactive ganga session. First thing to do is to open a file for writing and select the job from where the data set is to be taken:

In [2]:outfile=open('copyoflfns.txt','w')
In [3]:myjob = jobs(90)

That job has in n subjobs. Let's loop over them and copy the names of the dataset:

In [16]:for sjob in myjob.subjobs:
   ....:     lfnset = sjob.inputdata.copy()
   ....:     for files in lfnset.files:
   ....:         print
   ....:         outfile.write( + '\n' )

You can now close the file object:

In [17]:outfile.close()

Setting up Ganga to submit LHCb jobs to our local Condor batch queue

You can submit to Condor from your desktop. There is no longer any need to logon to the Condor frontend (

Ganga 5.X

Using ganga_utils.configure() and the centrally maintained ganga.ini means you need nothing new in your .gangarc aside from obtaining/configuring the ganga goodies.

Ganga 4.X

With ganga 4.X you will need to edit the Ganga configuration file '~/.gangarc' and add the following lines. For ganga 5 the first half is added automatically for you, so you only need to add the "other = " line.

<<ganga 4.X >>
<<ganga 5.X>>

env = { 'HOME' : '/Home/aooliver' , 'BASH_ENV' : '/Disk/lochnagar0/lhcb/lhcb-soft/scripts/' }

<<ganga 4.X >>
<<ganga 5.X >>

other = ['((Cluster == "ppe") ||  (Cluster == "cplab"))']

Change the path to your "home area" (in the example above is pointing to mine i.e. /Home/aooliver).

In principle, that's all !! You are ready to use Ganga in the usual way. Don't forget to change the backend to Condor().

If you're running with dCache data or DPM data you will need extra bits and pieces here, check out the individual pages for more details.

Using ganga on ECDF

ECDF uses Sun Grid Engine. The requirements for gangarc are listed here. For Ganga 5, nothing is required apart from using Greig's Ganga Goodies and a couple of changes in your bashrc if using the DPM.

If you're running with dCache data or DPM data you will need extra bits and pieces here, check out the individual pages for more details.

Ganga tricks

To quit python without a prompt hit "Ctrl \"

To reload a python module "gu" (if the source code has changed) use: "reload(gu)"

To try and force a job state transition if the job is stuck use:


if you really want to force a particular jobs status if it is annoyingly stuck somewhere use:


where js1 is a job or subjob.

To force the removal of a job from the list, if it is really annoying, use:


To change your cmtuser area do:


To change the directory your sim, digi, dst files go to, add:


Underneath [LHCb] in your gangarc.

Running ganga from afs

In case you want a different version of ganga, which you know is installed on afs:

GangaEnv latest

Submitting ROOT jobs with Ganga

See the entry Using root in Ganga.

Ganga Goodies

import ganga_utils as gu

GreigCowan + Rob Lambert have put together some common operations that need to be performed when using Ganga to submit, monitor and manage jobs. Hopefully some of these utilities will eventually be folded into the main Ganga release. You can get access to these utilities by checking them out of the LHCbEdinburghGroupCVS.

More details can be found on LHCbEdinburghGroupGangaUtils.

Ganga Utils is by default configured for use at Edinburgh. Read the documentation to find out how to change the configuration.

Creating an LHCbDataset from the list of locally available files

The ganga_utils module contains a method for automatically creating an LHCbDataset from the .dat file that you can find in the LHCbEdinburghGroupDataFiles table. i.e.

j.inputdataset = gu.dataset_from_twiki('name_of_file.dat')

where j is your job and name_of_file.dat is filename that you are interested in. A blank filename will give the list of files from : LHCbEdinburghGroupDataFiles

Getting back output files

This is what we did for βs ntuple production

  • cd ~gangadir/workspace/USER_NAME/LocalXML
  • cp -r X tmp_X
  • mv X /tmp/X
  • ln -s /tmp/X X
  • Enters Ganga
  • j = jobs(X)
  • [js.backend.getOutputData() for js in j.subjobs if js.status == "completed"]
  • cd(X) or from os import system and system("cd ...")
  • Then do hadd system("hadd -f DTT.root ../*/output/*.root")
  • Copy to castor system("rfcp DTT.root /castor/")
  • To look at system("root -l DTT.root" )
Topic attachments
I Attachment History Action Size Date Who Comment
PNGpng GangaLogo.png r1 manage 7.9 K 2007-10-17 - 01:06 AndresOsorio Ganga new cool logo
Edit | Attach | Watch | Print version | History: r41 < r40 < r39 < r38 < r37 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r41 - 2011-06-24 - MatthewNeedham
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Main All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2023 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback