mirror of
https://github.com/OpenCMT/uLib.git
synced 2025-12-06 07:21:31 +01:00
Compare commits
3 Commits
c526f61f8c
...
beam_trace
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e4d1e6af63 | ||
|
|
3cea59bc67 | ||
|
|
a2bd38fc2c |
@@ -15,16 +15,16 @@ set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin CACHE PATH "build path for
|
|||||||
mark_as_advanced(EXECUTABLE_OUTPUT_PATH)
|
mark_as_advanced(EXECUTABLE_OUTPUT_PATH)
|
||||||
|
|
||||||
## Install directories ##
|
## Install directories ##
|
||||||
set(INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables")
|
set(PACKAGE_INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables")
|
||||||
set(INSTALL_LIB_DIR lib/${PACKAGE_NAME} CACHE PATH "Installation directory for libraries")
|
set(PACKAGE_INSTALL_LIB_DIR lib/${PACKAGE_NAME} CACHE PATH "Installation directory for libraries")
|
||||||
set(INSTALL_INC_DIR include/${PACKAGE_NAME} CACHE PATH "Installation directory for headers")
|
set(PACKAGE_INSTALL_INC_DIR include/${PACKAGE_NAME} CACHE PATH "Installation directory for headers")
|
||||||
set(INSTALL_DATA_DIR share/${PACKAGE_NAME} CACHE PATH "Installation directory for data files")
|
set(PACKAGE_INSTALL_DATA_DIR share/${PACKAGE_NAME} CACHE PATH "Installation directory for data files")
|
||||||
if(WIN32 AND NOT CYGWIN)
|
if(WIN32 AND NOT CYGWIN)
|
||||||
set(DEF_INSTALL_CMAKE_DIR CMake)
|
set(DEF_INSTALL_CMAKE_DIR CMake)
|
||||||
else()
|
else()
|
||||||
set(DEF_INSTALL_CMAKE_DIR lib/cmake/${PACKAGE_NAME})
|
set(DEF_INSTALL_CMAKE_DIR lib/cmake/${PACKAGE_NAME})
|
||||||
endif()
|
endif()
|
||||||
set(INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files")
|
set(PACKAGE_INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files")
|
||||||
|
|
||||||
# Make relative paths absolute (needed later on)
|
# Make relative paths absolute (needed later on)
|
||||||
foreach(p LIB BIN INC DATA CMAKE)
|
foreach(p LIB BIN INC DATA CMAKE)
|
||||||
@@ -58,7 +58,7 @@ endif()
|
|||||||
set(CMAKE_CXX_WARNING_OPTION "" CACHE STRING "Warning level -WAll to verbose all warnings")
|
set(CMAKE_CXX_WARNING_OPTION "" CACHE STRING "Warning level -WAll to verbose all warnings")
|
||||||
set(CMAKE_VERBOSE_MAKEFILE FALSE CACHE STRING "Verbose compile output switch")
|
set(CMAKE_VERBOSE_MAKEFILE FALSE CACHE STRING "Verbose compile output switch")
|
||||||
|
|
||||||
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x ${CMAKE_CXX_WARNING_OPTION}")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x ${CMAKE_CXX_WARNING_OPTION}")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -41,15 +41,15 @@ macro(uLib_add_shared_library name)
|
|||||||
|
|
||||||
install(TARGETS ${mname}
|
install(TARGETS ${mname}
|
||||||
EXPORT "${PROJECT_NAME}Targets"
|
EXPORT "${PROJECT_NAME}Targets"
|
||||||
RUNTIME DESTINATION ${INSTALL_BIN_DIR} COMPONENT bin
|
RUNTIME DESTINATION ${PACKAGE_INSTALL_BIN_DIR} COMPONENT bin
|
||||||
LIBRARY DESTINATION ${INSTALL_LIB_DIR} COMPONENT lib
|
LIBRARY DESTINATION ${PACKAGE_INSTALL_LIB_DIR} COMPONENT lib
|
||||||
# PUBLIC_HEADER DESTINATION ${INSTALL_INC_DIR} COMPONENT dev
|
# PUBLIC_HEADER DESTINATION ${PACKAGE_INSTALL_INC_DIR} COMPONENT dev
|
||||||
)
|
)
|
||||||
endif(SOURCES)
|
endif(SOURCES)
|
||||||
|
|
||||||
if(HEADERS)
|
if(HEADERS)
|
||||||
foreach(header ${HEADERS})
|
foreach(header ${HEADERS})
|
||||||
install(FILES ${header} DESTINATION ${INSTALL_INC_DIR}/${name})
|
install(FILES ${header} DESTINATION ${PACKAGE_INSTALL_INC_DIR}/${name})
|
||||||
endforeach(header)
|
endforeach(header)
|
||||||
endif(HEADERS)
|
endif(HEADERS)
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ macro(uLib_add_target name)
|
|||||||
|
|
||||||
install(TARGETS ${name}
|
install(TARGETS ${name}
|
||||||
EXPORT "${PROJECT_NAME}Targets"
|
EXPORT "${PROJECT_NAME}Targets"
|
||||||
RUNTIME DESTINATION ${INSTALL_BIN_DIR} COMPONENT bin
|
RUNTIME DESTINATION ${PACKAGE_INSTALL_BIN_DIR} COMPONENT bin
|
||||||
)
|
)
|
||||||
ENDMACRO(uLib_add_target)
|
ENDMACRO(uLib_add_target)
|
||||||
|
|
||||||
|
|||||||
128
CMakeLists.txt
128
CMakeLists.txt
@@ -3,7 +3,7 @@
|
|||||||
##### CMAKE LISTS ##############################################################
|
##### CMAKE LISTS ##############################################################
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
cmake_minimum_required (VERSION 3.26)
|
cmake_minimum_required (VERSION 2.6)
|
||||||
|
|
||||||
## -------------------------------------------------------------------------- ##
|
## -------------------------------------------------------------------------- ##
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ project(uLib)
|
|||||||
|
|
||||||
# The version number.
|
# The version number.
|
||||||
set(PROJECT_VERSION_MAJOR 0)
|
set(PROJECT_VERSION_MAJOR 0)
|
||||||
set(PROJECT_VERSION_MINOR 6)
|
set(PROJECT_VERSION_MINOR 4)
|
||||||
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
|
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
|
||||||
set(PROJECT_SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
|
set(PROJECT_SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
|
||||||
|
|
||||||
@@ -33,31 +33,19 @@ message(STATUS "Module path = ${CMAKE_MODULE_PATH}")
|
|||||||
|
|
||||||
## GLOBALS ------------------------------------------------------------------ ##
|
## GLOBALS ------------------------------------------------------------------ ##
|
||||||
|
|
||||||
# -- move to GnuInstallDirs
|
set(PACKAGE_INSTALL_BIN_DIR ${CMAKE_INSTALL_PREFIX}/bin
|
||||||
# ref: https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html
|
CACHE PATH "Installation directory for executables")
|
||||||
include(GNUInstallDirs)
|
set(PACKAGE_INSTALL_LIB_DIR ${CMAKE_INSTALL_PREFIX}/lib/
|
||||||
set(INSTALL_INC_DIR ${CMAKE_INSTALL_INCLUDEDIR}/${PACKAGE_NAME}
|
CACHE PATH "Installation directory for libraries")
|
||||||
CACHE PATH "Location of header files (.../include)" )
|
set(PACKAGE_INSTALL_INC_DIR ${CMAKE_INSTALL_PREFIX}/include/${PACKAGE_NAME}
|
||||||
set(INSTALL_ETC_DIR ${CMAKE_INSTALL_SYSCONFDIR}/${PACKAGE_NAME}
|
CACHE PATH "Installation directory for headers")
|
||||||
CACHE PATH "Location of configuration files (.../etc)" )
|
set(PACKAGE_INSTALL_DATA_DIR ${CMAKE_INSTALL_PREFIX}/share/${PACKAGE_NAME}
|
||||||
set(INSTALL_BIN_DIR ${CMAKE_INSTALL_BINDIR}/${PACKAGE_NAME}
|
CACHE PATH "Installation directory for data files")
|
||||||
CACHE PATH "Location of executable files (.../bin)" )
|
set(PACKAGE_INSTALL_CMAKE_DIR ${CMAKE_INSTALL_PREFIX}/lib/cmake/${PACKAGE_NAME}
|
||||||
set(INSTALL_LIB_DIR ${CMAKE_INSTALL_LIBDIR}
|
CACHE PATH "Installation directory for CMake files")
|
||||||
CACHE PATH "Location of library files (.../lib)" )
|
|
||||||
set(INSTALL_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PACKAGE_NAME}
|
|
||||||
CACHE PATH "Location of cmake files (.../lib/cmake)" )
|
|
||||||
set(INSTALL_DATA_DIR ${CMAKE_INSTALL_DATADIR}/${PACKAGE_NAME}
|
|
||||||
CACHE PATH "Location of data files (.../share)" )
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
set(SRC_DIR ${PROJECT_SOURCE_DIR}/src)
|
set(SRC_DIR ${PROJECT_SOURCE_DIR}/src)
|
||||||
|
|
||||||
# this is used to be exported in build target
|
|
||||||
# ( to compile against build directory instead of install )
|
|
||||||
set(ULIB_SOURCE_DIR ${PROJECT_SOURCE_DIR})
|
|
||||||
|
|
||||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||||
message(STATUS "Setting build type to 'Release' as none was specified.")
|
message(STATUS "Setting build type to 'Release' as none was specified.")
|
||||||
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
|
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
|
||||||
@@ -72,12 +60,10 @@ set(CMAKE_CXX_WARNING_OPTION ""
|
|||||||
set(CMAKE_VERBOSE_MAKEFILE FALSE
|
set(CMAKE_VERBOSE_MAKEFILE FALSE
|
||||||
CACHE STRING "Verbose compile output switch")
|
CACHE STRING "Verbose compile output switch")
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_WARNING_OPTION}")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x ${CMAKE_CXX_WARNING_OPTION}")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -UULIB_SERIALIZATION_ON")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -UULIB_SERIALIZATION_ON")
|
||||||
|
|
||||||
# CTEST framework
|
#enable_testing()
|
||||||
enable_testing()
|
|
||||||
|
|
||||||
|
|
||||||
## FIND PACKAGES ------------------------------------------------------------ ##
|
## FIND PACKAGES ------------------------------------------------------------ ##
|
||||||
|
|
||||||
@@ -93,36 +79,8 @@ include(${EIGEN3_USE_FILE})
|
|||||||
find_package(ROOT CONFIG REQUIRED)
|
find_package(ROOT CONFIG REQUIRED)
|
||||||
include(${ROOT_USE_FILE})
|
include(${ROOT_USE_FILE})
|
||||||
|
|
||||||
find_package(VTK REQUIRED)
|
find_package(VTK CONFIG REQUIRED)
|
||||||
# include(${VTK_USE_FILE})
|
include(${VTK_USE_FILE})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
option(CENTOS_SUPPORT "VTK definitions for CentOS" OFF)
|
|
||||||
if(CENTOS_SUPPORT)
|
|
||||||
find_package(VTK CONFIG REQUIRED)
|
|
||||||
include(${VTK_USE_FILE})
|
|
||||||
else()
|
|
||||||
find_package(VTK REQUIRED
|
|
||||||
COMPONENTS CommonColor
|
|
||||||
CommonCore
|
|
||||||
FiltersCore
|
|
||||||
FiltersModeling
|
|
||||||
FiltersSources
|
|
||||||
IOLegacy
|
|
||||||
IOXML
|
|
||||||
IOXMLParser
|
|
||||||
ImagingCore
|
|
||||||
InteractionStyle
|
|
||||||
InteractionWidgets
|
|
||||||
RenderingAnnotation
|
|
||||||
RenderingContextOpenGL2
|
|
||||||
RenderingCore
|
|
||||||
RenderingFreeType
|
|
||||||
RenderingGL2PSOpenGL2
|
|
||||||
RenderingOpenGL2
|
|
||||||
RenderingVolumeOpenGL2)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_INCLUDES math.h)
|
set(CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_INCLUDES math.h)
|
||||||
set(CMAKE_REQUIRED_LIBRARIES CMAKE_REQUIRED_LIBRARIES m)
|
set(CMAKE_REQUIRED_LIBRARIES CMAKE_REQUIRED_LIBRARIES m)
|
||||||
@@ -161,7 +119,7 @@ configure_file("${PROJECT_SOURCE_DIR}/CMakeConfig.in.h"
|
|||||||
"${PROJECT_BINARY_DIR}/config.h")
|
"${PROJECT_BINARY_DIR}/config.h")
|
||||||
|
|
||||||
install(FILES "${PROJECT_BINARY_DIR}/config.h"
|
install(FILES "${PROJECT_BINARY_DIR}/config.h"
|
||||||
DESTINATION ${INSTALL_INC_DIR})
|
DESTINATION ${PACKAGE_INSTALL_INC_DIR})
|
||||||
|
|
||||||
## ADD LIBRARIES SUBDIRECTORIES --------------------------------------------- ##
|
## ADD LIBRARIES SUBDIRECTORIES --------------------------------------------- ##
|
||||||
|
|
||||||
@@ -206,8 +164,8 @@ add_subdirectory(${SRC_DIR}/Vtk)
|
|||||||
|
|
||||||
|
|
||||||
# Create the FooBarConfig.cmake and FooBarConfigVersion files
|
# Create the FooBarConfig.cmake and FooBarConfigVersion files
|
||||||
# file(RELATIVE_PATH REL_INCLUDE_DIR "${INSTALL_CMAKE_DIR}"
|
file(RELATIVE_PATH REL_INCLUDE_DIR "${PACKAGE_INSTALL_CMAKE_DIR}"
|
||||||
# "${INSTALL_INC_DIR}")
|
"${PACKAGE_INSTALL_INC_DIR}")
|
||||||
|
|
||||||
# ... for the build tree
|
# ... for the build tree
|
||||||
#set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/src" "${PROJECT_BINARY_DIR}")
|
#set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/src" "${PROJECT_BINARY_DIR}")
|
||||||
@@ -216,53 +174,21 @@ add_subdirectory(${SRC_DIR}/Vtk)
|
|||||||
|
|
||||||
# ... for the install tree
|
# ... for the install tree
|
||||||
set(CONF_INCLUDE_DIRS "\${ULIB_CMAKE_DIR}/${REL_INCLUDE_DIR}")
|
set(CONF_INCLUDE_DIRS "\${ULIB_CMAKE_DIR}/${REL_INCLUDE_DIR}")
|
||||||
# [ removed for the configure_config_file ]
|
configure_file(uLibConfig.cmake.in
|
||||||
# configure_file(uLibConfig.cmake.in
|
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/uLibConfig.cmake"
|
||||||
# "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/uLibConfig.cmake"
|
@ONLY)
|
||||||
# @ONLY)
|
|
||||||
|
|
||||||
# ... for both
|
# ... for both
|
||||||
configure_file(uLibConfigVersion.cmake.in
|
configure_file(uLibConfigVersion.cmake.in
|
||||||
"${PROJECT_BINARY_DIR}/uLibConfigVersion.cmake" @ONLY)
|
"${PROJECT_BINARY_DIR}/uLibConfigVersion.cmake" @ONLY)
|
||||||
|
|
||||||
|
install(FILES "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/uLibConfig.cmake"
|
||||||
# from CMake 3.x configure file shall be created using a dedicated function
|
|
||||||
# see: https://cmake.org/cmake/help/latest/module/CMakePackageConfigHelpers.html
|
|
||||||
#
|
|
||||||
include(CMakePackageConfigHelpers)
|
|
||||||
configure_package_config_file(uLibConfig.cmake.in
|
|
||||||
"${PROJECT_BINARY_DIR}/uLibConfig.cmake"
|
|
||||||
INSTALL_DESTINATION ${INSTALL_CMAKE_DIR}
|
|
||||||
PATH_VARS
|
|
||||||
INSTALL_LIB_DIR
|
|
||||||
INSTALL_INC_DIR
|
|
||||||
INSTALL_BIN_DIR
|
|
||||||
INSTALL_CMAKE_DIR
|
|
||||||
INSTALL_ETC_DIR
|
|
||||||
INSTALL_DATA_DIR
|
|
||||||
ULIB_SOURCE_DIR
|
|
||||||
ULIB_SHARED_LIBRARIES
|
|
||||||
# NO_SET_AND_CHECK_MACRO
|
|
||||||
# NO_CHECK_REQUIRED_COMPONENTS_MACRO
|
|
||||||
)
|
|
||||||
|
|
||||||
install(FILES "${PROJECT_BINARY_DIR}/uLibConfig.cmake"
|
|
||||||
"${PROJECT_BINARY_DIR}/uLibConfigVersion.cmake"
|
"${PROJECT_BINARY_DIR}/uLibConfigVersion.cmake"
|
||||||
DESTINATION "${INSTALL_CMAKE_DIR}"
|
DESTINATION "${PACKAGE_INSTALL_CMAKE_DIR}"
|
||||||
COMPONENT dev)
|
COMPONENT dev)
|
||||||
|
|
||||||
|
|
||||||
# this is a special target file for the build tree
|
|
||||||
# it is used also to identify if we are using a build direcory
|
|
||||||
# to link a project against uLib. see: uLibConfig.cmake ( IF )
|
|
||||||
export (TARGETS ${ULIB_SHARED_LIBRARIES}
|
|
||||||
FILE "${PROJECT_BINARY_DIR}/uLibTargets-build.cmake"
|
|
||||||
# NAMESPACE "uLib::"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Install the export set for use with the install-tree
|
# Install the export set for use with the install-tree
|
||||||
install(EXPORT "uLibTargets"
|
install(EXPORT "${PROJECT_NAME}Targets"
|
||||||
FILE "uLibTargets.cmake"
|
DESTINATION "${PACKAGE_INSTALL_CMAKE_DIR}"
|
||||||
DESTINATION "${INSTALL_CMAKE_DIR}"
|
|
||||||
COMPONENT dev)
|
COMPONENT dev)
|
||||||
|
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ target_link_libraries(${libname} ${LIBRARIES})
|
|||||||
|
|
||||||
install(TARGETS ${libname}
|
install(TARGETS ${libname}
|
||||||
EXPORT "${PROJECT_NAME}Targets"
|
EXPORT "${PROJECT_NAME}Targets"
|
||||||
RUNTIME DESTINATION ${INSTALL_BIN_DIR} COMPONENT bin
|
RUNTIME DESTINATION ${PACKAGE_INSTALL_BIN_DIR} COMPONENT bin
|
||||||
LIBRARY DESTINATION ${INSTALL_LIB_DIR} COMPONENT lib)
|
LIBRARY DESTINATION ${PACKAGE_INSTALL_LIB_DIR} COMPONENT lib)
|
||||||
|
|
||||||
install(FILES ${HEADERS} DESTINATION ${INSTALL_INC_DIR}/Core)
|
install(FILES ${HEADERS} DESTINATION ${PACKAGE_INSTALL_INC_DIR}/Core)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -31,9 +31,6 @@
|
|||||||
|
|
||||||
#include <boost/program_options.hpp>
|
#include <boost/program_options.hpp>
|
||||||
|
|
||||||
#include <boost/property_tree/ptree.hpp>
|
|
||||||
#include <boost/property_tree/ini_parser.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
//class boost::program_options::error_with_option_name;
|
//class boost::program_options::error_with_option_name;
|
||||||
//template<> boost::program_options::typed_value<int> boost::program_options::value<int>();
|
//template<> boost::program_options::typed_value<int> boost::program_options::value<int>();
|
||||||
@@ -77,23 +74,6 @@ void Options::parse_config_file(const char *fname)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Options::save_config_file(const char *fname) {
|
|
||||||
std::ofstream os;
|
|
||||||
os.open(fname);
|
|
||||||
|
|
||||||
using boost::property_tree::ptree;
|
|
||||||
|
|
||||||
ptree root;
|
|
||||||
|
|
||||||
|
|
||||||
std::cout << m_configuration << "\n";
|
|
||||||
std::cout << m_global << "\n";
|
|
||||||
|
|
||||||
write_ini( std::cout, root );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Options::count(const char *str) const
|
bool Options::count(const char *str) const
|
||||||
{
|
{
|
||||||
return (m_vm.count(str));
|
return (m_vm.count(str));
|
||||||
|
|||||||
@@ -160,8 +160,6 @@ public:
|
|||||||
|
|
||||||
void parse_config_file(const char *fname);
|
void parse_config_file(const char *fname);
|
||||||
|
|
||||||
void save_config_file(const char *fname);
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static inline boost::program_options::typed_value<T>* value(T *v, T dvalue) {
|
static inline boost::program_options::typed_value<T>* value(T *v, T dvalue) {
|
||||||
boost::program_options::typed_value<T> *r = boost::program_options::value<T>(v);
|
boost::program_options::typed_value<T> *r = boost::program_options::value<T>(v);
|
||||||
|
|||||||
@@ -2,6 +2,5 @@ set(HEADERS MuonScatter.h MuonError.h MuonEvent.h)
|
|||||||
|
|
||||||
set(ULIB_SELECTED_MODULES ${ULIB_SELECTED_MODULES} Detectors PARENT_SCOPE)
|
set(ULIB_SELECTED_MODULES ${ULIB_SELECTED_MODULES} Detectors PARENT_SCOPE)
|
||||||
|
|
||||||
|
|
||||||
install(FILES ${HEADERS}
|
install(FILES ${HEADERS}
|
||||||
DESTINATION ${INSTALL_INC_DIR}/Detectors)
|
DESTINATION ${PACKAGE_INSTALL_INC_DIR}/Detectors)
|
||||||
|
|||||||
@@ -27,8 +27,6 @@
|
|||||||
#ifndef U_MATH_BITCODE_H
|
#ifndef U_MATH_BITCODE_H
|
||||||
#define U_MATH_BITCODE_H
|
#define U_MATH_BITCODE_H
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include <boost/static_assert.hpp>
|
#include <boost/static_assert.hpp>
|
||||||
#include <boost/type_traits.hpp>
|
#include <boost/type_traits.hpp>
|
||||||
#include <boost/mpl/vector_c.hpp>
|
#include <boost/mpl/vector_c.hpp>
|
||||||
@@ -36,7 +34,6 @@
|
|||||||
|
|
||||||
#include <Math/Dense.h>
|
#include <Math/Dense.h>
|
||||||
|
|
||||||
|
|
||||||
namespace uLib {
|
namespace uLib {
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
set(HEADERS ContainerBox.h
|
set(HEADERS ContainerBox.h
|
||||||
Dense.h
|
Dense.h
|
||||||
Geometry.h
|
Geometry.h
|
||||||
@@ -33,8 +32,7 @@ set(SOURCES VoxRaytracer.cpp
|
|||||||
Structured4DGrid.cpp)
|
Structured4DGrid.cpp)
|
||||||
|
|
||||||
set(LIBRARIES ${Eigen_LIBRARY}
|
set(LIBRARIES ${Eigen_LIBRARY}
|
||||||
${ROOT_LIBRARIES}
|
${ROOT_LIBRARIES})
|
||||||
${VTK_LIBRARIES})
|
|
||||||
|
|
||||||
set(libname ${PACKAGE_LIBPREFIX}Math)
|
set(libname ${PACKAGE_LIBPREFIX}Math)
|
||||||
set(ULIB_SHARED_LIBRARIES ${ULIB_SHARED_LIBRARIES} ${libname} PARENT_SCOPE)
|
set(ULIB_SHARED_LIBRARIES ${ULIB_SHARED_LIBRARIES} ${libname} PARENT_SCOPE)
|
||||||
@@ -46,15 +44,10 @@ set_target_properties(${libname} PROPERTIES
|
|||||||
SOVERSION ${PROJECT_SOVERSION})
|
SOVERSION ${PROJECT_SOVERSION})
|
||||||
target_link_libraries(${libname} ${LIBRARIES})
|
target_link_libraries(${libname} ${LIBRARIES})
|
||||||
|
|
||||||
|
|
||||||
install(TARGETS ${libname}
|
install(TARGETS ${libname}
|
||||||
EXPORT "${PROJECT_NAME}Targets"
|
EXPORT "${PROJECT_NAME}Targets"
|
||||||
RUNTIME DESTINATION ${INSTALL_BIN_DIR} COMPONENT bin
|
RUNTIME DESTINATION ${PACKAGE_INSTALL_BIN_DIR} COMPONENT bin
|
||||||
LIBRARY DESTINATION ${INSTALL_LIB_DIR} COMPONENT lib)
|
LIBRARY DESTINATION ${PACKAGE_INSTALL_LIB_DIR} COMPONENT lib)
|
||||||
|
|
||||||
install(FILES ${HEADERS} DESTINATION ${INSTALL_INC_DIR}/Math)
|
install(FILES ${HEADERS} DESTINATION ${PACKAGE_INSTALL_INC_DIR}/Math)
|
||||||
|
|
||||||
# TESTING
|
|
||||||
# include(uLibTargetMacros)
|
|
||||||
# add_subdirectory(testing)
|
|
||||||
|
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ typedef Eigen::Vector4f Vector4f;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Vector String interaction ///////////////////////////////////////////////////
|
// Vector String interaction ///////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -110,17 +110,6 @@ public:
|
|||||||
|
|
||||||
inline void Rotate(const Matrix3f &m) { this->m_T.rotate(m); }
|
inline void Rotate(const Matrix3f &m) { this->m_T.rotate(m); }
|
||||||
|
|
||||||
inline void Rotate(const float angle, Vector3f axis)
|
|
||||||
{
|
|
||||||
axis.normalize(); // prehaps not necessary ( see eigens )
|
|
||||||
Eigen::AngleAxisf ax(angle,axis);
|
|
||||||
this->m_T.rotate(Eigen::Quaternion<float>(ax));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Rotate(const Vector3f euler_axis) {
|
|
||||||
float angle = euler_axis.norm();
|
|
||||||
Rotate(angle,euler_axis);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void PreRotate(const Matrix3f &m) { this->m_T.prerotate(m); }
|
inline void PreRotate(const Matrix3f &m) { this->m_T.prerotate(m); }
|
||||||
|
|
||||||
|
|||||||
@@ -30,13 +30,6 @@
|
|||||||
|
|
||||||
#include "VoxImage.h"
|
#include "VoxImage.h"
|
||||||
|
|
||||||
#include <vtkSmartPointer.h>
|
|
||||||
#include <vtkImageData.h>
|
|
||||||
#include <vtkXMLImageDataReader.h>
|
|
||||||
#include <vtkXMLImageDataWriter.h>
|
|
||||||
#include <vtkStringArray.h>
|
|
||||||
#include <vtkInformation.h>
|
|
||||||
#include <vtkInformationStringKey.h>
|
|
||||||
|
|
||||||
namespace uLib {
|
namespace uLib {
|
||||||
|
|
||||||
@@ -90,103 +83,7 @@ void Abstract::VoxImage::ExportToVtk (const char *file, bool density_type)
|
|||||||
printf("%s vtk file saved\n",file);
|
printf("%s vtk file saved\n",file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Abstract::VoxImage::ImportFromVtk(const char *file)
|
||||||
|
|
||||||
void Abstract::VoxImage::ExportToVti (const char *file, bool density_type, bool compressed)
|
|
||||||
{
|
|
||||||
Abstract::VoxImage *voxels = this;
|
|
||||||
|
|
||||||
vtkSmartPointer<vtkImageData> image = vtkSmartPointer<vtkImageData>::New();
|
|
||||||
image->SetDimensions(voxels->GetDims()(0), voxels->GetDims()(1), voxels->GetDims()(2));
|
|
||||||
image->SetSpacing(voxels->GetSpacing()(0), voxels->GetSpacing()(1), voxels->GetSpacing()(2));
|
|
||||||
image->SetOrigin(voxels->GetPosition()(0), voxels->GetPosition()(1), voxels->GetPosition()(2));
|
|
||||||
image->AllocateScalars(VTK_FLOAT, 1);
|
|
||||||
|
|
||||||
float norm;
|
|
||||||
if (density_type) {
|
|
||||||
norm = 1;
|
|
||||||
} else norm = 1.E6;
|
|
||||||
|
|
||||||
int nx = voxels->GetDims()(0);
|
|
||||||
int ny = voxels->GetDims()(1);
|
|
||||||
int nz = voxels->GetDims()(2);
|
|
||||||
|
|
||||||
size_t npoints = nx*ny*nz;
|
|
||||||
float *scalar = static_cast<float*>(image->GetScalarPointer());
|
|
||||||
|
|
||||||
StructuredData unwrap(*voxels);
|
|
||||||
unwrap.SetDataOrder(StructuredData::XYZ); // move to XYZ order (VTK)
|
|
||||||
for (size_t i = 0; i < npoints; i++) {
|
|
||||||
Vector3i idx = unwrap.UnMap(i);
|
|
||||||
scalar[i] = static_cast<float>(voxels->GetValue(idx) * norm);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a custom string key
|
|
||||||
static vtkInformationStringKey* ConfigNote =
|
|
||||||
vtkInformationStringKey::MakeKey("cmt.config", "Config");
|
|
||||||
|
|
||||||
// Attach metadata
|
|
||||||
vtkInformation *info = image->GetInformation();
|
|
||||||
info->Set(ConfigNote,
|
|
||||||
|
|
||||||
"This image was generated with uLib\n"
|
|
||||||
"-----------------------------------\n"
|
|
||||||
"Author: Andrea Rigoni\n"
|
|
||||||
"Version: 0.1\n"
|
|
||||||
"Date: 2025\n"
|
|
||||||
|
|
||||||
);
|
|
||||||
|
|
||||||
// std::cout << info->Get(ConfigNote) << std::endl;
|
|
||||||
vtkSmartPointer<vtkXMLImageDataWriter> writer = vtkSmartPointer<vtkXMLImageDataWriter>::New();
|
|
||||||
writer->SetFileName(file);
|
|
||||||
writer->SetInputData(image);
|
|
||||||
if(compressed) {
|
|
||||||
writer->SetDataModeToBinary();
|
|
||||||
writer->SetCompressorTypeToZLib();
|
|
||||||
}
|
|
||||||
writer->Write();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int Abstract::VoxImage::ImportFromVti(const char *file, bool density_type) {
|
|
||||||
|
|
||||||
vtkSmartPointer<vtkXMLImageDataReader> reader = vtkSmartPointer<vtkXMLImageDataReader>::New();
|
|
||||||
reader->SetFileName(file);
|
|
||||||
reader->Update();
|
|
||||||
vtkImageData *image = reader->GetOutput();
|
|
||||||
if(!image) return false;
|
|
||||||
|
|
||||||
Abstract::VoxImage *voxels = this;
|
|
||||||
int nx = image->GetDimensions()[0];
|
|
||||||
int ny = image->GetDimensions()[1];
|
|
||||||
int nz = image->GetDimensions()[2];
|
|
||||||
|
|
||||||
voxels->SetDims(Vector3i(nx,ny,nz));
|
|
||||||
voxels->SetSpacing(Vector3f(image->GetSpacing()[0],image->GetSpacing()[1],image->GetSpacing()[2]));
|
|
||||||
voxels->SetPosition(Vector3f(image->GetOrigin()[0],image->GetOrigin()[1],image->GetOrigin()[2]));
|
|
||||||
|
|
||||||
float norm;
|
|
||||||
if (density_type) {
|
|
||||||
norm = 1;
|
|
||||||
} else norm = 1.E6;
|
|
||||||
|
|
||||||
size_t npoints = nx*ny*nz;
|
|
||||||
float *scalar = static_cast<float*>(image->GetScalarPointer());
|
|
||||||
|
|
||||||
StructuredData wrap(*voxels);
|
|
||||||
wrap.SetDataOrder(StructuredData::XYZ);
|
|
||||||
for (size_t i = 0; i < npoints; i++) {
|
|
||||||
Vector3i idx = wrap.UnMap(i);
|
|
||||||
voxels->SetValue(idx, scalar[i] / norm);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int Abstract::VoxImage::ImportFromVtk(const char *file, bool density_type)
|
|
||||||
{
|
{
|
||||||
FILE * vtk_file = fopen(file, "r");
|
FILE * vtk_file = fopen(file, "r");
|
||||||
if (!vtk_file) return false;
|
if (!vtk_file) return false;
|
||||||
@@ -218,18 +115,14 @@ int Abstract::VoxImage::ImportFromVtk(const char *file, bool density_type)
|
|||||||
this->SetSpacing(Vector3f(sx,sy,sz));
|
this->SetSpacing(Vector3f(sx,sy,sz));
|
||||||
this->SetPosition(Vector3f(ox,oy,oz));
|
this->SetPosition(Vector3f(ox,oy,oz));
|
||||||
|
|
||||||
float norm;
|
|
||||||
if (density_type) {
|
|
||||||
norm = 1;
|
|
||||||
} else norm = 1.E6;
|
|
||||||
|
|
||||||
for (int k = 0; k < dz; ++k) {
|
for (int k = 0; k < dz; ++k) {
|
||||||
for (int j = 0; j < dy; ++j) {
|
for (int j = 0; j < dy; ++j) {
|
||||||
for (int i = 0; i < dx; ++i) {
|
for (int i = 0; i < dx; ++i) {
|
||||||
Vector3i idx(i, j, k);
|
Vector3i idx(i, j, k);
|
||||||
float tmp_val;
|
float tmp_val;
|
||||||
fscanf(vtk_file, "%f", &tmp_val);
|
fscanf(vtk_file, "%f", &tmp_val);
|
||||||
this->SetValue(idx,tmp_val / norm);
|
//this->SetValue(idx,fabs(tmp_val)*1E-6);
|
||||||
|
this->SetValue(idx,tmp_val*1E-6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,18 +56,8 @@ public:
|
|||||||
virtual void SetDims(const Vector3i &size) = 0;
|
virtual void SetDims(const Vector3i &size) = 0;
|
||||||
|
|
||||||
void ExportToVtk(const char *file, bool density_type = 0);
|
void ExportToVtk(const char *file, bool density_type = 0);
|
||||||
|
|
||||||
// use this function to export to VTK binary format
|
|
||||||
void ExportToVti (const char *file, bool density_type = 0, bool compressed = 0);
|
|
||||||
|
|
||||||
// this function has been deprecated in favor of ExportToVti
|
|
||||||
// but it is kept for backward compatibility and because it
|
|
||||||
// does not depend on vtk library
|
|
||||||
void ExportToVtkXml(const char *file, bool density_type = 0);
|
void ExportToVtkXml(const char *file, bool density_type = 0);
|
||||||
|
int ImportFromVtk(const char *file);
|
||||||
int ImportFromVtk(const char *file, bool density_type = 0);
|
|
||||||
|
|
||||||
int ImportFromVti(const char *file, bool density_type = 0);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|||||||
@@ -25,12 +25,11 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
#include "VoxRaytracer.h"
|
#include "VoxRaytracer.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
#define unlikely(expr) __builtin_expect(!!(expr), 0)
|
|
||||||
|
|
||||||
inline float fast_sign(float f) { return 1 - 2 * (f < 0); }
|
inline float fast_sign(float f) { return 1 - 2 * (f < 0); }
|
||||||
|
|
||||||
namespace uLib {
|
namespace uLib {
|
||||||
@@ -49,16 +48,17 @@ void VoxRaytracer::RayData::AddElement(Id_t id, float L)
|
|||||||
|
|
||||||
void VoxRaytracer::RayData::AppendRay(const VoxRaytracer::RayData &in)
|
void VoxRaytracer::RayData::AppendRay(const VoxRaytracer::RayData &in)
|
||||||
{
|
{
|
||||||
if (unlikely(!in.m_Data.size())) {
|
if (!in.m_Data.size())
|
||||||
|
{
|
||||||
std::cout << "Warinig: PoCA on exit border!\n";
|
std::cout << "Warinig: PoCA on exit border!\n";
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
else if (unlikely(!m_Data.size())) {
|
else if (!m_Data.size())
|
||||||
|
{
|
||||||
m_Data = in.m_Data;
|
m_Data = in.m_Data;
|
||||||
std::cout << "Warinig: PoCA on entrance border!\n";
|
std::cout << "Warinig: PoCA on entrance border!\n";
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
// Opzione 1) un voxel in piu' //
|
// Opzione 1) un voxel in piu' //
|
||||||
m_Data.reserve(m_Data.size() + in.m_Data.size());
|
m_Data.reserve(m_Data.size() + in.m_Data.size());
|
||||||
m_Data.insert(m_Data.end(), in.m_Data.begin(), in.m_Data.end());
|
m_Data.insert(m_Data.end(), in.m_Data.begin(), in.m_Data.end());
|
||||||
@@ -82,16 +82,22 @@ void VoxRaytracer::RayData::AppendRay(const VoxRaytracer::RayData &in)
|
|||||||
void VoxRaytracer::RayData::PrintSelf(std::ostream &o)
|
void VoxRaytracer::RayData::PrintSelf(std::ostream &o)
|
||||||
{
|
{
|
||||||
o << "Ray: total lenght " << m_TotalLength << "\n";
|
o << "Ray: total lenght " << m_TotalLength << "\n";
|
||||||
std::vector<Element>::iterator it;
|
for(std::vector<Element>::iterator it = m_Data.begin(); it < m_Data.end(); ++it)
|
||||||
for(it = m_Data.begin(); it < m_Data.end(); ++it)
|
{
|
||||||
o << "[ " << (*it).vox_id << ", " << (*it).L << "] \n";
|
o << "[ " << (*it).vox_id << ", " << (*it).L << "] \n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//// RAY TRACER ////////////////////////////////////////////////////////////////
|
//// RAY TRACER ////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
VoxRaytracer::VoxRaytracer(StructuredGrid &image) : m_Image(&image)
|
||||||
|
{
|
||||||
|
m_scale << (m_Image->GetWorldMatrix() * Vector4f(1,0,0,0)).norm(),
|
||||||
|
(m_Image->GetWorldMatrix() * Vector4f(0,1,0,0)).norm(),
|
||||||
|
(m_Image->GetWorldMatrix() * Vector4f(0,0,1,0)).norm();
|
||||||
|
}
|
||||||
|
|
||||||
bool VoxRaytracer::GetEntryPoint(const HLine3f &line, HPoint3f &pt)
|
bool VoxRaytracer::GetEntryPoint(const HLine3f &line, HPoint3f &pt)
|
||||||
{
|
{
|
||||||
@@ -150,9 +156,7 @@ bool VoxRaytracer::GetExitPoint(const HLine3f &line, HPoint3f &pt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VoxRaytracer::RayData VoxRaytracer::TraceBetweenPoints(const HPoint3f &in,
|
VoxRaytracer::RayData VoxRaytracer::TraceBetweenPoints(const HPoint3f &in, const HPoint3f &out) const
|
||||||
const HPoint3f &out)
|
|
||||||
const
|
|
||||||
{
|
{
|
||||||
RayData ray;
|
RayData ray;
|
||||||
Vector4f pt1 = m_Image->GetLocalPoint(in);
|
Vector4f pt1 = m_Image->GetLocalPoint(in);
|
||||||
@@ -162,53 +166,138 @@ const
|
|||||||
float l = s.head(3).norm();
|
float l = s.head(3).norm();
|
||||||
Vector3f L(l/s(0), l/s(1), l/s(2));
|
Vector3f L(l/s(0), l/s(1), l/s(2));
|
||||||
|
|
||||||
// Vector3f scale; // FIXXX
|
|
||||||
// scale << (m_Image->GetWorldMatrix() * Vector4f(1,0,0,0)).norm(),
|
|
||||||
// (m_Image->GetWorldMatrix() * Vector4f(0,1,0,0)).norm(),
|
|
||||||
// (m_Image->GetWorldMatrix() * Vector4f(0,0,1,0)).norm();
|
|
||||||
|
|
||||||
Vector3f offset;
|
Vector3f offset;
|
||||||
for(int i=0;i<3;++i) offset(i) = (s(i)>=0) - (pt1(i)-floor(pt1(i))) ;
|
for(int i=0;i<3;++i)
|
||||||
|
{
|
||||||
|
offset(i) = (s(i)>=0) - (pt1(i)-floor(pt1(i)));
|
||||||
|
}
|
||||||
offset = offset.cwiseProduct(L).cwiseAbs();
|
offset = offset.cwiseProduct(L).cwiseAbs();
|
||||||
L = L.cwiseAbs();
|
L = L.cwiseAbs();
|
||||||
|
|
||||||
//---- Check if the ray only crosses one voxel
|
//---- Check if the ray only crosses one voxel
|
||||||
Vector3i vid = m_Image->Find(in);
|
Vector3i vid = m_Image->Find(in);
|
||||||
if(vid == m_Image->Find(out)){
|
if (vid == m_Image->Find(out))
|
||||||
ray.AddElement(m_Image->Map(vid),s.norm());
|
{
|
||||||
return ray;
|
ray.AddElement(m_Image->Map(vid),s.norm());
|
||||||
|
return ray;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---- Otherwise, loop until ray is finished
|
//---- Otherwise, loop until ray is finished
|
||||||
int id; float d;
|
int id; float d;
|
||||||
while(l>0){
|
while (l>0)
|
||||||
|
{
|
||||||
|
d = offset.minCoeff(&id);
|
||||||
|
|
||||||
d = offset.minCoeff(&id);
|
if (m_Image->IsInsideGrid(vid))
|
||||||
|
{
|
||||||
|
ray.AddElement(m_Image->Map(vid), d * m_scale(id));
|
||||||
|
}
|
||||||
|
|
||||||
if(m_Image->IsInsideGrid(vid)){
|
vid(id) += (int)fast_sign(s(id));
|
||||||
ray.AddElement(m_Image->Map(vid), d * m_scale(id) );
|
|
||||||
}
|
|
||||||
|
|
||||||
// nan check //
|
l -= d;
|
||||||
// if(unlikely(!isFinite(d * scale(id)))) {
|
offset.array() -= d;
|
||||||
// std:: cout << "NAN in raytracer\n";
|
offset(id) = fmin(L(id),l);
|
||||||
// exit(1);
|
|
||||||
// }
|
|
||||||
|
|
||||||
vid(id) += (int)fast_sign(s(id));
|
|
||||||
|
|
||||||
l -= d;
|
|
||||||
offset.array() -= d;
|
|
||||||
offset(id) = fmin(L(id),l);
|
|
||||||
}
|
}
|
||||||
return ray;
|
return ray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int encode_v(Vector3i in)
|
||||||
|
{
|
||||||
|
return ((in[0] + 1) << 4) + ((in[1] + 1) << 2) + in[2] + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Vector3i decode_v(int in)
|
||||||
|
{
|
||||||
|
Vector3i result {
|
||||||
|
((in & 48) >> 4) - 1,
|
||||||
|
((in & 12) >> 2) - 1,
|
||||||
|
(in & 3) - 1
|
||||||
|
};
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
VoxRaytracer::RayData VoxRaytracer::BeamBetweenPoints(const HPoint3f &in, const HPoint3f &out, Vector3i thickness) const
|
||||||
|
{
|
||||||
|
if (thickness[0] < 0) thickness[0] = 0;
|
||||||
|
if (thickness[1] < 0) thickness[1] = 0;
|
||||||
|
if (thickness[2] < 0) thickness[2] = 0;
|
||||||
|
|
||||||
|
Vector3i zero_v { 0, 0, 0 };
|
||||||
|
|
||||||
|
RayData ray = TraceBetweenPoints(in, out);
|
||||||
|
if (thickness == zero_v || ray.Data().size() == 0) return ray;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Calculate the forbidden relocations
|
||||||
|
*/
|
||||||
|
|
||||||
|
std::unordered_map<int, int> ban_points(26);
|
||||||
|
|
||||||
|
Vector3i prevPos = m_Image->UnMap(ray.Data()[0].vox_id);
|
||||||
|
Vector3i currDir = zero_v;
|
||||||
|
int currLen = 1;
|
||||||
|
|
||||||
|
for (int k = 1; k < ray.Data().size(); k++)
|
||||||
|
{
|
||||||
|
Vector3i currPos = m_Image->UnMap(ray.Data()[k].vox_id);
|
||||||
|
Vector3i offset = currPos - prevPos;
|
||||||
|
prevPos = currPos;
|
||||||
|
|
||||||
|
if (k == 1) currDir = offset;
|
||||||
|
|
||||||
|
if (offset == currDir)
|
||||||
|
{
|
||||||
|
currLen++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int enc_v = encode_v(currDir);
|
||||||
|
if (ban_points.find(enc_v) == ban_points.end())
|
||||||
|
{
|
||||||
|
ban_points.emplace(enc_v, currLen);
|
||||||
|
}
|
||||||
|
else if (currLen > ban_points[enc_v])
|
||||||
|
{
|
||||||
|
ban_points[enc_v] = currLen;
|
||||||
|
}
|
||||||
|
|
||||||
|
currDir = offset;
|
||||||
|
currLen = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Calculate the beam section
|
||||||
|
*/
|
||||||
|
std::vector<Vector3i> relocs;
|
||||||
|
relocs.push_back(zero_v);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Compose the beam
|
||||||
|
*/
|
||||||
|
RayData beam;
|
||||||
|
for (auto iter : ray.Data())
|
||||||
|
{
|
||||||
|
Vector3i rPos = m_Image->UnMap(iter.vox_id);
|
||||||
|
|
||||||
|
for (Vector3i reloc : relocs)
|
||||||
|
{
|
||||||
|
Vector3i cPos = rPos + reloc;
|
||||||
|
if (!m_Image->IsInsideGrid(cPos)) continue;
|
||||||
|
|
||||||
|
beam.AddElement(m_Image->Map(cPos), iter.L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return beam;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 20150528 SV for absorbed muons
|
// 20150528 SV for absorbed muons
|
||||||
VoxRaytracer::RayData VoxRaytracer::TraceLine(const HLine3f &line) const
|
VoxRaytracer::RayData VoxRaytracer::TraceLine(const HLine3f &line) const
|
||||||
{
|
{
|
||||||
RayData ray;
|
RayData ray;
|
||||||
|
|
||||||
Vector4f pt = m_Image->GetLocalPoint(line.origin);
|
Vector4f pt = m_Image->GetLocalPoint(line.origin);
|
||||||
Vector4f s = m_Image->GetLocalPoint(line.direction);
|
Vector4f s = m_Image->GetLocalPoint(line.direction);
|
||||||
|
|
||||||
@@ -250,4 +339,4 @@ VoxRaytracer::RayData VoxRaytracer::TraceLine(const HLine3f &line) const
|
|||||||
return ray;
|
return ray;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} //end of namespace uLib
|
||||||
|
|||||||
@@ -38,7 +38,8 @@ namespace uLib {
|
|||||||
class VoxRaytracer {
|
class VoxRaytracer {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class RayData {
|
class RayData
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
RayData() : m_TotalLength(0) {}
|
RayData() : m_TotalLength(0) {}
|
||||||
|
|
||||||
@@ -62,14 +63,8 @@ public:
|
|||||||
Scalarf m_TotalLength;
|
Scalarf m_TotalLength;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
public:
|
VoxRaytracer(StructuredGrid &image);
|
||||||
VoxRaytracer(StructuredGrid &image) : m_Image(&image) {
|
|
||||||
m_scale <<
|
|
||||||
(m_Image->GetWorldMatrix() * Vector4f(1,0,0,0)).norm(),
|
|
||||||
(m_Image->GetWorldMatrix() * Vector4f(0,1,0,0)).norm(),
|
|
||||||
(m_Image->GetWorldMatrix() * Vector4f(0,0,1,0)).norm();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GetEntryPoint(const HLine3f &line, HPoint3f &pt);
|
bool GetEntryPoint(const HLine3f &line, HPoint3f &pt);
|
||||||
|
|
||||||
@@ -77,6 +72,8 @@ public:
|
|||||||
|
|
||||||
RayData TraceBetweenPoints(const HPoint3f &in, const HPoint3f &out) const;
|
RayData TraceBetweenPoints(const HPoint3f &in, const HPoint3f &out) const;
|
||||||
|
|
||||||
|
RayData BeamBetweenPoints(const HPoint3f &in, const HPoint3f &out, Vector3i thickness) const;
|
||||||
|
|
||||||
RayData TraceLine(const HLine3f &line) const;
|
RayData TraceLine(const HLine3f &line) const;
|
||||||
|
|
||||||
inline StructuredGrid* GetImage() const { return this->m_Image; }
|
inline StructuredGrid* GetImage() const { return this->m_Image; }
|
||||||
|
|||||||
@@ -19,4 +19,4 @@ set(LIBRARIES
|
|||||||
${PACKAGE_LIBPREFIX}Math
|
${PACKAGE_LIBPREFIX}Math
|
||||||
)
|
)
|
||||||
|
|
||||||
uLib_add_tests(Math)
|
uLib_add_tests(${uLib-module})
|
||||||
|
|||||||
@@ -92,20 +92,6 @@ int main() {
|
|||||||
imgR.ExportToVtk("./read_and_saved.vtk");
|
imgR.ExportToVtk("./read_and_saved.vtk");
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
VoxImage<TestVoxel> img(Vector3i(4,4,4));
|
|
||||||
img.InitVoxels({0,0});
|
|
||||||
for (int i=0; i<4; i++) {
|
|
||||||
for (int j=0; j<4; j++) {
|
|
||||||
for (int k=0; k<4; k++) {
|
|
||||||
img[Vector3i(i,j,k)] = {i+j+k,0};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
img.ExportToVti("./vti_saved.vti",0,1);
|
|
||||||
// img.ImportFromVtkXml("./test_vox_image.vti");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
VoxImage<TestVoxel> img1(Vector3i(5,5,5));
|
VoxImage<TestVoxel> img1(Vector3i(5,5,5));
|
||||||
|
|||||||
@@ -1,49 +1,12 @@
|
|||||||
set(HEADERS RootMathDense.h
|
set(HEADERS RootMathDense.h
|
||||||
RootMuonScatter.h
|
RootMuonScatter.h
|
||||||
RootHitRaw.h
|
RootHitRaw.h)
|
||||||
muCastorMCTrack.h
|
|
||||||
muCastorHit.h
|
|
||||||
muCastorInfo.h
|
|
||||||
muCastorSkinHit.h
|
|
||||||
muCastorPrimaryVertex.h
|
|
||||||
muCastorMuDetDIGI.h
|
|
||||||
SkinDetectorWriter.h)
|
|
||||||
|
|
||||||
set(SOURCES ${HEADERS} RootMuonScatter.cpp
|
set(SOURCES ${HEADERS} RootMuonScatter.cpp)
|
||||||
muCastorMCTrack.cpp
|
|
||||||
muCastorHit.cpp
|
|
||||||
muCastorInfo.cpp
|
|
||||||
muCastorSkinHit.cpp
|
|
||||||
muCastorPrimaryVertex.cpp
|
|
||||||
muCastorMuDetDIGI.cpp
|
|
||||||
SkinDetectorWriter.cpp)
|
|
||||||
|
|
||||||
set(DICTIONARY_HEADERS muCastorMCTrack.h
|
|
||||||
muCastorHit.h
|
|
||||||
muCastorInfo.h
|
|
||||||
muCastorSkinHit.h
|
|
||||||
muCastorPrimaryVertex.h
|
|
||||||
muCastorMuDetDIGI.h
|
|
||||||
SkinDetectorWriter.h)
|
|
||||||
|
|
||||||
set(LIBRARIES ${ROOT_LIBRARIES}
|
set(LIBRARIES ${ROOT_LIBRARIES}
|
||||||
${PACKAGE_LIBPREFIX}Math)
|
${PACKAGE_LIBPREFIX}Math)
|
||||||
|
|
||||||
set(rDictName ${PACKAGE_LIBPREFIX}RootDict)
|
|
||||||
root_generate_dictionary(${rDictName} ${DICTIONARY_HEADERS}
|
|
||||||
LINKDEF Linkdef.h)
|
|
||||||
set_source_files_properties(${rDictName}.cxx
|
|
||||||
PROPERTIES GENERATED TRUE)
|
|
||||||
set_source_files_properties(${rDictName}.h
|
|
||||||
PROPERTIES GENERATED TRUE)
|
|
||||||
list(APPEND SOURCES ${rDictName}.cxx)
|
|
||||||
|
|
||||||
# TODO use a custom target linked to root_generate_dictionary
|
|
||||||
set(R_ARTIFACTS ${CMAKE_CURRENT_BINARY_DIR}/lib${rDictName}_rdict.pcm
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/lib${rDictName}.rootmap)
|
|
||||||
install(FILES ${R_ARTIFACTS}
|
|
||||||
DESTINATION ${INSTALL_LIB_DIR})
|
|
||||||
|
|
||||||
set(libname ${PACKAGE_LIBPREFIX}Root)
|
set(libname ${PACKAGE_LIBPREFIX}Root)
|
||||||
set(ULIB_SHARED_LIBRARIES ${ULIB_SHARED_LIBRARIES} ${libname} PARENT_SCOPE)
|
set(ULIB_SHARED_LIBRARIES ${ULIB_SHARED_LIBRARIES} ${libname} PARENT_SCOPE)
|
||||||
set(ULIB_SELECTED_MODULES ${ULIB_SELECTED_MODULES} Root PARENT_SCOPE)
|
set(ULIB_SELECTED_MODULES ${ULIB_SELECTED_MODULES} Root PARENT_SCOPE)
|
||||||
@@ -51,15 +14,14 @@ set(ULIB_SELECTED_MODULES ${ULIB_SELECTED_MODULES} Root PARENT_SCOPE)
|
|||||||
add_library(${libname} SHARED ${SOURCES})
|
add_library(${libname} SHARED ${SOURCES})
|
||||||
set_target_properties(${libname} PROPERTIES
|
set_target_properties(${libname} PROPERTIES
|
||||||
VERSION ${PROJECT_VERSION}
|
VERSION ${PROJECT_VERSION}
|
||||||
SOVERSION ${PROJECT_SOVERSION}
|
SOVERSION ${PROJECT_SOVERSION})
|
||||||
CXX_STANDARD 17)
|
|
||||||
target_link_libraries(${libname} ${LIBRARIES})
|
target_link_libraries(${libname} ${LIBRARIES})
|
||||||
|
|
||||||
install(TARGETS ${libname}
|
install(TARGETS ${libname}
|
||||||
EXPORT "${PROJECT_NAME}Targets"
|
EXPORT "${PROJECT_NAME}Targets"
|
||||||
RUNTIME DESTINATION ${INSTALL_BIN_DIR} COMPONENT bin
|
RUNTIME DESTINATION ${PACKAGE_INSTALL_BIN_DIR} COMPONENT bin
|
||||||
LIBRARY DESTINATION ${INSTALL_LIB_DIR} COMPONENT lib)
|
LIBRARY DESTINATION ${PACKAGE_INSTALL_LIB_DIR} COMPONENT lib)
|
||||||
|
|
||||||
install(FILES ${HEADERS} DESTINATION ${INSTALL_INC_DIR}/Root)
|
install(FILES ${HEADERS} DESTINATION ${PACKAGE_INSTALL_INC_DIR}/Root)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -74,13 +74,11 @@ using namespace ROOT::Mutom;
|
|||||||
#pragma link C++ function HitRaw::Tdc() const;
|
#pragma link C++ function HitRaw::Tdc() const;
|
||||||
#pragma link C++ function HitRaw::Ch() const;
|
#pragma link C++ function HitRaw::Ch() const;
|
||||||
|
|
||||||
|
#pragma link C++ class muBlastMCTrack+;
|
||||||
|
#pragma link C++ class muBlastHit+;
|
||||||
#pragma link C++ class muCastorMCTrack+;
|
#pragma link C++ class muCastorMCTrack+;
|
||||||
#pragma link C++ class muCastorHit+;
|
#pragma link C++ class muCastorHit+;
|
||||||
#pragma link C++ class muCastorInfo+;
|
#pragma link C++ class muCastorInfo+;
|
||||||
#pragma link C++ class muCastorSkinHit+;
|
|
||||||
#pragma link C++ class muCastorPrimaryVertex+;
|
|
||||||
#pragma link C++ class muCastorMuDetDIGI+;
|
|
||||||
#pragma link C++ class SkinDetectorWriter+;
|
|
||||||
|
|
||||||
#endif // __CINT__
|
#endif // __CINT__
|
||||||
|
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
#include "SkinDetectorWriter.h"
|
|
||||||
#include "muCastorSkinHit.h"
|
|
||||||
#include "TVector3.h"
|
|
||||||
|
|
||||||
SkinDetectorWriter::SkinDetectorWriter(string filename) :
|
|
||||||
t_file(nullptr),
|
|
||||||
t_tree(nullptr),
|
|
||||||
t_buffer(nullptr),
|
|
||||||
i_status(0)
|
|
||||||
{
|
|
||||||
t_file = new TFile(filename.c_str(), "RECREATE");
|
|
||||||
t_tree = new TTree("muCastorMC", "muCastorMC");
|
|
||||||
t_buffer = new TClonesArray("muCastorSkinHit");
|
|
||||||
|
|
||||||
t_tree->Branch("CastorSkinHits", "TClonesArray", t_buffer, 32000, 99);
|
|
||||||
|
|
||||||
if (t_file->IsZombie()) i_status = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
SkinDetectorWriter::~SkinDetectorWriter()
|
|
||||||
{}
|
|
||||||
|
|
||||||
void SkinDetectorWriter::add(int detID, float p_x, float p_y, float p_z,
|
|
||||||
float m_x, float m_y, float m_z)
|
|
||||||
{
|
|
||||||
TClonesArray& ref = *t_buffer;
|
|
||||||
int size = ref.GetEntriesFast();
|
|
||||||
|
|
||||||
muCastorSkinHit* new_hit = new(ref[size]) muCastorSkinHit();
|
|
||||||
new_hit->SetDetID(detID);
|
|
||||||
new_hit->SetPdgCode(13);
|
|
||||||
new_hit->SetMotherID(-1);
|
|
||||||
new_hit->SetPos (TVector3(p_x, p_y, p_z));
|
|
||||||
new_hit->SetMom (TVector3(m_x, m_y, m_z));
|
|
||||||
}
|
|
||||||
|
|
||||||
void SkinDetectorWriter::write()
|
|
||||||
{
|
|
||||||
if (t_tree->Fill() < 0) i_status = 2;
|
|
||||||
t_buffer->Delete(); // or t_buffer->Clear() ??
|
|
||||||
}
|
|
||||||
|
|
||||||
void SkinDetectorWriter::close()
|
|
||||||
{
|
|
||||||
if (t_tree->Write() == 0) i_status = 3;
|
|
||||||
t_file->Close();
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#ifndef SkinDetectorWriter_h
|
|
||||||
#define SkinDetectorWriter_h
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "TFile.h"
|
|
||||||
#include "TTree.h"
|
|
||||||
#include "TClonesArray.h"
|
|
||||||
|
|
||||||
using std::string;
|
|
||||||
|
|
||||||
class SkinDetectorWriter
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SkinDetectorWriter(string filename);
|
|
||||||
virtual ~SkinDetectorWriter();
|
|
||||||
|
|
||||||
void add(int detID, float p_x, float p_y, float p_z, float m_x, float m_y, float m_z);
|
|
||||||
int status() { return i_status; }
|
|
||||||
void write();
|
|
||||||
void close();
|
|
||||||
|
|
||||||
private:
|
|
||||||
TFile* t_file;
|
|
||||||
TTree* t_tree;
|
|
||||||
TClonesArray* t_buffer;
|
|
||||||
int i_status;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif //SkinDetectorWriter_h
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
/// \file muCastorMuDetDIGI.cxx
|
|
||||||
/// \brief Implementation of the muCastorMuDetDIGI class
|
|
||||||
// This class build the DIGI for the scintillator detectors
|
|
||||||
/// \author G. Bonomi, M. Subieta - INFN
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include "muCastorMuDetDIGI.h"
|
|
||||||
|
|
||||||
/// \cond CLASSIMP
|
|
||||||
ClassImp(muCastorMuDetDIGI)
|
|
||||||
/// \endcond
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
//_____________________________________________________________________________
|
|
||||||
muCastorMuDetDIGI::muCastorMuDetDIGI() :
|
|
||||||
fDetID(-1),
|
|
||||||
fLayID(-1),
|
|
||||||
fTubID(-1),
|
|
||||||
fDistMC(0.),
|
|
||||||
fDriftMC(0.),
|
|
||||||
fDist(0.),
|
|
||||||
fDrift(0.),
|
|
||||||
fEnergy(0.)
|
|
||||||
{}
|
|
||||||
|
|
||||||
//_____________________________________________________________________________
|
|
||||||
muCastorMuDetDIGI::~muCastorMuDetDIGI()
|
|
||||||
{}
|
|
||||||
|
|
||||||
//_____________________________________________________________________________
|
|
||||||
void muCastorMuDetDIGI::Print(const Option_t* /*opt*/) const
|
|
||||||
{
|
|
||||||
cout << " DetID: " << fDetID
|
|
||||||
<< " LayID: " << fLayID
|
|
||||||
<< " TubID: " << fTubID
|
|
||||||
<< " energy deposit (keV): " << fEnergy
|
|
||||||
<< endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
#ifndef muCastor_MuDetDIGI_H
|
|
||||||
#define muCastor_MuDetDIGI_H
|
|
||||||
|
|
||||||
/// \file muCastorMuDetDIGI.h
|
|
||||||
/// \brief Definition of the muCastorMuDetDIGI class
|
|
||||||
///
|
|
||||||
/// \authors G. Bonomi, M. Subieta - INFN
|
|
||||||
|
|
||||||
#include <TObject.h>
|
|
||||||
|
|
||||||
class muCastorMuDetDIGI : public TObject
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
muCastorMuDetDIGI();
|
|
||||||
virtual ~muCastorMuDetDIGI();
|
|
||||||
|
|
||||||
// -------> PUBLIC FUNCTIONS
|
|
||||||
virtual void Print(const Option_t* option = "") const;
|
|
||||||
|
|
||||||
// -------> SET METHODS
|
|
||||||
|
|
||||||
/// Set Det ID (Detector module)
|
|
||||||
void SetDetID(Int_t id) { fDetID = id; };
|
|
||||||
|
|
||||||
/// Set Layer ID (Layer [0,5])
|
|
||||||
void SetLayID(Int_t id) { fLayID = id; };
|
|
||||||
|
|
||||||
/// Set Tube ID (Tube inside each layer)
|
|
||||||
void SetTubID(Int_t id) { fTubID = id; };
|
|
||||||
|
|
||||||
void SetDistMC (Double_t v) { fDistMC = v; };
|
|
||||||
void SetDriftMC (Double_t v) { fDriftMC= v; };
|
|
||||||
void SetDist (Double_t v) { fDist = v; };
|
|
||||||
void SetDrift (Double_t v) { fDrift = v; };
|
|
||||||
|
|
||||||
// Set energy
|
|
||||||
void SetEnergy(Double_t e) { fEnergy = e; };
|
|
||||||
|
|
||||||
// -------> GET METHODS
|
|
||||||
|
|
||||||
/// \return The Module number
|
|
||||||
Int_t GetDetID() { return fDetID; };
|
|
||||||
|
|
||||||
/// \return The Layer number
|
|
||||||
Int_t GetLayID() { return fLayID; };
|
|
||||||
|
|
||||||
/// \return The Tube number
|
|
||||||
Int_t GetTubID() { return fTubID; };
|
|
||||||
|
|
||||||
Double_t GetDistMC() { return fDistMC; };
|
|
||||||
Double_t GetDriftMC() { return fDriftMC; };
|
|
||||||
Double_t GetDist() { return fDist; };
|
|
||||||
Double_t GetDrift() { return fDrift; };
|
|
||||||
|
|
||||||
/// \return Get energy
|
|
||||||
Double_t GetEnergy() { return fEnergy; };
|
|
||||||
|
|
||||||
|
|
||||||
// -------> PRIVATE VARIABLES
|
|
||||||
private:
|
|
||||||
Int_t fDetID; // Detector module ID
|
|
||||||
Int_t fLayID; // Detector layer ID
|
|
||||||
Int_t fTubID; // Layer tube ID
|
|
||||||
Double_t fDistMC; // Minimum distance of particle tracks to the wire
|
|
||||||
Double_t fDriftMC; // Minimum drift time to the wire
|
|
||||||
Double_t fDist; // Minimum distance of particle tracks to the wire (with smearing)
|
|
||||||
Double_t fDrift; // Minimum drift time to the wire (with smearing)
|
|
||||||
Double_t fEnergy; // Energy released in the element
|
|
||||||
|
|
||||||
ClassDef(muCastorMuDetDIGI,1) //muCastorMuDetDIGI
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //muCastorMuDetDIGI_H
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
#include <iostream>
|
|
||||||
#include <limits>
|
|
||||||
|
|
||||||
#include "muCastorPrimaryVertex.h"
|
|
||||||
|
|
||||||
/// \cond CLASSIMP
|
|
||||||
ClassImp(muCastorPrimaryVertex)
|
|
||||||
/// \endcond
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
//_____________________________________________________________________________
|
|
||||||
muCastorPrimaryVertex::muCastorPrimaryVertex() {
|
|
||||||
/// Default constructor
|
|
||||||
Reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
//_____________________________________________________________________________
|
|
||||||
muCastorPrimaryVertex::~muCastorPrimaryVertex()
|
|
||||||
{
|
|
||||||
/// Destructor
|
|
||||||
}
|
|
||||||
|
|
||||||
//_____________________________________________________________________________
|
|
||||||
void muCastorPrimaryVertex::Reset()
|
|
||||||
{
|
|
||||||
fPdgCode = 0;
|
|
||||||
fVx = std::numeric_limits<double>::quiet_NaN();
|
|
||||||
fVy = std::numeric_limits<double>::quiet_NaN();
|
|
||||||
fVz = std::numeric_limits<double>::quiet_NaN();
|
|
||||||
fPx = std::numeric_limits<double>::quiet_NaN();
|
|
||||||
fPy = std::numeric_limits<double>::quiet_NaN();
|
|
||||||
fPz = std::numeric_limits<double>::quiet_NaN();
|
|
||||||
fE = std::numeric_limits<double>::quiet_NaN();
|
|
||||||
}
|
|
||||||
|
|
||||||
//_____________________________________________________________________________
|
|
||||||
void muCastorPrimaryVertex::Print(const Option_t* /*opt*/) const
|
|
||||||
{
|
|
||||||
/// Printing
|
|
||||||
|
|
||||||
cout << " Primary particle PDG Code " << fPdgCode << endl;
|
|
||||||
cout << " Vertex: (" << fVx << ", " << fVy << ", " << fVz << ") cm" << endl;
|
|
||||||
cout << " Mom: (" << fPx << ", " << fPy << ", " << fPz << ") MeV/c" << endl;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
#ifndef muCastor_PVTX_H
|
|
||||||
#define muCastor_PVTX_H
|
|
||||||
|
|
||||||
/// \brief Definition of the muCastorPrimaryVertex class
|
|
||||||
///
|
|
||||||
/// \authors G. Bonomi (04/02/2020)
|
|
||||||
|
|
||||||
#include <TObject.h>
|
|
||||||
|
|
||||||
class muCastorPrimaryVertex : public TObject
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
muCastorPrimaryVertex();
|
|
||||||
virtual ~muCastorPrimaryVertex();
|
|
||||||
|
|
||||||
// -------> PUBLIC FUNCTIONS
|
|
||||||
virtual void Print(const Option_t* option = "") const;
|
|
||||||
|
|
||||||
// -------> SET METHODS
|
|
||||||
|
|
||||||
void SetPdgCode(Int_t code) { fPdgCode = code; };
|
|
||||||
|
|
||||||
void SetVx(Double_t Vx) { fVx = Vx; };
|
|
||||||
void SetVy(Double_t Vy) { fVy = Vy; };
|
|
||||||
void SetVz(Double_t Vz) { fVz = Vz; };
|
|
||||||
|
|
||||||
void SetPx(Double_t Px) { fPx = Px; };
|
|
||||||
void SetPy(Double_t Py) { fPy = Py; };
|
|
||||||
void SetPz(Double_t Pz) { fPz = Pz; };
|
|
||||||
|
|
||||||
void SetE(Double_t E) { fE = E; };
|
|
||||||
|
|
||||||
void Reset();
|
|
||||||
private:
|
|
||||||
// -------> PRIVATE VARIABLES
|
|
||||||
Int_t fPdgCode; // PDG code of the particle
|
|
||||||
|
|
||||||
Double_t fVx; // x of production vertex
|
|
||||||
Double_t fVy; // y of production vertex
|
|
||||||
Double_t fVz; // z of production vertex
|
|
||||||
|
|
||||||
Double_t fPx; // x component of momentum
|
|
||||||
Double_t fPy; // y component of momentum
|
|
||||||
Double_t fPz; // z component of momentum
|
|
||||||
Double_t fE; // Energy
|
|
||||||
|
|
||||||
|
|
||||||
ClassDef(muCastorPrimaryVertex,1) //muCastorPrimaryVertex
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //muCastor_PVTX_H
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
//----------------------------------------------------------
|
|
||||||
// Class : CastorSkinHit
|
|
||||||
// Date: October 2020
|
|
||||||
// Author: Germano Bonomi germano.bonomi@unibs.it
|
|
||||||
//----------------------------------------------------------
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include "muCastorSkinHit.h"
|
|
||||||
|
|
||||||
/// \cond CLASSIMP
|
|
||||||
ClassImp(muCastorSkinHit)
|
|
||||||
/// \endcond
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
//_____________________________________________________________________________
|
|
||||||
muCastorSkinHit::muCastorSkinHit() :
|
|
||||||
fDetID(-1),
|
|
||||||
fPdgCode(-1),
|
|
||||||
fMotherID(-1),
|
|
||||||
fMomX(0.),
|
|
||||||
fMomY(0.),
|
|
||||||
fMomZ(0.),
|
|
||||||
fPosX(0.),
|
|
||||||
fPosY(0.),
|
|
||||||
fPosZ(0.)
|
|
||||||
{}
|
|
||||||
|
|
||||||
//_____________________________________________________________________________
|
|
||||||
muCastorSkinHit::~muCastorSkinHit()
|
|
||||||
{}
|
|
||||||
//_____________________________________________________________________________
|
|
||||||
void muCastorSkinHit::Print(const Option_t* /*opt*/) const
|
|
||||||
{
|
|
||||||
cout << " detID: " << fDetID
|
|
||||||
<< " position (cm): ("
|
|
||||||
<< fPosX << ", " << fPosY << ", " << fPosZ << ")"
|
|
||||||
<< " momentum (MeV/c): ("
|
|
||||||
<< fMomX << ", " << fMomY << ", " << fMomZ << ")"
|
|
||||||
<< endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
//----------------------------------------------------------
|
|
||||||
// Class : CastorSkinHit
|
|
||||||
// Date: October 2020
|
|
||||||
// Author: Germano Bonomi germano.bonomi@unibs.it
|
|
||||||
//----------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef muCastor_SKINHIT_H
|
|
||||||
#define muCastor_SKINHIT_H
|
|
||||||
|
|
||||||
|
|
||||||
#include <TObject.h>
|
|
||||||
#include <TVector3.h>
|
|
||||||
|
|
||||||
class muCastorSkinHit : public TObject
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
muCastorSkinHit();
|
|
||||||
virtual ~muCastorSkinHit();
|
|
||||||
|
|
||||||
// methods
|
|
||||||
virtual void Print(const Option_t* option = "") const;
|
|
||||||
|
|
||||||
// set methods
|
|
||||||
void SetDetID(Int_t id) { fDetID = id; };
|
|
||||||
void SetPdgCode(Int_t pdg) { fPdgCode = pdg; };
|
|
||||||
void SetMotherID(Int_t mid) { fMotherID = mid; };
|
|
||||||
void SetMom(TVector3 xyz) { fMomX = xyz.X(); fMomY = xyz.Y(); fMomZ = xyz.Z(); };
|
|
||||||
void SetPos(TVector3 xyz) { fPosX = xyz.X(); fPosY = xyz.Y(); fPosZ = xyz.Z(); };
|
|
||||||
|
|
||||||
Int_t GetDetID() { return fDetID; }
|
|
||||||
Int_t GetPdgCode() { return fPdgCode; }
|
|
||||||
Int_t GetMotherID() { return fMotherID; }
|
|
||||||
TVector3 GetMom() { return TVector3(fMomX, fMomY, fMomZ); }
|
|
||||||
TVector3 GetPos() { return TVector3(fPosX, fPosY, fPosZ); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
Int_t fDetID; // Detector module ID
|
|
||||||
Int_t fPdgCode; // Particle PDG Code
|
|
||||||
Int_t fMotherID; // Particle mother ID (-1 = primary, 0 = secondary, etc..)
|
|
||||||
Double_t fMomX; // Track momentum when releasing the hit (X)
|
|
||||||
Double_t fMomY; // Track momentum when releasing the hit (Y)
|
|
||||||
Double_t fMomZ; // Track momentum when releasing the hit (Z)
|
|
||||||
Double_t fPosX; // Hit coordinates (at the entrance of the detector) (X)
|
|
||||||
Double_t fPosY; // Hit coordinates (at the entrance of the detector) (Y)
|
|
||||||
Double_t fPosZ; // Hit coordinates (at the entrance of the detector) (Z)
|
|
||||||
|
|
||||||
ClassDef(muCastorSkinHit,1) //muCastorSkinHit
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //muCastort_SKINHIT_H
|
|
||||||
|
|
||||||
|
|
||||||
@@ -31,8 +31,8 @@ target_link_libraries(${libname} ${LIBRARIES})
|
|||||||
|
|
||||||
install(TARGETS ${libname}
|
install(TARGETS ${libname}
|
||||||
EXPORT "${PROJECT_NAME}Targets"
|
EXPORT "${PROJECT_NAME}Targets"
|
||||||
RUNTIME DESTINATION ${INSTALL_BIN_DIR} COMPONENT bin
|
RUNTIME DESTINATION ${PACKAGE_INSTALL_BIN_DIR} COMPONENT bin
|
||||||
LIBRARY DESTINATION ${INSTALL_LIB_DIR} COMPONENT lib)
|
LIBRARY DESTINATION ${PACKAGE_INSTALL_LIB_DIR} COMPONENT lib)
|
||||||
|
|
||||||
install(FILES ${HEADERS} DESTINATION ${INSTALL_INC_DIR}/Vtk)
|
install(FILES ${HEADERS} DESTINATION ${PACKAGE_INSTALL_INC_DIR}/Vtk)
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,6 @@ vtkContainerBox::~vtkContainerBox()
|
|||||||
vtkPolyData *vtkContainerBox::GetPolyData() const
|
vtkPolyData *vtkContainerBox::GetPolyData() const
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void vtkContainerBox::InstallPipe()
|
void vtkContainerBox::InstallPipe()
|
||||||
|
|||||||
@@ -1,92 +1,15 @@
|
|||||||
# - Config file for the ULib package
|
# - Config file for the FooBar package
|
||||||
# It defines the following variables
|
# It defines the following variables
|
||||||
# ULIB_INCLUDE_DIRS - include directories for ULib
|
# FOOBAR_INCLUDE_DIRS - include directories for FooBar
|
||||||
# ULIB_LIBRARIES - libraries to link against
|
# FOOBAR_LIBRARIES - libraries to link against
|
||||||
# ULIB_EXECUTABLE - the bar executable
|
# FOOBAR_EXECUTABLE - the bar executable
|
||||||
|
|
||||||
|
|
||||||
set(ULIB_VERSION @PROJECT_VERSION@)
|
|
||||||
|
|
||||||
@PACKAGE_INIT@
|
|
||||||
|
|
||||||
# Defines the include directories for the header files
|
|
||||||
# PACKAGE_INCLUDE_INSTALL_DIR is replaced by configure_package_config_file
|
|
||||||
# with the correct path for the installation.
|
|
||||||
set(ULIB_INCLUDE_DIRS "${PACKAGE_INCLUDE_INSTALL_DIR}")
|
|
||||||
|
|
||||||
|
# Compute paths
|
||||||
get_filename_component(ULIB_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
get_filename_component(ULIB_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||||
|
set(ULIB_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@")
|
||||||
|
|
||||||
# Search for the directory of exported build targets
|
# Our library dependencies (contains definitions for IMPORTED targets)
|
||||||
set(uLib_BUILD_TARGETS_FILE
|
include("${ULIB_CMAKE_DIR}/uLibTargets.cmake")
|
||||||
"${ULIB_CMAKE_DIR}/uLibTargets-build.cmake"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Search for the directory of installed targets
|
|
||||||
set(uLib_INSTALL_TARGETS_FILE
|
|
||||||
"${ULIB_CMAKE_DIR}/uLibTargets.cmake"
|
|
||||||
)
|
|
||||||
|
|
||||||
# We use a logic based on the presence of the build target file
|
|
||||||
# to determine if we are in a local build.
|
|
||||||
if(EXISTS "${uLib_BUILD_TARGETS_FILE}")
|
|
||||||
message(STATUS " ++ Using uLib build targets")
|
|
||||||
|
|
||||||
include("${uLib_BUILD_TARGETS_FILE}")
|
|
||||||
set_and_check(ULIB_INCLUDE_DIRS "@ULIB_SOURCE_DIR@/src")
|
|
||||||
set_and_check(ULIB_LIBRARY_DIRS "${ULIB_CMAKE_DIR}")
|
|
||||||
set(ULIB_BUILD_DIR ${ULIB_CMAKE_DIR})
|
|
||||||
|
|
||||||
# Target that builds uLib inside its build directory
|
|
||||||
add_custom_target(uLib_dependency_target
|
|
||||||
COMMAND echo " --------------------------------- "
|
|
||||||
COMMAND echo " - Building uLib as a dependency - "
|
|
||||||
COMMAND echo " --------------------------------- "
|
|
||||||
COMMAND echo ""
|
|
||||||
COMMAND ${CMAKE_COMMAND} --build ${ULIB_BUILD_DIR}
|
|
||||||
COMMAND echo ""
|
|
||||||
WORKING_DIRECTORY ${ULIB_BUILD_DIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
add_library(uLib_dependency INTERFACE)
|
|
||||||
add_dependencies(uLib_dependency uLib_dependency_target)
|
|
||||||
link_libraries(uLib_dependency)
|
|
||||||
|
|
||||||
else()
|
|
||||||
message(STATUS " ++ Using uLib installed targets")
|
|
||||||
|
|
||||||
include("${uLib_INSTALL_TARGETS_FILE}")
|
|
||||||
set_and_check(ULIB_INCLUDE_DIRS "@PACKAGE_INSTALL_INC_DIR@")
|
|
||||||
set(ULIB_SYSCONFIG_DIR "@PACKAGE_INSTALL_ETC_DIR@")
|
|
||||||
set_and_check(ULIB_CMAKE_DIR "@PACKAGE_INSTALL_CMAKE_DIR@")
|
|
||||||
set_and_check(ULIB_LIBRARY_DIRS "@PACKAGE_INSTALL_LIB_DIR@")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# --- Add required packages from uLib ---
|
|
||||||
# TODO: this should be selected if components are active
|
|
||||||
#
|
|
||||||
set(Boost_USE_STATIC_LIBS OFF)
|
|
||||||
set(Boost_USE_MULTITHREADED ON)
|
|
||||||
set(Boost_USE_STATIC_RUNTIME OFF)
|
|
||||||
find_package(Boost 1.45.0 COMPONENTS program_options filesystem REQUIRED)
|
|
||||||
include_directories(${Boost_INCLUDE_DIRS})
|
|
||||||
link_libraries(${Boost_LIBRARIES})
|
|
||||||
|
|
||||||
find_package(Eigen3 CONFIG REQUIRED)
|
|
||||||
include(${EIGEN3_USE_FILE})
|
|
||||||
|
|
||||||
find_package(ROOT CONFIG REQUIRED)
|
|
||||||
include(${ROOT_USE_FILE})
|
|
||||||
|
|
||||||
find_package(VTK REQUIRED)
|
|
||||||
# include(${VTK_USE_FILE})
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
link_directories("${ULIB_LIBRARY_DIRS}")
|
|
||||||
set(ULIB_LIBRARIES "@ULIB_SHARED_LIBRARIES@")
|
|
||||||
check_required_components(uLib)
|
|
||||||
|
|
||||||
# Set the variable to indicate that the package has been found.
|
|
||||||
set(uLib_FOUND TRUE)
|
|
||||||
|
|
||||||
|
|
||||||
|
# These are IMPORTED targets created by FooBarTargets.cmake
|
||||||
|
set(ULIB_LIBRARIES @ULIB_SHARED_LIBRARIES@)
|
||||||
|
|||||||
Reference in New Issue
Block a user