From 96e661a8df058821ea93876e05ba66c516623b91 Mon Sep 17 00:00:00 2001 From: Stuart Douglas Date: Tue, 17 Nov 2015 13:15:21 -0500 Subject: [PATCH] add cuda example --- .gitignore | 2 +- CUDA_Hadr04/src/CMakeLists.txt | 14 + CUDA_Hadr04/src/CUDA_G4NeutronHPVector.cu | 32 +++ CUDA_Hadr04/src/CUDA_G4NeutronHPVector.h | 1 + CUDA_Hadr04/src/Hadr04/.README | 127 +++++++++ CUDA_Hadr04/src/Hadr04/CMakeLists.txt | 73 ++++++ CUDA_Hadr04/src/Hadr04/GNUmakefile | 23 ++ CUDA_Hadr04/src/Hadr04/Hadr04.cc | 117 +++++++++ CUDA_Hadr04/src/Hadr04/History | 45 ++++ CUDA_Hadr04/src/Hadr04/README | 114 +++++++++ CUDA_Hadr04/src/Hadr04/debug.mac | 16 ++ CUDA_Hadr04/src/Hadr04/envHadronic.csh | 18 ++ CUDA_Hadr04/src/Hadr04/envHadronic.sh | 27 ++ CUDA_Hadr04/src/Hadr04/graphite.mac | 35 +++ CUDA_Hadr04/src/Hadr04/hadr04.in | 24 ++ .../Hadr04/include/ActionInitialization.hh | 59 +++++ .../Hadr04/include/DetectorConstruction.hh | 94 +++++++ .../src/Hadr04/include/DetectorMessenger.hh | 72 ++++++ .../src/Hadr04/include/HistoManager.hh | 58 +++++ .../src/Hadr04/include/NeutronHPMessenger.hh | 63 +++++ .../src/Hadr04/include/NeutronHPphysics.hh | 65 +++++ CUDA_Hadr04/src/Hadr04/include/PhysicsList.hh | 53 ++++ .../Hadr04/include/PrimaryGeneratorAction.hh | 66 +++++ CUDA_Hadr04/src/Hadr04/include/Run.hh | 86 +++++++ CUDA_Hadr04/src/Hadr04/include/RunAction.hh | 71 ++++++ .../src/Hadr04/include/StackingAction.hh | 54 ++++ .../src/Hadr04/include/SteppingAction.hh | 58 +++++ .../src/Hadr04/include/SteppingVerbose.hh | 55 ++++ .../src/Hadr04/include/TrackingAction.hh | 61 +++++ CUDA_Hadr04/src/Hadr04/plotHisto.C | 33 +++ CUDA_Hadr04/src/Hadr04/run01.mac | 35 +++ .../src/Hadr04/src/ActionInitialization.cc | 86 +++++++ .../src/Hadr04/src/DetectorConstruction.cc | 199 +++++++++++++++ .../src/Hadr04/src/DetectorMessenger.cc | 135 ++++++++++ CUDA_Hadr04/src/Hadr04/src/HistoManager.cc | 91 +++++++ .../src/Hadr04/src/NeutronHPMessenger.cc | 72 ++++++ .../src/Hadr04/src/NeutronHPphysics.cc | 143 +++++++++++ CUDA_Hadr04/src/Hadr04/src/PhysicsList.cc | 101 ++++++++ .../src/Hadr04/src/PrimaryGeneratorAction.cc | 92 +++++++ CUDA_Hadr04/src/Hadr04/src/Run.cc | 240 ++++++++++++++++++ CUDA_Hadr04/src/Hadr04/src/RunAction.cc | 184 ++++++++++++++ CUDA_Hadr04/src/Hadr04/src/StackingAction.cc | 70 +++++ CUDA_Hadr04/src/Hadr04/src/SteppingAction.cc | 77 ++++++ CUDA_Hadr04/src/Hadr04/src/SteppingVerbose.cc | 158 ++++++++++++ CUDA_Hadr04/src/Hadr04/src/TrackingAction.cc | 98 +++++++ CUDA_Hadr04/src/Hadr04/vis.mac | 79 ++++++ 46 files changed, 3475 insertions(+), 1 deletion(-) create mode 100644 CUDA_Hadr04/src/CMakeLists.txt create mode 100644 CUDA_Hadr04/src/CUDA_G4NeutronHPVector.cu create mode 100644 CUDA_Hadr04/src/CUDA_G4NeutronHPVector.h create mode 100644 CUDA_Hadr04/src/Hadr04/.README create mode 100644 CUDA_Hadr04/src/Hadr04/CMakeLists.txt create mode 100644 CUDA_Hadr04/src/Hadr04/GNUmakefile create mode 100644 CUDA_Hadr04/src/Hadr04/Hadr04.cc create mode 100644 CUDA_Hadr04/src/Hadr04/History create mode 100644 CUDA_Hadr04/src/Hadr04/README create mode 100644 CUDA_Hadr04/src/Hadr04/debug.mac create mode 100755 CUDA_Hadr04/src/Hadr04/envHadronic.csh create mode 100755 CUDA_Hadr04/src/Hadr04/envHadronic.sh create mode 100644 CUDA_Hadr04/src/Hadr04/graphite.mac create mode 100644 CUDA_Hadr04/src/Hadr04/hadr04.in create mode 100644 CUDA_Hadr04/src/Hadr04/include/ActionInitialization.hh create mode 100644 CUDA_Hadr04/src/Hadr04/include/DetectorConstruction.hh create mode 100644 CUDA_Hadr04/src/Hadr04/include/DetectorMessenger.hh create mode 100644 CUDA_Hadr04/src/Hadr04/include/HistoManager.hh create mode 100644 CUDA_Hadr04/src/Hadr04/include/NeutronHPMessenger.hh create mode 100644 CUDA_Hadr04/src/Hadr04/include/NeutronHPphysics.hh create mode 100644 CUDA_Hadr04/src/Hadr04/include/PhysicsList.hh create mode 100644 CUDA_Hadr04/src/Hadr04/include/PrimaryGeneratorAction.hh create mode 100644 CUDA_Hadr04/src/Hadr04/include/Run.hh create mode 100644 CUDA_Hadr04/src/Hadr04/include/RunAction.hh create mode 100644 CUDA_Hadr04/src/Hadr04/include/StackingAction.hh create mode 100644 CUDA_Hadr04/src/Hadr04/include/SteppingAction.hh create mode 100644 CUDA_Hadr04/src/Hadr04/include/SteppingVerbose.hh create mode 100644 CUDA_Hadr04/src/Hadr04/include/TrackingAction.hh create mode 100644 CUDA_Hadr04/src/Hadr04/plotHisto.C create mode 100644 CUDA_Hadr04/src/Hadr04/run01.mac create mode 100644 CUDA_Hadr04/src/Hadr04/src/ActionInitialization.cc create mode 100644 CUDA_Hadr04/src/Hadr04/src/DetectorConstruction.cc create mode 100644 CUDA_Hadr04/src/Hadr04/src/DetectorMessenger.cc create mode 100644 CUDA_Hadr04/src/Hadr04/src/HistoManager.cc create mode 100644 CUDA_Hadr04/src/Hadr04/src/NeutronHPMessenger.cc create mode 100644 CUDA_Hadr04/src/Hadr04/src/NeutronHPphysics.cc create mode 100644 CUDA_Hadr04/src/Hadr04/src/PhysicsList.cc create mode 100644 CUDA_Hadr04/src/Hadr04/src/PrimaryGeneratorAction.cc create mode 100644 CUDA_Hadr04/src/Hadr04/src/Run.cc create mode 100644 CUDA_Hadr04/src/Hadr04/src/RunAction.cc create mode 100644 CUDA_Hadr04/src/Hadr04/src/StackingAction.cc create mode 100644 CUDA_Hadr04/src/Hadr04/src/SteppingAction.cc create mode 100644 CUDA_Hadr04/src/Hadr04/src/SteppingVerbose.cc create mode 100644 CUDA_Hadr04/src/Hadr04/src/TrackingAction.cc create mode 100644 CUDA_Hadr04/src/Hadr04/vis.mac diff --git a/.gitignore b/.gitignore index 6b923070..3a7b0042 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,7 @@ G4STORK/Build-xcode-serial geant4.10.00.p02-build-xcode CUDA_simpleTest/bin -CUDA_Hadr04 +CUDA_Hadr04/bin # Geant / G4STORK build files G4STORK/Build/* diff --git a/CUDA_Hadr04/src/CMakeLists.txt b/CUDA_Hadr04/src/CMakeLists.txt new file mode 100644 index 00000000..f269c93f --- /dev/null +++ b/CUDA_Hadr04/src/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required (VERSION 2.8) + +option (USE_GPU "Use CUDA to run simulations on the GPU" ON) +add_subdirectory(Hadr04) + +if (USE_GPU) + find_package (CUDA REQUIRED) + + include_directories(/usr/local/cuda/include) + cuda_add_library (CUDA_G4NeutronHPVector SHARED CUDA_G4NeutronHPVector.h CUDA_G4NeutronHPVector.cu) + + LIST(APPEND CUDA_NVCC_FLAGS --compiler-options -fno-strict-aliasing -lineinfo -use_fast_math -Xptxas -dlcm=cg) + LIST(APPEND CUDA_NVCC_FLAGS -gencode arch=compute_30,code=sm_30) +endif() \ No newline at end of file diff --git a/CUDA_Hadr04/src/CUDA_G4NeutronHPVector.cu b/CUDA_Hadr04/src/CUDA_G4NeutronHPVector.cu new file mode 100644 index 00000000..4f516ffe --- /dev/null +++ b/CUDA_Hadr04/src/CUDA_G4NeutronHPVector.cu @@ -0,0 +1,32 @@ +#include +#include +#include +#include "CUDA_G4NeutronHPVector.h" + +// CUDA kernel +__global__ +void sumArrays(int* arr1, int* arr2, int* res, int n) +{ + int tid = blockIdx.x; + if (tid < n) + res[tid] = arr1[tid] + arr2[tid]; +} + +void CUDA_sumArrays(int* arr1, int* arr2, int* res, int n) { + int *gpu_arr1, *gpu_arr2, *gpu_res; + + cudaMalloc((void**)&gpu_arr1, n*sizeof(int)); + cudaMalloc((void**)&gpu_arr2, n*sizeof(int)); + cudaMalloc((void**)&gpu_res, n*sizeof(int)); + + cudaMemcpy(gpu_arr1, arr1, n*sizeof(int), cudaMemcpyHostToDevice); + cudaMemcpy(gpu_arr2, arr2, n*sizeof(int), cudaMemcpyHostToDevice); + + sumArrays<<>>(gpu_arr1, gpu_arr2, gpu_res, n); + + cudaMemcpy(res, gpu_res, n*sizeof(int), cudaMemcpyDeviceToHost); + + cudaFree(gpu_arr1); + cudaFree(gpu_arr2); + cudaFree(gpu_res); +} diff --git a/CUDA_Hadr04/src/CUDA_G4NeutronHPVector.h b/CUDA_Hadr04/src/CUDA_G4NeutronHPVector.h new file mode 100644 index 00000000..3e63212d --- /dev/null +++ b/CUDA_Hadr04/src/CUDA_G4NeutronHPVector.h @@ -0,0 +1 @@ +void CUDA_sumArrays(int* arr1, int* arr2, int* res, int n); diff --git a/CUDA_Hadr04/src/Hadr04/.README b/CUDA_Hadr04/src/Hadr04/.README new file mode 100644 index 00000000..bc5b6793 --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/.README @@ -0,0 +1,127 @@ +//$Id$ + +///\file "hadronic/Hadr04/.README" +///\brief Example Hadr04 README page + +/*! \page ExampleHadr04 Example Hadr04 + + This example is focused on neutronHP physics, especially neutron transport, + including thermal scattering. + See A.R. Garcia, E. Mendoza, D. Cano-Ott presentation at G4 Hadronic group + meeting (04/2013) and note on G4NeutronHP package + +\section Hadr04_s1 MATERIALS AND GEOMETRY DEFINITION + + It is a single box representing a 'quasi infinite' homogeneous medium. + Two parameters define the geometry : + - the material of the box, + - the (full) size of the box. + + The default geometry (1 m3 of pressurized water) is built in + DetectorConstruction, but the above parameters can be changed interactively + via commands defined in DetectorMessenger. + + A function, and its associated UI command, allows to build a material + directly from a single isotope. + + To be identified by the ThermalScattering module, the elements composing a + material must have a specific name (see G4NeutronHPThermalScatteringNames.cc) + Examples of such materials are build in DetectorConstruction. + +\section Hadr04_s2 PHYSICS LIST + + Only processes of neutronHP package are registered : neutronElastic + (including thermalScattering), neutronInelastic, nCapture; nFission. + See class NeutronHPphysics. No other hadronic nor electromagnetic processes. + + A command allows to select or not ThermalScattering model. + + Several hadronic physics options are controlled by environment variables. + To trigger them, an envHadronic.csh has been added in this example. + One must select the options wished, and do +\verbatim + source envHadronic.csh (or sh) +\endverbatim + +\section Hadr04_s3 AN EVENT : THE PRIMARY GENERATOR + + The primary kinematic is a single particle randomly shooted at the + centre of the box. The type of the particle and its energy are set in + PrimaryGeneratorAction (neutron 2 MeV), and can be changed via the G4 + build-in commands of ParticleGun class (see the macros provided with + this example). + +\section Hadr04_s4 PHYSICS + + All secondaries are killed in StackingAction. Therefore an event consists of + the transport of the primary neutron. Then one survey the thermal and non + thermal part of this parcours. + + +\section Hadr04_s5 HISTOGRAMS + + The test contains 7 built-in 1D histograms, which are managed by + G4AnalysisManager and its Messenger. The histos can be individually + activated with the command : + /analysis/h1/set id nbBins valMin valMax unit + where unit is the desired unit for the histo (MeV or keV, etc..) + (see the macros xxxx.mac). + + - 1 "incident neutron: nb of collisions above 1 eV" + - 2 "incident neutron: total track length above 1 eV" + - 3 "incident neutron: time of flight above 1 eV" + - 4 "incident neutron: nb of collisions below 1 eV" + - 5 "incident neutron: total track length below 1*eV" + - 6 "incident neutron: time of flight below 1 eV" + - 7 "incident neutron: energy distribution below 1*eV" + + The histograms are managed by the HistoManager class and its Messenger. + The histos can be individually activated with the command : +\verbatim +/analysis/h1/set id nbBins valMin valMax unit +\endverbatim + where unit is the desired unit for the histo (MeV or keV, deg or mrad, etc..) + + One can control the name of the histograms file with the command: +\verbatim +/analysis/setFileName name (default Hadr04) +\endverbatim + It is possible to choose the format of the histogram file : root (default), + xml, csv, by using namespace in HistoManager.hh + + It is also possible to print selected histograms on an ascii file: +\verbatim +/analysis/h1/setAscii id +\endverbatim + All selected histos will be written on a file name.ascii (default Hadr04) + +\section Hadr04_s6 VISUALIZATION + + The Visualization Manager is set in the main(). + The initialisation of the drawing is done via the commands + /vis/... in the macro vis.mac. To get visualisation: +\verbatim +> /control/execute vis.mac +\endverbatim + + The detector has a default view which is a longitudinal view of the box. + The tracks are drawn at the end of event, and erased at the end of run. + +\section Hadr04_s7 HOW TO START ? + + Execute Hadr04 in 'batch' mode from macro files : +\verbatim +% Hadr04 run01.mac +\endverbatim + + Execute Hadr04 in 'interactive mode' with visualization : +\verbatim +% Hadr04 +Idle> control/execute vis.mac + .... + Idle> type your commands + .... + Idle> exit +\endverbatim + +*/ diff --git a/CUDA_Hadr04/src/Hadr04/CMakeLists.txt b/CUDA_Hadr04/src/Hadr04/CMakeLists.txt new file mode 100644 index 00000000..c12e7554 --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/CMakeLists.txt @@ -0,0 +1,73 @@ +#---------------------------------------------------------------------------- +# Setup the project +cmake_minimum_required(VERSION 2.6 FATAL_ERROR) +project(Hadr04) + +#---------------------------------------------------------------------------- +# Find Geant4 package, activating all available UI and Vis drivers by default +# You can set WITH_GEANT4_UIVIS to OFF via the command line or ccmake/cmake-gui +# to build a batch mode only executable +# +option(WITH_GEANT4_UIVIS "Build example with Geant4 UI and Vis drivers" ON) +if(WITH_GEANT4_UIVIS) + find_package(Geant4 REQUIRED ui_all vis_all) +else() + find_package(Geant4 REQUIRED) +endif() + +#---------------------------------------------------------------------------- +# Setup Geant4 include directories and compile definitions +# +include(${Geant4_USE_FILE}) + +#---------------------------------------------------------------------------- +# Locate sources and headers for this project +# +include_directories(${PROJECT_SOURCE_DIR}/include + ${Geant4_INCLUDE_DIR} + ../) +file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc) +file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh) + +#---------------------------------------------------------------------------- +# Add the executable, and link it to the Geant4 libraries +# +add_executable(Hadr04 Hadr04.cc ${sources} ${headers}) +if (USE_GPU) + target_link_libraries(Hadr04 ${Geant4_LIBRARIES} CUDA_G4NeutronHPVector /usr/local/cuda/lib/libcudart_static.a) + add_definitions(-DUSE_GPU=1) + MESSAGE (STATUS "GPU Computation with CUDA is: ON") +else() + MESSAGE (STATUS "GPU Computation with CUDA is: OFF") + add_definitions(-DUSE_GPU=0) + target_link_libraries(Hadr04 ${Geant4_LIBRARIES}) +endif() + +#---------------------------------------------------------------------------- +# Copy all scripts to the build directory, i.e. the directory in which we +# build Hadr04. This is so that we can run the executable directly because it +# relies on these scripts being in the current working directory. +# +set(Hadr04_SCRIPTS + debug.mac + envHadronic.csh + envHadronic.sh + graphite.mac + hadr04.in + run01.mac + vis.mac + ) + +foreach(_script ${Hadr04_SCRIPTS}) + configure_file( + ${PROJECT_SOURCE_DIR}/${_script} + ${PROJECT_BINARY_DIR}/${_script} + COPYONLY + ) +endforeach() + +#---------------------------------------------------------------------------- +# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX +# +install(TARGETS Hadr04 DESTINATION bin) + diff --git a/CUDA_Hadr04/src/Hadr04/GNUmakefile b/CUDA_Hadr04/src/Hadr04/GNUmakefile new file mode 100644 index 00000000..6021208b --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/GNUmakefile @@ -0,0 +1,23 @@ +# $Id: GNUmakefile 67909 2013-03-12 18:51:09Z vnivanch $ +# -------------------------------------------------------------- +# GNUmakefile for examples module. Gabriele Cosmo, 06/04/98. +# -------------------------------------------------------------- + +name := Hadr04 +G4TARGET := $(name) +G4EXLIB := true + +ifndef G4INSTALL + G4INSTALL = ../../../.. +endif + +.PHONY: all +all: lib bin + +include $(G4INSTALL)/config/architecture.gmk + +include $(G4INSTALL)/config/binmake.gmk + +visclean: + rm -f g4*.prim g4*.eps g4*.wrl + rm -f .DAWN_* diff --git a/CUDA_Hadr04/src/Hadr04/Hadr04.cc b/CUDA_Hadr04/src/Hadr04/Hadr04.cc new file mode 100644 index 00000000..4bf961ca --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/Hadr04.cc @@ -0,0 +1,117 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +/// \file hadronic/Hadr03/Hadr03.cc +/// \brief Main program of the hadronic/Hadr03 example +// +// +// $Id: TestEm1.cc,v 1.16 2010-04-06 11:11:24 maire Exp $ +// +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#ifdef G4MULTITHREADED +#include "G4MTRunManager.hh" +#else +#include "G4RunManager.hh" +#endif + +#include "G4UImanager.hh" +#include "Randomize.hh" + +#include "DetectorConstruction.hh" +#include "PhysicsList.hh" +#include "ActionInitialization.hh" +#include "SteppingVerbose.hh" + +#ifdef G4VIS_USE + #include "G4VisExecutive.hh" +#endif + +#ifdef G4UI_USE +#include "G4UIExecutive.hh" +#endif + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +int main(int argc,char** argv) { + + //choose the Random engine + G4Random::setTheEngine(new CLHEP::RanecuEngine); + + // Construct the default run manager +#ifdef G4MULTITHREADED + G4MTRunManager* runManager = new G4MTRunManager; +#else + //my Verbose output class + G4VSteppingVerbose::SetInstance(new SteppingVerbose); + G4RunManager* runManager = new G4RunManager; +#endif + + // set mandatory initialization classes + DetectorConstruction* det= new DetectorConstruction; + runManager->SetUserInitialization(det); + + PhysicsList* phys = new PhysicsList; + runManager->SetUserInitialization(phys); + + runManager->SetUserInitialization(new ActionInitialization(det)); + + // get the pointer to the User Interface manager + G4UImanager* UI = G4UImanager::GetUIpointer(); + + if (argc!=1) // batch mode + { + G4String command = "/control/execute "; + G4String fileName = argv[1]; + UI->ApplyCommand(command+fileName); + } + + else //define visualization and UI terminal for interactive mode + { +#ifdef G4VIS_USE + G4VisManager* visManager = new G4VisExecutive; + visManager->Initialize(); +#endif + +#ifdef G4UI_USE + G4UIExecutive * ui = new G4UIExecutive(argc,argv); + ui->SessionStart(); + delete ui; +#endif + +#ifdef G4VIS_USE + delete visManager; +#endif + } + + // job termination + // + delete runManager; + + return 0; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... diff --git a/CUDA_Hadr04/src/Hadr04/History b/CUDA_Hadr04/src/Hadr04/History new file mode 100644 index 00000000..d5598362 --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/History @@ -0,0 +1,45 @@ +$Id: History 71654 2013-06-19 18:20:04Z maire $ + + ========================================================= + Geant4 - an Object-Oriented Toolkit for Simulation in HEP + ========================================================= + + Hadr04 History file + ------------------- +This file should be used by the G4 example coordinator to briefly +summarize all major modifications introduced in the code and keep +track of all tags. + + ---------------------------------------------------------- + * Reverse chronological order (last date on top), please * + ---------------------------------------------------------- + +21-11-13 A.Dotti (exhadr04-V09-06-07) +- Use G4RunManager::ReinitializeGeometry() to trigger geometry + rebuild +- Remove ui command to Update geometry and corresponding method + in DetectorConstruction + +07-11-13 I. Hrivnacova (exhadr04-V09-06-06) +- Setting SteppingVerbose in main only in seguential mode. + +07-11-13 mma (exhadr04-V09-06-05) +- BeginOfRunAction() : suppress printing + +05-11-13 I. Hrivnacova (exhadr04-V09-06-04) +- Improved Run class: define just one map of struct ParticleData + instead of four maps of G4int/G4double. + +04-11-13 I. Hrivnacova (exhadr04-V09-06-03) +- Added merging for maps, fixed endOfRunAction, + use G4Random instead of CLHEP::Random + +03-11-13 mma(exhadr04-V09-06-02) +- MT: Hadr04.cc + ActionInitialisation + RunAction + Run +- rm EventAction and EventActionMessenger + +09-09-13 mma (exhadr04-V09-06-01) +- cosmetic in RunAction + +01-09-13 Michel Maire (exhadr04-V09-06-00) +- created from Hadr03 and rdecay01 diff --git a/CUDA_Hadr04/src/Hadr04/README b/CUDA_Hadr04/src/Hadr04/README new file mode 100644 index 00000000..e894eec4 --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/README @@ -0,0 +1,114 @@ +$Id: README 69174 2013-04-21 20:38:15Z maire $ + + ========================================================= + Geant4 - an Object-Oriented Toolkit for Simulation in HEP + ========================================================= + + Hadr04 + ------ + + This example is focused on neutronHP physics, especially neutron transport, + including thermal scattering. + See A.R. Garcia, E. Mendoza, D. Cano-Ott presentation at G4 Hadronic group + meeting (04/2013) and note on G4NeutronHP package + + 1- MATERIALS AND GEOMETRY DEFINITION + + It is a single box representing a 'quasi infinite' homogeneous medium. + Two parameters define the geometry : + - the material of the box, + - the (full) size of the box. + + The default geometry (1 m3 of pressurized water) is built in + DetectorConstruction, but the above parameters can be changed interactively + via commands defined in DetectorMessenger. + + A function, and its associated UI command, allows to build a material + directly from a single isotope. + + To be identified by the ThermalScattering module, the elements composing a + material must have a specific name (see G4NeutronHPThermalScatteringNames.cc) + Examples of such materials are build in DetectorConstruction. + + 2- PHYSICS LIST + + Only processes of neutronHP package are registered : neutronElastic + (including thermalScattering), neutronInelastic, nCapture; nFission. + See class NeutronHPphysics. No other hadronic nor electromagnetic processes. + + A command allows to select or not ThermalScattering model. + + Several hadronic physics options are controlled by environment variables. + To trigger them, an envHadronic.csh has been added in this example. + One must select the options wished, and do + source envHadronic.csh (or sh) + + 3- AN EVENT : THE PRIMARY GENERATOR + + The primary kinematic is a single particle randomly shooted at the + centre of the box. The type of the particle and its energy are set in + PrimaryGeneratorAction (neutron 2 MeV), and can be changed via the G4 + build-in commands of ParticleGun class (see the macros provided with + this example). + + 4- PHYSICS + + All secondaries are killed in StackingAction. Therefore an event consists of + the transport of the primary neutron. Then one survey the thermal and non + thermal part of this parcours. + + + 5- HISTOGRAMS + + The test contains 7 built-in 1D histograms, which are managed by + G4AnalysisManager and its Messenger. The histos can be individually + activated with the command : + /analysis/h1/set id nbBins valMin valMax unit + where unit is the desired unit for the histo (MeV or keV, etc..) + (see the macros xxxx.mac). + + 1 "incident neutron: nb of collisions above 1 eV" + 2 "incident neutron: total track length above 1 eV" + 3 "incident neutron: time of flight above 1 eV" + 4 "incident neutron: nb of collisions below 1 eV" + 5 "incident neutron: total track length below 1*eV" + 6 "incident neutron: time of flight below 1 eV" + 7 "incident neutron: energy distribution below 1*eV" + + The histograms are managed by the HistoManager class and its Messenger. + The histos can be individually activated with the command : + /analysis/h1/set id nbBins valMin valMax unit + where unit is the desired unit for the histo (MeV or keV, deg or mrad, etc..) + + One can control the name of the histograms file with the command: + /analysis/setFileName name (default Hadr04) + + It is possible to choose the format of the histogram file : root (default), + xml, csv, by using namespace in HistoManager.hh + + It is also possible to print selected histograms on an ascii file: + /analysis/h1/setAscii id + All selected histos will be written on a file name.ascii (default Hadr04) + + 6- VISUALIZATION + + The Visualization Manager is set in the main(). + The initialisation of the drawing is done via the commands + /vis/... in the macro vis.mac. To get visualisation: + > /control/execute vis.mac + + The detector has a default view which is a longitudinal view of the box. + The tracks are drawn at the end of event, and erased at the end of run. + + 7- HOW TO START ? + + Execute Hadr04 in 'batch' mode from macro files : + % Hadr04 run01.mac + + Execute Hadr04 in 'interactive mode' with visualization : + % Hadr04 + Idle> control/execute vis.mac + .... + Idle> type your commands + .... + Idle> exit diff --git a/CUDA_Hadr04/src/Hadr04/debug.mac b/CUDA_Hadr04/src/Hadr04/debug.mac new file mode 100644 index 00000000..5577ad43 --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/debug.mac @@ -0,0 +1,16 @@ + +/control/verbose 2 +/run/verbose 2 +/tracking/verbose 2 +# +/testhadr/det/setMat Water_ts +/testhadr/det/setSize 1 m +# +/run/initialize +# +/gun/particle neutron +/gun/energy 2 MeV +# +/control/execute vis.mac +# +/run/beamOn 1 diff --git a/CUDA_Hadr04/src/Hadr04/envHadronic.csh b/CUDA_Hadr04/src/Hadr04/envHadronic.csh new file mode 100755 index 00000000..7313afef --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/envHadronic.csh @@ -0,0 +1,18 @@ +# +# for neutronHP +# +unsetenv G4NEUTRONHP_SKIP_MISSING_ISOTOPES +unsetenv G4NEUTRONHP_DO_NOT_ADJUST_FINAL_STATE +unsetenv G4NEUTRONHP_USE_ONLY_PHOTONEVAPORATION +unsetenv G4NEUTRONHP_NELECT_DOPPLER +unsetenv G4NEUTRONHP_PRODUCE_FISSION_FRAGMENTS + +if ( Xy == Xy ) then + setenv G4NEUTRONHP_SKIP_MISSING_ISOTOPES 1 + setenv G4NEUTRONHP_DO_NOT_ADJUST_FINAL_STATE 1 + setenv G4NEUTRONHP_USE_ONLY_PHOTONEVAPORATION 1 + setenv G4NEUTRONHP_NELECT_DOPPLER 1 + setenv G4NEUTRONHP_PRODUCE_FISSION_FRAGMENTS 1 +endif + +env |grep G4NEUTRONHP diff --git a/CUDA_Hadr04/src/Hadr04/envHadronic.sh b/CUDA_Hadr04/src/Hadr04/envHadronic.sh new file mode 100755 index 00000000..e2084ad0 --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/envHadronic.sh @@ -0,0 +1,27 @@ +# +# for neutronHP +# +unset G4NEUTRONHP_SKIP_MISSING_ISOTOPES +unset G4NEUTRONHP_DO_NOT_ADJUST_FINAL_STATE +unset G4NEUTRONHP_USE_ONLY_PHOTONEVAPORATION +unset G4NEUTRONHP_NELECT_DOPPLER +unset G4NEUTRONHP_PRODUCE_FISSION_FRAGMENTS + +if [ Xy == Xy ] then + G4NEUTRONHP_SKIP_MISSING_ISOTOPES=1 + export G4NEUTRONHP_SKIP_MISSING_ISOTOPES + + G4NEUTRONHP_DO_NOT_ADJUST_FINAL_STATE=1 + export G4NEUTRONHP_DO_NOT_ADJUST_FINAL_STATE + + G4NEUTRONHP_USE_ONLY_PHOTONEVAPORATION=1 + export G4NEUTRONHP_USE_ONLY_PHOTONEVAPORATION + + G4NEUTRONHP_NELECT_DOPPLER=1 + export G4NEUTRONHP_NELECT_DOPPLER + + G4NEUTRONHP_PRODUCE_FISSION_FRAGMENTS=1 + export G4NEUTRONHP_PRODUCE_FISSION_FRAGMENTS +fi + +env |grep G4NEUTRONHP diff --git a/CUDA_Hadr04/src/Hadr04/graphite.mac b/CUDA_Hadr04/src/Hadr04/graphite.mac new file mode 100644 index 00000000..69358853 --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/graphite.mac @@ -0,0 +1,35 @@ +# $Id$ +# +# Macro file for "Hadr04.cc" +# (can be run in batch, without graphic) +# +# neutron 2 MeV; all processes +# +/control/verbose 2 +/run/verbose 2 +# +/testhadr/det/setMat graphite +/testhadr/det/setSize 20 m +# +/testhadr/phys/thermalScattering true +# +/run/initialize +# +/process/list +# +/particle/createAllIsomer +/gun/particle neutron +/gun/energy 2 MeV +# +/analysis/setFileName Graphite_on +/analysis/h1/set 1 100 0. 200. none #nb colli >1eV +/analysis/h1/set 2 100 0. 5. m #track len >1eV +/analysis/h1/set 3 100 0. 50. mus #time of flight >1eV +/analysis/h1/set 4 100 0. 10000. none #nb colli <1eV +/analysis/h1/set 5 100 0. 100. m #track len <1eV +/analysis/h1/set 6 100 0. 100. ms #time of flight <1eV +/analysis/h1/set 7 100 0. 500. meV #energy dist <1eV +# +/run/printProgress 200 +# +/run/beamOn 2000 diff --git a/CUDA_Hadr04/src/Hadr04/hadr04.in b/CUDA_Hadr04/src/Hadr04/hadr04.in new file mode 100644 index 00000000..1b655f31 --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/hadr04.in @@ -0,0 +1,24 @@ +# $Id$ +# +# Macro file for "Hadr04.cc" +# (can be run in batch, without graphic) +# +# neutron 2 MeV; all processes +# +/control/verbose 2 +/run/verbose 2 +# +/testhadr/det/setMat Water_ts +/testhadr/det/setSize 1 m +# +/run/initialize +# +/process/list +# +###/particle/createAllIsomer +/gun/particle neutron +/gun/energy 2 MeV +# +/run/printProgress 100 +# +/run/beamOn 1000 diff --git a/CUDA_Hadr04/src/Hadr04/include/ActionInitialization.hh b/CUDA_Hadr04/src/Hadr04/include/ActionInitialization.hh new file mode 100644 index 00000000..5aa3cb50 --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/include/ActionInitialization.hh @@ -0,0 +1,59 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +// $Id: ActionInitialization.hh 68058 2013-03-13 14:47:43Z gcosmo $ +// +/// \file ActionInitialization.hh +/// \brief Definition of the ActionInitialization class + +#ifndef ActionInitialization_h +#define ActionInitialization_h 1 + +#include "G4VUserActionInitialization.hh" + +class DetectorConstruction; +class G4VSteppingVerbose; + +/// Action initialization class. +/// + +class ActionInitialization : public G4VUserActionInitialization +{ + public: + ActionInitialization(DetectorConstruction* detector); + virtual ~ActionInitialization(); + + virtual void BuildForMaster() const; + virtual void Build() const; + + virtual G4VSteppingVerbose* InitializeSteppingVerbose() const; + + private: + DetectorConstruction* fDetector; +}; + +#endif + + diff --git a/CUDA_Hadr04/src/Hadr04/include/DetectorConstruction.hh b/CUDA_Hadr04/src/Hadr04/include/DetectorConstruction.hh new file mode 100644 index 00000000..6a7adeb0 --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/include/DetectorConstruction.hh @@ -0,0 +1,94 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +/// \file hadronic/Hadr03/include/DetectorConstruction.hh +/// \brief Definition of the DetectorConstruction class +// +// $Id: DetectorConstruction.hh 66586 2012-12-21 10:48:39Z ihrivnac $ +// + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#ifndef DetectorConstruction_h +#define DetectorConstruction_h 1 + +#include "G4VUserDetectorConstruction.hh" +#include "globals.hh" + +class G4LogicalVolume; +class G4Material; +class DetectorMessenger; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +class DetectorConstruction : public G4VUserDetectorConstruction +{ + public: + + DetectorConstruction(); + ~DetectorConstruction(); + + public: + + virtual G4VPhysicalVolume* Construct(); + + G4Material* + MaterialWithSingleIsotope(G4String, G4String, G4double, G4int, G4int); + + void SetSize (G4double); + void SetMaterial (G4String); + + public: + + const + G4VPhysicalVolume* GetWorld() {return fPBox;}; + + G4double GetSize() {return fBoxSize;}; + G4Material* GetMaterial() {return fMaterial;}; + + void PrintParameters(); + + private: + + G4VPhysicalVolume* fPBox; + G4LogicalVolume* fLBox; + + G4double fBoxSize; + G4Material* fMaterial; + + DetectorMessenger* fDetectorMessenger; + + private: + + void DefineMaterials(); + G4VPhysicalVolume* ConstructVolumes(); +}; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + + +#endif + diff --git a/CUDA_Hadr04/src/Hadr04/include/DetectorMessenger.hh b/CUDA_Hadr04/src/Hadr04/include/DetectorMessenger.hh new file mode 100644 index 00000000..c1a2b09d --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/include/DetectorMessenger.hh @@ -0,0 +1,72 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +/// \file hadronic/Hadr03/include/DetectorMessenger.hh +/// \brief Definition of the DetectorMessenger class +// +// $Id: DetectorMessenger.hh 67103 2013-01-31 18:18:03Z maire $ +// +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#ifndef DetectorMessenger_h +#define DetectorMessenger_h 1 + +#include "G4UImessenger.hh" +#include "globals.hh" + +class DetectorConstruction; +class G4UIdirectory; +class G4UIcommand; +class G4UIcmdWithAString; +class G4UIcmdWithADoubleAndUnit; +class G4UIcmdWithoutParameter; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +class DetectorMessenger: public G4UImessenger +{ + public: + + DetectorMessenger(DetectorConstruction* ); + ~DetectorMessenger(); + + virtual void SetNewValue(G4UIcommand*, G4String); + + private: + + DetectorConstruction* fDetector; + + G4UIdirectory* fTestemDir; + G4UIdirectory* fDetDir; + G4UIcmdWithAString* fMaterCmd; + G4UIcmdWithADoubleAndUnit* fSizeCmd; + G4UIcommand* fIsotopeCmd; +}; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#endif + diff --git a/CUDA_Hadr04/src/Hadr04/include/HistoManager.hh b/CUDA_Hadr04/src/Hadr04/include/HistoManager.hh new file mode 100644 index 00000000..8e8d3be0 --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/include/HistoManager.hh @@ -0,0 +1,58 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +/// \file hadronic/Hadr03/include/HistoManager.hh +/// \brief Definition of the HistoManager class +// +// $Id: HistoManager.hh 66586 2012-12-21 10:48:39Z ihrivnac $ +// +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#ifndef HistoManager_h +#define HistoManager_h 1 + +#include "globals.hh" + +#include "g4root.hh" +//#include "g4xml.hh" + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +class HistoManager +{ + public: + HistoManager(); + ~HistoManager(); + + private: + void Book(); + G4String fFileName; +}; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#endif + diff --git a/CUDA_Hadr04/src/Hadr04/include/NeutronHPMessenger.hh b/CUDA_Hadr04/src/Hadr04/include/NeutronHPMessenger.hh new file mode 100644 index 00000000..e48197f5 --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/include/NeutronHPMessenger.hh @@ -0,0 +1,63 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +/// \file electromagnetic/TestEm12/include/NeutronHPMessenger.hh +/// \brief Definition of the NeutronHPMessenger class +// +// $Id: NeutronHPMessenger.hh 66241 2012-12-13 18:34:42Z gunter $ +// +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#ifndef NeutronHPMessenger_h +#define NeutronHPMessenger_h 1 + +#include "globals.hh" +#include "G4UImessenger.hh" + +class NeutronHPphysics; +class G4UIdirectory; +class G4UIcmdWithABool; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +class NeutronHPMessenger: public G4UImessenger +{ + public: + NeutronHPMessenger(NeutronHPphysics*); + ~NeutronHPMessenger(); + + virtual void SetNewValue(G4UIcommand*, G4String); + + private: + NeutronHPphysics* fNeutronPhysics; + + G4UIdirectory* fPhysDir; + G4UIcmdWithABool* fThermalCmd; +}; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#endif diff --git a/CUDA_Hadr04/src/Hadr04/include/NeutronHPphysics.hh b/CUDA_Hadr04/src/Hadr04/include/NeutronHPphysics.hh new file mode 100644 index 00000000..c4fadf15 --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/include/NeutronHPphysics.hh @@ -0,0 +1,65 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +/// \file hadronic/Hadr04/include/NeutronHPphysics.hh +/// \brief Definition of the NeutronHPphysics class +// +// $Id: NeutronHPphysics.hh 66587 2012-12-21 11:06:44Z ihrivnac $ +// + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#ifndef NeutronHPphysics_h +#define NeutronHPphysics_h 1 + +#include "globals.hh" +#include "G4VPhysicsConstructor.hh" + +class NeutronHPMessenger; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +class NeutronHPphysics : public G4VPhysicsConstructor +{ + public: + NeutronHPphysics(const G4String& name="neutron"); + ~NeutronHPphysics(); + + public: + virtual void ConstructParticle() { }; + virtual void ConstructProcess(); + + public: + void SetThermalPhysics(G4bool flag) {fThermal = flag;}; + + private: + G4bool fThermal; + NeutronHPMessenger* fNeutronMessenger; +}; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#endif + diff --git a/CUDA_Hadr04/src/Hadr04/include/PhysicsList.hh b/CUDA_Hadr04/src/Hadr04/include/PhysicsList.hh new file mode 100644 index 00000000..145db82d --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/include/PhysicsList.hh @@ -0,0 +1,53 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +/// \file hadronic/Hadr03/include/PhysicsList.hh +/// \brief Definition of the PhysicsList class +// +// $Id: PhysicsList.hh 66587 2012-12-21 11:06:44Z ihrivnac $ +// + +#ifndef PhysicsList_h +#define PhysicsList_h 1 + +#include "G4VModularPhysicsList.hh" +#include "globals.hh" + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +class PhysicsList: public G4VModularPhysicsList +{ +public: + PhysicsList(); + ~PhysicsList(); + +public: + virtual void ConstructParticle(); + virtual void SetCuts(); +}; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#endif diff --git a/CUDA_Hadr04/src/Hadr04/include/PrimaryGeneratorAction.hh b/CUDA_Hadr04/src/Hadr04/include/PrimaryGeneratorAction.hh new file mode 100644 index 00000000..0222a42f --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/include/PrimaryGeneratorAction.hh @@ -0,0 +1,66 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +/// \file electromagnetic/TestEm4/include/PrimaryGeneratorAction.hh +/// \brief Definition of the PrimaryGeneratorAction class +// +// +// $Id: PrimaryGeneratorAction.hh 66241 2012-12-13 18:34:42Z gunter $ +// +// + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#ifndef PrimaryGeneratorAction_h +#define PrimaryGeneratorAction_h 1 + +#include "G4VUserPrimaryGeneratorAction.hh" +#include "G4ParticleGun.hh" +#include "globals.hh" + +class G4Event; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction +{ + public: + PrimaryGeneratorAction(); + ~PrimaryGeneratorAction(); + + public: + virtual void GeneratePrimaries(G4Event*); + G4ParticleGun* GetParticleGun() {return fParticleGun;}; + + private: + G4ParticleGun* fParticleGun; //pointer a to G4 service class +}; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#endif + + diff --git a/CUDA_Hadr04/src/Hadr04/include/Run.hh b/CUDA_Hadr04/src/Hadr04/include/Run.hh new file mode 100644 index 00000000..5e3483ae --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/include/Run.hh @@ -0,0 +1,86 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +/// \file electromagnetic/TestEm11/include/Run.hh +/// \brief Definition of the Run class +// +// $Id: Run.hh 71375 2013-06-14 07:39:33Z maire $ +// +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#ifndef Run_h +#define Run_h 1 + +#include "G4Run.hh" +#include "G4VProcess.hh" +#include "globals.hh" +#include + +class DetectorConstruction; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +class Run : public G4Run +{ + public: + Run(DetectorConstruction*); + ~Run(); + + public: + void CountProcesses(const G4VProcess* process); + void ParticleCount(G4String, G4double); + void SumTrackLength (G4int,G4int,G4double,G4double,G4double,G4double); + void ComputeStatistics(); + + virtual void Merge(const G4Run*); + + private: + DetectorConstruction* fDetector; + + std::map fProcCounter; + + struct ParticleData { + ParticleData() + : fCount(0), fEmean(0.), fEmin(0.), fEmax(0.) {} + ParticleData(G4int count, G4double ekin, G4double emin, G4double emax) + : fCount(count), fEmean(ekin), fEmin(emin), fEmax(emax) {} + G4int fCount; + G4double fEmean; + G4double fEmin; + G4double fEmax; + }; + + std::map fParticleDataMap; + + G4int fNbStep1, fNbStep2; + G4double fTrackLen1, fTrackLen2; + G4double fTime1, fTime2; +}; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#endif + diff --git a/CUDA_Hadr04/src/Hadr04/include/RunAction.hh b/CUDA_Hadr04/src/Hadr04/include/RunAction.hh new file mode 100644 index 00000000..d3d029e9 --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/include/RunAction.hh @@ -0,0 +1,71 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +/// \file hadronic/Hadr03/include/RunAction.hh +/// \brief Definition of the RunAction class +// +// $Id: RunAction.hh 66241 2012-12-13 18:34:42Z gunter $ +// +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#ifndef RunAction_h +#define RunAction_h 1 + +#include "G4UserRunAction.hh" +#include "globals.hh" + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +class DetectorConstruction; +class Run; +class PrimaryGeneratorAction; +class HistoManager; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +class RunAction : public G4UserRunAction +{ + public: + RunAction(DetectorConstruction*, PrimaryGeneratorAction*); + ~RunAction(); + + public: + virtual G4Run* GenerateRun(); + virtual void BeginOfRunAction(const G4Run*); + virtual void EndOfRunAction(const G4Run*); + + private: + DetectorConstruction* fDetector; + PrimaryGeneratorAction* fPrimary; + Run* fRun; + HistoManager* fHistoManager; + +}; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#endif + diff --git a/CUDA_Hadr04/src/Hadr04/include/StackingAction.hh b/CUDA_Hadr04/src/Hadr04/include/StackingAction.hh new file mode 100644 index 00000000..ac6e9ef8 --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/include/StackingAction.hh @@ -0,0 +1,54 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +/// \file electromagnetic/TestEm5/include/StackingAction.hh +/// \brief Definition of the StackingAction class +// +// $Id: StackingAction.hh 66241 2012-12-13 18:34:42Z gunter $ +// +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#ifndef StackingAction_h +#define StackingAction_h 1 + +#include "G4UserStackingAction.hh" +#include "globals.hh" + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +class StackingAction : public G4UserStackingAction +{ + public: + StackingAction(); + ~StackingAction(); + + virtual G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track*); +}; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#endif + diff --git a/CUDA_Hadr04/src/Hadr04/include/SteppingAction.hh b/CUDA_Hadr04/src/Hadr04/include/SteppingAction.hh new file mode 100644 index 00000000..04ecb8d8 --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/include/SteppingAction.hh @@ -0,0 +1,58 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +/// \file hadronic/Hadr03/include/SteppingAction.hh +/// \brief Definition of the SteppingAction class +// +// $Id: SteppingAction.hh 66241 2012-12-13 18:34:42Z gunter $ +// +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#ifndef SteppingAction_h +#define SteppingAction_h 1 + +#include "G4UserSteppingAction.hh" +#include "globals.hh" + +class TrackingAction; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +class SteppingAction : public G4UserSteppingAction +{ + public: + SteppingAction(TrackingAction*); + ~SteppingAction(); + + virtual void UserSteppingAction(const G4Step*); + + private: + TrackingAction* fTrackingAction; +}; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#endif diff --git a/CUDA_Hadr04/src/Hadr04/include/SteppingVerbose.hh b/CUDA_Hadr04/src/Hadr04/include/SteppingVerbose.hh new file mode 100644 index 00000000..aa0944d4 --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/include/SteppingVerbose.hh @@ -0,0 +1,55 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +/// \file radioactivedecay/rdecay01/include/SteppingVerbose.hh +/// \brief Definition of the SteppingVerbose class +// +// +// $Id: SteppingVerbose.hh 70268 2013-05-28 14:17:50Z maire $ +// +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#ifndef SteppingVerbose_h +#define SteppingVerbose_h 1 + +#include "G4SteppingVerbose.hh" + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +class SteppingVerbose : public G4SteppingVerbose { + +public: + + SteppingVerbose(); + ~SteppingVerbose(); + + virtual void TrackingStarted(); + virtual void StepInfo(); +}; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#endif diff --git a/CUDA_Hadr04/src/Hadr04/include/TrackingAction.hh b/CUDA_Hadr04/src/Hadr04/include/TrackingAction.hh new file mode 100644 index 00000000..17fa81e1 --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/include/TrackingAction.hh @@ -0,0 +1,61 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +/// \file electromagnetic/TestEm12/include/TrackingAction.hh +/// \brief Definition of the TrackingAction class +// +// $Id: TrackingAction.hh 69099 2013-04-18 12:25:19Z maire $ +// +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#ifndef TrackingAction_h +#define TrackingAction_h 1 + +#include "G4UserTrackingAction.hh" +#include "globals.hh" + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +class TrackingAction : public G4UserTrackingAction { + + public: + TrackingAction(); + ~TrackingAction() {}; + + virtual void PreUserTrackingAction(const G4Track*); + virtual void PostUserTrackingAction(const G4Track*); + + void UpdateTrackInfo(G4double, G4double, G4double); + + private: + G4int fNbStep1, fNbStep2; + G4double fTrackLen1, fTrackLen2; + G4double fTime1, fTime2; +}; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#endif diff --git a/CUDA_Hadr04/src/Hadr04/plotHisto.C b/CUDA_Hadr04/src/Hadr04/plotHisto.C new file mode 100644 index 00000000..d74aaec2 --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/plotHisto.C @@ -0,0 +1,33 @@ +{ + gROOT->Reset(); + + // Draw histos filled by Geant4 simulation + // + ////TFile f = TFile("Hadr04.root"); + TFile f = TFile("Water_nothermal.root"); + TCanvas* c1 = new TCanvas("c1", " "); + c1->SetLogy(0); + c1->cd(); + c1->Update(); + + TH1D* hist1 = (TH1D*)f.Get("1"); + hist1->Draw("HIST"); + + TH1D* hist2 = (TH1D*)f.Get("2"); + hist2->Draw("HIST"); + + TH1D* hist3 = (TH1D*)f.Get("3"); + hist3->Draw("HIST"); + + TH1D* hist4 = (TH1D*)f.Get("4"); + hist4->Draw("HIST"); + + TH1D* hist5 = (TH1D*)f.Get("5"); + hist5->Draw("HIST"); + + TH1D* hist6 = (TH1D*)f.Get("6"); + hist6->Draw("HIST"); + + TH1D* hist7 = (TH1D*)f.Get("7"); + hist7->Draw("HIST"); +} diff --git a/CUDA_Hadr04/src/Hadr04/run01.mac b/CUDA_Hadr04/src/Hadr04/run01.mac new file mode 100644 index 00000000..923a7f84 --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/run01.mac @@ -0,0 +1,35 @@ +# $Id$ +# +# Macro file for "Hadr04.cc" +# (can be run in batch, without graphic) +# +# neutron 2 MeV; all processes +# +/control/verbose 2 +/run/verbose 2 +# +/testhadr/det/setMat Water_ts +/testhadr/det/setSize 1 m +# +/testhadr/phys/thermalScattering false +# +/run/initialize +# +/process/list +# +/particle/createAllIsomer +/gun/particle neutron +/gun/energy 2 MeV +# +/analysis/setFileName Water_nothermal +/analysis/h1/set 1 100 0. 100. none #nb colli >1eV +/analysis/h1/set 2 100 0. 100. cm #track len >1eV +/analysis/h1/set 3 100 0. 5. mus #time of flight >1eV +/analysis/h1/set 4 100 0. 1000. none #nb colli <1eV +/analysis/h1/set 5 100 0. 500. cm #track len <1eV +/analysis/h1/set 6 100 0. 1000. mus #time of flight <1eV +/analysis/h1/set 7 100 0. 500. meV #energy dist <1eV +# +/run/printProgress 200 +# +/run/beamOn 200 diff --git a/CUDA_Hadr04/src/Hadr04/src/ActionInitialization.cc b/CUDA_Hadr04/src/Hadr04/src/ActionInitialization.cc new file mode 100644 index 00000000..6b2f83aa --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/src/ActionInitialization.cc @@ -0,0 +1,86 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +// $Id: ActionInitialization.cc 68058 2013-03-13 14:47:43Z gcosmo $ +// +/// \file ActionInitialization.cc +/// \brief Implementation of the ActionInitialization class + +#include "ActionInitialization.hh" +#include "PrimaryGeneratorAction.hh" +#include "RunAction.hh" +#include "TrackingAction.hh" +#include "SteppingAction.hh" +#include "SteppingVerbose.hh" +#include "StackingAction.hh" + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +ActionInitialization::ActionInitialization(DetectorConstruction* detector) + : G4VUserActionInitialization(), + fDetector(detector) +{} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +ActionInitialization::~ActionInitialization() +{} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void ActionInitialization::BuildForMaster() const +{ + RunAction* runAction = new RunAction(fDetector, 0); + SetUserAction(runAction); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void ActionInitialization::Build() const +{ + PrimaryGeneratorAction* primary = new PrimaryGeneratorAction(); + SetUserAction(primary); + + RunAction* runAction = new RunAction(fDetector, primary ); + SetUserAction(runAction); + + TrackingAction* trackingAction = new TrackingAction(); + SetUserAction(trackingAction); + + SteppingAction* steppingAction = new SteppingAction(trackingAction); + SetUserAction(steppingAction); + + StackingAction* stackingAction = new StackingAction(); + SetUserAction(stackingAction); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +G4VSteppingVerbose* ActionInitialization::InitializeSteppingVerbose() const +{ + return new SteppingVerbose(); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... diff --git a/CUDA_Hadr04/src/Hadr04/src/DetectorConstruction.cc b/CUDA_Hadr04/src/Hadr04/src/DetectorConstruction.cc new file mode 100644 index 00000000..157f68ca --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/src/DetectorConstruction.cc @@ -0,0 +1,199 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +/// \file hadronic/Hadr03/src/DetectorConstruction.cc +/// \brief Implementation of the DetectorConstruction class +// +// $Id: DetectorConstruction.cc 70755 2013-06-05 12:17:48Z ihrivnac $ +// + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#include "DetectorConstruction.hh" +#include "DetectorMessenger.hh" +#include "G4Material.hh" +#include "G4NistManager.hh" + +#include "G4Box.hh" +#include "G4LogicalVolume.hh" +#include "G4PVPlacement.hh" + +#include "G4GeometryManager.hh" +#include "G4PhysicalVolumeStore.hh" +#include "G4LogicalVolumeStore.hh" +#include "G4SolidStore.hh" +#include "G4RunManager.hh" + +#include "G4UnitsTable.hh" +#include "G4SystemOfUnits.hh" + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +DetectorConstruction::DetectorConstruction() +:G4VUserDetectorConstruction(), + fPBox(0), fLBox(0), fMaterial(0), fDetectorMessenger(0) +{ + fBoxSize = 1*m; + DefineMaterials(); + SetMaterial("Water_ts"); + fDetectorMessenger = new DetectorMessenger(this); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +DetectorConstruction::~DetectorConstruction() +{ delete fDetectorMessenger;} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +G4VPhysicalVolume* DetectorConstruction::Construct() +{ + return ConstructVolumes(); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void DetectorConstruction::DefineMaterials() +{ + // specific element name for thermal neutronHP + // (see G4NeutronHPThermalScatteringNames.cc) + G4Element* H = new G4Element("TS_H_of_Water" ,"H" , 1., 1.0079*g/mole); + G4Element* O = new G4Element("Oxygen" ,"O" , 8., 16.00*g/mole); + + G4int ncomponents, natoms; + + G4Material* H2O = + new G4Material("Water_ts", 1.000*g/cm3, ncomponents=2, + kStateLiquid, 593*kelvin, 150*bar); + H2O->AddElement(H, natoms=2); + H2O->AddElement(O, natoms=1); + H2O->GetIonisation()->SetMeanExcitationEnergy(78.0*eV); + + // graphite + G4Isotope* C12 = new G4Isotope("C12", 6, 12); + G4Element* elC = new G4Element("TS_C_of_Graphite","C", ncomponents=1); + elC->AddIsotope(C12, 100.*perCent); + G4Material* graphite = + new G4Material("graphite", 2.27*g/cm3, ncomponents=1, + kStateSolid, 293*kelvin, 1*atmosphere); + graphite->AddElement(elC, natoms=1); + + ///G4cout << *(G4Material::GetMaterialTable()) << G4endl; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +G4Material* DetectorConstruction::MaterialWithSingleIsotope( G4String name, + G4String symbol, G4double density, G4int Z, G4int A) +{ + // define a material from an isotope + // + G4int ncomponents; + G4double abundance, massfraction; + + G4Isotope* isotope = new G4Isotope(symbol, Z, A); + + G4Element* element = new G4Element(name, symbol, ncomponents=1); + element->AddIsotope(isotope, abundance= 100.*perCent); + + G4Material* material = new G4Material(name, density, ncomponents=1); + material->AddElement(element, massfraction=100.*perCent); + + return material; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +G4VPhysicalVolume* DetectorConstruction::ConstructVolumes() +{ + // Cleanup old geometry + G4GeometryManager::GetInstance()->OpenGeometry(); + G4PhysicalVolumeStore::GetInstance()->Clean(); + G4LogicalVolumeStore::GetInstance()->Clean(); + G4SolidStore::GetInstance()->Clean(); + + G4Box* + sBox = new G4Box("Container", //its name + fBoxSize/2,fBoxSize/2,fBoxSize/2); //its dimensions + + fLBox = new G4LogicalVolume(sBox, //its shape + fMaterial, //its material + fMaterial->GetName()); //its name + + fPBox = new G4PVPlacement(0, //no rotation + G4ThreeVector(), //at (0,0,0) + fLBox, //its logical volume + fMaterial->GetName(), //its name + 0, //its mother volume + false, //no boolean operation + 0); //copy number + + PrintParameters(); + + //always return the root volume + // + return fPBox; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void DetectorConstruction::PrintParameters() +{ + G4cout << "\n The Box is " << G4BestUnit(fBoxSize,"Length") + << " of " << fMaterial->GetName() + << "\n \n" << fMaterial << G4endl; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void DetectorConstruction::SetMaterial(G4String materialChoice) +{ + // search the material by its name + G4Material* pttoMaterial = + G4NistManager::Instance()->FindOrBuildMaterial(materialChoice); + + if (pttoMaterial) { + if(fMaterial != pttoMaterial) { + fMaterial = pttoMaterial; + if(fLBox) { fLBox->SetMaterial(pttoMaterial); } + G4RunManager::GetRunManager()->PhysicsHasBeenModified(); + } + } else { + G4cout << "\n--> warning from DetectorConstruction::SetMaterial : " + << materialChoice << " not found" << G4endl; + } +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void DetectorConstruction::SetSize(G4double value) +{ + fBoxSize = value; + G4RunManager::GetRunManager()->ReinitializeGeometry(); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + diff --git a/CUDA_Hadr04/src/Hadr04/src/DetectorMessenger.cc b/CUDA_Hadr04/src/Hadr04/src/DetectorMessenger.cc new file mode 100644 index 00000000..5fe01230 --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/src/DetectorMessenger.cc @@ -0,0 +1,135 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +/// \file hadronic/Hadr03/src/DetectorMessenger.cc +/// \brief Implementation of the DetectorMessenger class +// +// $Id: DetectorMessenger.cc 70755 2013-06-05 12:17:48Z ihrivnac $ +// +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#include "DetectorMessenger.hh" + +#include "DetectorConstruction.hh" +#include "G4UIdirectory.hh" +#include "G4UIcommand.hh" +#include "G4UIparameter.hh" +#include "G4UIcmdWithAString.hh" +#include "G4UIcmdWithADoubleAndUnit.hh" +#include "G4UIcmdWithoutParameter.hh" + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +DetectorMessenger::DetectorMessenger(DetectorConstruction * Det) +:G4UImessenger(), + fDetector(Det), fTestemDir(0), fDetDir(0), fMaterCmd(0), fSizeCmd(0), + fIsotopeCmd(0) +{ + fTestemDir = new G4UIdirectory("/testhadr/"); + fTestemDir->SetGuidance("commands specific to this example"); + + G4bool broadcast = false; + fDetDir = new G4UIdirectory("/testhadr/det/",broadcast); + fDetDir->SetGuidance("detector construction commands"); + + fMaterCmd = new G4UIcmdWithAString("/testhadr/det/setMat",this); + fMaterCmd->SetGuidance("Select material of the box."); + fMaterCmd->SetParameterName("choice",false); + fMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle); + + fSizeCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/det/setSize",this); + fSizeCmd->SetGuidance("Set size of the box"); + fSizeCmd->SetParameterName("Size",false); + fSizeCmd->SetRange("Size>0."); + fSizeCmd->SetUnitCategory("Length"); + fSizeCmd->AvailableForStates(G4State_PreInit,G4State_Idle); + + fIsotopeCmd = new G4UIcommand("/testhadr/det/setIsotopeMat",this); + fIsotopeCmd->SetGuidance("Build and select a material with single isotope"); + fIsotopeCmd->SetGuidance(" symbol of isotope, Z, A, density of material"); + // + G4UIparameter* symbPrm = new G4UIparameter("isotope",'s',false); + symbPrm->SetGuidance("isotope symbol"); + fIsotopeCmd->SetParameter(symbPrm); + // + G4UIparameter* ZPrm = new G4UIparameter("Z",'i',false); + ZPrm->SetGuidance("Z"); + ZPrm->SetParameterRange("Z>0"); + fIsotopeCmd->SetParameter(ZPrm); + // + G4UIparameter* APrm = new G4UIparameter("A",'i',false); + APrm->SetGuidance("A"); + APrm->SetParameterRange("A>0"); + fIsotopeCmd->SetParameter(APrm); + // + G4UIparameter* densityPrm = new G4UIparameter("density",'d',false); + densityPrm->SetGuidance("density of material"); + densityPrm->SetParameterRange("density>0."); + fIsotopeCmd->SetParameter(densityPrm); + // + G4UIparameter* unitPrm = new G4UIparameter("unit",'s',false); + unitPrm->SetGuidance("unit of density"); + G4String unitList = G4UIcommand::UnitsList(G4UIcommand::CategoryOf("g/cm3")); + unitPrm->SetParameterCandidates(unitList); + fIsotopeCmd->SetParameter(unitPrm); + // + fIsotopeCmd->AvailableForStates(G4State_PreInit,G4State_Idle); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +DetectorMessenger::~DetectorMessenger() +{ + delete fMaterCmd; + delete fSizeCmd; + delete fIsotopeCmd; + delete fDetDir; + delete fTestemDir; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue) +{ + if( command == fMaterCmd ) + { fDetector->SetMaterial(newValue);} + + if( command == fSizeCmd ) + { fDetector->SetSize(fSizeCmd->GetNewDoubleValue(newValue));} + + if (command == fIsotopeCmd) + { + G4int Z; G4int A; G4double dens; + G4String name, unt; + std::istringstream is(newValue); + is >> name >> Z >> A >> dens >> unt; + dens *= G4UIcommand::ValueOf(unt); + fDetector->MaterialWithSingleIsotope (name,name,dens,Z,A); + fDetector->SetMaterial(name); + } +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... diff --git a/CUDA_Hadr04/src/Hadr04/src/HistoManager.cc b/CUDA_Hadr04/src/Hadr04/src/HistoManager.cc new file mode 100644 index 00000000..a19340b4 --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/src/HistoManager.cc @@ -0,0 +1,91 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +/// \file hadronic/Hadr03/src/HistoManager.cc +/// \brief Implementation of the HistoManager class +// +// $Id: HistoManager.cc 67909 2013-03-12 18:51:09Z vnivanch $ +// +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#include "HistoManager.hh" +#include "G4UnitsTable.hh" + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +HistoManager::HistoManager() + : fFileName("Hadr04") +{ + Book(); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +HistoManager::~HistoManager() +{ + delete G4AnalysisManager::Instance(); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void HistoManager::Book() +{ + // Create or get analysis manager + // The choice of analysis technology is done via selection of a namespace + // in HistoManager.hh + G4AnalysisManager* analysisManager = G4AnalysisManager::Instance(); + analysisManager->SetFileName(fFileName); + analysisManager->SetVerboseLevel(1); + analysisManager->SetActivation(true); //enable inactivation of histograms + + // Define histograms start values + const G4int kMaxHisto = 8; + const G4String id[] = {"0","1","2","3","4","5","6","7"}; + const G4String title[] = + { "dummy", //0 + "incident neutron: nb of collisions above 1 eV", //1 + "incident neutron: total track length above 1 eV", //2 + "incident neutron: time of flight above 1 eV", //3 + "incident neutron: nb of collisions below 1 eV", //4 + "incident neutron: total track length below 1*eV", //5 + "incident neutron: time of flight below 1 eV", //6 + "incident neutron: energy distribution below 1*eV" //7 + }; + + // Default values (to be reset via /analysis/h1/set command) + G4int nbins = 100; + G4double vmin = 0.; + G4double vmax = 100.; + + // Create all histograms as inactivated + // as we have not yet set nbins, vmin, vmax + for (G4int k=0; kCreateH1(id[k], title[k], nbins, vmin, vmax); + analysisManager->SetH1Activation(ih, false); + } +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... diff --git a/CUDA_Hadr04/src/Hadr04/src/NeutronHPMessenger.cc b/CUDA_Hadr04/src/Hadr04/src/NeutronHPMessenger.cc new file mode 100644 index 00000000..788f4c2e --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/src/NeutronHPMessenger.cc @@ -0,0 +1,72 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +/// \file electromagnetic/TestEm12/src/NeutronHPMessenger.cc +/// \brief Implementation of the NeutronHPMessenger class +// +// $Id: NeutronHPMessenger.cc 67268 2013-02-13 11:38:40Z ihrivnac $ +// +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#include "NeutronHPMessenger.hh" + +#include "NeutronHPphysics.hh" + +#include "G4UIdirectory.hh" +#include "G4UIcmdWithABool.hh" + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +NeutronHPMessenger::NeutronHPMessenger(NeutronHPphysics* phys) +:G4UImessenger(),fNeutronPhysics(phys), + fPhysDir(0), fThermalCmd(0) +{ + fPhysDir = new G4UIdirectory("/testhadr/phys/"); + fPhysDir->SetGuidance("physics list commands"); + + fThermalCmd = new G4UIcmdWithABool("/testhadr/phys/thermalScattering",this); + fThermalCmd->SetGuidance("set thermal scattering model"); + fThermalCmd->SetParameterName("thermal",false); + fThermalCmd->AvailableForStates(G4State_PreInit); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +NeutronHPMessenger::~NeutronHPMessenger() +{ + delete fThermalCmd; + delete fPhysDir; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void NeutronHPMessenger::SetNewValue(G4UIcommand* command, G4String newValue) +{ + if (command == fThermalCmd) + {fNeutronPhysics->SetThermalPhysics(fThermalCmd->GetNewBoolValue(newValue));} +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... diff --git a/CUDA_Hadr04/src/Hadr04/src/NeutronHPphysics.cc b/CUDA_Hadr04/src/Hadr04/src/NeutronHPphysics.cc new file mode 100644 index 00000000..81241d6d --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/src/NeutronHPphysics.cc @@ -0,0 +1,143 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +/// \file hadronic/Hadr04/src/NeutronHPphysics.cc +/// \brief Implementation of the NeutronHPphysics class +// +// $Id: NeutronHPphysics.cc 66587 2012-12-21 11:06:44Z ihrivnac $ +// + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#include "NeutronHPphysics.hh" + +#include "NeutronHPMessenger.hh" + +#include "G4ParticleDefinition.hh" +#include "G4ProcessManager.hh" + +// Processes + +#include "G4HadronElasticProcess.hh" +#include "G4NeutronHPElasticData.hh" +#include "G4NeutronHPThermalScatteringData.hh" +#include "G4NeutronHPElastic.hh" +#include "G4NeutronHPThermalScattering.hh" + +#include "G4NeutronInelasticProcess.hh" +#include "G4NeutronHPInelasticData.hh" +#include "G4NeutronHPInelastic.hh" + +#include "G4HadronCaptureProcess.hh" +#include "G4NeutronHPCaptureData.hh" +#include "G4NeutronHPCapture.hh" + +#include "G4HadronFissionProcess.hh" +#include "G4NeutronHPFissionData.hh" +#include "G4NeutronHPFission.hh" + +#include "G4SystemOfUnits.hh" + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +NeutronHPphysics::NeutronHPphysics(const G4String& name) +: G4VPhysicsConstructor(name), fThermal(true), fNeutronMessenger(0) +{ + fNeutronMessenger = new NeutronHPMessenger(this); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +NeutronHPphysics::~NeutronHPphysics() +{ + delete fNeutronMessenger; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void NeutronHPphysics::ConstructProcess() +{ + G4ProcessManager* pManager = G4Neutron::Neutron()->GetProcessManager(); + + // process: elastic + // + G4HadronElasticProcess* process1 = new G4HadronElasticProcess(); + pManager->AddDiscreteProcess(process1); + // + // cross section data set + G4NeutronHPElasticData* dataSet1a = new G4NeutronHPElasticData(); + G4NeutronHPThermalScatteringData* dataSet1b + = new G4NeutronHPThermalScatteringData(); + process1->AddDataSet(dataSet1a); + if (fThermal) process1->AddDataSet(dataSet1b); + // + // models + G4NeutronHPElastic* model1a = new G4NeutronHPElastic(); + G4NeutronHPThermalScattering* model1b = new G4NeutronHPThermalScattering(); + if (fThermal) model1a->SetMinEnergy(4*eV); + process1->RegisterMe(model1a); + if (fThermal) process1->RegisterMe(model1b); + + // process: inelastic + // + G4NeutronInelasticProcess* process2 = new G4NeutronInelasticProcess(); + pManager->AddDiscreteProcess(process2); + // + // cross section data set + G4NeutronHPInelasticData* dataSet2 = new G4NeutronHPInelasticData(); + process2->AddDataSet(dataSet2); + // + // models + G4NeutronHPInelastic* model2 = new G4NeutronHPInelastic(); + process2->RegisterMe(model2); + + // process: nCapture + // + G4HadronCaptureProcess* process3 = new G4HadronCaptureProcess(); + pManager->AddDiscreteProcess(process3); + // + // cross section data set + G4NeutronHPCaptureData* dataSet3 = new G4NeutronHPCaptureData(); + process3->AddDataSet(dataSet3); + // + // models + G4NeutronHPCapture* model3 = new G4NeutronHPCapture(); + process3->RegisterMe(model3); + + // process: nFission + // + G4HadronFissionProcess* process4 = new G4HadronFissionProcess(); + pManager->AddDiscreteProcess(process4); + // + // cross section data set + G4NeutronHPFissionData* dataSet4 = new G4NeutronHPFissionData(); + process4->AddDataSet(dataSet4); + // + // models + G4NeutronHPFission* model4 = new G4NeutronHPFission(); + process4->RegisterMe(model4); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... diff --git a/CUDA_Hadr04/src/Hadr04/src/PhysicsList.cc b/CUDA_Hadr04/src/Hadr04/src/PhysicsList.cc new file mode 100644 index 00000000..eae0ed5c --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/src/PhysicsList.cc @@ -0,0 +1,101 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +/// \file hadronic/Hadr03/src/PhysicsList.cc +/// \brief Implementation of the PhysicsList class +// +// $Id: PhysicsList.cc 70268 2013-05-28 14:17:50Z maire $ + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#include "PhysicsList.hh" + +#include "G4SystemOfUnits.hh" +#include "G4UnitsTable.hh" + +#include "NeutronHPphysics.hh" + +// particles + +#include "G4BosonConstructor.hh" +#include "G4LeptonConstructor.hh" +#include "G4MesonConstructor.hh" +#include "G4BosonConstructor.hh" +#include "G4BaryonConstructor.hh" +#include "G4IonConstructor.hh" +#include "G4ShortLivedConstructor.hh" + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +PhysicsList::PhysicsList() +:G4VModularPhysicsList() +{ + SetVerboseLevel(1); + + //add new units + // + new G4UnitDefinition( "millielectronVolt", "meV", "Energy", 1.e-3*eV); + new G4UnitDefinition( "mm2/g", "mm2/g", "Surface/Mass", mm2/g); + new G4UnitDefinition( "um2/mg", "um2/mg","Surface/Mass", um*um/mg); + + // Neutron Physics + RegisterPhysics( new NeutronHPphysics("neutronHP")); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +PhysicsList::~PhysicsList() +{ } + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void PhysicsList::ConstructParticle() +{ + G4BosonConstructor pBosonConstructor; + pBosonConstructor.ConstructParticle(); + + G4LeptonConstructor pLeptonConstructor; + pLeptonConstructor.ConstructParticle(); + + G4MesonConstructor pMesonConstructor; + pMesonConstructor.ConstructParticle(); + + G4BaryonConstructor pBaryonConstructor; + pBaryonConstructor.ConstructParticle(); + + G4IonConstructor pIonConstructor; + pIonConstructor.ConstructParticle(); + + G4ShortLivedConstructor pShortLivedConstructor; + pShortLivedConstructor.ConstructParticle(); +} +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void PhysicsList::SetCuts() +{ + SetCutValue(0*mm, "proton"); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... diff --git a/CUDA_Hadr04/src/Hadr04/src/PrimaryGeneratorAction.cc b/CUDA_Hadr04/src/Hadr04/src/PrimaryGeneratorAction.cc new file mode 100644 index 00000000..38158b51 --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/src/PrimaryGeneratorAction.cc @@ -0,0 +1,92 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +/// \file electromagnetic/TestEm4/src/PrimaryGeneratorAction.cc +/// \brief Implementation of the PrimaryGeneratorAction class +// +// +// $Id: PrimaryGeneratorAction.cc 67268 2013-02-13 11:38:40Z ihrivnac $ +// +// + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#include "PrimaryGeneratorAction.hh" + +#include "G4Event.hh" +#include "G4ParticleTable.hh" +#include "G4ParticleDefinition.hh" +#include "G4PhysicalConstants.hh" +#include "G4SystemOfUnits.hh" +#include "Randomize.hh" + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +PrimaryGeneratorAction::PrimaryGeneratorAction() +: G4VUserPrimaryGeneratorAction(),fParticleGun(0) +{ + G4int n_particle = 1; + fParticleGun = new G4ParticleGun(n_particle); + + // default particle kinematic + + G4ParticleDefinition* particle + = G4ParticleTable::GetParticleTable()->FindParticle("neutron"); + fParticleGun->SetParticleDefinition(particle); + fParticleGun->SetParticleMomentumDirection(G4ThreeVector(1.,0.,0.)); + fParticleGun->SetParticleEnergy(2*MeV); + fParticleGun->SetParticlePosition(G4ThreeVector(0.*cm,0.*cm,0.*cm)); + +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +PrimaryGeneratorAction::~PrimaryGeneratorAction() +{ + delete fParticleGun; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) +{ + //this function is called at the begining of event + // + //distribution uniform in solid angle + // + G4double cosTheta = 2*G4UniformRand() - 1., phi = twopi*G4UniformRand(); + G4double sinTheta = std::sqrt(1. - cosTheta*cosTheta); + G4double ux = sinTheta*std::cos(phi), + uy = sinTheta*std::sin(phi), + uz = cosTheta; + + fParticleGun->SetParticleMomentumDirection(G4ThreeVector(ux,uy,uz)); + + fParticleGun->GeneratePrimaryVertex(anEvent); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + diff --git a/CUDA_Hadr04/src/Hadr04/src/Run.cc b/CUDA_Hadr04/src/Hadr04/src/Run.cc new file mode 100644 index 00000000..45e68029 --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/src/Run.cc @@ -0,0 +1,240 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +/// \file electromagnetic/TestEm11/src/Run.cc +/// \brief Implementation of the Run class +// +// $Id: Run.cc 71376 2013-06-14 07:44:50Z maire $ +// +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#include "Run.hh" +#include "DetectorConstruction.hh" + +#include "G4UnitsTable.hh" +#include "G4SystemOfUnits.hh" + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +Run::Run(DetectorConstruction* det) +: G4Run(), + fDetector(det), + fNbStep1(0), fNbStep2(0), + fTrackLen1(0.), fTrackLen2(0.), + fTime1(0.),fTime2(0.) +{ } +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +Run::~Run() +{ } + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void Run::CountProcesses(const G4VProcess* process) +{ + std::map::iterator it = fProcCounter.find(process); + if ( it == fProcCounter.end()) { + fProcCounter[process] = 1; + } + else { + fProcCounter[process]++; + } +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void Run::ParticleCount(G4String name, G4double Ekin) +{ + std::map::iterator it = fParticleDataMap.find(name); + if ( it == fParticleDataMap.end()) { + fParticleDataMap[name] = ParticleData(1, Ekin, Ekin, Ekin); + } + else { + ParticleData& data = it->second; + data.fCount++; + data.fEmean += Ekin; + //update min max + G4double emin = data.fEmin; + if (Ekin < emin) data.fEmin = Ekin; + G4double emax = data.fEmax; + if (Ekin > emax) data.fEmax = Ekin; + } +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void Run::SumTrackLength(G4int nstep1, G4int nstep2, + G4double trackl1, G4double trackl2, + G4double time1, G4double time2) +{ + fNbStep1 += nstep1; fNbStep2 += nstep2; + fTrackLen1 += trackl1; fTrackLen2 += trackl2; + fTime1 += time1; fTime2 += time2; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void Run::ComputeStatistics() +{ + G4int prec = 5, wid = prec + 2; + G4int dfprec = G4cout.precision(prec); + + //frequency of processes + // + G4cout << "\n Process calls frequency --->"; + G4int survive = 0; + std::map::iterator it; + for (it = fProcCounter.begin(); it != fProcCounter.end(); it++) { + G4String procName = it->first->GetProcessName(); + G4int count = it->second; + G4cout << "\t" << procName << "= " << count; + if (procName == "Transportation") survive = count; + } + G4cout << G4endl; + + if (survive > 0) { + G4cout << "\n Nb of incident particles surviving after " + << G4BestUnit(0.5*(fDetector->GetSize()),"Length") << " of " + << fDetector->GetMaterial()->GetName() << " : " << survive << G4endl; + } + + // total track length of incident neutron + // + G4cout << "\n Parcours of incident neutron:"; + + G4double meanCollision1 = (G4double)fNbStep1/numberOfEvent; + G4double meanCollision2 = (G4double)fNbStep2/numberOfEvent; + G4double meanCollisTota = meanCollision1 + meanCollision2; + + G4cout << "\n nb of collisions E>1*eV= " << meanCollision1 + << " E<1*eV= " << meanCollision2 + << " total= " << meanCollisTota; + + G4double meanTrackLen1 = fTrackLen1/numberOfEvent; + G4double meanTrackLen2 = fTrackLen2/numberOfEvent; + G4double meanTrackLtot = meanTrackLen1 + meanTrackLen2; + + G4cout + << "\n track length E>1*eV= " << G4BestUnit(meanTrackLen1,"Length") + << " E<1*eV= " << G4BestUnit(meanTrackLen2, "Length") + << " total= " << G4BestUnit(meanTrackLtot, "Length"); + + G4double meanTime1 = fTime1/numberOfEvent; + G4double meanTime2 = fTime2/numberOfEvent; + G4double meanTimeTo = meanTime1 + meanTime2; + + G4cout + << "\n time of flight E>1*eV= " << G4BestUnit(meanTime1,"Time") + << " E<1*eV= " << G4BestUnit(meanTime2, "Time") + << " total= " << G4BestUnit(meanTimeTo, "Time") << G4endl; + + //particles count + // + G4cout << "\n List of generated particles:" << G4endl; + + std::map::iterator itn; + for (itn = fParticleDataMap.begin(); itn != fParticleDataMap.end(); itn++) { + G4String name = itn->first; + ParticleData data = itn->second; + G4int count = data.fCount; + G4double eMean = data.fEmean/count; + G4double eMin = data.fEmin; + G4double eMax = data.fEmax; + + G4cout << " " << std::setw(13) << name << ": " << std::setw(7) << count + << " Emean = " << std::setw(wid) << G4BestUnit(eMean, "Energy") + << "\t( " << G4BestUnit(eMin, "Energy") + << " --> " << G4BestUnit(eMax, "Energy") + << ")" << G4endl; + } + + //restore default format + G4cout.precision(dfprec); + + // remove all contents in fProcCounter + fProcCounter.clear(); + // remove all contents in fCount + fParticleDataMap.clear(); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void Run::Merge(const G4Run* run) +{ + const Run* localRun = static_cast(run); + + // accumulate sums + // + fNbStep1 += localRun->fNbStep1; + fNbStep2 += localRun->fNbStep2; + fTrackLen1 += localRun->fTrackLen1; + fTrackLen2 += localRun->fTrackLen2; + fTime1 += localRun->fTime1; + fTime2 += localRun->fTime2; + + //maps + std::map::const_iterator itp; + for ( itp = localRun->fProcCounter.begin(); + itp != localRun->fProcCounter.end(); ++itp ) { + + const G4VProcess* process = itp->first; + G4int localCount = itp->second; + if ( fProcCounter.find(process) == fProcCounter.end()) { + fProcCounter[process] = localCount; + } + else { + fProcCounter[process] += localCount; + } + } + + std::map::const_iterator itn; + for (itn = localRun->fParticleDataMap.begin(); + itn != localRun->fParticleDataMap.end(); ++itn) { + + G4String name = itn->first; + const ParticleData& localData = itn->second; + if ( fParticleDataMap.find(name) == fParticleDataMap.end()) { + fParticleDataMap[name] + = ParticleData(localData.fCount, + localData.fEmean, + localData.fEmin, + localData.fEmax); + } + else { + ParticleData& data = fParticleDataMap[name]; + data.fCount += localData.fCount; + data.fEmean += localData.fEmean; + G4double emin = localData.fEmin; + if (emin < data.fEmin) data.fEmin = emin; + G4double emax = localData.fEmax; + if (emax > data.fEmax) data.fEmax = emax; + } + } + + G4Run::Merge(run); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... diff --git a/CUDA_Hadr04/src/Hadr04/src/RunAction.cc b/CUDA_Hadr04/src/Hadr04/src/RunAction.cc new file mode 100644 index 00000000..1488ef38 --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/src/RunAction.cc @@ -0,0 +1,184 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +/// \file hadronic/Hadr03/src/RunAction.cc +/// \brief Implementation of the RunAction class +// +// $Id: RunAction.cc 70756 2013-06-05 12:20:06Z ihrivnac $ +// +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#include "RunAction.hh" + +#include "DetectorConstruction.hh" +#include "PrimaryGeneratorAction.hh" +#include "HistoManager.hh" +#include "Run.hh" + +#include "G4Run.hh" +#include "G4RunManager.hh" +#include "G4UnitsTable.hh" +#include "G4SystemOfUnits.hh" + +#include "Randomize.hh" +#include + +#include +#include +#include "CUDA_G4NeutronHPVector.h" + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +RunAction::RunAction(DetectorConstruction* det, PrimaryGeneratorAction* prim) + : G4UserRunAction(), + fDetector(det), fPrimary(prim), fRun(0), fHistoManager(0) +{ + // Book predefined histograms + fHistoManager = new HistoManager(); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +RunAction::~RunAction() +{ + delete fHistoManager; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +G4Run* RunAction::GenerateRun() +{ + fRun = new Run(fDetector); + return fRun; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void RunAction::BeginOfRunAction(const G4Run*) +{ + // save Rndm status + G4RunManager::GetRunManager()->SetRandomNumberStore(false); + G4Random::showEngineStatus(); + + //histograms + // + G4AnalysisManager* analysisManager = G4AnalysisManager::Instance(); + if ( analysisManager->IsActive() ) { + analysisManager->OpenFile(); + } +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void RunAction::EndOfRunAction(const G4Run* aRun) +{ + + // ================== CUDA CODE ==================== // + #if USE_GPU + #define arraySize 15 + int *arr1 = new int[arraySize]; + int *arr2 = new int[arraySize]; + for (int i = 0; i < arraySize; i++) { + arr1[i] = (int)rand() % 100; + arr2[i] = (int)rand() % 100; + } + int *sum = new int[arraySize]; + + G4cout << "\n***************************** CUDA ***********************************" << G4endl; + std::clock_t start = std::clock(); + CUDA_sumArrays(arr1, arr2, sum, arraySize); + std::clock_t end = std::clock(); + + G4cout << "Sum of ["; + for (int i = 0; i < arraySize; i++) { + if (i == arraySize-1) + G4cout << arr1[i] << "]"; + else + G4cout << arr1[i] << ", "; + } + G4cout << "\nand of ["; + for (int i = 0; i < arraySize; i++) { + if (i == arraySize-1) + G4cout << arr2[i] << "]"; + else + G4cout << arr2[i] << ", "; + } + G4cout << "\n Array ["; + for (int i = 0; i < arraySize; i++) { + if (i == arraySize-1) + G4cout << sum[i] << "]"; + else + G4cout << sum[i] << ", "; + } + G4cout << "\nComputation done in " << double(end-start)/CLOCKS_PER_SEC << " s" << G4endl; + G4cout << "******************************** CUDA ********************************\n" << G4endl; + #else + G4cout << "\nCUDA is disabled." << G4endl; + #endif + // ================ END CUDA CODE ================== // + + G4int nbOfEvents = aRun->GetNumberOfEvent(); + + if ( fPrimary && nbOfEvents ) { + + G4int prec = 5; + G4int dfprec = G4cout.precision(prec); + + G4Material* material = fDetector->GetMaterial(); + G4double density = material->GetDensity(); + + G4ParticleDefinition* particle = + fPrimary->GetParticleGun()->GetParticleDefinition(); + G4String Particle = particle->GetParticleName(); + G4double energy = fPrimary->GetParticleGun()->GetParticleEnergy(); + G4cout << "\n The run is of " << nbOfEvents << " "<< Particle << " of " + << G4BestUnit(energy,"Energy") << " through " + << G4BestUnit(fDetector->GetSize(),"Length") << " of " + << material->GetName() << " (density: " + << G4BestUnit(density,"Volumic Mass") << ")" << G4endl; + + //restore default format + G4cout.precision(dfprec); + } + + //compute and print statistics + // + if (isMaster) fRun->ComputeStatistics(); + + //save histograms + G4AnalysisManager* analysisManager = G4AnalysisManager::Instance(); + ////G4double factor = 1./nbOfEvents; + ////analysisManager->ScaleH1(3,factor); + if ( analysisManager->IsActive() ) { + analysisManager->Write(); + analysisManager->CloseFile(); + } + + // show Rndm status + G4Random::showEngineStatus(); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... diff --git a/CUDA_Hadr04/src/Hadr04/src/StackingAction.cc b/CUDA_Hadr04/src/Hadr04/src/StackingAction.cc new file mode 100644 index 00000000..56ffc8f2 --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/src/StackingAction.cc @@ -0,0 +1,70 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +/// \file electromagnetic/TestEm5/src/StackingAction.cc +/// \brief Implementation of the StackingAction class +// +// $Id: StackingAction.cc 67268 2013-02-13 11:38:40Z ihrivnac $ +// +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#include "StackingAction.hh" +#include "Run.hh" + +#include "G4RunManager.hh" +#include "G4Track.hh" + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +StackingAction::StackingAction() +:G4UserStackingAction() +{ } + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +StackingAction::~StackingAction() +{ } + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +G4ClassificationOfNewTrack +StackingAction::ClassifyNewTrack(const G4Track* aTrack) +{ + //keep primary particle + if (aTrack->GetParentID() == 0) return fUrgent; + + //count secondary particles + G4String name = aTrack->GetDefinition()->GetParticleName(); + G4double energy = aTrack->GetKineticEnergy(); + Run* run = static_cast( + G4RunManager::GetRunManager()->GetNonConstCurrentRun()); + run->ParticleCount(name,energy); + + //kill all secondaries + return fKill; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... diff --git a/CUDA_Hadr04/src/Hadr04/src/SteppingAction.cc b/CUDA_Hadr04/src/Hadr04/src/SteppingAction.cc new file mode 100644 index 00000000..eb9cf217 --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/src/SteppingAction.cc @@ -0,0 +1,77 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +/// \file hadronic/Hadr03/src/SteppingAction.cc +/// \brief Implementation of the SteppingAction class +// +// $Id: SteppingAction.cc 71404 2013-06-14 16:56:38Z maire $ +// +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#include "SteppingAction.hh" +#include "Run.hh" +#include "TrackingAction.hh" +#include "HistoManager.hh" + +#include "G4RunManager.hh" + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +SteppingAction::SteppingAction(TrackingAction* TrAct) +: G4UserSteppingAction(),fTrackingAction(TrAct) +{ } + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +SteppingAction::~SteppingAction() +{ } + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void SteppingAction::UserSteppingAction(const G4Step* aStep) +{ + // count processes + // + const G4StepPoint* endPoint = aStep->GetPostStepPoint(); + const G4VProcess* process = endPoint->GetProcessDefinedStep(); + Run* run = static_cast( + G4RunManager::GetRunManager()->GetNonConstCurrentRun()); + run->CountProcesses(process); + + // incident neutron + // + if (aStep->GetTrack()->GetTrackID() == 1) { + G4double ekin = endPoint->GetKineticEnergy(); + G4double trackl = aStep->GetTrack()->GetTrackLength(); + G4double time = aStep->GetTrack()->GetLocalTime(); + fTrackingAction->UpdateTrackInfo(ekin,trackl,time); + G4AnalysisManager::Instance()->FillH1(7,ekin); + } +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + + diff --git a/CUDA_Hadr04/src/Hadr04/src/SteppingVerbose.cc b/CUDA_Hadr04/src/Hadr04/src/SteppingVerbose.cc new file mode 100644 index 00000000..827b7013 --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/src/SteppingVerbose.cc @@ -0,0 +1,158 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +/// \file radioactivedecay/rdecay01/src/SteppingVerbose.cc +/// \brief Implementation of the SteppingVerbose class +// +// +// $Id: SteppingVerbose.cc 71654 2013-06-19 18:20:04Z maire $ +// +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#include "SteppingVerbose.hh" + +#include "G4SteppingManager.hh" +#include "G4ParticleTypes.hh" +#include "G4UnitsTable.hh" + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +SteppingVerbose::SteppingVerbose() + : G4SteppingVerbose() +{ } + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +SteppingVerbose::~SteppingVerbose() +{} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void SteppingVerbose::TrackingStarted() +{ + CopyState(); + + G4int prec = G4cout.precision(3); + + //Step zero + // + if( verboseLevel > 0 ){ + G4cout << std::setw( 5) << "Step#" << " " + << std::setw( 6) << "X" << " " + << std::setw( 6) << "Y" << " " + << std::setw( 6) << "Z" << " " + << std::setw( 9) << "KineE" << " " + << std::setw( 9) << "dEStep" << " " + << std::setw(10) << "StepLeng" + << std::setw(10) << "TrakLeng" + << std::setw(10) << "Volume" << " " + << std::setw(10) << "Process" << G4endl; + + G4cout << std::setw(5) << fTrack->GetCurrentStepNumber() << " " + << std::setw(6) << G4BestUnit(fTrack->GetPosition().x(),"Length") + << std::setw(6) << G4BestUnit(fTrack->GetPosition().y(),"Length") + << std::setw(6) << G4BestUnit(fTrack->GetPosition().z(),"Length") + << std::setw(6) << G4BestUnit(fTrack->GetKineticEnergy(),"Energy") + << std::setw(6) << G4BestUnit(fStep->GetTotalEnergyDeposit(),"Energy") + << std::setw(6) << G4BestUnit(fStep->GetStepLength(),"Length") + << std::setw(6) << G4BestUnit(fTrack->GetTrackLength(),"Length") + << std::setw(10) << fTrack->GetVolume()->GetName() + << " initStep" << G4endl; + } + G4cout.precision(prec); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void SteppingVerbose::StepInfo() +{ + CopyState(); + + G4int prec = G4cout.precision(3); + + if( verboseLevel >= 1 ){ + if( verboseLevel >= 4 ) VerboseTrack(); + if( verboseLevel >= 3 ){ + G4cout << G4endl; + G4cout << std::setw( 5) << "#Step#" << " " + << std::setw( 6) << "X" << " " + << std::setw( 6) << "Y" << " " + << std::setw( 6) << "Z" << " " + << std::setw( 9) << "KineE" << " " + << std::setw( 9) << "dEStep" << " " + << std::setw(10) << "StepLeng" + << std::setw(10) << "TrakLeng" + << std::setw(10) << "Volume" << " " + << std::setw(10) << "Process" << G4endl; + } + + G4cout << std::setw( 5) << fTrack->GetCurrentStepNumber() << " " + << std::setw(6) << G4BestUnit(fTrack->GetPosition().x(),"Length") + << std::setw(6) << G4BestUnit(fTrack->GetPosition().y(),"Length") + << std::setw(6) << G4BestUnit(fTrack->GetPosition().z(),"Length") + << std::setw(6) << G4BestUnit(fTrack->GetKineticEnergy(),"Energy") + << std::setw(6) << G4BestUnit(fStep->GetTotalEnergyDeposit(),"Energy") + << std::setw(6) << G4BestUnit(fStep->GetStepLength(),"Length") + << std::setw(6) << G4BestUnit(fTrack->GetTrackLength(),"Length") + << std::setw(10) << fTrack->GetVolume()->GetName(); + + const G4VProcess* process + = fStep->GetPostStepPoint()->GetProcessDefinedStep(); + G4String procName = " UserLimit"; + if (process) procName = process->GetProcessName(); + if (fStepStatus == fWorldBoundary) procName = "OutOfWorld"; + G4cout << " " << std::setw(10) << procName; + G4cout << G4endl; + + if (verboseLevel == 2) { + const std::vector* secondary + = fStep->GetSecondaryInCurrentStep(); + size_t nbtrk = (*secondary).size(); + if (nbtrk) { + G4cout << "\n :----- List of secondaries ----------------" << G4endl; + G4cout.precision(4); + for (size_t lp=0; lp<(*secondary).size(); lp++) { + G4cout << " " + << std::setw(13) + << (*secondary)[lp]->GetDefinition()->GetParticleName() + << ": energy =" + << std::setw(6) + << G4BestUnit((*secondary)[lp]->GetKineticEnergy(),"Energy") + << " time =" + << std::setw(6) + << G4BestUnit((*secondary)[lp]->GetGlobalTime(),"Time"); + G4cout << G4endl; + } + + G4cout << " :------------------------------------------\n" << G4endl; + } + } + + } + G4cout.precision(prec); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... diff --git a/CUDA_Hadr04/src/Hadr04/src/TrackingAction.cc b/CUDA_Hadr04/src/Hadr04/src/TrackingAction.cc new file mode 100644 index 00000000..5d4e1282 --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/src/TrackingAction.cc @@ -0,0 +1,98 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +/// \file electromagnetic/TestEm12/src/TrackingAction.cc +/// \brief Implementation of the TrackingAction class +// +// $Id: TrackingAction.cc 69099 2013-04-18 12:25:19Z maire $ +// +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#include "TrackingAction.hh" + +#include "Run.hh" +#include "HistoManager.hh" + +#include "G4RunManager.hh" +#include "G4Track.hh" +#include "G4SystemOfUnits.hh" + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +TrackingAction::TrackingAction() +:G4UserTrackingAction(), + fNbStep1(0),fNbStep2(0),fTrackLen1(0.),fTrackLen2(0.),fTime1(0.),fTime2(0.) +{ } + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void TrackingAction::PreUserTrackingAction(const G4Track*) +{ + fNbStep1 = fNbStep2 = 0; + fTrackLen1 = fTrackLen2 = 0.; + fTime1 = fTime2 = 0.; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void TrackingAction::UpdateTrackInfo(G4double ekin,G4double trackl, + G4double time) +{ + const G4double thermal = 1*eV; + if (ekin > thermal) { + fNbStep1++; fTrackLen1 = trackl; fTime1 = time; + } else { + fNbStep2++; fTrackLen2 = trackl - fTrackLen1; fTime2 = time - fTime1; + } +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void TrackingAction::PostUserTrackingAction(const G4Track* track) +{ + // keep only primary neutron + // + G4int trackID = track->GetTrackID(); + if (trackID > 1) return; + + Run* run + = static_cast( + G4RunManager::GetRunManager()->GetNonConstCurrentRun()); + run->SumTrackLength(fNbStep1,fNbStep2,fTrackLen1,fTrackLen2,fTime1,fTime2); + + // histograms + // + G4AnalysisManager* analysisManager = G4AnalysisManager::Instance(); + analysisManager->FillH1(1,fNbStep1); + analysisManager->FillH1(2,fTrackLen1); + analysisManager->FillH1(3,fTime1); + analysisManager->FillH1(4,fNbStep2); + analysisManager->FillH1(5,fTrackLen2); + analysisManager->FillH1(6,fTime2); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + diff --git a/CUDA_Hadr04/src/Hadr04/vis.mac b/CUDA_Hadr04/src/Hadr04/vis.mac new file mode 100644 index 00000000..e66636bb --- /dev/null +++ b/CUDA_Hadr04/src/Hadr04/vis.mac @@ -0,0 +1,79 @@ +# +# Macro file for the initialization phase of "TestEm6.cc" +# +# Sets some default verbose +# and initializes the graphic. +# +/control/verbose 2 +/run/verbose 2 +# +/run/initialize +# +# Use this open statement to create an OpenGL view: +/vis/open OGL 600x600-0+0 +# +# Use this open statement to create a .prim file suitable for +# viewing in DAWN: +#/vis/open DAWNFILE +# +# Use this open statement to create a .heprep file suitable for +# viewing in HepRApp: +#/vis/open HepRepFile +# +# Use this open statement to create a .wrl file suitable for +# viewing in a VRML viewer: +#/vis/open VRML2FILE +# +# Disable auto refresh and quieten vis messages whilst scene and +# trajectories are established: +/vis/viewer/set/autoRefresh false +/vis/verbose errors +# +# Draw geometry: +/vis/drawVolume +# +# Specify view angle: +#/vis/viewer/set/viewpointThetaPhi 90. 0. +# +# Specify zoom value: +/vis/viewer/zoom 1.4 +# +# Specify style (surface or wireframe): +#/vis/viewer/set/style surface +# +# Draw coordinate axes: +#/vis/scene/add/axes 0 0 0 1 m +# +# Draw smooth trajectories at end of event, showing trajectory points +# as markers 2 pixels wide: +/vis/scene/add/trajectories smooth +/vis/modeling/trajectories/create/drawByCharge +/vis/modeling/trajectories/drawByCharge-0/default/setDrawStepPts false +/vis/modeling/trajectories/drawByCharge-0/default/setStepPtsSize 1 +# (if too many tracks cause core dump => /tracking/storeTrajectory 0) +# +# Draw hits at end of event: +#/vis/scene/add/hits +# +# To draw only gammas: +#/vis/filtering/trajectories/create/particleFilter +#/vis/filtering/trajectories/particleFilter-0/add gamma +# +# To invert the above, drawing all particles except gammas, +# keep the above two lines but also add: +#/vis/filtering/trajectories/particleFilter-0/invert true +# +# Many other options are available with /vis/modeling and /vis/filtering. +# For example, to select colour by particle ID: +#/vis/modeling/trajectories/create/drawByParticleID +#/vis/modeling/trajectories/drawByParticleID-0/set e- blue +# +# To superimpose all of the events from a given run: +/vis/scene/endOfEventAction accumulate +# +# Re-establish auto refreshing and verbosity: +/vis/viewer/set/autoRefresh true +/vis/verbose warnings +# +# For file-based drivers, use this to create an empty detector view: +#/vis/viewer/flush