Configuring external libraries to CMSSW (like Geant4)

How does it work ?

After setting up CMSSW project workspace (scram project ...) following directory structure will appear:

bin  config  doc  external  include  lib  logs  python  share  src  test  tmp

Our own modules and plugins with code stored in "src" will be compiled into lib/slc4_ia32_gcc345/ directory, to the files lib*.so, plugin*.so and *.edmplugin. Those files are mainly shared libraries, which depends on external libraries.

External libraries are installed in the directory /afs/ (for example official Geant4 libraries are here: /afs/ ). In case of local CMSSW installation, local directory shall be used instead of /afs/

As there are many locations of different libraries there is a system of XML configuration files, where you can find necessary information (i.e. library locations) for all external tools/libraries. You can find it in the local project workspace, under config/toolbox/slc4_ia32_gcc345/tools.

After changing something in the XML files one needs to cofigure CMSSW workspace properly. This can be done with scram. Useful commands:

scram tool remove geant4 - tool removal

scram setup geant4core - tool installation (configuration)

scram tool info geant4 - prints information about tool configuration

Moreover ldd can give some important hints on library dependencies.

Step by step instruction how to replace Geant4 by custom instance

  • Source default set of environment variables:
> source /afs/

  • Initialize CMSSW project space:
> scram project CMSSW CMSSW_3_1_1

  • Replace Geant4 configuration by custom one, pointing to Geant4 compiled in /afs/ directory:
> cd CMSSW_3_1_1
> find . -name "geant4.xml"
> cp /afs/ ./config/toolbox/slc4_ia32_gcc345/tools/available/geant4.xml
> cp /afs/ ./config/toolbox/slc4_ia32_gcc345/tools/selected/geant4.xml
> find . -name "geant4core.xml"
> cp /afs/ ./config/toolbox/slc4_ia32_gcc345/tools/available/geant4core.xml
> cp /afs/ ./config/toolbox/slc4_ia32_gcc345/tools/selected/geant4core.xml

  • Reconfigure Geant4 tool, by typing:
> scram setup geant4
> scram setup geant4core

  • Check configuration:
> scram tool info geant4
> scram tool info geant4core

  • Now you can fetch source code from SVN repository and compile it

  • Check if SimG4Core/Application module was linked with custom G4 libraries:
> ldd lib/slc4_ia32_gcc345/ | grep G4process => /afs/ (0xf4208000)
> ls -l /afs/
lrwxr-xr-x  1 lgrzanka zj 86 Apr 22 15:15 /afs/ -> /afs/

  • In case of problems repeat following steps:
> scram tool remove geant4
> scram tool remove geant4core
> scram setup geant4
> scram setup geant4core
> scram b -j 4
> scram b -j 4
> scram b

Geant4 compilation

Sources of Geant4 libraries used in CMSSW are provided in the /afs/ Let us copy it into some directory and go there.

First thing is to adjust etc/ which contains all enviromental variables used in compilation process. In the original file lot of variables pointed to strange /build/d94/BUILD/... directory, probably on one of CMS build machines. Our file will have all the variables pointing to some subdirectory of /afs/ directory (G4TOTEM variable), see file /afs/

Second thing is the compiler. Geant4 needs to be compiled with some old GCC (3.3.?). In order to use the same compiler as in CMSSW, following enviromental variables are overwritten in file:

export BASE=/afs/
export GCC_BASE=$BASE/slc4_ia32_gcc345/external/gcc/3.4.5-cms
export CXX=$GCCBINDIR/c++
export MAKE_BASE=$BASE/slc4_ia32_gcc345/external/gmake/3.81-cms2
export PATH=$MAKE_BASE/bin:$PATH

We can now start compilation. First we need a fresh terminal ! Remember to compile Geant4 on a console which was not used before to compile CMSSW. Let us now go to source subdirectory and type:

source ../etc/
make global
We should now expect some files created in ../lib/Linux-g++. This is slightly different than original location (../lib), but it is easy to adjust it in geant4.xml and geant4core.xml.

Finally if we want to compile Geant4 with debugging options, the file to inspect is ../etc/architecture.gmk. One should put there somewhere at the beginning:

G4DEBUG := 0

-- LeszekGrzanka - 22-Apr-2010

Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r4 - 2010-06-21 - LeszekGrzanka
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    TOTEM All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2021 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