Commit 8ae1e154 authored by David Blyth's avatar David Blyth

Initial commit

parents
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
project(EICTrack VERSION 0.1.0)
set(CMAKE_CXX_STANDARD 11)
# ---------------------------------------------------------------------------
# set default install prefix and build type
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT FALSE)
set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "..." FORCE)
endif()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "..." FORCE)
endif()
#----------------------------------------------------------------------------
# Find Libraries
find_path(GENFIT_INCLUDE_DIR NAMES ProlateSpacepointMeasurement.h)
if(NOT GENFIT_INCLUDE_DIR)
message(FATAL_ERROR "GenFit headers not found!")
endif()
include_directories(${GENFIT_INCLUDE_DIR})
find_library(GENFIT_LIBRARY NAMES genfit2)
if(NOT GENFIT_LIBRARY)
message(FATAL_ERROR "GenFit was not found!")
endif()
get_filename_component(GENFIT_LIBRARY_DIR ${GENFIT_LIBRARY} DIRECTORY)
link_directories(${GENFIT_LIBRARY_DIR})
find_package(proio 0.10.0 REQUIRED)
include_directories(${proio_INCLUDE_DIR})
find_package(ROOT 6 REQUIRED)
find_package(Eigen3 REQUIRED)
include_directories(${EIGEN3_INCLUDE_DIRS})
#-----------------------------------------------------------------------------------
file(GLOB SRCS
${CMAKE_CURRENT_SOURCE_DIR}/src/EICTrack.cc
${CMAKE_CURRENT_SOURCE_DIR}/src/bfields/*.cc
)
file(GLOB HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/src/EICTrack.h
)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
add_executable(eictrack ${SRCS} ${HEADERS})
target_link_libraries(eictrack
${GENFIT_LIBRARY}
proio proio.pb
${ROOT_LIBRARIES} ROOT::Geom
${EIGEN3_LIBRARIES}
)
install(TARGETS eictrack
EXPORT ${PROJECT_NAME}Targets
DESTINATION bin
)
#----------------------------------------------------------------------------
# Install and export targets
install(EXPORT ${PROJECT_NAME}Targets
FILE ${PROJECT_NAME}Targets.cmake
DESTINATION lib/${PROJECT_NAME}
)
include(CMakePackageConfigHelpers)
set(TARGETS_INSTALL_PATH lib/${PROJECT_NAME}/${PROJECT_NAME}Targets.cmake)
CONFIGURE_PACKAGE_CONFIG_FILE(
cmake/${PROJECT_NAME}Config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
INSTALL_DESTINATION lib/${PROJECT_NAME}
PATH_VARS TARGETS_INSTALL_PATH
)
write_basic_package_version_file("${PROJECT_NAME}ConfigVersion.cmake"
VERSION ${${PROJECT_NAME}_VERSION}
COMPATIBILITY SameMajorVersion
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION lib/${PROJECT_NAME}
)
@PACKAGE_INIT@
include("@PACKAGE_TARGETS_INSTALL_PATH@")
check_required_components(${CMAKE_FIND_PACKAGE_NAME})
This diff is collapsed.
#ifndef CTRACK_GLOBALS_HH
#define CTRACK_GLOBALS_HH
#include <map>
#include <string>
#include <AbsBField.h>
namespace eictrack {
class BFieldFactory {
public:
virtual genfit::AbsBField *Create(double *params) = 0;
};
class BField {
public:
static void RegisterType(const std::string &name, BFieldFactory *factory) { factories[name] = factory; }
static genfit::AbsBField *Create(std::string name, double *params) {
if (factories.count(name))
return factories[name]->Create(params);
else
return NULL;
}
static std::vector<std::string> AvailableTypes() {
std::vector<std::string> types;
for (auto nameFactPair : factories) {
types.push_back(nameFactPair.first);
}
return types;
}
private:
static std::map<std::string, BFieldFactory *> factories;
};
} // namespace eictrack
#define BFIELD_TYPE(klass) \
namespace eictrack { \
class klass##Factory : public BFieldFactory { \
public: \
klass##Factory() { BField::RegisterType(#klass, this); } \
genfit::AbsBField *Create(double *params) { return new klass(params); } \
}; \
static klass##Factory global_##klass##Factory; \
}
#endif // CTRACK_GLOBALS_HH
#include <iostream>
#include "EICTrack.h"
namespace eictrack {
class TOPSiDE : public genfit::AbsBField {
public:
TOPSiDE(double *params) {
_params[0] = params[0] * 10;
_params[1] = params[1] / 10;
_params[2] = params[2] / 10;
_params[3] = params[3] / 10;
_params[4] = params[4] * 10;
_params[5] = params[5] / 10;
_params[6] = params[6] / 10;
_params[7] = params[7] / 10;
}
TVector3 get(const TVector3 &pos) const {
double b[3];
memset(b, 0, 3 * sizeof(double));
get(pos[0], pos[1], pos[2], b[0], b[1], b[2]);
return TVector3(b);
}
void get(const double &posX, const double &posY, const double &posZ, double &Bx, double &By,
double &Bz) const {
double z = posZ;
double r = sqrt(posX * posX + posY * posY);
if (r < _params[3] && z > _params[1] && z < _params[2]) Bz += _params[0];
if (r < _params[7] && z > _params[5] && z < _params[6]) Bx += _params[4];
}
private:
double _params[8];
};
} // namespace eictrack
BFIELD_TYPE(TOPSiDE)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment