check for IDF 1/2.

This commit is contained in:
2026-02-03 17:38:56 +01:00
parent 417901e271
commit a6c9120d06

View File

@@ -2219,7 +2219,7 @@ Bool_t PRunDataHandler::ReadNexusFile()
PRawRunDataSet dataSet;
TString str;
std::string sstr;
Int_t ival;
Int_t ival, idf{-1};
Double_t dval, factor;
bool ok;
@@ -2231,6 +2231,23 @@ Bool_t PRunDataHandler::ReadNexusFile()
return true;
}
// check for IDF_version
if (nxs_file->HasDataset("/run/IDF_version")) {
idf = nxs_file->GetDataset<int>("/run/IDF_version").GetData()[0];
std::cout << ">> PRunDataHandler::ReadNexusFile(): IDF V" << idf << std::endl;
}
if (idf == -1) { // IDF_version not found
if (nxs_file->HasDataset("/raw_data_1/IDF_version")) {
idf = nxs_file->GetDataset<int>("/raw_data_1/IDF_version").GetData()[0];
std::cout << ">> PRunDataHandler::ReadNexusFile(): IDF V" << idf << std::endl;
}
}
if ((idf != 1) && (idf != 2)) {
std::cerr << std::endl << ">> PRunDataHandler::ReadNexusFile(): a NeXus file with an invalid IDF V" << idf << std::endl;
return false;
}
if (idf == 1) { // HDF4 IDF V1
// get header information
// get/set laboratory
@@ -2397,7 +2414,9 @@ Bool_t PRunDataHandler::ReadNexusFile()
std::cerr << std::endl << "**ERROR** nxH4::PNeXus couldn't obtain data: '/run/histogram_data_1/counts' is missing." << std::endl;
return false;
}
} else { // HDF4 IDF V2
// not yet implemented
}
#endif
} else { // HDF5
std::unique_ptr<nxH5::PNeXus> nxs_file = std::make_unique<nxH5::PNeXus>(fRunPathName.Data());
@@ -2405,13 +2424,31 @@ Bool_t PRunDataHandler::ReadNexusFile()
std::cerr << std::endl << "**ERROR** allocation of nxH5::PNeXus object failed." << std::endl;
return true;
}
// check for IDF_version
if (nxs_file->HasDataset("/run/IDF_version")) {
idf = nxs_file->GetDataset<int>("/run/IDF_version").GetData()[0];
std::cout << ">> PRunDataHandler::ReadNexusFile(): IDF V" << idf << std::endl;
}
if (idf == -1) { // IDF_version not found
if (nxs_file->HasDataset("/raw_data_1/IDF_version")) {
idf = nxs_file->GetDataset<int>("/raw_data_1/IDF_version").GetData()[0];
std::cout << ">> PRunDataHandler::ReadNexusFile(): IDF V" << idf << std::endl;
}
}
if ((idf != 1) && (idf != 2)) {
std::cerr << std::endl << ">> PRunDataHandler::ReadNexusFile(): a NeXus file with an invalid IDF V" << idf << std::endl;
return false;
}
if (idf == 1) { // HDF5 IDF V1
// not yet implemented
} else { // HDF5 IDF V2
// not yet implemented
}
}
/* //as35
if (nxs_file->GetIdfVersion() == 1) {
// keep the information
fData.push_back(runData);
} else if (nxs_file->GetIdfVersion() == 2) {
if (!nxs_file->IsValid()) {
std::cout << std::endl << "**ERROR** invalid NeXus IDF 2 version file found." << std::endl;