Geant4_9_4_p02_Mac_Installation - SLAC Geant4 Team

plainspecialΛογισμικό & κατασκευή λογ/κού

14 Δεκ 2013 (πριν από 3 χρόνια και 8 μήνες)

373 εμφανίσεις

Installing Geant4 Release 4.8.2 on Macintosh OSX

Installing Geant4 Release 4.9.4.
p02

on Mac


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 a
t:

http://geant4.slac.stanford.edu/installation


Contents:


What are the three 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 Applicat
ion


Configuring the Environment


Building an Example Application


Running


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


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


XCode:

XCode is a set of developer tools that includes the gcc compiler that is recommended for Geant4
on Macintosh OSX.

For OSX 10.4, any version of XCode
in the 2.x series from 2.2 onwards will work.

For OSX 10.5, any version of XCode from 2.5 through 3.1.x will work.

For OSX 10.6, any version of XCode from 3.2 onwards will work.

Installing Geant4 Release 4.8.2 on Macintosh OSX

Other versions of XCode will give you problems. To check your version, go to
the Apple menu,
"About this Mac", "More Info…", "Software Applications" and then find XCode.


If you need to pick up a new version of XCode, you can get it from:

http://developer.apple.com/mac/

Look for "Dow
nload Xcode" on that page.

Note that the download is very large, over 900MB, so get yourself on a fast network.

You must register with Apple Developer Connection, but there is no charge.

The site makes it easy to find the latest version of XCode, appropria
te for OSX 10.6, but harder
to find older versions, appropriate for OSX 10.5 and OSX 10.4. To find those versions, go to:

http://connect.apple.com

Log in.

Click "Developer Tools" in the right hand column.

You can th
en search for the appropriate XCode version in the resulting page.


X11:

X11 is the XWindows system for Macintosh OSX. It comes with your OS X Mac on the
installation DVD, but is not generally pre
-
installed.

Insert the Mac OS X installation DVD into your
Mac.

Double
-
click on the Optional Installs package, open Applications and select X11.

Or use Spotlight to search for a file named X11User.pkg. It is typically in /Volumes/Mac OS X
Install DVD/System/Installation/Packages. Click on this package to start th
e installation process.

You should end up with X11.app in Applications/Utilities.

If you don't have X11, you can still use Geant4 on your Mac, but you will not be able to output
graphics to OpenGL. You should answer "no" when the Geant4 configuration scri
pt asks about
OpenGL and RayTracerX, and then just use one of the other Geant4 graphics drivers such as
HepRepFile (see some notes on HepRepFile later in this guide).

Later, when you have X11 installed, you can rerun the Geant4 configuration script, answer

"yes"
for OpenGL and RayTracerX, and Geant4 will recompile only those parts of the code that care
about the difference.



CLHEP:

CLHEP is a set of base libraries that have long provided great functionality for the particle
physics community. They provide

things like matrix manipulations, four
-
vector tools and lists of
particle properties. The Geant4 collaboration has chosen to use these libraries rather than re
-
invent these wheels. Please note that while CLHEP and Geant4 both come out of the particle
ph
ysics communities, they are separate products
-

the Geant4 collaboration is not responsible for
maintenance, distribution or documentation of CLHEP.

Be careful to use only the recommended version of CLHEP. If you use any other version, your
code may 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

Installing Geant4 Release 4.8.2 on Macintosh OSX


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/t
arFiles/clhep
-
2.1.0.1.tgz


The file is about 4 MB.


The file will automatically unzip and will be placed in your download area as:

clhep
-
2.1.0.1.tar


Click on the file.

It will automatically un
-
tar and leave you with a folder called:

2.1.0.1


Create a fol
der in your Applications folder called
CLHEP

Put the downloaded folder there, so that you now have:

/Applications/CLHEP/2.1.0.1


For the following step, note that there are two dashes in a row before the word "prefix".

And be sure to point to your top leve
l CLHEP directory, NOT:

/Applications/CLHEP/2.1.0.1/CLHEP


In a terminal window, navigate into the unpacked directory and begin the configuration process.

cd /Applications/CLHEP/2.1.0.1/CLHEP

