-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This builds an external application against Kassiopeia libraries.
- Loading branch information
Showing
3 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Makefile | ||
build.ninja | ||
/ks-particles-example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
cmake_minimum_required(VERSION 3.0) | ||
|
||
# Name your project | ||
project(Kassiopeia-Examples) | ||
|
||
message("CMake prefix path: ${CMAKE_PREFIX_PATH}") | ||
|
||
find_package(Boost REQUIRED COMPONENTS filesystem) | ||
find_package(VTK) | ||
if(VTK_FOUND) | ||
include(${VTK_USE_FILE}) | ||
endif(VTK_FOUND) | ||
|
||
# Don't forget to set CMAKE_PREFIX_PATH to your Kasper installation folder | ||
# before executing cmake. That way, CMake will be able to find the KaLi installation. | ||
find_package(Kassiopeia REQUIRED) | ||
find_package(KEMField REQUIRED) | ||
find_package(KGeoBag REQUIRED) | ||
|
||
# Set the default install prefix (you don't need to remember this) | ||
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) | ||
get_filename_component(BUILD_PARENT_DIR ${CMAKE_BINARY_DIR} PATH) | ||
set(CMAKE_INSTALL_PREFIX "${BUILD_PARENT_DIR}/install" CACHE PATH "Install path prefix, prepended onto install directories." FORCE) | ||
endif() | ||
|
||
set( CMAKE_CXX_STANDARD 14 ) | ||
set( CMAKE_CXX_STANDARD_REQUIRED ON ) | ||
set( CMAKE_CXX_EXTENSIONS OFF ) | ||
|
||
# Define your include directories | ||
include_directories ( | ||
${Kassiopeia_INCLUDE_DIRS} | ||
${KEMField_INCLUDE_DIRS} | ||
${KGeoBag_INCLUDE_DIRS} | ||
) | ||
|
||
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) | ||
|
||
#---------------------------------------- | ||
# Build libraries and ROOT dictionaries | ||
#---------------------------------------- | ||
|
||
# not needed for this example | ||
|
||
#---------------------------------------- | ||
# Build the executable | ||
#---------------------------------------- | ||
|
||
set( EXECUTABLES | ||
ks-particles-example | ||
) | ||
|
||
foreach(EXECUTABLE ${EXECUTABLES}) | ||
add_executable(${EXECUTABLE} ${EXECUTABLE}.cxx) | ||
target_link_libraries (${EXECUTABLE} ${Kassiopeia_LIBRARIES}) | ||
endforeach() | ||
|
||
# Define a cmake install target | ||
install(TARGETS ${EXECUTABLES} DESTINATION ${CMAKE_INSTALL_PREFIX}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* @file ks-particles.cxx | ||
* | ||
* @date 22.07.2020 | ||
* @author Jan Behrens <[email protected]> | ||
*/ | ||
|
||
// Kasper Common includes | ||
#include <KException.h> | ||
#include <KLogger.h> | ||
#include <KMessage.h> | ||
|
||
// Kassiopeia includes | ||
#include <KSMainMessage.h> | ||
#include <KSParticle.h> | ||
#include <KSParticleFactory.h> | ||
|
||
KLOGGER("kassiopeia.examples"); | ||
|
||
using namespace katrin; | ||
using namespace Kassiopeia; | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
// set message verbosity | ||
KMessageTable::GetInstance().SetTerminalVerbosity(eDebug); | ||
KMessageTable::GetInstance().SetLogVerbosity(eDebug); | ||
|
||
// create an instance of the particle factory | ||
KSParticleFactory& tFactory = KSParticleFactory::GetInstance(); | ||
|
||
// generate particles and print information | ||
for (int i = 1; i < argc; i++) { | ||
KSParticle *tParticle; | ||
|
||
mainmsg(eNormal) << "Creating a particle with id: " << argv[i] << eom; | ||
|
||
try { | ||
try { | ||
// try using a numeric particle id | ||
long tPID = std::stol(argv[i]); | ||
tParticle = tFactory.Create(tPID); | ||
} | ||
catch (std::invalid_argument) { | ||
// if it fails, try to use a string id | ||
std::string tStringID(argv[i]); | ||
tParticle = tFactory.StringCreate(tStringID); | ||
} | ||
} | ||
catch (KException) { | ||
continue; | ||
} | ||
|
||
tParticle->Print(); | ||
|
||
delete tParticle; | ||
} | ||
|
||
return 0; | ||
} |