Install Geant4

20
Installing Geant4 Release 4.9.4.p02 on Linux Installation guides are available for a variety of different Geant4 releases and operating systems. Be sure to use the appropriate guide for your Geant4 release and system. The full set of guides can be found at: http://geant4.slac.stanford.edu/installation Contents: What are the two pieces of software required for building Geant4? Getting and Installing CLHEP Getting Geant4 Getting Data Files Doing the Initial Build Single versus Multi-User Installation Creating the setup script The Geant4 Work Directory Selecting an Example Application Configuring the Environment Building an Example Application Running How to Go Back and Change Choices from./Configure -build What are the two pieces of software required for building Geant4? gcc 4.1.2 or 4.3.2 (for SLC5 or RedHat 5) or gcc 3.4.6 or 4.5.1 (for SLC4): gcc is the compiler that is recommended for Geant4 on Linux. Users have also had success with some other gcc versions, but there is no guarantee. To check your version, type: gcc –v. Installing Geant4 Release 4.9.4.p02 on Linux http://geant4.slac.stanford.edu/tutorial/installatio... 1 of 20 07/17/2014 05:32 PM

Transcript of Install Geant4

Page 1: Install Geant4

Installing Geant4 Release 4.9.4.p02 on Linux

Installation guides are available for a variety of different Geant4 releases and operating systems. Besure to use the appropriate guide for your Geant4 release and system. The full set of guides can befound at:http://geant4.slac.stanford.edu/installation

Contents:

What are the two pieces of software required for building Geant4?

Getting and Installing CLHEP

Getting Geant4

Getting Data Files

Doing the Initial Build

Single versus Multi-User Installation

Creating the setup script

The Geant4 Work Directory

Selecting an Example Application

Configuring the Environment

Building an Example Application

Running

How to Go Back and Change Choices from./Configure -build

What are the two pieces of software required for building Geant4?

gcc 4.1.2 or 4.3.2 (for SLC5 or RedHat 5) or gcc 3.4.6 or 4.5.1 (for SLC4):gcc is the compiler that is recommended for Geant4 on Linux. Users have also had success with someother gcc versions, but there is no guarantee.To check your version, type: gcc –v.

Installing Geant4 Release 4.9.4.p02 on Linux http://geant4.slac.stanford.edu/tutorial/installatio...

1 of 20 07/17/2014 05:32 PM

Page 2: Install Geant4

CLHEP:CLHEP is a set of base libraries that have long provided great functionality for the particle physicscommunity. They provide things like matrix manipulations, four-vector tools and lists of particleproperties. The Geant4 collaboration has chosen to use these libraries rather than re-invent thesewheels. Please note that while CLHEP and Geant4 both come out of the particle physicscommunities, they are separate products - the Geant4 collaboration is not responsible formaintenance, distribution or documentation of CLHEP.Be careful to use only the recommended version of CLHEP. If you use any other version, your codemay still run, but you may get incorrect results.

Getting and Installing CLHEP

Go to the CLHEP source download page:http://proj-clhep.web.cern.ch/proj-clhep/DISTRIBUTION/clhep.html

From the "Source" section near the bottom of the page, select "clhep-2.1.0.1.tgz"which corresponds to:http://proj-clhep.web.cern.ch/proj-clhep/DISTRIBUTION/tarFiles/clhep-2.1.0.1.tgz

The file is about 4 MB.

Put it into your directory of choice, such as:~/CLHEP

Navigate to this directory and unpack the file:cd ~/CLHEPtar -zxvf clhep-2.1.0.1.tgz

The unpacking process will begin, starting with:2.1.0.1/2.1.0.1/CLHEP/2.1.0.1/CLHEP/Cast/2.1.0.1/CLHEP/Cast/Cast/2.1.0.1/CLHEP/Cast/Cast/defs.h.in

And ending with:2.1.0.1/CLHEP/install-sh2.1.0.1/CLHEP/missing2.1.0.1/CLHEP/config.sub2.1.0.1/CLHEP/Makefile.in2.1.0.1/CLHEP/configure

For the following step, note that there are two dashes in a row before the word "prefix".Also note that for this command you should use the absolute path for your CLHEP, such as:/u/ey/perl/CLHEPrather than a relative path, such as:

Installing Geant4 Release 4.9.4.p02 on Linux http://geant4.slac.stanford.edu/tutorial/installatio...

2 of 20 07/17/2014 05:32 PM

Page 3: Install Geant4

~/CLHEPAnd be sure to point to your top level CLHEP directory, NOT:/u/ey/perl/CLHEP/2.1.0.1/CLHEP

Now navigate into the unpacked directory and begin the configuration process.Of course, substitute your actual CLHEP path here:cd 2.1.0.1/CLHEP./configure --prefix /u/ey/perl/CLHEP