./configure
--
prefix
/Applications/CLHEP


You should get a respo
nse that starts with:

checking build system type... i686
-
apple
-
darwin10.5.0

checking host system type... i686
-
apple
-
darwin10.5.0

checking target system type... i686
-
apple
-
darwin10.5.0

checking for a BSD
-
compatible install... /usr/bin/install
-
c

checking wh
ether build environment is sane... yes


And ends with:

config.status: creating test/exctest4.sh

config.status: creating test/exctestNothrow.sh

config.status: creating test/excDblThrow.sh

config.status: creating Exceptions/defs.h

config.status: executing de
pfiles 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.

Users coming from a Linux
background
may instead be used to typing
gmake
. It can be very hard to remember which of
these to type. Most Mac users will not have any command called
gmake
, but if you do find such
a command, there's no telling where it came from and it will not necessarily do th
e correct thing
for CLHEP or Geant4.

Installing Geant4 Release 4.8.2 on Macintosh OSX


Run the build process:

make


You should get a response that starts with:

Making all in Units

Making all in Units

make all
-
am

make[3]: Nothing to be done for `all
-
am'.

Making all in .

/Applications/CLHEP/2.1.0.1/CLHEP/
Units/autotools/install
-
sh
-
d
/Applications/CLHEP/2.1.0.1/CLHEP/Units/CLHEP;


And ends with:

liblist=`./getObjectList
-
shared Units Utility Vector Evaluator
GenericFunctions Geometry Random Matrix RandomObjects Cast RefCount
Exceptions`;
\


g++
-
O
-
ansi
-
p
edantic
-
Wall
-
D_GNU_SOURCE
-
g
-
O2
-
o libCLHEP
-
2.1.0.1.dylib
-
dynamiclib
-
single_module
-
undefined dynamic_lookup
-
Wl,
-
install_name,libCLHEP
-
2.1.0.1.dylib $liblist
-
o libCLHEP
-
2.1.0.1.dylib

./build
-
header


The complete output from the above command can b
e 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 th
at starts with:

Making install in Units

Making install in Units

make[3]: Nothing to be done for `install
-
exec
-
am'.

test
-
z "/Applications/CLHEP/include/CLHEP/Units" ||
/Applications/CLHEP/2.1.0.1/CLHEP/Units/autotools/install
-
sh
-
d
"/Applications/CLHEP/inc
lude/CLHEP/Units"


And ends with:

if test
-
f ClhepVersion.h; then
\



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



/usr/bin/install
-
c
-
m 644 "ClhepVersion.h"
"/Applications/CLHEP/include/CLH
EP/ClhepVersion.h";
\


else :; fi


/usr/bin/install
-
c
-
m 644 'ClhepVersion.h'
'/Applications/CLHEP/include/CLHEP/ClhepVersion.h'

