From ba0740d21c940a2e90169e271be95b9a71fadd56 Mon Sep 17 00:00:00 2001 From: Marco Giacalone Date: Thu, 21 Nov 2024 14:27:00 +0100 Subject: [PATCH] Fix for failing dataflow build Hybrid generator includes Pythia8, so when the dataflow build happens, without this fix, the Pythia8 header is loaded. It's not found due to the nature of the dataflow build. This fix prevents the Hybrid generator loading if Pythia8 is not found and it includes also HepMC3, given that a similar issue might arise with that generator as well in the future. --- Generators/CMakeLists.txt | 11 +++++++---- Generators/src/GeneratorFactory.cxx | 8 ++++++-- Generators/src/GeneratorsLinkDef.h | 6 ++++-- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Generators/CMakeLists.txt b/Generators/CMakeLists.txt index 3b32d076aec1a..d60d185817c84 100644 --- a/Generators/CMakeLists.txt +++ b/Generators/CMakeLists.txt @@ -24,8 +24,6 @@ o2_add_library(Generators src/GeneratorTGenerator.cxx src/GeneratorExternalParam.cxx src/GeneratorFromFile.cxx - src/GeneratorHybrid.cxx - src/GeneratorHybridParam.cxx src/GeneratorFromO2KineParam.cxx src/GeneratorFileOrCmd.cxx src/GeneratorFileOrCmdParam.cxx @@ -50,6 +48,8 @@ o2_add_library(Generators $<$:src/GeneratorHepMC.cxx> $<$:src/GeneratorHepMCParam.cxx> $<$:src/AODToHepMC.cxx> + $<$,$>:src/GeneratorHybrid.cxx> + $<$,$>:src/GeneratorHybridParam.cxx> PUBLIC_LINK_LIBRARIES FairRoot::Base O2::SimConfig O2::CommonUtils O2::DetectorsBase O2::ZDCBase O2::SimulationDataFormat ${pythiaTarget} ${hepmcTarget} FairRoot::Gen @@ -70,8 +70,6 @@ set(headers include/Generators/GeneratorTGenerator.h include/Generators/GeneratorExternalParam.h include/Generators/GeneratorFromFile.h - include/Generators/GeneratorHybrid.h - include/Generators/GeneratorHybridParam.h include/Generators/GeneratorFromO2KineParam.h include/Generators/GeneratorFileOrCmd.h include/Generators/GeneratorFileOrCmdParam.h @@ -104,6 +102,11 @@ if(HepMC3_FOUND) list(APPEND headers include/Generators/GeneratorHepMCParam.h) endif() +if(pythia_FOUND AND HepMC3_FOUND) + list(APPEND headers include/Generators/GeneratorHybrid.h) + list(APPEND headers include/Generators/GeneratorHybridParam.h) +endif() + o2_target_root_dictionary(Generators HEADERS ${headers}) o2_add_test_root_macro(share/external/extgen.C diff --git a/Generators/src/GeneratorFactory.cxx b/Generators/src/GeneratorFactory.cxx index 92be3773b54ee..8233024a4c2d7 100644 --- a/Generators/src/GeneratorFactory.cxx +++ b/Generators/src/GeneratorFactory.cxx @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #ifdef GENERATORS_WITH_PYTHIA8 @@ -27,12 +26,15 @@ #endif #include #include -#include #include "Generators/GeneratorFromO2KineParam.h" #ifdef GENERATORS_WITH_HEPMC3 #include #include #endif +#if defined(GENERATORS_WITH_PYTHIA8) && defined(GENERATORS_WITH_HEPMC3) +#include +#include +#endif #include #include #include @@ -260,6 +262,7 @@ void GeneratorFactory::setPrimaryGenerator(o2::conf::SimConfig const& conf, Fair primGen->AddGenerator(boxGen); } } +#if defined(GENERATORS_WITH_PYTHIA8) && defined(GENERATORS_WITH_HEPMC3) } else if (genconfig.compare("hybrid") == 0) { // hybrid using multiple generators LOG(info) << "Init hybrid generator"; auto& hybridparam = GeneratorHybridParam::Instance(); @@ -276,6 +279,7 @@ void GeneratorFactory::setPrimaryGenerator(o2::conf::SimConfig const& conf, Fair } auto hybrid = new o2::eventgen::GeneratorHybrid(config); primGen->AddGenerator(hybrid); +#endif } else { LOG(fatal) << "Invalid generator"; } diff --git a/Generators/src/GeneratorsLinkDef.h b/Generators/src/GeneratorsLinkDef.h index 18428a808a86b..41e14b02f18b9 100644 --- a/Generators/src/GeneratorsLinkDef.h +++ b/Generators/src/GeneratorsLinkDef.h @@ -52,10 +52,12 @@ #pragma link C++ class o2::conf::ConfigurableParamHelper < o2::eventgen::DecayerPythia8Param> + ; #pragma link C++ class o2::eventgen::GeneratorFactory + ; #endif -#pragma link C++ class o2::eventgen::GeneratorFromFile + ; -#pragma link C++ class o2::eventgen::GeneratorFromO2Kine + ; +#if defined(GENERATORS_WITH_PYTHIA8) && defined(GENERATORS_WITH_HEPMC3) #pragma link C++ class o2::eventgen::GeneratorHybrid + ; #pragma link C++ class o2::eventgen::GeneratorHybridParam + ; +#endif +#pragma link C++ class o2::eventgen::GeneratorFromFile + ; +#pragma link C++ class o2::eventgen::GeneratorFromO2Kine + ; #pragma link C++ class o2::eventgen::GeneratorFromO2KineParam + ; #pragma link C++ class o2::eventgen::O2KineGenConfig + ; #pragma link C++ class o2::conf::ConfigurableParamHelper < o2::eventgen::GeneratorFromO2KineParam> + ;