Geant4-10
December , 2013
Hajime YOSHIDA
Geant4 Associates International Ltd.
mail: hajime.yoshida@g4ai.org
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
Index
- MOMO for Geant4-10
- Environment Variables
- GAG
- GGE Geant4 Geometry Editor
- Characteristics
- Material Editor and Volume Editor
- Menus of GGE
- Material Editor
- Periodic Table of Elements
- Functionalities of the Material Editor
- The Logical Volume Editor
- Functionalities to define Geant4 logical volumes
- The Physical Volume Editor
- Limit of Physical volumes Editor
- Constructors of G4PVPlacement
- Single Positioned Volume
- Repeated Translationally Positioned Volumes
- Repeated Rotationally Positioned Volumes
- Replica in the X, Y or Z direction, Replica in rho, phi or Z direction
- Generation of C++ code
- Naming conventions in GGE
- Default values and combo-boxes
1) MOMO for Geant4-10
Momo was originally conceived as a kind of integrated GUI desktop for Geant4
but for Geant4 version 10, only two componetnts GAG (Geant4 Adaptive GUI)
and Environment Variable Panel are maintained.
Other MOMO's componets are kept for archives;
- GGE (Geant4 Geometry Editor) is kept on the MOMO's window
and may serve to create materials and simple geometry. For example,
attached PDG.xml file can be used to create C++ codes.
- GPE (Geant4 Physics Editor) is removed from the window.
Their original source Java codes are available in the form of Java Archive file "momo-src.jar" in the "environments/MOMO/" directory.
It is completely written in Java and runs on
any platform running Java like Linux, Windows and Mac.
Currently supported is Java 1.6 .
2. Environment
Variables
Geant4-10 adopts CMake as the default build system. The only
environment variables user has to set are those on the physics data set
files. MOMO shows the values of the following
environment variables which are set by user, for example, with geant4.(c)sh.
"G4LEDATA", "G4LEVELGAMMADATA", "G4RADIOACTIVEDATA", "G4NEUTRONHPDATA" , "G4ABLADATA" ,
"G4NEUTRONXSDATA" , "G4PIIDATA" , "G4REALSURFACEDATA", "G4SAIDXSDATA"
3. GAG
3-1 How to choose GAG as your user interface.
Geant4's
interface for GAG, G4UIGAG, is selected as one of default user
interfaces like csh and tcsh, when you use G4UIExecutive() in your main
code.
Basic examples, from B1 to B4 are codes as such.
To make GAG as your first choice, the file $HOME/.g4session must be used.
In this file user interfaces (and application which uses them) can be specified, for example;
#example
gag
tcsh
qt
3-2 How to use GAG
On the terminal, type the following line;
%java -jar your-path-to-MOMO/MOMO.jar
and you have the MOMO window.
You can create an icon to the above command if it helps you.
Usage of GAG is simple.
- Click the GAG tab and open the GAG's pane
- Click the top left Geant menu and its "Start" button
- Choose the Geant4 binary file, using the file chooser and click on it
- After a moment, the Geant4 command tree (at left) and
parameter panel (at right) are displayed. AT the lower panel is
displayed the outputs from Geant4 application.
- Click on the nodes or leaves make their help diaplayed. Commands in the opaque characters are inactive ones.
- Parameters are either chosen from the list or typed in.
- Four buttons are available
- "Default" button displays the default parameters of the command, if defined
- "Current" button displays the current value(s), if available
- "Clear" button clear the contents in the parameters cells
- "Execute" button starts the command. During the execution, its color isn't in green.
- Output from the Geant4 are shown in the lower window, if
"Log_to_Terminal" button is cheched. This button can be unchecked at
any time. "Log_to_File" button can be also cheched or unchecked at any
time.
- If you want to interrupt the execution, "Kill_Geant4" button is used.
4) GGE Geant4 Geometry Editor (for archive)
GGE, or GEANT4 Geometry Editor, is a tabular tool to "create" a
detector geometry of GEANT4.
From the rows of the tables, filled by user, it generates a
complete C++ class code lines for materials and logical volumes.
It is capable of limited and relatively simple cases of the full geometry,
including physical volumes, i.e., placing of logical volumes.
4-1) Characteristics
- Tables
- It provides users with several tables
into whose cells users can fill with their own detector parameters.
Each row of the tables corresponds to a kind of instantiation or
application of a certain method of a class.
- Help user with Geant4 defaults
- Default values, canonical units of Geant4, pre-defined Geant4 constants
etc. are visually provided for user's choice.
- C++ code generation
- Using the data in the tables, even if they are partial and imcomplete,
GGE can generate C++ source codes for a detector,
only if the class name of the geometry is supplied.
If user wants so, C++ codes generated by GGE can be a complete
description of a detector, including the definition of atoms, materials,
solids, color attributes,
logical volumes and physical volumes with rotations and translations.
- All necessary class names and their usages of the Geant4 class libraries
are applied in automatic C++ code generation
- All necessary class definition files are included automatically
- Necessary local variables such as to define the rotation or translation
are created when necessary. Naming conventions are explained later.
- The C++ source codes are saved into files and can be compiled to
make a GEANT4 executable.
- Persistency and Reuse of detector data
- Full detector data and material data can be
saved in the Java's serialization format or in the XML format a la GDML-1.
It can be reloaded for later reuse.
XML format a la GDML-1 is limited to materials and logical volumes.
But XML file
lacks some items in the MOMO's table due
to GDML-1's present imcompleteness. Physical volumes aren't
supported.
- Companion files and Extra "Project" functions
-
-
A set of companion files are provided to visualize the geometry and
to run the simulation with the physics list. Files generated by GGE and GPE
must be stored in the canonical sub-directories, therein.
Details will be explained later.
- The stand-alone version of MOMO provides three menu buttons;
- to generate a simple working main program. User has to supply the
name of the main program, which MOMO uses for the G4TARGET.
- to generate Momomake.gmk makefile. The environment variables set by
a user are included in the Momomake.gmk.
- to compile all. If MOMOHOME variable is defined to designate the
position of the companion files, MOMO starts make command. Or user can
use this makefile like;
%make -f Momomake.gmk
GGE consists of two tabular editors (material and volume) which are
interrelated.
The material editor consists of two tables; one for "material from scratch", another
for "compound materials".
Volume editor consists of two minor editors;
one for "logical volumes" and another for
"physical volumes". The logical volume editor allows user to specify complete
description of logical volumes,
including solid, material, and visualization attribute.
The Physical volume editor, in contrast, supports only limited use-cases ; Single
Positioned Volume, Repeatedly Positioned Volumes with incremental copy numbers
(translational arrangement or axially symmetric arrangement), and
Replicas (in any axis).
Tips!
- GGE/MOMO is based on Java's MVC (Model-View-Control) model, so that any changes
to any of the tables by a user
are automatically reflected to the internal data structure of GGE and thus to C++ codes.
This is true at any moment, so that user can get even imcomplete C++ class files
at any moment, even without any filled tabular cells, though only the
class name is mandatory.
-
The whole detector description can be saved in a persistent file and can
be loaded for later reuse.
-
GGE employs own naming rules to generate C++ codes from the tables. This will
be explained later.
GGE has a top menu buttons and fill-in text area.
4-4) Material Editor
The material editor
is composed of two minor tables for
- "material from scratch"
and
- "compound materials".
These tables can be enlengthened as will, if necessary.
The boundary of the two tables can be moved as will, too.
Every row corresponds to one material (scratch or compound).
A row is filled with selected element(s) and default values, when
user push the "append" or "insert" button, after selecting a element(s).
The periodic table is popped up,
when one of the "append" or "insert" buttons of the tables is pushed.
When an element is chosen by the mouse click, it's label color becomes green.
Multiple elements (upto 20 at present)
can be chosen simultaneously for compound materials.
When a mouse is clicked on the selected element, is is deselected. So, user
can choose correct element(s).
The foundamental properties of atoms; Z, A, etc. are pre-built in to the
atomic table and are copied automatically to the table.
They are also used to create
C++, XML and Java serialization files,
even though unseen to the user.
The element window can be hidden at any moment by the close
button of the window.
4-4-2) Functionalities of the Material Editor
The following functionalities are implemented;
- append, insert, edit and delete a material
- material from scratch
The name of an atom, numbers Z and A are
taken from the atomic table. User has to specify its density,
temperature and pressure. Canonical units and states can be
choosen from the listbox.
Although the scratch table shows
the names of the elements in the second column,
the corresponding instance in C++ is named "elementX", where
"X" represents element's symbol, like "elementH", "elementNa".
- material by combination (number or fractional ratios).
When element(s) is(are) chosen in the periodic table of
atoms, it(they) is(are) copied to tha table of
scratch(compound) on the pression of "append"
or "insert" button.
If user selected multiple elements and pushed
"insert" or "append" button of the scratch table, only the
first element is copied. When the button of the compound table
is pushed, all the selected elements are shown in the third column.
To "insert" a row, user
has to focus a row before the click on the menu button. A new row
is created just below it.
- User has to type in the name of a compound material,
which is employed as the variable name in verbatim.
- A pop-up window
is displayed when he focuses and click
on a third cell with the label "elements".
There, compound by number or by fraction can be specified.
The values are copied to the "elements" cell. To confirm, user
can enlarge the width of the cell.
- default states (and their canonical names)
and values are provided (material state, temperature,
pressure).
- canonical physical units of GEANT4
are shown in selectable combo-boxes.
- The first column "in Use" is to mark the
materials used in user's detector (logical volumes).
The default value is "in Use", when a row is created at the first time.
- Only materials used in the logical volumes can be
automatically checked and marked as "in Use" state by
the "Mark the Used Materials" button
on the Logical Volume Table, as seen below.
- user can add any materials "in Use" to
have C++ constructors, even when they aren't used in
logical volumes.
- input and output from/to persistent material file
Material tables are saved to a Java's persistent file and can be
reused. XML a la GDML format is also provided. Note that GDML is not yet
complete and is lacking a part of definitions like material's state etc.
- load, append or save a material file
- exemplary persistent material database
file "PDG.g4mt" and PDG.xml taken from the PDG data book
are available.
Not yet implemented are;
- material from materials,
- isotope
Notice on C++ codes
MOMO doesn't duplicate the C++ instance of an element, but
is not protected against possible duplication
of "in Use" instances of the same name of compound materials.
4-4-3) A code fragment generated from the dicom.xml; XML file.
// Elements
G4Element* elementH = new G4Element( "Hydrogen", "H", 1. , 1.00794*g/mole );
G4Element* elementC = new G4Element( "Carbon", "C", 6. , 12.011*g/mole );
G4Element* elementN = new G4Element( "Nitrogen", "N", 7. , 14.00674*g/mole );
G4Element* elementO = new G4Element( "Oxygen", "O", 8. , 15.9994*g/mole );
G4Element* elementNa = new G4Element( "Sodium", "Na", 11. , 22.989768*g/mole );
G4Element* elementMg = new G4Element( "Magnesium", "Mg", 12. , 24.305*g/mole );
G4Element* elementP = new G4Element( "Phosphorus", "P", 15. , 30.973762*g/mole );
G4Element* elementS = new G4Element( "Sulfur", "S", 16. , 32.066*g/mole );
G4Element* elementCl = new G4Element( "Chlorine", "Cl", 17. , 35.4527*g/mole );
G4Element* elementK = new G4Element( "Potassium", "K", 19. , 39.0983*g/mole );
G4Element* elementCa = new G4Element( "Calcium", "Ca", 20. , 40.078*g/mole );
G4Element* elementFe = new G4Element( "Iron", "Fe", 26. , 55.845*g/mole );
// Materials from Combination
G4Material* SkeletonSpongiosa = new G4Material("SkeletonSpongiosa", 1159.0*kg/m3,
12, kStateUndefined, 273.15*kelvin, 1.0*atmosphere );
SkeletonSpongiosa->AddElement( elementH, 0.085 );
SkeletonSpongiosa->AddElement( elementC, 0.404 );
SkeletonSpongiosa->AddElement( elementN, 0.058 );
SkeletonSpongiosa->AddElement( elementO, 0.367 );
SkeletonSpongiosa->AddElement( elementNa, 0.0010 );
SkeletonSpongiosa->AddElement( elementMg, 0.0010 );
SkeletonSpongiosa->AddElement( elementP, 0.034 );
SkeletonSpongiosa->AddElement( elementS, 0.0020 );
SkeletonSpongiosa->AddElement( elementCl, 0.0020 );
SkeletonSpongiosa->AddElement( elementK, 0.0010 );
SkeletonSpongiosa->AddElement( elementCa, 0.044 );
SkeletonSpongiosa->AddElement( elementFe, 0.0010 );
The above C++ lines are generated from the next fragments of XML file a la GDML
which was created by MOMO which reloaded this XML file.
<?xml version="1.0" encoding="UTF-8"?>
<gdml xmlns:gdml="http://cern.ch/2001/Schemas/GDML"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../schema/gdml_1.0.xsd">
<!--skip-->
<materials>
<!--Elements-->
<element name="Hydrogen" formula="H" Z="1">
<atom value="1.00794"/>
</element>
<element name="Carbon" formula="C" Z="6">
<atom value="12.011"/>
</element>
<element name="Nitrogen" formula="N" Z="7">
<atom value="14.00674"/>
</element>
<element name="Oxygen" formula="O" Z="8">
<atom value="15.9994"/>
</element>
<element name="Sodium" formula="Na" Z="11">
<atom value="22.989768"/>
</element>
<element name="Magnesium" formula="Mg" Z="12">
<atom value="24.305"/>
</element>
<element name="Phosphorus" formula="P" Z="15">
<atom value="30.973762"/>
</element>
<element name="Sulfur" formula="S" Z="16">
<atom value="32.066"/>
</element>
<element name="Chlorine" formula="Cl" Z="17">
<atom value="35.4527"/>
</element>
<element name="Potassium" formula="K" Z="19">
<atom value="39.0983"/>
</element>
<element name="Calcium" formula="Ca" Z="20">
<atom value="40.078"/>
</element>
<element name="Iron" formula="Fe" Z="26">
<atom value="55.845"/>
</element>
<!--Materials from Combination-->
<material name="SkeletonSpongiosa">
<D type="denstiy" value="1159.0" unit="kg/m3"/>
<T type="temperature" value="273.15" unit="kelvin"/>
<P type="pascal" value="1.0" unit="atmosphere"/>
<fraction n="0.085" ref="H"/>
<fraction n="0.404" ref="C"/>
<fraction n="0.058" ref="N"/>
<fraction n="0.367" ref="O"/>
<fraction n="0.0010" ref="Na"/>
<fraction n="0.0010" ref="Mg"/>
<fraction n="0.034" ref="P"/>
<fraction n="0.0020" ref="S"/>
<fraction n="0.0020" ref="Cl"/>
<fraction n="0.0010" ref="K"/>
<fraction n="0.044" ref="Ca"/>
<fraction n="0.0010" ref="Fe"/>
</material>
<!--skip-->
</gdml>
The logical volume editor is composed of
4-5-1) Functionalities of the logical volume editor
Following functionaliteis are implemented;
- Defining G4LogicalVolumes
Each row of the logical vulume table represents an
instance of the G4LogicalVolume constructor.
User can append, insert or delete a row with corresponding buttons.
The table has following columns;
- The first column is to specify the name of a logical volume.
- The second column is filled automatically by choosing one of the
G4Solid types from the listbox.
By clicking on the cell, user has a pop-up window
to edit its parameters and preview with DAWN.
- The third column is type-in cell for material name
listed in the material editor. All the items already
defined in the Material editor are diaplayed in the form
of the listbox only to choose one.
- The fourth column is to specify the visualization attribute's
name. All the color names defined in the color chooser lists are
displayed to choose one.
- Selecting a G4Solid
All Geant4 solids can be selected from the solid listbox, located at the
right of "Select a Solid" label.
- all CSG solids; box, tube segment, cone segment,
symmetric trapezoid, sphere segment, parallel piped,
torus segment, HYPE,
- BREP solids; PolyCone segment and Polygone segment
- After selecting a solid tyle, user pushes the "append" or "insert" button
and a new row is created in the table.
- By clicking on the "solid" cell (the second column),
a pop up
window appears to specify solid's parameters. User can
- type in parameters and select canonical units of CSG solids
- add any number of nodes and facets of BREP solids and
type in their parameters and select canonical units
- preview with DAWN with automatically chosen world size
- save DAWN format file of the solid
A code fragment of a logical volume "thintube" of
BREP PolyCone generated by MOMO. Words in red are those typed in by a user.
G4double DzArraythintube [] =
{-1000.0*micrometer, -750.0*micrometer, -500.0*micrometer, -250.0*micrometer,
0.0*micrometer, 250.0*micrometer, 500.0*micrometer, 750.0*micrometer,
1000.0*micrometer};
G4double RminArraythintube [] =
{1.0*micrometer, 1.0*micrometer, 1.0*micrometer, 1.0*micrometer, 1.0*micrometer,
1.0*micrometer, 1.0*micrometer, 1.0*micrometer, 1.0*micrometer};
G4double RmaxArraythintube [] =
{20.0*micrometer, 16.0*micrometer, 12.0*micrometer, 8.0*micrometer,
4.0*micrometer, 8.0*micrometer, 12.0*micrometer, 16.0*micrometer, 20.0*micrometer};
G4BREPSolidPCone *solidthintube = new G4BREPSolidPCone("solidthintube", //its name
0.0*mrad, //its start angle
270.0*deg, //its opening angle
9, //its nZ
DzArraythintube[0], //z start
DzArraythintube, //z value
RminArraythintube, //rmin
RmaxArraythintube ); //rmax
G4LogicalVolume * logicalthintube = new G4LogicalVolume(solidthintube, //its solid
carbon, //its material
"logicalthintube" , //its name
0,0,0);
logicalthintube->SetVisAttributes(black);
- Defining G4Color
The visualization attribute and its name are required by the logical
volumes. They
can be defined using a graphical color chooser.
Each color's given unique name is listed in the editor panel.
The RGB numbers defined by the chooser are taken
to generate C++ codes.
An example of code fragments generated by MOMO
G4VisAttributes * lightblue= new G4VisAttributes( G4Colour(0/255. ,255/255. ,255/255. ));
- "Make the used materials" button.
Clicking this button, GGE scans the materials specified in the
logical volume table and marks "in Use" cell (the first column )
of the material tables accordingly. All other materials not used in
logical volumes are not marked.
Note that only rows marked "in Use" are used
to generate C++ codes.
The physical volume editor consists of five minor tables of different
way of displacement of a logical volume. Each table is contained in a tabbed pane.
4-6-1) Limit of Physical volumes Editor
Compared with the logical volume editor, the physical volume one has limited
generality. So, if user aren't satisfied with the following simplistic ways
to place logical volumes, he can use partially generated C++ codes for
logical volumes etc. as a starting point.
4-6-2) Constructors of G4PVPlacement
Following four types of constructor are implemented,
according to the types of
rotation and types of the mother volume.
- Type 1 constructor = rotation of the frame, physical mother volume
- Type 2 constructor = rotation of a body, physical mother volume
- Type 3 constructor = rotation of the frame, logical mother volume
- Type 4 constructor = rotation of a body, logical mother volume
Next are the example C++ codes generated by MOMO for the above four cases. In the first two cases,
words in red are those which user typed in the cells of the editor.
- "box-bp" and "box-fp" in the first column to specify the pName, i.e., the name of the unstance of G4PVPlacement
- "box" in the second column to spscify the names of their
logical volumes, pLogical. All the names already defined in the logical
volume panel are displayed to choose one. In this case, one "box" is
used to make different physical volumes.
- "container" in the pMother, i.e., name of the mother volume.
The prefixes "logical" or "physical" are attached according to the type
of the mother volume.
pNames are used as postfixes
to designate local variables like rotation matrices and rotation angles etc..
On the contrary, several prefixes are used to differentiate
instances, like physicalcontainer and logicalcontainer, where only "container" is typed in a cell.
Naming conventions will be explained later.
// Single Positioned Placement
// Body rotation + physical mother
G4RotationMatrix rotMatrixbox-bp; // unit rotation matrix
G4double anglebox-bp = 0.0*deg; // rotational angle
rotMatrixbox-bp.rotateX(anglebox-bp); // rot matrix
G4VPhysicalVolume * box-bp= new G4PVPlacement(G4Transform3D(rotMatrixbox-bp, //rotation
G4ThreeVector(0.0*mm, 0.0*mm, 0.0*mm)),
"box-bp", //its name (2nd constructor)
box, //its logical volume
physicalcontainer, //its mother volume
false, //no boolean operation
0); //copy number
// Frame rotation + physical mother
G4RotationMatrix rotMatrixbox-fp; // unit rotation matrix
G4double anglebox-fp = 0.0*deg; // rotational angle
rotMatrixbox-fp.rotateX(anglebox-fp); // rot matrix
G4VPhysicalVolume * box-fp= new G4PVPlacement( new G4RotationMatrix(rotMatrixbox-fp) , // Frame rotation
G4ThreeVector(0.0*mm, 0.0*mm, 0.0*mm),
"box-fp", // 1st constructor its name
box, //its logical volume
physicalcontainer, //its mother volume
false, //no boolean operation
0); //copy number
// Body rotation + logical mother
G4RotationMatrix rotMatrixbox-bl; // unit rotation matrix
G4double anglebox-bl = 0.0*deg; // rotational angle
rotMatrixbox-bl.rotateX(anglebox-bl); // rot matrix
G4VPhysicalVolume * box-bl= new G4PVPlacement(G4Transform3D(rotMatrixbox-bl, //rotation
G4ThreeVector(0.0*mm, 0.0*mm, 0.0*mm)),
box, //its current logical volume(4th constructor)
"box-bl", //its name
logicalcontainer, //its mother volume
false, //no boolean operation
0); //copy number
// Frame rotation + logical mother
G4RotationMatrix rotMatrixbox-fl; // unit rotation matrix
G4double anglebox-fl = 0.0*deg; // rotational angle
rotMatrixbox-fl.rotateX(anglebox-fl); // rot matrix
G4VPhysicalVolume * box-fl= new G4PVPlacement( new G4RotationMatrix(rotMatrixbox-fl) , // Frame rotation
G4ThreeVector(0.0*mm, 0.0*mm, 0.0*mm),
box, // 3rd constructor its logical volume
"box-fl", //its name
logicalcontainer, //its mother volume
false, //no boolean operation
0); //copy number
Following simple placements are provided in GGE. Every placement is
contained in independent tabbed pane.
4-6-3)
Single Positioned Volume (SPV)
Each row represents a physical volume
which has one-to-one
correspondence to a logical volume. The C++ code lines are demonstrated just above.
IMPORTANT!! The world volume must be
defined in the first row of this table.
- The first column specifies either body or frame rotation.
- The second column specifies the instance's name of the physical volume
- The third column specifies the name of the logical volume to be placed
- The fourth column specifies the type of the mother volume.
The mother volume is either
null(Master Reference System), logical or physical.
The MARS or the world volume must be specified at the first row.
- The fifth column specifies the name of the mother volume, if it isn't NULL.
- The columns 7, 8 and 9-th specify the translation
in the X, Y or Z direction (default is no translation) with a
selectable unit of length
- The 11-th column specifies the axis of rotation (frame or body);
rotation around X, Y or Z axis with an angle in the 12-th column
4-6-4)
Repeated Translationally Positioned Volumes (RTPV Arrangement)
Each row represent a physical volume
which consists of any number of copies of a logical volume with incremental copy numbers.
- The first to 4-th columns are same as above.
- The columns 6, 7 and 8-th specify the position of the first copy
- The 10-th column specifies the direction of placement; X, Y or Z direction
- The 11-th column specifies the incremental step size of displacement
- The last column specifies the number of copies
Next is a fragment of C++ code generated from a line in the table. Here "Boses" is typed in the
first column, pName. This word is used as the postfix to designate local variables as well as
the loop variable. "box" is the pLogical, i.e., the name of the logical volume. Here the mother's
name is typed in as "world" in the pMother cell, and it is physical. The "box" logical volume
is translated along X direction from X0 = -100*cm in 10*cm step with the copy numbers "copyBoxes" from 1 to 21.
G4int copyBoxes;
copyBoxes=0;
for (G4int Boxes=1; Boxes<=21; Boxes++){
G4double transBoxes =-100.0*cm+10.0*cm*(Boxes-1);
G4VPhysicalVolume * Boxes = new G4PVPlacement(0, //no rotation
G4ThreeVector(transBoxes, 0.0*cm, 0.0*cm),
"Boxes", //its name
box, //its logical volume
physicalworld, //its mother volume
false, //no boolean operation
copyBoxes++); //copy number
}
4-6-5) Repeated Rotationally Positioned Volumes; (RRPV Arrangement)
Each row represents a physical volume
which consists of
axially symmetric arrangement of any number of copies of a
logical volume with incremental copy numbers.
- The columns "move", "pName", "pLogic", "MomType" and "pMother" are same as above.
- (X0, Y0, Z0) column specify the position of the center of an axial rotation
- "Radius" column specifies a radius of axially symmetric arrangement
- "RotAxis" column specifies the rotational axis ; X, Y or Z
- "Phi_0" and "dPhi" column specify a starting angle and incremental step angle
- The last column specifies the number of copies
A row of the table generates the C++ code lines as below. Here
"Circle" is the pName.
The logical volume "box" is
copied around the Z axis from 0* deg with 30* deg step and with copy number "copyCircle" from 1 to 10.
The center of rotation (x0Circle, y0Circle, z0Circle) = (-200*mm, 100*mm, 0.0*mm).
// Active Rotation of Bodies
G4int copyCircle;
copyCircle=0;
G4RotationMatrix rotationMatrixCircle;G4double startCircle = 0.0*deg;
G4double incCircle = 30.0*deg;
rotationMatrixCircle.rotateZ(startCircle);
G4double x0Circle = -200.0*mm;
G4double y0Circle = 100.0*mm;
G4double z0Circle = 0.0*mm;
G4double radiusCircle = 300.0*mm;
for (G4int Circle=1; Circle<=10; Circle++){
G4double transCircle = startCircle+incCircle*(Circle-1);
G4double xCircle, yCircle, zCircle;
xCircle = x0Circle + radiusCircle * cos(transCircle);
yCircle = y0Circle + radiusCircle * sin(transCircle);
zCircle = z0Circle;
G4VPhysicalVolume * Circle = new G4PVPlacement(G4Transform3D(rotationMatrixCircle, //rotate
G4ThreeVector(xCircle, yCircle, zCircle)),
"Circle", //its name
box, //its logical volume
physicalworld, //its mother volume
false, //no boolean operation
copyCircle++); //copy number
rotationMatrixCircle.rotateZ(incCircle);
}
- width (in length or angle) and number of replicas
- offset (in length or angle)
- logical or physical mother volume
Below is the C++ code lines generated from a row in the table. "Sliced" is the pName (the first column).
"box" is the logical volume to be sliced. pMother is "world" and it is the physical volume.
The number of replicas along X axis is 1000 with 2.0*micronmeter width and
with offset of -1.0*mm.
/ Slicing Translation
G4PVReplica * physicalSliced= new G4PVReplica("physicalSliced", //name
logicalbox, // its logical
physicalworld, // its mother
kXAxis, // along Axis
1000, // No of replicas
2.0*micrometer, // width
-1.0*mm); // offset
Planned but
not implemented yet are paremetrised volumes with linear scaling or linear rotation.
4-7) Generation of C++ code
GGE has two menu buttons to generate the implementation file and class definition file.
- C++ code lines are written out to a editor widget and can be edited and saved to a file.
But edited file
loses the correspondence with the tables contents or the persistent file.
- The required and necessary header files are automatically included; elements, solid types etc.
- The order of creating instances is following;
- G4Elements,
- G4Material,
- G4VisAttributes,
- G4Solids,
- G4LogicalVolume,
- Single Positioned Volumes,
- Repeated Volumes,
- Replicas
- return the instance name of the MARS
Order of instantiation inside each section is from the first row to downward.
Here is a sample of automatically generated C++ code
which is created from completely skelton tables but with the class name "MyDetector".
//***** Generated by Geant4 Geometry Editor at Wed Feb 25 20:27:44 JST 2004 *****
//------HeaderFile-
#include "MyDetector.hh"
#include "G4UnitsTable.hh"
#include "G4VUserDetectorConstruction.hh"
#include "globals.hh"
#include "G4Material.hh"
#include "G4MaterialTable.hh"
#include "G4Element.hh"
#include "G4ElementTable.hh"
#include "G4LogicalVolume.hh"
#include "G4ThreeVector.hh"
#include "G4PVPlacement.hh"
#include "G4PVReplica.hh"
#include "G4SDManager.hh"
#include "G4VisAttributes.hh"
#include "G4Colour.hh"
MyDetector::MyDetector()
{ ; }
MyDetector::~MyDetector()
{ ; }
G4VPhysicalVolume* MyDetector::Construct( )
{
// Elements
// Materials from Combination
// Materials from Scratch
// Visualization attributes
// Logical Volumes
// Physical Volumes ---- Single Positioned Placement, Repeated Placement, Slicing ---------------------------
// Single Positioned Placement
// Repeated Placement Translation
// Repeated Placement AxialSymmetoric
// Slicing Translation
// Slicing AxialSymmetric
// return the physical World
Next is the definition file of this skelton class.
// Geometry Header File
// MyDetector.hh generated by Geant4 Geometry Editor at Wed Feb 25 20:27:44 JST 2004
#ifndef MyDetector_h
#define MyDetector_h 1
class G4VPhysicalVolume;
#include "G4VUserDetectorConstruction.hh"
class MyDetector: public G4VUserDetectorConstruction
{ public:
MyDetector();
~MyDetector();
public:
G4VPhysicalVolume* Construct();
};
#endif
Knowing GGE's naming convention is helpful to read the generated C++ code as
well as using GGE correctly. Look at relevant Geant4 constructors will be very
suggestive.
- Elements and materials
- Elements are named "elementXXX", where XXX stands for the
element's symbol in the periodic table.
- materials are named just as you have typed in the second column
of the material window.
- solids and logical volumes
The "Name" typed in the first (leftmost) column of the "Logical Volume"
is used to name the corresponding solid. If the name "world" is given
to a logical volume of a Box, the G4Solid has an instance "solidworld".
- logical and physical volumes
- The strings of the pName (physical or logical) cells filled in the table are used literally as the names of instances.
- The instance of a physical volume defined by "pName" has
a name prefixed
with "physical", i.,e., instance's name is "physical" + pName ( + =>
string concatenation). "logical" is added to the instance of a logical
volume.
- In case of SPV (single positioned volume), the columns "pName" (instance of
physical volume) and "pLogical" may have the same strings.
-
In case of RVA (repeated volumes arrangement), "pName" is different from
"pLogical" whose copies are repeatedly placed.
- All variables are named after their proper instances.
See for example, the control variable used in the for loop in the
RVA.
Another examples are arrays to define BREP geometry.
- Default optional values of materials
GGE provides default values in a pre-filled columns or with the
combo-boxes. "Use", "State" and "Unit" columns are equipped with
combo-boxes. Temperature and pressure column are pre-filled with
273.15 * kelvin and 1 * atmosphere.
- Default values in volumes
"Mother Type" is either NULL (mother of all), logical (type 2, 4 constructors)
or physical (type 2 or 4 constructors) in G4PVPlacement.
yoshida
About
the authors