You should get a response that starts with:checking build system type... i686-pc-linux-gnuchecking host system type... i686-pc-linux-gnuchecking target system type... i686-pc-linux-gnuchecking for a BSD-compatible install... /usr/bin/install -cchecking whether build environment is sane... yes

And ends with:config.status: creating test/exctest4.shconfig.status: creating test/exctestNothrow.shconfig.status: creating test/excDblThrow.shconfig.status: creating Exceptions/defs.hconfig.status: executing depfiles commands

The complete output from the above command can be found in this same web directory as:CLHEPConfigure.txt

For the following, be sure to type make rather than gmake. It can be very hard to remember which ofthese to type. One some Linux systems, they may even do the exact same thing, but not always. Sofor your CLHEP and Geant4 work, don't use gmake

Run the build process:make

You should get a response that starts with:Making all in Unitsmake[1]: Entering directory `/afs/slac.stanford.edu/u/ey/perl/CLHEP/2.1.0.1/CLHEP/Unit'Making all in Unitsmake[2]: Entering directory `/afs/slac.stanford.edu/u/ey/perl/CLHEP/2.1.0.1/CLHEP/Units/Units'make all-am

And ends with:rm -f libCLHEP-2.1.0.1.soliblist=`./getObjectList -shared Units Utility Vector EvaluatorGenericFunctions Geometry Random Matrix RandomObjects Cast RefCountExceptions`; \

Installing Geant4 Release 4.9.4.p02 on Linux http://geant4.slac.stanford.edu/tutorial/installatio...

3 of 20 07/17/2014 05:32 PM

Page 4: Install Geant4

g++ -O -ansi -pedantic -Wall -D_GNU_SOURCE -g -O2 -o libCLHEP-2.1.0.1.so -shared -Wl,--no-undefined -Wl,-soname,libCLHEP-2.1.0.1.so$liblist -o libCLHEP-2.1.0.1.so./build-headermake[1]: Leaving directory `/afs/slac.stanford.edu/u/ey/perl/CLHEP/2.1.0.1/CLHEP'

The complete output from the above command can be found in this same web directory as:CLHEPMake.txt

Move the build products to their installation area (again, be careful you don't accidentally use gmake- you need to use make):make install

You should get a response that starts with:Making install in Unitsmake[1]: Entering directory `/afs/slac.stanford.edu/u/ey/perl/CLHEP/2.1.0.1/CLHEP/Units'Making install in Unitsmake[2]: Entering directory `/afs/slac.stanford.edu/u/ey/perl/CLHEP/2.1.0.1/CLHEP/Units/Units'

And ends with:test -z "/u/ey/perl/CLHEP/include/CLHEP" || mkdir -p -- "/u/ey/perl/CLHEP/include/CLHEP"if test -f ClhepVersion.h; then \

echo " /usr/bin/install -c -m 644 'ClhepVersion.h' '/u/ey/perl/CLHEP/include/CLHEP/ClhepVersion.h'"; \

/usr/bin/install -c -m 644 "ClhepVersion.h" "/u/ey/perl/CLHEP/include/CLHEP/ClhepVersion.h"; \

else :; fi/usr/bin/install -c -m 644 'ClhepVersion.h' '/u/ey/perl/CLHEP/include/CLHEP/ClhepVersion.h'make[2]: Nothing to be done for `install-data-am'.make[2]: Leaving directory `/afs/slac.stanford.edu/u/ey/perl/CLHEP/2.1.0.1/CLHEP'make[1]: Leaving directory `/afs/slac.stanford.edu/u/ey/perl/CLHEP/2.1.0.1/CLHEP'

The complete output from the above command can be found in this same web directory as:CLHEPInstall.txt

You will now have directories such as:~/CLHEP/includeand~/CLHEP/lib

Installing Geant4 Release 4.9.4.p02 on Linux http://geant4.slac.stanford.edu/tutorial/installatio...

4 of 20 07/17/2014 05:32 PM

Page 5: Install Geant4

The exact contents of the lib directory should be as follows:libCLHEP-2.1.0.1.alibCLHEP-2.1.0.1.solibCLHEP-Cast-2.1.0.1.alibCLHEP-Cast-2.1.0.1.solibCLHEP-Evaluator-2.1.0.1.alibCLHEP-Evaluator-2.1.0.1.solibCLHEP-Exceptions-2.1.0.1.alibCLHEP-Exceptions-2.1.0.1.solibCLHEP-GenericFunctions-2.1.0.1.alibCLHEP-GenericFunctions-2.1.0.1.solibCLHEP-Geometry-2.1.0.1.alibCLHEP-Geometry-2.1.0.1.solibCLHEP-Matrix-2.1.0.1.alibCLHEP-Matrix-2.1.0.1.solibCLHEP-Random-2.1.0.1.alibCLHEP-Random-2.1.0.1.solibCLHEP-RandomObjects-2.1.0.1.alibCLHEP-RandomObjects-2.1.0.1.solibCLHEP-RefCount-2.1.0.1.alibCLHEP-RefCount-2.1.0.1.solibCLHEP-Vector-2.1.0.1.alibCLHEP-Vector-2.1.0.1.solibCLHEP.alibCLHEP.so

