Commit c59a4297 authored by Wouter Deconinck's avatar Wouter Deconinck Committed by Sylvester Joosten
Browse files

Update cmake structure to support gaudi v35 and newer

parent 73398f16
cmake_minimum_required(VERSION 3.8)
project(Juggler)
set(CMAKE_CXX_STANDARD 17)
find_package(EICD REQUIRED)
......@@ -12,17 +14,6 @@ set(PODIO $ENV{PODIO})
set(CMAKE_MODULE_PATH CMAKE_MODULE_PATH PODIO)
find_package(podio 0.11.0 REQUIRED)
## There was a breaking change in how collections are stored in podio between
## version v0.13.0 and v0.13.1. This checks for podio version and sets the
## PODIO_BEFORE_0_13_1 preprocessor variable
if (${podio_VERSION_MAJOR} EQUAL 0 AND ${podio_VERSION_MINOR} LESS_EQUAL 13)
if (${podio_VERSION_MINOR} EQUAL 13 AND ${podio_VERSION_PATCH} EQUAL 0)
add_definitions("-DPODIO_BEFORE_0_13_1")
elseif (${podio_VERSION_MINOR} LESS 13)
add_definitions("-DPODIO_BEFORE_0_13_1")
endif()
endif()
include_directories(${podio_INCLUDE_DIR})
find_package(ROOT COMPONENTS MathCore GenVector Geom REQUIRED)
find_package(DD4hep COMPONENTS DDG4 DDG4IO DDRec REQUIRED)
......@@ -30,12 +21,13 @@ find_package(Geant4)
find_library(genfit2 genfit2 /usr/local/lib REQUIRED)
find_package(GaudiProject)
gaudi_project(Juggler v1r0
USE Gaudi v34r0)
find_package(Gaudi)
add_subdirectory(JugBase)
add_subdirectory(JugDigi)
add_subdirectory(JugReco)
add_subdirectory(JugTrack)
gaudi_install(CMAKE)
install(FILES ${CMAKE_BINARY_DIR}/run
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
DESTINATION bin/
)
# 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)
################################################################################
# Package: JugBase
################################################################################
gaudi_subdir(JugBase v1r0)
find_package(EICD)
find_package(Acts REQUIRED COMPONENTS Core PluginIdentification PluginTGeo PluginDD4hep )
find_package(ROOT COMPONENTS RIO Tree Core REQUIRED)
find_package(DD4hep COMPONENTS DDG4 DDG4IO DDRec REQUIRED)
find_library(genfit2 genfit2 /usr/local/lib REQUIRED)
# this declaration will not be needed in the future
gaudi_depends_on_subdirs(GaudiAlg GaudiKernel)
#gaudi_install_scripts()
#gaudi_install_python_modules()
gaudi_add_library(JugBase
src/*.cpp
src/Utilities/*.cpp
src/Plugins/BFieldOptions.cpp
#src/Plugins/BFieldScalor.cpp
SOURCES
src/ACTSLogger.cpp
src/PodioDataSvc.cpp
src/KeepDropSwitch.cpp
src/Utilities/Helpers.cpp
src/Utilities/Paths.cpp
src/Utilities/Options.cpp
src/Plugins/BFieldOptions.cpp
#src/Plugins/BFieldScalor.cpp
src/Plugins/BFieldUtils.cpp
INCLUDE_DIRS EICD PODIO ROOT $ENV{HOME}/stow/podio/include
LINK_LIBRARIES GaudiAlgLib GaudiKernel ROOT DD4hep::DDG4IO
PUBLIC_HEADERS JugBase )
target_link_libraries(JugBase
LINK
Gaudi::GaudiKernel Gaudi::GaudiAlgLib
podio::podioRootIO
ROOT::Core ROOT::RIO ROOT::Tree
DD4hep::DDG4IO DD4hep::DDRec
ActsCore ActsPluginDD4hep
)
${genfit2}
)
target_include_directories(JugBase PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_compile_options(JugBase PRIVATE -Wno-suggest-override)
file(GLOB JugBasePlugins_sources src/components/*.cpp)
gaudi_add_module(JugBasePlugins
src/components/*.cpp
src/components/ReadTestConsumer.cxx
LINK_LIBRARIES GaudiAlgLib GaudiKernel JugBase ROOT DD4hep::DDRec NPDet::DD4podIO ActsCore ActsPluginDD4hep EICD::eicd genfit2)
SOURCES
src/components/ConstPileUp.cpp
src/components/EICDataSvc.cpp
src/components/GeoSvc.cpp
src/components/InputCopier.cpp
src/components/MC2DummyParticle.cpp
src/components/PileupOverlayAlg.cpp
src/components/PodioInput.cpp
src/components/PodioOutput.cpp
src/components/PoissonPileUp.cpp
src/components/RangePileUp.cpp
src/components/type.cpp
src/components/ReadTestConsumer.cxx
LINK
Gaudi::GaudiKernel Gaudi::GaudiAlgLib
GaudiKernel GaudiAlgLib
ROOT::Core ROOT::RIO ROOT::Tree
JugBase
NPDet::DD4podIO
DD4hep::DDRec
ActsCore ActsPluginDD4hep
EICD::eicd
${genfit2}
)
target_include_directories(JugBasePlugins PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_compile_options(JugBasePlugins PRIVATE -Wno-suggest-override)
#gaudi_add_test(ProduceForReadTest
# WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
# FRAMEWORK tests/options/simple_producer.py)
gaudi_add_test(ReadTest
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
FRAMEWORK tests/options/simple_reader.py)
gaudi_add_test(ReadGeoTest
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
FRAMEWORK tests/options/reader_with_geosvc.py)
#gaudi_add_test(CheckReadCollectionSize
# ENVIRONMENT PYTHONPATH+=${PODIO_PYTHON_DIR}
# WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
# COMMAND python JugBase/tests/scripts/check_coll_after_read.py
# DEPENDS ReadTest)
install(TARGETS JugBase JugBasePlugins
EXPORT JugBaseTargets
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib
COMPONENT dev)
if(BUILD_TESTING)
enable_testing()
endif()
#add_test(NAME ProduceForReadTest
# WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
# COMMAND ${CMAKE_BINARY_DIR}/run ${PROJECT_SOURCE_DIR}/JugBase/scripts/gaudirun tests/options/simple_producer.py)
#add_test(NAME ReadTest
# WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
# COMMAND ${CMAKE_BINARY_DIR}/run ${PROJECT_SOURCE_DIR}/JugBase/scripts/gaudirun tests/options/simple_reader.py)
#add_test(NAME ReadGeoTest
# WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
# COMMAND ${CMAKE_BINARY_DIR}/run ${PROJECT_SOURCE_DIR}/JugBase/scripts/gaudirun tests/options/reader_with_geosvc.py)
#add_test(NAME CheckReadCollectionSize
# ENVIRONMENT PYTHONPATH+=${PODIO_PYTHON_DIR}
# WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
# COMMAND python JugBase/tests/scripts/check_coll_after_read.py
# DEPENDS ReadTest)
......@@ -148,19 +148,19 @@ const T* DataHandle<T>::get() {
DataObjectHandle<DataWrapper<T>>::setRead();
return reinterpret_cast<const T*>(tmp->collectionBase());
} else {
std::string errorMsg("The type provided for " + DataObjectHandle<DataWrapper<T>>::toString() +
std::string errorMsg("The type provided for " + DataObjectHandle<DataWrapper<T>>::pythonRepr() +
" is different from the one of the object in the store.");
throw GaudiException(errorMsg, "wrong product type", StatusCode::FAILURE);
}
}
std::string msg("Could not retrieve product " + DataObjectHandle<DataWrapper<T>>::toString());
std::string msg("Could not retrieve product " + DataObjectHandle<DataWrapper<T>>::pythonRepr());
throw GaudiException(msg, "wrong product name", StatusCode::FAILURE);
}
//---------------------------------------------------------------------------
template <typename T>
void DataHandle<T>::put(T* objectp) {
DataWrapper<T>* dw = new DataWrapper<T>();
std::unique_ptr<DataWrapper<T>> dw = std::make_unique<DataWrapper<T>>();
// in case T is of primitive type, we must not change the pointer address
// (see comments in ctor) instead copy the value of T into allocated memory
if constexpr (std::is_integral_v<T> || std::is_floating_point_v<T>) {
......@@ -169,7 +169,7 @@ void DataHandle<T>::put(T* objectp) {
m_dataPtr = objectp;
}
dw->setData(objectp);
DataObjectHandle<DataWrapper<T>>::put(dw);
DataObjectHandle<DataWrapper<T>>::put(std::move(dw));
}
//---------------------------------------------------------------------------
......@@ -188,9 +188,9 @@ T* DataHandle<T>::createAndPut() {
// temporary to allow property declaration
namespace Gaudi {
template <class T>
class Property<::DataHandle<T>&> : public ::DataObjectHandleProperty {
class Property<::DataHandle<T>&> : public ::DataHandleProperty {
public:
Property(const std::string& name, ::DataHandle<T>& value) : ::DataObjectHandleProperty(name, value) {}
Property(const std::string& name, ::DataHandle<T>& value) : ::DataHandleProperty(name, value) {}
/// virtual Destructor
virtual ~Property() {}
......
#include "PodioOutput.h"
#include "GaudiKernel/IJobOptionsSvc.h"
#include "GaudiKernel/ISvcLocator.h"
#include "JugBase/PodioDataSvc.h"
#include "TFile.h"
#include "type.h"
......@@ -118,38 +118,12 @@ StatusCode PodioOutput::execute() {
*/
StatusCode PodioOutput::finalize() {
if (GaudiAlgorithm::finalize().isFailure()) return StatusCode::FAILURE;
//// prepare job options metadata ///////////////////////
// retrieve the configuration of the job
// and write it to file as vector of strings
std::vector<std::string> config_data;
auto jobOptionsSvc = service<IJobOptionsSvc>("JobOptionsSvc");
auto configured_components = jobOptionsSvc->getClients();
for (const auto& name : configured_components) {
auto properties = jobOptionsSvc->getProperties(name);
std::stringstream config_stream;
for (const auto& property : *properties) {
// sample output:
// HepMCToEDMConverter.genparticles = "GenParticles";
// Note that quotes are added to all property values,
// which leads to problems with ints, lists, dicts and bools.
// For theses types, the quotes must be removed in postprocessing.
config_stream << name << "." << property->name() << " = \"" << property->toString() << "\";" << std::endl;
}
config_data.push_back(config_stream.str());
}
// Some default components are not captured by the job option service
// and have to be traversed like this. Note that Gaudi!577 will improve this.
for (const auto* name : {"ApplicationMgr", "MessageSvc", "NTupleSvc"}) {
std::stringstream config_stream;
auto svc = service<IProperty>( name );
if (!svc.isValid()) continue;
for (const auto* property : svc->getProperties()) {
config_stream << name << "." << property->name() << " = \"" << property->toString() << "\";" << std::endl;
}
config_data.push_back(config_stream.str());
}
//// save options for all clients
for ( const auto& p : serviceLocator()->getOptsSvc().items() ) { m_metadata[std::get<0>( p )] = std::get<1>( p ); }
//// finalize trees and file //////////////////////////////
m_metadatatree->Branch("gaudiConfigOptions", &config_data);
m_metadatatree->Branch("gaudiConfigOptions", &m_metadata);
m_metadatatree->Branch("CollectionIDs", m_podioDataSvc->getCollectionIDs());
m_metadatatree->Fill();
m_datatree->Write();
......
......@@ -51,6 +51,8 @@ private:
TTree* m_metadatatree;
/// The stored collections
std::vector<podio::CollectionBase*> m_storedCollections;
/// The metadata map
std::map<std::string, std::string> m_metadata;
};
#endif
################################################################################
# Package: JugDigi
################################################################################
gaudi_subdir(JugDigi v1r0)
find_package(EICD REQUIRED)
#set(PODIO $ENV{PODIO})
......@@ -12,21 +11,9 @@ find_package(EICD REQUIRED)
find_package(ROOT COMPONENTS RIO Tree Core REQUIRED)
find_package(DD4hep COMPONENTS DDG4 DDG4IO DDRec REQUIRED)
# this declaration will not be needed in the future
gaudi_depends_on_subdirs(GaudiAlg GaudiKernel)
#gaudi_install_scripts()
#gaudi_install_python_modules()
#gaudi_add_library(JugBase
# src/*.cpp
# INCLUDE_DIRS EICD PODIO ROOT $ENV{HOME}/stow/podio/include
# LINK_LIBRARIES GaudiAlgLib GaudiKernel ROOT DD4hep::DDG4IO
# PUBLIC_HEADERS JugBase)
#target_link_libraries(JugBase
# podio::podioRootIO
# )
file(GLOB JugDigiPlugins_sources src/components/*.cpp)
gaudi_add_module(JugDigiPlugins
SOURCES
src/components/CalorimeterHitDigi.cpp
src/components/CrystalEndcapsDigi.cpp
src/components/EMCalorimeterDigi.cpp
......@@ -36,18 +23,16 @@ gaudi_add_module(JugDigiPlugins
src/components/PhotoMultiplierDigi.cpp
src/components/SOIPIXTrackerDigi.cpp
src/components/UFSDTrackerDigi.cpp
LINK_LIBRARIES GaudiAlgLib GaudiKernel JugBase ROOT NPDet::DD4podIO EICD::eicd)
target_compile_options(JugDigiPlugins PRIVATE -Wno-suggest-override)
LINK
Gaudi::GaudiAlgLib Gaudi::GaudiKernel
JugBase
ROOT::Core ROOT::RIO ROOT::Tree
NPDet::DD4podIO
EICD::eicd
)
#gaudi_add_test(ProduceForReadTest
# WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
# FRAMEWORK tests/options/simple_producer.py)
gaudi_add_test(ExCaloDigi
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
FRAMEWORK tests/options/example_calodigi.py
)
#gaudi_add_test(CheckReadCollectionSize
# ENVIRONMENT PYTHONPATH+=${PODIO_PYTHON_DIR}
# WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
# COMMAND python FWCore/tests/scripts/check_coll_after_read.py
# DEPENDS ReadTest)
target_include_directories(JugDigiPlugins PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_compile_options(JugDigiPlugins PRIVATE -Wno-suggest-override)
################################################################################
# Package: JugReco
################################################################################
gaudi_subdir(JugReco v1r0)
find_package(EICD REQUIRED)
#set(PODIO $ENV{PODIO})
#set(CMAKE_MODULE_PATH CMAKE_MODULE_PATH PODIO)
#find_package(podio 0.11.01 REQUIRED)
#include_directories(${podio_INCLUDE_DIR})
#find_package(Acts REQUIRED COMPONENTS Core PluginIdentification PluginTGeo PluginDD4hep )
find_package(ROOT COMPONENTS RIO Tree Core REQUIRED)
find_package(DD4hep COMPONENTS DDG4 DDG4IO DDRec REQUIRED)
# this declaration will not be needed in the future
gaudi_depends_on_subdirs(GaudiAlg GaudiKernel)
#gaudi_install_scripts()
#gaudi_install_python_modules()
#gaudi_add_library(JugBase
# src/*.cpp
# INCLUDE_DIRS EICD PODIO ROOT $ENV{HOME}/stow/podio/include
# LINK_LIBRARIES GaudiAlgLib GaudiKernel ROOT DD4hep::DDG4IO
# PUBLIC_HEADERS JugBase)
#target_link_libraries(JugBase
# podio::podioRootIO
# )
file(GLOB JugRecoPlugins_sources src/components/*.cpp)
gaudi_add_module(JugRecoPlugins
SOURCES
src/components/TrackerHitReconstruction.cpp
src/components/SimpleClustering.cpp
src/components/CalorimeterHitReco.cpp
src/components/CalorimeterHitsEtaPhiProjector.cpp
src/components/CalorimeterHitsMerger.cpp
src/components/CalorimeterIslandCluster.cpp
src/components/CrystalEndcapsReco.cpp
......@@ -47,20 +29,17 @@ gaudi_add_module(JugRecoPlugins
src/components/ImagingPixelMerger.cpp
src/components/ImagingTopoCluster.cpp
src/components/ImagingClusterReco.cpp
src/components/CalorimeterHitsEtaPhiProjector.cpp
LINK_LIBRARIES GaudiAlgLib GaudiKernel JugBase ROOT NPDet::DD4podIO EICD::eicd DDRec )
LINK
Gaudi::GaudiAlgLib Gaudi::GaudiKernel
JugBase
ROOT::Core ROOT::RIO ROOT::Tree
NPDet::DD4podIO
EICD::eicd
DD4hep::DDRec
)
target_compile_options(JugRecoPlugins PRIVATE -Wno-suggest-override)
target_include_directories(JugRecoPlugins PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
#gaudi_add_test(ProduceForReadTest
# WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
# FRAMEWORK tests/options/simple_producer.py)
#gaudi_add_test(loggerTest
# WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
# FRAMEWORK tests/options/testLogger.py
# )
#gaudi_add_test(CheckReadCollectionSize
# ENVIRONMENT PYTHONPATH+=${PODIO_PYTHON_DIR}
# WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
# COMMAND python FWCore/tests/scripts/check_coll_after_read.py
# DEPENDS ReadTest)
target_compile_options(JugRecoPlugins PRIVATE -Wno-suggest-override)
################################################################################
# Package: JugTrack
################################################################################
gaudi_subdir(JugTrack v1r0)
find_package(EICD REQUIRED)
#set(PODIO $ENV{PODIO})
#set(CMAKE_MODULE_PATH CMAKE_MODULE_PATH PODIO)
#find_package(podio 0.11.01 REQUIRED)
#include_directories(${podio_INCLUDE_DIR})
find_package(Acts REQUIRED COMPONENTS Core PluginIdentification PluginTGeo PluginDD4hep )
find_package(ROOT COMPONENTS RIO Tree Core REQUIRED)
find_package(DD4hep COMPONENTS DDG4 DDG4IO DDRec REQUIRED)
find_library(genfit2 genfit2 /usr/local/lib REQUIRED)
# this declaration will not be needed in the future
gaudi_depends_on_subdirs(GaudiAlg GaudiKernel)
#gaudi_install_scripts()
#gaudi_install_python_modules()
#gaudi_add_library(JugBase
# src/*.cpp
# INCLUDE_DIRS EICD PODIO ROOT $ENV{HOME}/stow/podio/include
# LINK_LIBRARIES GaudiAlgLib GaudiKernel ROOT DD4hep::DDG4IO
# PUBLIC_HEADERS JugBase)
#target_link_libraries(JugBase
# podio::podioRootIO
# )
file(GLOB JugTrackPlugins_sources src/components/*.cpp)
gaudi_add_module(JugTrackPlugins
SOURCES
src/components/GenFitTrackFitter.cpp
src/components/SingleTrackSourceLinker.cpp
src/components/TrackerSourceLinker.cpp
......@@ -44,7 +25,20 @@ gaudi_add_module(JugTrackPlugins
src/components/TrackParamClusterInit.cpp
src/components/TrackParamVertexClusterInit.cpp
src/components/ParticlesFromTrackFit.cpp
LINK_LIBRARIES GaudiAlgLib GaudiKernel JugBase ROOT NPDet::DD4podIO EICD::eicd DDRec Acts genfit2)
LINK
Gaudi::GaudiAlgLib Gaudi::GaudiKernel
JugBase
ROOT::Core ROOT::RIO ROOT::Tree
NPDet::DD4podIO
EICD::eicd
DD4hep::DDRec
ActsCore
${genfit2}
)
target_include_directories(JugTrackPlugins PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_compile_options(JugTrackPlugins PRIVATE -Wno-suggest-override)
......@@ -52,8 +46,3 @@ target_compile_options(JugTrackPlugins PRIVATE -Wno-suggest-override)
# WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
# FRAMEWORK tests/options/testLogger.py
# )
#gaudi_add_test(CheckReadCollectionSize
# ENVIRONMENT PYTHONPATH+=${PODIO_PYTHON_DIR}
# WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
# COMMAND python FWCore/tests/scripts/check_coll_after_read.py
# DEPENDS ReadTest)
<?xml version="1.0" encoding="UTF-8"?>
<env:config xmlns:env="EnvSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="EnvSchema EnvSchema.xsd ">
<env:default variable="LCG_releases"></env:default>
<env:default variable="LCG_external"></env:default>
<env:search_path>@CMAKE_INSTALL_PREFIX@</env:search_path>
<env:prepend variable="PATH">${.}/scripts</env:prepend>
<env:prepend variable="PATH">${.}/bin</env:prepend>
<env:prepend variable="LD_LIBRARY_PATH">${.}/lib</env:prepend>
<env:prepend variable="PYTHONPATH">${.}/python</env:prepend>
</env:config>
include(CMakeFindDependencyMacro)
find_dependency(podio REQUIRED)
find_dependency(Gaudi REQUIRED)
# - Include the targets file to create the imported targets that a client can
# link to (libraries) or execute (programs)
include("${CMAKE_CURRENT_LIST_DIR}/JugglerTargets.cmake")
###############################################################################
## Create and install minimal project xenv file
###############################################################################
configure_file("cmake/${PROJECT_NAME}.xenv.in"
"${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${PROJECT_NAME}.xenv"
@ONLY)
install(FILES
"${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${PROJECT_NAME}.xenv"
DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT dev)
Supports Markdown
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