fixed typo, and added file pointer checks.
This commit is contained in:
@@ -2226,6 +2226,10 @@ Bool_t PRunDataHandler::ReadNexusFile()
|
|||||||
if (type == nxs::HDFType::HDF4) {
|
if (type == nxs::HDFType::HDF4) {
|
||||||
#ifdef HAVE_HDF4
|
#ifdef HAVE_HDF4
|
||||||
std::unique_ptr<nxH4::PNeXus> nxs_file = std::make_unique<nxH4::PNeXus>(fRunPathName.Data());
|
std::unique_ptr<nxH4::PNeXus> nxs_file = std::make_unique<nxH4::PNeXus>(fRunPathName.Data());
|
||||||
|
if (nxs_file == nullptr) {
|
||||||
|
std::cerr << std::endl << "**ERROR** allocation of nxH4::PNeXus object failed." << std::endl;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// get header information
|
// get header information
|
||||||
|
|
||||||
@@ -2349,113 +2353,19 @@ Bool_t PRunDataHandler::ReadNexusFile()
|
|||||||
runData.SetStopDate(date);
|
runData.SetStopDate(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get/set t0, firstGoodBin, lastGoodBin
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
} else { // HDF5
|
} else { // HDF5
|
||||||
std::unique_ptr<nxH5::PNeXus> nxs_file = std::make_unique<nxH5::PNeXus>(fRunPathName.Data());
|
std::unique_ptr<nxH5::PNeXus> nxs_file = std::make_unique<nxH5::PNeXus>(fRunPathName.Data());
|
||||||
|
if (nxs_file == nullptr) {
|
||||||
|
std::cerr << std::endl << "**ERROR** allocation of nxH5::PNeXus object failed." << std::endl;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* //as35
|
/* //as35
|
||||||
PDoubleVector histoData;
|
|
||||||
PRawRunData runData;
|
|
||||||
PRawRunDataSet dataSet;
|
|
||||||
TString str;
|
|
||||||
std::string sstr;
|
|
||||||
Double_t dval;
|
|
||||||
bool ok;
|
|
||||||
|
|
||||||
std::unique_ptr<PNeXus> nxs_file = std::make_unique<PNeXus>(fRunPathName.Data());
|
|
||||||
if (!nxs_file->IsValid()) {
|
|
||||||
std::cerr << std::endl << ">> PRunDataHandler::ReadNexusFile(): Not a valid NeXus file.";
|
|
||||||
std::cerr << std::endl << ">> Error Message: " << nxs_file->GetErrorMsg().data() << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nxs_file->GetIdfVersion() == 1) {
|
if (nxs_file->GetIdfVersion() == 1) {
|
||||||
if (!nxs_file->IsValid()) {
|
|
||||||
std::cout << std::endl << "**ERROR** invalid NeXus IDF 2 version file found." << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get header information
|
|
||||||
|
|
||||||
// get/set laboratory
|
|
||||||
str = TString(nxs_file->GetEntryIdf1()->GetLaboratory());
|
|
||||||
runData.SetLaboratory(str);
|
|
||||||
|
|
||||||
// get/set beamline
|
|
||||||
str = TString(nxs_file->GetEntryIdf1()->GetBeamline());
|
|
||||||
runData.SetBeamline(str);
|
|
||||||
|
|
||||||
// get/set instrument
|
|
||||||
str = TString(nxs_file->GetEntryIdf1()->GetInstrument()->GetName());
|
|
||||||
runData.SetInstrument(str);
|
|
||||||
|
|
||||||
// get/set run title
|
|
||||||
str = TString(nxs_file->GetEntryIdf1()->GetTitle());
|
|
||||||
runData.SetRunTitle(str);
|
|
||||||
|
|
||||||
// get/set run number
|
|
||||||
runData.SetRunNumber(nxs_file->GetEntryIdf1()->GetRunNumber());
|
|
||||||
|
|
||||||
// get/set temperature
|
|
||||||
dval = nxs_file->GetEntryIdf1()->GetSample()->GetPhysPropValue("temperature", ok);
|
|
||||||
if (ok)
|
|
||||||
runData.SetTemperature(0, dval, 0.0);
|
|
||||||
|
|
||||||
// get/set field
|
|
||||||
dval = nxs_file->GetEntryIdf1()->GetSample()->GetPhysPropValue("magnetic_field", ok);
|
|
||||||
nxs_file->GetEntryIdf1()->GetSample()->GetPhysPropUnit("magnetic_field", sstr, ok);
|
|
||||||
str = sstr;
|
|
||||||
// since field has to be given in Gauss, check the units
|
|
||||||
Double_t factor=1.0;
|
|
||||||
if (!str.CompareTo("gauss", TString::kIgnoreCase))
|
|
||||||
factor=1.0;
|
|
||||||
else if (!str.CompareTo("tesla", TString::kIgnoreCase))
|
|
||||||
factor=1.0e4;
|
|
||||||
else
|
|
||||||
factor=1.0;
|
|
||||||
runData.SetField(factor*dval);
|
|
||||||
|
|
||||||
// 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
|
|
||||||
runData.SetSetup(nxs_file->GetEntryIdf1()->GetNotes());
|
|
||||||
|
|
||||||
// get/set sample
|
|
||||||
runData.SetSample(nxs_file->GetEntryIdf1()->GetSample()->GetName());
|
|
||||||
|
|
||||||
// get/set orientation
|
|
||||||
runData.SetOrientation("??");
|
|
||||||
|
|
||||||
// get/set time resolution (ns)
|
|
||||||
runData.SetTimeResolution(nxs_file->GetEntryIdf1()->GetData()->GetTimeResolution("ns"));
|
|
||||||
|
|
||||||
// get/set start/stop time
|
|
||||||
sstr = nxs_file->GetEntryIdf1()->GetStartTime();
|
|
||||||
str = sstr;
|
|
||||||
TString date, time;
|
|
||||||
SplitTimeDate(str, time, date, ok);
|
|
||||||
if (ok) {
|
|
||||||
runData.SetStartTime(time);
|
|
||||||
runData.SetStartDate(date);
|
|
||||||
}
|
|
||||||
|
|
||||||
sstr = nxs_file->GetEntryIdf1()->GetStopTime();
|
|
||||||
str = sstr;
|
|
||||||
SplitTimeDate(str, time, date, ok);
|
|
||||||
if (ok) {
|
|
||||||
runData.SetStopTime(time);
|
|
||||||
runData.SetStopDate(date);
|
|
||||||
}
|
|
||||||
|
|
||||||
// get/set t0, firstGoodBin, lastGoodBin
|
// get/set t0, firstGoodBin, lastGoodBin
|
||||||
std::vector<unsigned int> *t0 = nxs_file->GetEntryIdf1()->GetData()->GetT0s();
|
std::vector<unsigned int> *t0 = nxs_file->GetEntryIdf1()->GetData()->GetT0s();
|
||||||
std::vector<unsigned int> *fgb = nxs_file->GetEntryIdf1()->GetData()->GetFirstGoodBins();
|
std::vector<unsigned int> *fgb = nxs_file->GetEntryIdf1()->GetData()->GetFirstGoodBins();
|
||||||
|
|||||||
@@ -389,14 +389,14 @@ int dump_header_nexus(const std::string fileName, const bool counts) {
|
|||||||
#ifdef HAVE_HDF4
|
#ifdef HAVE_HDF4
|
||||||
std::unique_ptr<nxH4::PNeXus> nxs_file = std::make_unique<nxH4::PNeXus>(fileName);
|
std::unique_ptr<nxH4::PNeXus> nxs_file = std::make_unique<nxH4::PNeXus>(fileName);
|
||||||
if (nxs_file == nullptr) {
|
if (nxs_file == nullptr) {
|
||||||
std::cerr << std::endl << "**ERROR** allocation of nxH4::PNeXus object faild." << std::endl;
|
std::cerr << std::endl << "**ERROR** allocation of nxH4::PNeXus object failed." << std::endl;
|
||||||
}
|
}
|
||||||
nxs_file->Dump();
|
nxs_file->Dump();
|
||||||
#endif
|
#endif
|
||||||
} else { // HDF5
|
} else { // HDF5
|
||||||
std::unique_ptr<nxH5::PNeXus> nxs_file = std::make_unique<nxH5::PNeXus>(fileName);
|
std::unique_ptr<nxH5::PNeXus> nxs_file = std::make_unique<nxH5::PNeXus>(fileName);
|
||||||
if (nxs_file == nullptr) {
|
if (nxs_file == nullptr) {
|
||||||
std::cerr << std::endl << "**ERROR** allocation of nxH5::PNeXus object faild." << std::endl;
|
std::cerr << std::endl << "**ERROR** allocation of nxH5::PNeXus object failed." << std::endl;
|
||||||
}
|
}
|
||||||
nxs_file->Dump();
|
nxs_file->Dump();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user