├── .gitignore ├── Begin_here └── README.md ├── README.md ├── tutorial1 ├── CMakeFiles │ ├── 3.3.0-rc3 │ │ ├── CMakeCCompiler.cmake │ │ ├── CMakeCXXCompiler.cmake │ │ ├── CMakeDetermineCompilerABI_C.bin │ │ ├── CMakeDetermineCompilerABI_CXX.bin │ │ ├── CMakeSystem.cmake │ │ ├── CompilerIdC │ │ │ ├── CMakeCCompilerId.c │ │ │ └── a.out │ │ └── CompilerIdCXX │ │ │ ├── CMakeCXXCompilerId.cpp │ │ │ └── a.out │ ├── CMakeDirectoryInformation.cmake │ ├── CMakeOutput.log │ ├── Makefile.cmake │ ├── Makefile2 │ ├── TargetDirectories.txt │ ├── cmake.check_cache │ ├── feature_tests.bin │ ├── feature_tests.c │ ├── feature_tests.cxx │ ├── progress.marks │ └── tutorial.dir │ │ ├── DependInfo.cmake │ │ ├── build.make │ │ ├── cmake_clean.cmake │ │ ├── depend.make │ │ ├── flags.make │ │ ├── link.txt │ │ └── progress.make ├── CMakeLists.txt ├── Makefile ├── README.md ├── include │ ├── DetectorConstruction.hh │ ├── PhysicsList.hh │ └── PrimaryGeneratorAction.hh ├── src │ ├── DetectorConstruction.cpp │ ├── PhysicsList.cpp │ └── PrimaryGeneratorAction.cpp └── tutorial.cpp ├── tutorial2 ├── CMakeLists.txt ├── README.md ├── include │ ├── DetectorConstruction.hh │ ├── PhysicsList.hh │ └── PrimaryGeneratorAction.hh ├── init_vis.mac ├── src │ ├── DetectorConstruction.cpp │ ├── PhysicsList.cpp │ └── PrimaryGeneratorAction.cpp ├── tutorial2.cpp └── vis.mac ├── tutorial3 ├── CMakeLists.txt ├── README.md ├── include │ ├── .PrimaryGeneratorAction.hh.swp │ ├── ActionInitialization.hh │ ├── DetectorConstruction.hh │ ├── PhysicsList.hh │ ├── PrimaryGeneratorAction.hh │ ├── Run.hh │ ├── RunAction.hh │ └── StackingAction.hh ├── init_vis.mac ├── run.mac ├── src │ ├── ActionInitialization.cpp │ ├── DetectorConstruction.cpp │ ├── PhysicsList.cpp │ ├── PrimaryGeneratorAction.cpp │ ├── Run.cpp │ ├── RunAction.cpp │ └── StackingAction.cpp ├── tutorial3.cpp └── vis.mac ├── tutorial4 ├── CMakeLists.txt ├── README.md ├── gui.mac ├── icons.mac ├── include │ ├── ActionInitialization.hh │ ├── DetectorConstruction.hh │ ├── PhysicsList.hh │ ├── PrimaryGeneratorAction.hh │ ├── Run.hh │ ├── RunAction.hh │ └── StackingAction.hh ├── init_vis.mac ├── run.png ├── runx10.png ├── src │ ├── ActionInitialization.cpp │ ├── DetectorConstruction.cpp │ ├── PhysicsList.cpp │ ├── PrimaryGeneratorAction.cpp │ ├── Run.cpp │ ├── RunAction.cpp │ └── StackingAction.cpp ├── tutorial4.cpp └── vis.mac └── tutorial5 ├── CMakeLists.txt ├── G4History.macro ├── README.md ├── gui.mac ├── icons.mac ├── include ├── ActionInitialization.hh ├── DetectorConstruction.hh ├── EventAction.hh ├── Materials.hh ├── PhysicsList.hh ├── PrimaryGeneratorAction.hh ├── Run.hh ├── RunAction.hh ├── StackingAction.hh └── SteppingAction.hh ├── init_vis.mac ├── run.png ├── run1.mac ├── run2.mac ├── runx10.png ├── src ├── ActionInitialization.cpp ├── DetectorConstruction.cpp ├── EventAction.cpp ├── PhysicsList.cpp ├── PrimaryGeneratorAction.cpp ├── Run.cpp ├── RunAction.cpp ├── StackingAction.cpp └── SteppingAction.cpp ├── tutorial5.cpp └── vis.mac /.gitignore: -------------------------------------------------------------------------------- 1 | *build 2 | *.swp 3 | *.swo 4 | *.aux 5 | *.log 6 | *.out 7 | *.o 8 | *.exe 9 | 10 | -------------------------------------------------------------------------------- /Begin_here/README.md: -------------------------------------------------------------------------------- 1 | # First thing first 2 | --- 3 | First thing is that we need to have our source file set. You may notice in the install 4 | directory in the bin folder a file called `geant4.sh`. I suggest adding 5 | ``` 6 | source /path/to/geant4-install/bin/geant4.sh 7 | ``` 8 | to your bashrc file. There is also a file for c-shell if you prefer that. 9 | 10 | Do note that Geant4 works best with these two shells, so if you are using something 11 | like z-shell do expect errors. It is best to just switch to bash when running Geant4 12 | programs. 13 | 14 | ### Warning 15 | If you do not know much C or C++ you will have a hard time creating programs with Geant4. 16 | If you need to refresh then brush up on subjects like classes/structures, initialization 17 | lists, and pointers. The Geant4 toolbox is created around classes, so if you do not know 18 | how to use these and refer to objects within the class then you are going to have a 19 | difficult time. 20 | 21 | You should also know some basics about cmake files and scripting. This will be less 22 | important because you should be able to lean pretty heavily on the ones within the 23 | examples. 24 | 25 | # Let's build an example 26 | --- 27 | Once you have Geant4 installed this is the first place that you should start. Before 28 | you start creating simulations it is important that we know how to build some of the 29 | examples. So first we want to find the example directory. This will be in your 30 | geant4-install path/share/Geant4.version/examples/basic 31 | 32 | Once we are there make a new directory called `B1-build`, or whatever you want to call 33 | it. So from the basic directory we will be running: 34 | ``` 35 | mkdir B1-build 36 | cd B1-build 37 | cmake ../B1 38 | make -j6 39 | ./example1 40 | ``` 41 | You should now be running the first Geant4 example and see something like this 42 | ![B1 example image](http://i.imgur.com/8AW9itx.png) 43 | This is using the QT visualization tools, and if you have something different that is 44 | okay as long as you see something. 45 | 46 | Now we want to run a simulation. So in the section where it says "Session" type 47 | `/run/beamOn 10` where this simulates the run of 10 gamma beams coming in from the 48 | left side. This is a uniform distribution from the yz plane at the most -x point in our 49 | world. Checkout `foo/basic/B1/src/B1PrimaryGeneratorAction.cc` to see how this was 50 | created. 51 | On the output you will see the total radiation accumulated in the volume, see B1RunAction.cc 52 | for more details. 53 | 54 | We can also change the particle type by running `/gun/particle e-`, changing it to an 55 | electron. Running another 10 particles we can see a lot more yellow dots and that all 56 | the green lines begin with a red section (with more yellow dots). The yellow dots 57 | represent an interaction of some kind. The colour of the beam indicated its charge. 58 | Red indicated a negative charge, green a neutral (so in this case a gamma ray) and blue 59 | a positive charge (verify by switching to a positron, e+. And try a proton, proton). 60 | 61 | You can also change the energy levels of the incident beam by running `/gun/energy 10 MeV` 62 | And then rerun. 63 | 64 | It is good to check out the `vis.mac` and `run.mac` files in the B1 directory. `vis.mac` 65 | will contain the initial commands for the setup. Including how the camera is oriented, 66 | axes, text, and more. The `run.mac` file contains a macro for running the program. If 67 | you just want results and no visualizations you can just run `./exampleB1 run1.mac` and 68 | it will run the commands listed in the file for you. This is extremely useful if you 69 | need to run bigger tests. If you will be outputting a lot I suggest running something 70 | like `./exampleB1 run1.mac | tee output.txt` which will save all the output that goes 71 | to the screen also in a file called `output.txt`. 72 | 73 | I suggest that you look through the basic examples to see how everything is created. 74 | These are some of the simpler geometries and scenarios that can be created. 75 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Geant4Tutorials 2 | ---------------------------- 3 | 4 | Geant4 tutorials made by Steven Walton: 5 | 6 | We will go through tutorials and build our first Geant4 application, step by step 7 | First we will get a basic geometry, then get a visualization where we can run a beam through it, then we will focus on the physics 8 | 9 | -------------------------------------- 10 | I am not an expert at Geant, this is both to help me learn and to help others that have the same problems as me. I welcome emails from others that would like to correct me and help with this. I am doing this because most of the information on Geant I see out there suggests that one should just review the examples and just dive in to making an application from there. 11 | 12 | It is my belief that one should be able to see and make and understand what is the bare 13 | essentials before building more complex ones. Going through the examples there are a 14 | lot of different ways of doing things and I am trying to piece together the parts from 15 | the [Geant4 User's Guide.](http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides/ForApplicationDeveloper/fo/BookForAppliDev.pdf) 16 | Please reference this material, as it has much more information than I will include. 17 | The point of this is just to get your feet wet. 18 | 19 | Install Guide 20 | -------------- 21 | [Install Guide and Options](http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides/InstallationGuide/fo/BookInstalGuide.pdf) 22 | 23 | Remember that if you would like to add more options (such as data, graphics libraries, or multithreading) you can just run the cmake in your build directory and add them. 24 | 25 | Standard Options are located on [page 15](http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides/InstallationGuide/fo/BookInstalGuide.pdf#page=15) of this document. 26 | Please read it. 27 | 28 | Suggested Install 29 | ---------------------- 30 | If you have separate root and home partitions you may want to check where you are installing to and make sure you have enough room. 31 | Follow the instruction document, but I use the following cmake command. 32 | 33 | ``` 34 | cmake -DCMAKE_INSTALL_PREFIX=/path/to/geant4-install_dir -DGEANT4_BUILD_MULTITHREADED=ON -DGEATN4_INSTALL_DATA=ON -DGEANT4_USE_GDML=ON -DGEANT4_USE_XM=ON -DGEANT4_USE_RAYTRACER_X11=ON -DGEANT4_USE_QT=ON -DGEANT4_USE_OPENGL_X11=ON /path/to/geant4.10.version.number 35 | ``` 36 | I have had some bugs when building and pointing to where the installed data is, so I 37 | suggest just letting Geant4 download the data for you. 38 | I also like using the QT visualization tools as it seems to work better with Ubuntu 16. It also has the most capabilities compared to the other visualization tools. This is the only visualizer needed but 39 | if you install more you can always call them or ignore them. 40 | I found when building with the other visualizers that I would have problems, and the QT 41 | version allows you to move the camera without having to manually set it. This can save 42 | some time if you need to view multiple angles. 43 | 44 | Next we continue with the make 45 | ```$ make -j6``` 46 | 47 | This makes the build with 6 processors, replace 6 with the number of processors you 48 | want to use (suggested max being 1 less than the number of threads you have) 49 | If you are having problems building I suggest dropping down to one processor and adding `VERBOSE=1`. 50 | 51 | ```# make install``` 52 | 53 | Use sudo for this if you are installing to `/opt`, but you don't need sudo if you are 54 | building into the home directory. 55 | 56 | Remember if you want to add additional D flags you can always remake the build. 57 | 58 | Packages Needed 59 | -------------------- 60 | From a base Ubuntu 16.04 version you will need 61 | - libxerces-c-dev 62 | - libxmu-dev 63 | 64 | Ubuntu on Windows 65 | ------------------- 66 | I've also done some testing on Ubuntu on Windows. All these tutorials have been verified to work on XMing server and Xmanager5. 67 | 68 | If you are trying to visualize runs (such as these tutorials) 69 | 70 | - Xmanager5 seems to work the best. There are a few glitches but nothing major. Note: I have not pushed the system. 71 | 72 | - XMing server works fine, but is glitchy. If you do not rotate your view the particles jump around while the run is happening. It looks normal when the run completes. When you try to rotate the view, XMing does not refresh at an acceptable rate, and will stutter. If you just care about the final view, XMing will work great (and it is free). 73 | -------------------------------------------------------------------------------- /tutorial1/CMakeFiles/3.3.0-rc3/CMakeCCompiler.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_C_COMPILER "/usr/bin/cc") 2 | set(CMAKE_C_COMPILER_ARG1 "") 3 | set(CMAKE_C_COMPILER_ID "GNU") 4 | set(CMAKE_C_COMPILER_VERSION "4.8.1") 5 | set(CMAKE_C_COMPILE_FEATURES "c_function_prototypes;c_restrict;c_variadic_macros;c_static_assert") 6 | set(CMAKE_C90_COMPILE_FEATURES "c_function_prototypes") 7 | set(CMAKE_C99_COMPILE_FEATURES "c_restrict;c_variadic_macros") 8 | set(CMAKE_C11_COMPILE_FEATURES "c_static_assert") 9 | 10 | set(CMAKE_C_PLATFORM_ID "Linux") 11 | set(CMAKE_C_SIMULATE_ID "") 12 | set(CMAKE_C_SIMULATE_VERSION "") 13 | 14 | set(CMAKE_AR "/usr/bin/ar") 15 | set(CMAKE_RANLIB "/usr/bin/ranlib") 16 | set(CMAKE_LINKER "/usr/bin/ld") 17 | set(CMAKE_COMPILER_IS_GNUCC 1) 18 | set(CMAKE_C_COMPILER_LOADED 1) 19 | set(CMAKE_C_COMPILER_WORKS TRUE) 20 | set(CMAKE_C_ABI_COMPILED TRUE) 21 | set(CMAKE_COMPILER_IS_MINGW ) 22 | set(CMAKE_COMPILER_IS_CYGWIN ) 23 | if(CMAKE_COMPILER_IS_CYGWIN) 24 | set(CYGWIN 1) 25 | set(UNIX 1) 26 | endif() 27 | 28 | set(CMAKE_C_COMPILER_ENV_VAR "CC") 29 | 30 | if(CMAKE_COMPILER_IS_MINGW) 31 | set(MINGW 1) 32 | endif() 33 | set(CMAKE_C_COMPILER_ID_RUN 1) 34 | set(CMAKE_C_SOURCE_FILE_EXTENSIONS c;m) 35 | set(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC) 36 | set(CMAKE_C_LINKER_PREFERENCE 10) 37 | 38 | # Save compiler ABI information. 39 | set(CMAKE_C_SIZEOF_DATA_PTR "8") 40 | set(CMAKE_C_COMPILER_ABI "ELF") 41 | set(CMAKE_C_LIBRARY_ARCHITECTURE "x86_64-linux-gnu") 42 | 43 | if(CMAKE_C_SIZEOF_DATA_PTR) 44 | set(CMAKE_SIZEOF_VOID_P "${CMAKE_C_SIZEOF_DATA_PTR}") 45 | endif() 46 | 47 | if(CMAKE_C_COMPILER_ABI) 48 | set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_C_COMPILER_ABI}") 49 | endif() 50 | 51 | if(CMAKE_C_LIBRARY_ARCHITECTURE) 52 | set(CMAKE_LIBRARY_ARCHITECTURE "x86_64-linux-gnu") 53 | endif() 54 | 55 | 56 | 57 | 58 | set(CMAKE_C_IMPLICIT_LINK_LIBRARIES "c") 59 | set(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "/usr/lib/gcc/x86_64-linux-gnu/4.8;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib") 60 | set(CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "") 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /tutorial1/CMakeFiles/3.3.0-rc3/CMakeCXXCompiler.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_CXX_COMPILER "/usr/bin/c++") 2 | set(CMAKE_CXX_COMPILER_ARG1 "") 3 | set(CMAKE_CXX_COMPILER_ID "GNU") 4 | set(CMAKE_CXX_COMPILER_VERSION "4.6.3") 5 | set(CMAKE_CXX_COMPILE_FEATURES "cxx_template_template_parameters;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extern_templates;cxx_func_identifier;cxx_generalized_initializers;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nullptr;cxx_range_for;cxx_raw_string_literals;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_variadic_macros;cxx_variadic_templates") 6 | set(CMAKE_CXX98_COMPILE_FEATURES "cxx_template_template_parameters") 7 | set(CMAKE_CXX11_COMPILE_FEATURES "cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extern_templates;cxx_func_identifier;cxx_generalized_initializers;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nullptr;cxx_range_for;cxx_raw_string_literals;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_variadic_macros;cxx_variadic_templates") 8 | set(CMAKE_CXX14_COMPILE_FEATURES "") 9 | 10 | set(CMAKE_CXX_PLATFORM_ID "Linux") 11 | set(CMAKE_CXX_SIMULATE_ID "") 12 | set(CMAKE_CXX_SIMULATE_VERSION "") 13 | 14 | set(CMAKE_AR "/usr/bin/ar") 15 | set(CMAKE_RANLIB "/usr/bin/ranlib") 16 | set(CMAKE_LINKER "/usr/bin/ld") 17 | set(CMAKE_COMPILER_IS_GNUCXX 1) 18 | set(CMAKE_CXX_COMPILER_LOADED 1) 19 | set(CMAKE_CXX_COMPILER_WORKS TRUE) 20 | set(CMAKE_CXX_ABI_COMPILED TRUE) 21 | set(CMAKE_COMPILER_IS_MINGW ) 22 | set(CMAKE_COMPILER_IS_CYGWIN ) 23 | if(CMAKE_COMPILER_IS_CYGWIN) 24 | set(CYGWIN 1) 25 | set(UNIX 1) 26 | endif() 27 | 28 | set(CMAKE_CXX_COMPILER_ENV_VAR "CXX") 29 | 30 | if(CMAKE_COMPILER_IS_MINGW) 31 | set(MINGW 1) 32 | endif() 33 | set(CMAKE_CXX_COMPILER_ID_RUN 1) 34 | set(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC) 35 | set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;mm;CPP) 36 | set(CMAKE_CXX_LINKER_PREFERENCE 30) 37 | set(CMAKE_CXX_LINKER_PREFERENCE_PROPAGATES 1) 38 | 39 | # Save compiler ABI information. 40 | set(CMAKE_CXX_SIZEOF_DATA_PTR "8") 41 | set(CMAKE_CXX_COMPILER_ABI "ELF") 42 | set(CMAKE_CXX_LIBRARY_ARCHITECTURE "x86_64-linux-gnu") 43 | 44 | if(CMAKE_CXX_SIZEOF_DATA_PTR) 45 | set(CMAKE_SIZEOF_VOID_P "${CMAKE_CXX_SIZEOF_DATA_PTR}") 46 | endif() 47 | 48 | if(CMAKE_CXX_COMPILER_ABI) 49 | set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_CXX_COMPILER_ABI}") 50 | endif() 51 | 52 | if(CMAKE_CXX_LIBRARY_ARCHITECTURE) 53 | set(CMAKE_LIBRARY_ARCHITECTURE "x86_64-linux-gnu") 54 | endif() 55 | 56 | 57 | 58 | 59 | set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "stdc++;m;c") 60 | set(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "/usr/lib/gcc/x86_64-linux-gnu/4.6;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib") 61 | set(CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "") 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /tutorial1/CMakeFiles/3.3.0-rc3/CMakeDetermineCompilerABI_C.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenwalton/Geant4Tutorials/9084bb7159326b032759939df9206f6a6677d860/tutorial1/CMakeFiles/3.3.0-rc3/CMakeDetermineCompilerABI_C.bin -------------------------------------------------------------------------------- /tutorial1/CMakeFiles/3.3.0-rc3/CMakeDetermineCompilerABI_CXX.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenwalton/Geant4Tutorials/9084bb7159326b032759939df9206f6a6677d860/tutorial1/CMakeFiles/3.3.0-rc3/CMakeDetermineCompilerABI_CXX.bin -------------------------------------------------------------------------------- /tutorial1/CMakeFiles/3.3.0-rc3/CMakeSystem.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_HOST_SYSTEM "Linux-3.13.0-55-generic") 2 | set(CMAKE_HOST_SYSTEM_NAME "Linux") 3 | set(CMAKE_HOST_SYSTEM_VERSION "3.13.0-55-generic") 4 | set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64") 5 | 6 | 7 | 8 | set(CMAKE_SYSTEM "Linux-3.13.0-55-generic") 9 | set(CMAKE_SYSTEM_NAME "Linux") 10 | set(CMAKE_SYSTEM_VERSION "3.13.0-55-generic") 11 | set(CMAKE_SYSTEM_PROCESSOR "x86_64") 12 | 13 | set(CMAKE_CROSSCOMPILING "FALSE") 14 | 15 | set(CMAKE_SYSTEM_LOADED 1) 16 | -------------------------------------------------------------------------------- /tutorial1/CMakeFiles/3.3.0-rc3/CompilerIdC/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenwalton/Geant4Tutorials/9084bb7159326b032759939df9206f6a6677d860/tutorial1/CMakeFiles/3.3.0-rc3/CompilerIdC/a.out -------------------------------------------------------------------------------- /tutorial1/CMakeFiles/3.3.0-rc3/CompilerIdCXX/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenwalton/Geant4Tutorials/9084bb7159326b032759939df9206f6a6677d860/tutorial1/CMakeFiles/3.3.0-rc3/CompilerIdCXX/a.out -------------------------------------------------------------------------------- /tutorial1/CMakeFiles/CMakeDirectoryInformation.cmake: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" Generator, CMake Version 3.3 3 | 4 | # Relative path conversion top directories. 5 | set(CMAKE_RELATIVE_PATH_TOP_SOURCE "/home/steven/GEANT4/Builds/tutorial") 6 | set(CMAKE_RELATIVE_PATH_TOP_BINARY "/home/steven/GEANT4/Builds/tutorial") 7 | 8 | # Force unix paths in dependencies. 9 | set(CMAKE_FORCE_UNIX_PATHS 1) 10 | 11 | 12 | # The C and CXX include file regular expressions for this directory. 13 | set(CMAKE_C_INCLUDE_REGEX_SCAN "^.*$") 14 | set(CMAKE_C_INCLUDE_REGEX_COMPLAIN "^$") 15 | set(CMAKE_CXX_INCLUDE_REGEX_SCAN ${CMAKE_C_INCLUDE_REGEX_SCAN}) 16 | set(CMAKE_CXX_INCLUDE_REGEX_COMPLAIN ${CMAKE_C_INCLUDE_REGEX_COMPLAIN}) 17 | -------------------------------------------------------------------------------- /tutorial1/CMakeFiles/Makefile.cmake: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" Generator, CMake Version 3.3 3 | 4 | # The generator used is: 5 | set(CMAKE_DEPENDS_GENERATOR "Unix Makefiles") 6 | 7 | # The top level Makefile was generated from the following files: 8 | set(CMAKE_MAKEFILE_DEPENDS 9 | "CMakeCache.txt" 10 | "CMakeFiles/3.3.0-rc3/CMakeCCompiler.cmake" 11 | "CMakeFiles/3.3.0-rc3/CMakeCXXCompiler.cmake" 12 | "CMakeFiles/3.3.0-rc3/CMakeSystem.cmake" 13 | "CMakeLists.txt" 14 | "/home/steven/GEANT4/geant4.10.1-install/lib/Geant4-10.1.2/Geant4Config.cmake" 15 | "/home/steven/GEANT4/geant4.10.1-install/lib/Geant4-10.1.2/Geant4ConfigVersion.cmake" 16 | "/home/steven/GEANT4/geant4.10.1-install/lib/Geant4-10.1.2/Geant4LibraryDepends-release.cmake" 17 | "/home/steven/GEANT4/geant4.10.1-install/lib/Geant4-10.1.2/Geant4LibraryDepends.cmake" 18 | "/home/steven/GEANT4/geant4.10.1-install/lib/Geant4-10.1.2/UseGeant4.cmake" 19 | "/usr/share/cmake-3.3/Modules/CMakeCInformation.cmake" 20 | "/usr/share/cmake-3.3/Modules/CMakeCXXInformation.cmake" 21 | "/usr/share/cmake-3.3/Modules/CMakeCommonLanguageInclude.cmake" 22 | "/usr/share/cmake-3.3/Modules/CMakeGenericSystem.cmake" 23 | "/usr/share/cmake-3.3/Modules/CMakeSystemSpecificInformation.cmake" 24 | "/usr/share/cmake-3.3/Modules/CMakeSystemSpecificInitialize.cmake" 25 | "/usr/share/cmake-3.3/Modules/Compiler/GNU-C.cmake" 26 | "/usr/share/cmake-3.3/Modules/Compiler/GNU-CXX.cmake" 27 | "/usr/share/cmake-3.3/Modules/Compiler/GNU.cmake" 28 | "/usr/share/cmake-3.3/Modules/Platform/Linux-GNU-C.cmake" 29 | "/usr/share/cmake-3.3/Modules/Platform/Linux-GNU-CXX.cmake" 30 | "/usr/share/cmake-3.3/Modules/Platform/Linux-GNU.cmake" 31 | "/usr/share/cmake-3.3/Modules/Platform/Linux.cmake" 32 | "/usr/share/cmake-3.3/Modules/Platform/UnixPaths.cmake" 33 | ) 34 | 35 | # The corresponding makefile is: 36 | set(CMAKE_MAKEFILE_OUTPUTS 37 | "Makefile" 38 | "CMakeFiles/cmake.check_cache" 39 | ) 40 | 41 | # Byproducts of CMake generate step: 42 | set(CMAKE_MAKEFILE_PRODUCTS 43 | "CMakeFiles/CMakeDirectoryInformation.cmake" 44 | ) 45 | 46 | # Dependency information for all targets: 47 | set(CMAKE_DEPEND_INFO_FILES 48 | "CMakeFiles/tutorial.dir/DependInfo.cmake" 49 | ) 50 | -------------------------------------------------------------------------------- /tutorial1/CMakeFiles/Makefile2: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" Generator, CMake Version 3.3 3 | 4 | # Default target executed when no arguments are given to make. 5 | default_target: all 6 | 7 | .PHONY : default_target 8 | 9 | # The main recursive all target 10 | all: 11 | 12 | .PHONY : all 13 | 14 | # The main recursive preinstall target 15 | preinstall: 16 | 17 | .PHONY : preinstall 18 | 19 | #============================================================================= 20 | # Special targets provided by cmake. 21 | 22 | # Disable implicit rules so canonical targets will work. 23 | .SUFFIXES: 24 | 25 | 26 | # Remove some rules from gmake that .SUFFIXES does not remove. 27 | SUFFIXES = 28 | 29 | .SUFFIXES: .hpux_make_needs_suffix_list 30 | 31 | 32 | # Suppress display of executed commands. 33 | $(VERBOSE).SILENT: 34 | 35 | 36 | # A target that is always out of date. 37 | cmake_force: 38 | 39 | .PHONY : cmake_force 40 | 41 | #============================================================================= 42 | # Set environment variables for the build. 43 | 44 | # The shell in which to execute make rules. 45 | SHELL = /bin/sh 46 | 47 | # The CMake executable. 48 | CMAKE_COMMAND = /usr/bin/cmake 49 | 50 | # The command to remove a file. 51 | RM = /usr/bin/cmake -E remove -f 52 | 53 | # Escaping for special characters. 54 | EQUALS = = 55 | 56 | # The top-level source directory on which CMake was run. 57 | CMAKE_SOURCE_DIR = /home/steven/GEANT4/Builds/tutorial 58 | 59 | # The top-level build directory on which CMake was run. 60 | CMAKE_BINARY_DIR = /home/steven/GEANT4/Builds/tutorial 61 | 62 | #============================================================================= 63 | # Target rules for target CMakeFiles/tutorial.dir 64 | 65 | # All Build rule for target. 66 | CMakeFiles/tutorial.dir/all: 67 | $(MAKE) -f CMakeFiles/tutorial.dir/build.make CMakeFiles/tutorial.dir/depend 68 | $(MAKE) -f CMakeFiles/tutorial.dir/build.make CMakeFiles/tutorial.dir/build 69 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --progress-dir=/home/steven/GEANT4/Builds/tutorial/CMakeFiles --progress-num=1,2,3,4,5 "Built target tutorial" 70 | .PHONY : CMakeFiles/tutorial.dir/all 71 | 72 | # Include target in all. 73 | all: CMakeFiles/tutorial.dir/all 74 | 75 | .PHONY : all 76 | 77 | # Build rule for subdir invocation for target. 78 | CMakeFiles/tutorial.dir/rule: cmake_check_build_system 79 | $(CMAKE_COMMAND) -E cmake_progress_start /home/steven/GEANT4/Builds/tutorial/CMakeFiles 5 80 | $(MAKE) -f CMakeFiles/Makefile2 CMakeFiles/tutorial.dir/all 81 | $(CMAKE_COMMAND) -E cmake_progress_start /home/steven/GEANT4/Builds/tutorial/CMakeFiles 0 82 | .PHONY : CMakeFiles/tutorial.dir/rule 83 | 84 | # Convenience name for target. 85 | tutorial: CMakeFiles/tutorial.dir/rule 86 | 87 | .PHONY : tutorial 88 | 89 | # clean rule for target. 90 | CMakeFiles/tutorial.dir/clean: 91 | $(MAKE) -f CMakeFiles/tutorial.dir/build.make CMakeFiles/tutorial.dir/clean 92 | .PHONY : CMakeFiles/tutorial.dir/clean 93 | 94 | # clean rule for target. 95 | clean: CMakeFiles/tutorial.dir/clean 96 | 97 | .PHONY : clean 98 | 99 | #============================================================================= 100 | # Special targets to cleanup operation of make. 101 | 102 | # Special rule to run CMake to check the build system integrity. 103 | # No rule that depends on this can have commands that come from listfiles 104 | # because they might be regenerated. 105 | cmake_check_build_system: 106 | $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 107 | .PHONY : cmake_check_build_system 108 | 109 | -------------------------------------------------------------------------------- /tutorial1/CMakeFiles/TargetDirectories.txt: -------------------------------------------------------------------------------- 1 | /home/steven/GEANT4/Builds/tutorial/CMakeFiles/tutorial.dir 2 | -------------------------------------------------------------------------------- /tutorial1/CMakeFiles/cmake.check_cache: -------------------------------------------------------------------------------- 1 | # This file is generated by cmake for dependency checking of the CMakeCache.txt file 2 | -------------------------------------------------------------------------------- /tutorial1/CMakeFiles/feature_tests.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenwalton/Geant4Tutorials/9084bb7159326b032759939df9206f6a6677d860/tutorial1/CMakeFiles/feature_tests.bin -------------------------------------------------------------------------------- /tutorial1/CMakeFiles/feature_tests.c: -------------------------------------------------------------------------------- 1 | 2 | const char features[] = {"" 3 | "C_FEATURE:" 4 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 5 | "1" 6 | #else 7 | "0" 8 | #endif 9 | "c_function_prototypes\n" 10 | "C_FEATURE:" 11 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 12 | "1" 13 | #else 14 | "0" 15 | #endif 16 | "c_restrict\n" 17 | "C_FEATURE:" 18 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201000L 19 | "1" 20 | #else 21 | "0" 22 | #endif 23 | "c_static_assert\n" 24 | "C_FEATURE:" 25 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 26 | "1" 27 | #else 28 | "0" 29 | #endif 30 | "c_variadic_macros\n" 31 | 32 | }; 33 | 34 | int main(int argc, char** argv) { (void)argv; return features[argc]; } 35 | -------------------------------------------------------------------------------- /tutorial1/CMakeFiles/feature_tests.cxx: -------------------------------------------------------------------------------- 1 | 2 | const char features[] = {"" 3 | "CXX_FEATURE:" 4 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 500 && __cplusplus >= 201402L 5 | "1" 6 | #else 7 | "0" 8 | #endif 9 | "cxx_aggregate_default_initializers\n" 10 | "CXX_FEATURE:" 11 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && __cplusplus >= 201103L 12 | "1" 13 | #else 14 | "0" 15 | #endif 16 | "cxx_alias_templates\n" 17 | "CXX_FEATURE:" 18 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L 19 | "1" 20 | #else 21 | "0" 22 | #endif 23 | "cxx_alignas\n" 24 | "CXX_FEATURE:" 25 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L 26 | "1" 27 | #else 28 | "0" 29 | #endif 30 | "cxx_alignof\n" 31 | "CXX_FEATURE:" 32 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L 33 | "1" 34 | #else 35 | "0" 36 | #endif 37 | "cxx_attributes\n" 38 | "CXX_FEATURE:" 39 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L 40 | "1" 41 | #else 42 | "0" 43 | #endif 44 | "cxx_attribute_deprecated\n" 45 | "CXX_FEATURE:" 46 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 47 | "1" 48 | #else 49 | "0" 50 | #endif 51 | "cxx_auto_type\n" 52 | "CXX_FEATURE:" 53 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L 54 | "1" 55 | #else 56 | "0" 57 | #endif 58 | "cxx_binary_literals\n" 59 | "CXX_FEATURE:" 60 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 61 | "1" 62 | #else 63 | "0" 64 | #endif 65 | "cxx_constexpr\n" 66 | "CXX_FEATURE:" 67 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L 68 | "1" 69 | #else 70 | "0" 71 | #endif 72 | "cxx_contextual_conversions\n" 73 | "CXX_FEATURE:" 74 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 75 | "1" 76 | #else 77 | "0" 78 | #endif 79 | "cxx_decltype\n" 80 | "CXX_FEATURE:" 81 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L 82 | "1" 83 | #else 84 | "0" 85 | #endif 86 | "cxx_decltype_auto\n" 87 | "CXX_FEATURE:" 88 | #if ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40801) && __cplusplus >= 201103L 89 | "1" 90 | #else 91 | "0" 92 | #endif 93 | "cxx_decltype_incomplete_return_types\n" 94 | "CXX_FEATURE:" 95 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 96 | "1" 97 | #else 98 | "0" 99 | #endif 100 | "cxx_default_function_template_args\n" 101 | "CXX_FEATURE:" 102 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 103 | "1" 104 | #else 105 | "0" 106 | #endif 107 | "cxx_defaulted_functions\n" 108 | "CXX_FEATURE:" 109 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 110 | "1" 111 | #else 112 | "0" 113 | #endif 114 | "cxx_defaulted_move_initializers\n" 115 | "CXX_FEATURE:" 116 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && __cplusplus >= 201103L 117 | "1" 118 | #else 119 | "0" 120 | #endif 121 | "cxx_delegating_constructors\n" 122 | "CXX_FEATURE:" 123 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 124 | "1" 125 | #else 126 | "0" 127 | #endif 128 | "cxx_deleted_functions\n" 129 | "CXX_FEATURE:" 130 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L 131 | "1" 132 | #else 133 | "0" 134 | #endif 135 | "cxx_digit_separators\n" 136 | "CXX_FEATURE:" 137 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 138 | "1" 139 | #else 140 | "0" 141 | #endif 142 | "cxx_enum_forward_declarations\n" 143 | "CXX_FEATURE:" 144 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 145 | "1" 146 | #else 147 | "0" 148 | #endif 149 | "cxx_explicit_conversions\n" 150 | "CXX_FEATURE:" 151 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && __cplusplus >= 201103L 152 | "1" 153 | #else 154 | "0" 155 | #endif 156 | "cxx_extended_friend_declarations\n" 157 | "CXX_FEATURE:" 158 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 159 | "1" 160 | #else 161 | "0" 162 | #endif 163 | "cxx_extern_templates\n" 164 | "CXX_FEATURE:" 165 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && __cplusplus >= 201103L 166 | "1" 167 | #else 168 | "0" 169 | #endif 170 | "cxx_final\n" 171 | "CXX_FEATURE:" 172 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 173 | "1" 174 | #else 175 | "0" 176 | #endif 177 | "cxx_func_identifier\n" 178 | "CXX_FEATURE:" 179 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 180 | "1" 181 | #else 182 | "0" 183 | #endif 184 | "cxx_generalized_initializers\n" 185 | "CXX_FEATURE:" 186 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L 187 | "1" 188 | #else 189 | "0" 190 | #endif 191 | "cxx_generic_lambdas\n" 192 | "CXX_FEATURE:" 193 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L 194 | "1" 195 | #else 196 | "0" 197 | #endif 198 | "cxx_inheriting_constructors\n" 199 | "CXX_FEATURE:" 200 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 201 | "1" 202 | #else 203 | "0" 204 | #endif 205 | "cxx_inline_namespaces\n" 206 | "CXX_FEATURE:" 207 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 208 | "1" 209 | #else 210 | "0" 211 | #endif 212 | "cxx_lambdas\n" 213 | "CXX_FEATURE:" 214 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L 215 | "1" 216 | #else 217 | "0" 218 | #endif 219 | "cxx_lambda_init_captures\n" 220 | "CXX_FEATURE:" 221 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 222 | "1" 223 | #else 224 | "0" 225 | #endif 226 | "cxx_local_type_template_args\n" 227 | "CXX_FEATURE:" 228 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 229 | "1" 230 | #else 231 | "0" 232 | #endif 233 | "cxx_long_long_type\n" 234 | "CXX_FEATURE:" 235 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 236 | "1" 237 | #else 238 | "0" 239 | #endif 240 | "cxx_noexcept\n" 241 | "CXX_FEATURE:" 242 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && __cplusplus >= 201103L 243 | "1" 244 | #else 245 | "0" 246 | #endif 247 | "cxx_nonstatic_member_init\n" 248 | "CXX_FEATURE:" 249 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 250 | "1" 251 | #else 252 | "0" 253 | #endif 254 | "cxx_nullptr\n" 255 | "CXX_FEATURE:" 256 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && __cplusplus >= 201103L 257 | "1" 258 | #else 259 | "0" 260 | #endif 261 | "cxx_override\n" 262 | "CXX_FEATURE:" 263 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 264 | "1" 265 | #else 266 | "0" 267 | #endif 268 | "cxx_range_for\n" 269 | "CXX_FEATURE:" 270 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 271 | "1" 272 | #else 273 | "0" 274 | #endif 275 | "cxx_raw_string_literals\n" 276 | "CXX_FEATURE:" 277 | #if ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40801) && __cplusplus >= 201103L 278 | "1" 279 | #else 280 | "0" 281 | #endif 282 | "cxx_reference_qualified_functions\n" 283 | "CXX_FEATURE:" 284 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 500 && __cplusplus >= 201402L 285 | "1" 286 | #else 287 | "0" 288 | #endif 289 | "cxx_relaxed_constexpr\n" 290 | "CXX_FEATURE:" 291 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L 292 | "1" 293 | #else 294 | "0" 295 | #endif 296 | "cxx_return_type_deduction\n" 297 | "CXX_FEATURE:" 298 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 299 | "1" 300 | #else 301 | "0" 302 | #endif 303 | "cxx_right_angle_brackets\n" 304 | "CXX_FEATURE:" 305 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 306 | "1" 307 | #else 308 | "0" 309 | #endif 310 | "cxx_rvalue_references\n" 311 | "CXX_FEATURE:" 312 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 313 | "1" 314 | #else 315 | "0" 316 | #endif 317 | "cxx_sizeof_member\n" 318 | "CXX_FEATURE:" 319 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 320 | "1" 321 | #else 322 | "0" 323 | #endif 324 | "cxx_static_assert\n" 325 | "CXX_FEATURE:" 326 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 327 | "1" 328 | #else 329 | "0" 330 | #endif 331 | "cxx_strong_enums\n" 332 | "CXX_FEATURE:" 333 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && __cplusplus 334 | "1" 335 | #else 336 | "0" 337 | #endif 338 | "cxx_template_template_parameters\n" 339 | "CXX_FEATURE:" 340 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L 341 | "1" 342 | #else 343 | "0" 344 | #endif 345 | "cxx_thread_local\n" 346 | "CXX_FEATURE:" 347 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 348 | "1" 349 | #else 350 | "0" 351 | #endif 352 | "cxx_trailing_return_types\n" 353 | "CXX_FEATURE:" 354 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 355 | "1" 356 | #else 357 | "0" 358 | #endif 359 | "cxx_unicode_literals\n" 360 | "CXX_FEATURE:" 361 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 362 | "1" 363 | #else 364 | "0" 365 | #endif 366 | "cxx_uniform_initialization\n" 367 | "CXX_FEATURE:" 368 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 369 | "1" 370 | #else 371 | "0" 372 | #endif 373 | "cxx_unrestricted_unions\n" 374 | "CXX_FEATURE:" 375 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && __cplusplus >= 201103L 376 | "1" 377 | #else 378 | "0" 379 | #endif 380 | "cxx_user_literals\n" 381 | "CXX_FEATURE:" 382 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 500 && __cplusplus >= 201402L 383 | "1" 384 | #else 385 | "0" 386 | #endif 387 | "cxx_variable_templates\n" 388 | "CXX_FEATURE:" 389 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 390 | "1" 391 | #else 392 | "0" 393 | #endif 394 | "cxx_variadic_macros\n" 395 | "CXX_FEATURE:" 396 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 397 | "1" 398 | #else 399 | "0" 400 | #endif 401 | "cxx_variadic_templates\n" 402 | 403 | }; 404 | 405 | int main(int argc, char** argv) { (void)argv; return features[argc]; } 406 | -------------------------------------------------------------------------------- /tutorial1/CMakeFiles/progress.marks: -------------------------------------------------------------------------------- 1 | 5 2 | -------------------------------------------------------------------------------- /tutorial1/CMakeFiles/tutorial.dir/DependInfo.cmake: -------------------------------------------------------------------------------- 1 | # The set of languages for which implicit dependencies are needed: 2 | set(CMAKE_DEPENDS_LANGUAGES 3 | "CXX" 4 | ) 5 | # The set of files for implicit dependencies of each language: 6 | set(CMAKE_DEPENDS_CHECK_CXX 7 | "/home/steven/GEANT4/Builds/tutorial/src/DetectorConstruction.cpp" "/home/steven/GEANT4/Builds/tutorial/CMakeFiles/tutorial.dir/src/DetectorConstruction.cpp.o" 8 | "/home/steven/GEANT4/Builds/tutorial/src/PhysicsList.cpp" "/home/steven/GEANT4/Builds/tutorial/CMakeFiles/tutorial.dir/src/PhysicsList.cpp.o" 9 | "/home/steven/GEANT4/Builds/tutorial/src/PrimaryGeneratorAction.cpp" "/home/steven/GEANT4/Builds/tutorial/CMakeFiles/tutorial.dir/src/PrimaryGeneratorAction.cpp.o" 10 | "/home/steven/GEANT4/Builds/tutorial/tutorial.cpp" "/home/steven/GEANT4/Builds/tutorial/CMakeFiles/tutorial.dir/tutorial.cpp.o" 11 | ) 12 | set(CMAKE_CXX_COMPILER_ID "GNU") 13 | 14 | # Preprocessor definitions for this target. 15 | set(CMAKE_TARGET_DEFINITIONS_CXX 16 | "G4INTY_USE_XT" 17 | "G4UI_USE" 18 | "G4UI_USE_TCSH" 19 | "G4VERBOSE" 20 | "G4VIS_USE" 21 | "G4VIS_USE_OPENGL" 22 | "G4VIS_USE_OPENGLX" 23 | "G4VIS_USE_RAYTRACERX" 24 | "G4_STORE_TRAJECTORY" 25 | ) 26 | 27 | # The include file search paths: 28 | set(CMAKE_CXX_TARGET_INCLUDE_PATH 29 | "/home/steven/GEANT4/geant4.10.1-install/include/Geant4" 30 | "include" 31 | ) 32 | 33 | # Targets to which this target links. 34 | set(CMAKE_TARGET_LINKED_INFO_FILES 35 | ) 36 | -------------------------------------------------------------------------------- /tutorial1/CMakeFiles/tutorial.dir/build.make: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" Generator, CMake Version 3.3 3 | 4 | # Delete rule output on recipe failure. 5 | .DELETE_ON_ERROR: 6 | 7 | 8 | #============================================================================= 9 | # Special targets provided by cmake. 10 | 11 | # Disable implicit rules so canonical targets will work. 12 | .SUFFIXES: 13 | 14 | 15 | # Remove some rules from gmake that .SUFFIXES does not remove. 16 | SUFFIXES = 17 | 18 | .SUFFIXES: .hpux_make_needs_suffix_list 19 | 20 | 21 | # Suppress display of executed commands. 22 | $(VERBOSE).SILENT: 23 | 24 | 25 | # A target that is always out of date. 26 | cmake_force: 27 | 28 | .PHONY : cmake_force 29 | 30 | #============================================================================= 31 | # Set environment variables for the build. 32 | 33 | # The shell in which to execute make rules. 34 | SHELL = /bin/sh 35 | 36 | # The CMake executable. 37 | CMAKE_COMMAND = /usr/bin/cmake 38 | 39 | # The command to remove a file. 40 | RM = /usr/bin/cmake -E remove -f 41 | 42 | # Escaping for special characters. 43 | EQUALS = = 44 | 45 | # The top-level source directory on which CMake was run. 46 | CMAKE_SOURCE_DIR = /home/steven/GEANT4/Builds/tutorial 47 | 48 | # The top-level build directory on which CMake was run. 49 | CMAKE_BINARY_DIR = /home/steven/GEANT4/Builds/tutorial 50 | 51 | # Include any dependencies generated for this target. 52 | include CMakeFiles/tutorial.dir/depend.make 53 | 54 | # Include the progress variables for this target. 55 | include CMakeFiles/tutorial.dir/progress.make 56 | 57 | # Include the compile flags for this target's objects. 58 | include CMakeFiles/tutorial.dir/flags.make 59 | 60 | CMakeFiles/tutorial.dir/tutorial.cpp.o: CMakeFiles/tutorial.dir/flags.make 61 | CMakeFiles/tutorial.dir/tutorial.cpp.o: tutorial.cpp 62 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/steven/GEANT4/Builds/tutorial/CMakeFiles --progress-num=$(CMAKE_PROGRESS_1) "Building CXX object CMakeFiles/tutorial.dir/tutorial.cpp.o" 63 | /usr/bin/c++ $(CXX_DEFINES) $(CXX_FLAGS) -o CMakeFiles/tutorial.dir/tutorial.cpp.o -c /home/steven/GEANT4/Builds/tutorial/tutorial.cpp 64 | 65 | CMakeFiles/tutorial.dir/tutorial.cpp.i: cmake_force 66 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/tutorial.dir/tutorial.cpp.i" 67 | /usr/bin/c++ $(CXX_DEFINES) $(CXX_FLAGS) -E /home/steven/GEANT4/Builds/tutorial/tutorial.cpp > CMakeFiles/tutorial.dir/tutorial.cpp.i 68 | 69 | CMakeFiles/tutorial.dir/tutorial.cpp.s: cmake_force 70 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/tutorial.dir/tutorial.cpp.s" 71 | /usr/bin/c++ $(CXX_DEFINES) $(CXX_FLAGS) -S /home/steven/GEANT4/Builds/tutorial/tutorial.cpp -o CMakeFiles/tutorial.dir/tutorial.cpp.s 72 | 73 | CMakeFiles/tutorial.dir/tutorial.cpp.o.requires: 74 | 75 | .PHONY : CMakeFiles/tutorial.dir/tutorial.cpp.o.requires 76 | 77 | CMakeFiles/tutorial.dir/tutorial.cpp.o.provides: CMakeFiles/tutorial.dir/tutorial.cpp.o.requires 78 | $(MAKE) -f CMakeFiles/tutorial.dir/build.make CMakeFiles/tutorial.dir/tutorial.cpp.o.provides.build 79 | .PHONY : CMakeFiles/tutorial.dir/tutorial.cpp.o.provides 80 | 81 | CMakeFiles/tutorial.dir/tutorial.cpp.o.provides.build: CMakeFiles/tutorial.dir/tutorial.cpp.o 82 | 83 | 84 | CMakeFiles/tutorial.dir/src/PrimaryGeneratorAction.cpp.o: CMakeFiles/tutorial.dir/flags.make 85 | CMakeFiles/tutorial.dir/src/PrimaryGeneratorAction.cpp.o: src/PrimaryGeneratorAction.cpp 86 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/steven/GEANT4/Builds/tutorial/CMakeFiles --progress-num=$(CMAKE_PROGRESS_2) "Building CXX object CMakeFiles/tutorial.dir/src/PrimaryGeneratorAction.cpp.o" 87 | /usr/bin/c++ $(CXX_DEFINES) $(CXX_FLAGS) -o CMakeFiles/tutorial.dir/src/PrimaryGeneratorAction.cpp.o -c /home/steven/GEANT4/Builds/tutorial/src/PrimaryGeneratorAction.cpp 88 | 89 | CMakeFiles/tutorial.dir/src/PrimaryGeneratorAction.cpp.i: cmake_force 90 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/tutorial.dir/src/PrimaryGeneratorAction.cpp.i" 91 | /usr/bin/c++ $(CXX_DEFINES) $(CXX_FLAGS) -E /home/steven/GEANT4/Builds/tutorial/src/PrimaryGeneratorAction.cpp > CMakeFiles/tutorial.dir/src/PrimaryGeneratorAction.cpp.i 92 | 93 | CMakeFiles/tutorial.dir/src/PrimaryGeneratorAction.cpp.s: cmake_force 94 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/tutorial.dir/src/PrimaryGeneratorAction.cpp.s" 95 | /usr/bin/c++ $(CXX_DEFINES) $(CXX_FLAGS) -S /home/steven/GEANT4/Builds/tutorial/src/PrimaryGeneratorAction.cpp -o CMakeFiles/tutorial.dir/src/PrimaryGeneratorAction.cpp.s 96 | 97 | CMakeFiles/tutorial.dir/src/PrimaryGeneratorAction.cpp.o.requires: 98 | 99 | .PHONY : CMakeFiles/tutorial.dir/src/PrimaryGeneratorAction.cpp.o.requires 100 | 101 | CMakeFiles/tutorial.dir/src/PrimaryGeneratorAction.cpp.o.provides: CMakeFiles/tutorial.dir/src/PrimaryGeneratorAction.cpp.o.requires 102 | $(MAKE) -f CMakeFiles/tutorial.dir/build.make CMakeFiles/tutorial.dir/src/PrimaryGeneratorAction.cpp.o.provides.build 103 | .PHONY : CMakeFiles/tutorial.dir/src/PrimaryGeneratorAction.cpp.o.provides 104 | 105 | CMakeFiles/tutorial.dir/src/PrimaryGeneratorAction.cpp.o.provides.build: CMakeFiles/tutorial.dir/src/PrimaryGeneratorAction.cpp.o 106 | 107 | 108 | CMakeFiles/tutorial.dir/src/PhysicsList.cpp.o: CMakeFiles/tutorial.dir/flags.make 109 | CMakeFiles/tutorial.dir/src/PhysicsList.cpp.o: src/PhysicsList.cpp 110 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/steven/GEANT4/Builds/tutorial/CMakeFiles --progress-num=$(CMAKE_PROGRESS_3) "Building CXX object CMakeFiles/tutorial.dir/src/PhysicsList.cpp.o" 111 | /usr/bin/c++ $(CXX_DEFINES) $(CXX_FLAGS) -o CMakeFiles/tutorial.dir/src/PhysicsList.cpp.o -c /home/steven/GEANT4/Builds/tutorial/src/PhysicsList.cpp 112 | 113 | CMakeFiles/tutorial.dir/src/PhysicsList.cpp.i: cmake_force 114 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/tutorial.dir/src/PhysicsList.cpp.i" 115 | /usr/bin/c++ $(CXX_DEFINES) $(CXX_FLAGS) -E /home/steven/GEANT4/Builds/tutorial/src/PhysicsList.cpp > CMakeFiles/tutorial.dir/src/PhysicsList.cpp.i 116 | 117 | CMakeFiles/tutorial.dir/src/PhysicsList.cpp.s: cmake_force 118 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/tutorial.dir/src/PhysicsList.cpp.s" 119 | /usr/bin/c++ $(CXX_DEFINES) $(CXX_FLAGS) -S /home/steven/GEANT4/Builds/tutorial/src/PhysicsList.cpp -o CMakeFiles/tutorial.dir/src/PhysicsList.cpp.s 120 | 121 | CMakeFiles/tutorial.dir/src/PhysicsList.cpp.o.requires: 122 | 123 | .PHONY : CMakeFiles/tutorial.dir/src/PhysicsList.cpp.o.requires 124 | 125 | CMakeFiles/tutorial.dir/src/PhysicsList.cpp.o.provides: CMakeFiles/tutorial.dir/src/PhysicsList.cpp.o.requires 126 | $(MAKE) -f CMakeFiles/tutorial.dir/build.make CMakeFiles/tutorial.dir/src/PhysicsList.cpp.o.provides.build 127 | .PHONY : CMakeFiles/tutorial.dir/src/PhysicsList.cpp.o.provides 128 | 129 | CMakeFiles/tutorial.dir/src/PhysicsList.cpp.o.provides.build: CMakeFiles/tutorial.dir/src/PhysicsList.cpp.o 130 | 131 | 132 | CMakeFiles/tutorial.dir/src/DetectorConstruction.cpp.o: CMakeFiles/tutorial.dir/flags.make 133 | CMakeFiles/tutorial.dir/src/DetectorConstruction.cpp.o: src/DetectorConstruction.cpp 134 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/steven/GEANT4/Builds/tutorial/CMakeFiles --progress-num=$(CMAKE_PROGRESS_4) "Building CXX object CMakeFiles/tutorial.dir/src/DetectorConstruction.cpp.o" 135 | /usr/bin/c++ $(CXX_DEFINES) $(CXX_FLAGS) -o CMakeFiles/tutorial.dir/src/DetectorConstruction.cpp.o -c /home/steven/GEANT4/Builds/tutorial/src/DetectorConstruction.cpp 136 | 137 | CMakeFiles/tutorial.dir/src/DetectorConstruction.cpp.i: cmake_force 138 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/tutorial.dir/src/DetectorConstruction.cpp.i" 139 | /usr/bin/c++ $(CXX_DEFINES) $(CXX_FLAGS) -E /home/steven/GEANT4/Builds/tutorial/src/DetectorConstruction.cpp > CMakeFiles/tutorial.dir/src/DetectorConstruction.cpp.i 140 | 141 | CMakeFiles/tutorial.dir/src/DetectorConstruction.cpp.s: cmake_force 142 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/tutorial.dir/src/DetectorConstruction.cpp.s" 143 | /usr/bin/c++ $(CXX_DEFINES) $(CXX_FLAGS) -S /home/steven/GEANT4/Builds/tutorial/src/DetectorConstruction.cpp -o CMakeFiles/tutorial.dir/src/DetectorConstruction.cpp.s 144 | 145 | CMakeFiles/tutorial.dir/src/DetectorConstruction.cpp.o.requires: 146 | 147 | .PHONY : CMakeFiles/tutorial.dir/src/DetectorConstruction.cpp.o.requires 148 | 149 | CMakeFiles/tutorial.dir/src/DetectorConstruction.cpp.o.provides: CMakeFiles/tutorial.dir/src/DetectorConstruction.cpp.o.requires 150 | $(MAKE) -f CMakeFiles/tutorial.dir/build.make CMakeFiles/tutorial.dir/src/DetectorConstruction.cpp.o.provides.build 151 | .PHONY : CMakeFiles/tutorial.dir/src/DetectorConstruction.cpp.o.provides 152 | 153 | CMakeFiles/tutorial.dir/src/DetectorConstruction.cpp.o.provides.build: CMakeFiles/tutorial.dir/src/DetectorConstruction.cpp.o 154 | 155 | 156 | # Object files for target tutorial 157 | tutorial_OBJECTS = \ 158 | "CMakeFiles/tutorial.dir/tutorial.cpp.o" \ 159 | "CMakeFiles/tutorial.dir/src/PrimaryGeneratorAction.cpp.o" \ 160 | "CMakeFiles/tutorial.dir/src/PhysicsList.cpp.o" \ 161 | "CMakeFiles/tutorial.dir/src/DetectorConstruction.cpp.o" 162 | 163 | # External object files for target tutorial 164 | tutorial_EXTERNAL_OBJECTS = 165 | 166 | tutorial: CMakeFiles/tutorial.dir/tutorial.cpp.o 167 | tutorial: CMakeFiles/tutorial.dir/src/PrimaryGeneratorAction.cpp.o 168 | tutorial: CMakeFiles/tutorial.dir/src/PhysicsList.cpp.o 169 | tutorial: CMakeFiles/tutorial.dir/src/DetectorConstruction.cpp.o 170 | tutorial: CMakeFiles/tutorial.dir/build.make 171 | tutorial: /home/steven/GEANT4/geant4.10.1-install/lib/libG4Tree.so 172 | tutorial: /home/steven/GEANT4/geant4.10.1-install/lib/libG4GMocren.so 173 | tutorial: /home/steven/GEANT4/geant4.10.1-install/lib/libG4visHepRep.so 174 | tutorial: /home/steven/GEANT4/geant4.10.1-install/lib/libG4RayTracer.so 175 | tutorial: /home/steven/GEANT4/geant4.10.1-install/lib/libG4VRML.so 176 | tutorial: /home/steven/GEANT4/geant4.10.1-install/lib/libG4OpenGL.so 177 | tutorial: /home/steven/GEANT4/geant4.10.1-install/lib/libG4gl2ps.so 178 | tutorial: /home/steven/GEANT4/geant4.10.1-install/lib/libG4interfaces.so 179 | tutorial: /home/steven/GEANT4/geant4.10.1-install/lib/libG4persistency.so 180 | tutorial: /home/steven/GEANT4/geant4.10.1-install/lib/libG4analysis.so 181 | tutorial: /home/steven/GEANT4/geant4.10.1-install/lib/libG4error_propagation.so 182 | tutorial: /home/steven/GEANT4/geant4.10.1-install/lib/libG4readout.so 183 | tutorial: /home/steven/GEANT4/geant4.10.1-install/lib/libG4physicslists.so 184 | tutorial: /home/steven/GEANT4/geant4.10.1-install/lib/libG4parmodels.so 185 | tutorial: /home/steven/GEANT4/geant4.10.1-install/lib/libG4FR.so 186 | tutorial: /home/steven/GEANT4/geant4.10.1-install/lib/libG4vis_management.so 187 | tutorial: /home/steven/GEANT4/geant4.10.1-install/lib/libG4modeling.so 188 | tutorial: /usr/lib/x86_64-linux-gnu/libGLU.so 189 | tutorial: /usr/lib/x86_64-linux-gnu/libGL.so 190 | tutorial: /usr/lib/x86_64-linux-gnu/libSM.so 191 | tutorial: /usr/lib/x86_64-linux-gnu/libICE.so 192 | tutorial: /usr/lib/x86_64-linux-gnu/libX11.so 193 | tutorial: /usr/lib/x86_64-linux-gnu/libXext.so 194 | tutorial: /usr/lib/x86_64-linux-gnu/libXmu.so 195 | tutorial: /home/steven/GEANT4/geant4.10.1-install/lib/libG4run.so 196 | tutorial: /home/steven/GEANT4/geant4.10.1-install/lib/libG4event.so 197 | tutorial: /home/steven/GEANT4/geant4.10.1-install/lib/libG4tracking.so 198 | tutorial: /home/steven/GEANT4/geant4.10.1-install/lib/libG4processes.so 199 | tutorial: /home/steven/GEANT4/geant4.10.1-install/lib/libG4zlib.so 200 | tutorial: /usr/lib/x86_64-linux-gnu/libexpat.so 201 | tutorial: /home/steven/GEANT4/geant4.10.1-install/lib/libG4digits_hits.so 202 | tutorial: /home/steven/GEANT4/geant4.10.1-install/lib/libG4track.so 203 | tutorial: /home/steven/GEANT4/geant4.10.1-install/lib/libG4particles.so 204 | tutorial: /home/steven/GEANT4/geant4.10.1-install/lib/libG4geometry.so 205 | tutorial: /home/steven/GEANT4/geant4.10.1-install/lib/libG4geomUSolids.so 206 | tutorial: /home/steven/GEANT4/geant4.10.1-install/lib/libG4materials.so 207 | tutorial: /home/steven/GEANT4/geant4.10.1-install/lib/libG4graphics_reps.so 208 | tutorial: /home/steven/GEANT4/geant4.10.1-install/lib/libG4intercoms.so 209 | tutorial: /home/steven/GEANT4/geant4.10.1-install/lib/libG4global.so 210 | tutorial: /home/steven/GEANT4/geant4.10.1-install/lib/libG4clhep.so 211 | tutorial: CMakeFiles/tutorial.dir/link.txt 212 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --bold --progress-dir=/home/steven/GEANT4/Builds/tutorial/CMakeFiles --progress-num=$(CMAKE_PROGRESS_5) "Linking CXX executable tutorial" 213 | $(CMAKE_COMMAND) -E cmake_link_script CMakeFiles/tutorial.dir/link.txt --verbose=$(VERBOSE) 214 | 215 | # Rule to build all files generated by this target. 216 | CMakeFiles/tutorial.dir/build: tutorial 217 | 218 | .PHONY : CMakeFiles/tutorial.dir/build 219 | 220 | CMakeFiles/tutorial.dir/requires: CMakeFiles/tutorial.dir/tutorial.cpp.o.requires 221 | CMakeFiles/tutorial.dir/requires: CMakeFiles/tutorial.dir/src/PrimaryGeneratorAction.cpp.o.requires 222 | CMakeFiles/tutorial.dir/requires: CMakeFiles/tutorial.dir/src/PhysicsList.cpp.o.requires 223 | CMakeFiles/tutorial.dir/requires: CMakeFiles/tutorial.dir/src/DetectorConstruction.cpp.o.requires 224 | 225 | .PHONY : CMakeFiles/tutorial.dir/requires 226 | 227 | CMakeFiles/tutorial.dir/clean: 228 | $(CMAKE_COMMAND) -P CMakeFiles/tutorial.dir/cmake_clean.cmake 229 | .PHONY : CMakeFiles/tutorial.dir/clean 230 | 231 | CMakeFiles/tutorial.dir/depend: 232 | cd /home/steven/GEANT4/Builds/tutorial && $(CMAKE_COMMAND) -E cmake_depends "Unix Makefiles" /home/steven/GEANT4/Builds/tutorial /home/steven/GEANT4/Builds/tutorial /home/steven/GEANT4/Builds/tutorial /home/steven/GEANT4/Builds/tutorial /home/steven/GEANT4/Builds/tutorial/CMakeFiles/tutorial.dir/DependInfo.cmake --color=$(COLOR) 233 | .PHONY : CMakeFiles/tutorial.dir/depend 234 | 235 | -------------------------------------------------------------------------------- /tutorial1/CMakeFiles/tutorial.dir/cmake_clean.cmake: -------------------------------------------------------------------------------- 1 | file(REMOVE_RECURSE 2 | "CMakeFiles/tutorial.dir/tutorial.cpp.o" 3 | "CMakeFiles/tutorial.dir/src/PrimaryGeneratorAction.cpp.o" 4 | "CMakeFiles/tutorial.dir/src/PhysicsList.cpp.o" 5 | "CMakeFiles/tutorial.dir/src/DetectorConstruction.cpp.o" 6 | "tutorial.pdb" 7 | "tutorial" 8 | ) 9 | 10 | # Per-language clean rules from dependency scanning. 11 | foreach(lang CXX) 12 | include(CMakeFiles/tutorial.dir/cmake_clean_${lang}.cmake OPTIONAL) 13 | endforeach() 14 | -------------------------------------------------------------------------------- /tutorial1/CMakeFiles/tutorial.dir/depend.make: -------------------------------------------------------------------------------- 1 | # Empty dependencies file for tutorial. 2 | # This may be replaced when dependencies are built. 3 | -------------------------------------------------------------------------------- /tutorial1/CMakeFiles/tutorial.dir/flags.make: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" Generator, CMake Version 3.3 3 | 4 | # compile CXX with /usr/bin/c++ 5 | CXX_FLAGS = -W -Wall -pedantic -Wno-non-virtual-dtor -Wno-long-long -Wwrite-strings -Wpointer-arith -Woverloaded-virtual -Wno-variadic-macros -Wshadow -pipe -std=c++98 -isystem /home/steven/GEANT4/geant4.10.1-install/include/Geant4 -I/home/steven/GEANT4/Builds/tutorial/include 6 | 7 | CXX_DEFINES = -DG4INTY_USE_XT -DG4UI_USE -DG4UI_USE_TCSH -DG4VERBOSE -DG4VIS_USE -DG4VIS_USE_OPENGL -DG4VIS_USE_OPENGLX -DG4VIS_USE_RAYTRACERX -DG4_STORE_TRAJECTORY 8 | 9 | -------------------------------------------------------------------------------- /tutorial1/CMakeFiles/tutorial.dir/link.txt: -------------------------------------------------------------------------------- 1 | /usr/bin/c++ -W -Wall -pedantic -Wno-non-virtual-dtor -Wno-long-long -Wwrite-strings -Wpointer-arith -Woverloaded-virtual -Wno-variadic-macros -Wshadow -pipe -std=c++98 CMakeFiles/tutorial.dir/tutorial.cpp.o CMakeFiles/tutorial.dir/src/PrimaryGeneratorAction.cpp.o CMakeFiles/tutorial.dir/src/PhysicsList.cpp.o CMakeFiles/tutorial.dir/src/DetectorConstruction.cpp.o -o tutorial -rdynamic /home/steven/GEANT4/geant4.10.1-install/lib/libG4Tree.so /home/steven/GEANT4/geant4.10.1-install/lib/libG4GMocren.so /home/steven/GEANT4/geant4.10.1-install/lib/libG4visHepRep.so /home/steven/GEANT4/geant4.10.1-install/lib/libG4RayTracer.so /home/steven/GEANT4/geant4.10.1-install/lib/libG4VRML.so /home/steven/GEANT4/geant4.10.1-install/lib/libG4OpenGL.so /home/steven/GEANT4/geant4.10.1-install/lib/libG4gl2ps.so /home/steven/GEANT4/geant4.10.1-install/lib/libG4interfaces.so /home/steven/GEANT4/geant4.10.1-install/lib/libG4persistency.so /home/steven/GEANT4/geant4.10.1-install/lib/libG4analysis.so /home/steven/GEANT4/geant4.10.1-install/lib/libG4error_propagation.so /home/steven/GEANT4/geant4.10.1-install/lib/libG4readout.so /home/steven/GEANT4/geant4.10.1-install/lib/libG4physicslists.so /home/steven/GEANT4/geant4.10.1-install/lib/libG4parmodels.so /home/steven/GEANT4/geant4.10.1-install/lib/libG4FR.so /home/steven/GEANT4/geant4.10.1-install/lib/libG4vis_management.so /home/steven/GEANT4/geant4.10.1-install/lib/libG4modeling.so -lGLU -lGL -lSM -lICE -lX11 -lXext -lXmu /home/steven/GEANT4/geant4.10.1-install/lib/libG4run.so /home/steven/GEANT4/geant4.10.1-install/lib/libG4event.so /home/steven/GEANT4/geant4.10.1-install/lib/libG4tracking.so /home/steven/GEANT4/geant4.10.1-install/lib/libG4processes.so /home/steven/GEANT4/geant4.10.1-install/lib/libG4zlib.so -lexpat /home/steven/GEANT4/geant4.10.1-install/lib/libG4digits_hits.so /home/steven/GEANT4/geant4.10.1-install/lib/libG4track.so /home/steven/GEANT4/geant4.10.1-install/lib/libG4particles.so /home/steven/GEANT4/geant4.10.1-install/lib/libG4geometry.so /home/steven/GEANT4/geant4.10.1-install/lib/libG4geomUSolids.so /home/steven/GEANT4/geant4.10.1-install/lib/libG4materials.so /home/steven/GEANT4/geant4.10.1-install/lib/libG4graphics_reps.so /home/steven/GEANT4/geant4.10.1-install/lib/libG4intercoms.so /home/steven/GEANT4/geant4.10.1-install/lib/libG4global.so /home/steven/GEANT4/geant4.10.1-install/lib/libG4clhep.so -Wl,-rpath,/home/steven/GEANT4/geant4.10.1-install/lib: 2 | -------------------------------------------------------------------------------- /tutorial1/CMakeFiles/tutorial.dir/progress.make: -------------------------------------------------------------------------------- 1 | CMAKE_PROGRESS_1 = 1 2 | CMAKE_PROGRESS_2 = 2 3 | CMAKE_PROGRESS_3 = 3 4 | CMAKE_PROGRESS_4 = 4 5 | CMAKE_PROGRESS_5 = 5 6 | 7 | -------------------------------------------------------------------------------- /tutorial1/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Our minimum cmake list 2 | 3 | # Setup Project 4 | cmake_minimum_required(VERSION 2.6 FATAL_ERROR) 5 | project(tutorial) 6 | 7 | # Find Geant4 and activate ALL UI and vis drivers by default 8 | option(WITH_GEANT4_UIVIS "Build example with Geant4 UI and Vis drivers" ON) 9 | if(WITH_GEANT4_UIVIS) 10 | find_package(Geant4 REQUIRED ui_all vis_all) 11 | else() 12 | find_package(Geant4 REQUIRED) 13 | endif() 14 | 15 | # Setup include directories 16 | include(${Geant4_USE_FILE}) 17 | include_directories(${PROJECT_SOURCE_DIR}/include) 18 | 19 | # Locate the source and header files 20 | file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cpp) 21 | file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh) 22 | 23 | # Add exec and links the libraries 24 | add_executable(tutorial tutorial.cpp ${sources} ${headers}) 25 | target_link_libraries(tutorial ${Geant4_LIBRARIES}) 26 | 27 | # if you want to copy scripts over uncomment this section 28 | # set(TUTORIAL_SCRIPTS 29 | # tutorial.in 30 | # tutorial.out 31 | # init_vis.mac 32 | # run1.mac 33 | # run2.mac 34 | # vis.mac 35 | # ) 36 | # 37 | # foreach(_script ${TUTORIAL_SCRIPTS}) 38 | # configure_file( 39 | # ${PROJECT_SOURCE_DIR}/${_script} 40 | # ${PROJECT_BINARY_DIR}/${_script} 41 | # COPYONLY 42 | # ) 43 | # endforeach() 44 | 45 | # Install exec's to bin directory under CMAKE_INSTALL_PREFIX 46 | install(TARGETS tutorial DESTINATION bin) 47 | -------------------------------------------------------------------------------- /tutorial1/Makefile: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" Generator, CMake Version 3.3 3 | 4 | # Default target executed when no arguments are given to make. 5 | default_target: all 6 | 7 | .PHONY : default_target 8 | 9 | # Allow only one "make -f Makefile2" at a time, but pass parallelism. 10 | .NOTPARALLEL: 11 | 12 | 13 | #============================================================================= 14 | # Special targets provided by cmake. 15 | 16 | # Disable implicit rules so canonical targets will work. 17 | .SUFFIXES: 18 | 19 | 20 | # Remove some rules from gmake that .SUFFIXES does not remove. 21 | SUFFIXES = 22 | 23 | .SUFFIXES: .hpux_make_needs_suffix_list 24 | 25 | 26 | # Suppress display of executed commands. 27 | $(VERBOSE).SILENT: 28 | 29 | 30 | # A target that is always out of date. 31 | cmake_force: 32 | 33 | .PHONY : cmake_force 34 | 35 | #============================================================================= 36 | # Set environment variables for the build. 37 | 38 | # The shell in which to execute make rules. 39 | SHELL = /bin/sh 40 | 41 | # The CMake executable. 42 | CMAKE_COMMAND = /usr/bin/cmake 43 | 44 | # The command to remove a file. 45 | RM = /usr/bin/cmake -E remove -f 46 | 47 | # Escaping for special characters. 48 | EQUALS = = 49 | 50 | # The top-level source directory on which CMake was run. 51 | CMAKE_SOURCE_DIR = /home/steven/GEANT4/Builds/tutorial 52 | 53 | # The top-level build directory on which CMake was run. 54 | CMAKE_BINARY_DIR = /home/steven/GEANT4/Builds/tutorial 55 | 56 | #============================================================================= 57 | # Targets provided globally by CMake. 58 | 59 | # Special rule for the target install/strip 60 | install/strip: preinstall 61 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing the project stripped..." 62 | /usr/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake 63 | .PHONY : install/strip 64 | 65 | # Special rule for the target install/strip 66 | install/strip/fast: install/strip 67 | 68 | .PHONY : install/strip/fast 69 | 70 | # Special rule for the target edit_cache 71 | edit_cache: 72 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..." 73 | /usr/bin/ccmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) 74 | .PHONY : edit_cache 75 | 76 | # Special rule for the target edit_cache 77 | edit_cache/fast: edit_cache 78 | 79 | .PHONY : edit_cache/fast 80 | 81 | # Special rule for the target rebuild_cache 82 | rebuild_cache: 83 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..." 84 | /usr/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) 85 | .PHONY : rebuild_cache 86 | 87 | # Special rule for the target rebuild_cache 88 | rebuild_cache/fast: rebuild_cache 89 | 90 | .PHONY : rebuild_cache/fast 91 | 92 | # Special rule for the target install 93 | install: preinstall 94 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..." 95 | /usr/bin/cmake -P cmake_install.cmake 96 | .PHONY : install 97 | 98 | # Special rule for the target install 99 | install/fast: preinstall/fast 100 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..." 101 | /usr/bin/cmake -P cmake_install.cmake 102 | .PHONY : install/fast 103 | 104 | # Special rule for the target list_install_components 105 | list_install_components: 106 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Available install components are: \"Unspecified\"" 107 | .PHONY : list_install_components 108 | 109 | # Special rule for the target list_install_components 110 | list_install_components/fast: list_install_components 111 | 112 | .PHONY : list_install_components/fast 113 | 114 | # Special rule for the target install/local 115 | install/local: preinstall 116 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing only the local directory..." 117 | /usr/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake 118 | .PHONY : install/local 119 | 120 | # Special rule for the target install/local 121 | install/local/fast: install/local 122 | 123 | .PHONY : install/local/fast 124 | 125 | # The main all target 126 | all: cmake_check_build_system 127 | $(CMAKE_COMMAND) -E cmake_progress_start /home/steven/GEANT4/Builds/tutorial/CMakeFiles /home/steven/GEANT4/Builds/tutorial/CMakeFiles/progress.marks 128 | $(MAKE) -f CMakeFiles/Makefile2 all 129 | $(CMAKE_COMMAND) -E cmake_progress_start /home/steven/GEANT4/Builds/tutorial/CMakeFiles 0 130 | .PHONY : all 131 | 132 | # The main clean target 133 | clean: 134 | $(MAKE) -f CMakeFiles/Makefile2 clean 135 | .PHONY : clean 136 | 137 | # The main clean target 138 | clean/fast: clean 139 | 140 | .PHONY : clean/fast 141 | 142 | # Prepare targets for installation. 143 | preinstall: all 144 | $(MAKE) -f CMakeFiles/Makefile2 preinstall 145 | .PHONY : preinstall 146 | 147 | # Prepare targets for installation. 148 | preinstall/fast: 149 | $(MAKE) -f CMakeFiles/Makefile2 preinstall 150 | .PHONY : preinstall/fast 151 | 152 | # clear depends 153 | depend: 154 | $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 155 | .PHONY : depend 156 | 157 | #============================================================================= 158 | # Target rules for targets named tutorial 159 | 160 | # Build rule for target. 161 | tutorial: cmake_check_build_system 162 | $(MAKE) -f CMakeFiles/Makefile2 tutorial 163 | .PHONY : tutorial 164 | 165 | # fast build rule for target. 166 | tutorial/fast: 167 | $(MAKE) -f CMakeFiles/tutorial.dir/build.make CMakeFiles/tutorial.dir/build 168 | .PHONY : tutorial/fast 169 | 170 | src/DetectorConstruction.o: src/DetectorConstruction.cpp.o 171 | 172 | .PHONY : src/DetectorConstruction.o 173 | 174 | # target to build an object file 175 | src/DetectorConstruction.cpp.o: 176 | $(MAKE) -f CMakeFiles/tutorial.dir/build.make CMakeFiles/tutorial.dir/src/DetectorConstruction.cpp.o 177 | .PHONY : src/DetectorConstruction.cpp.o 178 | 179 | src/DetectorConstruction.i: src/DetectorConstruction.cpp.i 180 | 181 | .PHONY : src/DetectorConstruction.i 182 | 183 | # target to preprocess a source file 184 | src/DetectorConstruction.cpp.i: 185 | $(MAKE) -f CMakeFiles/tutorial.dir/build.make CMakeFiles/tutorial.dir/src/DetectorConstruction.cpp.i 186 | .PHONY : src/DetectorConstruction.cpp.i 187 | 188 | src/DetectorConstruction.s: src/DetectorConstruction.cpp.s 189 | 190 | .PHONY : src/DetectorConstruction.s 191 | 192 | # target to generate assembly for a file 193 | src/DetectorConstruction.cpp.s: 194 | $(MAKE) -f CMakeFiles/tutorial.dir/build.make CMakeFiles/tutorial.dir/src/DetectorConstruction.cpp.s 195 | .PHONY : src/DetectorConstruction.cpp.s 196 | 197 | src/PhysicsList.o: src/PhysicsList.cpp.o 198 | 199 | .PHONY : src/PhysicsList.o 200 | 201 | # target to build an object file 202 | src/PhysicsList.cpp.o: 203 | $(MAKE) -f CMakeFiles/tutorial.dir/build.make CMakeFiles/tutorial.dir/src/PhysicsList.cpp.o 204 | .PHONY : src/PhysicsList.cpp.o 205 | 206 | src/PhysicsList.i: src/PhysicsList.cpp.i 207 | 208 | .PHONY : src/PhysicsList.i 209 | 210 | # target to preprocess a source file 211 | src/PhysicsList.cpp.i: 212 | $(MAKE) -f CMakeFiles/tutorial.dir/build.make CMakeFiles/tutorial.dir/src/PhysicsList.cpp.i 213 | .PHONY : src/PhysicsList.cpp.i 214 | 215 | src/PhysicsList.s: src/PhysicsList.cpp.s 216 | 217 | .PHONY : src/PhysicsList.s 218 | 219 | # target to generate assembly for a file 220 | src/PhysicsList.cpp.s: 221 | $(MAKE) -f CMakeFiles/tutorial.dir/build.make CMakeFiles/tutorial.dir/src/PhysicsList.cpp.s 222 | .PHONY : src/PhysicsList.cpp.s 223 | 224 | src/PrimaryGeneratorAction.o: src/PrimaryGeneratorAction.cpp.o 225 | 226 | .PHONY : src/PrimaryGeneratorAction.o 227 | 228 | # target to build an object file 229 | src/PrimaryGeneratorAction.cpp.o: 230 | $(MAKE) -f CMakeFiles/tutorial.dir/build.make CMakeFiles/tutorial.dir/src/PrimaryGeneratorAction.cpp.o 231 | .PHONY : src/PrimaryGeneratorAction.cpp.o 232 | 233 | src/PrimaryGeneratorAction.i: src/PrimaryGeneratorAction.cpp.i 234 | 235 | .PHONY : src/PrimaryGeneratorAction.i 236 | 237 | # target to preprocess a source file 238 | src/PrimaryGeneratorAction.cpp.i: 239 | $(MAKE) -f CMakeFiles/tutorial.dir/build.make CMakeFiles/tutorial.dir/src/PrimaryGeneratorAction.cpp.i 240 | .PHONY : src/PrimaryGeneratorAction.cpp.i 241 | 242 | src/PrimaryGeneratorAction.s: src/PrimaryGeneratorAction.cpp.s 243 | 244 | .PHONY : src/PrimaryGeneratorAction.s 245 | 246 | # target to generate assembly for a file 247 | src/PrimaryGeneratorAction.cpp.s: 248 | $(MAKE) -f CMakeFiles/tutorial.dir/build.make CMakeFiles/tutorial.dir/src/PrimaryGeneratorAction.cpp.s 249 | .PHONY : src/PrimaryGeneratorAction.cpp.s 250 | 251 | tutorial.o: tutorial.cpp.o 252 | 253 | .PHONY : tutorial.o 254 | 255 | # target to build an object file 256 | tutorial.cpp.o: 257 | $(MAKE) -f CMakeFiles/tutorial.dir/build.make CMakeFiles/tutorial.dir/tutorial.cpp.o 258 | .PHONY : tutorial.cpp.o 259 | 260 | tutorial.i: tutorial.cpp.i 261 | 262 | .PHONY : tutorial.i 263 | 264 | # target to preprocess a source file 265 | tutorial.cpp.i: 266 | $(MAKE) -f CMakeFiles/tutorial.dir/build.make CMakeFiles/tutorial.dir/tutorial.cpp.i 267 | .PHONY : tutorial.cpp.i 268 | 269 | tutorial.s: tutorial.cpp.s 270 | 271 | .PHONY : tutorial.s 272 | 273 | # target to generate assembly for a file 274 | tutorial.cpp.s: 275 | $(MAKE) -f CMakeFiles/tutorial.dir/build.make CMakeFiles/tutorial.dir/tutorial.cpp.s 276 | .PHONY : tutorial.cpp.s 277 | 278 | # Help Target 279 | help: 280 | @echo "The following are some of the valid targets for this Makefile:" 281 | @echo "... all (the default if no target is provided)" 282 | @echo "... clean" 283 | @echo "... depend" 284 | @echo "... install/strip" 285 | @echo "... edit_cache" 286 | @echo "... rebuild_cache" 287 | @echo "... install" 288 | @echo "... tutorial" 289 | @echo "... list_install_components" 290 | @echo "... install/local" 291 | @echo "... src/DetectorConstruction.o" 292 | @echo "... src/DetectorConstruction.i" 293 | @echo "... src/DetectorConstruction.s" 294 | @echo "... src/PhysicsList.o" 295 | @echo "... src/PhysicsList.i" 296 | @echo "... src/PhysicsList.s" 297 | @echo "... src/PrimaryGeneratorAction.o" 298 | @echo "... src/PrimaryGeneratorAction.i" 299 | @echo "... src/PrimaryGeneratorAction.s" 300 | @echo "... tutorial.o" 301 | @echo "... tutorial.i" 302 | @echo "... tutorial.s" 303 | .PHONY : help 304 | 305 | 306 | 307 | #============================================================================= 308 | # Special targets to cleanup operation of make. 309 | 310 | # Special rule to run CMake to check the build system integrity. 311 | # No rule that depends on this can have commands that come from listfiles 312 | # because they might be regenerated. 313 | cmake_check_build_system: 314 | $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 315 | .PHONY : cmake_check_build_system 316 | 317 | -------------------------------------------------------------------------------- /tutorial1/README.md: -------------------------------------------------------------------------------- 1 | # Tutorial 1 2 | It is important to note that we do not want to cmake our tutorials in the source directory. Thus we create the build directory and cmake from there. 3 | 4 | If you are in tutorial-build, then you can run the command 5 | ``` 6 | cmake ../tutorial1 7 | ``` 8 | Then you will want to make the file, which can be done with 9 | ``` 10 | make -j# 11 | ``` 12 | Where you want to replace "#" with the number of processors you want to make with. In these tutorials you don't really have to use the j flag because the programs are simple, but it is good to know for later when you master Geant and you need to make larger programs. 13 | 14 | What is in this tutorial 15 | ------------------------ 16 | We go through (almost) the MOST basic example I can think of making. The files we need are 17 | 18 | - main.cpp 19 | - DetectorConstruction 20 | - PhysicsList 21 | - PrimaryGeneratorAction 22 | - CMakeLists.txt 23 | 24 | Note that these files are MANDATORY! You can combine all the c++ files together, but it is not suggested, stay organized. 25 | 26 | In our DetectorConstruction file you will see how we define materials (multiple ways), and create a world box as well as a small physical box inside. We are filling the entire world with Air and the box with water. 27 | 28 | Tips for playing around 29 | ------------- 30 | Remember that cout and endl in geant are G4cout and G4endl. 31 | - Try to figure out how to print the materials table. 32 | - Why did I comment out the liquid Argon? Is it a problem if you don't? 33 | - See if using `G4UniformRand()` you can make the beams come from an incident plane instead of a point. 34 | -------------------------------------------------------------------------------- /tutorial1/include/DetectorConstruction.hh: -------------------------------------------------------------------------------- 1 | /* Need our required Detector construction header */ 2 | #ifndef DetectorConstruction_h 3 | #define DetectorConstruction_h 1 4 | 5 | #include "G4VUserDetectorConstruction.hh" 6 | #include "globals.hh" 7 | 8 | // These two classes are called within the construct function 9 | class G4VPhysicalVolume; 10 | class G4LogicalVolume; 11 | 12 | class DetectorConstruction : public G4VUserDetectorConstruction 13 | { 14 | public: 15 | DetectorConstruction(); 16 | virtual ~DetectorConstruction(); 17 | virtual G4VPhysicalVolume* Construct(); 18 | 19 | private: 20 | void DefineMaterials(); 21 | }; 22 | #endif 23 | -------------------------------------------------------------------------------- /tutorial1/include/PhysicsList.hh: -------------------------------------------------------------------------------- 1 | /* Our Physics List header */ 2 | #ifndef PhysicsList_h 3 | #define PhysicsList_h 1 4 | 5 | #include "G4VModularPhysicsList.hh" 6 | 7 | class PhysicsList : public G4VModularPhysicsList 8 | { 9 | public: 10 | PhysicsList(); 11 | ~PhysicsList(); 12 | 13 | virtual void SetCuts(); 14 | 15 | }; 16 | #endif 17 | -------------------------------------------------------------------------------- /tutorial1/include/PrimaryGeneratorAction.hh: -------------------------------------------------------------------------------- 1 | /* We have to have a .hh file for our primary generator action file */ 2 | #ifndef PrimaryGeneratorAction_h 3 | #define PrimaryGeneratorAction_h 1 4 | 5 | #include "G4VUserPrimaryGeneratorAction.hh" //This is a Geant file, not created by user 6 | 7 | class G4ParticleGun; 8 | class G4Event; 9 | 10 | class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction 11 | { 12 | public: 13 | PrimaryGeneratorAction(); 14 | virtual ~PrimaryGeneratorAction(); // We must be able to destroy what we can create 15 | 16 | public: 17 | virtual void GeneratePrimaries(G4Event*); // See .cpp file 18 | 19 | const G4ParticleGun* GetParticleGun() const { return particleGun;} 20 | 21 | 22 | private: 23 | G4ParticleGun* particleGun; 24 | 25 | }; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /tutorial1/src/DetectorConstruction.cpp: -------------------------------------------------------------------------------- 1 | /******* We will create the most basics of a detector construction file ********/ 2 | /*** 3 | * To do this we will create a world box and place another box inside it and fill it. We need 4 | * to create the logical volume, use the solid, and add other attributes (like composition) 5 | * ***/ 6 | 7 | #include "DetectorConstruction.hh" 8 | #include "G4NistManager.hh" // Contains the NIST data for particles 9 | #include "G4Box.hh" // Needed to create box shapes 10 | #include "G4LogicalVolume.hh" // Will be required in every Detector construction file 11 | #include "G4PVPlacement.hh" 12 | #include "G4RotationMatrix.hh" 13 | #include "G4Transform3D.hh" 14 | #include "G4PhysicalConstants.hh" 15 | #include "G4SystemOfUnits.hh" 16 | 17 | // Our initial constructor 18 | DetectorConstruction::DetectorConstruction() 19 | : G4VUserDetectorConstruction() 20 | { 21 | DefineMaterials(); // Whenever we create a world and volume we want to have materials 22 | } 23 | 24 | // Create virtual 25 | DetectorConstruction::~DetectorConstruction() 26 | {} // Don't need to destruct anything, but we keep good habits 27 | 28 | void DetectorConstruction::DefineMaterials() 29 | { 30 | G4NistManager* man = G4NistManager::Instance(); // Calls the NIST manager 31 | // The NIST manager will populate the materials in proportions of abundance. If we 32 | // want to work with pure materials then we should turn isotopes off 33 | G4bool isotopes = false; 34 | 35 | /** 36 | * G4Element class has properties: Atomic number, number of nucleons, atomic mass, shell energy, cross section per atom, etc 37 | * G4Material has macroscopic properties: density, state, temperature, pressure, radiation length, mean free path, dE/dx, etc 38 | */ 39 | 40 | /* Define simple material */ 41 | // G4double density = 1.390 * g/cm3; 42 | // G4double a = 39.95 * g/mole; 43 | // G4Material* lAr = new G4Material("liquidArgon", // Name 44 | // 18., // Z value 45 | // a, // atomic mass 46 | // density); // That thing 47 | // 48 | 49 | /* Define a simple molecule */ 50 | // Here we are telling GEANT to do a lookup in the NIST tables for Hydrogen 51 | G4Element* H = man -> FindOrBuildElement("H", isotopes); // another way of adding elements. 52 | G4Element* O = man -> FindOrBuildElement("O", isotopes); 53 | 54 | // We will then want to create the water molecule with our defined properties 55 | G4Material* H2O = new G4Material("Water", // name 56 | 1.000 * g/cm3, // density 57 | 2); // number of components 58 | // We then need to tell GEANT what elements are in the molecule and in what 59 | // proportions 60 | H2O -> AddElement(H, 2); 61 | H2O -> AddElement(O, 1); 62 | 63 | /* Define mixture by fractional mass */ 64 | G4Element* N = man -> FindOrBuildElement("N", isotopes); 65 | G4double density = 1.290 * mg/cm3; 66 | G4Material* Air = new G4Material("Air", density, 2); 67 | Air -> AddElement(N, 70*perCent); 68 | Air -> AddElement(O, 30*perCent); 69 | // Note that GEANT already has predefined Air and Water that can be called so we don't 70 | // have to create them each time, but we're being explicit here 71 | } 72 | 73 | 74 | 75 | // Now we will be creating the actual world and object inside the world here 76 | G4VPhysicalVolume* DetectorConstruction::Construct() 77 | { 78 | 79 | // Same as above 80 | G4NistManager* man = G4NistManager::Instance(); 81 | // This time the manager will find the materials we created above 82 | G4Material* default_mat = man -> FindOrBuildMaterial("Air"); 83 | G4Material* box_mat = man -> FindOrBuildMaterial("Water"); 84 | 85 | /*** FIRST create the WORLD ***/ 86 | G4double worldSize = 1 * m; 87 | G4Box* solidWorld = new G4Box("World", worldSize, worldSize, worldSize); 88 | G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, default_mat, "World"); 89 | G4VPhysicalVolume* physWorld = new G4PVPlacement(0, G4ThreeVector(), logicWorld, "World", 0, false, 0); 90 | 91 | /* to create a solid box we do the following */ 92 | G4double Box_x = 0.5*m; // Note that these are HALF LENGTHS 93 | G4double Box_y = 0.5*m; 94 | G4double Box_z = 0.5*m; 95 | // creates a 1x1x1 m box, from -0.5 to 0.5 on each side of the axies 96 | 97 | // first we need to create outline 98 | G4Box* testBox = new G4Box("testBox", // Name 99 | Box_x, // x length 100 | Box_y, // y length 101 | Box_z); // z length 102 | 103 | /** Create a logical volume **/ 104 | G4LogicalVolume* testBox_log = new G4LogicalVolume(testBox, // Its solid (see the box we made) 105 | box_mat, // Its material 106 | "testBox"); // Its name 107 | 108 | /** Create the Physical Volume **/ 109 | /** Physical volume is a placed instance of the logical volume. We'll place it in 110 | * its mother logical volume **/ 111 | G4VPhysicalVolume* testBox_phy = new G4PVPlacement(0, // Rotation 112 | G4ThreeVector(), // its location 113 | testBox_log, // the logical volume 114 | "testBox", // its name 115 | logicWorld, // its mother volume 116 | false, // boolean operations 117 | 0); // its copy number 118 | 119 | return physWorld; // Always return the world 120 | } 121 | -------------------------------------------------------------------------------- /tutorial1/src/PhysicsList.cpp: -------------------------------------------------------------------------------- 1 | /* Second REQUIRED file (Detector Construction, Primary Generator Action) */ 2 | #include "PhysicsList.hh" 3 | 4 | // Our basic physics packages needed to do simple decay 5 | #include "G4DecayPhysics.hh" 6 | #include "G4RadioactiveDecayPhysics.hh" 7 | #include "G4EmStandardPhysics.hh" 8 | 9 | PhysicsList::PhysicsList() 10 | : G4VModularPhysicsList() 11 | { 12 | //setVerboseLevel(1); 13 | 14 | /* 15 | * All we have to do is tell GEANT4 that we are using these lists 16 | */ 17 | // Default physics 18 | RegisterPhysics(new G4DecayPhysics()); 19 | 20 | // Radioactive Decay 21 | RegisterPhysics(new G4RadioactiveDecayPhysics()); 22 | 23 | // E&M physics 24 | RegisterPhysics(new G4EmStandardPhysics()); 25 | } 26 | 27 | PhysicsList::~PhysicsList() 28 | {} 29 | 30 | /* 31 | * Cuts are a threshold value at which a secondary will not be created. From the 32 | * documentation they note that this is because some of the elctromagnetic processes 33 | * will create infrared divergence if this is not set. There is also a max threshold 34 | * energy set at 10 GeV and can be changed by running "/cuts/setMaxCutEnergy" in the 35 | * command line of the run. 36 | * 37 | * We will just keep the defaults 38 | */ 39 | void PhysicsList::SetCuts() 40 | { 41 | G4VUserPhysicsList::SetCuts(); 42 | } 43 | -------------------------------------------------------------------------------- /tutorial1/src/PrimaryGeneratorAction.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Remember to use the header file in the /include folder 3 | * This is the third REQUIRED file (Detector Const, and Phys list) 4 | */ 5 | 6 | #include "PrimaryGeneratorAction.hh" 7 | 8 | // Now to create some events in our world 9 | #include "G4Event.hh" 10 | #include "G4ParticleGun.hh" 11 | #include "G4ThreeVector.hh" 12 | #include "G4Geantino.hh" 13 | #include "globals.hh" 14 | #include "G4SystemOfUnits.hh" 15 | 16 | /* We'll use the Geantino (non-interacting particle) for the gun, can be changed. 17 | * This particle is generally used for testing. Think of it as similar to a neutrino. 18 | * 19 | * In our gun design all particles will fire from a stationary spot 20 | * */ 21 | PrimaryGeneratorAction::PrimaryGeneratorAction() 22 | { 23 | G4int n_particle = 1; // Number of particles fired per beamOn run 24 | particleGun = new G4ParticleGun(n_particle); // creation of particle gun 25 | 26 | particleGun -> SetParticleDefinition(G4Geantino::GeantinoDefinition()); // Use Geantino as firing particle 27 | // 1GeV energy of gun, this can be changed from the command line 28 | particleGun -> SetParticleEnergy(1.0 * GeV); 29 | particleGun -> SetParticlePosition(G4ThreeVector(-1.*m, 0.*m, 0.*m)); // Set gun to be at furthest x in world (far left to standard orientation) 30 | } 31 | 32 | // Create destructor 33 | PrimaryGeneratorAction::~PrimaryGeneratorAction() 34 | { 35 | delete particleGun; 36 | } 37 | 38 | // Primary event 39 | void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) 40 | { 41 | particleGun -> SetParticleMomentumDirection(G4ThreeVector(1.0,0.,0.)); // Pure x momentum 42 | 43 | particleGun -> GeneratePrimaryVertex(anEvent); // creates the initial momentum 44 | } 45 | -------------------------------------------------------------------------------- /tutorial1/tutorial.cpp: -------------------------------------------------------------------------------- 1 | /***** The most basic main file ****/ 2 | 3 | // Our required includes 4 | #include "G4RunManager.hh" 5 | #include "G4UImanager.hh" 6 | 7 | // Classes we will be pulling from for our construction 8 | #include "DetectorConstruction.hh" 9 | #include "PhysicsList.hh" 10 | #include "PrimaryGeneratorAction.hh" 11 | 12 | // add "int argc, char** argv" to int main if you'd like to run arguments 13 | int main() 14 | { 15 | // Construct the default run manager 16 | // App Dev Guide notes that this is the ONLY manager class in G4 kernel that should be explicitly constructed in main() 17 | G4RunManager* runManager = new G4RunManager; 18 | 19 | // Create visualization manager (Not NEEDED, but useful) 20 | //G4VisManager* visManager = VisManager; 21 | //visManager -> initialize(); 22 | 23 | // Set MANDATORY initialization classes 24 | runManager -> SetUserInitialization(new DetectorConstruction); 25 | runManager -> SetUserInitialization(new PhysicsList); 26 | 27 | // Set MANDATORY user action class 28 | runManager -> SetUserAction(new PrimaryGeneratorAction); 29 | 30 | // Run the kernel 31 | runManager -> Initialize(); 32 | 33 | // get pointer to UI manager and set verbosities 34 | G4UImanager* UI = G4UImanager::GetUIpointer(); 35 | UI -> ApplyCommand("/run/verbose 1"); 36 | UI -> ApplyCommand("/event/verbose 1"); 37 | UI -> ApplyCommand("/tracking/verbose 1"); 38 | 39 | // start a run 40 | int numberOfEvents = 3; 41 | runManager -> BeamOn(numberOfEvents); 42 | 43 | // TERMINATE job 44 | // Remember to always clean up. Any time we create something with new we should delete it 45 | delete runManager; 46 | //delete visManager; 47 | return 0; 48 | } 49 | /***************** 50 | * DETECTOR CONSTRUCTION specifies GEOMETRY, MATERIALS, SENSITIVE REGIONS, and READOUT schemes of sensitive regions 51 | * PARTICLE LIST (from G4VUserPhysicsList) requires user define PARTICLES being used, RANGE CUTS for particles, and ALL PHYSICS PROCESSES to be simulated 52 | * 53 | * GEANT does not check for mandatory classes till initialize() and BeamOn() are invoked 54 | * 55 | * OPTIONAL USER CLASSES 56 | * UserRunAction, EventAction, StackingAction, TrackingAction, SteppingAction 57 | ******************/ 58 | -------------------------------------------------------------------------------- /tutorial2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Our minimum cmake list 2 | 3 | # Setup Project 4 | cmake_minimum_required(VERSION 2.6 FATAL_ERROR) 5 | project(tutorial2) 6 | 7 | # Find Geant4 and activate ALL UI and vis drivers by default 8 | option(WITH_GEANT4_UIVIS "Build example with Geant4 UI and Vis drivers" ON) 9 | if(WITH_GEANT4_UIVIS) 10 | find_package(Geant4 REQUIRED ui_all vis_all) 11 | else() 12 | find_package(Geant4 REQUIRED) 13 | endif() 14 | 15 | # Setup include directories 16 | include(${Geant4_USE_FILE}) 17 | include_directories(${PROJECT_SOURCE_DIR}/include) 18 | 19 | # Locate the source and header files 20 | file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cpp) 21 | file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh) 22 | 23 | # Add exec and links the libraries 24 | add_executable(tutorial2 tutorial2.cpp ${sources} ${headers}) 25 | target_link_libraries(tutorial2 ${Geant4_LIBRARIES}) 26 | 27 | # if you want to copy scripts over uncomment this section 28 | set(TUTORIAL_SCRIPTS 29 | # tutorial.in 30 | # tutorial.out 31 | init_vis.mac 32 | # run1.mac 33 | # run2.mac 34 | vis.mac 35 | ) 36 | # 37 | foreach(_script ${TUTORIAL_SCRIPTS}) 38 | configure_file( 39 | ${PROJECT_SOURCE_DIR}/${_script} 40 | ${PROJECT_BINARY_DIR}/${_script} 41 | COPYONLY 42 | ) 43 | endforeach() 44 | 45 | # Install exec's to bin directory under CMAKE_INSTALL_PREFIX 46 | install(TARGETS tutorial2 DESTINATION bin) 47 | -------------------------------------------------------------------------------- /tutorial2/README.md: -------------------------------------------------------------------------------- 1 | # Tutorial 2: Visualization 2 | In this tutorial we make it possible to visualize the trajectory of the Geantino that we are firing (a noninteracting particle used for testing). 3 | 4 | I use the OpenGL library to visualize this, if you do not have this library then please see the User's Guide, or look at one of the other examples (vis.mac) to see how they use another driver. Remember to make sure that Geant has that library turned on. Remember that you can always go back to the build library and cmake with new flags. 5 | 6 | What's new in this tutorial 7 | --------------------- 8 | In this tutorial we have changed our CMakeLists.txt file and added init vis.mac and vis.mac files to open the visualizer. 9 | 10 | I do get a weird memory error when running OGL, so what I do to work around this is just give it a memory with a large number. 11 | -------------------------------------------------------------------------------- /tutorial2/include/DetectorConstruction.hh: -------------------------------------------------------------------------------- 1 | /* Need our required Detector construction header */ 2 | #ifndef DetectorConstruction_h 3 | #define DetectorConstruction_h 1 4 | 5 | #include "G4VUserDetectorConstruction.hh" 6 | #include "globals.hh" 7 | 8 | class G4VPhysicalVolume; 9 | class G4LogicalVolume; 10 | 11 | class DetectorConstruction : public G4VUserDetectorConstruction 12 | { 13 | public: 14 | DetectorConstruction(); 15 | virtual ~DetectorConstruction(); 16 | 17 | public: 18 | virtual G4VPhysicalVolume* Construct(); 19 | 20 | private: 21 | void DefineMaterials(); 22 | }; 23 | #endif 24 | -------------------------------------------------------------------------------- /tutorial2/include/PhysicsList.hh: -------------------------------------------------------------------------------- 1 | /* Our Physics List header */ 2 | #ifndef PhysicsList_h 3 | #define PhysicsList_h 1 4 | 5 | #include "G4VModularPhysicsList.hh" 6 | 7 | /* G4VModularPhysicsList includes: 8 | * G4DecayPhysics (default) 9 | * G4RadioActiveDecayPhysics 10 | * G4EmStandardPhysics 11 | * 12 | * Which are used in the .cpp file 13 | */ 14 | 15 | class PhysicsList : public G4VModularPhysicsList 16 | { 17 | public: 18 | PhysicsList(); 19 | ~PhysicsList(); 20 | 21 | virtual void SetCuts(); 22 | 23 | }; 24 | #endif 25 | -------------------------------------------------------------------------------- /tutorial2/include/PrimaryGeneratorAction.hh: -------------------------------------------------------------------------------- 1 | /* We have to have a .hh file for our primary generator action file */ 2 | #ifndef PrimaryGeneratorAction_h 3 | #define PrimaryGeneratorAction_h 1 4 | 5 | #include "G4VUserPrimaryGeneratorAction.hh" 6 | 7 | class G4ParticleGun; 8 | class G4Event; 9 | 10 | class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction 11 | { 12 | public: 13 | PrimaryGeneratorAction(); 14 | virtual ~PrimaryGeneratorAction(); 15 | 16 | public: 17 | virtual void GeneratePrimaries(G4Event*); 18 | 19 | const G4ParticleGun* GetParticleGun() const { return particleGun;} 20 | 21 | 22 | private: 23 | G4ParticleGun* particleGun; 24 | 25 | }; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /tutorial2/init_vis.mac: -------------------------------------------------------------------------------- 1 | # Macro file for tutorial 2 2 | # Let's make an interactive session 3 | # Set some default verbose 4 | /control/verbose 2 5 | /control/saveHistory 6 | /run/verbose 2 7 | 8 | # Initialize kernel 9 | /run/initialize 10 | 11 | # Visualization setting 12 | /control/execute vis.mac 13 | -------------------------------------------------------------------------------- /tutorial2/src/DetectorConstruction.cpp: -------------------------------------------------------------------------------- 1 | #include "DetectorConstruction.hh" 2 | 3 | #include "G4NistManager.hh" 4 | #include "G4Box.hh" 5 | #include "G4LogicalVolume.hh" 6 | #include "G4PVPlacement.hh" 7 | #include "G4RotationMatrix.hh" 8 | #include "G4Transform3D.hh" 9 | #include "G4PhysicalConstants.hh" 10 | #include "G4SystemOfUnits.hh" 11 | 12 | DetectorConstruction::DetectorConstruction() 13 | : G4VUserDetectorConstruction() 14 | { 15 | DefineMaterials(); 16 | } 17 | 18 | DetectorConstruction::~DetectorConstruction() 19 | {} 20 | 21 | void DetectorConstruction::DefineMaterials() 22 | { 23 | G4NistManager* man = G4NistManager::Instance(); 24 | G4bool isotopes = false; 25 | 26 | G4Element* H = man -> FindOrBuildElement("H", isotopes); 27 | G4Element* O = man -> FindOrBuildElement("O", isotopes); 28 | 29 | G4Material* H2O = new G4Material("Water", // name 30 | 1.000 * g/cm3, // density 31 | 2); // number of components 32 | H2O -> AddElement(H, 2); 33 | H2O -> AddElement(O, 1); 34 | 35 | /* Define mixture by fractional mass */ 36 | G4Element* N = man -> FindOrBuildElement("N", isotopes); 37 | G4double density = 1.290 * mg/cm3; 38 | G4Material* Air = new G4Material("Air", density, 2); 39 | Air -> AddElement(N, 70*perCent); 40 | Air -> AddElement(O, 30*perCent); 41 | } 42 | 43 | 44 | 45 | G4VPhysicalVolume* DetectorConstruction::Construct() 46 | { 47 | 48 | G4NistManager* nist = G4NistManager::Instance(); 49 | G4Material* default_mat = nist -> FindOrBuildMaterial("Air"); 50 | G4Material* box_mat = nist -> FindOrBuildMaterial("Water"); 51 | 52 | /*** FIRST create the WORLD ***/ 53 | G4double worldSize = 1 * m; 54 | G4Box* solidWorld = new G4Box("World", worldSize, worldSize, worldSize); 55 | G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, default_mat, "World"); 56 | G4VPhysicalVolume* physWorld = new G4PVPlacement(0, G4ThreeVector(), logicWorld, "World", 0, false, 0); 57 | 58 | G4double Box_x = 0.5*m; // Note that these are HALF LENGTHS 59 | G4double Box_y = 0.5*m; 60 | G4double Box_z = 0.5*m; 61 | 62 | G4Box* testBox = new G4Box("testBox", // Name 63 | Box_x, // x length 64 | Box_y, // y length 65 | Box_z); // z length 66 | 67 | G4LogicalVolume* testBox_log = new G4LogicalVolume(testBox, 68 | box_mat, // Its material 69 | "testBox"); // Its name 70 | 71 | /** Create the Physical Volume **/ 72 | G4VPhysicalVolume* testBox_phy = new G4PVPlacement(0, // Rotation 73 | G4ThreeVector(), // its location 74 | testBox_log, // the logical volume 75 | "testBox", // its name 76 | logicWorld, // its mother volume 77 | false, // boolean operations 78 | 0); // its copy number 79 | 80 | return physWorld; // Always return the world 81 | } 82 | -------------------------------------------------------------------------------- /tutorial2/src/PhysicsList.cpp: -------------------------------------------------------------------------------- 1 | #include "PhysicsList.hh" 2 | 3 | #include "G4DecayPhysics.hh" 4 | #include "G4RadioactiveDecayPhysics.hh" 5 | #include "G4EmStandardPhysics.hh" 6 | 7 | PhysicsList::PhysicsList() 8 | : G4VModularPhysicsList() 9 | { 10 | RegisterPhysics(new G4DecayPhysics()); 11 | RegisterPhysics(new G4RadioactiveDecayPhysics()); 12 | RegisterPhysics(new G4EmStandardPhysics()); 13 | } 14 | 15 | PhysicsList::~PhysicsList() 16 | {} 17 | 18 | void PhysicsList::SetCuts() 19 | { 20 | G4VUserPhysicsList::SetCuts(); 21 | } 22 | -------------------------------------------------------------------------------- /tutorial2/src/PrimaryGeneratorAction.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Remember to use the header file in the /include folder 3 | * This is the third REQUIRED file (Detector Const, and Phys list) 4 | */ 5 | 6 | #include "PrimaryGeneratorAction.hh" 7 | #include "G4Event.hh" 8 | #include "G4ParticleGun.hh" 9 | #include "G4ThreeVector.hh" 10 | #include "G4Geantino.hh" 11 | #include "globals.hh" 12 | #include "G4SystemOfUnits.hh" 13 | 14 | PrimaryGeneratorAction::PrimaryGeneratorAction() 15 | { 16 | G4int n_particle = 1; 17 | particleGun = new G4ParticleGun(n_particle); 18 | 19 | particleGun -> SetParticleDefinition(G4Geantino::GeantinoDefinition()); 20 | particleGun -> SetParticleEnergy(1.0 * MeV); 21 | particleGun -> SetParticlePosition(G4ThreeVector(-1.*m, 0.*m, 0.*m)); 22 | } 23 | 24 | // Create destructor 25 | PrimaryGeneratorAction::~PrimaryGeneratorAction() 26 | { 27 | delete particleGun; 28 | } 29 | 30 | // Primary event 31 | void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) 32 | { 33 | particleGun -> SetParticleMomentumDirection(G4ThreeVector(1.0,0.,0.)); 34 | 35 | particleGun -> GeneratePrimaryVertex(anEvent); 36 | } 37 | -------------------------------------------------------------------------------- /tutorial2/tutorial2.cpp: -------------------------------------------------------------------------------- 1 | #include "G4RunManager.hh" 2 | #include "G4UImanager.hh" 3 | #include "G4VisExecutive.hh" 4 | #include "G4UIExecutive.hh" 5 | #include "DetectorConstruction.hh" 6 | #include "PhysicsList.hh" 7 | #include "PrimaryGeneratorAction.hh" 8 | 9 | int main(int argc, char** argv) 10 | { 11 | G4RunManager* runManager = new G4RunManager; 12 | 13 | G4UIExecutive* ui = new G4UIExecutive(argc, argv); 14 | // Create visualization manager 15 | G4VisManager* visManager = new G4VisExecutive; 16 | visManager -> Initialize(); 17 | 18 | // Set MANDATORY initialization classes 19 | runManager -> SetUserInitialization(new DetectorConstruction); 20 | runManager -> SetUserInitialization(new PhysicsList); 21 | 22 | // Set MANDATORY user action class 23 | runManager -> SetUserAction(new PrimaryGeneratorAction); 24 | 25 | // Run the kernel 26 | runManager -> Initialize(); 27 | 28 | // get pointer to UI manager and set verbosities 29 | G4UImanager* UI = G4UImanager::GetUIpointer(); 30 | UI -> ApplyCommand("/control/execute init_vis.mac"); 31 | ui -> SessionStart(); 32 | delete ui; 33 | 34 | // start a run 35 | int numberOfEvents = 3; 36 | runManager -> BeamOn(numberOfEvents); 37 | 38 | // Cleanup 39 | delete runManager; 40 | delete visManager; 41 | 42 | return 0; 43 | } 44 | 45 | /* 46 | * DETECTOR CONSTRUCTION specifies GEOMETRY, MATERIALS, SENSITIVE REGIONS, and READOUT schemes of sensitive regions 47 | * PARTICLE LIST (from G4VUserPhysicsList) requires user define PARTICLES being used, RANGE CUTS for particles, and ALL PHYSICS PROCESSES to be simulated 48 | * 49 | * GEANT does not check for mandatory classes till initialize() and BeamOn() are invoked 50 | * 51 | * OPTIONAL USER CLASSES 52 | * UserRunAction, EventAction, StackingAction, TrackingAction, SteppingAction 53 | */ 54 | -------------------------------------------------------------------------------- /tutorial2/vis.mac: -------------------------------------------------------------------------------- 1 | # Macrofile for visualization, split with init_vis 2 | 3 | # We're using OpenGL (See vis files in examples for other drivers such as OpenInventor, DAWN, HepRApp and others 4 | 5 | /vis/open OGL 900x900-0+0 6 | # If you get an error when working in a VM a possible workaround is setting the display limit to an absurdly large number 7 | /vis/ogl/set/displayListLimit 100000 8 | 9 | # Disable auto refresh and quieten vis messages whilst scene and trajectories established 10 | /vis/viewer/set/autoRefresh false 11 | /vis/verbose errors 12 | 13 | # Draw the geometry we created 14 | /vis/drawVolume 15 | 16 | # Specify viewing angle 17 | /vis/viewer/set/viewpointThetaPhi 20. 20. 18 | 19 | # Make smooth trajectories at end of event, trajectory points as markers 2px wide 20 | /vis/scene/add/trajectories smooth 21 | /vis/modeling/trajectories/create/drawByCharge 22 | /vis/modeling/trajectories/drawByCharge-0/default/setDrawStepPts true 23 | /vis/modeling/trajectories/drawByCharge-0/default/setStepPtsSize 1 24 | 25 | # Select colour by particle ID 26 | /vis/modeling/trajectories/create/drawByParticleID 27 | /vis/modeling/trajectories/drawByParticleID-0/default/setDrawStepPts true 28 | 29 | # Superimpose all events from given run 30 | /vis/scene/endOfEventAction accumulate 31 | 32 | # Re-establish auto refreshing and verbosity 33 | /vis/viewer/set/autoRefresh true 34 | /vis/verbose warnings 35 | -------------------------------------------------------------------------------- /tutorial3/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Our minimum cmake list 2 | 3 | # Setup Project 4 | cmake_minimum_required(VERSION 2.6 FATAL_ERROR) 5 | project(tutorial3) 6 | 7 | # Find Geant4 and activate ALL UI and vis drivers by default 8 | option(WITH_GEANT4_UIVIS "Build example with Geant4 UI and Vis drivers" ON) 9 | if(WITH_GEANT4_UIVIS) 10 | find_package(Geant4 REQUIRED ui_all vis_all) 11 | else() 12 | find_package(Geant4 REQUIRED) 13 | endif() 14 | option(ui_all ON) 15 | option(vis_all ON) 16 | MESSAGE( STATUS "Geant4_qt_FOUND: " ${Geant4_qt_FOUND} ) 17 | MESSAGE( STATUS "Geant4_vis_opengl_x11_FOUND: " ${Geant4_vis_opengl_x11_FOUND} ) 18 | 19 | # Setup include directories 20 | include(${Geant4_USE_FILE}) 21 | include_directories(${PROJECT_SOURCE_DIR}/include) 22 | 23 | # Locate the source and header files 24 | file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cpp) 25 | file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh) 26 | 27 | # Add exec and links the libraries 28 | add_executable(tutorial3 tutorial3.cpp ${sources} ${headers}) 29 | target_link_libraries(tutorial3 ${Geant4_LIBRARIES}) 30 | 31 | # if you want to copy scripts over uncomment this section 32 | set(TUTORIAL_SCRIPTS 33 | init_vis.mac 34 | run.mac 35 | vis.mac 36 | ) 37 | # 38 | foreach(_script ${TUTORIAL_SCRIPTS}) 39 | configure_file( 40 | ${PROJECT_SOURCE_DIR}/${_script} 41 | ${PROJECT_BINARY_DIR}/${_script} 42 | COPYONLY 43 | ) 44 | endforeach() 45 | 46 | # Install exec's to bin directory under CMAKE_INSTALL_PREFIX 47 | install(TARGETS tutorial3 DESTINATION bin) 48 | -------------------------------------------------------------------------------- /tutorial3/README.md: -------------------------------------------------------------------------------- 1 | # Tutorial 3: Counting dose through a flux field 2 | 3 | So running the last tutorial you will see that we just have a Geantino passing through the box. Now we want to use a different particle and get some interactions 4 | 5 | What we changed 6 | ----------- 7 | In this tutorial we have changed our firing particle to a gamma ray. 8 | 9 | We need to add a lot more here with the ActionInitialization, Run, RunAction, and Stacking Action files. With these we are initializing the run a different way (see change to the main file). The Stacking Action file is especially important if you don't want to track neutrinos. In beta decays we get neutrinos/antineutrinos. Generally we won't want to track these because they don't really interfere with people or objects. Since we are looking for radiation dosages we just want to free up computer time and delete these as soon as they appear. If you are following along to the changes I'm making from B3 you will notice that they track "good" events. Since they are concerned with the positron-electron annihilation they want to see productions that are exactly 511keV and they specify this. It is good to pay attention to how they do this, if you are looking for specific applications (like a PET scan). 10 | 11 | I also introduced a macro, called `run.mac`. You can see the change made in the main file. We check `argc` (that is if there are arguments passed to the run command, eg `./tutorial3 run.mac`) and if so, we have it run the command. See the if/else statement that checks if `ui` is not 0. 12 | 13 | Play around 14 | ------------- 15 | Play around with the vis manager here's some things you should practice. 16 | 17 | - Change the gun energy 18 | ``` 19 | /gun/energy 50 MeV 20 | ``` 21 | - Change the gun particle 22 | ``` 23 | /gun/particle e+ 24 | ``` 25 | If you type in an invalid particle you will get the full list of particles. 26 | It is also available in [chapter 5.3](http://geant4.cern.ch/G4UsersDocuments/UsersGuides/ForApplicationDeveloper/html/TrackingAndPhysics/particle.html) 27 | - Change the viewing angle 28 | 29 | - Make the box empty and fire a gamma at the water target. What happens? 30 | 31 | - Make both the box and the water a detector and see the different dosages each take. 32 | 33 | -------------------------------------------------------------------------------- /tutorial3/include/.PrimaryGeneratorAction.hh.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenwalton/Geant4Tutorials/9084bb7159326b032759939df9206f6a6677d860/tutorial3/include/.PrimaryGeneratorAction.hh.swp -------------------------------------------------------------------------------- /tutorial3/include/ActionInitialization.hh: -------------------------------------------------------------------------------- 1 | #ifndef ActionInitialization_h 2 | #define ActionInitialization_h 1 3 | 4 | #include "G4VUserActionInitialization.hh" 5 | 6 | class ActionInitialization: public G4VUserActionInitialization 7 | { 8 | public: 9 | ActionInitialization(); 10 | virtual ~ActionInitialization(); 11 | 12 | virtual void BuildForMaster() const; 13 | virtual void Build() const; 14 | }; 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /tutorial3/include/DetectorConstruction.hh: -------------------------------------------------------------------------------- 1 | /* Need our required Detector construction header */ 2 | #ifndef DetectorConstruction_h 3 | #define DetectorConstruction_h 1 4 | 5 | #include "G4VUserDetectorConstruction.hh" 6 | #include "globals.hh" 7 | 8 | class G4VPhysicalVolume; 9 | class G4LogicalVolume; 10 | 11 | class DetectorConstruction : public G4VUserDetectorConstruction 12 | { 13 | public: 14 | DetectorConstruction(); 15 | virtual ~DetectorConstruction(); 16 | 17 | virtual G4VPhysicalVolume* Construct(); 18 | virtual void ConstructSDandField(); 19 | 20 | private: 21 | void DefineMaterials(); 22 | }; 23 | #endif 24 | -------------------------------------------------------------------------------- /tutorial3/include/PhysicsList.hh: -------------------------------------------------------------------------------- 1 | /* Our Physics List header */ 2 | #ifndef PhysicsList_h 3 | #define PhysicsList_h 1 4 | 5 | #include "G4VModularPhysicsList.hh" 6 | 7 | class PhysicsList : public G4VModularPhysicsList 8 | { 9 | public: 10 | PhysicsList(); 11 | ~PhysicsList(); 12 | 13 | virtual void SetCuts(); 14 | 15 | }; 16 | #endif 17 | -------------------------------------------------------------------------------- /tutorial3/include/PrimaryGeneratorAction.hh: -------------------------------------------------------------------------------- 1 | /* We have to have a .hh file for our primary generator action file */ 2 | #ifndef PrimaryGeneratorAction_h 3 | #define PrimaryGeneratorAction_h 1 4 | 5 | #include "G4VUserPrimaryGeneratorAction.hh" //This is a Geant file, not created by user 6 | 7 | class G4ParticleGun; 8 | class G4Event; 9 | class G4Box; 10 | 11 | class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction 12 | { 13 | public: 14 | PrimaryGeneratorAction(); 15 | virtual ~PrimaryGeneratorAction(); // We must be able to destroy what we can create 16 | 17 | virtual void GeneratePrimaries(G4Event*); // See .cpp file 18 | 19 | const G4ParticleGun* GetParticleGun() const { return particleGun;} 20 | 21 | 22 | private: 23 | G4ParticleGun* particleGun; 24 | G4Box* EnvelopeBox; 25 | 26 | }; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /tutorial3/include/Run.hh: -------------------------------------------------------------------------------- 1 | #ifndef Run_h 2 | #define Run_h 1 3 | 4 | #include "G4Run.hh" 5 | #include "globals.hh" 6 | 7 | class Run : public G4Run 8 | { 9 | public: 10 | Run(); 11 | virtual ~Run(); 12 | 13 | virtual void RecordEvent(const G4Event*); 14 | virtual void Merge(const G4Run*); 15 | 16 | G4double GetSumDose() const {return SumDose;} 17 | 18 | private: 19 | G4int CollID_plate; 20 | G4int PrintModulo; 21 | G4double SumDose; 22 | }; 23 | #endif 24 | -------------------------------------------------------------------------------- /tutorial3/include/RunAction.hh: -------------------------------------------------------------------------------- 1 | #ifndef RunAction_h 2 | #define RunAction_h 1 3 | 4 | #include "G4UserRunAction.hh" 5 | #include "globals.hh" 6 | 7 | class G4Run; 8 | 9 | class RunAction : public G4UserRunAction 10 | { 11 | public: 12 | RunAction(); 13 | virtual ~RunAction(); 14 | 15 | virtual G4Run* GenerateRun(); 16 | virtual void BeginOfRunAction(const G4Run*); 17 | virtual void EndOfRunAction(const G4Run*); 18 | }; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /tutorial3/include/StackingAction.hh: -------------------------------------------------------------------------------- 1 | #ifndef StackingAction_h 2 | #define StackingAction_h 1 3 | 4 | #include "G4UserStackingAction.hh" 5 | #include "globals.hh" 6 | 7 | class StackingAction : public G4UserStackingAction 8 | { 9 | public: 10 | StackingAction(); 11 | virtual ~StackingAction(); 12 | 13 | virtual G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track*); 14 | }; 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /tutorial3/init_vis.mac: -------------------------------------------------------------------------------- 1 | # Macro file for tutorial 2 2 | # Let's make an interactive session 3 | # Set some default verbose 4 | /control/verbose 2 5 | /control/saveHistory 6 | /run/verbose 2 7 | 8 | #/run/setCutForAGivenParticle gamma 0.5 m 9 | #/cuts/setLowEdge 511 keV 10 | # Initialize kernel 11 | /run/initialize 12 | 13 | # Visualization setting 14 | /control/execute vis.mac 15 | -------------------------------------------------------------------------------- /tutorial3/run.mac: -------------------------------------------------------------------------------- 1 | /run/beamOn 10 2 | -------------------------------------------------------------------------------- /tutorial3/src/ActionInitialization.cpp: -------------------------------------------------------------------------------- 1 | /* This code will be used to run the Primary Generator Action, Run Action, and Stacking actions. 2 | * This is just for helping with organization 3 | */ 4 | #include "ActionInitialization.hh" 5 | #include "PrimaryGeneratorAction.hh" 6 | #include "RunAction.hh" 7 | #include "StackingAction.hh" 8 | 9 | ActionInitialization::ActionInitialization() 10 | : G4VUserActionInitialization() 11 | {} 12 | 13 | ActionInitialization::~ActionInitialization() 14 | {} 15 | 16 | void ActionInitialization::BuildForMaster() const 17 | { 18 | SetUserAction(new RunAction); 19 | } 20 | 21 | void ActionInitialization::Build() const 22 | { 23 | SetUserAction(new PrimaryGeneratorAction); 24 | SetUserAction(new RunAction); 25 | SetUserAction(new StackingAction); 26 | } 27 | 28 | -------------------------------------------------------------------------------- /tutorial3/src/DetectorConstruction.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "DetectorConstruction.hh" 3 | #include "G4NistManager.hh" 4 | #include "G4Box.hh" 5 | #include "G4LogicalVolume.hh" 6 | #include "G4PVPlacement.hh" 7 | #include "G4RotationMatrix.hh" 8 | #include "G4Transform3D.hh" 9 | #include "G4PhysicalConstants.hh" 10 | #include "G4SystemOfUnits.hh" 11 | 12 | // New includes 13 | #include "G4SDManager.hh" 14 | #include "G4MultiFunctionalDetector.hh" 15 | #include "G4VPrimitiveScorer.hh" 16 | #include "G4PSEnergyDeposit.hh" 17 | #include "G4PSDoseDeposit.hh" 18 | 19 | #include "G4VisAttributes.hh" 20 | 21 | 22 | DetectorConstruction::DetectorConstruction() 23 | : G4VUserDetectorConstruction() 24 | { 25 | DefineMaterials(); 26 | } 27 | 28 | DetectorConstruction::~DetectorConstruction() 29 | {} 30 | 31 | void DetectorConstruction::DefineMaterials() 32 | { 33 | G4NistManager* man = G4NistManager::Instance(); 34 | G4bool isotopes = false; 35 | /* Define simple material */ 36 | G4double density = 1.390 * g/cm3; 37 | G4double a = 39.95 * g/mole; 38 | G4Material* lAr = new G4Material("lArgon", // Name 39 | 18., // Z value 40 | a, // atomic mass 41 | density); // That thing 42 | 43 | /* Define a simple molecule */ 44 | G4Element* H = man -> FindOrBuildElement("H", isotopes); 45 | G4Element* O = man -> FindOrBuildElement("O", isotopes); 46 | 47 | G4Material* H2O = new G4Material("Water", // name 48 | 1.000 * g/cm3, // density 49 | 2); // number of components 50 | H2O -> AddElement(H, 2); // Name and number of atoms in molecule 51 | H2O -> AddElement(O, 1); 52 | 53 | /* Define mixture by fractional mass */ 54 | G4Element* N = man -> FindOrBuildElement("N", isotopes); 55 | density = 1.290 * mg/cm3; 56 | G4Material* Air = new G4Material("Air", density, 2); 57 | Air -> AddElement(N, 70*perCent); 58 | Air -> AddElement(O, 30*perCent); 59 | } 60 | 61 | 62 | // Create our world and box 63 | G4VPhysicalVolume* DetectorConstruction::Construct() 64 | { 65 | 66 | G4NistManager* man = G4NistManager::Instance(); 67 | G4Material* default_mat = man -> FindOrBuildMaterial("Air"); 68 | G4Material* box_mat = man -> FindOrBuildMaterial("lArgon"); 69 | G4Material* water = man -> FindOrBuildMaterial("Water"); 70 | 71 | /*** FIRST create the WORLD ***/ 72 | G4double worldSize = 1. * m; 73 | G4Box* solidWorld = new G4Box("World", worldSize, worldSize, worldSize); 74 | G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, default_mat, "World"); 75 | G4VPhysicalVolume* physWorld = new G4PVPlacement(0, G4ThreeVector(), logicWorld, "World", 0, false, 0); 76 | 77 | G4double Box_x = 0.5 * worldSize; 78 | G4double Box_y = 0.5 * worldSize; 79 | G4double Box_z = 0.5 * worldSize; 80 | 81 | G4Box* testBox = new G4Box("testBox", // Name 82 | Box_x, // x length 83 | Box_y, // y length 84 | Box_z); // z length 85 | 86 | G4LogicalVolume* testBox_log = new G4LogicalVolume(testBox, // Its solid (see the box we made) 87 | box_mat, // Its material 88 | "testBox"); // Its name 89 | 90 | // We can place this as part of the G4Logical Volume 91 | new G4PVPlacement(0, // Rotation 92 | G4ThreeVector(), // its location 93 | testBox_log, // the logical volume 94 | "testBox", // its name 95 | logicWorld, // its mother volume 96 | false, // boolean operations 97 | 0); // its copy number 98 | 99 | 100 | 101 | /* We are now going to create a thin plate and have it act as a detector. We'll place it at the edge of the world, opposite of the incoming rays. This means that 102 | * it will be located at the lowest value of x in our world. Remember that our particle gun was defined at 1.,0,0 103 | * */ 104 | G4Box* plate = new G4Box("plate", 105 | 0.1 * m, 106 | worldSize, 107 | worldSize); 108 | 109 | G4LogicalVolume* plate_log = new G4LogicalVolume(plate, 110 | water, 111 | "plateLV"); 112 | new G4PVPlacement(0, 113 | G4ThreeVector(0.9 * worldSize,0,0), // Remember that we have to account for the size of the box 114 | plate_log, 115 | "plate", 116 | logicWorld, 117 | false, 118 | 0); 119 | 120 | 121 | return physWorld; // Always return the world 122 | } 123 | 124 | // We are now going to create the detector here 125 | // Remember that we will have to edit our .hh file here 126 | void DetectorConstruction::ConstructSDandField() 127 | { 128 | G4SDManager::GetSDMpointer() -> SetVerboseLevel(1); 129 | 130 | G4MultiFunctionalDetector* det = new G4MultiFunctionalDetector("plate"); 131 | G4SDManager::GetSDMpointer() -> AddNewDetector(det); 132 | G4VPrimitiveScorer* prim = new G4PSDoseDeposit("dose"); // We want to record the dosage to the patient 133 | det -> RegisterPrimitive(prim); 134 | SetSensitiveDetector("plateLV", det); 135 | } 136 | 137 | -------------------------------------------------------------------------------- /tutorial3/src/PhysicsList.cpp: -------------------------------------------------------------------------------- 1 | #include "PhysicsList.hh" 2 | 3 | #include "G4DecayPhysics.hh" 4 | #include "G4RadioactiveDecayPhysics.hh" 5 | #include "G4EmStandardPhysics.hh" 6 | 7 | PhysicsList::PhysicsList() 8 | : G4VModularPhysicsList() 9 | { 10 | RegisterPhysics(new G4DecayPhysics()); 11 | RegisterPhysics(new G4RadioactiveDecayPhysics()); 12 | RegisterPhysics(new G4EmStandardPhysics()); 13 | } 14 | 15 | PhysicsList::~PhysicsList() 16 | {} 17 | 18 | void PhysicsList::SetCuts() 19 | { 20 | G4VUserPhysicsList::SetCuts(); 21 | } 22 | -------------------------------------------------------------------------------- /tutorial3/src/PrimaryGeneratorAction.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Remember to use the header file in the /include folder 3 | */ 4 | 5 | #include "PrimaryGeneratorAction.hh" 6 | 7 | #include "G4RunManager.hh" 8 | #include "G4Event.hh" 9 | #include "G4ParticleGun.hh" 10 | #include "G4ThreeVector.hh" 11 | #include "G4ParticleTable.hh" 12 | #include "G4ParticleDefinition.hh" 13 | #include "G4IonTable.hh" 14 | #include "globals.hh" 15 | #include "G4SystemOfUnits.hh" 16 | 17 | //New 18 | #include "G4LogicalVolumeStore.hh" 19 | #include "G4LogicalVolume.hh" 20 | #include "G4Box.hh" 21 | #include "Randomize.hh" 22 | #include "G4Geantino.hh" 23 | 24 | PrimaryGeneratorAction::PrimaryGeneratorAction() 25 | : G4VUserPrimaryGeneratorAction(), 26 | particleGun(0), 27 | EnvelopeBox(0) 28 | { 29 | G4int n_particle = 1; 30 | particleGun = new G4ParticleGun(n_particle); 31 | 32 | // Here we'll load the whole particle table to be able to call a lookup 33 | //G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable(); 34 | //G4String particleName; 35 | //G4ParticleDefinition* particle = particleTable -> FindParticle(particleName="gamma"); 36 | //G4ParticleDefinition* particle = particleTable -> FindParticle(particleName="geantino"); 37 | particleGun -> SetParticleDefinition(G4Geantino::GeantinoDefinition()); 38 | 39 | //particleGun -> SetParticleDefinition(particle); 40 | particleGun -> SetParticleEnergy(6.0 * MeV); 41 | 42 | //particleGun -> SetParticlePosition(G4ThreeVector(-1.*m, 0.*m, 0.*m)); 43 | particleGun -> SetParticleMomentumDirection(G4ThreeVector(1., 0., 0.)); 44 | } 45 | 46 | // Create destructor 47 | PrimaryGeneratorAction::~PrimaryGeneratorAction() 48 | { 49 | delete particleGun; 50 | } 51 | 52 | // Primary event 53 | void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) 54 | { 55 | /* 56 | * To avoid dependence on Detector Construction we will get an envelope volume 57 | * from the G4LogicalVolumeStore 58 | * 59 | * Here we will be assuming our box is sitting in a world where the radiation flux 60 | * is coming from the -x direction. Thus we will have a uniform random start location 61 | * through the YZ plane 62 | */ 63 | G4double envSizeX = 0.; 64 | G4double envSizeYZ = 0.; 65 | 66 | if ( !EnvelopeBox ) 67 | { 68 | G4LogicalVolume* envLV = G4LogicalVolumeStore::GetInstance() -> GetVolume("World"); 69 | if ( envLV ) EnvelopeBox = dynamic_cast( envLV -> GetSolid() ); 70 | } 71 | 72 | if ( EnvelopeBox ) 73 | { 74 | envSizeYZ = EnvelopeBox -> GetYHalfLength() *2.; 75 | envSizeX = EnvelopeBox -> GetXHalfLength() *2.; 76 | } 77 | else 78 | { 79 | G4ExceptionDescription msg; 80 | msg << "World volume of box shape is not found.\n"; 81 | msg << "Perhaps you have changed the geometry.\n"; 82 | msg << "\nWhere has the world gone?"; 83 | G4Exception("PrimaryGeneratorAction::GeneratePrimaries()","Mycode0001",JustWarning,msg); 84 | } 85 | 86 | // We won't use the outer 10% edge 87 | G4double size = 0.9; 88 | // Since we are starting in the -x direction and firing in the x direction we want the 89 | // particles to come uniformly out of the YZ plane 90 | G4double x0 = 0.5 * envSizeX; 91 | G4double y0 = size * envSizeYZ * (G4UniformRand() - 0.5); 92 | G4double z0 = size * envSizeYZ * (G4UniformRand() - 0.5); 93 | 94 | particleGun -> SetParticlePosition(G4ThreeVector(-x0,y0,z0)); 95 | //particleGun -> SetParticleMomentumDirection(G4ThreeVector(1.0,0.,0.)); // Pure x momentum 96 | 97 | particleGun -> GeneratePrimaryVertex(anEvent); // creates the initial momentum 98 | } 99 | -------------------------------------------------------------------------------- /tutorial3/src/Run.cpp: -------------------------------------------------------------------------------- 1 | /* NEW FILE 2 | * In this file we are mapping the dosages to the detector. We want to track the event ID 3 | */ 4 | #include "Run.hh" 5 | 6 | #include "G4RunManager.hh" 7 | #include "G4Event.hh" 8 | #include "G4SDManager.hh" 9 | #include "G4HCofThisEvent.hh" 10 | #include "G4THitsMap.hh" 11 | #include "G4SystemOfUnits.hh" 12 | 13 | 14 | /* We want to set up the event with these parameters. Very important to set the Sum Dosage so that we don't stack the values from 15 | * random points in memory */ 16 | Run::Run() 17 | : G4Run(), 18 | CollID_plate(-1), 19 | PrintModulo(10000), 20 | SumDose(0.) 21 | {} 22 | 23 | Run::~Run() 24 | {} 25 | 26 | void Run::RecordEvent(const G4Event* event) 27 | { 28 | // Note how this relates to the condition above. We now can find the ID of the dose the plate gets 29 | if (CollID_plate < 0) 30 | { 31 | CollID_plate = G4SDManager::GetSDMpointer() -> GetCollectionID("plate/dose"); 32 | } 33 | 34 | // We also want to pull the ID for the event 35 | G4int evtNb = event -> GetEventID(); 36 | 37 | // Every time an event ends we want to separate it from new events. We make this clear with our output 38 | if(evtNb%PrintModulo == 0) 39 | { 40 | G4cout << G4endl << "---> end of event: " << evtNb << G4endl; 41 | } 42 | 43 | // Collections of Hits 44 | G4HCofThisEvent* HCE = event -> GetHCofThisEvent(); 45 | if(!HCE) return; 46 | 47 | // Dosage deposit in the plate 48 | G4double dose = 0.; 49 | 50 | // We need to preform a cast here to get the correct data type 51 | G4THitsMap* evtMap = static_cast< G4THitsMap*>(HCE -> GetHC(CollID_plate)); 52 | 53 | // Loop to map the events and add the dosages so that we get a total dose 54 | std::map::iterator i; 55 | for (i = evtMap -> GetMap() -> begin(); i != evtMap -> GetMap() -> end(); ++i) 56 | { 57 | dose = *(i -> second); 58 | } 59 | SumDose += dose; 60 | 61 | G4Run::RecordEvent(event); 62 | 63 | } 64 | 65 | void Run::Merge(const G4Run* aRun) 66 | { 67 | const Run* localRun = static_cast(aRun); 68 | SumDose += localRun -> SumDose; 69 | 70 | G4Run::Merge(aRun); 71 | } 72 | -------------------------------------------------------------------------------- /tutorial3/src/RunAction.cpp: -------------------------------------------------------------------------------- 1 | /* NEW FILE 2 | * Here we need to control our output. Most of this file is to handle the 3 | * dosage output 4 | */ 5 | #include "RunAction.hh" 6 | #include "PrimaryGeneratorAction.hh" 7 | #include "Run.hh" 8 | 9 | #include "G4Run.hh" 10 | #include "G4RunManager.hh" 11 | #include "G4UnitsTable.hh" 12 | #include "G4SystemOfUnits.hh" 13 | 14 | #include "G4ParticleDefinition.hh" 15 | #include "G4ParticleTable.hh" 16 | #include "G4ParticleGun.hh" 17 | 18 | RunAction::RunAction() 19 | : G4UserRunAction() 20 | { 21 | 22 | // We need the units for the dosages since GEANT4 doesn't know what a gray is 23 | const G4double milligray = 1.e-3 * gray; 24 | const G4double microgray = 1.e-6 * gray; 25 | const G4double nanogray = 1.e-9 * gray; 26 | const G4double picogray = 1.e-12* gray; 27 | 28 | // We really want units that are more easily read 29 | // We could just as easily use this to put our system in the furlong frikin fortnight system 30 | new G4UnitDefinition("milligray", "milliGy", "Dose", milligray); 31 | new G4UnitDefinition("microgray", "microGy", "Dose", microgray); 32 | new G4UnitDefinition("nanogray" , "nanoGy" , "Dose", nanogray); 33 | new G4UnitDefinition("picogray" , "picoGy" , "Dose", picogray); 34 | } 35 | 36 | RunAction::~RunAction() 37 | {} 38 | 39 | G4Run* RunAction::GenerateRun() 40 | { 41 | return new Run; 42 | } 43 | 44 | void RunAction::BeginOfRunAction(const G4Run* run) 45 | { 46 | G4cout << "### Run " << run -> GetRunID() << " start." << G4endl; 47 | 48 | // We need to inform the run manager to save the random number seed 49 | G4RunManager::GetRunManager() -> SetRandomNumberStore(false); 50 | } 51 | 52 | void RunAction::EndOfRunAction(const G4Run* run) 53 | { 54 | G4int nofEvents = run -> GetNumberOfEvent(); 55 | if (nofEvents == 0) return; 56 | 57 | // Our run conditions 58 | const PrimaryGeneratorAction* generatorAction 59 | = static_cast 60 | (G4RunManager::GetRunManager() -> GetUserPrimaryGeneratorAction()); 61 | G4String partName; 62 | 63 | if (generatorAction) 64 | { 65 | G4ParticleDefinition* particle 66 | = generatorAction -> GetParticleGun() -> GetParticleDefinition(); 67 | partName = particle -> GetParticleName(); 68 | } 69 | 70 | // Get our results \ o / 71 | const Run* tRun = static_cast(run); 72 | G4double sumDose = tRun -> GetSumDose(); 73 | 74 | // And print the data 75 | if (IsMaster()) 76 | { 77 | G4cout << G4endl 78 | << "--------------- End of Global Run --------------" 79 | << G4endl 80 | << "The run was " << nofEvents << " event(s) "; 81 | } 82 | else 83 | { 84 | G4cout << G4endl 85 | << "--------------- End of Local Run ---------------" 86 | << G4endl 87 | << "The run was " << nofEvents << " " << partName; 88 | } 89 | G4cout << G4endl 90 | << "Total dose to the plate : " << G4BestUnit(sumDose, "Dose") 91 | << G4endl 92 | << "--------------------------------------------------" 93 | << G4endl 94 | << G4endl; 95 | } 96 | -------------------------------------------------------------------------------- /tutorial3/src/StackingAction.cpp: -------------------------------------------------------------------------------- 1 | /* NEW FILE 2 | * Here we are really just deleting neutrinos because we don't care about them 3 | */ 4 | #include "StackingAction.hh" 5 | 6 | #include "G4Track.hh" 7 | #include "G4NeutrinoE.hh" 8 | 9 | StackingAction::StackingAction() 10 | {} 11 | 12 | StackingAction::~StackingAction() 13 | {} 14 | 15 | G4ClassificationOfNewTrack 16 | StackingAction::ClassifyNewTrack(const G4Track* track) 17 | { 18 | // Keep Primary Particle 19 | if (track -> GetParentID() == 0) return fUrgent; 20 | 21 | // KILL the secondary neutrinos (from beta decays) 22 | if (track -> GetDefinition() == G4NeutrinoE::NeutrinoE()) return fKill; 23 | else return fUrgent; 24 | } 25 | 26 | /* 27 | * Remember that during beta decays there is either a neutrino or antineutrino. We are just killing the neutrinos here because of the B+ decay, find 28 | * out how to kill the antineutrino form the e- decay 29 | */ 30 | -------------------------------------------------------------------------------- /tutorial3/tutorial3.cpp: -------------------------------------------------------------------------------- 1 | #include "G4RunManager.hh" 2 | #include "G4UImanager.hh" 3 | #include "G4VisExecutive.hh" 4 | #include "G4UIExecutive.hh" 5 | #include "DetectorConstruction.hh" 6 | #include "PhysicsList.hh" 7 | #include "ActionInitialization.hh" 8 | 9 | #include "G4UIcommand.hh" 10 | 11 | int main(int argc, char** argv) 12 | { 13 | G4UIExecutive* ui = 0; 14 | // Run a macro if one is given 15 | if( argc == 1 ) 16 | ui = new G4UIExecutive(argc,argv); 17 | 18 | G4RunManager* runManager = new G4RunManager; 19 | 20 | G4VisManager* visManager = new G4VisExecutive; 21 | visManager -> Initialize(); 22 | 23 | runManager -> SetUserInitialization(new DetectorConstruction); 24 | runManager -> SetUserInitialization(new PhysicsList); 25 | runManager -> SetUserInitialization(new ActionInitialization()); 26 | runManager -> Initialize(); 27 | 28 | // get pointer to UI manager and set verbosities 29 | G4UImanager* UI = G4UImanager::GetUIpointer(); 30 | if ( !ui ) 31 | { 32 | G4String command = "/control/execute "; 33 | G4String fileName = argv[1]; 34 | UI -> ApplyCommand(command + fileName); 35 | } 36 | else 37 | { 38 | UI -> ApplyCommand("/control/execute init_vis.mac"); 39 | ui -> SessionStart(); 40 | 41 | delete ui; 42 | } 43 | 44 | // TERMINATE job 45 | delete runManager; 46 | delete visManager; 47 | 48 | // We will output the table of materials that were used when we end the program 49 | // We could also place this within DetectorConstruction and have it output when 50 | // we start the program 51 | G4cout << *(G4Material::GetMaterialTable()) << G4endl; 52 | 53 | return 0; 54 | } 55 | -------------------------------------------------------------------------------- /tutorial3/vis.mac: -------------------------------------------------------------------------------- 1 | # Macrofile for visualization, split with init_vis 2 | 3 | # We're using OpenGL (See vis files in examples for other drivers such as OpenInventor, DAWN, HepRApp and others 4 | 5 | /vis/open OGL #600x600-0+0 6 | #/vis/open OIX 7 | # I get a weird error with my VM and so I do this as a workaround 8 | #/vis/ogl/set/displayListLimit 10000 9 | 10 | # Disable auto refresh and quieten vis messages whilst scene and trajectories established 11 | /vis/viewer/set/autoRefresh false 12 | /vis/verbose errors 13 | 14 | # Draw the geometry we created 15 | /vis/drawVolume 16 | 17 | # Specify viewing angle 18 | /vis/viewer/set/viewpointThetaPhi 30. 120. 19 | # We're going to draw axes 20 | /vis/scene/add/axes 21 | 22 | # Make smooth trajectories at end of event, trajectory points as markers 2px wide 23 | /vis/scene/add/trajectories smooth 24 | /vis/modeling/trajectories/create/drawByCharge 25 | /vis/modeling/trajectories/drawByCharge-0/default/setDrawStepPts true 26 | /vis/modeling/trajectories/drawByCharge-0/default/setStepPtsSize 1 27 | 28 | # Select colour by particle ID 29 | #/vis/modeling/trajectories/create/drawByParticleID 30 | #/vis/modeling/trajectories/drawByParticleID-0/default/setDrawStepPts true 31 | 32 | # Superimpose all events from given run 33 | /vis/scene/endOfEventAction accumulate 34 | 35 | # Re-establish auto refreshing and verbosity 36 | /vis/viewer/set/autoRefresh true 37 | /vis/verbose warnings 38 | 39 | -------------------------------------------------------------------------------- /tutorial4/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Our minimum cmake list 2 | 3 | # Setup Project 4 | cmake_minimum_required(VERSION 2.6 FATAL_ERROR) 5 | project(tutorial4) 6 | 7 | # Find Geant4 and activate ALL UI and vis drivers by default 8 | option(WITH_GEANT4_UIVIS "Build example with Geant4 UI and Vis drivers" ON) 9 | if(WITH_GEANT4_UIVIS) 10 | find_package(Geant4 REQUIRED ui_all vis_all) 11 | else() 12 | find_package(Geant4 REQUIRED) 13 | endif() 14 | 15 | # Setup include directories 16 | include(${Geant4_USE_FILE}) 17 | include_directories(${PROJECT_SOURCE_DIR}/include) 18 | 19 | # Locate the source and header files 20 | file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cpp) 21 | file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh) 22 | 23 | # Add exec and links the libraries 24 | add_executable(tutorial4 tutorial4.cpp ${sources} ${headers}) 25 | target_link_libraries(tutorial4 ${Geant4_LIBRARIES}) 26 | 27 | # if you want to copy scripts over uncomment this section 28 | set(TUTORIAL_SCRIPTS 29 | # tutorial.in 30 | # tutorial.out 31 | init_vis.mac 32 | # run1.mac 33 | # run2.mac 34 | vis.mac 35 | gui.mac 36 | icons.mac 37 | run.png 38 | runx10.png 39 | ) 40 | # 41 | foreach(_script ${TUTORIAL_SCRIPTS}) 42 | configure_file( 43 | ${PROJECT_SOURCE_DIR}/${_script} 44 | ${PROJECT_BINARY_DIR}/${_script} 45 | COPYONLY 46 | ) 47 | endforeach() 48 | 49 | # Install exec's to bin directory under CMAKE_INSTALL_PREFIX 50 | install(TARGETS tutorial4 DESTINATION bin) 51 | -------------------------------------------------------------------------------- /tutorial4/README.md: -------------------------------------------------------------------------------- 1 | # Changes in Tutorial 4 2 | The biggest change we did is that we stated to count the number of secondaries 3 | We use the filter `G4PSNofSecondary` to count the number of secondary e-,e+,protons, and neutrons. 4 | These filters are set within the detector construction class and are added in the run class. 5 | Pay special attention to the comments made and how order matters when setting the filters and 6 | calling back the hits maps 7 | 8 | We have also added to the GUI. Specifically we have a run button that will run a single event as well as one 9 | to run 10 events. A menu has also been created and that allows you to change the energy levels and the gun's 10 | particle. 11 | -------------------------------------------------------------------------------- /tutorial4/gui.mac: -------------------------------------------------------------------------------- 1 | # Adding a GUI interface for ease of use 2 | # This allows us to add toolbars and buttons that can run custom commands. Thanks to QT 3 | 4 | /control/execute icons.mac # Where we store the icons 5 | 6 | # File menu 7 | /gui/addMenu file File 8 | /gui/addButton file Quit exit # Adds "Quit" under file menu that runs "exit" command 9 | 10 | # Run menu 11 | /gui/addMenu run Run 12 | # If above didn't make sense this pattern should 13 | /gui/addButton run "beamOn 1" "/run/beamOn 1" 14 | /gui/addButton run "beamOn 100" "/run/beamOn 100" 15 | 16 | # Gun Menu 17 | /gui/addMenu gun Gun 18 | /gui/addButton gun "e-" "/gun/particle e-" 19 | /gui/addButton gun "e+" "/gun/particle e+" 20 | /gui/addButton gun "proton" "/gun/particle proton" 21 | /gui/addButton gun "neutron" "/gun/particle neutron" 22 | /gui/addButton gun "alpha" "/gun/particle alpha" 23 | /gui/addButton gun "1MeV" "/gun/energy 1 MeV" 24 | /gui/addButton gun "10MeV" "/gun/energy 10 MeV" 25 | /gui/addButton gun "100MeV" "/gun/energy 100 MeV" 26 | /gui/addButton gun "1GeV" "/gun/energy 1 GeV" 27 | 28 | # Adding a run button 29 | /gui/addIcon "Run Beam" user_icon "/run/beamOn 1" run.png # photo from geant4 slac handson tutorials 30 | /gui/addIcon "Run Beam x10" user_icon "run/beamOn 10" runx10.png 31 | -------------------------------------------------------------------------------- /tutorial4/icons.mac: -------------------------------------------------------------------------------- 1 | # This file adds icons to the gui 2 | # Save/open 3 | /gui/addIcon "Open macro" open /control/execute 4 | /gui/addIcon "Save viewer state" save /vis/viewer/save 5 | 6 | # Cursor icons 7 | /gui/addIcon "Move" move 8 | /gui/addIcon "Pick" pick 9 | /gui/addIcon "Zoom Out" zoom_out 10 | /gui/addIcon "Zoom In" zoom_in 11 | /gui/addIcon "Rotate" rotate 12 | 13 | # Perspectives 14 | /gui/addIcon "Perspective" perspective 15 | /gui/addIcon "Orthogonal" ortho 16 | -------------------------------------------------------------------------------- /tutorial4/include/ActionInitialization.hh: -------------------------------------------------------------------------------- 1 | #ifndef ActionInitialization_h 2 | #define ActionInitialization_h 1 3 | 4 | #include "G4VUserActionInitialization.hh" 5 | 6 | class ActionInitialization: public G4VUserActionInitialization 7 | { 8 | public: 9 | ActionInitialization(); 10 | virtual ~ActionInitialization(); 11 | 12 | virtual void BuildForMaster() const; 13 | virtual void Build() const; 14 | }; 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /tutorial4/include/DetectorConstruction.hh: -------------------------------------------------------------------------------- 1 | /* Need our required Detector construction header */ 2 | #ifndef DetectorConstruction_h 3 | #define DetectorConstruction_h 1 4 | 5 | #include "G4VUserDetectorConstruction.hh" 6 | #include "globals.hh" 7 | #include "G4MultiFunctionalDetector.hh" 8 | 9 | class G4VPhysicalVolume; 10 | class G4LogicalVolume; 11 | 12 | class DetectorConstruction : public G4VUserDetectorConstruction 13 | { 14 | public: 15 | DetectorConstruction(); 16 | virtual ~DetectorConstruction(); 17 | 18 | virtual G4VPhysicalVolume* Construct(); 19 | virtual void ConstructSDandField(); 20 | 21 | private: 22 | void DefineMaterials(); 23 | G4LogicalVolume* plate_log; 24 | }; 25 | #endif 26 | -------------------------------------------------------------------------------- /tutorial4/include/PhysicsList.hh: -------------------------------------------------------------------------------- 1 | /* Our Physics List header */ 2 | #ifndef PhysicsList_h 3 | #define PhysicsList_h 1 4 | 5 | #include "G4VModularPhysicsList.hh" 6 | 7 | class PhysicsList : public G4VModularPhysicsList 8 | { 9 | public: 10 | PhysicsList(); 11 | ~PhysicsList(); 12 | 13 | virtual void SetCuts(); 14 | 15 | }; 16 | #endif 17 | -------------------------------------------------------------------------------- /tutorial4/include/PrimaryGeneratorAction.hh: -------------------------------------------------------------------------------- 1 | /* We have to have a .hh file for our primary generator action file */ 2 | #ifndef PrimaryGeneratorAction_h 3 | #define PrimaryGeneratorAction_h 1 4 | 5 | #include "G4VUserPrimaryGeneratorAction.hh" //This is a Geant file, not created by user 6 | 7 | class G4ParticleGun; 8 | class G4Event; 9 | class G4Box; 10 | 11 | class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction 12 | { 13 | public: 14 | PrimaryGeneratorAction(); 15 | virtual ~PrimaryGeneratorAction(); // We must be able to destroy what we can create 16 | 17 | virtual void GeneratePrimaries(G4Event*); // See .cpp file 18 | 19 | const G4ParticleGun* GetParticleGun() const { return particleGun;} 20 | 21 | 22 | private: 23 | G4ParticleGun* particleGun; 24 | G4Box* EnvelopeBox; 25 | 26 | }; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /tutorial4/include/Run.hh: -------------------------------------------------------------------------------- 1 | #ifndef Run_h 2 | #define Run_h 1 3 | 4 | #include "G4Run.hh" 5 | #include "globals.hh" 6 | #include "G4THitsMap.hh" 7 | 8 | class Run : public G4Run 9 | { 10 | public: 11 | Run(); 12 | virtual ~Run(); 13 | 14 | virtual void RecordEvent(const G4Event*); 15 | virtual void Merge(const G4Run*); 16 | 17 | G4double GetSumDose() const {return SumDose;} 18 | // New functions will pull values from map 19 | G4double GetNProtons() const { return GetTotal(mapSum[0][0]); } 20 | G4double GetNElectrons() const { return GetTotal(mapSum[0][1]); } 21 | G4double GetNPositrons() const { return GetTotal(mapSum[0][2]); } 22 | G4double GetNNeutrons() const { return GetTotal(mapSum[0][3]); } 23 | 24 | private: 25 | G4int CollID_plate; 26 | // We need ID values 27 | G4int nProton_ID; 28 | G4int nElectron_ID; 29 | G4int nPositron_ID; 30 | G4int nNeutron_ID; 31 | 32 | G4int PrintModulo; 33 | G4double SumDose; 34 | // Map well count the number of secondaries we have. We are just specifying the size 35 | G4THitsMap mapSum[2][3]; 36 | // Function defined in the class file 37 | G4double GetTotal(const G4THitsMap &map) const; 38 | }; 39 | #endif 40 | -------------------------------------------------------------------------------- /tutorial4/include/RunAction.hh: -------------------------------------------------------------------------------- 1 | #ifndef RunAction_h 2 | #define RunAction_h 1 3 | 4 | #include "G4UserRunAction.hh" 5 | #include "globals.hh" 6 | 7 | class G4Run; 8 | 9 | class RunAction : public G4UserRunAction 10 | { 11 | public: 12 | RunAction(); 13 | virtual ~RunAction(); 14 | 15 | virtual G4Run* GenerateRun(); 16 | virtual void BeginOfRunAction(const G4Run*); 17 | virtual void EndOfRunAction(const G4Run*); 18 | }; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /tutorial4/include/StackingAction.hh: -------------------------------------------------------------------------------- 1 | #ifndef StackingAction_h 2 | #define StackingAction_h 1 3 | 4 | #include "G4UserStackingAction.hh" 5 | #include "globals.hh" 6 | 7 | class StackingAction : public G4UserStackingAction 8 | { 9 | public: 10 | StackingAction(); 11 | virtual ~StackingAction(); 12 | 13 | virtual G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track*); 14 | }; 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /tutorial4/init_vis.mac: -------------------------------------------------------------------------------- 1 | # Macro file for tutorial 2 2 | # Let's make an interactive session 3 | # Set some default verbose 4 | /control/verbose 2 5 | /control/saveHistory 6 | /run/verbose 2 7 | 8 | #/run/setCutForAGivenParticle gamma 0.5 m 9 | #/cuts/setLowEdge 511 keV 10 | # Initialize kernel 11 | /run/initialize 12 | 13 | # Visualization setting 14 | /control/execute vis.mac 15 | -------------------------------------------------------------------------------- /tutorial4/run.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenwalton/Geant4Tutorials/9084bb7159326b032759939df9206f6a6677d860/tutorial4/run.png -------------------------------------------------------------------------------- /tutorial4/runx10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenwalton/Geant4Tutorials/9084bb7159326b032759939df9206f6a6677d860/tutorial4/runx10.png -------------------------------------------------------------------------------- /tutorial4/src/ActionInitialization.cpp: -------------------------------------------------------------------------------- 1 | /* This code will be used to run the Primary Generator Action, Run Action, and Stacking actions. 2 | * This is just for helping with organization 3 | */ 4 | #include "ActionInitialization.hh" 5 | #include "PrimaryGeneratorAction.hh" 6 | #include "RunAction.hh" 7 | #include "StackingAction.hh" 8 | 9 | ActionInitialization::ActionInitialization() 10 | : G4VUserActionInitialization() 11 | {} 12 | 13 | ActionInitialization::~ActionInitialization() 14 | {} 15 | 16 | void ActionInitialization::BuildForMaster() const 17 | { 18 | SetUserAction(new RunAction); 19 | } 20 | 21 | void ActionInitialization::Build() const 22 | { 23 | SetUserAction(new PrimaryGeneratorAction); 24 | SetUserAction(new RunAction); 25 | SetUserAction(new StackingAction); 26 | } 27 | 28 | -------------------------------------------------------------------------------- /tutorial4/src/DetectorConstruction.cpp: -------------------------------------------------------------------------------- 1 | #include "DetectorConstruction.hh" 2 | #include "G4NistManager.hh" 3 | #include "G4Box.hh" 4 | #include "G4LogicalVolume.hh" 5 | #include "G4PVPlacement.hh" 6 | #include "G4RotationMatrix.hh" 7 | #include "G4Transform3D.hh" 8 | #include "G4PhysicalConstants.hh" 9 | #include "G4SystemOfUnits.hh" 10 | #include "G4SDManager.hh" 11 | #include "G4VPrimitiveScorer.hh" 12 | #include "G4PSEnergyDeposit.hh" 13 | #include "G4PSDoseDeposit.hh" 14 | #include "G4SDParticleFilter.hh" 15 | #include "G4PSEnergyDeposit.hh" 16 | #include "G4PSNofSecondary.hh" 17 | #include "G4VSDFilter.hh" 18 | 19 | 20 | DetectorConstruction::DetectorConstruction() 21 | : G4VUserDetectorConstruction() 22 | { 23 | DefineMaterials(); 24 | } 25 | 26 | DetectorConstruction::~DetectorConstruction() 27 | {} 28 | 29 | void DetectorConstruction::DefineMaterials() 30 | { 31 | G4NistManager* man = G4NistManager::Instance(); 32 | G4bool isotopes = false; 33 | /* Define simple material */ 34 | G4double density = 1.390 * g/cm3; 35 | G4double a = 39.95 * g/mole; 36 | G4Material* lAr = new G4Material("lArgon", // Name 37 | 18., // Z value 38 | a, // atomic mass 39 | density); // That thing 40 | 41 | /* Define a simple molecule */ 42 | G4Element* H = man -> FindOrBuildElement("H", isotopes); 43 | G4Element* O = man -> FindOrBuildElement("O", isotopes); 44 | 45 | G4Material* H2O = new G4Material("Water", // name 46 | 1.000 * g/cm3, // density 47 | 2); // number of components 48 | H2O -> AddElement(H, 2); // Name and number of atoms in molecule 49 | H2O -> AddElement(O, 1); 50 | 51 | /* Define mixture by fractional mass */ 52 | G4Element* N = man -> FindOrBuildElement("N", isotopes); 53 | density = 1.290 * mg/cm3; 54 | G4Material* Air = new G4Material("Air", density, 2); 55 | Air -> AddElement(N, 70*perCent); 56 | Air -> AddElement(O, 30*perCent); 57 | } 58 | 59 | 60 | // Create our world and box 61 | G4VPhysicalVolume* DetectorConstruction::Construct() 62 | { 63 | 64 | G4NistManager* man = G4NistManager::Instance(); 65 | G4Material* default_mat = man -> FindOrBuildMaterial("Air"); 66 | G4Material* box_mat = man -> FindOrBuildMaterial("lArgon"); 67 | G4Material* water = man -> FindOrBuildMaterial("Water"); 68 | 69 | /*** FIRST create the WORLD ***/ 70 | G4double worldSize = 1. * m; 71 | G4Box* solidWorld = new G4Box("World", worldSize, worldSize, worldSize); 72 | G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, default_mat, "World"); 73 | G4VPhysicalVolume* physWorld = new G4PVPlacement(0, G4ThreeVector(), logicWorld, "World", 0, false, 0); 74 | 75 | G4double Box_x = 0.5 * worldSize; 76 | G4double Box_y = 0.5 * worldSize; 77 | G4double Box_z = 0.5 * worldSize; 78 | 79 | G4Box* testBox = new G4Box("testBox", // Name 80 | Box_x, // x length 81 | Box_y, // y length 82 | Box_z); // z length 83 | 84 | G4LogicalVolume* testBox_log = new G4LogicalVolume(testBox, // Its solid (see the box we made) 85 | box_mat, // Its material 86 | "testBox"); // Its name 87 | 88 | // We can place this as part of the G4Logical Volume 89 | new G4PVPlacement(0, // Rotation 90 | G4ThreeVector(), // its location 91 | testBox_log, // the logical volume 92 | "testBox", // its name 93 | logicWorld, // its mother volume 94 | false, // boolean operations 95 | 0); // its copy number 96 | 97 | 98 | 99 | /* We are now going to create a thin plate and have it act as a detector. We'll place it at the edge of the world, opposite of the incoming rays. This means that 100 | * it will be located at the lowest value of x in our world. Remember that our particle gun was defined at 1.,0,0 101 | * */ 102 | G4Box* plate = new G4Box("plate", 103 | 0.1 * m, 104 | worldSize, 105 | worldSize); 106 | 107 | /*G4LogicalVolume*/ plate_log = new G4LogicalVolume(plate, 108 | water, 109 | "plateLV"); 110 | new G4PVPlacement(0, 111 | G4ThreeVector(0.9 * worldSize,0,0), // Remember that we have to account for the size of the box 112 | plate_log, 113 | "plate", 114 | logicWorld, 115 | false, 116 | 0); 117 | 118 | 119 | return physWorld; // Always return the world 120 | } 121 | 122 | // We are now going to create the detector here 123 | // Remember that we will have to edit our .hh file here 124 | void DetectorConstruction::ConstructSDandField() 125 | { 126 | G4SDManager* sdManage = G4SDManager::GetSDMpointer(); 127 | sdManage -> SetVerboseLevel(1); 128 | G4String filterName, particleName; 129 | // Changed name to detector to be clearer 130 | G4MultiFunctionalDetector* det = new G4MultiFunctionalDetector("plate"); 131 | sdManage -> AddNewDetector(det); 132 | G4VPrimitiveScorer* prim; 133 | prim = new G4PSDoseDeposit("dose"); // We want to record the dosage to the patient 134 | det -> RegisterPrimitive(prim); 135 | // Now we are going to apply filters to get the number of secondary particles 136 | // The way we order these filters will determine how we access them 137 | // We are keeping in line with the example RE06. We can access multiple detectors by changing 138 | // the i value where j specifies the filter 139 | // [i][j] = detector and filter 140 | // [0][0] = Protons 141 | G4SDParticleFilter* protonFilter = new G4SDParticleFilter(filterName="protonFilter", particleName="proton"); 142 | prim = new G4PSNofSecondary("nProton"); 143 | prim -> SetFilter(protonFilter); 144 | det -> RegisterPrimitive(prim); 145 | // [0][1] = e- 146 | G4SDParticleFilter* electronFilter = new G4SDParticleFilter("electronFilter", "e-"); 147 | prim = new G4PSNofSecondary("nElectron"); 148 | prim -> SetFilter(electronFilter); 149 | det -> RegisterPrimitive(prim); 150 | // [0][2] = e+ 151 | G4SDParticleFilter* positronFilter = new G4SDParticleFilter("positronFilter", "e+"); 152 | prim = new G4PSNofSecondary("nPositron"); 153 | prim -> SetFilter(positronFilter); 154 | det -> RegisterPrimitive(prim); 155 | // [0][3] = n 156 | G4SDParticleFilter* neutronFilter = new G4SDParticleFilter("neutronFilter", "neutron"); 157 | prim = new G4PSNofSecondary("nNeutron"); 158 | prim -> SetFilter(neutronFilter); 159 | det -> RegisterPrimitive(prim); 160 | // Have to set as a sensitive detector and the logical volume we are pointing at 161 | SetSensitiveDetector("plateLV", det); 162 | } 163 | 164 | -------------------------------------------------------------------------------- /tutorial4/src/PhysicsList.cpp: -------------------------------------------------------------------------------- 1 | #include "PhysicsList.hh" 2 | 3 | #include "G4DecayPhysics.hh" 4 | #include "G4RadioactiveDecayPhysics.hh" 5 | #include "G4EmStandardPhysics.hh" 6 | 7 | PhysicsList::PhysicsList() 8 | : G4VModularPhysicsList() 9 | { 10 | RegisterPhysics(new G4DecayPhysics()); 11 | RegisterPhysics(new G4RadioactiveDecayPhysics()); 12 | RegisterPhysics(new G4EmStandardPhysics()); 13 | } 14 | 15 | PhysicsList::~PhysicsList() 16 | {} 17 | 18 | void PhysicsList::SetCuts() 19 | { 20 | G4VUserPhysicsList::SetCuts(); 21 | } 22 | -------------------------------------------------------------------------------- /tutorial4/src/PrimaryGeneratorAction.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Remember to use the header file in the /include folder 3 | */ 4 | 5 | #include "PrimaryGeneratorAction.hh" 6 | 7 | #include "G4RunManager.hh" 8 | #include "G4Event.hh" 9 | #include "G4ParticleGun.hh" 10 | #include "G4ThreeVector.hh" 11 | #include "G4ParticleTable.hh" 12 | #include "G4ParticleDefinition.hh" 13 | #include "G4IonTable.hh" 14 | #include "globals.hh" 15 | #include "G4SystemOfUnits.hh" 16 | 17 | //New 18 | #include "G4LogicalVolumeStore.hh" 19 | #include "G4LogicalVolume.hh" 20 | #include "G4Box.hh" 21 | #include "Randomize.hh" 22 | 23 | PrimaryGeneratorAction::PrimaryGeneratorAction() 24 | : G4VUserPrimaryGeneratorAction(), 25 | particleGun(0), 26 | EnvelopeBox(0) 27 | { 28 | G4int n_particle = 1; 29 | particleGun = new G4ParticleGun(n_particle); 30 | 31 | // Here we'll load the whole particle table to be able to call a lookup 32 | G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable(); 33 | G4String particleName; 34 | G4ParticleDefinition* particle = particleTable -> FindParticle(particleName="gamma"); 35 | 36 | particleGun -> SetParticleDefinition(particle); 37 | particleGun -> SetParticleEnergy(6.0 * MeV); 38 | 39 | //particleGun -> SetParticlePosition(G4ThreeVector(-1.*m, 0.*m, 0.*m)); 40 | particleGun -> SetParticleMomentumDirection(G4ThreeVector(1., 0., 0.)); 41 | } 42 | 43 | // Create destructor 44 | PrimaryGeneratorAction::~PrimaryGeneratorAction() 45 | { 46 | delete particleGun; 47 | } 48 | 49 | // Primary event 50 | void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) 51 | { 52 | /* 53 | * To avoid dependence on Detector Construction we will get an envelope volume 54 | * from the G4LogicalVolumeStore 55 | * 56 | * Here we will be assuming our box is sitting in a world where the radiation flux 57 | * is coming from the -x direction. Thus we will have a uniform random start location 58 | * through the YZ plane 59 | */ 60 | G4double envSizeX = 0.; 61 | G4double envSizeYZ = 0.; 62 | 63 | if ( !EnvelopeBox ) 64 | { 65 | G4LogicalVolume* envLV = G4LogicalVolumeStore::GetInstance() -> GetVolume("World"); 66 | if ( envLV ) EnvelopeBox = dynamic_cast( envLV -> GetSolid() ); 67 | } 68 | 69 | if ( EnvelopeBox ) 70 | { 71 | envSizeYZ = EnvelopeBox -> GetYHalfLength() *2.; 72 | envSizeX = EnvelopeBox -> GetXHalfLength() *2.; 73 | } 74 | else 75 | { 76 | G4ExceptionDescription msg; 77 | msg << "World volume of box shape is not found.\n"; 78 | msg << "Perhaps you have changed the geometry.\n"; 79 | msg << "\nWhere has the world gone?"; 80 | G4Exception("PrimaryGeneratorAction::GeneratePrimaries()","Mycode0001",JustWarning,msg); 81 | } 82 | 83 | // We won't use the outer 10% edge 84 | G4double size = 0.9; 85 | // Since we are starting in the -x direction and firing in the x direction we want the 86 | // particles to come uniformly out of the YZ plane 87 | G4double x0 = 0.5 * envSizeX; 88 | G4double y0 = size * envSizeYZ * (G4UniformRand() - 0.5); 89 | G4double z0 = size * envSizeYZ * (G4UniformRand() - 0.5); 90 | 91 | particleGun -> SetParticlePosition(G4ThreeVector(-x0,y0,z0)); 92 | //particleGun -> SetParticleMomentumDirection(G4ThreeVector(1.0,0.,0.)); // Pure x momentum 93 | 94 | particleGun -> GeneratePrimaryVertex(anEvent); // creates the initial momentum 95 | } 96 | -------------------------------------------------------------------------------- /tutorial4/src/Run.cpp: -------------------------------------------------------------------------------- 1 | /* NEW FILE 2 | * In this file we are mapping the dosages to the detector. We want to track the event ID 3 | */ 4 | #include "Run.hh" 5 | 6 | #include "G4RunManager.hh" 7 | #include "G4Event.hh" 8 | #include "G4SDManager.hh" 9 | #include "G4HCofThisEvent.hh" 10 | #include "G4THitsMap.hh" 11 | #include "G4SystemOfUnits.hh" 12 | #include "G4VPrimitiveScorer.hh" 13 | #include "G4MultiFunctionalDetector.hh" 14 | #include "G4String.hh" 15 | 16 | /* We want to set up the event with these parameters. Very important to set the Sum Dosage so that we don't stack the values from 17 | * random points in memory */ 18 | Run::Run() 19 | : G4Run(), 20 | CollID_plate(-1), 21 | nProton_ID(-1), 22 | nElectron_ID(-1), 23 | nPositron_ID(-1), 24 | nNeutron_ID(-1), 25 | PrintModulo(10000), 26 | SumDose(0.) 27 | { 28 | } 29 | 30 | Run::~Run() 31 | { 32 | } 33 | 34 | void Run::RecordEvent(const G4Event* event) 35 | { 36 | // Note how this relates to the condition above. We now can find the ID of the dose the plate gets 37 | if (CollID_plate < 0) 38 | CollID_plate = G4SDManager::GetSDMpointer() -> GetCollectionID("plate/dose"); 39 | if ( nProton_ID < 0 ) 40 | nProton_ID = G4SDManager::GetSDMpointer() -> GetCollectionID("plate/nProton"); 41 | if (nElectron_ID < 0 ) 42 | nElectron_ID = G4SDManager::GetSDMpointer() -> GetCollectionID("plate/nElectron"); 43 | if ( nPositron_ID < 0 ) 44 | nPositron_ID = G4SDManager::GetSDMpointer() -> GetCollectionID("plate/nPositron"); 45 | if ( nNeutron_ID < 0 ) 46 | nNeutron_ID = G4SDManager::GetSDMpointer() -> GetCollectionID("plate/nNeutron"); 47 | 48 | // We also want to pull the ID for the event 49 | G4int evtNb = event -> GetEventID(); 50 | 51 | // Every time an event ends we want to separate it from new events. We make this clear with our output 52 | if(evtNb%PrintModulo == 0) 53 | { 54 | G4cout << G4endl << "---> end of event: " << evtNb << G4endl; 55 | } 56 | 57 | // Collections of Hits 58 | G4HCofThisEvent* HCE = event -> GetHCofThisEvent(); 59 | if(!HCE) return; 60 | 61 | // Dosage deposit in the plate 62 | G4double dose = 0.; 63 | 64 | // We need to preform a cast here to get the correct data type 65 | G4THitsMap* evtMap = static_cast< G4THitsMap*>(HCE -> GetHC(CollID_plate)); 66 | 67 | // Loop to map the events and add the dosages so that we get a total dose 68 | std::map::iterator i; 69 | for (i = evtMap -> GetMap() -> begin(); i != evtMap -> GetMap() -> end(); ++i) 70 | dose = *(i -> second); 71 | SumDose += dose; 72 | // We are using the maps to count the particles 73 | evtMap = (G4THitsMap*)(HCE -> GetHC(nProton_ID)); 74 | mapSum[0][0] += *evtMap; // Adds the Protons 75 | evtMap = (G4THitsMap*)(HCE -> GetHC(nElectron_ID)); 76 | mapSum[0][1] += *evtMap; // Adds the electrons 77 | evtMap = (G4THitsMap*)(HCE -> GetHC(nPositron_ID)); 78 | mapSum[0][2] += *evtMap; // Adds the positrons 79 | evtMap = (G4THitsMap*)(HCE -> GetHC(nNeutron_ID)); 80 | mapSum[0][3] += *evtMap; // Adds Neutrons 81 | 82 | 83 | G4Run::RecordEvent(event); // invoke base class method 84 | } 85 | 86 | // We need this function to get the total number from each map 87 | G4double Run::GetTotal(const G4THitsMap &map) const 88 | { 89 | G4double tot = 0.; 90 | if ( map.GetSize() == 0 ) return tot; 91 | std::map::iterator itr; 92 | for (itr = map.GetMap() -> begin(); itr != map.GetMap() -> end(); ++itr ) 93 | tot += *(itr -> second); 94 | return tot; 95 | } 96 | 97 | void Run::Merge(const G4Run* aRun) 98 | { 99 | const Run* localRun = static_cast(aRun); 100 | SumDose += localRun -> SumDose; 101 | // Note that the order here is from the order we specified when creating the filters 102 | // Remember that each run is an independent event 103 | mapSum[0][0] += localRun -> mapSum[0][0]; // Protons 104 | mapSum[0][1] += localRun -> mapSum[0][1]; // Electrons 105 | mapSum[0][2] += localRun -> mapSum[0][2]; // Positrons 106 | mapSum[0][3] += localRun -> mapSum[0][3]; // Neutrons 107 | 108 | G4Run::Merge(aRun); 109 | } 110 | 111 | -------------------------------------------------------------------------------- /tutorial4/src/RunAction.cpp: -------------------------------------------------------------------------------- 1 | /* NEW FILE 2 | * Here we need to control our output. Most of this file is to handle the 3 | * dosage output 4 | */ 5 | #include "RunAction.hh" 6 | #include "PrimaryGeneratorAction.hh" 7 | #include "Run.hh" 8 | 9 | #include "G4Run.hh" 10 | #include "G4RunManager.hh" 11 | #include "G4UnitsTable.hh" 12 | #include "G4SystemOfUnits.hh" 13 | 14 | #include "G4ParticleDefinition.hh" 15 | #include "G4ParticleTable.hh" 16 | #include "G4ParticleGun.hh" 17 | 18 | RunAction::RunAction() 19 | : G4UserRunAction() 20 | { 21 | 22 | // We need the units for the dosages since GEANT4 doesn't know what a gray is 23 | const G4double milligray = 1.e-3 * gray; 24 | const G4double microgray = 1.e-6 * gray; 25 | const G4double nanogray = 1.e-9 * gray; 26 | const G4double picogray = 1.e-12* gray; 27 | 28 | // We really want units that are more easily read 29 | // We could just as easily use this to put our system in the furlong frikin fortnight system 30 | new G4UnitDefinition("milligray", "milliGy", "Dose", milligray); 31 | new G4UnitDefinition("microgray", "microGy", "Dose", microgray); 32 | new G4UnitDefinition("nanogray" , "nanoGy" , "Dose", nanogray); 33 | new G4UnitDefinition("picogray" , "picoGy" , "Dose", picogray); 34 | } 35 | 36 | RunAction::~RunAction() 37 | {} 38 | 39 | G4Run* RunAction::GenerateRun() 40 | { 41 | return new Run; 42 | } 43 | 44 | void RunAction::BeginOfRunAction(const G4Run* run) 45 | { 46 | G4cout << "### Run " << run -> GetRunID() << " start." << G4endl; 47 | 48 | // We need to inform the run manager to save the random number seed 49 | G4RunManager::GetRunManager() -> SetRandomNumberStore(false); 50 | } 51 | 52 | void RunAction::EndOfRunAction(const G4Run* run) 53 | { 54 | G4int nofEvents = run -> GetNumberOfEvent(); 55 | if (nofEvents == 0) return; 56 | 57 | // Our run conditions 58 | const PrimaryGeneratorAction* generatorAction 59 | = static_cast 60 | (G4RunManager::GetRunManager() -> GetUserPrimaryGeneratorAction()); 61 | G4String partName; 62 | 63 | if (generatorAction) 64 | { 65 | G4ParticleDefinition* particle 66 | = generatorAction -> GetParticleGun() -> GetParticleDefinition(); 67 | partName = particle -> GetParticleName(); 68 | G4cout << "Gun particle name: " << partName << G4endl; // We can get the gun particle's name by outputting to the screen here 69 | } 70 | 71 | // Get our results \ o / 72 | const Run* tRun = static_cast(run); 73 | G4double sumDose = tRun -> GetSumDose(); 74 | G4double nEl = tRun -> GetNElectrons(); 75 | G4double nP = tRun -> GetNProtons(); 76 | G4double nEp = tRun -> GetNPositrons(); 77 | G4double nN = tRun -> GetNNeutrons(); 78 | 79 | // And print the data 80 | if (IsMaster()) 81 | { 82 | G4cout << G4endl 83 | << "--------------- End of Global Run --------------" 84 | << G4endl 85 | << " The run was " << nofEvents << "events "; 86 | } 87 | else 88 | { 89 | G4cout << G4endl 90 | << "--------------- End of Local Run ---------------" 91 | << G4endl 92 | << " The run was " << nofEvents << " " << partName; 93 | } 94 | G4cout << G4endl 95 | << "Total dose to the plate : " << G4BestUnit(sumDose, "Dose") 96 | << G4endl 97 | // Now we'll output values 98 | << "Number of Protons collected: " << nP << G4endl 99 | << "Number of Electrons collected: " << nEl << G4endl 100 | << "Number of Positrons collected: " << nEp << G4endl 101 | << "Number of Neutrons collected: " << nN << G4endl 102 | << "--------------------------------------------------" 103 | << G4endl 104 | << G4endl; 105 | } 106 | -------------------------------------------------------------------------------- /tutorial4/src/StackingAction.cpp: -------------------------------------------------------------------------------- 1 | /* NEW FILE 2 | * Here we are really just deleting neutrinos because we don't care about them 3 | */ 4 | #include "StackingAction.hh" 5 | 6 | #include "G4Track.hh" 7 | #include "G4NeutrinoE.hh" 8 | 9 | StackingAction::StackingAction() 10 | {} 11 | 12 | StackingAction::~StackingAction() 13 | {} 14 | 15 | G4ClassificationOfNewTrack 16 | StackingAction::ClassifyNewTrack(const G4Track* track) 17 | { 18 | // Keep Primary Particle 19 | if (track -> GetParentID() == 0) return fUrgent; 20 | 21 | // KILL the secondary neutrinos (from beta decays) 22 | if (track -> GetDefinition() == G4NeutrinoE::NeutrinoE()) return fKill; 23 | else return fUrgent; 24 | } 25 | 26 | /* 27 | * Remember that during beta decays there is either a neutrino or antineutrino. We are just killing the neutrinos here because of the B+ decay, find 28 | * out how to kill the antineutrino form the e- decay 29 | */ 30 | -------------------------------------------------------------------------------- /tutorial4/tutorial4.cpp: -------------------------------------------------------------------------------- 1 | #include "G4RunManager.hh" 2 | #include "G4UImanager.hh" 3 | #include "G4VisExecutive.hh" 4 | #include "G4UIExecutive.hh" 5 | #include "DetectorConstruction.hh" 6 | #include "PhysicsList.hh" 7 | //#include "PrimaryGeneratorAction.hh" 8 | #include "ActionInitialization.hh" 9 | 10 | int main(int argc, char** argv) 11 | { 12 | //G4RunManager* runManager = new G4RunManager; 13 | 14 | G4UIExecutive* ui = new G4UIExecutive(argc, argv); 15 | //G4VisManager* visManager = new G4VisExecutive; 16 | //visManager -> Initialize(); 17 | auto runManager = new G4RunManager; 18 | 19 | runManager -> SetUserInitialization(new DetectorConstruction); 20 | runManager -> SetUserInitialization(new PhysicsList); 21 | runManager -> SetUserInitialization(new ActionInitialization()); 22 | 23 | //runManager -> Initialize(); 24 | auto visManager = new G4VisExecutive; 25 | visManager -> Initialize(); 26 | 27 | // get pointer to UI manager and set verbosities 28 | //G4UImanager* UI = G4UImanager::GetUIpointer(); 29 | auto UI = G4UImanager::GetUIpointer(); 30 | UI -> ApplyCommand("/control/execute init_vis.mac"); 31 | // Have to add this to get the gui command 32 | UI -> ApplyCommand("/control/execute gui.mac"); 33 | ui -> SessionStart(); 34 | 35 | delete ui; 36 | 37 | // TERMINATE job 38 | delete runManager; 39 | delete visManager; 40 | 41 | // We will output the table of materials that were used when we end the program 42 | // We could also place this within DetectorConstruction and have it output when 43 | // we start the program 44 | G4cout << *(G4Material::GetMaterialTable()) << G4endl; 45 | 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /tutorial4/vis.mac: -------------------------------------------------------------------------------- 1 | # Macrofile for visualization, split with init_vis 2 | 3 | # We're using OpenGL (See vis files in examples for other drivers such as OpenInventor, DAWN, HepRApp and others 4 | 5 | /vis/open OGL 600x600-0+0 6 | # I get a weird error with my VM and so I do this as a workaround 7 | #/vis/ogl/set/displayListLimit 100000000000000 8 | 9 | # Disable auto refresh and quieten vis messages whilst scene and trajectories established 10 | /vis/viewer/set/autoRefresh false 11 | /vis/verbose errors 12 | 13 | # Draw the geometry we created 14 | /vis/drawVolume 15 | 16 | # Specify viewing angle 17 | /vis/viewer/set/viewpointThetaPhi 30. 120. 18 | # We're going to draw axes 19 | /vis/scene/add/axes 20 | 21 | # Make smooth trajectories at end of event, trajectory points as markers 2px wide 22 | /vis/scene/add/trajectories smooth 23 | /vis/modeling/trajectories/create/drawByCharge 24 | /vis/modeling/trajectories/drawByCharge-0/default/setDrawStepPts true 25 | /vis/modeling/trajectories/drawByCharge-0/default/setStepPtsSize 2 26 | 27 | # Select colour by particle ID 28 | #/vis/modeling/trajectories/create/drawByParticleID 29 | #/vis/modeling/trajectories/drawByParticleID-0/default/setDrawStepPts true 30 | 31 | # Re-establish auto refreshing and verbosity 32 | /vis/viewer/set/autoRefresh true 33 | /vis/verbose warnings 34 | 35 | # Superimpose all events from given run 36 | /vis/scene/endOfEventAction accumulate 37 | 38 | 39 | -------------------------------------------------------------------------------- /tutorial5/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Our minimum cmake list 2 | 3 | # Setup Project 4 | cmake_minimum_required(VERSION 2.6 FATAL_ERROR) 5 | project(tutorial5) 6 | 7 | # Find Geant4 and activate ALL UI and vis drivers by default 8 | option(WITH_GEANT4_UIVIS "Build example with Geant4 UI and Vis drivers" ON) 9 | if(WITH_GEANT4_UIVIS) 10 | find_package(Geant4 REQUIRED ui_all vis_all) 11 | else() 12 | find_package(Geant4 REQUIRED) 13 | endif() 14 | 15 | # Setup include directories 16 | include(${Geant4_USE_FILE}) 17 | include_directories(${PROJECT_SOURCE_DIR}/include) 18 | 19 | # Locate the source and header files 20 | file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cpp) 21 | file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh) 22 | 23 | # Add exec and links the libraries 24 | add_executable(tutorial5 tutorial5.cpp ${sources} ${headers}) 25 | target_link_libraries(tutorial5 ${Geant4_LIBRARIES}) 26 | 27 | # if you want to copy scripts over uncomment this section 28 | set(TUTORIAL_SCRIPTS 29 | init_vis.mac 30 | vis.mac 31 | gui.mac 32 | icons.mac 33 | run.png 34 | runx10.png 35 | ) 36 | # 37 | foreach(_script ${TUTORIAL_SCRIPTS}) 38 | configure_file( 39 | ${PROJECT_SOURCE_DIR}/${_script} 40 | ${PROJECT_BINARY_DIR}/${_script} 41 | COPYONLY 42 | ) 43 | endforeach() 44 | 45 | # Install exec's to bin directory under CMAKE_INSTALL_PREFIX 46 | install(TARGETS tutorial5 DESTINATION bin) 47 | -------------------------------------------------------------------------------- /tutorial5/G4History.macro: -------------------------------------------------------------------------------- 1 | /run/verbose 2 2 | /run/initialize 3 | /control/execute vis.mac 4 | /vis/open OGL 900x900-0+0 5 | /vis/sceneHandler/create OGL 6 | /vis/viewer/create ! ! 900x900-0+0 7 | /vis/viewer/refresh 8 | /vis/ogl/set/displayListLimit 100000000000000 9 | /vis/viewer/set/autoRefresh false 10 | /vis/verbose errors 11 | /vis/drawVolume 12 | /vis/scene/create 13 | /vis/scene/add/volume world 14 | /vis/sceneHandler/attach 15 | /vis/viewer/set/viewpointThetaPhi 30. 120. 16 | /vis/scene/add/axes 17 | /vis/scene/notifyHandlers 18 | /vis/scene/add/trajectories smooth 19 | /tracking/storeTrajectory 2 20 | /vis/scene/notifyHandlers 21 | /vis/modeling/trajectories/create/drawByCharge 22 | /vis/modeling/trajectories/create/drawByParticleID 23 | /vis/modeling/trajectories/drawByParticleID-0/default/setDrawStepPts true 24 | /vis/scene/notifyHandlers scene-0 25 | /vis/scene/endOfEventAction accumulate 26 | /vis/viewer/set/autoRefresh true 27 | /vis/viewer/refresh 28 | /vis/verbose warnings 29 | /control/execute gui.mac 30 | /control/execute icons.mac 31 | /gui/addIcon "Open macro" open /control/execute 32 | /gui/addIcon "Save viewer state" save /vis/viewer/save 33 | /gui/addIcon "Move" move 34 | /gui/addIcon "Pick" pick 35 | /gui/addIcon "Zoom Out" zoom_out 36 | /gui/addIcon "Zoom In" zoom_in 37 | /gui/addIcon "Rotate" rotate 38 | /gui/addIcon "Perspective" perspective 39 | /gui/addIcon "Orthogonal" ortho 40 | /gui/addMenu file File 41 | /gui/addButton file Quit exit 42 | /gui/addMenu run Run 43 | /gui/addButton run "beamOn 1" "/run/beamOn 1" 44 | /gui/addButton run "beamOn 100" "/run/beamOn 100" 45 | /gui/addMenu gun Gun 46 | /gui/addButton gun "e-" "/gun/particle e-" 47 | /gui/addButton gun "e+" "/gun/particle e+" 48 | /gui/addButton gun "proton" "/gun/particle proton" 49 | /gui/addButton gun "neutron" "/gun/particle neutron" 50 | /gui/addButton gun "alpha" "/gun/particle alpha" 51 | /gui/addButton gun "1MeV" "/gun/energy 1 MeV" 52 | /gui/addButton gun "10MeV" "/gun/energy 10 MeV" 53 | /gui/addButton gun "100MeV" "/gun/energy 100 MeV" 54 | /gui/addButton gun "1GeV" "/gun/energy 1 GeV" 55 | /gui/addIcon "Run Beam" user_icon "/run/beamOn 1" run.png 56 | /gui/addIcon "Run Beam x10" user_icon "run/beamOn 10" runx10.png 57 | /run/beamOn 1 58 | /vis/scene/notifyHandlers scene-0 59 | /run/beamOn 1 60 | /run/beamOn 1 61 | /run/beamOn 1 62 | -------------------------------------------------------------------------------- /tutorial5/README.md: -------------------------------------------------------------------------------- 1 | # Changes in Tutorial 5 2 | ------------------------ 3 | This time we had the goal to get the Effective Dosages in the detector. If we reference 4 | ICRP 103 we can find the weights that each particle has, specifically neutrons are a problem. 5 | Unfortunately the dosage detector we've been using does not account for the weights of the 6 | particles. That's okay though, because we can do it manually. In this case we need to define 7 | how each step works. So we'll again build off of what we already have, there are probably 8 | more clever ways to do this task but this works. We want to minimize computation time so we 9 | are only going to change how steps work when they are inside the detector. Once we know 10 | we are in the detector we need to get some items here. 11 | 12 | We know that the Effective Dose (unit: Sv) is the sum of the weights times the equivalent dose. 13 | The Equivalent dose is the sum of the weight of the organ times the organ's absorbed dose. We 14 | don't care so much about that so we are just going to assume H\_T = D. That is the absorbed dose, 15 | grays, absorbed. We know that one gray is a joule per kilogram or 100 rad. So from here we can 16 | back out our effective dose. 17 | ``` 18 | E = sum(w_p * D) 19 | ``` 20 | So in the Stepping Action we are able to grab the mass of the detector (in this case 800kg) and 21 | we will use the energy of the particle. So for each event (each time something happens: particle 22 | splits, decay, strike, etc) we get the total energy deposited in the detector. Remember here that 23 | GEANT4 uses units, so we divide those out. We then convert from MeV to Joules (we're being 24 | explicit). We also want to make sure that we are not counting non-ionizing radiation, as that 25 | does not get counted in the dosage. We then figure out which particle is depositing the energy 26 | and apply the correct weight. We give a warning at the end in case we don't know the particle and 27 | do not apply any weight. If you want to use fission fragments or other things you will have to 28 | add them manually. Finally we add our effective dosage to the event. You will notice that we 29 | add specifically what each particle's dose is (we do not call this out in the end of our run but 30 | this is left as an exercise). 31 | 32 | We will next move to EventAction. Here we output the total energy deposits and effective dosages 33 | at the end of each event. We also add this to the effective dosage in RunAction. You need to do 34 | this if you want to get the total effective dosage at the end of the run. You will see these 35 | numbers at the end of the run and you can add them to verify that you are getting the correct 36 | effective dosage. We output the energy so the same can be done there too. 37 | 38 | Finally we'll run the program and turn the beam on. You will notice that the total dosage in the 39 | plate and the effective dosage is the same. This is to be expected because we are firing gammas 40 | and you will notice that the only secondaries created are betas, which have a weight of 1. To 41 | check that we did this all correctly we'll switch the gun to fire protons and up the energy to 42 | 100 MeV so we can hit the plate (remember we programmed these into the menu). You will notice no 43 | secondaries and that effective dosage is twice that of the total deposited dosage. We have again 44 | verified that we did things correctly (and that total dosage doesn't account for weight) because 45 | protons have a weight of 2. 46 | 47 | ## Minor Changes made 48 | --------------------- 49 | We included the options to run multiple macros at once. Try this out by running 50 | 51 | `./tutorial5 run1.mac run2.mac` 52 | 53 | You will notice that the output becomes cumbersome. I left the output to illustrate this point and let the reader 54 | experiment with multithreaded options in this configuration (See Example B3's main file). 55 | 56 | We also moved the material definition outside of the DetectorContruction file. You can also do this as a class, 57 | but it is simple to do as a standard header file. If you have a more complex geometry and material list this 58 | will be suggested as it makes reading the code easier. Remember, GEANT4 is just C++, so we can do anything that we 59 | normally would do there here. 60 | -------------------------------------------------------------------------------- /tutorial5/gui.mac: -------------------------------------------------------------------------------- 1 | # Adding a GUI interface for ease of use 2 | # This allows us to add toolbars and buttons that can run custom commands. Thanks to QT 3 | 4 | /control/execute icons.mac # Where we store the icons 5 | 6 | # File menu 7 | /gui/addMenu file File 8 | /gui/addButton file Quit exit # Adds "Quit" under file menu that runs "exit" command 9 | 10 | # Run menu 11 | /gui/addMenu run Run 12 | # If above didn't make sense this pattern should 13 | /gui/addButton run "beamOn 1" "/run/beamOn 1" 14 | /gui/addButton run "beamOn 100" "/run/beamOn 100" 15 | 16 | # Gun Menu 17 | /gui/addMenu gun Gun 18 | /gui/addButton gun "e-" "/gun/particle e-" 19 | /gui/addButton gun "e+" "/gun/particle e+" 20 | /gui/addButton gun "proton" "/gun/particle proton" 21 | /gui/addButton gun "neutron" "/gun/particle neutron" 22 | /gui/addButton gun "alpha" "/gun/particle alpha" 23 | /gui/addButton gun "1MeV" "/gun/energy 1 MeV" 24 | /gui/addButton gun "10MeV" "/gun/energy 10 MeV" 25 | /gui/addButton gun "100MeV" "/gun/energy 100 MeV" 26 | /gui/addButton gun "1GeV" "/gun/energy 1 GeV" 27 | 28 | # Adding a run button 29 | /gui/addIcon "Run Beam" user_icon "/run/beamOn 1" run.png # photo from geant4 slac handson tutorials 30 | /gui/addIcon "Run Beam x10" user_icon "/run/beamOn 10" runx10.png 31 | -------------------------------------------------------------------------------- /tutorial5/icons.mac: -------------------------------------------------------------------------------- 1 | # This file adds icons to the gui 2 | # Save/open 3 | /gui/addIcon "Open macro" open /control/execute 4 | /gui/addIcon "Save viewer state" save /vis/viewer/save 5 | 6 | # Cursor icons 7 | /gui/addIcon "Move" move 8 | /gui/addIcon "Pick" pick 9 | /gui/addIcon "Zoom Out" zoom_out 10 | /gui/addIcon "Zoom In" zoom_in 11 | /gui/addIcon "Rotate" rotate 12 | 13 | # Perspectives 14 | /gui/addIcon "Perspective" perspective 15 | /gui/addIcon "Orthogonal" ortho 16 | -------------------------------------------------------------------------------- /tutorial5/include/ActionInitialization.hh: -------------------------------------------------------------------------------- 1 | #ifndef ActionInitialization_h 2 | #define ActionInitialization_h 1 3 | 4 | #include "G4VUserActionInitialization.hh" 5 | 6 | class DetectorConstruction; 7 | 8 | class ActionInitialization: public G4VUserActionInitialization 9 | { 10 | public: 11 | ActionInitialization(DetectorConstruction*); 12 | virtual ~ActionInitialization(); 13 | 14 | virtual void BuildForMaster() const; 15 | virtual void Build() const; 16 | 17 | private: 18 | DetectorConstruction* fDetConst; 19 | }; 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /tutorial5/include/DetectorConstruction.hh: -------------------------------------------------------------------------------- 1 | /* Need our required Detector construction header */ 2 | #ifndef DetectorConstruction_h 3 | #define DetectorConstruction_h 1 4 | 5 | #include "G4VUserDetectorConstruction.hh" 6 | #include "globals.hh" 7 | #include "G4MultiFunctionalDetector.hh" 8 | 9 | class G4VPhysicalVolume; 10 | class G4LogicalVolume; 11 | 12 | class DetectorConstruction : public G4VUserDetectorConstruction 13 | { 14 | public: 15 | DetectorConstruction(); 16 | virtual ~DetectorConstruction(); 17 | 18 | virtual G4VPhysicalVolume* Construct(); 19 | virtual void ConstructSDandField(); 20 | 21 | inline const G4VPhysicalVolume* GetAbsorberPV() const { return platePV;} 22 | 23 | private: 24 | G4LogicalVolume* plate_log; 25 | G4VPhysicalVolume* platePV; 26 | }; 27 | #endif 28 | -------------------------------------------------------------------------------- /tutorial5/include/EventAction.hh: -------------------------------------------------------------------------------- 1 | #ifndef EventAction_h 2 | #define EventAction_h 1 3 | 4 | #include "G4UserEventAction.hh" 5 | #include "globals.hh" 6 | #include "G4HCofThisEvent.hh" 7 | 8 | class RunAction; 9 | 10 | class EventAction : public G4UserEventAction 11 | { 12 | public: 13 | EventAction(RunAction*); 14 | virtual ~EventAction(); 15 | 16 | virtual void BeginOfEventAction(const G4Event*); 17 | virtual void EndOfEventAction(const G4Event* event); 18 | 19 | inline void AddEnergy(G4double edep) {totalEnergy += edep;} 20 | inline G4double GetTotalEnergy() { return totalEnergy; } 21 | inline G4int GetfEventID() { return fEventID;} 22 | inline G4HCofThisEvent* GetHCofThisEvent() { return fHCE;} 23 | // Get the effective dosages 24 | inline void addEffectiveDose(G4double effectiveDose) { effDose += effectiveDose; } 25 | inline void addProtDose(G4double pDose) { protDose += pDose; } 26 | inline void addBetaDose(G4double bDose) { betaDose += bDose; } 27 | inline void addAlphDose(G4double aDose) { alphDose += aDose; } 28 | inline void addNeutDose(G4double nDose) { neutDose += nDose; } 29 | inline void addGammDose(G4double gDose) { gammaDose += gDose; } 30 | 31 | inline G4double getEventEffectiveDose() { return effDose; } 32 | G4double effDose; 33 | 34 | 35 | private: 36 | G4double totalEnergy; 37 | G4int fEventID; 38 | G4HCofThisEvent* fHCE; 39 | //G4double effDose; 40 | G4double protDose; 41 | G4double betaDose; 42 | G4double alphDose; 43 | G4double neutDose; 44 | G4double gammaDose; 45 | RunAction* fRunAction; 46 | }; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /tutorial5/include/Materials.hh: -------------------------------------------------------------------------------- 1 | #ifndef MATERIALS_hh 2 | #define MATERIALS_hh 1 3 | 4 | #include "G4NistManager.hh" 5 | #include "G4PhysicalConstants.hh" 6 | #include "G4SystemOfUnits.hh" 7 | 8 | void DefineMaterials() 9 | { 10 | G4NistManager* man = G4NistManager::Instance(); 11 | G4bool isotopes = false; 12 | G4double density = 1.39 * g/cm3; 13 | G4double a = 39.95 * g/mole; 14 | G4Material* lAr = new G4Material("lArgon", 15 | 18., // Z value 16 | a, // atomic mass 17 | density); 18 | G4Element* H = man -> FindOrBuildElement("H", isotopes); 19 | G4Element* O = man -> FindOrBuildElement("O", isotopes); 20 | G4Material* H2O = new G4Material("Water", 21 | 1.000 * g/cm3, // density 22 | 2); // Number of components 23 | H2O -> AddElement(H, 2); 24 | H2O -> AddElement(O, 1); 25 | 26 | G4Element* N = man -> FindOrBuildElement("N", isotopes); 27 | density = 1.290 * mg/cm3; 28 | G4Material* Air = new G4Material("Air", density, 2); 29 | Air -> AddElement(N, 70*perCent); 30 | Air -> AddElement(O, 30*perCent); 31 | } 32 | #endif 33 | 34 | -------------------------------------------------------------------------------- /tutorial5/include/PhysicsList.hh: -------------------------------------------------------------------------------- 1 | /* Our Physics List header */ 2 | #ifndef PhysicsList_h 3 | #define PhysicsList_h 1 4 | 5 | #include "G4VModularPhysicsList.hh" 6 | 7 | class PhysicsList : public G4VModularPhysicsList 8 | { 9 | public: 10 | PhysicsList(); 11 | ~PhysicsList(); 12 | 13 | virtual void SetCuts(); 14 | 15 | }; 16 | #endif 17 | -------------------------------------------------------------------------------- /tutorial5/include/PrimaryGeneratorAction.hh: -------------------------------------------------------------------------------- 1 | /* We have to have a .hh file for our primary generator action file */ 2 | #ifndef PrimaryGeneratorAction_h 3 | #define PrimaryGeneratorAction_h 1 4 | 5 | #include "G4VUserPrimaryGeneratorAction.hh" //This is a Geant file, not created by user 6 | 7 | class G4ParticleGun; 8 | class G4Event; 9 | class G4Box; 10 | 11 | class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction 12 | { 13 | public: 14 | PrimaryGeneratorAction(); 15 | virtual ~PrimaryGeneratorAction(); // We must be able to destroy what we can create 16 | 17 | virtual void GeneratePrimaries(G4Event*); // See .cpp file 18 | 19 | const G4ParticleGun* GetParticleGun() const { return particleGun;} 20 | 21 | 22 | private: 23 | G4ParticleGun* particleGun; 24 | G4Box* EnvelopeBox; 25 | 26 | }; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /tutorial5/include/Run.hh: -------------------------------------------------------------------------------- 1 | #ifndef Run_h 2 | #define Run_h 1 3 | 4 | #include "G4Run.hh" 5 | #include "globals.hh" 6 | #include "G4THitsMap.hh" 7 | #include "G4UserEventAction.hh" 8 | //#include "EventAction.hh" 9 | 10 | //class EventAction; 11 | 12 | class Run : public G4Run 13 | //public EventAction 14 | { 15 | public: 16 | Run(); 17 | virtual ~Run(); 18 | 19 | virtual void RecordEvent(const G4Event* event/*, EventAction* fEvent*/); 20 | virtual void Merge(const G4Run*); 21 | 22 | G4double GetSumDose() const {return SumDose;} 23 | // New functions will pull values from map 24 | G4double GetNProtons() const { return GetTotal(mapSum[0][0]); } 25 | G4double GetNElectrons() const { return GetTotal(mapSum[0][1]); } 26 | G4double GetNPositrons() const { return GetTotal(mapSum[0][2]); } 27 | G4double GetNNeutrons() const { return GetTotal(mapSum[0][3]); } 28 | 29 | G4double GetEffectiveDose() const { return effectiveDosage; } 30 | inline void AddEffectiveDosage(G4double dose) { effectiveDosage += dose; } 31 | 32 | private: 33 | G4int CollID_plate; 34 | // We need ID values 35 | G4int nProton_ID; 36 | G4int nElectron_ID; 37 | G4int nPositron_ID; 38 | G4int nNeutron_ID; 39 | 40 | G4int PrintModulo; 41 | G4double SumDose; 42 | // Map well count the number of secondaries we have. We are just specifying the size 43 | G4THitsMap mapSum[2][3]; 44 | // Function defined in the class file 45 | G4double GetTotal(const G4THitsMap &map) const; 46 | 47 | G4double effectiveDosage; 48 | }; 49 | #endif 50 | -------------------------------------------------------------------------------- /tutorial5/include/RunAction.hh: -------------------------------------------------------------------------------- 1 | #ifndef RunAction_h 2 | #define RunAction_h 1 3 | 4 | #include "G4UserRunAction.hh" 5 | #include "globals.hh" 6 | 7 | class G4Run; 8 | 9 | class RunAction : public G4UserRunAction 10 | { 11 | public: 12 | RunAction(); 13 | virtual ~RunAction(); 14 | 15 | virtual G4Run* GenerateRun(); 16 | virtual void BeginOfRunAction(const G4Run*); 17 | virtual void EndOfRunAction(const G4Run*); 18 | 19 | inline void AddEffectiveDosage(G4double dose) { totalEffectiveDosage += dose; } 20 | 21 | private: 22 | G4double runEnergy; 23 | G4double totalEffectiveDosage; 24 | }; 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /tutorial5/include/StackingAction.hh: -------------------------------------------------------------------------------- 1 | #ifndef StackingAction_h 2 | #define StackingAction_h 1 3 | 4 | #include "G4UserStackingAction.hh" 5 | #include "globals.hh" 6 | 7 | class StackingAction : public G4UserStackingAction 8 | { 9 | public: 10 | StackingAction(); 11 | virtual ~StackingAction(); 12 | 13 | virtual G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track*); 14 | }; 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /tutorial5/include/SteppingAction.hh: -------------------------------------------------------------------------------- 1 | #ifndef SteppingAction_h 2 | #define SteppingAction_h 1 3 | 4 | #include "G4UserSteppingAction.hh" 5 | #include "G4UserEventAction.hh" 6 | #include "globals.hh" 7 | 8 | class DetectorConstruction; 9 | class EventAction; 10 | 11 | class SteppingAction : public G4UserSteppingAction 12 | { 13 | public: 14 | SteppingAction(const DetectorConstruction* detConst, EventAction* event); 15 | virtual ~SteppingAction(); 16 | 17 | virtual void UserSteppingAction(const G4Step*); 18 | inline G4double GetEffectiveDose() { return effectiveDose;} 19 | 20 | private: 21 | const DetectorConstruction* fDetConst; 22 | EventAction* fEvent; 23 | G4double effectiveDose; 24 | G4double energy; 25 | 26 | }; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /tutorial5/init_vis.mac: -------------------------------------------------------------------------------- 1 | # Macro file for tutorial 2 2 | # Let's make an interactive session 3 | # Set some default verbose 4 | /control/verbose 2 5 | /control/saveHistory 6 | /run/verbose 2 7 | 8 | #/run/setCutForAGivenParticle gamma 0.5 m 9 | #/cuts/setLowEdge 511 keV 10 | # Initialize kernel 11 | /run/initialize 12 | 13 | # Visualization setting 14 | /control/execute vis.mac 15 | -------------------------------------------------------------------------------- /tutorial5/run.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenwalton/Geant4Tutorials/9084bb7159326b032759939df9206f6a6677d860/tutorial5/run.png -------------------------------------------------------------------------------- /tutorial5/run1.mac: -------------------------------------------------------------------------------- 1 | /gun/particle e- 2 | /run/beamOn 10 3 | -------------------------------------------------------------------------------- /tutorial5/run2.mac: -------------------------------------------------------------------------------- 1 | /gun/particle geantino 2 | /run/beamOn 1 3 | -------------------------------------------------------------------------------- /tutorial5/runx10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenwalton/Geant4Tutorials/9084bb7159326b032759939df9206f6a6677d860/tutorial5/runx10.png -------------------------------------------------------------------------------- /tutorial5/src/ActionInitialization.cpp: -------------------------------------------------------------------------------- 1 | /* This code will be used to run the Primary Generator Action, Run Action, and Stacking actions. 2 | * This is just for helping with organization 3 | */ 4 | #include "ActionInitialization.hh" 5 | #include "PrimaryGeneratorAction.hh" 6 | #include "RunAction.hh" 7 | #include "StackingAction.hh" 8 | 9 | #include "EventAction.hh" 10 | #include "DetectorConstruction.hh" 11 | #include "SteppingAction.hh" 12 | 13 | ActionInitialization::ActionInitialization(DetectorConstruction* detConst) 14 | : G4VUserActionInitialization(), 15 | fDetConst(detConst) 16 | {} 17 | 18 | ActionInitialization::~ActionInitialization() 19 | {} 20 | 21 | void ActionInitialization::BuildForMaster() const 22 | { 23 | SetUserAction(new RunAction); 24 | } 25 | 26 | void ActionInitialization::Build() const 27 | { 28 | SetUserAction(new PrimaryGeneratorAction); 29 | RunAction* rAction = new RunAction; 30 | SetUserAction(rAction); 31 | EventAction* event = new EventAction(rAction); 32 | SetUserAction(event); 33 | SetUserAction(new SteppingAction(fDetConst, event)); 34 | SetUserAction(new StackingAction); 35 | } 36 | 37 | -------------------------------------------------------------------------------- /tutorial5/src/DetectorConstruction.cpp: -------------------------------------------------------------------------------- 1 | #include "DetectorConstruction.hh" 2 | #include "G4NistManager.hh" 3 | #include "G4Box.hh" 4 | #include "G4LogicalVolume.hh" 5 | #include "G4PVPlacement.hh" 6 | #include "G4RotationMatrix.hh" 7 | #include "G4Transform3D.hh" 8 | #include "G4PhysicalConstants.hh" 9 | #include "G4SystemOfUnits.hh" 10 | #include "G4SDManager.hh" 11 | #include "G4VPrimitiveScorer.hh" 12 | #include "G4PSEnergyDeposit.hh" 13 | #include "G4PSDoseDeposit.hh" 14 | #include "G4SDParticleFilter.hh" 15 | #include "G4PSEnergyDeposit.hh" 16 | #include "G4PSNofSecondary.hh" 17 | #include "G4VSDFilter.hh" 18 | 19 | #include "Materials.hh" 20 | 21 | DetectorConstruction::DetectorConstruction() 22 | : G4VUserDetectorConstruction(), 23 | platePV(0) 24 | { 25 | DefineMaterials(); 26 | } 27 | 28 | DetectorConstruction::~DetectorConstruction() 29 | {} 30 | 31 | // Create our world and box 32 | G4VPhysicalVolume* DetectorConstruction::Construct() 33 | { 34 | 35 | G4NistManager* man = G4NistManager::Instance(); 36 | G4Material* default_mat = man -> FindOrBuildMaterial("Air"); 37 | G4Material* box_mat = man -> FindOrBuildMaterial("lArgon"); 38 | G4Material* water = man -> FindOrBuildMaterial("Water"); 39 | 40 | /*** FIRST create the WORLD ***/ 41 | G4double worldSize = 1. * m; 42 | G4Box* solidWorld = new G4Box("World", worldSize, worldSize, worldSize); 43 | G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, default_mat, "World"); 44 | G4VPhysicalVolume* physWorld = new G4PVPlacement(0, G4ThreeVector(), logicWorld, "World", 0, false, 0); 45 | 46 | G4double Box_x = 0.5 * worldSize; 47 | G4double Box_y = 0.5 * worldSize; 48 | G4double Box_z = 0.5 * worldSize; 49 | 50 | G4Box* testBox = new G4Box("testBox", // Name 51 | Box_x, // x length 52 | Box_y, // y length 53 | Box_z); // z length 54 | 55 | G4LogicalVolume* testBox_log = new G4LogicalVolume(testBox, // Its solid (see the box we made) 56 | box_mat, // Its material 57 | "testBox"); // Its name 58 | 59 | // We can place this as part of the G4Logical Volume 60 | new G4PVPlacement(0, // Rotation 61 | G4ThreeVector(), // its location 62 | testBox_log, // the logical volume 63 | "testBox", // its name 64 | logicWorld, // its mother volume 65 | false, // boolean operations 66 | 0); // its copy number 67 | 68 | 69 | 70 | /* We are now going to create a thin plate and have it act as a detector. We'll place it at the edge of the world, opposite of the incoming rays. This means that 71 | * it will be located at the lowest value of x in our world. Remember that our particle gun was defined at 1.,0,0 72 | * */ 73 | G4Box* plate = new G4Box("plate", 74 | 0.1 * m, 75 | worldSize, 76 | worldSize); 77 | 78 | /*G4LogicalVolume*/ plate_log = new G4LogicalVolume(plate, 79 | water, 80 | "plateLV"); 81 | platePV = new G4PVPlacement(0, 82 | G4ThreeVector(0.9 * worldSize,0,0), // Remember that we have to account for the size of the box 83 | plate_log, 84 | "plate", 85 | logicWorld, 86 | false, 87 | 0); 88 | 89 | 90 | return physWorld; // Always return the world 91 | } 92 | 93 | // We are now going to create the detector here 94 | // Remember that we will have to edit our .hh file here 95 | void DetectorConstruction::ConstructSDandField() 96 | { 97 | G4SDManager* sdManage = G4SDManager::GetSDMpointer(); 98 | sdManage -> SetVerboseLevel(1); 99 | G4String filterName, particleName; 100 | // Changed name to detector to be clearer 101 | G4MultiFunctionalDetector* det = new G4MultiFunctionalDetector("plate"); 102 | sdManage -> AddNewDetector(det); 103 | G4VPrimitiveScorer* prim; 104 | prim = new G4PSDoseDeposit("dose"); // We want to record the dosage to the patient 105 | det -> RegisterPrimitive(prim); 106 | // Now we are going to apply filters to get the number of secondary particles 107 | // The way we order these filters will determine how we access them 108 | // We are keeping in line with the example RE06. We can access multiple detectors by changing 109 | // the i value where j specifies the filter 110 | // [i][j] = detector and filter 111 | // [0][0] = Protons 112 | G4SDParticleFilter* protonFilter = new G4SDParticleFilter(filterName="protonFilter", particleName="proton"); 113 | prim = new G4PSNofSecondary("nProton"); 114 | prim -> SetFilter(protonFilter); 115 | det -> RegisterPrimitive(prim); 116 | // [0][1] = e- 117 | G4SDParticleFilter* electronFilter = new G4SDParticleFilter("electronFilter", "e-"); 118 | prim = new G4PSNofSecondary("nElectron"); 119 | prim -> SetFilter(electronFilter); 120 | det -> RegisterPrimitive(prim); 121 | // [0][2] = e+ 122 | G4SDParticleFilter* positronFilter = new G4SDParticleFilter("positronFilter", "e+"); 123 | prim = new G4PSNofSecondary("nPositron"); 124 | prim -> SetFilter(positronFilter); 125 | det -> RegisterPrimitive(prim); 126 | // [0][3] = n 127 | G4SDParticleFilter* neutronFilter = new G4SDParticleFilter("neutronFilter", "neutron"); 128 | prim = new G4PSNofSecondary("nNeutron"); 129 | prim -> SetFilter(neutronFilter); 130 | det -> RegisterPrimitive(prim); 131 | // Have to set as a sensitive detector and the logical volume we are pointing at 132 | SetSensitiveDetector("plateLV", det); 133 | } 134 | 135 | -------------------------------------------------------------------------------- /tutorial5/src/EventAction.cpp: -------------------------------------------------------------------------------- 1 | #include "EventAction.hh" 2 | #include "RunAction.hh" 3 | #include "G4RunManager.hh" 4 | #include "G4Event.hh" 5 | #include "G4UnitsTable.hh" 6 | #include "Randomize.hh" 7 | #include 8 | #include "G4HCofThisEvent.hh" 9 | #include "G4SystemOfUnits.hh" 10 | 11 | EventAction::EventAction(RunAction* runAction) 12 | : G4UserEventAction(), 13 | fRunAction(runAction), 14 | totalEnergy(0.), 15 | effDose(0.) 16 | {} 17 | 18 | EventAction::~EventAction() 19 | {} 20 | 21 | void EventAction::BeginOfEventAction(const G4Event*) 22 | { 23 | totalEnergy = 0.; 24 | effDose = 0.; 25 | } 26 | 27 | void EventAction::EndOfEventAction(const G4Event* event) 28 | { 29 | 30 | G4int eventID = event -> GetEventID(); 31 | fEventID = eventID; 32 | fHCE = event -> GetHCofThisEvent(); 33 | G4int printModulo = G4RunManager::GetRunManager() -> GetPrintProgress(); 34 | if ( ( printModulo > 0 ) && ( eventID % printModulo == 0 ) ) 35 | { 36 | fRunAction -> AddEffectiveDosage(effDose); 37 | G4cout << "\n\n---> End of Event: " << eventID << G4endl; 38 | 39 | G4cout << " Total deposited energy: " << std::setw(7) 40 | << G4BestUnit(totalEnergy, "Energy") 41 | << "\n Effective Dose: " << effDose << " Sv" 42 | << G4endl; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /tutorial5/src/PhysicsList.cpp: -------------------------------------------------------------------------------- 1 | #include "PhysicsList.hh" 2 | 3 | #include "G4DecayPhysics.hh" 4 | #include "G4RadioactiveDecayPhysics.hh" 5 | #include "G4EmStandardPhysics.hh" 6 | 7 | PhysicsList::PhysicsList() 8 | : G4VModularPhysicsList() 9 | { 10 | RegisterPhysics(new G4DecayPhysics()); 11 | RegisterPhysics(new G4RadioactiveDecayPhysics()); 12 | RegisterPhysics(new G4EmStandardPhysics()); 13 | } 14 | 15 | PhysicsList::~PhysicsList() 16 | {} 17 | 18 | void PhysicsList::SetCuts() 19 | { 20 | G4VUserPhysicsList::SetCuts(); 21 | } 22 | -------------------------------------------------------------------------------- /tutorial5/src/PrimaryGeneratorAction.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Remember to use the header file in the /include folder 3 | */ 4 | 5 | #include "PrimaryGeneratorAction.hh" 6 | 7 | #include "G4RunManager.hh" 8 | #include "G4Event.hh" 9 | #include "G4ParticleGun.hh" 10 | #include "G4ThreeVector.hh" 11 | #include "G4ParticleTable.hh" 12 | #include "G4ParticleDefinition.hh" 13 | #include "G4IonTable.hh" 14 | #include "globals.hh" 15 | #include "G4SystemOfUnits.hh" 16 | 17 | //New 18 | #include "G4LogicalVolumeStore.hh" 19 | #include "G4LogicalVolume.hh" 20 | #include "G4Box.hh" 21 | #include "Randomize.hh" 22 | 23 | PrimaryGeneratorAction::PrimaryGeneratorAction() 24 | : G4VUserPrimaryGeneratorAction(), 25 | particleGun(0), 26 | EnvelopeBox(0) 27 | { 28 | G4int n_particle = 1; 29 | particleGun = new G4ParticleGun(n_particle); 30 | 31 | // Here we'll load the whole particle table to be able to call a lookup 32 | G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable(); 33 | G4String particleName; 34 | G4ParticleDefinition* particle = particleTable -> FindParticle(particleName="gamma"); 35 | 36 | particleGun -> SetParticleDefinition(particle); 37 | particleGun -> SetParticleEnergy(6.0 * MeV); 38 | 39 | //particleGun -> SetParticlePosition(G4ThreeVector(-1.*m, 0.*m, 0.*m)); 40 | particleGun -> SetParticleMomentumDirection(G4ThreeVector(1., 0., 0.)); 41 | } 42 | 43 | // Create destructor 44 | PrimaryGeneratorAction::~PrimaryGeneratorAction() 45 | { 46 | delete particleGun; 47 | } 48 | 49 | // Primary event 50 | void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) 51 | { 52 | /* 53 | * To avoid dependence on Detector Construction we will get an envelope volume 54 | * from the G4LogicalVolumeStore 55 | * 56 | * Here we will be assuming our box is sitting in a world where the radiation flux 57 | * is coming from the -x direction. Thus we will have a uniform random start location 58 | * through the YZ plane 59 | */ 60 | G4double envSizeX = 0.; 61 | G4double envSizeYZ = 0.; 62 | 63 | if ( !EnvelopeBox ) 64 | { 65 | G4LogicalVolume* envLV = G4LogicalVolumeStore::GetInstance() -> GetVolume("World"); 66 | if ( envLV ) EnvelopeBox = dynamic_cast( envLV -> GetSolid() ); 67 | } 68 | 69 | if ( EnvelopeBox ) 70 | { 71 | envSizeYZ = EnvelopeBox -> GetYHalfLength() *2.; 72 | envSizeX = EnvelopeBox -> GetXHalfLength() *2.; 73 | } 74 | else 75 | { 76 | G4ExceptionDescription msg; 77 | msg << "World volume of box shape is not found.\n"; 78 | msg << "Perhaps you have changed the geometry.\n"; 79 | msg << "\nWhere has the world gone?"; 80 | G4Exception("PrimaryGeneratorAction::GeneratePrimaries()","Mycode0001",JustWarning,msg); 81 | } 82 | 83 | // We won't use the outer 10% edge 84 | G4double size = 0.9; 85 | // Since we are starting in the -x direction and firing in the x direction we want the 86 | // particles to come uniformly out of the YZ plane 87 | G4double x0 = 0.5 * envSizeX; 88 | G4double y0 = size * envSizeYZ * (G4UniformRand() - 0.5); 89 | G4double z0 = size * envSizeYZ * (G4UniformRand() - 0.5); 90 | 91 | particleGun -> SetParticlePosition(G4ThreeVector(-x0,y0,z0)); 92 | //particleGun -> SetParticleMomentumDirection(G4ThreeVector(1.0,0.,0.)); // Pure x momentum 93 | 94 | particleGun -> GeneratePrimaryVertex(anEvent); // creates the initial momentum 95 | } 96 | -------------------------------------------------------------------------------- /tutorial5/src/Run.cpp: -------------------------------------------------------------------------------- 1 | /* NEW FILE 2 | * In this file we are mapping the dosages to the detector. We want to track the event ID 3 | */ 4 | #include "Run.hh" 5 | 6 | #include "G4RunManager.hh" 7 | #include "G4Event.hh" 8 | #include "G4SDManager.hh" 9 | #include "G4HCofThisEvent.hh" 10 | #include "G4THitsMap.hh" 11 | #include "G4SystemOfUnits.hh" 12 | #include "G4VPrimitiveScorer.hh" 13 | #include "G4MultiFunctionalDetector.hh" 14 | #include "G4String.hh" 15 | 16 | /* We want to set up the event with these parameters. Very important to set the Sum Dosage so that we don't stack the values from 17 | * random points in memory */ 18 | Run::Run() 19 | : G4Run(), 20 | CollID_plate(-1), 21 | nProton_ID(-1), 22 | nElectron_ID(-1), 23 | nPositron_ID(-1), 24 | nNeutron_ID(-1), 25 | PrintModulo(10000), 26 | SumDose(0.) 27 | { 28 | } 29 | 30 | Run::~Run() 31 | { 32 | } 33 | 34 | void Run::RecordEvent(const G4Event* event)//, EventAction* fEvent) 35 | { 36 | // Note how this relates to the condition above. We now can find the ID of the dose the plate gets 37 | if (CollID_plate < 0) 38 | CollID_plate = G4SDManager::GetSDMpointer() -> GetCollectionID("plate/dose"); 39 | if ( nProton_ID < 0 ) 40 | nProton_ID = G4SDManager::GetSDMpointer() -> GetCollectionID("plate/nProton"); 41 | if (nElectron_ID < 0 ) 42 | nElectron_ID = G4SDManager::GetSDMpointer() -> GetCollectionID("plate/nElectron"); 43 | if ( nPositron_ID < 0 ) 44 | nPositron_ID = G4SDManager::GetSDMpointer() -> GetCollectionID("plate/nPositron"); 45 | if ( nNeutron_ID < 0 ) 46 | nNeutron_ID = G4SDManager::GetSDMpointer() -> GetCollectionID("plate/nNeutron"); 47 | 48 | // We also want to pull the ID for the event 49 | G4int evtNb = event -> GetEventID(); 50 | 51 | // Every time an event ends we want to separate it from new events. We make this clear with our output 52 | if(evtNb%PrintModulo == 0) 53 | { 54 | G4cout << G4endl << "---> end of events: " << evtNb << G4endl; 55 | } 56 | 57 | // Collections of Hits 58 | G4HCofThisEvent* HCE = event -> GetHCofThisEvent(); 59 | if(!HCE) return; 60 | 61 | // Dosage deposit in the plate 62 | G4double dose = 0.; 63 | 64 | // We need to preform a cast here to get the correct data type 65 | G4THitsMap* evtMap = static_cast< G4THitsMap*>(HCE -> GetHC(CollID_plate)); 66 | 67 | // Loop to map the events and add the dosages so that we get a total dose 68 | std::map::iterator i; 69 | for (i = evtMap -> GetMap() -> begin(); i != evtMap -> GetMap() -> end(); ++i) 70 | dose = *(i -> second); 71 | SumDose += dose; 72 | // We are using the maps to count the particles 73 | evtMap = (G4THitsMap*)(HCE -> GetHC(nProton_ID)); 74 | mapSum[0][0] += *evtMap; // Adds the Protons 75 | evtMap = (G4THitsMap*)(HCE -> GetHC(nElectron_ID)); 76 | mapSum[0][1] += *evtMap; // Adds the electrons 77 | evtMap = (G4THitsMap*)(HCE -> GetHC(nPositron_ID)); 78 | mapSum[0][2] += *evtMap; // Adds the positrons 79 | evtMap = (G4THitsMap*)(HCE -> GetHC(nNeutron_ID)); 80 | mapSum[0][3] += *evtMap; // Adds Neutrons 81 | 82 | G4Run::RecordEvent(event); // invoke base class method 83 | } 84 | 85 | // We need this function to get the total number from each map 86 | G4double Run::GetTotal(const G4THitsMap &map) const 87 | { 88 | G4double tot = 0.; 89 | if ( map.GetSize() == 0 ) return tot; 90 | std::map::iterator itr; 91 | for (itr = map.GetMap() -> begin(); itr != map.GetMap() -> end(); ++itr ) 92 | tot += *(itr -> second); 93 | return tot; 94 | } 95 | 96 | void Run::Merge(const G4Run* aRun) 97 | { 98 | const Run* localRun = static_cast(aRun); 99 | SumDose += localRun -> SumDose; 100 | // Note that the order here is from the order we specified when creating the filters 101 | // Remember that each run is an independent event 102 | mapSum[0][0] += localRun -> mapSum[0][0]; // Protons 103 | mapSum[0][1] += localRun -> mapSum[0][1]; // Electrons 104 | mapSum[0][2] += localRun -> mapSum[0][2]; // Positrons 105 | mapSum[0][3] += localRun -> mapSum[0][3]; // Neutrons 106 | 107 | G4Run::Merge(aRun); 108 | } 109 | 110 | -------------------------------------------------------------------------------- /tutorial5/src/RunAction.cpp: -------------------------------------------------------------------------------- 1 | /* NEW FILE 2 | * Here we need to control our output. Most of this file is to handle the 3 | * dosage output 4 | */ 5 | #include "RunAction.hh" 6 | #include "PrimaryGeneratorAction.hh" 7 | #include "Run.hh" 8 | 9 | #include "G4Run.hh" 10 | #include "G4RunManager.hh" 11 | #include "G4UnitsTable.hh" 12 | #include "G4SystemOfUnits.hh" 13 | 14 | #include "G4ParticleDefinition.hh" 15 | #include "G4ParticleTable.hh" 16 | #include "G4ParticleGun.hh" 17 | 18 | RunAction::RunAction() 19 | : G4UserRunAction(), 20 | totalEffectiveDosage(0.) 21 | { 22 | G4RunManager::GetRunManager() -> SetPrintProgress(1); 23 | 24 | // We need the units for the dosages since GEANT4 doesn't know what a gray is 25 | const G4double milligray = 1.e-3 * gray; 26 | const G4double microgray = 1.e-6 * gray; 27 | const G4double nanogray = 1.e-9 * gray; 28 | const G4double picogray = 1.e-12* gray; 29 | 30 | // We really want units that are more easily read 31 | // We could just as easily use this to put our system in the furlong frikin fortnight system 32 | new G4UnitDefinition("milligray", "milliGy", "Dose", milligray); 33 | new G4UnitDefinition("microgray", "microGy", "Dose", microgray); 34 | new G4UnitDefinition("nanogray" , "nanoGy" , "Dose", nanogray); 35 | new G4UnitDefinition("picogray" , "picoGy" , "Dose", picogray); 36 | } 37 | 38 | RunAction::~RunAction() 39 | {} 40 | 41 | G4Run* RunAction::GenerateRun() 42 | { 43 | return new Run; 44 | } 45 | 46 | void RunAction::BeginOfRunAction(const G4Run* run) 47 | { 48 | G4cout << "### Run " << run -> GetRunID() << " start." << G4endl; 49 | 50 | // We need to inform the run manager to save the random number seed 51 | G4RunManager::GetRunManager() -> SetRandomNumberStore(false); 52 | totalEffectiveDosage = 0.; 53 | } 54 | 55 | void RunAction::EndOfRunAction(const G4Run* run) 56 | { 57 | G4int nofEvents = run -> GetNumberOfEvent(); 58 | if (nofEvents == 0) return; 59 | 60 | // Our run conditions 61 | const PrimaryGeneratorAction* generatorAction 62 | = static_cast 63 | (G4RunManager::GetRunManager() -> GetUserPrimaryGeneratorAction()); 64 | G4String partName; 65 | 66 | if (generatorAction) 67 | { 68 | G4ParticleDefinition* particle 69 | = generatorAction -> GetParticleGun() -> GetParticleDefinition(); 70 | partName = particle -> GetParticleName(); 71 | G4cout << "Gun particle name: " << partName << G4endl; // We can get the gun particle's name by outputting to the screen here 72 | } 73 | 74 | // Get our results \ o / 75 | const Run* tRun = static_cast(run); 76 | G4double sumDose = tRun -> GetSumDose(); 77 | G4double nEl = tRun -> GetNElectrons(); 78 | G4double nP = tRun -> GetNProtons(); 79 | G4double nEp = tRun -> GetNPositrons(); 80 | G4double nN = tRun -> GetNNeutrons(); 81 | 82 | // And print the data 83 | if (IsMaster()) 84 | { 85 | G4cout << G4endl 86 | << "--------------- End of Global Run --------------" 87 | << G4endl 88 | << " The run was " << nofEvents << " events "; 89 | } 90 | else 91 | { 92 | G4cout << G4endl 93 | << "--------------- End of Local Run ---------------" 94 | << G4endl 95 | << " The run was " << nofEvents << " " << partName; 96 | } 97 | G4cout << G4endl 98 | << "Total dose to the plate : " << G4BestUnit(sumDose, "Dose") 99 | << G4endl 100 | // Now we'll output values 101 | << "Number of Protons collected: " << nP << G4endl 102 | << "Number of Electrons collected: " << nEl << G4endl 103 | << "Number of Positrons collected: " << nEp << G4endl 104 | << "Number of Neutrons collected: " << nN << G4endl 105 | << "Total Effective Dose is: " << totalEffectiveDosage << " Sv" << G4endl 106 | << "--------------------------------------------------" 107 | << G4endl 108 | << G4endl; 109 | } 110 | -------------------------------------------------------------------------------- /tutorial5/src/StackingAction.cpp: -------------------------------------------------------------------------------- 1 | /* NEW FILE 2 | * Here we are really just deleting neutrinos because we don't care about them 3 | */ 4 | #include "StackingAction.hh" 5 | 6 | #include "G4Track.hh" 7 | #include "G4NeutrinoE.hh" 8 | 9 | StackingAction::StackingAction() 10 | {} 11 | 12 | StackingAction::~StackingAction() 13 | {} 14 | 15 | G4ClassificationOfNewTrack 16 | StackingAction::ClassifyNewTrack(const G4Track* track) 17 | { 18 | // Keep Primary Particle 19 | if (track -> GetParentID() == 0) return fUrgent; 20 | 21 | // KILL the secondary neutrinos (from beta decays) 22 | if (track -> GetDefinition() == G4NeutrinoE::NeutrinoE()) return fKill; 23 | else return fUrgent; 24 | } 25 | 26 | /* 27 | * Remember that during beta decays there is either a neutrino or antineutrino. We are just killing the neutrinos here because of the B+ decay, find 28 | * out how to kill the antineutrino form the e- decay 29 | */ 30 | -------------------------------------------------------------------------------- /tutorial5/src/SteppingAction.cpp: -------------------------------------------------------------------------------- 1 | #include "SteppingAction.hh" 2 | #include "EventAction.hh" 3 | #include "DetectorConstruction.hh" 4 | 5 | #include "G4Step.hh" 6 | #include "G4RunManager.hh" 7 | #include "G4SystemOfUnits.hh" 8 | #include "G4SDManager.hh" 9 | #include 10 | 11 | #include "G4UnitsTable.hh" 12 | 13 | SteppingAction::SteppingAction(const DetectorConstruction* detConst, EventAction* event) 14 | : G4UserSteppingAction(), 15 | fDetConst(detConst), 16 | fEvent(event), 17 | effectiveDose(0.), 18 | energy(0.) 19 | {} 20 | 21 | SteppingAction::~SteppingAction() 22 | {} 23 | 24 | void SteppingAction::UserSteppingAction(const G4Step* step) 25 | { 26 | // Volume of current Step 27 | G4VPhysicalVolume* volume = step -> GetPreStepPoint() -> GetTouchableHandle() -> GetVolume(); 28 | // Get Energy deposit 29 | // We only run next steps if the fEvent happens in the detector to save computation time 30 | if ( volume == fDetConst -> GetAbsorberPV() ) 31 | { 32 | G4double mass = (step -> GetPreStepPoint() -> GetTouchableHandle() -> GetVolume() -> GetLogicalVolume() -> GetMass())/kg; 33 | energy = step -> GetTotalEnergyDeposit(); 34 | fEvent -> AddEnergy(energy); 35 | // We want to convert to Sieverts. Which is J/kg 36 | G4double edep = (energy/MeV) * ( 1.60218e-13 ); // MeV = 1.602e-13 J 37 | G4double nonIon = step -> GetNonIonizingEnergyDeposit(); 38 | G4double dose = (edep - nonIon) / mass; 39 | G4String particleName = step -> GetTrack() -> GetDynamicParticle() -> GetDefinition() -> GetParticleName(); 40 | if ( particleName == "gamma" || particleName == "e-" || particleName == "e+" ) 41 | { 42 | if ( particleName == "gamma" ) 43 | fEvent -> addGammDose(dose); 44 | else 45 | fEvent -> addBetaDose(dose); 46 | } 47 | else if ( particleName == "proton" ) 48 | { 49 | dose *= 2.; 50 | fEvent -> addProtDose(dose); 51 | } 52 | else if ( particleName == "alpha" /* or fission fragments */ ) 53 | { 54 | dose *= 20.; 55 | fEvent -> addAlphDose(dose); 56 | } 57 | // Weights from ICRP 103 58 | else if ( particleName == "neutron" ) 59 | { 60 | G4double weight = 0.; 61 | if ( energy < 1*MeV ) 62 | weight = 2.5 + (18.2*exp(-1 * pow(log(energy),2)/6)); 63 | else if ( energy< 50 * MeV ) 64 | weight = 5.0 + (17.0 * exp(-1 * pow(log(2*energy),2)/6)); 65 | else // E_n > 50 MeV 66 | weight = 2.5 + (3.25 * exp(-1 * pow(log(0.04*energy),2)/6)); 67 | dose *= weight; 68 | fEvent -> addNeutDose(dose); 69 | } 70 | else 71 | { 72 | dose *= 0.; 73 | G4cout << "\nWARNING: WE DON'T HAVE WEIGHT FOR: " << particleName << G4endl; 74 | } 75 | 76 | effectiveDose += dose; 77 | fEvent -> addEffectiveDose(dose); 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /tutorial5/tutorial5.cpp: -------------------------------------------------------------------------------- 1 | #include "G4RunManager.hh" 2 | #include "G4UImanager.hh" 3 | #include "G4VisExecutive.hh" 4 | #include "G4UIExecutive.hh" 5 | #include "DetectorConstruction.hh" 6 | #include "PhysicsList.hh" 7 | //#include "PrimaryGeneratorAction.hh" 8 | #include "ActionInitialization.hh" 9 | #include "EventAction.hh" 10 | 11 | int main(int argc, char** argv) 12 | { 13 | // Initialize ui to a null value 14 | G4UIExecutive* ui = 0; 15 | // If we only have no arguments then we want a visual interface 16 | if ( argc == 1 ) 17 | ui = new G4UIExecutive(argc, argv); 18 | 19 | G4RunManager* runManager = new G4RunManager; 20 | 21 | G4VisManager* visManager = new G4VisExecutive; 22 | visManager -> Initialize(); 23 | 24 | DetectorConstruction* detConst = new DetectorConstruction; 25 | runManager -> SetUserInitialization(detConst); 26 | runManager -> SetUserInitialization(new PhysicsList); 27 | runManager -> SetUserInitialization(new ActionInitialization(detConst)); 28 | 29 | runManager -> Initialize(); 30 | 31 | G4UImanager* UI = G4UImanager::GetUIpointer(); 32 | 33 | // We have given a number of macro commands, let's run them 34 | if ( !ui ) 35 | { 36 | G4String command = "/control/execute "; 37 | // Loop through the macro commands. Remember that argv[1] is the first macro and argv[0] is the 38 | // command you ran ie: `./tutorial5` 39 | for ( int i = 1; i < argc; ++i ) 40 | { 41 | G4String fileName = argv[i]; 42 | UI -> ApplyCommand(command + fileName); 43 | } 44 | } 45 | else 46 | { 47 | // get pointer to UI manager and set verbosities 48 | UI -> ApplyCommand("/control/execute init_vis.mac"); 49 | // Have to add this to get the gui command 50 | UI -> ApplyCommand("/control/execute gui.mac"); 51 | ui -> SessionStart(); 52 | 53 | delete ui; 54 | } 55 | 56 | // TERMINATE job 57 | delete runManager; 58 | delete visManager; 59 | 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /tutorial5/vis.mac: -------------------------------------------------------------------------------- 1 | # Macrofile for visualization, split with init_vis 2 | 3 | # We're using OpenGL (See vis files in examples for other drivers such as OpenInventor, DAWN, HepRApp and others 4 | 5 | /vis/open OGL 900x900-0+0 6 | # I get a weird error with my VM and so I do this as a workaround 7 | /vis/ogl/set/displayListLimit 100000000000000 8 | 9 | # Disable auto refresh and quieten vis messages whilst scene and trajectories established 10 | /vis/viewer/set/autoRefresh false 11 | /vis/verbose errors 12 | 13 | # Draw the geometry we created 14 | /vis/drawVolume 15 | 16 | # Specify viewing angle 17 | /vis/viewer/set/viewpointThetaPhi 30. 120. 18 | # We're going to draw axes 19 | /vis/scene/add/axes 20 | 21 | # Make smooth trajectories at end of event, trajectory points as markers 2px wide 22 | /vis/scene/add/trajectories smooth 23 | /vis/modeling/trajectories/create/drawByCharge 24 | #/vis/modeling/trajectories/drawByCharge-0/default/setDrawStepPts true 25 | #/vis/modeling/trajectories/drawByChage-0/default/setStepPtsSize 1 26 | 27 | # Select colour by particle ID 28 | /vis/modeling/trajectories/create/drawByParticleID 29 | /vis/modeling/trajectories/drawByParticleID-0/default/setDrawStepPts true 30 | 31 | # Superimpose all events from given run 32 | /vis/scene/endOfEventAction accumulate 33 | 34 | # Re-establish auto refreshing and verbosity 35 | /vis/viewer/set/autoRefresh true 36 | /vis/verbose warnings 37 | 38 | --------------------------------------------------------------------------------