add more HDF4 header info: counts.

This commit is contained in:
2026-02-03 08:03:13 +01:00
parent 30fbd8eb67
commit 8d1dcef2de

View File

@@ -2353,7 +2353,31 @@ Bool_t PRunDataHandler::ReadNexusFile()
runData.SetStopDate(date); runData.SetStopDate(date);
} }
// get/set t0, firstGoodBin, lastGoodBin // data with its metadata
int t0_bin{-1}, fgb{-1}, lgb{-1}, noOfHistos{-1}, histoLength{-1};
if (nxs_file->HasDataset("/run/histogram_data_1/counts")) {
auto count_ds = nxs_file->GetDataset<int>("/run/histogram_data_1/counts");
auto count = count_ds.GetData();
// get all necessary attributes
if (count_ds.HasAttribute("t0_bin"))
t0_bin = std::any_cast<int>(count_ds.GetAttribute("t0_bin"));
if (count_ds.HasAttribute("first_good_bin"))
fgb = std::any_cast<int>(count_ds.GetAttribute("first_good_bin"));
if (count_ds.HasAttribute("last_good_bin"))
lgb = std::any_cast<int>(count_ds.GetAttribute("last_good_bin"));
if (count_ds.HasAttribute("number"))
noOfHistos = std::any_cast<int>(count_ds.GetAttribute("number"));
if (count_ds.HasAttribute("length"))
histoLength = std::any_cast<int>(count_ds.GetAttribute("length"));
if (count.size() != noOfHistos*histoLength) {
std::cerr << std::endl << "**ERROR** nxH4::PNeXus data size error! count.size()=" << count.size() << ", #histos=" << noOfHistos << ", length=" << histoLength << "." << std::endl;
return false;
}
// fill dataSet - STILL MISSING
} else { // no data found
std::cerr << std::endl << "**ERROR** nxH4::PNeXus couldn't obtain data: '/run/histogram_data_1/counts' is missing." << std::endl;
return false;
}
#endif #endif
} else { // HDF5 } else { // HDF5