From 79b05cced787f86c46b78ae46aaac51fd7d38abb Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Sat, 21 Feb 2026 07:44:20 +0100 Subject: [PATCH] adopted the PNeXus lib such that the class naming scheme is self-consistent. --- src/classes/PRunDataHandler.cpp | 92 +++++++------- src/external/nexus/PNeXus.cpp | 208 ++++++++++++++++---------------- src/external/nexus/PNeXus.h | 68 +++++------ 3 files changed, 184 insertions(+), 184 deletions(-) diff --git a/src/classes/PRunDataHandler.cpp b/src/classes/PRunDataHandler.cpp index b2c888b9c..5131dd1c9 100644 --- a/src/classes/PRunDataHandler.cpp +++ b/src/classes/PRunDataHandler.cpp @@ -4841,10 +4841,10 @@ Bool_t PRunDataHandler::WriteNexusFile(TString format, TString fln) if (fAny2ManyInfo->idf == 1) { // IDF V1 // set IDF version - nxs->AddDataset("/run/IDF_version", {(int)fAny2ManyInfo->idf}, {1}, nxH4::H4DataType::INT32); + nxs->AddDataset("/run/IDF_version", {(int)fAny2ManyInfo->idf}, {1}, nxH4::H4DataType::kINT32); // set program name - nxs->AddDataset("/run/program_name", {"any2many"}, {1}, nxH4::H4DataType::CHAR8); + nxs->AddDataset("/run/program_name", {"any2many"}, {1}, nxH4::H4DataType::kCHAR8); str="n/a"; #ifdef HAVE_CONFIG_H str = PACKAGE_VERSION; @@ -4852,74 +4852,74 @@ Bool_t PRunDataHandler::WriteNexusFile(TString format, TString fln) nxs->AddDatasetAttribute("/run/program_name", "version", str); // set run number - nxs->AddDataset("/run/number", {fData[0].GetRunNumber()}, {1}, nxH4::H4DataType::INT32); + nxs->AddDataset("/run/number", {fData[0].GetRunNumber()}, {1}, nxH4::H4DataType::kINT32); // set title - nxs->AddDataset("/run/title", {fData[0].GetRunTitle()->Data()}, {1}, nxH4::H4DataType::CHAR8); + nxs->AddDataset("/run/title", {fData[0].GetRunTitle()->Data()}, {1}, nxH4::H4DataType::kCHAR8); // set notes - nxs->AddDataset("/run/notes", {std::string("n/a")}, {1}, nxH4::H4DataType::CHAR8); + nxs->AddDataset("/run/notes", {std::string("n/a")}, {1}, nxH4::H4DataType::kCHAR8); // set analysis - nxs->AddDataset("/run/analysis", {std::string("muonTD")}, {1}, nxH4::H4DataType::CHAR8); + nxs->AddDataset("/run/analysis", {std::string("muonTD")}, {1}, nxH4::H4DataType::kCHAR8); // set lab str = *fData[0].GetLaboratory(); - nxs->AddDataset("/run/lab", {str}, {1}, nxH4::H4DataType::CHAR8); + nxs->AddDataset("/run/lab", {str}, {1}, nxH4::H4DataType::kCHAR8); // set beamline str = *fData[0].GetBeamline(); - nxs->AddDataset("/run/beamline", {str}, {1}, nxH4::H4DataType::CHAR8); + nxs->AddDataset("/run/beamline", {str}, {1}, nxH4::H4DataType::kCHAR8); // set start time str = std::string(fData[0].GetStartDate()->Data()) + std::string("T") + std::string(fData[0].GetStartTime()->Data()); - nxs->AddDataset("/run/start_time", {str}, {1}, nxH4::H4DataType::CHAR8); + nxs->AddDataset("/run/start_time", {str}, {1}, nxH4::H4DataType::kCHAR8); // set stop time str = std::string(fData[0].GetStopDate()->Data()) + std::string("T") + std::string(fData[0].GetStopTime()->Data()); - nxs->AddDataset("/run/stop_time", {str}, {1}, nxH4::H4DataType::CHAR8); + nxs->AddDataset("/run/stop_time", {str}, {1}, nxH4::H4DataType::kCHAR8); // set switching state - nxs->AddDataset("/run/switching_states", {1}, {1}, nxH4::H4DataType::INT32); + nxs->AddDataset("/run/switching_states", {1}, {1}, nxH4::H4DataType::kINT32); // set user name - nxs->AddDataset("/run/user/name", {std::string("n/a")}, {1}, nxH4::H4DataType::CHAR8); + nxs->AddDataset("/run/user/name", {std::string("n/a")}, {1}, nxH4::H4DataType::kCHAR8); // set user experiment_number - nxs->AddDataset("/run/user/experiment_number", {std::string("n/a")}, {1}, nxH4::H4DataType::CHAR8); + nxs->AddDataset("/run/user/experiment_number", {std::string("n/a")}, {1}, nxH4::H4DataType::kCHAR8); // set sample name - nxs->AddDataset("/run/sample/name", {fData[0].GetSample()->Data()}, {1}, nxH4::H4DataType::CHAR8); + nxs->AddDataset("/run/sample/name", {fData[0].GetSample()->Data()}, {1}, nxH4::H4DataType::kCHAR8); // set sample temperature - nxs->AddDataset("/run/sample/temperature", {(float)fData[0].GetTemperature(0)}, {1}, nxH4::H4DataType::FLOAT32); + nxs->AddDataset("/run/sample/temperature", {(float)fData[0].GetTemperature(0)}, {1}, nxH4::H4DataType::kFLOAT32); nxs->AddDatasetAttribute("/run/sample/temperature", "units", std::string("Kelvin")); // set magnetic field - nxs->AddDataset("/run/sample/magnetic_field", {(float)fData[0].GetField()}, {1}, nxH4::H4DataType::FLOAT32); + nxs->AddDataset("/run/sample/magnetic_field", {(float)fData[0].GetField()}, {1}, nxH4::H4DataType::kFLOAT32); nxs->AddDatasetAttribute("/run/sample/magnetic_field", "units", std::string("Gauss")); // set sample environment - nxs->AddDataset("/run/sample/environment", {fData[0].GetSetup()->Data()}, {1}, nxH4::H4DataType::CHAR8); + nxs->AddDataset("/run/sample/environment", {fData[0].GetSetup()->Data()}, {1}, nxH4::H4DataType::kCHAR8); // set sample shape - nxs->AddDataset("/run/sample/shape", {std::string("n/a")}, {1}, nxH4::H4DataType::CHAR8); + nxs->AddDataset("/run/sample/shape", {std::string("n/a")}, {1}, nxH4::H4DataType::kCHAR8); // set magnetic field vector - nxs->AddDataset("/run/sample/magnetic_field_vector", {1.0f, 1.0f, 1.0f}, {3}, nxH4::H4DataType::FLOAT32); + nxs->AddDataset("/run/sample/magnetic_field_vector", {1.0f, 1.0f, 1.0f}, {3}, nxH4::H4DataType::kFLOAT32); nxs->AddDatasetAttribute("/run/sample/magnetic_field_vector", "coordinate_system", std::string("cartesian")); nxs->AddDatasetAttribute("/run/sample/magnetic_field_vector", "units", std::string("Gauss")); nxs->AddDatasetAttribute("/run/sample/magnetic_field_vector", "available", 0); // set instrument name str = *fData[0].GetInstrument(); - nxs->AddDataset("/run/instrument/name", {str}, {1}, nxH4::H4DataType::CHAR8); + nxs->AddDataset("/run/instrument/name", {str}, {1}, nxH4::H4DataType::kCHAR8); // set instrument number of detectors - nxs->AddDataset("/run/instrument/detector/number", {(int)fData[0].GetNoOfHistos()}, {1}, nxH4::H4DataType::INT32); + nxs->AddDataset("/run/instrument/detector/number", {(int)fData[0].GetNoOfHistos()}, {1}, nxH4::H4DataType::kINT32); // set instrument collimator - nxs->AddDataset("/run/instrument/collimator/type", {std::string("n/a")}, {1}, nxH4::H4DataType::CHAR8); + nxs->AddDataset("/run/instrument/collimator/type", {std::string("n/a")}, {1}, nxH4::H4DataType::kCHAR8); // set instrument beam total number of counts in Mev // calculate the total number of counts @@ -4936,16 +4936,16 @@ Bool_t PRunDataHandler::WriteNexusFile(TString format, TString fln) total_counts += dataSet->GetData()->at(j); } float total_counts_mev = (float) total_counts / 1.0e6; - nxs->AddDataset("/run/instrument/beam/total_counts", {total_counts_mev}, {1}, nxH4::H4DataType::FLOAT32); + nxs->AddDataset("/run/instrument/beam/total_counts", {total_counts_mev}, {1}, nxH4::H4DataType::kFLOAT32); nxs->AddDatasetAttribute("/run/instrument/beam/total_counts", "units", std::string("MEv")); // set time resolution (use FLOAT instead of INT) float res = (float)(fData[0].GetTimeResolution()*fAny2ManyInfo->rebin*1.0e3); - nxs->AddDataset("/run/histogram_data_1/resolution", {res}, {1}, nxH4::H4DataType::FLOAT32); + nxs->AddDataset("/run/histogram_data_1/resolution", {res}, {1}, nxH4::H4DataType::kFLOAT32); nxs->AddDatasetAttribute("/run/histogram_data_1/resolution", "units", std::string("picoseconds")); // set time zero time to 0. see t0_bin attribute of counts! - nxs->AddDataset("/run/histogram_data_1/time_zero", {0}, {1}, nxH4::H4DataType::INT32); + nxs->AddDataset("/run/histogram_data_1/time_zero", {0}, {1}, nxH4::H4DataType::kINT32); nxs->AddDatasetAttribute("/run/histogram_data_1/time_zero", "units", std::string("microseconds")); nxs->AddDatasetAttribute("/run/histogram_data_1/time_zero", "available", 0); @@ -4956,26 +4956,26 @@ Bool_t PRunDataHandler::WriteNexusFile(TString format, TString fln) std::vector time; for (unsigned int i=0; iAddDataset("/run/histogram_data_1/raw_time", time, {length}, nxH4::H4DataType::FLOAT32); + nxs->AddDataset("/run/histogram_data_1/raw_time", time, {length}, nxH4::H4DataType::kFLOAT32); nxs->AddDatasetAttribute("/run/histogram_data_1/raw_time", "axis", 1); nxs->AddDatasetAttribute("/run/histogram_data_1/raw_time", "primary", 0); nxs->AddDatasetAttribute("/run/histogram_data_1/raw_time", "units", std::string("microseconds")); nxs->AddDatasetAttribute("/run/histogram_data_1/raw_time", "available", 0); // set corrected_time - nxs->AddDataset("/run/histogram_data_1/corrected_time", time, {length}, nxH4::H4DataType::FLOAT32); + nxs->AddDataset("/run/histogram_data_1/corrected_time", time, {length}, nxH4::H4DataType::kFLOAT32); nxs->AddDatasetAttribute("/run/histogram_data_1/corrected_time", "axis", 1); nxs->AddDatasetAttribute("/run/histogram_data_1/corrected_time", "units", std::string("microseconds")); nxs->AddDatasetAttribute("/run/histogram_data_1/corrected_time", "available", 0); // set grouping std::vector grouping(fData[0].GetNoOfHistos(), 0); - nxs->AddDataset("/run/histogram_data_1/grouping", grouping, {(uint32_t)grouping.size()}, nxH4::H4DataType::INT32); + nxs->AddDataset("/run/histogram_data_1/grouping", grouping, {(uint32_t)grouping.size()}, nxH4::H4DataType::kINT32); nxs->AddDatasetAttribute("/run/histogram_data_1/grouping", "avaliabe", 0); // set alpha int ival=1; - nxs->AddDataset("/run/histogram_data_1/alpha", {ival}, {1}, nxH4::H4DataType::INT32); + nxs->AddDataset("/run/histogram_data_1/alpha", {ival}, {1}, nxH4::H4DataType::kINT32); nxs->AddDatasetAttribute("/run/histogram_data_1/alpha", "avaliabe", 0); // set counts @@ -5022,7 +5022,7 @@ Bool_t PRunDataHandler::WriteNexusFile(TString format, TString fln) } size = dataCount; } - nxs->AddDataset("/run/histogram_data_1/counts", data, {(uint32_t)noHisto, (uint32_t)size}, nxH4::H4DataType::INT32); + nxs->AddDataset("/run/histogram_data_1/counts", data, {(uint32_t)noHisto, (uint32_t)size}, nxH4::H4DataType::kINT32); nxs->AddDatasetAttribute("/run/histogram_data_1/counts", "units", std::string("counts")); nxs->AddDatasetAttribute("/run/histogram_data_1/counts", "signal", 1); nxs->AddDatasetAttribute("/run/histogram_data_1/counts", "number", noHisto); @@ -5036,48 +5036,48 @@ Bool_t PRunDataHandler::WriteNexusFile(TString format, TString fln) nxs->AddGroupAttribute("/raw_data_1", "NX_class", std::string("NXentry")); // set IDF version - nxs->AddDataset("/raw_data_1/IDF_version", {(int)fAny2ManyInfo->idf}, {1}, nxH4::H4DataType::INT32); + nxs->AddDataset("/raw_data_1/IDF_version", {(int)fAny2ManyInfo->idf}, {1}, nxH4::H4DataType::kINT32); // set beamline str = *fData[0].GetBeamline(); - nxs->AddDataset("/raw_data_1/beamline", {str}, {1}, nxH4::H4DataType::CHAR8); + nxs->AddDataset("/raw_data_1/beamline", {str}, {1}, nxH4::H4DataType::kCHAR8); // set definition - nxs->AddDataset("/raw_data_1/definition", {std::string("muonTD")}, {1}, nxH4::H4DataType::CHAR8); + nxs->AddDataset("/raw_data_1/definition", {std::string("muonTD")}, {1}, nxH4::H4DataType::kCHAR8); // set run_number - nxs->AddDataset("/raw_data_1/run_number", {fData[0].GetRunNumber()}, {1}, nxH4::H4DataType::INT32); + nxs->AddDataset("/raw_data_1/run_number", {fData[0].GetRunNumber()}, {1}, nxH4::H4DataType::kINT32); // set title - nxs->AddDataset("/raw_data_1/title", {fData[0].GetRunTitle()->Data()}, {1}, nxH4::H4DataType::CHAR8); + nxs->AddDataset("/raw_data_1/title", {fData[0].GetRunTitle()->Data()}, {1}, nxH4::H4DataType::kCHAR8); // set start time str = std::string(fData[0].GetStartDate()->Data()) + std::string("T") + std::string(fData[0].GetStartTime()->Data()); - nxs->AddDataset("/raw_data_1/start_time", {str}, {1}, nxH4::H4DataType::CHAR8); + nxs->AddDataset("/raw_data_1/start_time", {str}, {1}, nxH4::H4DataType::kCHAR8); nxs->AddDatasetAttribute("/raw_data_1/start_time", "units", "ISO8601"); // set end time str = std::string(fData[0].GetStopDate()->Data()) + std::string("T") + std::string(fData[0].GetStopTime()->Data()); - nxs->AddDataset("/raw_data_1/end_time", {str}, {1}, nxH4::H4DataType::CHAR8); + nxs->AddDataset("/raw_data_1/end_time", {str}, {1}, nxH4::H4DataType::kCHAR8); nxs->AddDatasetAttribute("/raw_data_1/end_time", "units", "ISO8601"); // set experiment_identifier str = "n/a"; - nxs->AddDataset("/raw_data_1/experiment_identifier", {str}, {1}, nxH4::H4DataType::CHAR8); + nxs->AddDataset("/raw_data_1/experiment_identifier", {str}, {1}, nxH4::H4DataType::kCHAR8); // set instrument attribute nxs->AddGroupAttribute("/raw_data_1/instrument", "NX_class", std::string("NXinstrument")); // set instrument name str = *fData[0].GetInstrument(); - nxs->AddDataset("/raw_data_1/instrument/name", {str}, {1}, nxH4::H4DataType::CHAR8); + nxs->AddDataset("/raw_data_1/instrument/name", {str}, {1}, nxH4::H4DataType::kCHAR8); // set instrument/source attribute nxs->AddGroupAttribute("/raw_data_1/instrument/source", "NX_class", std::string("NXsource")); // set instrument/source/name str = fData[0].GetLaboratory()->Data(); - nxs->AddDataset("/raw_data_1/instrument/source/name", {str}, {1}, nxH4::H4DataType::CHAR8); + nxs->AddDataset("/raw_data_1/instrument/source/name", {str}, {1}, nxH4::H4DataType::kCHAR8); // set instrument/source/type TString tstr = *fData[0].GetInstrument(); @@ -5093,11 +5093,11 @@ Bool_t PRunDataHandler::WriteNexusFile(TString format, TString fln) tstr.Contains("HIFI", TString::kIgnoreCase)) { type = "pulsed muon source"; } - nxs->AddDataset("/raw_data_1/instrument/source/type", {type}, {1}, nxH4::H4DataType::CHAR8); + nxs->AddDataset("/raw_data_1/instrument/source/type", {type}, {1}, nxH4::H4DataType::kCHAR8); // set instrument/source/probe str = "positive muons"; - nxs->AddDataset("/raw_data_1/instrument/source/probe", {str}, {1}, nxH4::H4DataType::CHAR8); + nxs->AddDataset("/raw_data_1/instrument/source/probe", {str}, {1}, nxH4::H4DataType::kCHAR8); // set instrument/detector info nxs->AddGroupAttribute("/raw_data_1/instrument/detector_1", "NX_class", std::string("NXdetector")); @@ -5107,11 +5107,11 @@ Bool_t PRunDataHandler::WriteNexusFile(TString format, TString fln) std::vector spectrum_index(noHistos); for (unsigned int i=0; iAddDataset("/raw_data_1/instrument/detector_1/spectrum_index", spectrum_index, {(uint32_t)spectrum_index.size()}, nxH4::H4DataType::INT32); + nxs->AddDataset("/raw_data_1/instrument/detector_1/spectrum_index", spectrum_index, {(uint32_t)spectrum_index.size()}, nxH4::H4DataType::kINT32); // set instrument/detector/raw_time (not useful for quasi-continuous sources) int ival=0; - nxs->AddDataset("/raw_data_1/instrument/detector_1/raw_time", {ival}, {1}, nxH4::H4DataType::INT32); + nxs->AddDataset("/raw_data_1/instrument/detector_1/raw_time", {ival}, {1}, nxH4::H4DataType::kINT32); nxs->AddDatasetAttribute("/raw_data_1/instrument/detector_1/raw_time", "available", 0); // set instrument/detector/counts @@ -5160,7 +5160,7 @@ Bool_t PRunDataHandler::WriteNexusFile(TString format, TString fln) } size = dataCount; } - nxs->AddDataset("/raw_data_1/instrument/detector_1/counts", data, {(uint32_t)noHisto, (uint32_t)size}, nxH4::H4DataType::INT32); + nxs->AddDataset("/raw_data_1/instrument/detector_1/counts", data, {(uint32_t)noHisto, (uint32_t)size}, nxH4::H4DataType::kINT32); nxs->AddDatasetAttribute("/raw_data_1/instrument/detector_1/counts", "axes", std::string("spectrum_index,time_bin")); nxs->AddDatasetAttribute("/raw_data_1/instrument/detector_1/counts", "long_name", std::string("positon counts")); nxs->AddDatasetAttribute("/raw_data_1/instrument/detector_1/counts", "signal", 1); @@ -5175,7 +5175,7 @@ Bool_t PRunDataHandler::WriteNexusFile(TString format, TString fln) nxs->AddGroupAttribute("/raw_data_1/detector_1", "NX_class", std::string("NXdata")); // set detector/counts - nxs->AddDataset("/raw_data_1/detector_1/counts", data, {(uint32_t)noHisto, (uint32_t)size}, nxH4::H4DataType::INT32); + nxs->AddDataset("/raw_data_1/detector_1/counts", data, {(uint32_t)noHisto, (uint32_t)size}, nxH4::H4DataType::kINT32); nxs->AddDatasetAttribute("/raw_data_1/detector_1/counts", "axes", std::string("spectrum_index,time_bin")); nxs->AddDatasetAttribute("/raw_data_1/detector_1/counts", "long_name", std::string("positon counts")); nxs->AddDatasetAttribute("/raw_data_1/detector_1/counts", "signal", 1); diff --git a/src/external/nexus/PNeXus.cpp b/src/external/nexus/PNeXus.cpp index 9b0c588fa..77b319819 100644 --- a/src/external/nexus/PNeXus.cpp +++ b/src/external/nexus/PNeXus.cpp @@ -297,7 +297,7 @@ double nxH4::PNeXusDeadTime::operator()(const std::vector &par) const //============================================================================= // PNeXusDeadTime::minimize //============================================================================= -void nxH4::PNeXusDeadTime::minimize(const int i) +void nxH4::PNeXusDeadTime::Minimize(const int i) { if (i < 0 || i >= static_cast(fDims[1])) { std::cerr << "**ERROR** Invalid spectrum index: " << i << std::endl; @@ -404,23 +404,23 @@ int nxH4::PNeXus::ReadNexusFile() continue; } - if (caseInsensitiveEquals(attr_name, "HDF_version") || - caseInsensitiveEquals(attr_name, "HDF4_version")) { + if (CaseInsensitiveEquals(attr_name, "HDF_version") || + CaseInsensitiveEquals(attr_name, "HDF4_version")) { std::vector buffer(attr_count + 1, '\0'); if (SDreadattr(fSdId, i, buffer.data()) != FAIL) { fHdf4Version = std::string(buffer.data()); } - } else if (caseInsensitiveEquals(attr_name, "NeXus_version")) { + } else if (CaseInsensitiveEquals(attr_name, "NeXus_version")) { std::vector buffer(attr_count + 1, '\0'); if (SDreadattr(fSdId, i, buffer.data()) != FAIL) { fNeXusVersion = std::string(buffer.data()); } - } else if (caseInsensitiveEquals(attr_name, "file_name")) { + } else if (CaseInsensitiveEquals(attr_name, "file_name")) { std::vector buffer(attr_count + 1, '\0'); if (SDreadattr(fSdId, i, buffer.data()) != FAIL) { fFileNameNxs = std::string(buffer.data()); } - } else if (caseInsensitiveEquals(attr_name, "file_time")) { + } else if (CaseInsensitiveEquals(attr_name, "file_time")) { std::vector buffer(attr_count + 1, '\0'); if (SDreadattr(fSdId, i, buffer.data()) != FAIL) { fFileTimeNxs = std::string(buffer.data()); @@ -455,7 +455,7 @@ int nxH4::PNeXus::ReadNexusFile() // If not found, try /run/IDF_version (IDF version 1 location) if (fIdfVersion == -1) { try { - int32 sds_ref = findDatasetRefByPath("/run/IDF_version"); + int32 sds_ref = FindDatasetRefByPath("/run/IDF_version"); if (sds_ref != -1) { int32 sds_idx = SDreftoindex(fSdId, sds_ref); if (sds_idx != FAIL) { @@ -485,7 +485,7 @@ int nxH4::PNeXus::ReadNexusFile() // If still not found, try /raw_data_1/idf_version (IDF version 2 location) if (fIdfVersion == -1) { try { - int32 sds_ref = findDatasetRefByPath("/raw_data_1/idf_version"); + int32 sds_ref = FindDatasetRefByPath("/raw_data_1/idf_version"); if (sds_ref != -1) { int32 sds_idx = SDreftoindex(fSdId, sds_ref); if (sds_idx != FAIL) { @@ -690,7 +690,7 @@ void nxH4::PNeXus::HandleIdfV2(int32 sd_id) void nxH4::PNeXus::ReadIntDataset(int32 sd_id, const std::string& path) { // Extract dataset name from path - std::vector components = splitPath(path); + std::vector components = SplitPath(path); if (components.empty()) { throw std::runtime_error("Invalid path: " + path); } @@ -700,7 +700,7 @@ void nxH4::PNeXus::ReadIntDataset(int32 sd_id, const std::string& path) int32 sds_ref = -1; if (components.size() > 1) { // Try to resolve via VGroup hierarchy - sds_ref = findDatasetRefByPath(path); + sds_ref = FindDatasetRefByPath(path); } int32 sds_idx = -1; @@ -711,7 +711,7 @@ void nxH4::PNeXus::ReadIntDataset(int32 sd_id, const std::string& path) // Fallback to name-based search if VGroup navigation failed if (sds_idx == FAIL || sds_idx == -1) { - sds_idx = findDatasetIndex(sd_id, dataset_name); + sds_idx = FindDatasetIndex(sd_id, dataset_name); } int32 sds_id = SDselect(sd_id, sds_idx); @@ -747,7 +747,7 @@ void nxH4::PNeXus::ReadIntDataset(int32 sd_id, const std::string& path) std::vector int_data(data.begin(), data.end()); // Create PNXdata object - PNXdata pnx_data(H4DataType::INT32); + PNXdata pnx_data(H4DataType::kINT32); pnx_data.SetData(int_data); pnx_data.SetDimensions(dimensions); @@ -766,7 +766,7 @@ void nxH4::PNeXus::ReadIntDataset(int32 sd_id, const std::string& path) void nxH4::PNeXus::ReadFloatDataset(int32 sd_id, const std::string& path) { // Extract dataset name from path - std::vector components = splitPath(path); + std::vector components = SplitPath(path); if (components.empty()) { throw std::runtime_error("Invalid path: " + path); } @@ -776,7 +776,7 @@ void nxH4::PNeXus::ReadFloatDataset(int32 sd_id, const std::string& path) int32 sds_ref = -1; if (components.size() > 1) { // Try to resolve via VGroup hierarchy - sds_ref = findDatasetRefByPath(path); + sds_ref = FindDatasetRefByPath(path); } int32 sds_idx = -1; @@ -787,7 +787,7 @@ void nxH4::PNeXus::ReadFloatDataset(int32 sd_id, const std::string& path) // Fallback to name-based search if VGroup navigation failed if (sds_idx == FAIL || sds_idx == -1) { - sds_idx = findDatasetIndex(sd_id, dataset_name); + sds_idx = FindDatasetIndex(sd_id, dataset_name); } int32 sds_id = SDselect(sd_id, sds_idx); @@ -823,7 +823,7 @@ void nxH4::PNeXus::ReadFloatDataset(int32 sd_id, const std::string& path) std::vector float_data(data.begin(), data.end()); // Create PNXdata object - PNXdata pnx_data(H4DataType::FLOAT32); + PNXdata pnx_data(H4DataType::kFLOAT32); pnx_data.SetData(float_data); pnx_data.SetDimensions(dimensions); @@ -842,7 +842,7 @@ void nxH4::PNeXus::ReadFloatDataset(int32 sd_id, const std::string& path) void nxH4::PNeXus::ReadStringDataset(int32 sd_id, const std::string& path) { // Extract dataset name from path - std::vector components = splitPath(path); + std::vector components = SplitPath(path); if (components.empty()) { throw std::runtime_error("Invalid path: " + path); } @@ -852,7 +852,7 @@ void nxH4::PNeXus::ReadStringDataset(int32 sd_id, const std::string& path) int32 sds_ref = -1; if (components.size() > 1) { // Try to resolve via VGroup hierarchy - sds_ref = findDatasetRefByPath(path); + sds_ref = FindDatasetRefByPath(path); } int32 sds_idx = -1; @@ -863,7 +863,7 @@ void nxH4::PNeXus::ReadStringDataset(int32 sd_id, const std::string& path) // Fallback to name-based search if VGroup navigation failed if (sds_idx == FAIL || sds_idx == -1) { - sds_idx = findDatasetIndex(sd_id, dataset_name); + sds_idx = FindDatasetIndex(sd_id, dataset_name); } int32 sds_id = SDselect(sd_id, sds_idx); @@ -900,7 +900,7 @@ void nxH4::PNeXus::ReadStringDataset(int32 sd_id, const std::string& path) string_data.push_back(std::string(data.data())); // Create PNXdata object - PNXdata pnx_data(H4DataType::CHAR8); + PNXdata pnx_data(H4DataType::kCHAR8); pnx_data.SetData(string_data); pnx_data.SetDimensions(dimensions); @@ -2125,7 +2125,7 @@ int32 nxH4::PNeXus::WriteIntDataset(int32 sd_id, const std::string& path, const PNXdata& data) { // Extract dataset name from path - std::vector components = splitPath(path); + std::vector components = SplitPath(path); if (components.empty()) { throw std::runtime_error("Invalid path: " + path); } @@ -2173,7 +2173,7 @@ int32 nxH4::PNeXus::WriteFloatDataset(int32 sd_id, const std::string& path, const PNXdata& data) { // Extract dataset name from path - std::vector components = splitPath(path); + std::vector components = SplitPath(path); if (components.empty()) { throw std::runtime_error("Invalid path: " + path); } @@ -2221,7 +2221,7 @@ int32 nxH4::PNeXus::WriteStringDataset(int32 sd_id, const std::string& path, const PNXdata& data) { // Extract dataset name from path - std::vector components = splitPath(path); + std::vector components = SplitPath(path); if (components.empty()) { throw std::runtime_error("Invalid path: " + path); } @@ -2365,7 +2365,7 @@ void nxH4::PNeXus::WriteVGroupAttributes(int32 vgroup_id, int32 nxH4::PNeXus::CreateVGroupHierarchy(int32 file_id, const std::string& path, std::map& vgroupCache) { - std::vector components = splitPath(path); + std::vector components = SplitPath(path); if (components.empty()) { return -1; } @@ -2513,7 +2513,7 @@ bool nxH4::PNeXus::AddRootAttribute(const std::string& attrName, const std::any& //============================================================================= // Helper methods //============================================================================= -bool nxH4::PNeXus::caseInsensitiveEquals(const std::string& a, const std::string& b) +bool nxH4::PNeXus::CaseInsensitiveEquals(const std::string& a, const std::string& b) { if (a.length() != b.length()) { return false; @@ -2525,7 +2525,7 @@ bool nxH4::PNeXus::caseInsensitiveEquals(const std::string& a, const std::string }); } -std::vector nxH4::PNeXus::splitPath(const std::string& path) +std::vector nxH4::PNeXus::SplitPath(const std::string& path) { std::vector components; std::string current; @@ -2548,7 +2548,7 @@ std::vector nxH4::PNeXus::splitPath(const std::string& path) return components; } -std::string nxH4::PNeXus::findAttributeName(int32 sd_id, const std::string& requestedName) +std::string nxH4::PNeXus::FindAttributeName(int32 sd_id, const std::string& requestedName) { int32 n_datasets, n_attrs; if (SDfileinfo(sd_id, &n_datasets, &n_attrs) == FAIL) { @@ -2560,7 +2560,7 @@ std::string nxH4::PNeXus::findAttributeName(int32 sd_id, const std::string& requ for (int32 i = 0; i < n_attrs; i++) { if (SDattrinfo(sd_id, i, attr_name, &attr_type, &attr_count) != FAIL) { - if (caseInsensitiveEquals(attr_name, requestedName)) { + if (CaseInsensitiveEquals(attr_name, requestedName)) { return std::string(attr_name); } } @@ -2569,7 +2569,7 @@ std::string nxH4::PNeXus::findAttributeName(int32 sd_id, const std::string& requ throw std::runtime_error("Attribute not found: " + requestedName); } -int32 nxH4::PNeXus::findDatasetIndex(int32 sd_id, const std::string& requestedName) +int32 nxH4::PNeXus::FindDatasetIndex(int32 sd_id, const std::string& requestedName) { // First try exact match int32 idx = SDnametoindex(sd_id, requestedName.c_str()); @@ -2589,7 +2589,7 @@ int32 nxH4::PNeXus::findDatasetIndex(int32 sd_id, const std::string& requestedNa char name[H4_MAX_NC_NAME]; int32 rank, dim_sizes[H4_MAX_VAR_DIMS], data_type, n_ds_attrs; if (SDgetinfo(sds_id, name, &rank, dim_sizes, &data_type, &n_ds_attrs) != FAIL) { - if (caseInsensitiveEquals(name, requestedName)) { + if (CaseInsensitiveEquals(name, requestedName)) { SDendaccess(sds_id); return i; } @@ -2601,12 +2601,12 @@ int32 nxH4::PNeXus::findDatasetIndex(int32 sd_id, const std::string& requestedNa throw std::runtime_error("Dataset not found: " + requestedName); } -int32 nxH4::PNeXus::findDatasetRefByPath(const std::string& path) +int32 nxH4::PNeXus::FindDatasetRefByPath(const std::string& path) { // Navigate VGroup hierarchy to find the dataset reference // Path format: /group1/group2/.../dataset_name - std::vector components = splitPath(path); + std::vector components = SplitPath(path); if (components.empty()) { return -1; } @@ -2634,7 +2634,7 @@ int32 nxH4::PNeXus::findDatasetRefByPath(const std::string& path) if (vg_id != FAIL) { char vg_name[VGNAMELENMAX]; if (Vgetname(vg_id, vg_name) != FAIL) { - if (caseInsensitiveEquals(vg_name, components[0])) { + if (CaseInsensitiveEquals(vg_name, components[0])) { current_vg_ref = vgroup_refs[i]; Vdetach(vg_id); break; @@ -2668,7 +2668,7 @@ int32 nxH4::PNeXus::findDatasetRefByPath(const std::string& path) if (child_vg_id != FAIL) { char child_name[VGNAMELENMAX]; if (Vgetname(child_vg_id, child_name) != FAIL) { - if (caseInsensitiveEquals(child_name, components[comp_idx])) { + if (CaseInsensitiveEquals(child_name, components[comp_idx])) { current_vg_ref = ref; found = true; Vdetach(child_vg_id); @@ -2709,7 +2709,7 @@ int32 nxH4::PNeXus::findDatasetRefByPath(const std::string& path) char ds_name[H4_MAX_NC_NAME]; int32 rank, dim_sizes[H4_MAX_VAR_DIMS], data_type, n_attrs; if (SDgetinfo(sds_id, ds_name, &rank, dim_sizes, &data_type, &n_attrs) != FAIL) { - if (caseInsensitiveEquals(ds_name, target_name)) { + if (CaseInsensitiveEquals(ds_name, target_name)) { result_ref = ref; SDendaccess(sds_id); break; @@ -2744,16 +2744,16 @@ int32 nxH4::PNeXus::findDatasetRefByPath(const std::string& path) nxH4::H4DataType nxH4::PNeXus::convertHdf4Type(int32 hdf4_type) { switch (hdf4_type) { - case DFNT_INT32: return H4DataType::INT32; - case DFNT_FLOAT32: return H4DataType::FLOAT32; - case DFNT_FLOAT64: return H4DataType::FLOAT64; - case DFNT_CHAR8: return H4DataType::CHAR8; - case DFNT_UINT32: return H4DataType::UINT32; - case DFNT_INT16: return H4DataType::INT16; - case DFNT_UINT16: return H4DataType::UINT16; - case DFNT_INT8: return H4DataType::INT8; - case DFNT_UINT8: return H4DataType::UINT8; - default: return H4DataType::INT32; + case DFNT_INT32: return H4DataType::kINT32; + case DFNT_FLOAT32: return H4DataType::kFLOAT32; + case DFNT_FLOAT64: return H4DataType::kFLOAT64; + case DFNT_CHAR8: return H4DataType::kCHAR8; + case DFNT_UINT32: return H4DataType::kUINT32; + case DFNT_INT16: return H4DataType::kINT16; + case DFNT_UINT16: return H4DataType::kUINT16; + case DFNT_INT8: return H4DataType::kINT8; + case DFNT_UINT8: return H4DataType::kUINT8; + default: return H4DataType::kINT32; } } @@ -2771,15 +2771,15 @@ nxH4::H4DataType nxH4::PNeXus::convertHdf4Type(int32 hdf4_type) int32 nxH4::PNeXus::convertToHdf4Type(H4DataType dataType) { switch (dataType) { - case H4DataType::INT32: return DFNT_INT32; - case H4DataType::FLOAT32: return DFNT_FLOAT32; - case H4DataType::FLOAT64: return DFNT_FLOAT64; - case H4DataType::CHAR8: return DFNT_CHAR8; - case H4DataType::UINT32: return DFNT_UINT32; - case H4DataType::INT16: return DFNT_INT16; - case H4DataType::UINT16: return DFNT_UINT16; - case H4DataType::INT8: return DFNT_INT8; - case H4DataType::UINT8: return DFNT_UINT8; + case H4DataType::kINT32: return DFNT_INT32; + case H4DataType::kFLOAT32: return DFNT_FLOAT32; + case H4DataType::kFLOAT64: return DFNT_FLOAT64; + case H4DataType::kCHAR8: return DFNT_CHAR8; + case H4DataType::kUINT32: return DFNT_UINT32; + case H4DataType::kINT16: return DFNT_INT16; + case H4DataType::kUINT16: return DFNT_UINT16; + case H4DataType::kINT8: return DFNT_INT8; + case H4DataType::kUINT8: return DFNT_UINT8; default: return DFNT_INT32; } } @@ -2936,7 +2936,7 @@ double nxH5::PNeXusDeadTime::operator()(const std::vector &par) const } //============================================================================= -// nxH5::PNeXusDeadTime::minimize() +// nxH5::PNeXusDeadTime::Minimize() //============================================================================= /** * @brief Minimize dead time for a specific detector spectrum @@ -2957,7 +2957,7 @@ double nxH5::PNeXusDeadTime::operator()(const std::vector &par) const * * @see GetDeadTimeEstimated() to retrieve results after minimization */ -void nxH5::PNeXusDeadTime::minimize(const int i) +void nxH5::PNeXusDeadTime::Minimize(const int i) { fIdx = i; @@ -3008,11 +3008,11 @@ void nxH5::PNeXusDeadTime::minimize(const int i) * * @example * @code - * caseInsensitiveEquals("NeXus", "nexus") // returns true - * caseInsensitiveEquals("IDF_VERSION", "idf_version") // returns true + * CaseInsensitiveEquals("NeXus", "nexus") // returns true + * CaseInsensitiveEquals("IDF_VERSION", "idf_version") // returns true * @endcode */ -bool nxH5::PNeXus::caseInsensitiveEquals(const std::string& a, const std::string& b) +bool nxH5::PNeXus::CaseInsensitiveEquals(const std::string& a, const std::string& b) { if (a.length() != b.length()) { return false; @@ -3044,12 +3044,12 @@ bool nxH5::PNeXus::caseInsensitiveEquals(const std::string& a, const std::string * * @example * @code - * splitPath("/raw_data_1/IDF_version") // returns ["", "raw_data_1", "IDF_version"] - * splitPath("detector_1/counts") // returns ["detector_1", "counts"] - * splitPath("/") // returns [""] + * SplitPath("/raw_data_1/IDF_version") // returns ["", "raw_data_1", "IDF_version"] + * SplitPath("detector_1/counts") // returns ["detector_1", "counts"] + * SplitPath("/") // returns [""] * @endcode */ -std::vector nxH5::PNeXus::splitPath(const std::string& path) +std::vector nxH5::PNeXus::SplitPath(const std::string& path) { std::vector components; std::string component; @@ -3083,11 +3083,11 @@ std::vector nxH5::PNeXus::splitPath(const std::string& path) * * @example * @code - * std::string actualName = findAttributeName(file, "nexus_VERSION"); + * std::string actualName = FindAttributeName(file, "nexus_VERSION"); * // actualName might be "NeXus_version" if that's how it's stored * @endcode */ -std::string nxH5::PNeXus::findAttributeName(H5::H5File& obj, const std::string& requestedName) +std::string nxH5::PNeXus::FindAttributeName(H5::H5File& obj, const std::string& requestedName) { int numAttrs = obj.getNumAttrs(); @@ -3096,7 +3096,7 @@ std::string nxH5::PNeXus::findAttributeName(H5::H5File& obj, const std::string& std::string attrName = attr.getName(); attr.close(); - if (caseInsensitiveEquals(attrName, requestedName)) { + if (CaseInsensitiveEquals(attrName, requestedName)) { return attrName; } } @@ -3104,7 +3104,7 @@ std::string nxH5::PNeXus::findAttributeName(H5::H5File& obj, const std::string& // Not found - throw exception std::ostringstream msg; msg << "Could not find attribute matching case-insensitive name: '" << requestedName << "'"; - throw H5::AttributeIException("findAttributeName", msg.str()); + throw H5::AttributeIException("FindAttributeName", msg.str()); } //============================================================================= @@ -3124,13 +3124,13 @@ std::string nxH5::PNeXus::findAttributeName(H5::H5File& obj, const std::string& * * @example * @code - * std::string path = findGroupPath(file, "/RAW_DATA_1/detector_1"); + * std::string path = FindGroupPath(file, "/RAW_DATA_1/detector_1"); * // path might be "/raw_data_1/detector_1" if that's the actual casing * @endcode */ -std::string nxH5::PNeXus::findGroupPath(H5::H5File& parent, const std::string& requestedPath) +std::string nxH5::PNeXus::FindGroupPath(H5::H5File& parent, const std::string& requestedPath) { - std::vector components = splitPath(requestedPath); + std::vector components = SplitPath(requestedPath); // Handle empty path if (components.empty()) { @@ -3164,7 +3164,7 @@ std::string nxH5::PNeXus::findGroupPath(H5::H5File& parent, const std::string& r bool found = false; for (const auto& objName : objectNames) { - if (caseInsensitiveEquals(objName, requestedComponent)) { + if (CaseInsensitiveEquals(objName, requestedComponent)) { matchedName = objName; found = true; break; @@ -3175,7 +3175,7 @@ std::string nxH5::PNeXus::findGroupPath(H5::H5File& parent, const std::string& r std::ostringstream msg; msg << "Could not find group component matching case-insensitive path: '" << requestedPath << "' (failed at component: '" << requestedComponent << "')"; - throw H5::GroupIException("findGroupPath", msg.str()); + throw H5::GroupIException("FindGroupPath", msg.str()); } // Build current path @@ -3187,7 +3187,7 @@ std::string nxH5::PNeXus::findGroupPath(H5::H5File& parent, const std::string& r std::ostringstream msg; msg << "Path component '" << matchedName << "' in '" << requestedPath << "' is not a group"; - throw H5::GroupIException("findGroupPath", msg.str()); + throw H5::GroupIException("FindGroupPath", msg.str()); } } @@ -3197,9 +3197,9 @@ std::string nxH5::PNeXus::findGroupPath(H5::H5File& parent, const std::string& r //----------------------------------------------------------------------------- // Find group path with case-insensitive matching (Group overload) //----------------------------------------------------------------------------- -std::string nxH5::PNeXus::findGroupPath(H5::Group& parent, const std::string& requestedPath) +std::string nxH5::PNeXus::FindGroupPath(H5::Group& parent, const std::string& requestedPath) { - std::vector components = splitPath(requestedPath); + std::vector components = SplitPath(requestedPath); // Handle empty path if (components.empty()) { @@ -3230,7 +3230,7 @@ std::string nxH5::PNeXus::findGroupPath(H5::Group& parent, const std::string& re bool found = false; for (const auto& objName : objectNames) { - if (caseInsensitiveEquals(objName, requestedComponent)) { + if (CaseInsensitiveEquals(objName, requestedComponent)) { matchedName = objName; found = true; break; @@ -3241,7 +3241,7 @@ std::string nxH5::PNeXus::findGroupPath(H5::Group& parent, const std::string& re std::ostringstream msg; msg << "Could not find group component matching case-insensitive path: '" << requestedPath << "' (failed at component: '" << requestedComponent << "')"; - throw H5::GroupIException("findGroupPath", msg.str()); + throw H5::GroupIException("FindGroupPath", msg.str()); } // Build current path @@ -3253,7 +3253,7 @@ std::string nxH5::PNeXus::findGroupPath(H5::Group& parent, const std::string& re std::ostringstream msg; msg << "Path component '" << matchedName << "' in '" << requestedPath << "' is not a group"; - throw H5::GroupIException("findGroupPath", msg.str()); + throw H5::GroupIException("FindGroupPath", msg.str()); } // Open the group for next iteration @@ -3284,18 +3284,18 @@ std::string nxH5::PNeXus::findGroupPath(H5::Group& parent, const std::string& re * * @example * @code - * std::string path = findDatasetPath(file, "/RAW_DATA_1/idf_VERSION"); + * std::string path = FindDatasetPath(file, "/RAW_DATA_1/idf_VERSION"); * // path might be "/raw_data_1/IDF_version" if that's the actual casing * std::int data = H5Easy::load(file, path); * @endcode */ -std::string nxH5::PNeXus::findDatasetPath(H5::H5File& parent, const std::string& requestedPath) +std::string nxH5::PNeXus::FindDatasetPath(H5::H5File& parent, const std::string& requestedPath) { - std::vector components = splitPath(requestedPath); + std::vector components = SplitPath(requestedPath); // Handle empty path if (components.empty()) { - throw H5::DataSetIException("findDatasetPath", "Empty dataset path provided"); + throw H5::DataSetIException("FindDatasetPath", "Empty dataset path provided"); } // Check if absolute path @@ -3325,7 +3325,7 @@ std::string nxH5::PNeXus::findDatasetPath(H5::H5File& parent, const std::string& bool found = false; for (const auto& objName : objectNames) { - if (caseInsensitiveEquals(objName, requestedComponent)) { + if (CaseInsensitiveEquals(objName, requestedComponent)) { matchedName = objName; found = true; break; @@ -3336,7 +3336,7 @@ std::string nxH5::PNeXus::findDatasetPath(H5::H5File& parent, const std::string& std::ostringstream msg; msg << "Could not find dataset matching case-insensitive path: '" << requestedPath << "' (failed at component: '" << requestedComponent << "')"; - throw H5::DataSetIException("findDatasetPath", msg.str()); + throw H5::DataSetIException("FindDatasetPath", msg.str()); } // Build current path @@ -3349,7 +3349,7 @@ std::string nxH5::PNeXus::findDatasetPath(H5::H5File& parent, const std::string& std::ostringstream msg; msg << "Path '" << requestedPath << "' resolves to '" << currentPath << "' which is not a dataset"; - throw H5::DataSetIException("findDatasetPath", msg.str()); + throw H5::DataSetIException("FindDatasetPath", msg.str()); } } else { // Intermediate component - should be a group @@ -3358,7 +3358,7 @@ std::string nxH5::PNeXus::findDatasetPath(H5::H5File& parent, const std::string& std::ostringstream msg; msg << "Path component '" << matchedName << "' in '" << requestedPath << "' is not a group"; - throw H5::DataSetIException("findDatasetPath", msg.str()); + throw H5::DataSetIException("FindDatasetPath", msg.str()); } } } @@ -3369,13 +3369,13 @@ std::string nxH5::PNeXus::findDatasetPath(H5::H5File& parent, const std::string& //----------------------------------------------------------------------------- // Find dataset path with case-insensitive matching (Group overload) //----------------------------------------------------------------------------- -std::string nxH5::PNeXus::findDatasetPath(H5::Group& parent, const std::string& requestedPath) +std::string nxH5::PNeXus::FindDatasetPath(H5::Group& parent, const std::string& requestedPath) { - std::vector components = splitPath(requestedPath); + std::vector components = SplitPath(requestedPath); // Handle empty path if (components.empty()) { - throw H5::DataSetIException("findDatasetPath", "Empty dataset path provided"); + throw H5::DataSetIException("FindDatasetPath", "Empty dataset path provided"); } // Check if absolute path @@ -3402,7 +3402,7 @@ std::string nxH5::PNeXus::findDatasetPath(H5::Group& parent, const std::string& bool found = false; for (const auto& objName : objectNames) { - if (caseInsensitiveEquals(objName, requestedComponent)) { + if (CaseInsensitiveEquals(objName, requestedComponent)) { matchedName = objName; found = true; break; @@ -3413,7 +3413,7 @@ std::string nxH5::PNeXus::findDatasetPath(H5::Group& parent, const std::string& std::ostringstream msg; msg << "Could not find dataset matching case-insensitive path: '" << requestedPath << "' (failed at component: '" << requestedComponent << "')"; - throw H5::DataSetIException("findDatasetPath", msg.str()); + throw H5::DataSetIException("FindDatasetPath", msg.str()); } // Build current path @@ -3426,7 +3426,7 @@ std::string nxH5::PNeXus::findDatasetPath(H5::Group& parent, const std::string& std::ostringstream msg; msg << "Path '" << requestedPath << "' resolves to '" << currentPath << "' which is not a dataset"; - throw H5::DataSetIException("findDatasetPath", msg.str()); + throw H5::DataSetIException("FindDatasetPath", msg.str()); } } else { // Intermediate component - should be a group @@ -3435,7 +3435,7 @@ std::string nxH5::PNeXus::findDatasetPath(H5::Group& parent, const std::string& std::ostringstream msg; msg << "Path component '" << matchedName << "' in '" << requestedPath << "' is not a group"; - throw H5::DataSetIException("findDatasetPath", msg.str()); + throw H5::DataSetIException("FindDatasetPath", msg.str()); } // Open the group for next iteration currentGroup = currentGroup.openGroup(matchedName); @@ -3541,7 +3541,7 @@ int nxH5::PNeXus::ReadNexusFile() // Load NeXus version attribute (with case-insensitive lookup) std::string version; try { - std::string versionNeXusAttr = findAttributeName(file, "NeXus_version"); + std::string versionNeXusAttr = FindAttributeName(file, "NeXus_version"); H5::Attribute attr = file.openAttribute(versionNeXusAttr); H5::DataType dtype = attr.getDataType(); attr.read(dtype, version); @@ -3557,7 +3557,7 @@ int nxH5::PNeXus::ReadNexusFile() // Load IDF version from dataset (with case-insensitive lookup) int idf_vers{-1}; try { - std::string idfPath = findDatasetPath(file, "/run/IDF_version"); + std::string idfPath = FindDatasetPath(file, "/run/IDF_version"); H5::DataSet dataset = file.openDataSet(idfPath); dataset.read(&idf_vers, H5::PredType::NATIVE_INT); dataset.close(); @@ -3569,7 +3569,7 @@ int nxH5::PNeXus::ReadNexusFile() if (fIdfVersion == -1) { try { - std::string idfPath = findDatasetPath(file, "/raw_data_1/IDF_version"); + std::string idfPath = FindDatasetPath(file, "/raw_data_1/IDF_version"); H5::DataSet dataset = file.openDataSet(idfPath); dataset.read(&idf_vers, H5::PredType::NATIVE_INT); dataset.close(); @@ -3580,7 +3580,7 @@ int nxH5::PNeXus::ReadNexusFile() } try { - std::string versionHdf5Attr = findAttributeName(file, "HDF5_version"); + std::string versionHdf5Attr = FindAttributeName(file, "HDF5_version"); H5::Attribute attr = file.openAttribute(versionHdf5Attr); H5::DataType dtype = attr.getDataType(); attr.read(dtype, version); @@ -3636,7 +3636,7 @@ void nxH5::PNeXus::HandleIdfV1(H5::H5File &file) std::string attrStr{""}, attrStrName{""}; // get file_name attribute try { - attrStrName = findAttributeName(file, "user"); + attrStrName = FindAttributeName(file, "user"); H5::Attribute attr = file.openAttribute(attrStrName); H5::DataType dtype = attr.getDataType(); attr.read(dtype, attrStr); @@ -3698,7 +3698,7 @@ void nxH5::PNeXus::HandleIdfV2(H5::H5File &file) std::string attrStr{""}, attrStrName{""}; // get file_name attribute try { - attrStrName = findAttributeName(file, "file_name"); + attrStrName = FindAttributeName(file, "file_name"); H5::Attribute attr = file.openAttribute(attrStrName); H5::DataType dtype = attr.getDataType(); attr.read(dtype, attrStr); @@ -3713,7 +3713,7 @@ void nxH5::PNeXus::HandleIdfV2(H5::H5File &file) // get file_time attribute attrStr=""; try { - attrStrName = findAttributeName(file, "file_time"); + attrStrName = FindAttributeName(file, "file_time"); H5::Attribute attr = file.openAttribute(attrStrName); H5::DataType dtype = attr.getDataType(); attr.read(dtype, attrStr); @@ -4770,7 +4770,7 @@ void nxH5::PNeXus::ReadIntDataset(H5::H5File& file, const std::string& path) { try { // Find the actual path (case-insensitive) - std::string actualPath = findDatasetPath(file, path); + std::string actualPath = FindDatasetPath(file, path); // Open the dataset H5::DataSet dataset = file.openDataSet(actualPath); @@ -4836,7 +4836,7 @@ void nxH5::PNeXus::ReadFloatDataset(H5::H5File& file, const std::string& path) { try { // Find the actual path (case-insensitive) - std::string actualPath = findDatasetPath(file, path); + std::string actualPath = FindDatasetPath(file, path); // Open the dataset H5::DataSet dataset = file.openDataSet(actualPath); @@ -4901,7 +4901,7 @@ void nxH5::PNeXus::ReadStringDataset(H5::H5File& file, const std::string& path) { try { // Find the actual path (case-insensitive) - std::string actualPath = findDatasetPath(file, path); + std::string actualPath = FindDatasetPath(file, path); // Open the dataset H5::DataSet dataset = file.openDataSet(actualPath); @@ -5026,7 +5026,7 @@ template void nxH5::PNeXus::ReadDatasetAttributes(H5::DataSet&, PNXdata components = splitPath(path); + std::vector components = SplitPath(path); std::string currentPath = ""; H5::Group currentGroup; diff --git a/src/external/nexus/PNeXus.h b/src/external/nexus/PNeXus.h index 540419115..69729cc85 100644 --- a/src/external/nexus/PNeXus.h +++ b/src/external/nexus/PNeXus.h @@ -295,7 +295,7 @@ public: * * @note Prints minimization results including dead time estimate and errors * @note The index i must be less than dims[1] (number of spectra) */ - void minimize(const int i); + void Minimize(const int i); /** * @brief Get the dimensions of the count dataset @@ -327,15 +327,15 @@ private: * This enum maps to HDF4 numeric types (DFNT_*) for type-safe dataset handling */ enum class H4DataType { - INT32, ///< 32-bit signed integer (DFNT_INT32) - FLOAT32, ///< 32-bit floating point (DFNT_FLOAT32) - FLOAT64, ///< 64-bit floating point (DFNT_FLOAT64) - CHAR8, ///< 8-bit character (DFNT_CHAR8) - UINT32, ///< 32-bit unsigned integer (DFNT_UINT32) - INT16, ///< 16-bit signed integer (DFNT_INT16) - UINT16, ///< 16-bit unsigned integer (DFNT_UINT16) - INT8, ///< 8-bit signed integer (DFNT_INT8) - UINT8 ///< 8-bit unsigned integer (DFNT_UINT8) + kINT32, ///< 32-bit signed integer (DFNT_INT32) + kFLOAT32, ///< 32-bit floating point (DFNT_FLOAT32) + kFLOAT64, ///< 64-bit floating point (DFNT_FLOAT64) + kCHAR8, ///< 8-bit character (DFNT_CHAR8) + kUINT32, ///< 32-bit unsigned integer (DFNT_UINT32) + kINT16, ///< 16-bit signed integer (DFNT_INT16) + kUINT16, ///< 16-bit unsigned integer (DFNT_UINT16) + kINT8, ///< 8-bit signed integer (DFNT_INT8) + kUINT8 ///< 8-bit unsigned integer (DFNT_UINT8) }; /** @@ -372,7 +372,7 @@ public: /** * @brief Default constructor */ - PNXdata() : fDataType(H4DataType::INT32) {} + PNXdata() : fDataType(H4DataType::kINT32) {} /** * @brief Constructor with datatype @@ -758,7 +758,7 @@ public: template bool AddDataset(const std::string& path, const std::vector& data, const std::vector& dimensions, - const H4DataType& dataType = H4DataType::INT32) { + const H4DataType& dataType = H4DataType::kINT32) { if (HasDataset(path)) return false; PNXdata dataset(dataType); dataset.SetData(data); @@ -930,9 +930,9 @@ private: */ void HandleIdfV2(int32 sd_id); - // ======================================================================== - // Write methods for HDF4 file creation - // ======================================================================== + // ======================================================================== + // Write methods for HDF4 file creation + // ======================================================================== /** * @brief Write dataset attributes from PNXdata object @@ -1017,7 +1017,7 @@ private: * @return true if strings are equal (ignoring case), false otherwise * @note Uses std::tolower for character-by-character comparison */ - static bool caseInsensitiveEquals(const std::string& a, const std::string& b); + static bool CaseInsensitiveEquals(const std::string& a, const std::string& b); /** * @brief Split an HDF4 path into components @@ -1026,7 +1026,7 @@ private: * @note Empty first component indicates absolute path * @example "/raw_data_1/IDF_version" -> ["", "raw_data_1", "IDF_version"] */ - static std::vector splitPath(const std::string& path); + static std::vector SplitPath(const std::string& path); /** * @brief Find attribute name with case-insensitive matching @@ -1036,7 +1036,7 @@ private: * @throws std::runtime_error if attribute not found * @example "nexus_version" might resolve to "NeXus_version" */ - std::string findAttributeName(int32 sd_id, const std::string& requestedName); + std::string FindAttributeName(int32 sd_id, const std::string& requestedName); /** * @brief Find dataset index with case-insensitive matching @@ -1045,7 +1045,7 @@ private: * @return Dataset index * @throws std::runtime_error if dataset not found */ - int32 findDatasetIndex(int32 sd_id, const std::string& requestedName); + int32 FindDatasetIndex(int32 sd_id, const std::string& requestedName); /** * @brief Find dataset reference by navigating VGroup hierarchy @@ -1053,11 +1053,11 @@ private: * @return Dataset reference number, or -1 if not found * @note Uses VGroup navigation to resolve paths in HDF4 files with duplicate dataset names */ - int32 findDatasetRefByPath(const std::string& path); + int32 FindDatasetRefByPath(const std::string& path); - // ======================================================================== - // Dataset reading helper methods - // ======================================================================== + // ======================================================================== + // Dataset reading helper methods + // ======================================================================== /** * @brief Read an integer dataset and store in data map @@ -1240,7 +1240,7 @@ public: * * @note Prints minimization results including dead time estimate and errors * @note The index i must be less than dims[1] (number of spectra) */ - void minimize(const int i); + void Minimize(const int i); /** * @brief Get the dimensions of the count dataset @@ -1914,9 +1914,9 @@ private: */ void HandleIdfV2(H5::H5File &file); - // ======================================================================== - // Write methods for HDF5 file creation - // ======================================================================== + // ======================================================================== + // Write methods for HDF5 file creation + // ======================================================================== /** * @brief Create nested group hierarchy for a given path @@ -1991,7 +1991,7 @@ private: * @return true if strings are equal (ignoring case), false otherwise * @note Uses std::tolower for character-by-character comparison */ - static bool caseInsensitiveEquals(const std::string& a, const std::string& b); + static bool CaseInsensitiveEquals(const std::string& a, const std::string& b); /** * @brief Split an HDF5 path into components @@ -2000,7 +2000,7 @@ private: * @note Empty first component indicates absolute path * @example "/raw_data_1/IDF_version" -> ["", "raw_data_1", "IDF_version"] */ - static std::vector splitPath(const std::string& path); + static std::vector SplitPath(const std::string& path); /** * @brief Find attribute name with case-insensitive matching @@ -2010,7 +2010,7 @@ private: * @throws H5::AttributeIException if attribute not found * @example "nexus_version" might resolve to "NeXus_version" */ - std::string findAttributeName(H5::H5File& obj, const std::string& requestedName); + std::string FindAttributeName(H5::H5File& obj, const std::string& requestedName); /** * @brief Find group path with case-insensitive matching (File version) @@ -2020,7 +2020,7 @@ private: * @throws H5::GroupIException if group not found or path invalid * @example "/RAW_DATA_1" might resolve to "/raw_data_1" */ - std::string findGroupPath(H5::H5File& parent, const std::string& requestedPath); + std::string FindGroupPath(H5::H5File& parent, const std::string& requestedPath); /** * @brief Find group path with case-insensitive matching (Group version) @@ -2029,7 +2029,7 @@ private: * @return Correctly-cased group path as it exists in the file * @throws H5::GroupIException if group not found or path invalid */ - std::string findGroupPath(H5::Group& parent, const std::string& requestedPath); + std::string FindGroupPath(H5::Group& parent, const std::string& requestedPath); /** * @brief Find dataset path with case-insensitive matching (File version) @@ -2040,7 +2040,7 @@ private: * @example "/RAW_DATA_1/idf_VERSION" might resolve to "/raw_data_1/IDF_version" * @note Validates that final path component is actually a dataset */ - std::string findDatasetPath(H5::H5File& parent, const std::string& requestedPath); + std::string FindDatasetPath(H5::H5File& parent, const std::string& requestedPath); /** * @brief Find dataset path with case-insensitive matching (Group version) @@ -2050,7 +2050,7 @@ private: * @throws H5::DataSetIException if dataset not found or path invalid * @note Validates that final path component is actually a dataset */ - std::string findDatasetPath(H5::Group& parent, const std::string& requestedPath); + std::string FindDatasetPath(H5::Group& parent, const std::string& requestedPath); // ======================================================================== // Dataset reading helper methods