From 9a9c36bfd9c80c21f9f3a93a260076ecb836ef68 Mon Sep 17 00:00:00 2001 From: Marco Giacalone Date: Wed, 17 Dec 2025 14:17:57 +0100 Subject: [PATCH] Moved configFile check + expand env vars --- Generators/src/GeneratorFactory.cxx | 5 ----- Generators/src/GeneratorHybrid.cxx | 12 +++++++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Generators/src/GeneratorFactory.cxx b/Generators/src/GeneratorFactory.cxx index 4102bd8ffd9b2..d04e785402915 100644 --- a/Generators/src/GeneratorFactory.cxx +++ b/Generators/src/GeneratorFactory.cxx @@ -279,11 +279,6 @@ void GeneratorFactory::setPrimaryGenerator(o2::conf::SimConfig const& conf, Fair LOG(fatal) << "No configuration file provided for hybrid generator"; return; } - // check if file named config exists and it's not empty - else if (gSystem->AccessPathName(config.c_str())) { - LOG(fatal) << "Configuration file for hybrid generator does not exist"; - return; - } auto& hybrid = o2::eventgen::GeneratorHybrid::Instance(config); primGen->AddGenerator(&hybrid); #endif diff --git a/Generators/src/GeneratorHybrid.cxx b/Generators/src/GeneratorHybrid.cxx index 370671a977a5c..2a13f9876e717 100644 --- a/Generators/src/GeneratorHybrid.cxx +++ b/Generators/src/GeneratorHybrid.cxx @@ -615,17 +615,23 @@ Bool_t GeneratorHybrid::confSetter(const auto& gen) Bool_t GeneratorHybrid::parseJSON(const std::string& path) { + auto expandedPath = o2::utils::expandShellVarsInFileName(path); + // Check if configuration file exists + if (gSystem->AccessPathName(expandedPath.c_str())) { + LOG(fatal) << "Configuration file " << expandedPath << " for hybrid generator does not exist"; + return false; + } // Parse JSON file to build map - std::ifstream fileStream(path, std::ios::in); + std::ifstream fileStream(expandedPath, std::ios::in); if (!fileStream.is_open()) { - LOG(error) << "Cannot open " << path; + LOG(error) << "Cannot open " << expandedPath; return false; } rapidjson::IStreamWrapper isw(fileStream); rapidjson::Document doc; doc.ParseStream(isw); if (doc.HasParseError()) { - LOG(error) << "Error parsing provided json file " << path; + LOG(error) << "Error parsing provided json file " << expandedPath; LOG(error) << " - Error -> " << rapidjson::GetParseError_En(doc.GetParseError()); return false; }