-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #121 from kjvbrt/ana_thrust
Adding determination of event thrust not by minimization
- Loading branch information
Showing
13 changed files
with
280 additions
and
46 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 |
---|---|---|
|
@@ -3,7 +3,7 @@ name: benchmark | |
on: [push] | ||
|
||
jobs: | ||
test: | ||
bench: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
|
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 |
---|---|---|
|
@@ -9,7 +9,10 @@ __pycache__/ | |
|
||
# ROOT files | ||
*.root | ||
|
||
# Editors | ||
*~ | ||
.vimlocal | ||
|
||
# Distribution / packaging | ||
.Python | ||
|
This file was deleted.
Oops, something went wrong.
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
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,14 @@ | ||
#ifndef UTILS_ANALYZERS_H | ||
#define UTILS_ANALYZERS_H | ||
|
||
#include <cmath> | ||
|
||
namespace FCCAnalyses { | ||
namespace Utils { | ||
|
||
template<typename T> inline auto getsize( T& vec){ return vec.size();}; | ||
|
||
} | ||
} | ||
|
||
#endif |
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
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
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,46 @@ | ||
|
||
if(USE_EXTERNAL_CATCH2) | ||
find_package(Catch2 REQUIRED) | ||
else() | ||
message(STATUS "Fetching local copy of Catch2 library for unit-tests...") | ||
# Build Catch2 with the default flags, to avoid generating warnings when we | ||
# build it | ||
set(CXX_FLAGS_CMAKE_USED ${CMAKE_CXX_FLAGS}) | ||
set(CMAKE_CXX_FLAGS ${CXX_FLAGS_CMAKE_DEFAULTS}) | ||
Include(FetchContent) | ||
FetchContent_Declare( | ||
Catch2 | ||
GIT_REPOSITORY https://github.com/catchorg/Catch2.git | ||
GIT_TAG 037ddbc75cc5e58b93cf5a010a94b32333ad824d | ||
) | ||
FetchContent_MakeAvailable(Catch2) | ||
set(CMAKE_MODULE_PATH ${Catch2_SOURCE_DIR}/extras ${CMAKE_MODULE_PATH}) | ||
# Disable clang-tidy on external contents | ||
set_target_properties(Catch2 PROPERTIES CXX_CLANG_TIDY "") | ||
|
||
# Hack around the fact, that the include directories are not declared as | ||
# SYSTEM for the targets defined this way. Otherwise warnings can still occur | ||
# in Catch2 code when templates are evaluated (which happens quite a bit) | ||
get_target_property(CATCH2_IF_INC_DIRS Catch2 INTERFACE_INCLUDE_DIRECTORIES) | ||
set_target_properties(Catch2 PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${CATCH2_IF_INC_DIRS}") | ||
|
||
# Reset the flags | ||
set(CMAKE_CXX_FLAGS ${CXX_FLAGS_CMAKE_USED}) | ||
|
||
endif() | ||
|
||
|
||
# The unittests are a bit better and they are labelled so we can put together a | ||
# list of labels that we want to ignore | ||
set(filter_tests "") | ||
|
||
add_executable(bench algorithms.cpp myutils.cpp) | ||
target_link_libraries(bench PUBLIC FCCAnalyses gfortran PRIVATE Catch2::Catch2WithMain) | ||
target_include_directories(bench PUBLIC ${VDT_INCLUDE_DIR}) | ||
|
||
include(Catch) | ||
catch_discover_tests(bench | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} | ||
TEST_PREFIX "B_" # make it possible to filter easily with -R ^UT | ||
TEST_SPEC ${filter_tests} # discover only tests that are known to not fail | ||
) |
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,15 @@ | ||
#include "FCCAnalyses/Algorithms.h" | ||
|
||
#include "catch2/catch_test_macros.hpp" | ||
#include <catch2/benchmark/catch_benchmark.hpp> | ||
|
||
|
||
TEST_CASE("calculate_thrust", "[algorithms]") { | ||
ROOT::VecOps::RVec<float> x {0., 1., 3., 7., 11., 3.}; | ||
ROOT::VecOps::RVec<float> y {0., -1., 3., -7., -11., .3}; | ||
ROOT::VecOps::RVec<float> z {5., -3., 1., 4., 2., -4}; | ||
|
||
BENCHMARK("calculate_thrust short vector") { | ||
return FCCAnalyses::Algorithms::calculate_thrust()(x, y, z); | ||
}; | ||
} |
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,15 @@ | ||
#include "FCCAnalyses/myUtils.h" | ||
|
||
#include <catch2/catch_test_macros.hpp> | ||
#include <catch2/benchmark/catch_benchmark.hpp> | ||
|
||
TEST_CASE("isPV", "[basics]") { | ||
edm4hep::ReconstructedParticleData p; | ||
p.tracks_begin = 0; | ||
ROOT::VecOps::RVec<int> index1 = {3, 0, 7}; | ||
ROOT::VecOps::RVec<int> index2 = {3, 1, 7}; | ||
|
||
BENCHMARK("isPV") { | ||
return FCCAnalyses::myUtils::isPV(p, index1); | ||
}; | ||
} |
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
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
Oops, something went wrong.