You're done setting up CLHEP.

If the CLHEP build fails in some strange way, you may be able to instead use pre-built versions ofCLHEP. We do not recommended them in general because they do not work for all versions of Linuxor all versions of C++, but if you have no other solution, this might be the way to solve your issues.Pre-built versions can be found in the right hand column of the CLHEP source download page:http://proj-clhep.web.cern.ch/proj-clhep/DISTRIBUTION/clhep.html

Untar this withtar –zxvf

Move all of its contents (bin, build, include, lib) into ~/CLHEPIf your Geant4 build and run goes OK, then this was an appropriate CLHEP build. If not, then thispre-built version of CLHEP was not appropriate for your version of Linux or C++.

We do not recommend you run the "make check" command described in the CLHEPdocumentation unless you really want to. If you do, note that it will report some errors that you canignore, such as:FAIL: testMatrix.shFAIL: testInversion.shFAIL: testBug6181

Installing Geant4 Release 4.9.4.p02 on Linux http://geant4.slac.stanford.edu/tutorial/installatio...

5 of 20 07/17/2014 05:32 PM

Page 6: Install Geant4

Much more detailed instructions on installation of CLHEP are available from the CLHEP web site:http://proj-clhep.web.cern.ch/proj-clhep/INSTALLATION/newCLHEP-install.html

Getting Geant4

From the Geant4 home page:http://geant4.web.cern.ch/geant4/

Select "Download" from near the top right corner of the page.

Select "Unix tar format, compressed using gzip"which corresponds to:http://geant4.cern.ch/support/source/geant4.9.4.p02.tar.gzThe file is about 24 M.

Put it into your directory of choice, such as:~/geant4

Navigate to this directory and unpack the file:cd ~/geant4tar -zxvf geant4.9.4.p02.tar.gz

The unpacking process will begin, starting with:geant4.9.4.p02/geant4.9.4.p02/cmake/geant4.9.4.p02/cmake/Modules/geant4.9.4.p02/cmake/Modules/Geant4MacroUtilities.cmakegeant4.9.4.p02/cmake/Modules/ResolveCompilerPaths.cmake

And ending with:geant4.9.4.p02/examples/GNUmakefilegeant4.9.4.p02/examples/READMEgeant4.9.4.p02/Configuregeant4.9.4.p02/LICENSEgeant4.9.4.p02/CMakeLists.txt

Getting Data Files

Depending on the physics of your particular application, you may need to install additional data files.These data files can be downloaded separately from the Geant4 source distribution page (the sameplace where you got Geant4 itself).

Create a new folder within ~/geant4/geant4.9.4.p02 to hold any of these required data files.

Installing Geant4 Release 4.9.4.p02 on Linux http://geant4.slac.stanford.edu/tutorial/installatio...

6 of 20 07/17/2014 05:32 PM

Page 7: Install Geant4

~/geant4/geant4.9.4.p02/data

For now, pick up the "data files for low energy electromagnetic processes":http://geant4.cern.ch/support/source/G4EMLOW.6.19.tar.gz

The file is about 14 M.

Put the file into your new data directory.

Navigate to this directory and unpack the file:cd ~/geant4/geant4.9.4.p02/datatar -zxvf G4EMLOW.6.19.tar.gz

The unpacking process will begin, starting with:G4EMLOW6.19/G4EMLOW6.19/auger/G4EMLOW6.19/auger/au-tr-pr-10.datG4EMLOW6.19/auger/au-tr-pr-100.datG4EMLOW6.19/auger/au-tr-pr-11.dat

And ending with:G4EMLOW6.19/tripdata/pp-trip-cs-95.datG4EMLOW6.19/tripdata/pp-trip-cs-96.datG4EMLOW6.19/tripdata/pp-trip-cs-97.datG4EMLOW6.19/tripdata/pp-trip-cs-98.datG4EMLOW6.19/tripdata/pp-trip-cs-99.dat

Doing the Initial Build

TAKE YOUR TIME AT THIS STAGE, DON'T RUSH IT.Mistakes made at this stage can be very time-consuming to correct. Slow down.Maybe get a cup of coffee (or a glass of wine) before you proceed. Breathe.

Finally, unless you're absolutely sure you are starting from a nice clean system, make sure you don'thave any pre-existing Geant4 environment variables. You can use the "printenv" command to showall variables, and filter this with a "grep" for the string G4 as follows:From a Terminal or xterm window:printenv | grep G4If any variables show up, find out what is setting them and remove them. They might be coming fromyour .login or .cshrc file or from some other script that you invoke upon login for some other project.Take the time now to find the cause and resolve it.

From a Terminal or xterm window:cd ~/geant4/geant4.9.4.p02./Configure -build

