0

我正在对 geant4 中的 HPGe 探测器进行简单模拟。我为简单的 HPGe 探测器配置编写了代码。我为 1.hpgeDetectorConstruction 2.hpgePhysicsLists 3.hpgePrimaryActionGenerator 编写代码的地方

头文件和 C++ 文件。我也为此编写了主程序。我为 CMakeLists.txt 编写了用于执行 cmake 的代码,如下所示:

#----------------------------------------------------------------------------
# Setup the project
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(hpge)

#----------------------------------------------------------------------------
# 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(hpge hpge_main.cc ${sources} ${headers})
target_link_libraries(hpge ${Geant4_LIBRARIES})

#----------------------------------------------------------------------------
# Copy all scripts to the build directory, i.e. the directory in which we
# build hpge. This is so that we can run the executable directly because it
# relies on these scripts being in the current working directory.
#
set(HPGE_SCRIPT
  hepgeDet.in
  hpgeDet.out
  init_vis.mac
  run1.mac
  run2.mac
  vis.mac
  )

foreach(_script ${HPGE_SCRIPTS})
  configure_file(
    ${PROJECT_SOURCE_DIR}/${_script}
    ${PROJECT_BINARY_DIR}/${_script}
    COPYONLY
    )
endforeach()

#----------------------------------------------------------------------------
# For internal Geant4 use - but has no effect if you build this
# example standalone
#
add_custom_target(hpgeDet DEPENDS hpge)

#----------------------------------------------------------------------------
# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
#
install(TARGETS hpge DESTINATION bin)

当我运行命令cmake <path>时,它成功执行。之后,我将前往执行make -j4以构建目标。它向我显示了错误:

Scanning dependencies of target hpge
[ 20%] Building CXX object CMakeFiles/hpge.dir/hpge_main.cc.o
/home/subhrod/G4_project/HPGe_design/hpge_main.cc:1:10: fatal error: G4RunManagerFactory.hh: No such file or directory
    1 | #include "G4RunManagerFactory.hh"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/hpge.dir/build.make:63: CMakeFiles/hpge.dir/hpge_main.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:104: CMakeFiles/hpge.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
subhrod@subhrod-HP-Pavilion-x360-Convert

请帮助我,如何让我的系统检测到 geant4 的头文件。

4

0 回答 0