Compare commits

...

3 Commits

Author SHA1 Message Date
Gitea 8d41c90e26 Creation of Medtech 2018-03-30 18:54:24 +02:00
Gitea 9264023505 Added CMakeLists.txt 2018-03-30 18:53:09 +02:00
Gitea 299a56a4f6 Added default macros 2018-03-30 18:50:26 +02:00
6 changed files with 188 additions and 0 deletions

72
CMakeLists.txt Executable file
View File

@ -0,0 +1,72 @@
# $Id: CMakeLists.txt 86065 2014-11-07 08:51:15Z gcosmo $
#----------------------------------------------------------------------------
# Setup the project
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(medtech)
#----------------------------------------------------------------------------
# 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
# Setup include directory for this project
#
include(${Geant4_USE_FILE})
include_directories(${PROJECT_SOURCE_DIR}/include)
#----------------------------------------------------------------------------
# Locate sources and headers for this project
# NB: headers are included so they will show up in IDEs
#
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(medtech medtech.cc ${sources} ${headers})
target_link_libraries(medtech ${Geant4_LIBRARIES})
#----------------------------------------------------------------------------
# Copy all scripts to the build directory, i.e. the directory in which we
# build DE. This is so that we can run the executable directly because it
# relies on these scripts being in the current working directory.
#
set(EXAMPLEMEDTECH_SCRIPTS
icons.mac
run.png
gui.mac
vis.mac
)
foreach(_script ${EXAMPLEMEDTECH_SCRIPTS})
configure_file(
${PROJECT_SOURCE_DIR}/macros/${_script}
${PROJECT_BINARY_DIR}/macros/${_script}
COPYONLY
)
endforeach()
#----------------------------------------------------------------------------
# For internal Geant4 use - but has no effect if you build this
# example standalone
#
add_custom_target(GDE DEPENDS medtech)
#----------------------------------------------------------------------------
# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
#
install(TARGETS medtech DESTINATION bin)

12
macros/gui.mac Executable file
View File

@ -0,0 +1,12 @@
/control/execute icons.mac
/control/execute vis.mac
/gui/addMenu run Run
/gui/addButton run "beamOn 1" "/run/beamOn 1"
/gui/addButton run "beamOn 10" "/run/beamOn 10"
/gui/addButton run "beamOn 100" "/run/beamOn 100"
/gui/addButton run "beamOn 1000" "/run/beamOn 1000"
# User defined icon :
/gui/addIcon "Run beam on" user_icon "/run/beamOn 1" run.png

25
macros/icons.mac Executable file
View File

@ -0,0 +1,25 @@
/gui/addIcon "Open macro file" open /control/execute
/gui/addIcon "Save viewer state" save /vis/viewer/save
# Cursors style icons
/gui/addIcon "Move" move
/gui/addIcon "Rotate" rotate
# Particle
/gui/addMenu particle Particle
/gui/addButton particle muon- "/gun/particle mu-"
/gui/addButton particle electron- "/gun/particle e-"
/gui/addButton particle pion- "/gun/particle pi-"
/gui/addButton particle gamma "/gun/particle gamma"
#
# Energy
/gui/addMenu energy Energy
/gui/addButton energy 100-keV "/gun/energy 100 keV"
/gui/addButton energy 300-keV "/gun/energy 300 keV"
/gui/addButton energy 1-MeV "/gun/energy 1 MeV"
/gui/addButton energy 3-MeV "/gun/energy 3 MeV"
/gui/addButton energy 10-MeV "/gun/energy 10 MeV"
#
# Surface Style icons
/gui/addIcon "Surfaces" solid
/gui/addIcon "Wireframe" wireframe

BIN
macros/run.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

22
macros/vis.mac Executable file
View File

@ -0,0 +1,22 @@
/run/initialize
/vis/open OGL 600x600-0+0
/vis/drawVolume
/vis/geometry/set/visibility World 0 false
/vis/viewer/set/style surface
/vis/viewer/set/viewpointThetaPhi 120 150
/vis/viewer/set/autoRefresh true
/vis/scene/add/trajectories smooth
/vis/scene/endOfEventAction accumulate 1000
/vis/scene/add/axes
/vis/scene/add/eventID
/vis/scene/add/text 0 6 14 cm 18 4 4 Box
/vis/ogl/set/displayListLimit 50000
/run/beamOn 10

57
medtech.cc Normal file
View File

@ -0,0 +1,57 @@
//
// medtech.cc
// CERN MedTech:Hack
//
// Created by Baranyai David on 2018. 03. 30..
// Copyright © 2018. Baranyai David. All rights reserved.
//
#ifdef G4MULTITHREADED
#include "G4MTRunManager.hh"
#else
#include "G4RunManager.hh"
#endif
#include "G4UImanager.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"
int main(int argc,char** argv)
{
//parameter from command line
int NoE=0;
if (argc==2) NoE=atoi(argv[1]);
#ifdef G4MULTITHREADED
G4MTRunManager* runManager = new G4MTRunManager;
unsigned nthreads = sysconf(_SC_NPROCESSORS_ONLN); //Use all available cores
std::cout << "Using all cores (" << nthreads << ")\n";
runManager->SetNumberOfThreads(nthreads);
#else
G4RunManager* runManager = new G4RunManager;
#endif
G4VisManager* visManager = new G4VisExecutive;
visManager->Initialize();
G4UImanager* UImanager = G4UImanager::GetUIpointer();
if (argc==2) {
//batch mode
runManager->Initialize();
runManager->BeamOn(NoE);
}
else {
//interactive mode
G4UIExecutive* ui = 0;
if ( argc == 1 ) {
ui = new G4UIExecutive(argc, argv);
}
UImanager->ApplyCommand("/control/macroPath macros"); //Need to set, macros moved to that folder
ui->SessionStart();
delete ui;
}
delete visManager;
delete runManager;
}