Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Algorithms integration #3

Draft
wants to merge 51 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
e49ccfd
fix: ensure build/compile_commands.json is in clang-tidy workflow
wdconinc Aug 8, 2022
739c7a2
fix: download-artifact path is directory
wdconinc Aug 11, 2022
861a64e
feat: ScatteredElectronFinder, returns subset collection with first `…
wdconinc Aug 11, 2022
e1118a2
ci: build docker containers with tag docker-new
wdconinc Aug 15, 2022
71fc7f9
Resolve "Many places have hard-coded `eicd::Vector3f` which should de…
wdconinc Aug 15, 2022
65ed7b2
fix: `PodioOutput` metadata branch `CollectionTypeInfo` is not comple…
c-dilks Aug 17, 2022
c0123f2
fix: make work with edm4hep::Vector and eicd::Vector
wdconinc Aug 23, 2022
a715a94
fix: allow for non-existent eicd::Vector types
wdconinc Aug 23, 2022
e69b933
fix: allow for non-existent unused third conditional type
wdconinc Aug 23, 2022
6df6351
fix: ensure eicd::Vector2f and 3f exist
wdconinc Aug 23, 2022
f85f375
feat: use eicd from github
wdconinc Aug 23, 2022
bf366a3
chore: rename `eicd` -> `EDM4eic`
Sep 5, 2022
7d5411c
Homogeneous ecal smearing: change where scaling is applied
Sep 13, 2022
3eeebb3
ci: use run-clang-tidy
wdconinc Sep 18, 2022
17c8e9b
chore: remove genfit
wdconinc Sep 20, 2022
1fbb346
Add core algorithm headers
sly2j Sep 13, 2022
ca32a51
Added dummy executable
sly2j Sep 13, 2022
9175cce
Added simple cmake build to algorithms
sly2j Sep 13, 2022
4141556
change Juggler default build type when .git is present to RelWithDebInfo
sly2j Sep 13, 2022
1351e2f
WIP: AlgoriServiceSvc
sly2j Sep 13, 2022
dff8bdf
detection for the LogSvc, still need to add hooks to logger
sly2j Sep 14, 2022
7f6a2fa
correctly load the GNU prefix structure
sly2j Sep 14, 2022
ec35c77
add clang-format to algorithms
sly2j Sep 14, 2022
efae5ed
add critical log level, rename junk --> trace
sly2j Sep 14, 2022
c33426e
better comment
sly2j Sep 14, 2022
65be5b4
Actually setup default log level
sly2j Sep 14, 2022
6058684
Add logger action and ensure all messages are displayed
sly2j Sep 14, 2022
44319ea
Initial implementation of base Gaudi Algorithm
sly2j Sep 14, 2022
37ce0b8
Get rid of extra template parameter in setProperty using SFINAE
sly2j Sep 14, 2022
82226d2
more typetrait-ian names for upcast to improve clarity
sly2j Sep 14, 2022
233b50f
support rvalues for more complicated types
sly2j Sep 14, 2022
efd5f88
Also add function-style logger
sly2j Sep 14, 2022
6647e21
Proper version of endmsg without preprocesor macros (that could clash…
sly2j Sep 14, 2022
946bb86
Add type traits to detect special algorithm argument types (vector an…
sly2j Sep 14, 2022
e678784
Fix shadow bug
sly2j Sep 19, 2022
7248ac9
+depends JugBase
sly2j Sep 19, 2022
b8c289d
full type deduction for algorithms
sly2j Sep 19, 2022
f6dea6e
Wrote the guts for generic DataHandle operations, needs testing
sly2j Sep 19, 2022
ffe353c
Added glue code into Algorithm base class
sly2j Sep 19, 2022
5d85f7d
Added simple DD4hep geo service, and added service bindings to Juggler
sly2j Sep 20, 2022
8b0de86
First working algorithm implementation, ready to finish Juggler end
sly2j Sep 20, 2022
1b77f2d
Added first example algorithm, ready for testing
sly2j Sep 21, 2022
d098bfb
minor improvements
sly2j Sep 22, 2022
e8a649b
ensure AlgoServiceSvc is loaded
sly2j Sep 22, 2022
dbb30f0
added debug line to try to understand any_cast failure
sly2j Sep 23, 2022
e8ec549
Add explicit specialization for bools
sly2j Sep 23, 2022
5f99ef3
debug code
sly2j Sep 23, 2022
91ace76
bugfix: raise exceptions when NOT using a valid reconstruction method
sly2j Sep 23, 2022
d3e11dc
remove debug code
sly2j Sep 23, 2022
b237ca0
Ensure log level always initialized
sly2j Sep 23, 2022
22735ea
Added documentation (inline) and license info
sly2j Sep 23, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ SpaceAfterControlStatementKeyword: true
PointerBindsToType: true
IncludeBlocks: Preserve
UseTab: Never
ColumnLimit: 120
ColumnLimit: 100
NamespaceIndentation: Inner
AlignConsecutiveAssignments: true
...
11 changes: 8 additions & 3 deletions .github/workflows/linux-eic-shell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ jobs:
cmake --build build -- install
- uses: actions/upload-artifact@v3
with:
name: build-eic-shell
name: install-eic-shell
path: install/
if-no-files-found: error
- uses: actions/upload-artifact@v3
with:
name: build-eic-shell
path: build/
if-no-files-found: error

clang-tidy:
runs-on: ubuntu-latest
Expand All @@ -31,12 +36,12 @@ jobs:
- uses: actions/download-artifact@v3
with:
name: build-eic-shell
path: install/
path: build/
- uses: eic/run-cvmfs-osg-eic-shell@main
with:
platform-release: "jug_xl:nightly"
run: |
run-clang-tidy-13 -p build -export-fixes clang_tidy_fixes.yml -extra-arg='-std=c++17'
run-clang-tidy -p build -export-fixes clang_tidy_fixes.yml -extra-arg='-std=c++17'
- uses: actions/upload-artifact@v3
with:
name: clang-tidy-fixes.yml
Expand Down
20 changes: 11 additions & 9 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ variables:
## Other versions to be included in the container. In general these should be "master"
## to keep the container functionally identical to jug_xl:nightly
JUGGLER_NPDET_VERSION: "master"
JUGGLER_EICD_VERSION: "master"
JUGGLER_EDM4EIC_VERSION: "main"
JUGGLER_EDM4EIC_REPOSITORYURL: "https://github.com/eic/EDM4eic.git"

## We have:
## - Juggler triggers eic_container on a master pipeline
Expand Down Expand Up @@ -75,13 +76,13 @@ juggler:local:
- CMAKE_CXX_STANDARD:
- 17
script:
## first install EICD to ensure the latest version, then build juggler
## first install EDM4EIC to ensure the latest version, then build juggler
- |
git clone https://eicweb.phy.anl.gov/eic/eicd.git /tmp/eicd
cd /tmp/eicd && git checkout $JUGGLER_EICD_VERSION && cd -
cmake -B /tmp/build -S /tmp/eicd -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} -DCMAKE_INSTALL_PREFIX=/usr/local
git clone ${JUGGLER_EDM4EIC_REPOSITORYURL} /tmp/EDM4eic
cd /tmp/EDM4eic && git checkout ${JUGGLER_EDM4EIC_VERSION} && cd -
cmake -B /tmp/build -S /tmp/EDM4eic -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} -DCMAKE_INSTALL_PREFIX=/usr/local
cmake --build /tmp/build -j40 -- install
rm -rf /tmp/build /tmp/eicd
rm -rf /tmp/build /tmp/EDM4eic
- |
cmake -Bbuild -S. -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} -DCMAKE_INSTALL_PREFIX=/usr/local
cmake --build build -j20
Expand All @@ -97,7 +98,7 @@ analysis:clang-tidy:
- juggler:local
script:
- |
run-clang-tidy-13 -p build -j20 -export-fixes clang_tidy_fixes.yml -extra-arg='-std=c++17'
run-clang-tidy -p build -j20 -export-fixes clang_tidy_fixes.yml -extra-arg='-std=c++17'
artifacts:
expire_in: 1 week
paths:
Expand Down Expand Up @@ -130,7 +131,7 @@ version:
juggler:default:
stage: docker
tags:
- docker
- docker-new
rules:
- if: '$CI_SERVER_HOST == "eicweb.phy.anl.gov"'
needs:
Expand All @@ -145,7 +146,8 @@ juggler:default:
--build-arg INTERNAL_TAG=${EIC_DEV_TAG}
--build-arg JUGGLER_VERSION=${CI_COMMIT_REF_NAME}
--build-arg NPDET_VERSION=${JUGGLER_NPDET_VERSION}
--build-arg EICD_VERSION=${JUGGLER_EICD_VERSION}
--build-arg EDM4EIC_REPOSITORYURL=${JUGGLER_EDM4EIC_REPOSITORYURL}
--build-arg EDM4EIC_VERSION=${JUGGLER_EDM4EIC_VERSION}
--build-arg DETECTOR_VERSION=${JUGGLER_DETECTOR_VERSION}
--build-arg IP6_VERSION=${JUGGLER_IP6_VERSION}
--build-arg JUG_VERSION=juggler-${INTERNAL_TAG}-$(date +%Y-%m-%d_%H-%M-%S)-$(git rev-parse HEAD)
Expand Down
10 changes: 6 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ endif()
# Set default build type
set(default_build_type "Release")
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
set(default_build_type "Debug")
set(default_build_type "RelWithDebInfo")
endif()
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
Expand All @@ -51,7 +51,7 @@ endif()

find_package(Microsoft.GSL CONFIG)

find_package(EICD REQUIRED)
find_package(EDM4EIC REQUIRED)
find_package(EDM4HEP 0.4.1 REQUIRED)

find_package(podio 0.14.1 REQUIRED)
Expand All @@ -73,18 +73,20 @@ add_definitions("-DActs_VERSION_MAJOR=${Acts_VERSION_MAJOR}")
add_definitions("-DActs_VERSION_MINOR=${Acts_VERSION_MINOR}")
add_definitions("-DActs_VERSION_PATCH=${Acts_VERSION_PATCH}")

find_library(genfit2 genfit2 /usr/local/lib REQUIRED)
find_path(genfit2_INCLUDE_DIR NAMES GFGbl.h PATHS /usr/local/include ${genfit2}/../include REQUIRED)
## algorithms dependency
add_subdirectory(external/algorithms)

find_package(Gaudi)
add_subdirectory(JugBase)
add_subdirectory(JugAlgo)
add_subdirectory(JugDigi)
add_subdirectory(JugFast)
add_subdirectory(JugPID)
add_subdirectory(JugReco)
add_subdirectory(JugTrack)
gaudi_install(CMAKE)


# create and install Juggler.xenv file as it still has a use-case
# TODO: update workflow to not need xenv files anymore
include(cmake/xenv.cmake)
51 changes: 51 additions & 0 deletions JugAlgo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
# Copyright (C) 2022 Sylvester Joosten

################################################################################
# Package: JugAlgo
################################################################################

file(GLOB JugAlgo_sources CONFIGURE_DEPENDS src/*.cpp)
gaudi_add_library(JugAlgo
SOURCES
${JugAlgo_sources}
LINK
Gaudi::GaudiKernel Gaudi::GaudiAlgLib
algocore
JugBase
)

target_include_directories(JugAlgo PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

target_compile_options(JugAlgo PRIVATE -Wno-suggest-override)

file(GLOB JugAlgoPlugins_sources CONFIGURE_DEPENDS src/components/*.cpp)
gaudi_add_module(JugAlgoPlugins
SOURCES
${JugAlgoPlugins_sources}
LINK
Gaudi::GaudiKernel Gaudi::GaudiAlgLib
JugBase
JugAlgo
algocore
)

target_include_directories(JugAlgoPlugins PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

target_compile_options(JugAlgoPlugins PRIVATE -Wno-suggest-override)

install(TARGETS JugAlgo JugAlgoPlugins
EXPORT JugAlgoTargets
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib
COMPONENT dev)

if(BUILD_TESTING)
enable_testing()
endif()
94 changes: 94 additions & 0 deletions JugAlgo/JugAlgo/Algorithm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright (C) 2022 Sylvester Joosten

#include <string>
#include <type_traits>

#include <algorithms/algorithm.h>
#include <algorithms/type_traits.h>

#include <GaudiAlg/GaudiAlgorithm.h>
#include <GaudiKernel/Service.h>
#include <JugAlgo/IAlgoServiceSvc.h>
#include <JugAlgo/detail/DataProxy.h>

namespace Jug::Algo {

template <class AlgoImpl> class Algorithm : public GaudiAlgorithm {
public:
using algo_type = AlgoImpl;
using input_type = typename algo_type::input_type;
using output_type = typename algo_type::output_type;
using Input = typename algo_type::Input;
using Output = typename algo_type::Output;

Algorithm(const std::string& name, ISvcLocator* svcLoc)
: GaudiAlgorithm(name, svcLoc)
, m_algo{name}
, m_output{this, m_algo.outputNames()}
, m_input{this, m_algo.inputNames()} {}

StatusCode initialize() override {
debug() << "Initializing " << name() << endmsg;

// Grab the AlgoServiceSvc
m_algo_svc = service("AlgoServiceSvc");
if (!m_algo_svc) {
error() << "Unable to get an instance of the AlgoServiceSvc" << endmsg;
return StatusCode::FAILURE;
}

// Forward the log level of this algorithm
const algorithms::LogLevel level{
static_cast<algorithms::LogLevel>(msgLevel() > 0 ? msgLevel() - 1 : 0)};
debug() << "Setting the logger level to " << algorithms::logLevelName(level) << endmsg;
m_algo.level(level);

// Init our data structures
debug() << "Initializing data structures" << endmsg;
m_input.init();
m_output.init();

// call configure function that passes properties
debug() << "Configuring properties" << endmsg;
auto sc = configure();
if (sc != StatusCode::SUCCESS) {
return sc;
}

// call the internal algorithm init
debug() << "Initializing underlying algorithm " << m_algo.name() << endmsg;
m_algo.init();
return StatusCode::SUCCESS;
}

StatusCode execute() override {
try {
m_algo.process(m_input.get(), m_output.get());
} catch (const std::exception& e) {
error() << e.what() << endmsg;
return StatusCode::FAILURE;
}
return StatusCode::SUCCESS;
}

virtual StatusCode configure() = 0;

protected:
template <typename T> void setAlgoProp(std::string_view name, T&& value) {
m_algo.template setProperty<T>(name, value);
}
template <typename T> T getAlgoProp(std::string name) const {
return m_algo.template getProperty<T>(name);
}
bool hasAlgoProp(std::string_view name) const { return m_algo.hasProperty(name); }

private:
algo_type m_algo;
SmartIF<IAlgoServiceSvc> m_algo_svc;
detail::DataProxy<output_type> m_output;
detail::DataProxy<input_type> m_input;
};

} // namespace Jug::Algo

16 changes: 16 additions & 0 deletions JugAlgo/JugAlgo/IAlgoServiceSvc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright (C) 2022 Sylvester Joosten

#pragma once

#include <GaudiKernel/IService.h>

// Juggler bindings for all required algorithms services
// Will setup all necessary services (using the algorithms::ServiceSvc)

class GAUDI_API IAlgoServiceSvc : virtual public IService {
public:
DeclareInterfaceID(IAlgoServiceSvc, 1, 0);
virtual ~IAlgoServiceSvc() {}
// No actual API needed, as this service will do all the magic behind the screens
};
Loading