make[2]: Nothing to be done for `install
-
data
-
am'.


The complete output from the above command can be found in this same web d
irectory as:

Installing Geant4 Release 4.8.2 on Macintosh OSX

CLHEPInstall.txt


You will now have directories such as:

/Applications/CLHEP/include

and

/Applications/CLHEP/lib


The exact contents of the lib directory should be as follows:

libCLHEP
-
2.1.0.1.a

libCLHEP
-
2.1.0
.1.dylib

libCLHEP
-
Cast
-
2.1.0.1.a

libCLHEP
-
Cast
-
2.1.0.1.dylib

libCLHEP
-
Evaluator
-
2.1.0.1.a

libCLHEP
-
Evaluator
-
2.1.0.1.dylib

libCLHEP
-
Exceptions
-
2.1.0.1.a

libCLHEP
-
Exceptions
-
2.1.0.1.dylib

libCLHEP
-
GenericFunctions
-
2.1.0.1.a

libCLHEP
-
GenericFunctions
-
2.1.0.1
.dylib

libCLHEP
-
Geometry
-
2.1.0.1.a

libCLHEP
-
Geometry
-
2.1.0.1.dylib

libCLHEP
-
Matrix
-
2.1.0.1.a

libCLHEP
-
Matrix
-
2.1.0.1.dylib

libCLHEP
-
Random
-
2.1.0.1.a

libCLHEP
-
Random
-
2.1.0.1.dylib

libCLHEP
-
RandomObjects
-
2.1.0.1.a

libCLHEP
-
RandomObjects
-
2.1.0.1.dylib

libCLHE
P
-
RefCount
-
2.1.0.1.a

libCLHEP
-
RefCount
-
2.1.0.1.dylib

libCLHEP
-
Vector
-
2.1.0.1.a

libCLHEP
-
Vector
-
2.1.0.1.dylib

libCLHEP.a

libCLHEP.dylib


You're done setting up CLHEP.


If the CLHEP build fails in some strange way, you may be able to instead use pre
-
built ve
rsions
of CLHEP. We do not recommended them in general because they do not work for all versions
of Mac OSX or 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 with

tar

zxvf


Move all of its contents (bin, build
, include, lib) into /Applications/CLHEP

If your Geant4 build and run goes OK, then this was an appropriate CLHEP build. If not, then
this pre
-
built version of CLHEP was not appropriate for your version of Mac OSX or C++.


Installing Geant4 Release 4.8.2 on Macintosh OSX

We do not recommend you run the
"
make check"

command described in the CLHEP
documentation unless you really want to. If you do, note that it will report some errors that you
can ignore, such as:

FAIL: testMatrix.sh

FAIL: testInversion.sh

FAIL: testBug6181


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.gz


The file is about 24 M.


The file will automatically unzip and will be placed in your download area as:

geant4.9.4.
p02
.tar


Click on the
file.

It will automatically un
-
tar and leave you with a folder called:

geant4.9.4.
p02


Put this into your Applications folder.


Getting Data Files


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



Create a new folder within
/Applications/geant4.9.4.
p02

to hold any of these required
data files.

/Applications/geant4.9.4.
p
02
/data


For now, pick up the "
data files for low energy electromagnetic processes"
:

http://geant4.cern.ch/support/source/G4EMLOW.6.19.tar.gz

Installing Geant4 Release 4.8.2 on Macintosh OSX


The file is about 14 M.


The file will au
tomatically unzip and will be placed in your download area as:

G4EMLOW6.19.tar


Click on the file.

It will automatically un
-
tar and leave you with a folder called:

G4EMLOW6.19


Put this into your
Applications/geant4.9.4.
p02
/data

folder.


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't have any pre
-
existing Geant4 environment variables. You can use the "printenv" command
to show all variables, and filter this with a "grep" for the string G4 as follows:

From a Terminal or xterm windo
w:

printenv | grep G4

If any variables show up, find out what is setting them and remove them. They might be coming
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 Term
inal or xterm window:

cd /Applications/geant4.9.4.
p02
/

./Configure
-
build


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 de
fault for certain questions listed below.


Along the way you will see a message
"Failed to locate one or more of the
Geant4 data libraries..."

Don't worry about this. The additional data libraries are not
required for the simple physics in our initial ex
amples. They can be loaded later as needed. For
now, just accept the default 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

/Applications/CLHEP

Installing Geant4 Release 4.8.2 on Macintosh OSX


Make sure you have lib, bin and include subdirectories in that directory.

If not, recheck your CLHEP installation. If so, proceed.


Enter:
/Applications/CLHEP

Or wherever you've decided to keep CL
HEP.


Take the default for everything else except:


When it asks:

Enable building of the X11 OpenGL visualization driver? [n]

Enter:
y

This tells Geant4 that you want to include the optional OpenGL Visualization driver.


When it asks:

Enable building of th
e X11 RayTracer visualization driver? [n]

Enter:
y

This 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 file

can be edited if necessary!

You can introduce any change to the configuration file

/Applications/geant4.9.4.
p02
/.config/bin/Darwin
-
g++/config.sh before
the final installation.

To do so, use a shell escape now (e.g. !vi
/Appli
cations/geant4.9.4.
p02
/.config/bin/Darwin
-
g++/config.sh).


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


At this point, what you have seen in this question and answer session should match what you
find in this 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=Darwin
-
g++

On this machine the G4INSTALL=/Applications/gean
t4.9.4.
p02

On this machine the G4TMP=/Applications/geant4.9.4.
p02
/tmp

On this machine the G4LIB=/Applications/geant4.9.4.
p02
/lib

Installing Geant4 Release 4.8.2 on Macintosh OSX

On this machine the
G4LEVELGAMMADATA=/Applications/geant4.9.4.
p02
/data/PhotonEvaporation2.
1

On this machine the
G4RADIOACTIVEDA
TA=/Applications/geant4.9.4.
p02
/data/RadioactiveDecay3.
3

On this machine the
G4LEDATA=/Applications/geant4.9.4.
p02
/data/G4EMLOW6.19

On this machine the
G4NEUTRONHPDATA=/Applications/geant4.9.4.
p02
/data/G4NDL3.14

On this machine the
G4ABLADATA=/Applications
/geant4.9.4.
p02
/data/G4ABLA3.0

On this machine the CLHEP_BASE_DIR=/Applications/CLHEP

On this machine the CLHEP_INCLUDE_DIR=/Applications/CLHEP/include

On this machine the CLHEP_LIB_DIR=/Applications/CLHEP/lib

On this machine the CLHEP_LIB=CLHEP

On this ma
chine 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 G4VIS_BUILD_OPENGLX_DRIVER=1

On this machine the G4VIS_BUILD_RAYTRACERX_DRIVER=1

On this machine the G4VI
S_USE_OPENGLX=1

On this machine the G4VIS_USE_RAYTRACERX=1

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 b
uild...


Cleaning up /Applications/geant4.9.4.
p02
/.config/bin/Darwin
-
g++/g4make.log

Building global libraries...

*************************************************************


Installation Geant4 v
ersion
-

geant4
-
09
-
04
-
patch
-
02



Copyright (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/G4PhysicsOrdered
FreeVector.cc ...

Installing Geant4 Release 4.8.2 on Macintosh OSX

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/G4ErrorPropa
gatorData.cc ...

Making dependency for file src/G4DataVector.cc ...

Making dependency for file src/G4AllocatorPool.cc ...

Removing library libG4globman.a ...

Removing library libG4globman.dylib ...

Compiling G4AllocatorPool.cc ...

Compiling G4DataVector.cc

...

Compiling G4ErrorPropagatorData.cc ...

Compiling G4Exception.cc ...


Once you see any lines like:

Compiling G4AllocatorPool.cc ...

with no errors,

the compilation is successfully under way.


Adjust your machine's power management properties so that it

doesn't go to sleep, and then walk
away 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
can review it later if necess
ary. The information will appear in:

/Applications/geant4.9.4.
p02
/.config/bin/Darwin
-
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 wi
ll see a message stating that libraries have been installed, then you will see
messages about 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:

# /Applications/geant4.9.4.
p02
/.config/bin/Darwin
-
g++/g4make.log

####################################################

Single versus Multi
-
User Installat
ion


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

processes.

Installing Geant4 Release 4.8.2 on Macintosh OSX


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


When Geant4's
./Configure
-
build

asks you to "Specify the path where Geant4 libraries
and source files should be installed", specify the area you want the code to eventually be
instal
led.


When Geant4's
./Configure
-
build

asks you about the CLHEP library, be sure to specify
the same location that you specified during the CLHEP installation.


After you finish the
./Configure
-
build
, issue an additional command to copy the libraries
and
header 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 future
sessions. Have configure make you an environment setup script by typi
ng:

./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 an
d set it to

your HOME if needed.

You can use these files also for further modifications

(adding your own environments).

---------------------------------------------------


Your directory /Applications/geant4.9.4.
p02

will now contain two scripts:

env.sh

an
d

env.csh


Installing Geant4 Release 4.8.2 on Macintosh OSX

The Geant4 Work Directory


You have now built the Geant4 toolkit. If you have learned a little about Geant4, you will know
that Geant4 is not an application but rather a toolkit from which you can build any number of
applications. So before yo
u can test Geant4, you need an example application.


You should create a new directory, outside of your Geant4 installation area, where you will keep
your example applications. This separation of spaces will help you avoid accidentally messing
up your mai
n 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 be disturbed.


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


For example, if you want your work to be in
/Applications/g4work
:

export G4WORKDIR=/Applications/g4work


Selecting

an Example Application


You can try any of the Geant4 examples. Some suggested starting points are any of the N
ovice
examples

/Applications/geant4.9.4.
p02
/examples/novice

or the analysis example

/Applications/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 cho
ose, copy it to your Geant4 work directory.

For example, you might end up with:

/Applications/g4work/A01


Configuring the Environment


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


Type:

export G4WORKDIR=
/Appl
ications/g4work

export DYLD_LIBRARY_PATH=/Applications/CLHEP/lib

source
/Applications/geant4.9.4.
p02
/
env.sh


It will respond:

On this machine the G4SYSTEM=Darwin
-
g++

On this machine the G4INSTALL=/Applications/geant4.9.4.
p02

On this machine the G4LIB=/Appl
ications/geant4.9.4.
p02
/lib

Installing Geant4 Release 4.8.2 on Macintosh OSX

On this machine the
G4LEVELGAMMADATA=/Applications/geant4.9.4.
p02
/data/PhotonEvaporation2.
1

On this machine the
G4RADIOACTIVEDATA=/Applications/geant4.9.4.
p02
/data/RadioactiveDecay3.
3

On this machine the
G4LEDATA=/Applications/g
eant4.9.4.
p02
/data/G4EMLOW6.19

On this machine the
G4NEUTRONHPDATA=/Applications/geant4.9.4.
p02
/data/G4NDL3.14

On this machine the
G4ABLADATA=/Applications/geant4.9.4.
p02
/data/G4ABLA3.0

On this machine the
G4REALSURFACEDATA=/Applications/geant4.9.4.
p02
/dat
a/RealSurface1.0

On this machine the
G4NEUTRONXSDATA=/Applications/geant4.9.4.
p02
/data/G4NEUTRONXS1.0

On this machine the
G4PIIDATA=/Applications/geant4.9.4.
p02
/data/G4PII1.2

On this machine the CLHEP_BASE_DIR=/Applications/CLHEP

On this machine the CLHEP_
INCLUDE_DIR=/Applications/CLHEP/include

On this machine the CLHEP_LIB_DIR=/Applications/CLHEP/lib

On this machine the CLHEP_LIB=CLHEP

On this machine the G4UI_USE_TCSH=1

On this machine the G4VIS_BUILD_OPENGLX_DRIVER=1

On this machine the G4VIS_BUILD_RAYTR
ACERX_DRIVER=1

On this machine the G4VIS_USE_OPENGLX=1

On this machine the G4VIS_USE_RAYTRACERX=1

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 machi
ne the G4LIB_BUILD_SHARED=1


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
set those variables that you had declared to
non
-
default

values in the configure

process. This
works fine because any variable that Geant4 does not find is assumed to be default. But if you
are also setting some of your Geant4 environment variables elsewhere, you can end up with
inconsistent results. That is why you were strongly a
dvised to make sure you had no pre
-
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
every time you start a new Term
inal or xterm window.


Build your example by typing, the following. Be sure to use
make

rather than
gmake
.

cd $G4WORKDIR/A01

Installing Geant4 Release 4.8.2 on Macintosh OSX

make


You will see output beginning with:

Making dependency for file A01app.cc ...

Making dependency for file src/A01PrimaryGenera
torMessenger.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 /Applications/g4work/tmp
/Darwin
-
g++/A01app/libA01app.dylib ...

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 buil
d is successful, you will see the completed application file in your
$G4WORKDIR

directory such as:

$G4WORKDIR/bin/Darwin
-
g++/A01app


Running


Since the example will be using OpenGL for visualization, OS 10.4 users will need to run it from
an xterm window r
ather than a Terminal window (open the X11 application and then from its
"Applications" menu, select "xterm"). On OS 10.5, both kinds of windows, Terminal or xterm
can launch the appropriate graphics.


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

export G4WORKDIR=
/Applications/g4work

export DYLD_LIBRARY_PATH=/Applications/CLHEP/lib

source
/Applications/geant4.9.4.
p02
/
env.sh


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
/Darwin
-
g++/A01app


You will see a response that starts with:

*************************************************************


Geant4 ver
sion Name: geant4
-
09
-
04
-
patch
-
02 (24
-
June
-
2011)



Copyright : Geant4 Collaboration


Reference : NIM A 506 (2003), 250
-
303


WWW : http://cern.ch/geant4

Installing Geant4 Release 4.8.2 on Macintosh OSX

*************************************************************


Visualization Manager instantiating w
ith 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)


G4He
pRep (HepRepXML)


G4HepRepFile (HepRepFile)


RayTracer (RayTracer)


VRML1FILE (VRML1FILE)


VRML2FILE (VRML2FILE)


gMocrenFile (gMocrenFile)


OpenGLStoredX (OGL)


OpenGLImmediateX (OGLI)


OpenGLStoredX (OGLS)


OpenGLImmediateX (OGLIX)


OpenGLStore
dX (OGLSX)


RayTracerX (RayTracerX)


And ends with:


EMcalorimeterPhysical[0] EMcalorimeterLogical 1 CsI


cellPhysical[
-
1] cellLogical 0 CsI /EMcalorimeter


HadCalorimeterPhysical[0] HadCalorimeterLogical 1 Lead


HadCalColumnPhysical[
-
1] H
adCalColumnLogical 1 Lead


HadCalCellPhysical[
-
1] HadCalCellLogical 1 Lead


HadCalLayerPhysical[
-
1] HadCalLayerLogical 1 Lead


HadCalScintiPhysical[0] HadCalScintiLogical 0 Scintillator
/HadCalorimeter

Idle>


The complete output

from the above command can be found in this same web directory as:

A01Run.txt


Make sure your output included a mention of the graphics systems:


OpenGLStoredX (OGL)


If those didn't show up, you have missed something in the a
bove 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 follo
w the instructions above about "
As always for a new xterm or Terminal window,
configure the environment…."?


Installing Geant4 Release 4.8.2 on Macintosh OSX

If you still can't figure out why you don't have OpenGL, you can still proceed, but you will have
to use some other graphics driver. See some note
s a little later in this document about how to use
the HepRepFile 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


And an OpenGL windo
w will appear and the example geometry will be drawn, as in:



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.8.2 on Macintosh OSX



When you are finis
hed with your Geant4 session, just type:

exit


For more details on using OpenGL for Geant4, see:

http://geant4.slac.stanford.edu/Presentations/vis/G4Op
enGLTutorial/G4OpenGLTutorial.html


Here's another example. This one makes output go to a HepRep file, suitable for viewing in the
HepRApp HepRep Browser:

$G4WORKDIR/bin/Darwin
-
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/vi
s/G4HepRAppTutorial/G4HepRAppTutorial.html


Note: HepRApp and Geant4 do not have to run on the same machine. You can copy the .heprep
file from the Geant4 machine to the machine with HepRApp, or you can simply make the
.heprep file visible 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
then read in the zipped version (you don't need to unzip the file).


You now have Geant4 installed and have demonstrat
ed a few examples using two different
visualization systems.


Installing Geant4 Release 4.8.2 on Macintosh OSX

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 change
various options. In general, this will not force

a complete recompilation but will only rebuild
those libraries that have changes.


Make sure to run
./Configure
-
build

in a fresh session, one that doesn't have the
G4WORKDIR environment variable set. Otherwise this difference between your original buil
d
environment and your new one will trigger a whole new Geant4 build in a whole new place.


After the build, do
./Configure

(the version with no arguments that creates the env.sh and
env.csh files) and, if you are doing a multi
-
user installation,
./Config
ure
-
install


Also note that even though you successfully rebuild Geant4, your user application will not take
advantage of the change unless you explicitly tell it to do so. The standard way to do this is to
update the time stamp of your application's mai
n class before you rebuild the application. For
example, use the "touch" command:

export G4WORKDIR=/Applications/g4work

export DYLD_LIBRARY_PATH=/Applications/CLHEP/lib

source /Applications/geant4.9.4.
p02
/env.sh

cd
$G4WORKDIR/A01

touch A01app.cc

make



I
hope these instructions have been helpful.

If you find any problems or can suggest corrections, please
let me know
.


Joseph Perl

SLAC Geant4 Team

26 October

2011