Frequently Asked Questions
(See also
Useful Tips page
at SLAC)
- How do I add a FAQ to this page?
Solution:
This is done manually at the moment. Please send your FAQ with solution
to the editors.
- When I download the source from the web, and unpack
the tar file, some files unpack into the top level directory.
Solution:
The problem you describe usually is the result of using "UNIX" tar to
unpack the gtar ("GNU-tar") file, or vice versa, or using zip on either the
gtar or tar file. Please make certain that you download the correct file for
your system, and that you use the correct unpacking tool. Note that for Linux
you must download the gtar.gz file.
- I cannot find CLHEP files or library and I have
it installed in my system.
Solution:
If the standard CLHEP installation procedure has been adopted, the variable
CLHEP_BASE_DIR should point to the area where include/ and
lib/ directories for CLHEP headers & library are installed in your
system. In case the library file name is different than the one
expected (libCLHEP.a), you should either create a symbolic
link with the expected name, or define the variable CLHEP_LIB in
your environment which explicitly sets the name of the CLHEP library.
If a non-standard CLHEP installation has been adopted, define variables
CLHEP_INCLUDE_DIR, CLHEP_LIB_DIR (and CLHEP_LIB)
to refer explicitly to the place where headers, library (and library-name)
respectively are placed in your system.
On Windows systems, the full library file name (with extension) should be
specified as CLHEP_LIB, while for UNIX-like systems, just the name
is required (i.e. CLHEP for libCLHEP.a)
- While installing the Geant4 libraries I get
the following message printed:
gmake[1]: cernlib: Command not found
Has Geant4 been installed properly ? What to do to solve this error ?
Solution:
The message:
gmake[1]: cernlib: Command not found
shows that you don't have the 'cernlib' command installed in your system;
'cernlib' is a command from the CERN program library (cernlib) returning a
list of libraries needed to link a cernlib application. This command is only
used in the 'g3tog4' module, however, if you do not make use of the 'g3tog4'
tool, it's harmless. The cernlib script (and the needed cernlib libraries)
are available from: http://cern.ch/cernlib.
- Trying building the Geant4 libraries I see several
of these errors appearing and my installation fails:
.....G4Exception.d:1:
*** missing separator. Stop.
...../G4DalitzDecayChannel.d:1:
*** missing separator. Stop.
:
:
Has Geant4 been installed properly ? What to do to solve this error ?
Solution:
It looks like some file dependencies (.d) are corrupted, possibly
due to previous build attempts which failed for some reason.
You need to remove each of them. A quick recipe for doing this is to:
- On Linux, I get a segmentation fault
as soon as I run one of the official examples.
Solution:
Check that the CLHEP library has been installed and compiled coherently with
the same compiler you use for installing Geant4 and for the same version of Linux
distribution.
For example, a binary object produced with Red-Hat 7.X is not fully compatible with
binaries running on RH 9.X or higher, due to different libc used in the two
configurations.
- I installed Geant4 libraries and built my application,
when I try to run it I get:
error in loading shared libraries:
libCLHEP.so: cannot open shared object file:
No such file or directory.
Solution:
Your installation of CLHEP includes shared libraries. You need to specify
the path where libCLHEP.so is installed through your environment
variable LD_LIBRARY_PATH. For example, in tcsh UNIX shell:
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:$CLHEP_BASE_DIR/lib
- On my system I get a Floating Point Exception
(FPE) since some physics processes sometimes return DBL_MAX as interaction
length and this number is afterwards multiplied by a number greater than 1.
Solution:
Geant4 coding conventions and installation setup explicitly follow the ANSI/IEEE-754
Standard for the initialization of floating-point arithmetic hardware and
portability. The Standard foresees floating-point arithmetic to be nonstop
and underflows to be gradual. On DEC platforms, for example, the ANSI/IEEE-754
Standard compliance needs to be explicitly set (since deactivated by default);
in this case we use infact the option "-ieee" on the DEC/cxx native C++ compiler
to achieve this. You should check if your compiler provides compilation options
for activating Standard initialization of FP arithmetic (it may be platform
specific).
- I have a generic point and I would like to know
in which physical volume I'm located in my detector geometry.
Solution:
The best way of doing this is by invoking the G4Navigator.
First get a pointer of the navigator through the G4TransportationManager,
and then locate the point.
i.e.
#include "G4TransportationManager.hh"
#include "G4Navigator.hh"
G4ThreeVector myPoint = ....;
G4Navigator* theNavigator = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
G4VPhysicalVolume* myVolume = theNavigator->LocateGlobalPointAndSetup(myPoint);
NOTE 1: it is advisable to perform the call for locating the point when the
geometry is "closed", i.e. after the geometry optimisation has been
generated.
NOTE 2: by using the navigator for tracking as shown above, the actual particle
gets also -relocated- in the specified position. Therefore, if this
information is needed during tracking time, in order to avoid affecting
tracking, you should either use an alternative G4Navigator
object (which you then assign to your world-volume), or you access the
information through the track or touchable as specified in the FAQ
for tracking and steps.
- How can I access the daughter volumes of a specific
physical volume?
Solution:
Through the associated logical volume.
G4VPhysicalVolume* myPVolume = ....;
G4LogicalVolume* myLVolume = myPVolume->GetLogicalVolume();
for (G4int i=0; i < myLVolume->GetNoDaughters(); i++)
myPVolume = myLVolume->GetDaughter(i);
- How can I identify the exact copy-number of a specific
physical volume in my mass geometry? I tried with
GetCopyNo()
from my physical volume pointer, but it doesn't seem to work!
Solution:
The correct way to identify -uniquely- a physical volume in your
mass geometry is by using the touchables (see also section 4.1.5 of the
User's Guide for Application Developers), as follows:
G4Step* aStep = ..;
G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
G4TouchableHandle theTouchable = preStepPoint->GetTouchableHandle();
G4int copyNo = theTouchable->GetCopyNumber();
G4int motherCopyNo = theTouchable->GetCopyNumber(1);
where Copy here stays for any duplicated instance of a physical
volume, either if it is a G4PVPlacement (multiple placements of the
same logical volume) or a G4PVReplica/G4PVParameterised.
The method GetCopyNo() is meant to return only the serial
number of placements not duplicated in the geometry tree.
- How can I determine the exact position in global coordinates
in my mass geometry during tracking and how can I convert it to coordinates local to
the current volume ?
Solution:
You need again to do it through the touchables (see also section 4.1.5 of the
User's Guide for Application Developers), as follows:
G4Step* aStep = ..;
G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
G4TouchableHandle theTouchable = preStepPoint->GetTouchableHandle();
G4ThreeVector worldPosition = preStepPoint->GetPosition();
G4ThreeVector localPosition = theTouchable->GetHistory()->
GetTopTransform().TransformPoint(worldPosition);
where worldPosition here stays for the position related to the world
volume, while localPosition refers to the coordinates local to the
volume where the particle is currently placed.
- How can I access the track information through
the step object and what information am I allowed to access ?
Answer:
A G4Step object consists of two points:
G4StepPoint* point1 = step->GetPreStepPoint();
G4StepPoint* point2 = step->GetPostStepPoint();
To get their positions in the global coordinate system:
G4ThreeVector pos1 = point1->GetPosition();
G4ThreeVector pos2 = point2->GetPosition();
Hereafter we call current volume the volume where the step has just
gone through. Geometrical informations are available from
preStepPoint.
G4VTouchable and its derivates keep these geometrical
informations. We retrieve a touchable by creating a handle
for it:
G4TouchableHandle touch1 = point1->GetTouchableHandle();
To get the current volume:
G4VPhysicalVolume* volume = touch1->GetVolume();
To get its name:
G4String name = volume->GetName();
To get the physical volume copy number:
G4int copyNumber = touch1->GetCopyNumber();
To get logical volume:
G4LogicalVolume* lVolume = volume->GetLogicalVolume();
To get the associated material: the following statements are equivalent:
G4Material* material = point1 ->GetMaterial();
G4Material* material = lVolume ->GetMaterial();
To get the geometrical region:
G4Region* region = lVolume->GetRegion();
To get its mother volume:
G4VPhysicalVolume* mother = touch1->GetVolume(depth=1);
grandMother: depth=2 ...etc...
To get the copy number of the mother volume:
G4int copyNumber = touch1->GetCopyNumber(depth=1);
grandMother: depth=2 ...etc...
To get the process which has limited the current step:
G4VProcess* aProcess = point2->GetProcessDefinedStep();
To check that the particle has just entered in the current volume
(i.e. it is at the first step in the volume; the preStepPoint
is at the boundary):
if (point1->GetStepStatus() == fGeomBoundary)
To check that the particle is leaving the current volume
(i.e. it is at the last step in the volume; the postStepPoint
is at the boundary):
if (point2->GetStepStatus() == fGeomBoundary)
In the above situation, to get touchable of the next volume:
G4TouchableHandle touch2 = point2->GetTouchableHandle();
From touch2, all informations on the next volume can
be retrieved as above.
Physics quantities are available from the step (G4Step) or
from the track (G4Track).
To get the energy deposition, step length, displacement and time of flight
spent by the current step:
G4double eDeposit = step->GetTotalEnergyDeposit();
G4double sLength = step->GetStepLength();
G4ThreeVector displace = step->GetDeltaPosition();
G4double tof = step->GetDeltaTime();
To get momentum, kinetic energy and global time (time since the beginning
of the event) of the track after the completion of the current step:
G4Track* track = step->GetTrack();
G4ThreeVector momentum = track->GetMomentum();
G4double kinEnergy = track->GetKineticEnergy();
G4double globalTime = track->GetGlobalTime();
...etc...
Remark - To transform a position from the global coordinate
system to the local system of the current volume, use the
preStepPoint transformation, as described in the
geometry section above.
- How do production cuts (in range) work in Geant4 ?
Are they also used in tracking ? If a particle has an energy lower than the
converted cut in energy for the given material and the distance to the next
boundary is smaller than the cut in range, is the particle killed ?
Answer:
Geant4 does NOT have a "tracking cut". The toolkit's default behaviour
is to track particles down to zero range (i.e. zero energy).
Of course, it is possible for the user to create and register a process
that kills particles below a certain energy or range; this is however
NOT provided by default in Geant4. So there's NO "tracking cut".
For example, suppose a particle that is nearing zero energy will at some point
be proposed by its Ionisation process to undergo one final step, from its current
energy down to zero energy. This is still only a proposal. If during this step
the particle crosses a boundary, then the transportation will limit the step at
a length smaller than the Ionisation -- so the particle will still see and cross
the relevant boundary, and another step will occur on the other side of that
boundary.
In summary the "production threshold" range and its equivalent in
energy are not utilised as a "tracking cut". A particle is not abandoned
by Geant4 below a certain range/energy unless the user registers a process
to do this by him/her-self.
- I have set G4VIS... environmental variables but
visualization does not appear to be enabled.
Solution:
This might be
because you set the environment variables *after* already compiling. The environment
variables control C-pre-processor macros of the same name and therefore influence
what code gets compiled. It is suggested to proceed with the following manual procedure
to correct the current installation:
|