From 65efb389c37b567708ff8d367bfb6377cac7b050 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Sun, 25 Jan 2026 16:20:10 +0100 Subject: [PATCH] first test to read hdf4/hdf5 directly. --- src/classes/PRunDataHandler.cpp | 40 ++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/src/classes/PRunDataHandler.cpp b/src/classes/PRunDataHandler.cpp index 1436a4d7..dafa1447 100644 --- a/src/classes/PRunDataHandler.cpp +++ b/src/classes/PRunDataHandler.cpp @@ -2139,18 +2139,32 @@ Bool_t PRunDataHandler::ReadNexusFile() #ifdef PNEXUS_ENABLED std::cout << std::endl << ">> PRunDataHandler::ReadNexusFile(): Will read nexus file " << fRunPathName.Data() << " ..."; - nxs::HDFType type = nxs::checkHDFType(fRunPathName.Data()); - switch (type) { - case nxs::HDFType::HDF4: - std::cout << std::endl << ">> PRunDataHandler::ReadNexusFile(): HDF4 file." << std::endl; - break; - case nxs::HDFType::HDF5: - std::cout << std::endl << ">> PRunDataHandler::ReadNexusFile(): HDF5 file." << std::endl; - break; - case nxs::HDFType::Unknown: - std::cerr << std::endl << ">> PRunDataHandler::ReadNexusFile(): Not a valid NeXus file." << std::endl; - return false; - } + nxs::HDFType type = nxs::checkHDFType(fRunPathName.Data()); + + // check for type errors, missing enabled HDF4 + switch (type) { + case nxs::HDFType::HDF4: + std::cout << std::endl << ">> PRunDataHandler::ReadNexusFile(): HDF4 file." << std::endl; +#ifndef HAVE_HDF4 + std::cerr << std::endl << ">> PRunDataHandler::ReadNexusFile(): **ERROR**, HDF4 is not enabled." << std::endl; + return false; +#endif + break; + case nxs::HDFType::HDF5: + std::cout << std::endl << ">> PRunDataHandler::ReadNexusFile(): HDF5 file." << std::endl; + break; + case nxs::HDFType::Unknown: + std::cerr << std::endl << ">> PRunDataHandler::ReadNexusFile(): Not a valid NeXus file." << std::endl; + return false; + } + + if (type == nxs::HDFType::HDF4) { +#ifdef HAVE_HDF4 + std::unique_ptr nxs_file = std::make_unique(fRunPathName.Data()); +#endif + } else { // HDF5 + std::unique_ptr nxs_file = std::make_unique(fRunPathName.Data()); + } /* //as35 PDoubleVector histoData; @@ -2159,7 +2173,7 @@ Bool_t PRunDataHandler::ReadNexusFile() TString str; std::string sstr; Double_t dval; - bool ok; + bool ok; std::unique_ptr nxs_file = std::make_unique(fRunPathName.Data()); if (!nxs_file->IsValid()) {