Installing Geant4 Release 4.9.4.p02 on Linux http://geant4.slac.stanford.edu/tutorial/installatio...

7 of 20 07/17/2014 05:32 PM

Page 8: Install Geant4

You will be asked a series of questions.In most cases, you can just take the default response (by hitting carriage return).But pay close attention so that you do not accept the default for certain questions listed below.

Along the way you will see a message "Failed to locate one or more of the Geant4data libraries..." Don't worry about this. The additional data libraries are not required for thesimple physics in our initial examples. They can be loaded later as needed. For now, just accept thedefault response (by hitting carriage return).

When the configure script says:Could not find CLHEP installed on this system!Please, specify where CLHEP is installed:

First, confirm that you have installed your CLHEP to/u/ey/perl/CLHEPOr wherever you've decided to keep CLHEP.

Make sure you have lib, bin and include subdirectories in that directory.If not, recheck your CLHEP installation. If so, proceed.

Note that for this command you should use the absolute path for your CLHEP, such as:/u/ey/perl/CLHEPrather than a relative path, such as:~/CLHEPOf course, substitute your actual CLHEP path here.

Enter: /u/ey/perl/CLHEP

Take the default for everything else except:

When it asks:Enable building of the X11 OpenGL visualization driver? [n]Enter: yThis tells Geant4 that you want to include the optional OpenGL Visualization driver.

When it asks:Enable building of the X11 RayTracer visualization driver? [n]Enter: yThis tells Geant4 that you want to include the optional RayTracerX Visualization driver.

Take the default for everything else.

Once all of the questions have been answered, you will be told:WARNING: the generated configuration filecan be edited if necessary!You can introduce any change to the configuration file

Installing Geant4 Release 4.9.4.p02 on Linux http://geant4.slac.stanford.edu/tutorial/installatio...

8 of 20 07/17/2014 05:32 PM

Page 9: Install Geant4

/u/ey/perl/geant4/geant4.9.4.p02/.config/bin/Linux-g++/config.sh beforethe final installation.To do so, use a shell escape now (e.g. !vi /u/ey/perl/geant4/geant4.9.4.p02/.config/bin/Linux-g++/config.sh).

Press [Enter] to start installation or use a shell escape to editconfig.sh:

At this point, what you have seen in this question and answer session should match what you find inthis web directory as:Geant4Build.txt

You are ready to proceed with the build.Hit Enter.

You will then see:Now starting Geant4 libraries build...

On this machine the G4SYSTEM=Linux-g++On this machine the G4INSTALL=/u/ey/perl/geant4/geant4.9.4.p02On this machine the G4TMP=/u/ey/perl/geant4/geant4.9.4.p02/tmpOn this machine the G4LIB=/u/ey/perl/geant4/geant4.9.4.p02/libOn this machine the G4LEVELGAMMADATA=/u/ey/perl/geant4/geant4.9.4.p02/data/PhotonEvaporation2.1On this machine the G4RADIOACTIVEDATA=/u/ey/perl/geant4/geant4.9.4.p02/data/RadioactiveDecay3.3On this machine the G4LEDATA=/u/ey/perl/geant4/geant4.9.4.p02/data/G4EMLOW6.19On this machine the G4NEUTRONHPDATA=/u/ey/perl/geant4/geant4.9.4.p02/data/G4NDL3.14On this machine the G4ABLADATA=/u/ey/perl/geant4/geant4.9.4.p02/data/G4ABLA3.0On this machine the CLHEP_BASE_DIR=/u/ey/perl/CLHEPOn this machine the CLHEP_INCLUDE_DIR=/u/ey/perl/CLHEP/includeOn this machine the CLHEP_LIB_DIR=/u/ey/perl/CLHEP/libOn this machine the CLHEP_LIB=CLHEPOn this machine G4UI_NONE is not set - following UIs will be built:On this machine G4VIS_NONE is not set - following drivers will be built:On this machine the XMFLAGS=On this machine the XMLIBS=On this machine the XMFLAGS=On this machine the XAWFLAGS=On this machine the XAWLIBS=On this machine the G4LIB_BUILD_SHARED=1

Starting build...

Installing Geant4 Release 4.9.4.p02 on Linux http://geant4.slac.stanford.edu/tutorial/installatio...

9 of 20 07/17/2014 05:32 PM

Page 10: Install Geant4

