Skip to content
Snippets Groups Projects
Commit 9e671a62 authored by Whitney Armstrong's avatar Whitney Armstrong
Browse files

Adding skeleton helper library.

- This library should be added to and expanded.
parent ac9a9359
Branches
Tags
1 merge request!20Resolve "Helper library"
Pipeline #8262 passed
......@@ -4,7 +4,6 @@ project(EICD
LANGUAGES CXX)
#--- Declare options -----------------------------------------------------------
option(CREATE_DOC "Whether or not to create doxygen doc target.")
option(BUILD_DATA_MODEL "Run podio class generator yaml file" ON)
if(APPLE)
......@@ -12,8 +11,6 @@ if(APPLE)
endif(APPLE)
#set(PODIO $ENV{PODIO})
#set(CMAKE_MODULE_PATH ${PODIO}/lib/cmake/podio)
find_package(podio 0.11.0 REQUIRED)
include_directories(${podio_INCLUDE_DIR})
......@@ -50,6 +47,9 @@ PODIO_GENERATE_DICTIONARY(eicd ${headers}
set_target_properties(eicd-dictgen PROPERTIES EXCLUDE_FROM_ALL TRUE)
target_sources(eicd PRIVATE eicd.cxx)
add_subdirectory(source)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/eicd
DESTINATION include
FILES_MATCHING PATTERN *.h
......@@ -74,6 +74,8 @@ add_custom_target( doc_doxygen #ALL
COMMENT "Generating API documentation with Doxygen"
VERBATIM )
# -------------------------
# install library config
include(CMakePackageConfigHelpers)
......
find_package(ROOT REQUIRED COMPONENTS GenVector MathCore)
#ROOT_GENERATE_DICTIONARY(G__NPDetGeoCad
# include/TGeoToStep.h
# OPTIONS -I${OpenCASCADE_INCLUDE_DIR}
# OPTIONS -I${CMAKE_CURRENT_SOURCE_DIR}
# OPTIONS -I${CMAKE_CURRENT_SOURCE_DIR}/include
# OPTIONS -I${CMAKE_CURRENT_SOURCE_DIR}/src
# LINKDEF include/LinkDef.h
# )
#add_custom_target(G__NPDetGeoCad_ROOTDICT DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/G__NPDetGeoCad.cxx)
add_library(eicd_core SHARED
src/helpers.cxx
)
target_compile_features(eicd_core
PUBLIC cxx_auto_type
PUBLIC cxx_trailing_return_types
PUBLIC cxx_std_17
PRIVATE cxx_variadic_templates
)
target_compile_options(eicd_core PRIVATE
-Wno-extra
-Wno-ignored-qualifiers
-Wno-overloaded-virtual
-Wno-shadow)
target_link_libraries(eicd_core
PUBLIC eicd
PUBLIC ROOT::GenVector ROOT::MathCore)
target_include_directories(eicd_core
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PUBLIC $<INSTALL_INTERFACE:include>
)
install(FILES
include/eicd/helpers.h
DESTINATION include/eicd
)
#install(FILES
# "${CMAKE_CURRENT_BINARY_DIR}/libNPDetGeoCad.rootmap"
# "${CMAKE_CURRENT_BINARY_DIR}/libNPDetGeoCad_rdict.pcm"
# DESTINATION lib)
install(TARGETS eicd_core
EXPORT ${PROJECT_NAME}Targets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)
#ifndef EICD_HELPERS_HH
#define EICD_HELPERS_HH
#include <algorithm>
#include <cmath>
#include <exception>
#include <limits>
#include <string>
#include <vector>
#include <Math/Vector4D.h>
#include "eicd/TrackParametersCollection.h"
#include "eicd/ReconstructedParticleCollection.h"
#include "eicd/ReconstructedParticleData.h"
namespace eicd::helpers {
/** Four momentum from track and mass.
* Get a vector of 4-momenta from raw tracking info, using an externally
* provided particle mass assumption.
*/
inline auto momenta_from_tracking(const std::vector<eic::TrackParametersData>& tracks,
const double mass)
{
std::vector<ROOT::Math::PxPyPzMVector> momenta{tracks.size()};
// transform our raw tracker info into proper 4-momenta
std::transform(tracks.begin(), tracks.end(), momenta.begin(), [mass](const auto& track) {
// make sure we don't divide by zero
if (fabs(track.qOverP) < 1e-9) {
return ROOT::Math::PxPyPzMVector{};
}
const double p = fabs(1. / track.qOverP);
const double px = p * cos(track.phi) * sin(track.theta);
const double py = p * sin(track.phi) * sin(track.theta);
const double pz = p * cos(track.theta);
return ROOT::Math::PxPyPzMVector{px, py, pz, mass};
});
return momenta;
}
} // namespace eicd::helpers
#endif
#include "eicd/helpers.h"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment