From 4d6b9626268d5901d179e6f9499cd1184271db4d Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Fri, 6 Nov 2026 16:17:30 +0100 Subject: [PATCH 1/3] [Infrastructure] Allow building a workflow as a workflow plugin A workflow opts in with WORKFLOW_PLUGIN on o2physics_add_dpl_workflow. Its sources, with the shared precompiled header as before, are then compiled once, into the DSO libO2PhysicsPlugin holding the DPL workflow plugin , the CamelCase of the executable name without o2-, which o2-dpl-run can load with --workflow-plugin. The executable keeps its name and options and only has a main() calling the plugin it links, which it runs as its embedded workflow. Workflows which do not opt in are built as before. The histograms tutorial opts in. It needs the matching O2 change, which adds WORKFLOW_PLUGIN to o2_add_dpl_workflow and dpl_workflow_main() to runDataProcessing.h. --- Tutorials/CMakeLists.txt | 3 +- cmake/O2PhysicsAddWorkflow.cmake | 60 ++++++++++++++++++++++++++------ 2 files changed, 52 insertions(+), 11 deletions(-) diff --git a/Tutorials/CMakeLists.txt b/Tutorials/CMakeLists.txt index e99e99b9d9d..61c55da5f8d 100644 --- a/Tutorials/CMakeLists.txt +++ b/Tutorials/CMakeLists.txt @@ -60,7 +60,8 @@ o2physics_add_dpl_workflow(dynamic-columns o2physics_add_dpl_workflow(histograms SOURCES src/histograms.cxx PUBLIC_LINK_LIBRARIES O2::Framework - COMPONENT_NAME AnalysisTutorial) + COMPONENT_NAME AnalysisTutorial + WORKFLOW_PLUGIN) o2physics_add_dpl_workflow(histograms-full-tracks SOURCES src/histogramsFullTracks.cxx diff --git a/cmake/O2PhysicsAddWorkflow.cmake b/cmake/O2PhysicsAddWorkflow.cmake index 6b8c46ef0da..8ba111087fb 100644 --- a/cmake/O2PhysicsAddWorkflow.cmake +++ b/cmake/O2PhysicsAddWorkflow.cmake @@ -25,27 +25,67 @@ include_guard() # The installed JSON file will be named .json and installed # under share/dpl directory # +# With WORKFLOW_PLUGIN, the sources are compiled into the DPL workflow plugin +# , in libO2PhysicsPlugin, which o2-dpl-run can load with +# --workflow-plugin, and the executable is only a main() linking it. is +# the CamelCase of the executable name without o2-. +# function(o2physics_add_dpl_workflow baseTargetName) - cmake_parse_arguments(PARSE_ARGV 1 A "" "COMPONENT_NAME;TARGETVARNAME;REUSE_FROM" + cmake_parse_arguments(PARSE_ARGV 1 A "WORKFLOW_PLUGIN" "COMPONENT_NAME;TARGETVARNAME;REUSE_FROM" "SOURCES;PUBLIC_LINK_LIBRARIES") if(A_UNPARSED_ARGUMENTS) message(FATAL_ERROR "Got trailing arguments ${A_UNPARSED_ARGUMENTS}") endif() - o2physics_add_executable(${baseTargetName} - COMPONENT_NAME ${A_COMPONENT_NAME} TARGETVARNAME targetExeName - SOURCES ${A_SOURCES} - PUBLIC_LINK_LIBRARIES O2::Framework ${A_PUBLIC_LINK_LIBRARIES}) + set(compileTarget "") + if(A_WORKFLOW_PLUGIN) + if(NOT TARGET O2PhysicsWorkflowMain) + file(CONFIGURE OUTPUT ${CMAKE_BINARY_DIR}/O2PhysicsWorkflowMain.cxx CONTENT [[ +extern "C" int dpl_workflow_main(int argc, char** argv); +int main(int argc, char** argv) { return dpl_workflow_main(argc, argv); } +]]) + add_library(O2PhysicsWorkflowMain OBJECT ${CMAKE_BINARY_DIR}/O2PhysicsWorkflowMain.cxx) + endif() + # Callers may pass JOB_POOL among the sources, for o2physics_add_executable. + cmake_parse_arguments(S "" "JOB_POOL" "" ${A_SOURCES}) + o2physics_add_executable(${baseTargetName} + COMPONENT_NAME ${A_COMPONENT_NAME} TARGETVARNAME targetExeName + SOURCES $ + PUBLIC_LINK_LIBRARIES O2::Framework ${A_PUBLIC_LINK_LIBRARIES}) + get_target_property(name ${targetExeName} OUTPUT_NAME) + string(REGEX REPLACE "^o2-" "" name ${name}) + string(REPLACE "-" ";" parts ${name}) + set(name "") + foreach(part IN LISTS parts) + string(SUBSTRING ${part} 0 1 first) + string(SUBSTRING ${part} 1 -1 rest) + string(TOUPPER ${first} first) + string(APPEND name ${first}${rest}) + endforeach() + string(MAKE_C_IDENTIFIER ${name} name) + set(compileTarget O2Physics${name}Plugin) + add_library(${compileTarget} SHARED ${S_UNPARSED_ARGUMENTS}) + target_link_libraries(${compileTarget} PUBLIC O2::Framework ${A_PUBLIC_LINK_LIBRARIES}) + target_compile_definitions(${compileTarget} PRIVATE DPL_WORKFLOW_PLUGIN_NAME=${name}) + target_link_libraries(${targetExeName} PUBLIC ${compileTarget}) + install(TARGETS ${compileTarget} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + else() + o2physics_add_executable(${baseTargetName} + COMPONENT_NAME ${A_COMPONENT_NAME} TARGETVARNAME targetExeName + SOURCES ${A_SOURCES} + PUBLIC_LINK_LIBRARIES O2::Framework ${A_PUBLIC_LINK_LIBRARIES}) + set(compileTarget ${targetExeName}) + endif() if(A_TARGETVARNAME) set(${A_TARGETVARNAME} ${targetExeName} PARENT_SCOPE) endif() - set_property(TARGET ${targetExeName} PROPERTY JOB_POOL_COMPILE analysis) - set_property(TARGET ${targetExeName} PROPERTY JOB_POOL_LINK analysis) + set_property(TARGET ${compileTarget} PROPERTY JOB_POOL_COMPILE analysis) + set_property(TARGET ${compileTarget} ${targetExeName} PROPERTY JOB_POOL_LINK analysis) # Reuse a precompiled header. Without an explicit REUSE_FROM, fall back to the # shared AnalysisPCH (Common/Core): a workflow translation unit spends most of @@ -63,7 +103,7 @@ function(o2physics_add_dpl_workflow baseTargetName) endif() # A target cannot reuse its own PCH, and the carrier is not built when recc # is caching compilations remotely instead. - if(_pch AND NOT _pch STREQUAL targetExeName AND NOT DEFINED ENV{USE_RECC}) + if(_pch AND NOT _pch STREQUAL compileTarget AND NOT DEFINED ENV{USE_RECC}) # GCC refuses a PCH built with a different preprocessor state than the # consumer's, and -Werror turns that refusal into a build failure: # cmake_pch.hxx.gch: not used because `RANS_ENABLE_JSON' not defined @@ -87,8 +127,8 @@ function(o2physics_add_dpl_workflow baseTargetName) # preprocessor state the carrier compiled with, and that state is exactly # what GCC compares, rather than one property of it at a time. # Requires CMake >= 3.27. - target_link_libraries(${targetExeName} PRIVATE $) - target_precompile_headers(${targetExeName} REUSE_FROM ${_pch}) + target_link_libraries(${compileTarget} PRIVATE $) + target_precompile_headers(${compileTarget} REUSE_FROM ${_pch}) endif() set(jsonFile $.json) From f650eea6617fd8946f3c6edb6448721bfa8b886c Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Fri, 6 Nov 2026 16:22:48 +0100 Subject: [PATCH 2/3] [Common] Build the common table producers as workflow plugins The table producers which most trains run first, for Run 3 and Run 2: the event selection services (timestamp, bc and event selection), the propagation services, track selection, the Run 2 track DCA filler, the track-to-collision associator, the mult/cent and FT0 corrected tables, the TPC and TOF PID tasks, and the converters run on Run 2 data. They are built with WORKFLOW_PLUGIN: same executables, with their code in a plugin o2-dpl-run can load. --- Common/TableProducer/CMakeLists.txt | 18 +++++++++--------- Common/TableProducer/Converters/CMakeLists.txt | 10 +++++----- Common/TableProducer/PID/CMakeLists.txt | 10 +++++----- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Common/TableProducer/CMakeLists.txt b/Common/TableProducer/CMakeLists.txt index d01f137f339..f11eb1b958b 100644 --- a/Common/TableProducer/CMakeLists.txt +++ b/Common/TableProducer/CMakeLists.txt @@ -20,24 +20,24 @@ o2physics_add_dpl_workflow(trackextension o2physics_add_dpl_workflow(trackselection SOURCES trackselection.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore - COMPONENT_NAME Analysis) + COMPONENT_NAME Analysis WORKFLOW_PLUGIN) o2physics_add_dpl_workflow(event-selection-service SOURCES eventSelectionService.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCCDB O2::DataFormatsITSMFT - COMPONENT_NAME Analysis) + COMPONENT_NAME Analysis WORKFLOW_PLUGIN) o2physics_add_dpl_workflow(event-selection-service-run2 SOURCES eventSelectionServiceRun2.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCCDB O2::DataFormatsITSMFT - COMPONENT_NAME Analysis) + COMPONENT_NAME Analysis WORKFLOW_PLUGIN) o2physics_add_dpl_workflow(multcenttable SOURCES multCentTable.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore - COMPONENT_NAME Analysis) + COMPONENT_NAME Analysis WORKFLOW_PLUGIN) o2physics_add_dpl_workflow(multiplicity-extra-table SOURCES multiplicityExtraTable.cxx @@ -52,12 +52,12 @@ o2physics_add_dpl_workflow(weak-decay-indices o2physics_add_dpl_workflow(ft0-corrected-table SOURCES ft0CorrectedTable.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore - COMPONENT_NAME Analysis) + COMPONENT_NAME Analysis WORKFLOW_PLUGIN) o2physics_add_dpl_workflow(propagationservice SOURCES propagationService.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter KFParticle::KFParticle O2Physics::TPCDriftManager - COMPONENT_NAME Analysis) + COMPONENT_NAME Analysis WORKFLOW_PLUGIN) o2physics_add_dpl_workflow(propagationservice-v2 SOURCES propagationServiceV2.cxx @@ -67,12 +67,12 @@ o2physics_add_dpl_workflow(propagationservice-v2 o2physics_add_dpl_workflow(propagationservice-run2 SOURCES propagationServiceRun2.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter KFParticle::KFParticle O2Physics::TPCDriftManager - COMPONENT_NAME Analysis) + COMPONENT_NAME Analysis WORKFLOW_PLUGIN) o2physics_add_dpl_workflow(track-dca-cov-filler-run2 SOURCES trackDcaCovFillerRun2.cxx PUBLIC_LINK_LIBRARIES O2::DetectorsBase O2Physics::AnalysisCore - COMPONENT_NAME Analysis) + COMPONENT_NAME Analysis WORKFLOW_PLUGIN) o2physics_add_dpl_workflow(calo-clusters SOURCES caloClusterProducer.cxx @@ -90,7 +90,7 @@ o2physics_add_dpl_workflow(fwdtrackextension o2physics_add_dpl_workflow(track-to-collision-associator SOURCES trackToCollisionAssociator.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore - COMPONENT_NAME Analysis) + COMPONENT_NAME Analysis WORKFLOW_PLUGIN) o2physics_add_dpl_workflow(fwdtrack-to-collision-associator SOURCES fwdtrackToCollisionAssociator.cxx diff --git a/Common/TableProducer/Converters/CMakeLists.txt b/Common/TableProducer/Converters/CMakeLists.txt index 600dfea3d9b..f999f2d77f6 100644 --- a/Common/TableProducer/Converters/CMakeLists.txt +++ b/Common/TableProducer/Converters/CMakeLists.txt @@ -27,7 +27,7 @@ o2physics_add_dpl_workflow(tracks-extra-converter o2physics_add_dpl_workflow(tracks-extra-v002-converter SOURCES tracksExtraV002Converter.cxx PUBLIC_LINK_LIBRARIES - COMPONENT_NAME Analysis) + COMPONENT_NAME Analysis WORKFLOW_PLUGIN) o2physics_add_dpl_workflow(mft-tracks-converter SOURCES mftTracksConverter.cxx @@ -42,7 +42,7 @@ o2physics_add_dpl_workflow(fdd-converter o2physics_add_dpl_workflow(collision-converter SOURCES collisionConverter.cxx PUBLIC_LINK_LIBRARIES - COMPONENT_NAME Analysis) + COMPONENT_NAME Analysis WORKFLOW_PLUGIN) o2physics_add_dpl_workflow(mccollision-converter SOURCES mcCollisionConverter.cxx @@ -52,7 +52,7 @@ o2physics_add_dpl_workflow(mccollision-converter o2physics_add_dpl_workflow(bc-converter SOURCES bcConverter.cxx PUBLIC_LINK_LIBRARIES O2::Framework - COMPONENT_NAME Analysis) + COMPONENT_NAME Analysis WORKFLOW_PLUGIN) o2physics_add_dpl_workflow(bc-flags-creator SOURCES bcFlagsCreator.cxx @@ -67,7 +67,7 @@ o2physics_add_dpl_workflow(calo-label-converter o2physics_add_dpl_workflow(zdc-converter SOURCES zdcConverter.cxx PUBLIC_LINK_LIBRARIES - COMPONENT_NAME Analysis) + COMPONENT_NAME Analysis WORKFLOW_PLUGIN) o2physics_add_dpl_workflow(hmpid-converter SOURCES hmpConverter.cxx @@ -102,7 +102,7 @@ o2physics_add_dpl_workflow(trackqa-converter-003 o2physics_add_dpl_workflow(run2bcinfos-converter SOURCES run2bcinfosConverter.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore - COMPONENT_NAME Analysis) + COMPONENT_NAME Analysis WORKFLOW_PLUGIN) o2physics_add_dpl_workflow(run2-tracks-extra-converter SOURCES run2tracksExtraConverter.cxx diff --git a/Common/TableProducer/PID/CMakeLists.txt b/Common/TableProducer/PID/CMakeLists.txt index 462abb408b1..bf322700d05 100644 --- a/Common/TableProducer/PID/CMakeLists.txt +++ b/Common/TableProducer/PID/CMakeLists.txt @@ -19,17 +19,17 @@ o2physics_add_dpl_workflow(pid-its o2physics_add_dpl_workflow(pid-tof-base SOURCES pidTOFBase.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::TOFBase - COMPONENT_NAME Analysis) + COMPONENT_NAME Analysis WORKFLOW_PLUGIN) o2physics_add_dpl_workflow(pid-tof SOURCES pidTOF.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::TOFWorkflowUtils - COMPONENT_NAME Analysis) + COMPONENT_NAME Analysis WORKFLOW_PLUGIN) o2physics_add_dpl_workflow(pid-tof-merge SOURCES pidTOFMerge.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::TOFWorkflowUtils - COMPONENT_NAME Analysis) + COMPONENT_NAME Analysis WORKFLOW_PLUGIN) o2physics_add_dpl_workflow(pid-tof-beta SOURCES pidTOFbeta.cxx @@ -46,12 +46,12 @@ o2physics_add_dpl_workflow(pid-tof-full o2physics_add_dpl_workflow(pid-tpc-service SOURCES pidTPCService.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore O2Physics::AnalysisCCDB - COMPONENT_NAME Analysis) + COMPONENT_NAME Analysis WORKFLOW_PLUGIN) o2physics_add_dpl_workflow(pid-tpc-service-run2 SOURCES pidTPCServiceRun2.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore O2Physics::AnalysisCCDB - COMPONENT_NAME Analysis) + COMPONENT_NAME Analysis WORKFLOW_PLUGIN) o2physics_add_dpl_workflow(pid-tpc-base SOURCES pidTPCBase.cxx From 8355e51e66e98742a1013da03c843530d6d769f1 Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Fri, 6 Nov 2026 16:22:49 +0100 Subject: [PATCH 3/3] [PWGCF,PWGLF] Build the Run 2 integration test tasks as workflow plugins The analysis tasks of the Run 2 integration test on LHC15o (cf correlations, TOF and tiny TPC spectra, and the full tracks histograms tutorial), built with WORKFLOW_PLUGIN like the common table producers they run with. --- PWGCF/Tasks/CMakeLists.txt | 2 +- PWGLF/Tasks/Nuspex/CMakeLists.txt | 4 ++-- Tutorials/CMakeLists.txt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/PWGCF/Tasks/CMakeLists.txt b/PWGCF/Tasks/CMakeLists.txt index 22e2b0f9f21..a39f0df452d 100644 --- a/PWGCF/Tasks/CMakeLists.txt +++ b/PWGCF/Tasks/CMakeLists.txt @@ -27,4 +27,4 @@ o2physics_add_dpl_workflow(match-reco-gen o2physics_add_dpl_workflow(correlations SOURCES correlations.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGCFCore - COMPONENT_NAME Analysis) + COMPONENT_NAME Analysis WORKFLOW_PLUGIN) diff --git a/PWGLF/Tasks/Nuspex/CMakeLists.txt b/PWGLF/Tasks/Nuspex/CMakeLists.txt index 43450b1a161..c75af757c4b 100644 --- a/PWGLF/Tasks/Nuspex/CMakeLists.txt +++ b/PWGLF/Tasks/Nuspex/CMakeLists.txt @@ -63,7 +63,7 @@ o2physics_add_dpl_workflow(spectra-tof-light o2physics_add_dpl_workflow(spectra-tof-run2 SOURCES spectraTOFRun2.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore - COMPONENT_NAME Analysis) + COMPONENT_NAME Analysis WORKFLOW_PLUGIN) o2physics_add_dpl_workflow(spectra-tpc SOURCES spectraTPC.cxx @@ -78,7 +78,7 @@ o2physics_add_dpl_workflow(spectra-tpc-pikapr o2physics_add_dpl_workflow(spectra-tpc-tiny SOURCES spectraTPCtiny.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore - COMPONENT_NAME Analysis) + COMPONENT_NAME Analysis WORKFLOW_PLUGIN) o2physics_add_dpl_workflow(nuclei-tpcspectra SOURCES nucleitpcPbPb.cxx diff --git a/Tutorials/CMakeLists.txt b/Tutorials/CMakeLists.txt index 61c55da5f8d..7d8525ebcaf 100644 --- a/Tutorials/CMakeLists.txt +++ b/Tutorials/CMakeLists.txt @@ -66,7 +66,7 @@ o2physics_add_dpl_workflow(histograms o2physics_add_dpl_workflow(histograms-full-tracks SOURCES src/histogramsFullTracks.cxx PUBLIC_LINK_LIBRARIES O2::Framework - COMPONENT_NAME AnalysisTutorial) + COMPONENT_NAME AnalysisTutorial WORKFLOW_PLUGIN) o2physics_add_dpl_workflow(filters SOURCES src/filters.cxx