Cleaning up /u/ey/perl/geant4/geant4.9.4.p02/.config/bin/Linux-g++/g4make.logBuilding global libraries...*************************************************************Installation Geant4 version - geant4-09-04-patch-02Copyright (C) 1994-2011 Geant4 Collaboration*************************************************************Making dependency for file src/G4ios.cc ...Making dependency for file src/G4coutDestination.cc ...Making dependency for file src/G4VStateDependent.cc ...Making dependency for file src/G4VNotifier.cc ...Making dependency for file src/G4VExceptionHandler.cc ...Making dependency for file src/G4UnitsTable.cc ...Making dependency for file src/G4Timer.cc ...Making dependency for file src/G4StateManager.cc ...Making dependency for file src/G4SliceTimer.cc ...Making dependency for file src/G4Pow.cc ...Making dependency for file src/G4PhysicsVector.cc ...Making dependency for file src/G4PhysicsTable.cc ...Making dependency for file src/G4PhysicsOrderedFreeVector.cc ...Making dependency for file src/G4PhysicsLogVector.cc ...Making dependency for file src/G4PhysicsLnVector.cc ...Making dependency for file src/G4PhysicsLinearVector.cc ...Making dependency for file src/G4PhysicsFreeVector.cc ...Making dependency for file src/G4OrderedTable.cc ...Making dependency for file src/G4LPhysicsFreeVector.cc ...Making dependency for file src/G4GeometryTolerance.cc ...Making dependency for file src/G4Exception.cc ...Making dependency for file src/G4ErrorPropagatorData.cc ...Making dependency for file src/G4DataVector.cc ...Making dependency for file src/G4AllocatorPool.cc ...Removing library libG4globman.a ...Removing library libG4globman.so ...Compiling G4AllocatorPool.cc ...Compiling G4DataVector.cc ...Compiling G4ErrorPropagatorData.cc ...Compiling G4Exception.cc ...

