diff --git a/src/classes/PRunDataHandler.cpp b/src/classes/PRunDataHandler.cpp index 7e6c2364..93fbc401 100644 --- a/src/classes/PRunDataHandler.cpp +++ b/src/classes/PRunDataHandler.cpp @@ -2353,7 +2353,31 @@ Bool_t PRunDataHandler::ReadNexusFile() 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("/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(count_ds.GetAttribute("t0_bin")); + if (count_ds.HasAttribute("first_good_bin")) + fgb = std::any_cast(count_ds.GetAttribute("first_good_bin")); + if (count_ds.HasAttribute("last_good_bin")) + lgb = std::any_cast(count_ds.GetAttribute("last_good_bin")); + if (count_ds.HasAttribute("number")) + noOfHistos = std::any_cast(count_ds.GetAttribute("number")); + if (count_ds.HasAttribute("length")) + histoLength = std::any_cast(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 } else { // HDF5