Skip to content

Commit

Permalink
Use the Key4hepConfig flag to set the standard, compiler flags and rp…
Browse files Browse the repository at this point in the history
…ath magic (#203)
  • Loading branch information
jmcarcell authored Sep 11, 2024
1 parent ff40f1a commit 3165e40
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 47 deletions.
20 changes: 1 addition & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,14 @@ cmake_minimum_required(VERSION 3.14)
cmake_policy(SET CMP0074 NEW) # use package_ROOT env var to find packages
project(k4MarlinWrapper LANGUAGES CXX)

# RPATH settings
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE CACHE BOOL "RPATH USE LINK PATH")
option(USE_RUNPATH_INSTEAD_OF_RPATH "Use runpath instead of rpath (allow specifying linked libraries via LD_LIBRARY_PATH)" OFF)
if(USE_RUNPATH_INSTEAD_OF_RPATH)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--enable-new-dtags")
endif()

# project version
SET( ${PROJECT_NAME}_VERSION_MAJOR 0 )
SET( ${PROJECT_NAME}_VERSION_MINOR 8 )
SET( ${PROJECT_NAME}_VERSION_PATCH 0 )

SET( ${PROJECT_NAME}_VERSION "${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH}" )

set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")

set(CMAKE_CXX_STANDARD 20 CACHE STRING "")

if(NOT CMAKE_CXX_STANDARD MATCHES "20|23")
message(FATAL_ERROR "Unsupported C++ standard: ${CMAKE_CXX_STANDARD}")
endif()

# Ninja compiler output
include(cmake/compiler_output.cmake)
include(cmake/Key4hepConfig.cmake)

include(GNUInstallDirs)

Expand Down
9 changes: 0 additions & 9 deletions cmake/compiler_output.cmake

This file was deleted.

5 changes: 2 additions & 3 deletions k4MarlinWrapper/k4MarlinWrapper/util/k4MarlinWrapperUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#ifndef K4MARLINWRAPPER_UTIL_H
#define K4MARLINWRAPPER_UTIL_H

#include <iostream>
#include <regex>
#include <string>
#include <vector>
Expand All @@ -44,8 +43,8 @@ namespace k4MW::util {

/// singleton helper to initialize global Marlin parameters exactly once. This
marlin::StringParameters* marlinGlobalParameters() {
static marlin::StringParameters p{};
const static auto initMarlinGlobal = []() {
static marlin::StringParameters p{};
[[maybe_unused]] const static auto initMarlinGlobal = []() {
marlin::Global::parameters = &p;
return true; // need a non-void return type
}();
Expand Down
11 changes: 5 additions & 6 deletions k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,14 @@ podio::CollectionBase* EDM4hep2LcioTool::getEDM4hepCollection(const std::string&
if (ptr) {
collPtr = ptr->collectionBase();
}
// When the collection can't be retrieved from the frame
// there is still the possibility that it was generated
// from a functional algorithm
// When the collection can't be retrieved from the frame there is still the
// possibility that it was generated from a functional algorithm
else {
auto ptr = dynamic_cast<AnyDataWrapper<std::shared_ptr<podio::CollectionBase>>*>(p);
if (!ptr) {
auto nptr = dynamic_cast<AnyDataWrapper<std::shared_ptr<podio::CollectionBase>>*>(p);
if (!nptr) {
throw GaudiException("Collection could not be casted to the expected type", name(), StatusCode::FAILURE);
} else {
collPtr = dynamic_cast<podio::CollectionBase*>(ptr->getData().get());
collPtr = dynamic_cast<podio::CollectionBase*>(nptr->getData().get());
}
}

Expand Down
10 changes: 7 additions & 3 deletions k4MarlinWrapper/src/components/LcioEventOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,12 @@ void LcioEventOutput::revertSubsets(const std::vector<lcio::LCCollectionVec*>& s
////////////////////////////////////////////
StatusCode LcioEventOutput::execute(const EventContext&) const {
// Get event
DataObject* pObject = nullptr;
StatusCode sc = evtSvc()->retrieveObject("/Event/LCEvent", pObject);
DataObject* pObject = nullptr;
StatusCode sc = evtSvc()->retrieveObject("/Event/LCEvent", pObject);
if (sc.isFailure()) {
error() << "Could not retrieve LCEvent from event service" << endmsg;
return StatusCode::FAILURE;
}
lcio::LCEventImpl* the_event = dynamic_cast<IMPL::LCEventImpl*>(static_cast<LCEventWrapper*>(pObject)->getEvent());

std::vector<lcio::LCCollectionVec*> subsets{};
Expand All @@ -149,7 +153,7 @@ StatusCode LcioEventOutput::execute(const EventContext&) const {
StatusCode LcioEventOutput::finalize() {
// Cleanup
m_writer->close();
delete (m_writer);
delete m_writer;

return StatusCode::SUCCESS;
}
12 changes: 6 additions & 6 deletions k4MarlinWrapper/src/components/MarlinProcessorWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,9 @@ StatusCode MarlinProcessorWrapper::execute(const EventContext&) const {
// Handle exceptions that may come from Marlin
catch (marlin::SkipEventException& e) {
// Store flag to prevent the rest of the event from processing
auto pStatus = std::make_unique<LCEventWrapperStatus>(false);
const StatusCode scStatus = eventSvc()->registerObject("/Event/LCEventStatus", pStatus.release());
if (scStatus.isFailure()) {
auto upStatus = std::make_unique<LCEventWrapperStatus>(false);
const StatusCode code = eventSvc()->registerObject("/Event/LCEventStatus", upStatus.release());
if (code.isFailure()) {
error() << "Failed to store flag to skip event on Marlin marlin::SkipEventException" << endmsg;
return scStatus;
}
Expand All @@ -287,9 +287,9 @@ StatusCode MarlinProcessorWrapper::execute(const EventContext&) const {
return StatusCode::FAILURE;
} catch (marlin::StopProcessingException& e) {
// Store flag to prevent the rest of the event from processing
auto pStatus = std::make_unique<LCEventWrapperStatus>(false);
const StatusCode scStatus = eventSvc()->registerObject("/Event/LCEventStatus", pStatus.release());
if (scStatus.isFailure()) {
auto upStatus = std::make_unique<LCEventWrapperStatus>(false);
const StatusCode code = eventSvc()->registerObject("/Event/LCEventStatus", upStatus.release());
if (code.isFailure()) {
error() << "Failed to store flag to skip event on Marlin marlin::StopProcessingException" << endmsg;
return scStatus;
}
Expand Down
2 changes: 1 addition & 1 deletion test/src/MarlinMCRecoLinkChecker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void MarlinMCRecoLinkChecker::processEvent(LCEvent* evt) {
std::to_string(relColl->getNumberOfElements()) + ")");
}

for (size_t i = 0; i < mcColl->getNumberOfElements(); ++i) {
for (size_t i = 0; i < static_cast<size_t>(mcColl->getNumberOfElements()); ++i) {
const auto mc = static_cast<EVENT::MCParticle*>(mcColl->getElementAt(i));
const auto reco = static_cast<EVENT::ReconstructedParticle*>(recoColl->getElementAt(i));
const auto rel = static_cast<EVENT::LCRelation*>(relColl->getElementAt(i));
Expand Down

0 comments on commit 3165e40

Please sign in to comment.