add more HDF4 header info.

This commit is contained in:
2026-02-01 19:49:55 +01:00
parent 60f11dfc0e
commit 008ca7210a

View File

@@ -2220,7 +2220,7 @@ Bool_t PRunDataHandler::ReadNexusFile()
TString str;
std::string sstr;
Int_t ival;
Double_t dval;
Double_t dval, factor;
bool ok;
if (type == nxs::HDFType::HDF4) {
@@ -2261,9 +2261,52 @@ Bool_t PRunDataHandler::ReadNexusFile()
// get/set temperature
dval = PMUSR_UNDEFINED;
if (nxs_file->HasDataset("/run/sample/temperature"))
dval = nxs_file->GetDataset<float>("/run/sample/temperature").GetData()[0];
sstr = "n/a";
if (nxs_file->HasDataset("/run/sample/temperature")) {
auto tmp_ds = nxs_file->GetDataset<float>("/run/sample/temperature");
dval = tmp_ds.GetData()[0];
if (tmp_ds.HasAttribute("units"))
sstr = std::any_cast<std::string>(tmp_ds.GetAttribute("units"));
if (sstr == "Celcius")
dval += 273.16;
}
runData.SetTemperature(0, dval, 0.0);
// get/set field
dval = PMUSR_UNDEFINED;
sstr = "n/a";
factor = 1.0;
if (nxs_file->HasDataset("/run/sample/magnetic_field")) {
auto mag_ds = nxs_file->GetDataset<float>("/run/sample/magnetic_field");
dval = mag_ds.GetData()[0];
if (mag_ds.HasAttribute("units"))
sstr = std::any_cast<std::string>(mag_ds.GetAttribute("units"));
if (sstr == "Tesla")
factor = 1.0e4;
}
runData.SetField(dval*factor);
// get/set implantation energy
runData.SetEnergy(PMUSR_UNDEFINED);
// get/set moderator HV
runData.SetTransport(PMUSR_UNDEFINED);
// get/set RA HV's (LEM specific)
for (UInt_t i=0; i<4; i++)
runData.SetRingAnode(i, PMUSR_UNDEFINED);
// get/set setup
sstr = "n/a";
if (nxs_file->HasDataset("/run/notes"))
sstr = nxs_file->GetDataset<std::string>("/run/notes").GetData()[0];
runData.SetSetup(sstr);
// get/set sample
sstr = "n/a";
if (nxs_file->HasDataset("/run/sample/name"))
sstr = nxs_file->GetDataset<std::string>("/run/sample/name").GetData()[0];
runData.SetSample(sstr);
#endif
} else { // HDF5
std::unique_ptr<nxH5::PNeXus> nxs_file = std::make_unique<nxH5::PNeXus>(fRunPathName.Data());