If you get a lot of warnings of the form/usr/include/c++/3.2.3/i386-redhat-linux/bits/codecvt_specializations.h:84: warning: unused parameter `int __ibom'just ignore them. These result from a bug in certain versions of gcc. The bug is harmless.

Once you see any lines like:Compiling G4AllocatorPool.cc ...with no errors,the compilation is successfully under way.

Installing Geant4 Release 4.9.4.p02 on Linux http://geant4.slac.stanford.edu/tutorial/installatio...

10 of 20 07/17/2014 05:32 PM

Page 11: Install Geant4

Adjust your machine's power management properties so that it doesn't go to sleep, and then walkaway for a long long time. Wait, and wait, and wait, for the initial compilation to run.

The same information that is showing on the console is also being written to a log file so that you canreview it later if necessary. The information will appear in:~/geant4/geant4.9.4.p02/.config/bin/Linux-g++/g4make.log

An example of how this log file should look can be found in this same web directory as:Geant4Make.txt

Eventually, you will see messages stating that libname.map has been built, then you will see messagesabout successful completion:Building library management utility liblist ...Libraries installation completed !

##################################################### Your Geant4 installation seems to be successful!# To be sure please have a look into the log file:# /u/ey/perl/geant4/geant4.9.4.p02/.config/bin/Linux-g++/g4make.log####################################################

While the Geant4 collaboration works hard to support a large variety of different Linux systems, theremay be special things you need to do to make it work for your particular Linux. If you have aproblem in the above build procedure, such as if your build fails to find some of the OpenGL libraries(error messages about this may include references to libXmu), look for hints in the Geant4Installation and Configuration User Forum:http://geant4-hn.slac.stanford.edu:5090/Geant4-HyperNews/index

Linux users are generally very helpful about documenting such issues for each other. Your questionhas very likely already been documented in that forum. If you don't find your answer there, post it asa question.

Single versus Multi-User Installation

The above instructions assumed you were doing a single-user installation. They had you keep all ofthe build products in the same area as your CLHEP and Geant4 source. Note however that both ofthese packages support standard multi-user installation processes.

For CLHEP, just specify a different value for "--prefix".

When Geant4's ./Configure -build asks you to "Specify the path where Geant4 libraries andsource files should be installed", specify the area you want the code to eventually be installed.

Installing Geant4 Release 4.9.4.p02 on Linux http://geant4.slac.stanford.edu/tutorial/installatio...

11 of 20 07/17/2014 05:32 PM

Page 12: Install Geant4

When Geant4's ./Configure -build asks you about the CLHEP library, be sure to specify thesame location that you specified during the CLHEP installation.

After you finish the ./Configure -build, issue an additional command to copy the libraries andheader files to the installation area:./Configure -install.

Creating the setup script

The configure process has set up some environment variables that you will want to have in futuresessions. Have configure make you an environment setup script by typing:./Configure(that was with no options, as opposed to ./Configure –build that you typed earlier).

You will see the following:--- Geant4 Toolkit Installation ---(setting environments for USER )

---------------------------------------------------The Geant4 toolkit installation was found.The files env.[c]sh will be copied to your current directory.For setting Geant4 environments you should make:

source env.csh

or

. env.sh

It will also check G4WORKDIR setting and set it toyour HOME if needed.You can use these files also for further modifications(adding your own environments).---------------------------------------------------

Your directory ~/geant4/geant4.9.4.p02 will now contain two scripts:env.shandenv.csh

The Geant4 Work Directory

You have now built the Geant4 toolkit. If you have learned a little about Geant4, you will know thatGeant4 is not an application but rather a toolkit from which you can build any number of

Installing Geant4 Release 4.9.4.p02 on Linux http://geant4.slac.stanford.edu/tutorial/installatio...

12 of 20 07/17/2014 05:32 PM

Page 13: Install Geant4

applications. So before you can test Geant4, you need an example application.

You should create a new directory, outside of your Geant4 installation area, where you will keep yourexample applications. This separation of spaces will help you avoid accidentally messing up yourmain Geant4 installation, and will insure that if you eventually update your main Geant4 installation(for example when a newer Geant4 release is available), your personal application work will not bedisturbed.

Create a new directory for your work, and designate it as your G4WORKDIR.

For example, if you want your work to be in ~/g4work and you are using C Shell or TC Shell:setenv G4WORKDIR ~/g4work

If you are using Bourne Shell or Korn Shell:export G4WORKDIR=~/g4work

Selecting an Example Application

You can try any of the Geant4 examples. Some suggested starting points are any of the Noviceexamples~/geant4/geant4.9.4.p02/examples/noviceor the analysis example~/geant4/geant4.9.4.p02/examples/extended/analysis/A01

Each example is described in a detailed README in the example's top level directory.

Whichever example you choose, copy it to your Geant4 work directory.For example:cp -r ~/geant4/geant4.9.4.p02/examples/extended/analysis/A01$G4WORKDIR/A01

Configuring the Environment

Note that this step needs to be redone any time you start a fresh Terminal or xterm window.

If you are using C Shell or TC Shell:setenv G4WORKDIR ~/g4worksetenv LD_LIBRARY_PATH ~/CLHEP/lib/:$LD_LIBRARY_PATHsource ~/geant4/geant4.9.4.p02/env.csh

If you are using Bourne Shell or Korn Shell:export G4WORKDIR=~/g4workexport LD_LIBRARY_PATH=~/CLHEP/lib/:$LD_LIBRARY_PATHsource ~/geant4/geant4.9.4.p02/env.sh

Installing Geant4 Release 4.9.4.p02 on Linux http://geant4.slac.stanford.edu/tutorial/installatio...

13 of 20 07/17/2014 05:32 PM

Page 14: Install Geant4

It will respond:On this machine the G4SYSTEM=Linux-g++On this machine the G4INSTALL=/u/ey/perl/geant4/geant4.9.4.p02On this machine the G4LIB=/u/ey/perl/geant4/geant4.9.4.p02/libOn this machine the G4LEVELGAMMADATA=/u/ey/perl/geant4/geant4.9.4.p02/data/PhotonEvaporation2.1On this machine the G4RADIOACTIVEDATA=/u/ey/perl/geant4/geant4.9.4.p02/data/RadioactiveDecay3.3On this machine the G4LEDATA=/u/ey/perl/geant4/geant4.9.4.p02/data/G4EMLOW6.19On this machine the G4NEUTRONHPDATA=/u/ey/perl/geant4/geant4.9.4.p02/data/G4NDL3.14On this machine the G4ABLADATA=/u/ey/perl/geant4/geant4.9.4.p02/data/G4ABLA3.0On this machine the G4REALSURFACEDATA=/u/ey/perl/geant4/geant4.9.4.p02/data/RealSurface1.0On this machine the G4NEUTRONXSDATA=/u/ey/perl/geant4/geant4.9.4.p02/data/G4NEUTRONXS1.0On this machine the G4PIIDATA=/u/ey/perl/geant4/geant4.9.4.p02/data/G4PII1.2On this machine the CLHEP_BASE_DIR=/u/ey/perl/CLHEPOn this machine the CLHEP_INCLUDE_DIR=/u/ey/perl/CLHEP/includeOn this machine the CLHEP_LIB_DIR=/u/ey/perl/CLHEP/libOn this machine the CLHEP_LIB=CLHEPOn this machine the G4UI_USE_TCSH=1On this machine the G4VIS_BUILD_OPENGLX_DRIVER=1On this machine the G4VIS_BUILD_RAYTRACERX_DRIVER=1On this machine the G4VIS_USE_OPENGLX=1On this machine the G4VIS_USE_RAYTRACERX=1On this machine the XMFLAGS=On this machine the XMLIBS=On this machine the XMFLAGS=On this machine the XMLIBS=On this machine the XAWFLAGS=On this machine the XAWLIBS=On this machine the G4LIB_BUILD_SHARED=1In your environment you have the G4WORKDIR=/u/ey/perl/g4work

LD_LIBRARY_PATH is set to include CLHEP and Geant4 libraries.NOTE : you should verify that the correct path for the CLHEP library

/u/ey/perl/CLHEP/lib

is included in the dynamic library search path ahead of any otherinstallations of CLHEP on your system that may be referenced by thispath.

Installing Geant4 Release 4.9.4.p02 on Linux http://geant4.slac.stanford.edu/tutorial/installatio...

14 of 20 07/17/2014 05:32 PM

Page 15: Install Geant4

A further note about the environment setup scripts:The env scripts do not set every environment variable that could be used by Geant4. They only setthose variables that you had declared to non-default values in the configure process. This works finebecause any variable that Geant4 does not find is assumed to be default. But if you are also settingsome of your Geant4 environment variables elsewhere, such as in your .login or .cshrc file, you canend up with inconsistent results. That is why you were strongly advised to make sure you had nopre-existing Geant4 variables set before you began the Geant4 build.

Building an Example Application

Did you "Configure the Environment" as described above? Remember that you need to do this everytime you start a new terminal session.

Build your example by typing, the following. Be sure to use make rather than gmake.cd $G4WORKDIR/A01make

You will see output beginning with:Making dependency for file A01app.cc ...Making dependency for file src/A01PrimaryGeneratorMessenger.cc ...Making dependency for file src/A01PrimaryGeneratorAction.cc ...Making dependency for file src/A01PhysicsList.cc ...Making dependency for file src/A01MuonPhysics.cc ...

And ending with:Creating shared library /u/ey/perl/g4work/tmp/Linux-g++/A01app/libA01app.so ...Compiling A01app.cc ...Using global libraries ...Linking A01app... Done!

The complete output from the above command can be found in this same web directory as:A01Make.txt

If the build is successful, you will see the completed application file in your $G4WORKDIR directorysuch as:$G4WORKDIR/bin/Linux-g++/A01app

Running

As always for a new xterm or Terminal window, configure the environment:

Installing Geant4 Release 4.9.4.p02 on Linux http://geant4.slac.stanford.edu/tutorial/installatio...

15 of 20 07/17/2014 05:32 PM

Page 16: Install Geant4

If you are using C Shell or TC Shell:setenv G4WORKDIR ~/g4worksetenv LD_LIBRARY_PATH ~/CLHEP/lib/:$LD_LIBRARY_PATHsource ~/geant4/geant4.9.4.p02/env.csh

If you are using Bourne Shell or Korn Shell:export G4WORKDIR=~/g4workexport LD_LIBRARY_PATH=~/CLHEP/lib/:$LD_LIBRARY_PATHsource ~/geant4/geant4.9.4.p02/env.sh

This might be good time to check that your XWindows setup is correct for our purposes.If you are running Geant4 on a remote machine (using the machine in front of you just as a terminal),make sure you have your XWindows client running.Make sure your terminal is correctly set to accept connections from the machine where you arerunning Geant4.You might need to explicitly set display from the machine on which you are running Geant4 tomake it display to you terminal, or use the -X option of ssh.It is beyond the scope if this tutorial to advise on all XWindows problems, but it is always helpful totry a test with a simple application such as xclock.

Then, to run your example, cd to the example's top level directory, such as:cd $G4WORKDIR/A01

And from there, run the newly created executable:$G4WORKDIR/bin/Linux-g++/A01app

You will see a response that starts with:************************************************************Geant4 version Name: geant4-09-04-patch-02 (24-June-2011)

Copyright : Geant4 CollaborationReference : NIM A 506 (2003), 250-303

WWW : http://cern.ch/geant4*************************************************************

Visualization Manager instantiating with verbosity "warnings (3)"...Visualization Manager initialising...Registering graphics systems...

You have successfully registered the following graphics systems.Current available graphics systems are:ASCIITree (ATree)DAWNFILE (DAWNFILE)G4HepRep (HepRepXML)G4HepRepFile (HepRepFile)RayTracer (RayTracer)VRML1FILE (VRML1FILE)VRML2FILE (VRML2FILE)

Installing Geant4 Release 4.9.4.p02 on Linux http://geant4.slac.stanford.edu/tutorial/installatio...

16 of 20 07/17/2014 05:32 PM

Page 17: Install Geant4

gMocrenFile (gMocrenFile)OpenGLStoredX (OGL)OpenGLImmediateX (OGLI)OpenGLStoredX (OGLS)OpenGLImmediateX (OGLIX)OpenGLStoredX (OGLSX)RayTracerX (RayTracerX)

And ends with:EMcalorimeterPhysical[0] EMcalorimeterLogical 1 CsI

cellPhysical[-1] cellLogical 0 CsI /EMcalorimeterHadCalorimeterPhysical[0] HadCalorimeterLogical 1 LeadHadCalColumnPhysical[-1] HadCalColumnLogical 1 LeadHadCalCellPhysical[-1] HadCalCellLogical 1 LeadHadCalLayerPhysical[-1] HadCalLayerLogical 1 LeadHadCalScintiPhysical[0] HadCalScintiLogical 0 Scintillator

/HadCalorimeterIdle>

The complete output from the above command can be found in this same web directory as:A01Run.txt

If it fails to run, claiming it can't find CLHEP.so, you probably missed thesetenv LD_LIBRARY_PATH ~/CLHEP/lib/:$LD_LIBRARY_PATHFix that and try to run again.

Make sure your output included a mention of the graphics system:OpenGLStoredX (OGL)

If this didn't show up, you have missed something in the above instructions.Did you correctly answered the questions about OpenGL in the ./Configure -build procedure?Did you get error messages during that procedure?Did you follow the instructions in the above section, "Creating the setup script"?Did you follow the instructions above about "As always for a new xterm or Terminal window,configure the environment…."?

If you still can't figure out why you don't have OpenGL, you can still proceed, but you will have touse some other graphics driver. See some notes a little later in this document about how to use theHepRepFile driver.

From here, we'll assume you have OpenGL successfully loaded.

From the idle prompt, visualize the example by typing the following:/vis/open OGL/vis/drawVolume

An OpenGL window will appear and the example geometry will be drawn, as in:

Installing Geant4 Release 4.9.4.p02 on Linux http://geant4.slac.stanford.edu/tutorial/installatio...

17 of 20 07/17/2014 05:32 PM

Page 18: Install Geant4

If you have something odd about your OpenGL installation, it may be that you will get better resultswith a slightly different version of the OpenGL driver:/vis/open OGLI/vis/drawVolumeThe difference is in whether or not OpenGL will use something called a "display list." Most userswill not need to try this, but there are so many different versions of Linux and OpenGL drivers in usethat we mention this option for those who might need to try it.

To add trajectories and hits to the visualization, and then run an event:/vis/scene/add/trajectories/vis/scene/add/hits/run/beamOn 1

You will then see something like:

Installing Geant4 Release 4.9.4.p02 on Linux http://geant4.slac.stanford.edu/tutorial/installatio...

18 of 20 07/17/2014 05:32 PM

Page 19: Install Geant4

If you see only the trajectories, but not the geometry, this almost certainly means you have amismatch between your graphics driver and your graphics hardware. What is happening is that yourdriver sends the hardware the correct commands to draw polylines (the trajectories happen to be madefrom polylines), but not the correct commands to draw polygons (the geometry happens to be madefrom polygons). Quite a few Linux users have had this problem. The solution is to find an expert onyour Linux system or read around on the web and find out what graphics driver is actually correct foryour graphics hardware.

When you are finished with your Geant4 session, just type:exit

For more details on using OpenGL for Geant4, see:http://geant4.slac.stanford.edu/Presentations/vis/G4OpenGLTutorial/G4OpenGLTutorial.html

Here's another example. This one makes output go to a HepRep file, suitable for viewing in theHepRApp HepRep Browser:$G4WORKDIR/bin/Linux-g++/A01app/vis/open HepRepFile/vis/drawVolume/vis/viewer/flush/vis/scene/add/trajectories/vis/scene/add/hits/run/beamOn 1

For more details on using HepRApp for Geant4, see:http://geant4.slac.stanford.edu/Presentations/vis/G4HepRAppTutorial/G4HepRAppTutorial.html

Note: HepRApp and Geant4 do not have to run on the same machine. You can copy the .heprep filefrom the Geant4 machine to the machine with HepRApp, or you can simply make the .heprep filevisible from the web, and let HepRApp pick it up via the url.Also note that the .heprep file can be zipped to about 5 percent of original size and HepRApp can thenread in the zipped version (you don't need to unzip the file).

You now have Geant4 installed and have demonstrated a few examples using two differentvisualization systems.

How to go back and change choices from./Configure -build

You can go back and re-run Geant4's ./Configure -build procedure at any time to changevarious options. In general, this will not force a complete recompilation but will only rebuild thoselibraries that have changes.

Make sure to run ./Configure -build in a fresh session, one that doesn't have theG4WORKDIR environment variable set. Otherwise this difference between your original buildenvironment and your new one will trigger a whole new Geant4 build in a whole new place.

Installing Geant4 Release 4.9.4.p02 on Linux http://geant4.slac.stanford.edu/tutorial/installatio...

19 of 20 07/17/2014 05:32 PM

Page 20: Install Geant4

After the build, do ./Configure (the version with no arguments that creates the env.sh andenv.csh files) and, if you are doing a multi-user installation, ./Configure -install

Also note that even though you successfully rebuild Geant4, your user application will not takeadvantage of the change unless you explicitly tell it to do so. The standard way to do this is to updatethe time stamp of your application's main class before you rebuild the application. For example, usethe "touch" command:setenv G4WORKDIR ~/g4worksetenv LD_LIBRARY_PATH ~/CLHEP/lib/:$LD_LIBRARY_PATHsource ~/geant4/geant4.9.4.p02/env.cshcd $G4WORKDIR/A01touch A01app.ccgmake

I hope these instructions have been helpful.If you find any problems or can suggest corrections, please let me know.

Joseph PerlSLAC Geant4 Team26 October 2011

Installing Geant4 Release 4.9.4.p02 on Linux http://geant4.slac.stanford.edu/tutorial/installatio...

20 of 20 07/17/2014 05:32 PM