diff --git a/ChangeLog b/ChangeLog index ba331c2e..c66be610 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,8 @@ changes since 0.9.0 =================================== +NEW 2011-12-22 added nexus_dump. It is used to dump nexus files in an ascii +form. For instance it can be used to read header info. NEW if the background is estimated form an interval rather than fitted, it will be added as a comment to the background interval tag. (MUSR-192). NEW forward/backward accept now not only c0 c1 c2 ... cn, but also c0-cn cm-cp, or c0 c1-cn cm cx-cy, etc. (MUSR-201, improvement whish). @@ -19,7 +21,7 @@ NEW the chi^2 calculation in single-histogram and asymmetry fits is parallelized if musrfit is built using a compiler supporting OpenMP (e.g. GCC >= 4.2) Using --disable-omp this feature can be disabled on the configure level. NEW any2many: force the user to define the exact NeXus ouput format (HDF4,HDF5,XML) -FIXED 2011-12-15 some more work towards a proper NeXus muon data format support. +FIXED 2011-12-22 some more work towards a proper NeXus muon data format support. FIXED proper phase correction for Re/Im Fourier transform (MUSR-206) FIXED when release or restore is called (command block commands), the corresponding parameter error is set to 2% of its parameter value (MUSR-188). diff --git a/doc/examples/data/EMU00005989_v2.nxs b/doc/examples/data/EMU00005989_v2.nxs new file mode 100644 index 00000000..9a213b03 Binary files /dev/null and b/doc/examples/data/EMU00005989_v2.nxs differ diff --git a/doc/examples/data/emu00005989_v2.nxs b/doc/examples/data/emu00005989_v2.nxs deleted file mode 100644 index 91f812aa..00000000 Binary files a/doc/examples/data/emu00005989_v2.nxs and /dev/null differ diff --git a/doc/examples/test-asy-NeXus2.msr b/doc/examples/test-asy-NeXus2.msr index 329f0173..a4ee4e77 100644 --- a/doc/examples/test-asy-NeXus2.msr +++ b/doc/examples/test-asy-NeXus2.msr @@ -20,7 +20,7 @@ FUNCTIONS fun1 = gamma_mu * par4 ############################################################### -RUN data/emu00005989_v2 EMU ISIS NEXUS (name beamline institute data-file-format) +RUN data/EMU00005989_v2 EMU ISIS NEXUS (name beamline institute data-file-format) fittype 2 (asymmetry fit) alpha 1 map 0 0 0 0 0 0 0 0 0 0 diff --git a/doc/examples/test-histo-NeXus2.msr b/doc/examples/test-histo-NeXus2.msr index 6e6a66f1..8330c616 100644 --- a/doc/examples/test-histo-NeXus2.msr +++ b/doc/examples/test-histo-NeXus2.msr @@ -26,7 +26,7 @@ fun1 = par2 + map1 fun2 = gamma_mu * par3 ############################################################### -RUN data/emu00005989_v2 XXXX ISIS NEXUS (name beamline institute data-file-format) +RUN data/EMU00005989_v2 XXXX ISIS NEXUS (name beamline institute data-file-format) fittype 0 (single histogram fit) norm 7 backgr.fit 8 @@ -37,7 +37,7 @@ data 40 1500 fit 0.2 14 packing 1 -RUN data/emu00005989_v2 XXXX ISIS NEXUS (name beamline institute data-file-format) +RUN data/EMU00005989_v2 XXXX ISIS NEXUS (name beamline institute data-file-format) fittype 0 (single histogram fit) norm 9 backgr.fit 10 diff --git a/src/Makefile.am b/src/Makefile.am index 47a8afda..4ed8f027 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -17,12 +17,23 @@ SUBDIRS = external/TLemRunHeader \ external/mud \ $(PNEXUSDIRS) \ classes \ - external \ - $(EDITORDIR) + external +if BUILD_MUSRGUI +SUBDIRS += $(EDITORDIR) EXTRA_DIST = $(EDITORDIR)/Makefile +endif + +if BUILD_MUSREDIT +SUBDIRS += $(EDITORDIR) +EXTRA_DIST = $(EDITORDIR)/Makefile +endif bin_PROGRAMS = musrfit musrview musrt0 musrparam msr2msr msr2data any2many +if PNEXUS_ENABLED +bin_PROGRAMS += nexus_dump +endif + musrfit_SOURCES = musrfit.cpp musrview_SOURCES = musrview.cpp musrt0_SOURCES = musrt0.cpp @@ -30,6 +41,9 @@ musrparam_SOURCES = musrparam.cpp msr2msr_SOURCES = msr2msr.cpp msr2data_SOURCES = msr2data.cpp any2many_SOURCES = any2many.cpp +if PNEXUS_ENABLED +nexus_dump_SOURCES = nexus_dump.cpp +endif xmldir = $(bindir) xml_DATA = musrfit_startup.xml @@ -39,6 +53,10 @@ LIBADD = $(PMUSR_LIBS) $(LEM_LIBS) $(PSIBIN_LIBS) $(MUD_LIBS) $(PNEXUS_LIBS) AM_CXXFLAGS = $(LOCAL_BIN_CXXFLAGS) AM_LDFLAGS = $(LOCAL_BIN_LDFLAGS) INCLUDES = $(PMUSR_CFLAGS) $(FFTW3_CFLAGS) $(GSL_CFLAGS) $(BOOST_CFLAGS) $(ROOT_CFLAGS) +if PNEXUS_ENABLED +INCLUDES += $(HDF5_CFLAGS) $(NEXUS_CFLAGS) $(PNEXUS_CXXFLAGS) +endif + LIBS = $(PMUSR_LIBS) $(USERFCN_LIBS) $(LEM_LIBS) $(PSIBIN_LIBS) $(MUD_LIBS) $(PNEXUS_LIBS) $(FFTW3_LIBS) $(GSL_LIBS) $(ROOT_LIBS) install-xmlDATA: $(xml_DATA) @@ -72,12 +90,10 @@ uninstall-xmlDATA: read REMOVE && \ if test "$$REMOVE" = "y" || test "$$REMOVE" = "Y"; then \ echo "$(RM) '$(DESTDIR)$(xmldir)/$(xml_DATA)'" && \ - $(RM) "$(DESTDIR)$(xmldir)/$(xml_DATA)" && \ - rmdir "$(DESTDIR)$(xmldir)"; \ + $(RM) "$(DESTDIR)$(xmldir)/$(xml_DATA)"; \ fi; \ else \ echo "$(RM) '$(DESTDIR)$(xmldir)/$(xml_DATA)'" && \ - $(RM) "$(DESTDIR)$(xmldir)/$(xml_DATA)" && \ - rmdir "$(DESTDIR)$(xmldir)"; \ + $(RM) "$(DESTDIR)$(xmldir)/$(xml_DATA)"; \ fi; \ fi diff --git a/src/any2many.cpp b/src/any2many.cpp index 2b436242..71a8ec36 100644 --- a/src/any2many.cpp +++ b/src/any2many.cpp @@ -53,8 +53,8 @@ void any2many_syntax() cout << endl << "usage: any2many [--help] : will show this help."; cout << endl << " any2many --version : will show the svn version."; cout << endl << " any2many -f | -r "; - cout << endl << " -c [-p ]"; - cout << endl << " [-y ] [-t ] [-s]"; + cout << endl << " -c [-p ] [-y ]"; + cout << endl << " [-o | -t ] [-s]"; cout << endl << " [-rebin ] [-z ]"; cout << endl << " -f : where is space"; cout << endl << " separeted a list of file names (not starting with a '-'),"; diff --git a/src/classes/PMusr.cpp b/src/classes/PMusr.cpp index 36ac64f3..28efb7be 100644 --- a/src/classes/PMusr.cpp +++ b/src/classes/PMusr.cpp @@ -224,6 +224,8 @@ PRawRunData::PRawRunData() fLaboratory = TString("n/a"); fBeamline = TString("n/a"); fInstrument = TString("n/a"); + fMuonSource = TString("n/a"); + fMuonSpecies = TString("n/a"); fRunName = TString("n/a"); fRunNumber = -1; fRunTitle = TString("n/a"); diff --git a/src/classes/PRunDataHandler.cpp b/src/classes/PRunDataHandler.cpp index 0b4b1e31..e2c6a4eb 100644 --- a/src/classes/PRunDataHandler.cpp +++ b/src/classes/PRunDataHandler.cpp @@ -39,6 +39,7 @@ #include #include #include +#include using namespace std; #include @@ -584,7 +585,7 @@ Bool_t PRunDataHandler::ReadWriteFilesList() } //-------------------------------------------------------------------------- -// FileAlreadyRead +// FileAlreadyRead (private) //-------------------------------------------------------------------------- /** *

Checks if a file has been already read in order to prevent multiple @@ -608,7 +609,7 @@ Bool_t PRunDataHandler::FileAlreadyRead(TString runName) } //-------------------------------------------------------------------------- -// TestFileName -- private +// TestFileName (private) //-------------------------------------------------------------------------- /** *

Tests if a file exists (with or without given extension). @@ -622,75 +623,91 @@ void PRunDataHandler::TestFileName(TString &runName, const TString &ext) TString tmpStr(runName), tmpExt(ext); // check first if the file exists with the default extension which is not given with the run name - runName += TString(".") + ext; - if (gSystem->AccessPathName(runName.Data()) != true) { // found - return; - } - - // test if the file exists with only upper-case letters - runName.ToUpper(); - if (gSystem->AccessPathName(runName.Data()) != true) { // found - return; - } - - // test if the file exists with only lower-case letters - runName.ToLower(); - if (gSystem->AccessPathName(runName.Data()) != true) { // found + tmpStr += TString(".") + ext; + if (gSystem->AccessPathName(tmpStr.Data()) != true) { // found + runName = tmpStr; return; } // test if the file exists with the given run name but an only upper-case extension which is not included in the file name - runName = tmpStr; + tmpStr = runName; tmpExt.ToUpper(); - runName += TString(".") + tmpExt; - if (gSystem->AccessPathName(runName.Data()) != true) { // found + tmpStr += TString(".") + tmpExt; + if (gSystem->AccessPathName(tmpStr.Data()) != true) { // found + runName = tmpStr; return; } // test if the file exists with the given run name but an only lower-case extension which is not included in the file name + tmpStr = runName; tmpExt.ToLower(); - runName = runName.Replace(static_cast(runName.Length()-tmpExt.Length()), tmpExt.Length(), tmpExt); - if (gSystem->AccessPathName(runName.Data()) != true) { // found + tmpStr += TString(".") + tmpExt; + if (gSystem->AccessPathName(tmpStr.Data()) != true) { // found + runName = tmpStr; return; } - runName = tmpStr; + // test if the file exists with only upper-case letters + tmpStr = runName + TString(".") + tmpExt; + tmpStr.ToUpper(); + if (gSystem->AccessPathName(tmpStr.Data()) != true) { // found + runName = tmpStr; + return; + } + + // test if the file exists with only lower-case letters + tmpStr.ToLower(); + if (gSystem->AccessPathName(tmpStr.Data()) != true) { // found + runName = tmpStr; + return; + } + + tmpStr = runName; // the extension is already part of the file name, therefore, do not append it - if (runName.EndsWith(ext.Data(), TString::kIgnoreCase)) { - if (gSystem->AccessPathName(runName.Data()) != true) { // found + if (tmpStr.EndsWith(ext.Data(), TString::kIgnoreCase)) { + if (gSystem->AccessPathName(tmpStr.Data()) != true) { // found + runName = tmpStr; return; } // assume some extension is part of the given file name but the real data file ends with an lower-case extension tmpExt.ToLower(); - runName = runName.Replace(static_cast(runName.Length()-tmpExt.Length()), tmpExt.Length(), tmpExt); - if (gSystem->AccessPathName(runName.Data()) != true) { // found + tmpStr = tmpStr.Replace(static_cast(tmpStr.Length()-tmpExt.Length()), tmpExt.Length(), tmpExt); + if (gSystem->AccessPathName(tmpStr.Data()) != true) { // found + runName = tmpStr; return; } // assume some extension is part of the given file name but the real data file ends with an upper-case extension tmpExt.ToUpper(); - runName = runName.Replace(static_cast(runName.Length()-tmpExt.Length()), tmpExt.Length(), tmpExt); - if (gSystem->AccessPathName(runName.Data()) != true) { // found + tmpStr = runName; + tmpStr = tmpStr.Replace(static_cast(tmpStr.Length()-tmpExt.Length()), tmpExt.Length(), tmpExt); + if (gSystem->AccessPathName(tmpStr.Data()) != true) { // found + runName = tmpStr; return; } // test if the file exists with only lower-case letters and the extension already included in the file name - runName.ToLower(); - if (gSystem->AccessPathName(runName.Data()) != true) { // found + tmpStr = runName; + tmpStr.ToLower(); + if (gSystem->AccessPathName(tmpStr.Data()) != true) { // found + runName = tmpStr; return; } // test if the file exists with only upper-case letters and the extension already included in the file name - runName.ToUpper(); - if (gSystem->AccessPathName(runName.Data()) != true) { // found + tmpStr = runName; + tmpStr.ToUpper(); + if (gSystem->AccessPathName(tmpStr.Data()) != true) { // found + runName = tmpStr; return; } } // if the file has not been found, set the run name to be empty runName = ""; + return; } @@ -1043,6 +1060,8 @@ Bool_t PRunDataHandler::ReadRootFile(UInt_t tag) runData.SetLaboratory("PSI"); runData.SetBeamline("muE4"); runData.SetInstrument("LEM"); + runData.SetMuonSource("low energy muon source"); + runData.SetMuonSpecies("positive muons"); // get run title TObjString ostr = runHeader->GetRunTitle(); @@ -1072,36 +1091,14 @@ Bool_t PRunDataHandler::ReadRootFile(UInt_t tag) time_t idt = (time_t)runHeader->GetStartTime(); runData.SetStartDateTime(idt); struct tm *dt = localtime(&idt); - TString stime(""); - Int_t yy = dt->tm_year; - if (yy > 100) - yy -= 100; - if (yy < 10) - stime += "0"; - stime += yy; - stime += "-"; - stime += GetMonth(dt->tm_mon); - stime += "-"; - if (dt->tm_mday < 10) - stime += "0"; - stime += dt->tm_mday; + char str[128]; + strftime(str, sizeof(str), "%F", dt); + TString stime(str); runData.SetStartDate(stime); // start time - if (dt->tm_hour == 0) - stime = "00"; - else if (dt->tm_hour < 10) - stime = "0"; - else - stime = ""; - stime += dt->tm_hour; - stime += ":"; - if (dt->tm_min < 10) - stime += "0"; - stime += dt->tm_min; - stime += ":"; - if (dt->tm_sec < 10) - stime += "0"; - stime += dt->tm_sec; + memset(str, 0, sizeof(str)); + strftime(str, sizeof(str), "%T", dt); + stime = str; runData.SetStartTime(stime); // get stop time/date @@ -1109,43 +1106,21 @@ Bool_t PRunDataHandler::ReadRootFile(UInt_t tag) idt = (time_t)runHeader->GetStopTime(); runData.SetStopDateTime(idt); dt = localtime(&idt); - stime = ""; - yy = dt->tm_year; - if (yy > 100) - yy -= 100; - if (yy < 10) - stime += "0"; - stime += yy; - stime += "-"; - stime += GetMonth(dt->tm_mon); - stime += "-"; - if (dt->tm_mday < 10) - stime += "0"; - stime += dt->tm_mday; + memset(str, 0, sizeof(str)); + strftime(str, sizeof(str), "%F", dt); + stime = str; runData.SetStopDate(stime); // stop time - if (dt->tm_hour == 0) - stime = "00"; - else if (dt->tm_hour < 10) - stime = "0"; - else - stime = ""; - stime += dt->tm_hour; - stime += ":"; - if (dt->tm_min < 10) - stime += "0"; - stime += dt->tm_min; - stime += ":"; - if (dt->tm_sec < 10) - stime += "0"; - stime += dt->tm_sec; + memset(str, 0, sizeof(str)); + strftime(str, sizeof(str), "%T", dt); + stime = str; runData.SetStopTime(stime); // get time resolution runData.SetTimeResolution(runHeader->GetTimeResolution()); // get number of histogramms - Int_t noOfHistos = runHeader->GetNHist(); + Int_t noOfHistos = runHeader->GetNHist(); // get t0's Double_t *t0 = runHeader->GetTimeZero(); @@ -1155,6 +1130,11 @@ Bool_t PRunDataHandler::ReadRootFile(UInt_t tag) for (Int_t i=0; iGetEntryIdf2()->GetInstrument()->GetSource()->GetName()); + runData.SetLaboratory(str); + + // get/set beamline + str = TString(nxs_file->GetEntryIdf2()->GetInstrument()->GetName()); + runData.SetBeamline(str); + + // get/set instrument + str = TString(nxs_file->GetEntryIdf2()->GetInstrument()->GetName()); + runData.SetInstrument(str); + + // get/set muon source + str = TString(nxs_file->GetEntryIdf2()->GetInstrument()->GetSource()->GetType()); + runData.SetMuonSource(str); + + // get/set muon species + str = TString(nxs_file->GetEntryIdf2()->GetInstrument()->GetSource()->GetProbe()); + runData.SetMuonSpecies(str); + // get/set run title str = TString(nxs_file->GetEntryIdf2()->GetTitle()); runData.SetRunTitle(str); @@ -1588,7 +1588,7 @@ Bool_t PRunDataHandler::ReadNexusFile() int *lgb = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetLastGoodBins(); PIntPair goodDataBin; - if (nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetT0Tag() == 2) { // t0, fgb, lgb: [][] + if (nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetT0Tag() == 3) { // t0, fgb, lgb: [][] for (int i=0; iGetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfPeriods(); i++) { for (int j=0; jGetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfSpectra(); j++) { if (fgb && lgb) { @@ -1601,6 +1601,17 @@ Bool_t PRunDataHandler::ReadNexusFile() } } } + } else if (nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetT0Tag() == 2) { // t0, fgb, lgb: [] + for (int i=0; iGetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfSpectra(); i++) { + if (fgb && lgb) { + goodDataBin.first = *(fgb+i); + goodDataBin.second = *(lgb+i); + } + runData.AppendT0(*(t0+i)); + if (fgb && lgb) { + runData.AppendGoodDataBin(goodDataBin); + } + } } else { // t0, fgb, lgb: single numbers if (fgb && lgb) { goodDataBin.first = *fgb; @@ -2011,27 +2022,42 @@ Bool_t PRunDataHandler::ReadPsiBinFile() // filter from the file name the instrument TString instrument("n/a"), beamline("n/a"); + TString muonSource("n/a"), muonSpecies("n/a"); if (fRunPathName.Contains("_gps_", TString::kIgnoreCase)) { instrument = "GPS"; beamline = "piM3.2"; + muonSource = "continuous surface muon source"; + muonSpecies = "positive muons"; } else if (fRunPathName.Contains("_ltf_", TString::kIgnoreCase)) { instrument = "LTF"; beamline = "piM3.3"; + muonSource = "continuous surface muon source"; + muonSpecies = "positive muons"; } else if (fRunPathName.Contains("_gpd_", TString::kIgnoreCase)) { instrument = "GPD"; beamline = "muE1"; + muonSource = "continuous decay channel muon source"; + muonSpecies = "positive muons"; } else if (fRunPathName.Contains("_dolly_", TString::kIgnoreCase)) { instrument = "DOLLY"; beamline = "piE1"; + muonSource = "continuous surface muon source"; + muonSpecies = "positive muons"; } else if (fRunPathName.Contains("_alc_", TString::kIgnoreCase)) { instrument = "ALC"; beamline = "piE3"; + muonSource = "continuous surface muon source"; + muonSpecies = "positive muons"; } else if (fRunPathName.Contains("_hifi_", TString::kIgnoreCase)) { instrument = "HIFI"; beamline = "piE3"; + muonSource = "continuous surface muon source"; + muonSpecies = "positive muons"; } runData.SetInstrument(instrument); runData.SetBeamline(beamline); + runData.SetMuonSource(muonSource); + runData.SetMuonSpecies(muonSpecies); // keep run name runData.SetRunName(fRunName); @@ -2091,7 +2117,13 @@ Bool_t PRunDataHandler::ReadPsiBinFile() if (sDateTime.size() < 2) { cerr << endl << ">> **WARNING** psi-bin file: couldn't obtain run start date/time" << endl; } - runData.SetStartDate(sDateTime[0]); + string date(""); + if (DateToISO8601(sDateTime[0], date)) { + runData.SetStartDate(date); + } else { + cerr << endl << ">> **WARNING** failed to convert start date: " << sDateTime[0] << " into ISO 8601 date." << endl; + runData.SetStartDate(sDateTime[0]); + } runData.SetStartTime(sDateTime[1]); sDateTime.clear(); @@ -2099,7 +2131,13 @@ Bool_t PRunDataHandler::ReadPsiBinFile() if (sDateTime.size() < 2) { cerr << endl << ">> **WARNING** psi-bin file: couldn't obtain run stop date/time" << endl; } - runData.SetStopDate(sDateTime[0]); + date = string(""); + if (DateToISO8601(sDateTime[0], date)) { + runData.SetStopDate(date); + } else { + cerr << endl << ">> **WARNING** failed to convert stop date: " << sDateTime[0] << " into ISO 8601 date." << endl; + runData.SetStopDate(sDateTime[0]); + } runData.SetStopTime(sDateTime[1]); sDateTime.clear(); @@ -2209,41 +2247,20 @@ Bool_t PRunDataHandler::ReadMudFile() time_t tval; struct tm *dt; TString stime(""); - Int_t yy = 0; success = MUD_getTimeBegin( fh, (UINT32*)&tval ); if (success) { runData.SetStartDateTime((const time_t)tval); dt = localtime((const time_t*)&tval); assert(dt); - yy = dt->tm_year; - if (yy > 100) - yy -= 100; - if (yy < 10) - stime += "0"; - stime += yy; - stime += "-"; - stime += GetMonth(dt->tm_mon); - stime += "-"; - if (dt->tm_mday < 10) - stime += "0"; - stime += dt->tm_mday; + + // start date + strftime(str, sizeof(str), "%F", dt); + stime = str; runData.SetStartDate(stime); // start time - if (dt->tm_hour == 0) - stime = "00"; - else if (dt->tm_hour < 10) - stime = "0"; - else - stime = ""; - stime += dt->tm_hour; - stime += ":"; - if (dt->tm_min < 10) - stime += "0"; - stime += dt->tm_min; - stime += ":"; - if (dt->tm_sec < 10) - stime += "0"; - stime += dt->tm_sec; + memset(str, 0, sizeof(str)); + strftime(str, sizeof(str), "%T", dt); + stime = str; runData.SetStartTime(stime); } @@ -2253,36 +2270,15 @@ Bool_t PRunDataHandler::ReadMudFile() runData.SetStopDateTime((const time_t)tval); dt = localtime((const time_t*)&tval); assert(dt); - stime = ""; - yy = dt->tm_year; - if (yy > 100) - yy -= 100; - if (yy < 10) - stime += "0"; - stime += yy; - stime += "-"; - stime += GetMonth(dt->tm_mon); - stime += "-"; - if (dt->tm_mday < 10) - stime += "0"; - stime += dt->tm_mday; + + // stop date + strftime(str, sizeof(str), "%F", dt); + stime = str; runData.SetStopDate(stime); // stop time - if (dt->tm_hour == 0) - stime = "00"; - else if (dt->tm_hour < 10) - stime = "0"; - else - stime = ""; - stime += dt->tm_hour; - stime += ":"; - if (dt->tm_min < 10) - stime += "0"; - stime += dt->tm_min; - stime += ":"; - if (dt->tm_sec < 10) - stime += "0"; - stime += dt->tm_sec; + memset(str, 0, sizeof(str)); + strftime(str, sizeof(str), "%T", dt); + stime = str; runData.SetStopTime(stime); } @@ -3687,8 +3683,6 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln) { #ifdef PNEXUS_ENABLED - int *t0=0, *fgb=0, *lgb=0, *histo=0; - // generate output file name if (fln.Length() == 0) { Bool_t ok = false; @@ -3725,7 +3719,7 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln) tm = localtime(&now); string str(""); char cstr[128]; - sprintf(cstr, "%04d-%02d-%02d %02d:%02d:%02d", 1900+tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_hour, tm->tm_sec); + strftime(cstr, sizeof(cstr), "%FT%T", tm); str = string(cstr); nxs->SetFileTime(str); @@ -3739,9 +3733,9 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln) nxs->GetEntryIdf1()->SetLaboratory(fData[0].GetLaboratory()->Data()); if (*fData[0].GetBeamline() != "n/a") nxs->GetEntryIdf1()->SetBeamline(fData[0].GetBeamline()->Data()); - str = string(fData[0].GetStartDate()->Data()) + string(" ") + string(fData[0].GetStartTime()->Data()); + str = string(fData[0].GetStartDate()->Data()) + string("T") + string(fData[0].GetStartTime()->Data()); nxs->GetEntryIdf1()->SetStartTime(str); - str = string(fData[0].GetStopDate()->Data()) + string(" ") + string(fData[0].GetStopTime()->Data()); + str = string(fData[0].GetStopDate()->Data()) + string("T") + string(fData[0].GetStopTime()->Data()); nxs->GetEntryIdf1()->SetStopTime(str); nxs->GetEntryIdf1()->SetSwitchingState(1); nxs->GetEntryIdf1()->GetUser()->SetName("n/a"); @@ -3749,13 +3743,23 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln) nxs->GetEntryIdf1()->GetSample()->SetName(fData[0].GetSample()->Data()); nxs->GetEntryIdf1()->GetSample()->SetPhysProp("temperature", fData[0].GetTemperature(0), "Kelvin"); nxs->GetEntryIdf1()->GetSample()->SetPhysProp("magnetic_field", fData[0].GetField(), "Gauss"); - nxs->GetEntryIdf1()->GetSample()->SetEnvironment("n/a"); + nxs->GetEntryIdf1()->GetSample()->SetEnvironment(fData[0].GetSetup()->Data()); nxs->GetEntryIdf1()->GetSample()->SetShape("n/a"); nxs->GetEntryIdf1()->GetSample()->SetMagneticFieldVectorAvailable(0); if (*fData[0].GetInstrument() != "n/a") nxs->GetEntryIdf1()->GetInstrument()->SetName(fData[0].GetInstrument()->Data()); nxs->GetEntryIdf1()->GetInstrument()->GetDetector()->SetNumber(fData[0].GetNoOfHistos()); nxs->GetEntryIdf1()->GetInstrument()->GetCollimator()->SetType("n/a"); + // calculate the total number of counts + int total_counts = 0; + for (unsigned int i=0; isize(); j++) + total_counts += fData[0].GetDataBin(i)->at(j); + } + double total_counts_mev = (double) total_counts / 1.0e6; + nxs->GetEntryIdf1()->GetInstrument()->GetBeam()->SetTotalCounts(total_counts_mev); + nxs->GetEntryIdf1()->GetInstrument()->GetBeam()->SetUnits("Mev"); + nxs->GetEntryIdf1()->GetData()->SetTimeResolution(fData[0].GetTimeResolution(), "ns"); // t0 @@ -3792,60 +3796,149 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln) tm = localtime(&now); string str(""); char cstr[128]; - sprintf(cstr, "%04d-%02d-%02d %02d:%02d:%02d", 1900+tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_hour, tm->tm_sec); + strftime(cstr, sizeof(cstr), "%FT%T", tm); str = string(cstr); nxs->SetFileTime(str); - nxs->SetCreator("PSI - any2many"); + // NXroot info + nxs->SetCreator("PSI: any2many"); - nxs->GetEntryIdf2()->SetDefinition("pulsedTD"); + // NXentry info + nxs->GetEntryIdf2()->SetDefinition("muonTD"); + nxs->GetEntryIdf2()->SetProgramName("any2many"); + nxs->GetEntryIdf2()->SetProgramVersion("$Id$"); nxs->GetEntryIdf2()->SetRunNumber(fData[0].GetRunNumber()); nxs->GetEntryIdf2()->SetTitle(fData[0].GetRunTitle()->Data()); - str = string(fData[0].GetStartDate()->Data()) + string(" ") + string(fData[0].GetStartTime()->Data()); + str = string(fData[0].GetStartDate()->Data()) + string("T") + string(fData[0].GetStartTime()->Data()); nxs->GetEntryIdf2()->SetStartTime(str); - str = string(fData[0].GetStopDate()->Data()) + string(" ") + string(fData[0].GetStopTime()->Data()); + str = string(fData[0].GetStopDate()->Data()) + string("T") + string(fData[0].GetStopTime()->Data()); nxs->GetEntryIdf2()->SetStopTime(str); nxs->GetEntryIdf2()->SetExperimentIdentifier("n/a"); + // NXuser info nxs->GetEntryIdf2()->GetUser()->SetName("n/a"); + // NXsample info nxs->GetEntryIdf2()->GetSample()->SetName(fData[0].GetSample()->Data()); nxs->GetEntryIdf2()->GetSample()->SetDescription("n/a"); nxs->GetEntryIdf2()->GetSample()->SetPhysProp("temperature_1", fData[0].GetTemperature(0), "Kelvin"); nxs->GetEntryIdf2()->GetSample()->SetPhysProp("magnetic_field_1", fData[0].GetField(), "Gauss"); - nxs->GetEntryIdf2()->GetSample()->SetEnvironmentTemp("n/a"); + nxs->GetEntryIdf2()->GetSample()->SetEnvironmentTemp(fData[0].GetSetup()->Data()); nxs->GetEntryIdf2()->GetSample()->SetEnvironmentField("n/a"); - // here would be the information for NXinstrument. Currently there are not enough information to feed this + // here would be the information for NXinstrument. Currently there are not much information to feed this + nxs->GetEntryIdf2()->GetInstrument()->SetName(fData[0].GetInstrument()->Data()); - nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetDescription("n/a"); - nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetNoOfPeriods(1); // currently red/green is not distinguished + // NXinstrument/NXsource + nxs->GetEntryIdf2()->GetInstrument()->GetSource()->SetName(fData[0].GetLaboratory()->Data()); + nxs->GetEntryIdf2()->GetInstrument()->GetSource()->SetType(fData[0].GetMuonSource()->Data()); + nxs->GetEntryIdf2()->GetInstrument()->GetSource()->SetProbe(fData[0].GetMuonSpecies()->Data()); + + // NXinstrument/NXbeamline + nxs->GetEntryIdf2()->GetInstrument()->GetBeamline()->SetName(fData[0].GetBeamline()->Data()); + + // NXinstrument/NXdetector + nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetDescription(fData[0].GetInstrument()->Data()); // assume that this should be the instrument name + nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetNoOfPeriods(0); // currently red/green is not distinguished nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetNoOfSpectra(fData[0].GetNoOfHistos()); nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetNoOfBins(fData[0].GetDataBin(0)->size()); nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetTimeResolution(fData[0].GetTimeResolution(), "ns"); - histo = new int[fData[0].GetNoOfHistos()*fData[0].GetDataBin(0)->size()]; + int *histo = new int[fData[0].GetNoOfHistos()*fData[0].GetDataBin(0)->size()]; for (int i=0; iGetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfSpectra(); i++) { for (unsigned int j=0; jsize(); j++) { *(histo+i*fData[0].GetDataBin(0)->size()+j) = (int) fData[0].GetDataBin(i)->at(j); } } nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetHistos(histo); + // clean up + if (histo) { + delete [] histo; + histo = 0; + } + + // handle spectrum index for (int i=0; iGetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfSpectra(); i++) nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetSpectrumIndex(i+1); - nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetT0Tag(2); - int *t0 = new int[fData[0].GetT0Size()]; + // handle histogram resolution + nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetTimeResolution(fData[0].GetTimeResolution(), "ns"); + + // handle raw time + vector raw_time; + for (unsigned int i=0; isize(); i++) { + raw_time.push_back((double)i * fData[0].GetTimeResolution() * 1.0e-3); // since time resolution is given in ns, the factor 1.0e-3 is needed to convert to us + } + nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetRawTime(raw_time); + nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetRawTimeUnit("micro.second"); + nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetRawTimeName("time"); + raw_time.clear(); + + // handle t0 + nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetT0Tag(2); // i.e. t0[#histo] format + int *t0 = new int[fData[0].GetNoOfHistos()]; for (unsigned int i=0; i> **WARNING** NO t0's are present in the original file, will use the estimated once, no waranty this is correct!!" << endl; + } + if (iGetEntryIdf2()->GetInstrument()->GetDetector()->SetT0(t0); - // first_good_bin - still missing - // last_good_bin - still missing + // handle first_good_bin + int *fgb = new int[fData[0].GetNoOfHistos()]; + for (unsigned int i=0; iGetEntryIdf2()->GetInstrument()->GetDetector()->SetFirstGoodBin(fgb); + // clean up + if (fgb) { + delete [] fgb; + fgb = 0; + } + + // handle last_good_bin + int *lgb = new int[fData[0].GetNoOfHistos()]; + for (unsigned int i=0; isize() - 1; + } else { // first good bin present + if (i < fData[0].GetGoodDataBinSize()) + lgb[i] = fData[0].GetGoodDataBin(i).second; + else + lgb[i] = fData[0].GetGoodDataBin(0).second; + } + } + nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetLastGoodBin(lgb); + // clean up + if (lgb) { + delete [] lgb; + lgb = 0; + } + + // clean up + if (t0) { + delete [] t0; + t0 = 0; + } + } else { // clean up if (nxs != 0) { @@ -3877,23 +3970,6 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln) // write file nxs->WriteFile(fln, fileType, fAny2ManyInfo->idf); - // clean up - if (t0) { - delete [] t0; - t0 = 0; - } - if (fgb) { - delete [] fgb; - fgb = 0; - } - if (lgb) { - delete [] lgb; - lgb = 0; - } - if (histo) { - delete [] histo; - histo = 0; - } if (nxs != 0) { delete nxs; nxs = 0; @@ -4915,49 +4991,32 @@ TString PRunDataHandler::FileNameFromTemplate(TString &fileNameTemplate, Int_t r } //-------------------------------------------------------------------------- -// GetMonth (private) +// DateToISO8601 (private) //-------------------------------------------------------------------------- /** - *

Spits out the month as MMM for a given numerical month 0..11 + *

If possible converts a inDate, into a ISO8601 standard date. * - * return: - * - constructed file name from template, run number, and year - * - empty string + *

return: true if conversion was successfull otherwise false. * - * \param template template string + * \param inDate input date which should be converted to an ISO 8601 date. + * \param iso8601Date on success the converted iso8601Date, otherwise an empty string */ -TString PRunDataHandler::GetMonth(Int_t month) +bool PRunDataHandler::DateToISO8601(string inDate, string &iso8601Date) { - TString mm(""); + iso8601Date = string(""); - if (month == 0) - mm = "JAN"; - else if (month == 1) - mm = "FEB"; - else if (month == 2) - mm = "MAR"; - else if (month == 3) - mm = "APR"; - else if (month == 4) - mm = "MAY"; - else if (month == 5) - mm = "JUN"; - else if (month == 6) - mm = "JUL"; - else if (month == 7) - mm = "AUG"; - else if (month == 8) - mm = "SEP"; - else if (month == 9) - mm = "OCT"; - else if (month == 10) - mm = "NOV"; - else if (month == 11) - mm = "DEC"; - else - mm = "???"; + struct tm tm; - return mm; + // currently only dates like dd-mmm-yy are handled, where dd day of the month, mmm month as abbrivation, e.g. JAN, and yy as the year + if (!strptime(inDate.c_str(), "%d-%b-%y", &tm)) // failed + return false; + + TString str(""); + str.Form("%04d-%02d-%02d", 1900+tm.tm_year, tm.tm_mon, tm.tm_mday); + + iso8601Date = str.Data(); + + return true; } //-------------------------------------------------------------------------- diff --git a/src/external/nexus/PNeXus.cpp b/src/external/nexus/PNeXus.cpp index 645a2349..cb0d58fb 100644 --- a/src/external/nexus/PNeXus.cpp +++ b/src/external/nexus/PNeXus.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -835,6 +836,7 @@ PNeXusDetector2::PNeXusDetector2() PNeXusDetector2::~PNeXusDetector2() { fSpectrumIndex.clear(); + fRawTime.clear(); if (fT0) { delete [] fT0; @@ -891,8 +893,13 @@ bool PNeXusDetector2::IsValid(bool strict) return false; } - if ((fT0 == 0) || (fHisto == 0)) { - cerr << ">> **ERROR** IDF2 NXdetector problem with t0/counts settings (data)." << endl; + if (fT0 == 0) { + cerr << ">> **ERROR** IDF2 NXdetector t0 settings pointer is null." << endl; + return false; + } + + if (fHisto == 0) { + cerr << ">> **ERROR** IDF2 NXdetector counts settings pointer is null." << endl; return false; } @@ -917,14 +924,20 @@ int PNeXusDetector2::GetT0(int idxp, int idxs) { int result = -1; - if ((idxp < 0) || (idxs < 0)) { // assumption: there is only ONE t0 for all spectra + if ((idxp < 0) && (idxs < 0)) { // assumption: there is only ONE t0 for all spectra if (fT0 != 0) { result = *fT0; } - } else { // assumption: t0's are represented as t0[np][ns] + } else if ((idxp < 0) && (idxs >= 0)) { // assumption: t0's are represented as t0[ns] + if (idxs < fNoOfSpectra) { + result = *(fT0+idxs); + } + } else if ((idxp >= 0) && (idxs >= 0)) { // assumption: t0's are represented as t0[np][ns] if ((idxp < fNoOfPeriods) || (idxs < fNoOfSpectra)) { result = *(fT0+idxp*fNoOfSpectra+idxs); } + } else { + result = -1; } return result; @@ -959,10 +972,18 @@ int PNeXusDetector2::SetT0(int *t0) fErrorMsg = ss.str(); result = 0; break; - case 1: + case 1: // just one single t0 size = 1; break; - case 2: + case 2: // t0[#histos] + if (fNoOfSpectra <= 0) { + fErrorMsg = "PNeXusDetector2::SetT0(int *t0): ask for t0 vector (ns), but ns <= 0!"; + result = 0; + } else { + size = fNoOfSpectra; + } + break; + case 3: // t0[np][#histos] if ((fNoOfPeriods <= 0) || (fNoOfSpectra <= 0)) { fErrorMsg = "PNeXusDetector2::SetT0(int *t0): ask for t0 vector (np, ns), but either np or ns <= 0!"; result = 0; @@ -1013,14 +1034,20 @@ int PNeXusDetector2::GetFirstGoodBin(int idxp, int idxs) { int result = -1; - if ((idxp < 0) || (idxs < 0)) { // assumption: there is only ONE t0 for all spectra + if ((idxp < 0) && (idxs < 0)) { // assumption: there is only ONE t0 for all spectra if (fFirstGoodBin != 0) { result = *fFirstGoodBin; } - } else { // assumption: fgb's are represented as fgb[np][ns] + } else if ((idxp < 0) && (idxs >= 0)) { // assumptions: fgb's are represented as fgb[ns] + if (idxs < fNoOfSpectra) { + result = *(fFirstGoodBin+idxs); + } + } else if ((idxp >= 0) && (idxs >= 0)) { // assumption: fgb's are represented as fgb[np][ns] if ((idxp < fNoOfPeriods) || (idxs < fNoOfSpectra)) { result = *(fFirstGoodBin+idxp*fNoOfSpectra+idxs); } + } else { + result = -1; } return result; @@ -1055,10 +1082,18 @@ int PNeXusDetector2::SetFirstGoodBin(int *fgb) fErrorMsg = ss.str(); result = 0; break; - case 1: + case 1: // single fgb size = 1; break; - case 2: + case 2: // fgb[#histos] + if (fNoOfSpectra <= 0) { + fErrorMsg = "PNeXusDetector2::SetFirstGoodBin(int *fgb): ask for fgb vector (ns), but ns <= 0!"; + result = 0; + } else { + size = fNoOfSpectra; + } + break; + case 3: // fgb[np][#histos] if ((fNoOfPeriods <= 0) || (fNoOfSpectra <= 0)) { fErrorMsg = "PNeXusDetector2::SetFirstGoodBin(int *fgb): ask for fgb vector (np, ns), but either np or ns <= 0!"; result = 0; @@ -1109,14 +1144,20 @@ int PNeXusDetector2::GetLastGoodBin(int idxp, int idxs) { int result = -1; - if ((idxp < 0) || (idxs < 0)) { // assumption: there is only ONE t0 for all spectra + if ((idxp < 0) && (idxs < 0)) { // assumption: there is only ONE t0 for all spectra if (fLastGoodBin != 0) { result = *fLastGoodBin; } - } else { // assumption: lgb's are represented as lgb[np][ns] + } else if ((idxp < 0) && (idxs >= 0)) { // assumption: lgb's are represented as lgb[ns] + if (idxs < fNoOfSpectra) { + result = *(fLastGoodBin+idxs); + } + } else if ((idxp >= 0) && (idxs >= 0)) { // assumption: lgb's are represented as lgb[np][ns] if ((idxp < fNoOfPeriods) || (idxs < fNoOfSpectra)) { result = *(fLastGoodBin+idxp*fNoOfSpectra+idxs); } + } else { + result = -1; } return result; @@ -1151,10 +1192,18 @@ int PNeXusDetector2::SetLastGoodBin(int *lgb) fErrorMsg = ss.str(); result = 0; break; - case 1: + case 1: // single lgb only size = 1; break; - case 2: + case 2: // lgb[#histos] + if (fNoOfSpectra <= 0) { + fErrorMsg = "PNeXusDetector2::SetLastGoodBin(int *lgb): ask for lgb vector (ns), but ns <= 0!"; + result = 0; + } else { + size = fNoOfSpectra; + } + break; + case 3: // lgb[np][#histos] if ((fNoOfPeriods <= 0) || (fNoOfSpectra <= 0)) { fErrorMsg = "PNeXusDetector2::SetLastGoodBin(int *lgb): ask for lgb vector (np, ns), but either np or ns <= 0!"; result = 0; @@ -1343,6 +1392,20 @@ void PNeXusDetector2::SetTimeResolution(double val, string units) fTimeResolution = val * 1.0e6; } +//------------------------------------------------------------------------------------------ +// SetRawTime (public) +//------------------------------------------------------------------------------------------ +/** + *

sets the raw time (deep copy). + * + * \param rawTime raw time vector. + */ +void PNeXusDetector2::SetRawTime(vector &rawTime) +{ + for (unsigned int i=0; i> **ERROR** " << msg << endl; - return false; - } else { - cerr << ">> **WARNING** " << msg << endl; - } + cerr << ">> **WARNING** IDF2 NXsample 'name' not set." << msg << endl; } if (!fDescription.compare("n/a")) { @@ -1996,14 +2053,14 @@ int PNeXus::ReadFile(const char *fileName) status = ReadFileIdf1(); if (status != NX_OK) { fErrorCode = PNEXUS_VAILD_READ_IDF1_FILE; - fErrorMsg = ">> **ERROR** coudn't read IDF Version 1 file '" + fFileName + "'."; + fErrorMsg = ">> **ERROR** while reading IDF Version 1 file '" + fFileName + "'."; } break; case 2: status = ReadFileIdf2(); if (status != NX_OK) { fErrorCode = PNEXUS_VAILD_READ_IDF2_FILE; - fErrorMsg = ">> **ERROR** coudn't read IDF Version 2 file '" + fFileName + "'."; + fErrorMsg = ">> **ERROR** while reading IDF Version 2 file '" + fFileName + "'."; } break; default: @@ -2082,9 +2139,12 @@ void PNeXus::Dump() cout << endl << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"; cout << endl << "NXfile:"; cout << endl << " NeXus_version : " << fNeXusVersion; - cout << endl << " user: ..."; + cout << endl << " file format ver: " << fFileFormatVersion; + cout << endl << " file name : " << fFileName; + cout << endl << " file time : " << fFileTime; + cout << endl << " user : " << fCreator; cout << endl << "NXentry:"; - cout << endl << " IDF version : " << fIdfVersion; + cout << endl << " idf version : " << fIdfVersion; cout << endl << " program name : " << fNxEntry1->GetProgramName() << ", version: " << fNxEntry1->GetProgramVersion(); cout << endl << " run number : " << fNxEntry1->GetRunNumber(); cout << endl << " title : " << fNxEntry1->GetTitle(); @@ -2197,6 +2257,8 @@ void PNeXus::Dump() cout << "..."; } } + cout << endl << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"; + cout << endl << "that's all!"; cout << endl << endl; } else if (fIdfVersion == 2) { cout << endl << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"; @@ -2207,9 +2269,10 @@ void PNeXus::Dump() cout << endl << " file format version : " << fFileFormatVersion; cout << endl << " creator : " << fCreator; cout << endl << "NXentry:"; - cout << endl << " IDF version : " << fIdfVersion; + cout << endl << " idf version : " << fIdfVersion; cout << endl << " definition : " << fNxEntry2->GetDefinition(); - cout << endl << " program name : " << fNxEntry2->GetProgramName() << ", version: " << fNxEntry2->GetProgramVersion(); + if (!fNxEntry2->GetProgramName().empty()) + cout << endl << " program name : " << fNxEntry2->GetProgramName() << ", version: " << fNxEntry2->GetProgramVersion(); cout << endl << " run_number : " << fNxEntry2->GetRunNumber(); cout << endl << " run_title : " << fNxEntry2->GetTitle(); cout << endl << " start_time : " << fNxEntry2->GetStartTime(); @@ -2221,17 +2284,17 @@ void PNeXus::Dump() cout << endl << " name : " << fNxEntry2->GetSample()->GetName(); cout << endl << " description : " << fNxEntry2->GetSample()->GetDescription(); cout << endl << " mag.field state : " << fNxEntry2->GetSample()->GetMagneticFieldState(); - dval = fNxEntry2->GetSample()->GetPhysPropValue("temperature", ok); + dval = fNxEntry2->GetSample()->GetPhysPropValue("temperature_1", ok); if (ok) cout << endl << " temperature : " << dval; - fNxEntry2->GetSample()->GetPhysPropUnit("temperature", str, ok); + fNxEntry2->GetSample()->GetPhysPropUnit("temperature_1", str, ok); if (ok) cout << " (" << str << ")"; cout << endl << " temp.environment : " << fNxEntry2->GetSample()->GetEnvironmentTemp(); - dval = fNxEntry2->GetSample()->GetPhysPropValue("magnetic_field", ok); + dval = fNxEntry2->GetSample()->GetPhysPropValue("magnetic_field_1", ok); if (ok) cout << endl << " magnetic_field : " << dval; - fNxEntry2->GetSample()->GetPhysPropUnit("magnetic_field", str, ok); + fNxEntry2->GetSample()->GetPhysPropUnit("magnetic_field_1", str, ok); if (ok) cout << " (" << str << ")"; cout << endl << " mag. field env. : " << fNxEntry2->GetSample()->GetEnvironmentField(); @@ -2249,11 +2312,16 @@ void PNeXus::Dump() if (fNxEntry2->GetInstrument()->GetDetector()->IsT0Present()) { if (fNxEntry2->GetInstrument()->GetDetector()->GetT0Tag() == 1) { // only one t0 for all histograms cout << endl << " t0 : " << fNxEntry2->GetInstrument()->GetDetector()->GetT0(); + } else if (fNxEntry2->GetInstrument()->GetDetector()->GetT0Tag() == 2) { // t0[ns] + cout << endl << " t0 (idx_s/t0) : "; + for (int i=0; iGetInstrument()->GetDetector()->GetNoOfSpectra(); i++) { + cout << "(" << i+1 << "/" << fNxEntry2->GetInstrument()->GetDetector()->GetT0(-1, i) << "), "; + } } else { // t0 vector of the form t0[np][ns] cout << endl << " t0 (idx_p/idx_s/t0): "; for (int i=0; iGetInstrument()->GetDetector()->GetNoOfPeriods(); i++) { for (int j=0; jGetInstrument()->GetDetector()->GetNoOfSpectra(); j++) { - cout << "(" << i << "/" << j << "/" << fNxEntry2->GetInstrument()->GetDetector()->GetT0(i,j); + cout << "(" << i+1 << "/" << j+1 << "/" << fNxEntry2->GetInstrument()->GetDetector()->GetT0(i,j) << "), "; } } } @@ -2261,27 +2329,37 @@ void PNeXus::Dump() cout << endl << " t0 : n/a"; } if (fNxEntry2->GetInstrument()->GetDetector()->IsFirstGoodBinPresent()) { - if (fNxEntry2->GetInstrument()->GetDetector()->GetT0Tag() == 1) { // only one t0/fgb/lgb for all histograms + if (fNxEntry2->GetInstrument()->GetDetector()->GetT0Tag() == 1) { // only one fgb for all histograms cout << endl << " first good bin : " << fNxEntry2->GetInstrument()->GetDetector()->GetFirstGoodBin(); + } else if (fNxEntry2->GetInstrument()->GetDetector()->GetT0Tag() == 2) { // fgb[ns] + cout << endl << " fgb (idx_s/fgb) : "; + for (int i=0; iGetInstrument()->GetDetector()->GetNoOfSpectra(); i++) { + cout << "(" << i+1 << "/" << fNxEntry2->GetInstrument()->GetDetector()->GetFirstGoodBin(-1,i) << ") , "; + } } else { // fgb vector of the form fgb[np][ns] cout << endl << " fgb (idx_p/idx_s/fgb): "; for (int i=0; iGetInstrument()->GetDetector()->GetNoOfPeriods(); i++) { for (int j=0; jGetInstrument()->GetDetector()->GetNoOfSpectra(); j++) { - cout << "(" << i << "/" << j << "/" << fNxEntry2->GetInstrument()->GetDetector()->GetFirstGoodBin(i,j); + cout << "(" << i+1 << "/" << j+1 << "/" << fNxEntry2->GetInstrument()->GetDetector()->GetFirstGoodBin(i,j); } } } } else { cout << endl << " first good bin : n/a"; } - if (fNxEntry2->GetInstrument()->GetDetector()->IsFirstGoodBinPresent()) { - if (fNxEntry2->GetInstrument()->GetDetector()->GetT0Tag() == 1) { // only one t0/fgb/lgb for all histograms - cout << endl << " last good bin : " << fNxEntry2->GetInstrument()->GetDetector()->GetLastGoodBin(); + if (fNxEntry2->GetInstrument()->GetDetector()->IsLastGoodBinPresent()) { + if (fNxEntry2->GetInstrument()->GetDetector()->GetT0Tag() == 1) { // only one lgb for all histograms + cout << endl << " last good bin : " << fNxEntry2->GetInstrument()->GetDetector()->GetLastGoodBin(); + } else if (fNxEntry2->GetInstrument()->GetDetector()->GetT0Tag() == 2) { // lgb[ns] + cout << endl << " lgb (idx_s/lgb) : "; + for (int i=0; iGetInstrument()->GetDetector()->GetNoOfSpectra(); i++) { + cout << "(" << i+1 << "/" << fNxEntry2->GetInstrument()->GetDetector()->GetLastGoodBin(-1,i) << "), "; + } } else { // lgb vector of the form lgb[np][ns] cout << endl << " lgb (idx_p/idx_s/lgb): "; for (int i=0; iGetInstrument()->GetDetector()->GetNoOfPeriods(); i++) { for (int j=0; jGetInstrument()->GetDetector()->GetNoOfSpectra(); j++) { - cout << "(" << i << "/" << j << "/" << fNxEntry2->GetInstrument()->GetDetector()->GetLastGoodBin(i,j); + cout << "(" << i+1 << "/" << j+1 << "/" << fNxEntry2->GetInstrument()->GetDetector()->GetLastGoodBin(i,j) << "), "; } } } @@ -2294,7 +2372,7 @@ void PNeXus::Dump() // dump data int maxDump = 15; - cout << endl << " counts : "; + cout << endl << " counts : "; if (fNxEntry2->GetInstrument()->GetDetector()->GetNoOfPeriods() > 0) { // counts[np][ns][ntc] for (int i=0; iGetInstrument()->GetDetector()->GetNoOfPeriods(); i++) { cout << endl << " period : " << i+1; @@ -2332,6 +2410,7 @@ void PNeXus::Dump() cout << "..."; } } + cout << endl << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"; cout << endl << "that's all!"; cout << endl << endl; } @@ -2645,7 +2724,7 @@ NXstatus PNeXus::GetIntVectorData(vector &data) */ int PNeXus::ReadFileIdf1() { - cout << endl << ">> reading NeXus Version 1 file ..." << endl; + cout << endl << ">> reading NeXus IDF Version 1 file ..." << endl; // create first the necessary NXentry object for IDF Version 1 fNxEntry1 = new PNeXusEntry1(); @@ -2659,6 +2738,8 @@ int PNeXus::ReadFileIdf1() char cstr[128]; int ival; float fval; + int attlen, atttype; + NXname data_value, nxAttrName; // open file NXstatus status; @@ -2669,6 +2750,44 @@ int PNeXus::ReadFileIdf1() return NX_ERROR; } + // collect the NXroot attribute information + do { + status = NXgetnextattr(fFileHandle, nxAttrName, &attlen, &atttype); + if (status == NX_OK) { + if (!strcmp(nxAttrName, "HDF_version")) { + attlen = VGNAMELENMAX - 1; + atttype = NX_CHAR; + status = NXgetattr(fFileHandle, nxAttrName, data_value, &attlen, &atttype); + if (status == NX_OK) { + fFileFormatVersion = string(data_value); + } + } else if (!strcmp(nxAttrName, "HDF5_Version")) { + attlen = VGNAMELENMAX - 1; + atttype = NX_CHAR; + status = NXgetattr(fFileHandle, nxAttrName, data_value, &attlen, &atttype); + if (status == NX_OK) { + fFileFormatVersion = string("HDF5: ")+string(data_value); + } + } else if (!strcmp(nxAttrName, "XML_version")) { + attlen = VGNAMELENMAX - 1; + atttype = NX_CHAR; + status = NXgetattr(fFileHandle, nxAttrName, data_value, &attlen, &atttype); + if (status == NX_OK) { + fFileFormatVersion = string(data_value); + } + } else if (!strcmp(nxAttrName, "file_name")) { + if (!ErrorHandler(GetStringAttr("file_name", str), PNEXUS_GET_ATTR_ERROR, "couldn't read NXroot 'file_name' attribute!")) return NX_ERROR; + fFileName = str; + } else if (!strcmp(nxAttrName, "file_time")) { + if (!ErrorHandler(GetStringAttr("file_time", str), PNEXUS_GET_ATTR_ERROR, "couldn't read NXroot 'file_time' attribute!")) return NX_ERROR; + fFileTime = str; + } else if (!strcmp(nxAttrName, "user")) { + if (!ErrorHandler(GetStringAttr("user", str), PNEXUS_GET_ATTR_ERROR, "couldn't read NXroot 'user' attribute!")) return NX_ERROR; + fCreator = str; + } + } + } while (status == NX_OK); + // look for the first occurring NXentry bool found = false; NXname nxname, nxclass; @@ -2819,11 +2938,12 @@ int PNeXus::ReadFileIdf1() if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'magnetic_field' data in sample group")) return NX_ERROR; fNxEntry1->GetSample()->SetPhysProp("magnetic_field", (double)fval, str); - // read sample shape, e.g. powder, single crystal, etc. - if (!ErrorHandler(NXopendata(fFileHandle, "shape"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'shape' data in sample group!")) return NX_ERROR; - if (!ErrorHandler(GetStringData(str), PNEXUS_GET_DATA_ERROR, "couldn't read 'shape' data in sample group!")) return NX_ERROR; - if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'shape' data in sample group")) return NX_ERROR; - fNxEntry1->GetSample()->SetShape(str); + // read sample shape, e.g. powder, single crystal, etc (THIS IS AN OPTIONAL ENTRY) + if (NXopendata(fFileHandle, "shape") == NX_OK) { + if (!ErrorHandler(GetStringData(str), PNEXUS_GET_DATA_ERROR, "couldn't read 'shape' data in sample group!")) return NX_ERROR; + if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'shape' data in sample group")) return NX_ERROR; + fNxEntry1->GetSample()->SetShape(str); + } // read magnetic field state, e.g. TF, LF, ZF if (!ErrorHandler(NXopendata(fFileHandle, "magnetic_field_state"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'magnetic_field_state' data in sample group!")) return NX_ERROR; @@ -3182,7 +3302,7 @@ int PNeXus::ReadFileIdf1() */ int PNeXus::ReadFileIdf2() { - cout << endl << ">> reading NeXus Version 2 file ..." << endl; + cout << endl << ">> reading NeXus IDF Version 2 file ..." << endl; // create first the necessary NXentry object for IDF Version 1 fNxEntry2 = new PNeXusEntry2(); @@ -3195,7 +3315,7 @@ int PNeXus::ReadFileIdf2() string str; int ival, attlen, atttype; float fval; - NXname data_value; + NXname data_value, nxAttrName; int rank, type, dims[32], size, noOfElements; // open file @@ -3203,55 +3323,68 @@ int PNeXus::ReadFileIdf2() status = NXopen(fFileName.c_str(), NXACC_READ, &fFileHandle); if (status != NX_OK) { fErrorCode = PNEXUS_FILE_OPEN_ERROR; - fErrorMsg = "PNeXus::ReadFile() **ERROR** Couldn't open file '"+fFileName+"' !"; + fErrorMsg = "PNeXus::ReadFileIdf2() **ERROR** Couldn't open file '"+fFileName+"' !"; return NX_ERROR; } // collect the NXroot attribute information - if (!ErrorHandler(GetStringAttr("file_name", str), PNEXUS_GET_ATTR_ERROR, "couldn't read NXroot 'file_name' attribute!")) return NX_ERROR; - fFileName = str; - if (!ErrorHandler(GetStringAttr("file_time", str), PNEXUS_GET_ATTR_ERROR, "couldn't read NXroot 'file_time' attribute!")) return NX_ERROR; - fFileTime = str; - if (!ErrorHandler(GetStringAttr("creator", str), PNEXUS_GET_ATTR_ERROR, "couldn't read NXroot 'creator' attribute!")) return NX_ERROR; - fCreator = str; - - attlen = VGNAMELENMAX - 1; - atttype = NX_CHAR; - str = string("HDF_version"); - status = NXgetattr(fFileHandle, (char *)str.c_str(), data_value, &attlen, &atttype); - if (status == NX_OK) { - fFileFormatVersion = string(data_value); - } - - if (!fFileFormatVersion.compare("n/a")) { - attlen = VGNAMELENMAX - 1; - atttype = NX_CHAR; - str = string("HDF5_version"); - status = NXgetattr(fFileHandle, (char *)str.c_str(), data_value, &attlen, &atttype); + do { + status = NXgetnextattr(fFileHandle, nxAttrName, &attlen, &atttype); if (status == NX_OK) { - fFileFormatVersion = string(data_value); + if (!strcmp(nxAttrName, "HDF_version")) { + attlen = VGNAMELENMAX - 1; + atttype = NX_CHAR; + status = NXgetattr(fFileHandle, nxAttrName, data_value, &attlen, &atttype); + if (status == NX_OK) { + fFileFormatVersion = string(data_value); + } + } else if (!strcmp(nxAttrName, "HDF5_Version")) { + attlen = VGNAMELENMAX - 1; + atttype = NX_CHAR; + status = NXgetattr(fFileHandle, nxAttrName, data_value, &attlen, &atttype); + if (status == NX_OK) { + fFileFormatVersion = string("HDF5: ")+string(data_value); + } + } else if (!strcmp(nxAttrName, "XML_version")) { + attlen = VGNAMELENMAX - 1; + atttype = NX_CHAR; + status = NXgetattr(fFileHandle, nxAttrName, data_value, &attlen, &atttype); + if (status == NX_OK) { + fFileFormatVersion = string(data_value); + } + } else if (!strcmp(nxAttrName, "file_name")) { + if (!ErrorHandler(GetStringAttr("file_name", str), PNEXUS_GET_ATTR_ERROR, "couldn't read NXroot 'file_name' attribute!")) return NX_ERROR; + fFileName = str; + } else if (!strcmp(nxAttrName, "file_time")) { + if (!ErrorHandler(GetStringAttr("file_time", str), PNEXUS_GET_ATTR_ERROR, "couldn't read NXroot 'file_time' attribute!")) return NX_ERROR; + fFileTime = str; + } else if (!strcmp(nxAttrName, "creator")) { + if (!ErrorHandler(GetStringAttr("creator", str), PNEXUS_GET_ATTR_ERROR, "couldn't read NXroot 'creator' attribute!")) return NX_ERROR; + fCreator = str; + } } - } + } while (status == NX_OK); - if (!fFileFormatVersion.compare("n/a")) { - attlen = VGNAMELENMAX - 1; - atttype = NX_CHAR; - str = string("XML_version"); - status = NXgetattr(fFileHandle, (char *)str.c_str(), data_value, &attlen, &atttype); - if (status == NX_OK) { - fFileFormatVersion = string(data_value); - } - } - - // look for the first occurring NXentry + // look for the first occurring NXentry which name ends on "_1" NXname nxname, nxclass; int dataType; - // make sure any NXentry has been found - if (!SearchInGroup("NXentry", "class", nxname, nxclass, dataType)) { + bool found = false; + size_t pos; + do { + status = NXgetnextentry(fFileHandle, nxname, nxclass, &dataType); + if (!strcmp(nxclass, "NXentry")) { + str = nxname; + pos = str.find_last_of("_1"); + if (pos != str.npos) + found = true; + } + } while (!found && (status == NX_OK)); + if (!found) { fErrorCode = PNEXUS_NXENTRY_NOT_FOUND; - fErrorMsg = ">> **ERROR** Couldn't find any NXentry!"; + fErrorMsg = ">> **ERROR** Couldn't find any NXentry on NXroot level!"; return NX_ERROR; } + // open the NXentry group to obtain the necessary stuff status = NXopengroup(fFileHandle, nxname, "NXentry"); if (status != NX_OK) { @@ -3267,7 +3400,8 @@ int PNeXus::ReadFileIdf2() fNxEntry2->SetDefinition(str); // program_name and version - if (NXopendata(fFileHandle, "program_name") == NX_OK) { + if (SearchInGroup("program_name", "name", nxname, nxclass, dataType)) { + if (!ErrorHandler(NXopendata(fFileHandle, "program_name"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'program_name' data in NXentry!")) return NX_ERROR; if (!ErrorHandler(GetStringData(str), PNEXUS_GET_DATA_ERROR, "couldn't read 'program_name' data in NXentry!")) return NX_ERROR; fNxEntry2->SetProgramName(str); if (!ErrorHandler(GetStringAttr("version", str), PNEXUS_GET_ATTR_ERROR, "couldn't read 'program_name' attribute in NXentry!")) return NX_ERROR; @@ -3312,92 +3446,98 @@ int PNeXus::ReadFileIdf2() fNxEntry2->SetExperimentIdentifier(str); // find entry for NXuser - if (!SearchInGroup("NXuser", "class", nxname, nxclass, dataType)) { - fErrorCode = PNEXUS_NXUSER_NOT_FOUND; - fErrorMsg = ">> **ERROR** Couldn't find any NXuser int NXentry!"; - return NX_ERROR; - } - // open the NXuser - status = NXopengroup(fFileHandle, nxname, "NXuser"); - if (status != NX_OK) { - fErrorCode = PNEXUS_GROUP_OPEN_ERROR; - fErrorMsg = "PNeXus::ReadFileIdf2() **ERROR** Couldn't open NXuser '" + string(nxname) + "' in NXentry!"; - return NX_ERROR; - } + if (SearchInGroup("NXuser", "class", nxname, nxclass, dataType)) { + // open the NXuser + status = NXopengroup(fFileHandle, nxname, "NXuser"); + if (status != NX_OK) { + fErrorCode = PNEXUS_GROUP_OPEN_ERROR; + fErrorMsg = "PNeXus::ReadFileIdf2() **ERROR** Couldn't open NXuser '" + string(nxname) + "' in NXentry!"; + return NX_ERROR; + } - // user name - if (!ErrorHandler(NXopendata(fFileHandle, "name"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'name' data in NXuser!")) return NX_ERROR; - if (!ErrorHandler(GetStringData(str), PNEXUS_GET_DATA_ERROR, "couldn't read 'name' data in NXuser!")) return NX_ERROR; - if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'name' data in NXuser!")) return NX_ERROR; - fNxEntry2->GetUser()->SetName(str); - - // close group NXuser - NXclosegroup(fFileHandle); - - // open group NXsample - if (!ErrorHandler(NXopengroup(fFileHandle, "sample", "NXsample"), PNEXUS_GROUP_OPEN_ERROR, "couldn't open NeXus subgroup sample!")) return NX_ERROR; - - // sample name - if (!ErrorHandler(NXopendata(fFileHandle, "name"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'name' data in NXsample!")) return NX_ERROR; - if (!ErrorHandler(GetStringData(str), PNEXUS_GET_DATA_ERROR, "couldn't read 'name' data in NXsample!")) return NX_ERROR; - if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'name' data in NXsample!")) return NX_ERROR; - fNxEntry2->GetSample()->SetName(str); - - // sample description - if (NXopendata(fFileHandle, "description") == NX_OK) { - if (!ErrorHandler(GetStringData(str), PNEXUS_GET_DATA_ERROR, "couldn't read 'description' data in NXsample!")) return NX_ERROR; - if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'description' data in NXsample!")) return NX_ERROR; - fNxEntry2->GetSample()->SetDescription(str); - } - - // temperature - if (NXopendata(fFileHandle, "temperature_1") == NX_OK) { - if (!ErrorHandler(NXgetdata(fFileHandle, &fval), PNEXUS_GET_DATA_ERROR, "couldn't read 'temperature_1' data in NXsample!")) return NX_ERROR; - if (!ErrorHandler(GetStringAttr("units", str), PNEXUS_GET_ATTR_ERROR, "couldn't read temperature units in NXsample!")) return NX_ERROR; - if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'temperature_1' data in NXsample!")) return NX_ERROR; - fNxEntry2->GetSample()->SetPhysProp("temperature_1", fval, str); - } - - // temperature environment - if (NXopengroup(fFileHandle, "temperature_1_env", "NXenvironment") == NX_OK) { // user name - if (!ErrorHandler(NXopendata(fFileHandle, "name"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'name' data in NXenvironment!")) return NX_ERROR; - if (!ErrorHandler(GetStringData(str), PNEXUS_GET_DATA_ERROR, "couldn't read 'name' data in NXenvironment!")) return NX_ERROR; - if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'name' data in NXenvironment!")) return NX_ERROR; - fNxEntry2->GetSample()->SetEnvironmentTemp(str); - // close group NXenvironment + if (!ErrorHandler(NXopendata(fFileHandle, "name"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'name' data in NXuser!")) return NX_ERROR; + if (!ErrorHandler(GetStringData(str), PNEXUS_GET_DATA_ERROR, "couldn't read 'name' data in NXuser!")) return NX_ERROR; + if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'name' data in NXuser!")) return NX_ERROR; + fNxEntry2->GetUser()->SetName(str); + + // close group NXuser NXclosegroup(fFileHandle); } - // magnetic_field - if (NXopendata(fFileHandle, "magnetic_field_1") == NX_OK) { - if (!ErrorHandler(NXgetdata(fFileHandle, &fval), PNEXUS_GET_DATA_ERROR, "couldn't read 'magnetic_field_1' data in NXsample!")) return NX_ERROR; - if (!ErrorHandler(GetStringAttr("units", str), PNEXUS_GET_ATTR_ERROR, "couldn't read magnetic field units in NXsample!")) return NX_ERROR; - if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'magnetic_field_1' data in NXsample!")) return NX_ERROR; - fNxEntry2->GetSample()->SetPhysProp("magnetic_field_1", fval, str); - } + // find entry for NXsample + if (SearchInGroup("NXsample", "class", nxname, nxclass, dataType)) { + // open group NXsample + if (!ErrorHandler(NXopengroup(fFileHandle, "sample", "NXsample"), PNEXUS_GROUP_OPEN_ERROR, "couldn't open NeXus subgroup sample!")) return NX_ERROR; - // magnetic field state - if (NXopendata(fFileHandle, "magnetic_field_state") == NX_OK) { - if (!ErrorHandler(GetStringData(str), PNEXUS_GET_DATA_ERROR, "couldn't read 'magnetic_field_state' data in NXsample!")) return NX_ERROR; - if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'magnetic_field_state' data in NXsample!")) return NX_ERROR; - fNxEntry2->GetSample()->SetMagneticFieldState(str); - } + // sample name + if (!ErrorHandler(NXopendata(fFileHandle, "name"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'name' data in NXsample!")) return NX_ERROR; + if (!ErrorHandler(GetStringData(str), PNEXUS_GET_DATA_ERROR, "couldn't read 'name' data in NXsample!")) return NX_ERROR; + if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'name' data in NXsample!")) return NX_ERROR; + fNxEntry2->GetSample()->SetName(str); - // magnetic field environment - if (NXopengroup(fFileHandle, "magnetic_field_1_env", "NXenvironment") == NX_OK) { - // user name - if (!ErrorHandler(NXopendata(fFileHandle, "name"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'name' data in NXenvironment!")) return NX_ERROR; - if (!ErrorHandler(GetStringData(str), PNEXUS_GET_DATA_ERROR, "couldn't read 'name' data in NXenvironment!")) return NX_ERROR; - if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'name' data in NXenvironment!")) return NX_ERROR; - fNxEntry2->GetSample()->SetEnvironmentField(str); - // close group NXenvironment + // sample description + if (SearchInGroup("description", "name", nxname, nxclass, dataType)) { + if (!ErrorHandler(NXopendata(fFileHandle, "description"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'description' data in NXsample!")) return NX_ERROR; + if (!ErrorHandler(GetStringData(str), PNEXUS_GET_DATA_ERROR, "couldn't read 'description' data in NXsample!")) return NX_ERROR; + if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'description' data in NXsample!")) return NX_ERROR; + fNxEntry2->GetSample()->SetDescription(str); + } + + // temperature + if (SearchInGroup("temperature_1", "name", nxname, nxclass, dataType)) { + if (!ErrorHandler(NXopendata(fFileHandle, "temperature_1"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'temperature_1' data in NXsample!")) return NX_ERROR; + if (!ErrorHandler(NXgetdata(fFileHandle, &fval), PNEXUS_GET_DATA_ERROR, "couldn't read 'temperature_1' data in NXsample!")) return NX_ERROR; + if (!ErrorHandler(GetStringAttr("units", str), PNEXUS_GET_ATTR_ERROR, "couldn't read temperature units in NXsample!")) return NX_ERROR; + if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'temperature_1' data in NXsample!")) return NX_ERROR; + fNxEntry2->GetSample()->SetPhysProp("temperature_1", fval, str); + } + + // temperature environment + if (SearchInGroup("temperature_1_env", "name", nxname, nxclass, dataType)) { + if (!ErrorHandler(NXopengroup(fFileHandle, "temperature_1_env", "NXenvironment"), PNEXUS_GROUP_OPEN_ERROR, "couldn't open NeXus subgroup NXenvironment!")) return NX_ERROR; + // temperature environment name + if (!ErrorHandler(NXopendata(fFileHandle, "name"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'name' data in NXenvironment!")) return NX_ERROR; + if (!ErrorHandler(GetStringData(str), PNEXUS_GET_DATA_ERROR, "couldn't read 'name' data in NXenvironment!")) return NX_ERROR; + if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'name' data in NXenvironment!")) return NX_ERROR; + fNxEntry2->GetSample()->SetEnvironmentTemp(str); + // close group NXenvironment + NXclosegroup(fFileHandle); + } + + // magnetic_field + if (SearchInGroup("magnetic_field_1", "name", nxname, nxclass, dataType)) { + if (!ErrorHandler(NXopendata(fFileHandle, "magnetic_field_1"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'magnetic_field_1' data in NXsample!")) return NX_ERROR; + if (!ErrorHandler(NXgetdata(fFileHandle, &fval), PNEXUS_GET_DATA_ERROR, "couldn't read 'magnetic_field_1' data in NXsample!")) return NX_ERROR; + if (!ErrorHandler(GetStringAttr("units", str), PNEXUS_GET_ATTR_ERROR, "couldn't read magnetic field units in NXsample!")) return NX_ERROR; + if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'magnetic_field_1' data in NXsample!")) return NX_ERROR; + fNxEntry2->GetSample()->SetPhysProp("magnetic_field_1", fval, str); + } + + // magnetic field state + if (SearchInGroup("magnetic_field_state", "name", nxname, nxclass, dataType)) { + if (!ErrorHandler(NXopendata(fFileHandle, "magnetic_field_state"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'magnetic_field_state' data in NXsample!")) return NX_ERROR; + if (!ErrorHandler(GetStringData(str), PNEXUS_GET_DATA_ERROR, "couldn't read 'magnetic_field_state' data in NXsample!")) return NX_ERROR; + if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'magnetic_field_state' data in NXsample!")) return NX_ERROR; + fNxEntry2->GetSample()->SetMagneticFieldState(str); + } + + // magnetic field environment + if (SearchInGroup("magnetic_field_1_env", "name", nxname, nxclass, dataType)) { + if (!ErrorHandler(NXopengroup(fFileHandle, "magnetic_field_1_env", "NXenvironment"), PNEXUS_GROUP_OPEN_ERROR, "couldn't open NeXus subgroup NXenvironment!")) return NX_ERROR; + // magnetic field environment name + if (!ErrorHandler(NXopendata(fFileHandle, "name"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'name' data in NXenvironment!")) return NX_ERROR; + if (!ErrorHandler(GetStringData(str), PNEXUS_GET_DATA_ERROR, "couldn't read 'name' data in NXenvironment!")) return NX_ERROR; + if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'name' data in NXenvironment!")) return NX_ERROR; + fNxEntry2->GetSample()->SetEnvironmentField(str); + // close group NXenvironment + NXclosegroup(fFileHandle); + } + + // close group NXsample NXclosegroup(fFileHandle); } - // close group NXsample - NXclosegroup(fFileHandle); - // open group NXinstrument if (!ErrorHandler(NXopengroup(fFileHandle, "instrument", "NXinstrument"), PNEXUS_GROUP_OPEN_ERROR, "couldn't open NeXus subgroup instrument in NXentry!")) return NX_ERROR; @@ -3456,11 +3596,17 @@ int PNeXus::ReadFileIdf2() // 1st check if 'histogram_resolution' is found if (SearchInGroup("histogram_resolution", "name", nxname, nxclass, dataType)) { if (!ErrorHandler(NXopendata(fFileHandle, "histogram_resolution"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'histogram_resolution' data in NXdetector!")) return NX_ERROR; - if (!ErrorHandler(NXgetdata(fFileHandle, &ival), PNEXUS_GET_DATA_ERROR, "couldn't read 'histogram_resolution' data in NXdetector!")) return NX_ERROR; - if (!ErrorHandler(GetStringAttr("units", str), PNEXUS_GET_ATTR_ERROR, "couldn't read magnetic field units in NXsample!")) return NX_ERROR; + if (!ErrorHandler(NXgetdata(fFileHandle, &fval), PNEXUS_GET_DATA_ERROR, "couldn't read 'histogram_resolution' data in NXdetector!")) return NX_ERROR; + if (!ErrorHandler(GetStringAttr("units", str), PNEXUS_GET_ATTR_ERROR, "couldn't read time resolution units in NXdetector!")) return NX_ERROR; if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'histogram_resolution' data in NXdetector!")) return NX_ERROR; - fNxEntry2->GetInstrument()->GetDetector()->SetTimeResolution((double)ival, str); - } else { // 2nd 'histogram_resolution' is not present, hence extract the time resolution from the 'raw_time' vector + fNxEntry2->GetInstrument()->GetDetector()->SetTimeResolution((double)fval, str); + } else if (SearchInGroup("resolution", "name", nxname, nxclass, dataType)) { // 2nd check if 'resolution' is found + if (!ErrorHandler(NXopendata(fFileHandle, "resolution"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'resolution' data in NXdetector!")) return NX_ERROR; + if (!ErrorHandler(NXgetdata(fFileHandle, &fval), PNEXUS_GET_DATA_ERROR, "couldn't read 'resolution' data in NXdetector!")) return NX_ERROR; + if (!ErrorHandler(GetStringAttr("units", str), PNEXUS_GET_ATTR_ERROR, "couldn't read time resolution units in NXdetector!")) return NX_ERROR; + if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'resolution' data in NXdetector!")) return NX_ERROR; + fNxEntry2->GetInstrument()->GetDetector()->SetTimeResolution((double)fval, str); + } else { // 3nd 'histogram_resolution' is not present, hence extract the time resolution from the 'raw_time' vector if (!ErrorHandler(NXopendata(fFileHandle, "raw_time"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'raw_time' data in NXdetector!")) return NX_ERROR; vector rawTime; if (!ErrorHandler(GetDoubleVectorData(rawTime), PNEXUS_GET_DATA_ERROR, "couldn't get 'raw_time' data in NXdetector!")) return NX_ERROR; @@ -3569,8 +3715,12 @@ int PNeXus::ReadFileIdf2() // check the dimensions of the 'time_zero_bin' vector if (!ErrorHandler(NXgetinfo(fFileHandle, &rank, dims, &type), PNEXUS_GET_META_INFO_ERROR, "couldn't get 'time_zero_bin' info in NXdetector!")) return NX_ERROR; - if (rank <= 2) { - fNxEntry2->GetInstrument()->GetDetector()->SetT0Tag(rank); + if ((rank == 1) && (dims[0] == 1)) { // single t0 entry + fNxEntry2->GetInstrument()->GetDetector()->SetT0Tag(1); + } else if ((rank == 1) && (dims[0] > 1)) { // t0 of the form t0[ns] + fNxEntry2->GetInstrument()->GetDetector()->SetT0Tag(2); + } else if (rank == 2) { // t0 of the form t0[np][ns] + fNxEntry2->GetInstrument()->GetDetector()->SetT0Tag(3); } else { cerr << endl << ">> **ERROR** found 'time_zero_bin' info in NXdetector with rank=" << rank << ". Do not know how to handle." << endl; return NX_ERROR; @@ -3613,8 +3763,12 @@ int PNeXus::ReadFileIdf2() // check the dimensions of the 'time_zero' vector if (!ErrorHandler(NXgetinfo(fFileHandle, &rank, dims, &type), PNEXUS_GET_META_INFO_ERROR, "couldn't get 'time_zero' info in NXdetector!")) return NX_ERROR; - if (rank <= 2) { - fNxEntry2->GetInstrument()->GetDetector()->SetT0Tag(rank); + if ((rank == 1) && (dims[0] == 1)) { // single t0 entry + fNxEntry2->GetInstrument()->GetDetector()->SetT0Tag(1); + } else if ((rank == 1) && (dims[0] > 1)) { // t0 of the form t0[ns] + fNxEntry2->GetInstrument()->GetDetector()->SetT0Tag(2); + } else if (rank == 2) { // t0 of the form t0[np][ns] + fNxEntry2->GetInstrument()->GetDetector()->SetT0Tag(3); } else { cerr << endl << ">> **ERROR** found 'time_zero' info in NXdetector with rank=" << rank << ". Do not know how to handle." << endl; return NX_ERROR; @@ -3684,16 +3838,6 @@ int PNeXus::ReadFileIdf2() // check the dimensions of the 'first_good_bin' vector if (!ErrorHandler(NXgetinfo(fFileHandle, &rank, dims, &type), PNEXUS_GET_META_INFO_ERROR, "couldn't get 'first_good_bin' info in NXdetector!")) return NX_ERROR; - if (rank <= 2) { - if (rank != fNxEntry2->GetInstrument()->GetDetector()->GetT0Tag()) { - cerr << endl << ">> **ERROR** rank of 'first_good_bin' (" << rank << ") is different than t0 rank=" << rank << ". Do not know how to handle." << endl; - return NX_ERROR; - } - } else { - cerr << endl << ">> **ERROR** found 'first_good_bin' info in NXdetector with rank=" << rank << ". Do not know how to handle." << endl; - return NX_ERROR; - } - // calculate the needed size size = dims[0]; for (int i=1; iGetInstrument()->GetDetector()->GetT0Tag()) { - cerr << endl << ">> **ERROR** rank of 'first_good_time' (" << rank << ") is different than t0 rank=" << rank << ". Do not know how to handle." << endl; - return NX_ERROR; - } - } else { - cerr << endl << ">> **ERROR** found 'first_good_time' info in NXdetector with rank=" << rank << ". Do not know how to handle." << endl; - return NX_ERROR; - } - // calculate the needed size size = dims[0]; for (int i=1; iGetInstrument()->GetDetector()->GetT0Tag()) { - cerr << endl << ">> **ERROR** rank of 'last_good_bin' (" << rank << ") is different than t0 rank=" << rank << ". Do not know how to handle." << endl; - return NX_ERROR; - } - } else { - cerr << endl << ">> **ERROR** found 'last_good_bin' info in NXdetector with rank=" << rank << ". Do not know how to handle." << endl; - return NX_ERROR; - } - // calculate the needed size size = dims[0]; for (int i=1; iGetInstrument()->GetDetector()->GetT0Tag()) { - cerr << endl << ">> **ERROR** rank of 'last_good_time' (" << rank << ") is different than t0 rank=" << rank << ". Do not know how to handle." << endl; - return NX_ERROR; - } - } else { - cerr << endl << ">> **ERROR** found 'last_good_time' info in NXdetector with rank=" << rank << ". Do not know how to handle." << endl; - return NX_ERROR; - } - // calculate the needed size size = dims[0]; for (int i=1; iGetSample()->GetShape().length(); - if (!ErrorHandler(NXmakedata(fFileHandle, "shape", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'NXsample/shape'.")) return NX_ERROR; - if (!ErrorHandler(NXopendata(fFileHandle, "shape"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'NXsample/shape' for writting.")) return NX_ERROR; - strncpy(cstr, fNxEntry1->GetSample()->GetShape().c_str(), sizeof(cstr)); - if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXsample/shape'.")) return NX_ERROR; - NXclosedata(fFileHandle); + // write sample 'shape' only if populated with something different than 'n/a' + if (fNxEntry1->GetSample()->GetShape() != "n/a") { + size = fNxEntry1->GetSample()->GetShape().length(); + if (!ErrorHandler(NXmakedata(fFileHandle, "shape", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'NXsample/shape'.")) return NX_ERROR; + if (!ErrorHandler(NXopendata(fFileHandle, "shape"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'NXsample/shape' for writting.")) return NX_ERROR; + strncpy(cstr, fNxEntry1->GetSample()->GetShape().c_str(), sizeof(cstr)); + if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXsample/shape'.")) return NX_ERROR; + NXclosedata(fFileHandle); + } // write sample 'magnetic_field_state' size = fNxEntry1->GetSample()->GetMagneticFieldState().length(); @@ -4556,7 +4672,8 @@ int PNeXus::WriteFileIdf2(const char* fileName, const NXaccess access) int size, idata; float fdata; double dval; - NXlink clink; + NXlink nxLink; + vector nxLinkVec; memset(cstr, '\0', sizeof(cstr)); snprintf(cstr, sizeof(cstr), "couldn't open file '%s' for writing", fileName); @@ -4594,6 +4711,20 @@ int PNeXus::WriteFileIdf2(const char* fileName, const NXaccess access) if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'definition' in NXentry.")) return NX_ERROR; NXclosedata(fFileHandle); + // write 'program_name' if present + if (!fNxEntry2->GetProgramName().empty()) { + size = fNxEntry2->GetProgramName().length(); + if (!ErrorHandler(NXmakedata(fFileHandle, "program_name", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'program_name' in NXentry.")) return NX_ERROR; + if (!ErrorHandler(NXopendata(fFileHandle, "program_name"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'program_name' in NXentry for writting.")) return NX_ERROR; + memset(cstr, '\0', sizeof(cstr)); + strncpy(cstr, fNxEntry2->GetProgramName().c_str(), sizeof(cstr)); + if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'program_name' in NXentry.")) return NX_ERROR; + memset(cstr, '\0', sizeof(cstr)); + strncpy(cstr, fNxEntry2->GetProgramVersion().c_str(), sizeof(cstr)); + if (!ErrorHandler(NXputattr(fFileHandle, "version", cstr, strlen(cstr), NX_CHAR), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'version' for 'program_name' in NXentry.")) return NX_ERROR; + NXclosedata(fFileHandle); + } + // write run 'run_number' size = 1; if (!ErrorHandler(NXmakedata(fFileHandle, "run_number", NX_INT32, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'run_number' in NXentry.")) return NX_ERROR; @@ -4638,22 +4769,25 @@ int PNeXus::WriteFileIdf2(const char* fileName, const NXaccess access) if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'experiment_identifier' in NXentry.")) return NX_ERROR; NXclosedata(fFileHandle); - // make group 'user_1' - if (!ErrorHandler(NXmakegroup(fFileHandle, "user_1", "NXuser"), PNEXUS_CREATE_GROUP_ERROR, "couldn't create group 'user_1' in NXentry.")) return NX_ERROR; - // open group 'user' - if (!ErrorHandler(NXopengroup(fFileHandle, "user_1", "NXuser"), PNEXUS_GROUP_OPEN_ERROR, "couldn't open group 'user_1' in NXentry for writting.")) return NX_ERROR; + // user_1 (NXuser) will only be written if there is at least a user name present + if (fNxEntry2->GetUser()->GetName() != "n/a") { + // make group 'user_1' + if (!ErrorHandler(NXmakegroup(fFileHandle, "user_1", "NXuser"), PNEXUS_CREATE_GROUP_ERROR, "couldn't create group 'user_1' in NXentry.")) return NX_ERROR; + // open group 'user' + if (!ErrorHandler(NXopengroup(fFileHandle, "user_1", "NXuser"), PNEXUS_GROUP_OPEN_ERROR, "couldn't open group 'user_1' in NXentry for writting.")) return NX_ERROR; - // write user 'name' - size = fNxEntry2->GetUser()->GetName().length(); - if (!ErrorHandler(NXmakedata(fFileHandle, "name", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'name' in NXuser.")) return NX_ERROR; - if (!ErrorHandler(NXopendata(fFileHandle, "name"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'name' in NXuser for writting.")) return NX_ERROR; - memset(cstr, '\0', sizeof(cstr)); - strncpy(cstr, fNxEntry2->GetUser()->GetName().c_str(), sizeof(cstr)); - if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'name' in NXuser.")) return NX_ERROR; - NXclosedata(fFileHandle); + // write user 'name' + size = fNxEntry2->GetUser()->GetName().length(); + if (!ErrorHandler(NXmakedata(fFileHandle, "name", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'name' in NXuser.")) return NX_ERROR; + if (!ErrorHandler(NXopendata(fFileHandle, "name"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'name' in NXuser for writting.")) return NX_ERROR; + memset(cstr, '\0', sizeof(cstr)); + strncpy(cstr, fNxEntry2->GetUser()->GetName().c_str(), sizeof(cstr)); + if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'name' in NXuser.")) return NX_ERROR; + NXclosedata(fFileHandle); - // close group 'user_1' - NXclosegroup(fFileHandle); + // close group 'user_1' + NXclosegroup(fFileHandle); + } // make group 'sample' if (!ErrorHandler(NXmakegroup(fFileHandle, "sample", "NXsample"), PNEXUS_CREATE_GROUP_ERROR, "couldn't create group 'sample' in NXentry.")) return NX_ERROR; @@ -4683,10 +4817,10 @@ int PNeXus::WriteFileIdf2(const char* fileName, const NXaccess access) // check if temperature is present and if yes, write it into the file ok=false; - dval = fNxEntry2->GetSample()->GetPhysPropValue("temperature", ok); + dval = fNxEntry2->GetSample()->GetPhysPropValue("temperature_1", ok); if (ok) { fdata = (float)dval; - fNxEntry2->GetSample()->GetPhysPropUnit("temperature", str, ok); + fNxEntry2->GetSample()->GetPhysPropUnit("temperature_1", str, ok); } if (ok) { size = 1; @@ -4701,22 +4835,28 @@ int PNeXus::WriteFileIdf2(const char* fileName, const NXaccess access) // check if temperature environment info is present if (fNxEntry2->GetSample()->GetEnvironmentTemp().compare("n/a")) { + // make group 'temperature_1_env' + if (!ErrorHandler(NXmakegroup(fFileHandle, "temperature_1_env", "NXenvironment"), PNEXUS_CREATE_GROUP_ERROR, "couldn't create group 'temperature_1_env' in NXsample.")) return NX_ERROR; + // open group 'temperature_1_env' + if (!ErrorHandler(NXopengroup(fFileHandle, "temperature_1_env", "NXenvironment"), PNEXUS_GROUP_OPEN_ERROR, "couldn't open group 'NXenvironment' in NXsample for writting.")) return NX_ERROR; // write sample 'temperature_1_env' size = fNxEntry2->GetSample()->GetEnvironmentTemp().length(); - if (!ErrorHandler(NXmakedata(fFileHandle, "temperature_1_env", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'temperature_1_env' in NXsample.")) return NX_ERROR; - if (!ErrorHandler(NXopendata(fFileHandle, "temperature_1_env"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'temperature_1_env' in NXsample for writting.")) return NX_ERROR; + if (!ErrorHandler(NXmakedata(fFileHandle, "name", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'name' in 'temperature_1_env' in NXsample.")) return NX_ERROR; + if (!ErrorHandler(NXopendata(fFileHandle, "name"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'name' in 'temperature_1_env' in NXsample for writting.")) return NX_ERROR; memset(cstr, '\0', sizeof(cstr)); strncpy(cstr, fNxEntry2->GetSample()->GetEnvironmentTemp().c_str(), sizeof(cstr)); if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'temperature_1_env' in NXsample.")) return NX_ERROR; NXclosedata(fFileHandle); + // close group 'temperature_1_env' + NXclosegroup(fFileHandle); } // check if magnetic field is present and if yes, write it into the file ok=false; - dval = fNxEntry2->GetSample()->GetPhysPropValue("magnetic_field", ok); + dval = fNxEntry2->GetSample()->GetPhysPropValue("magnetic_field_1", ok); if (ok) { fdata = (float)dval; - fNxEntry2->GetSample()->GetPhysPropUnit("magnetic_field", str, ok); + fNxEntry2->GetSample()->GetPhysPropUnit("magnetic_field_1", str, ok); } if (ok) { size = 1; @@ -4731,6 +4871,10 @@ int PNeXus::WriteFileIdf2(const char* fileName, const NXaccess access) // check if magnetic field environment info is present if (fNxEntry2->GetSample()->GetEnvironmentField().compare("n/a")) { + // make group 'magnetic_field_1_env' + if (!ErrorHandler(NXmakegroup(fFileHandle, "magnetic_field_1_env", "NXenvironment"), PNEXUS_CREATE_GROUP_ERROR, "couldn't create group 'magnetic_field_1_env' in NXsample.")) return NX_ERROR; + // open group 'magnetic_field_1_env' + if (!ErrorHandler(NXopengroup(fFileHandle, "magnetic_field_1_env", "NXenvironment"), PNEXUS_GROUP_OPEN_ERROR, "couldn't open group 'NXenvironment' in NXsample for writting.")) return NX_ERROR; // write sample 'magnetic_field_1_env' size = fNxEntry2->GetSample()->GetEnvironmentField().length(); if (!ErrorHandler(NXmakedata(fFileHandle, "magnetic_field_1_env", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'magnetic_field_1_env' in NXsample.")) return NX_ERROR; @@ -4739,6 +4883,8 @@ int PNeXus::WriteFileIdf2(const char* fileName, const NXaccess access) strncpy(cstr, fNxEntry2->GetSample()->GetEnvironmentField().c_str(), sizeof(cstr)); if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'magnetic_field_1_env' in NXsample.")) return NX_ERROR; NXclosedata(fFileHandle); + // close group 'magnetic_field_1_env' + NXclosegroup(fFileHandle); } // check if magnetic field state info is present @@ -4811,13 +4957,13 @@ int PNeXus::WriteFileIdf2(const char* fileName, const NXaccess access) // open group 'beamline' if (!ErrorHandler(NXopengroup(fFileHandle, "beamline", "NXbeamline"), PNEXUS_GROUP_OPEN_ERROR, "couldn't open group 'beamline' in NXentry for NXinstrument.")) return NX_ERROR; - // write instrument 'name' + // write beamline 'beamline' size = fNxEntry2->GetInstrument()->GetBeamline()->GetName().length(); - if (!ErrorHandler(NXmakedata(fFileHandle, "name", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'name' in NXbeamline.")) return NX_ERROR; - if (!ErrorHandler(NXopendata(fFileHandle, "name"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'name' in NXbeamline for writting.")) return NX_ERROR; + if (!ErrorHandler(NXmakedata(fFileHandle, "beamline", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'beamline' in NXbeamline.")) return NX_ERROR; + if (!ErrorHandler(NXopendata(fFileHandle, "beamline"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'beamline' in NXbeamline for writting.")) return NX_ERROR; memset(cstr, '\0', sizeof(cstr)); strncpy(cstr, fNxEntry2->GetInstrument()->GetBeamline()->GetName().c_str(), sizeof(cstr)); - if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'name' in NXbeamline.")) return NX_ERROR; + if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'beamline' in NXbeamline.")) return NX_ERROR; NXclosedata(fFileHandle); // close group 'beamline' @@ -4883,17 +5029,59 @@ int PNeXus::WriteFileIdf2(const char* fileName, const NXaccess access) } if (!ErrorHandler(NXputattr(fFileHandle, "long_name", cstr, strlen(cstr), NX_CHAR), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'long_name' for 'counts' in NXdetector.")) return NX_ERROR; // create link of 'counts' for NXdata - if (!ErrorHandler(NXgetdataID(fFileHandle, &clink), PNEXUS_LINKING_ERROR, "couldn't obtain link of 'counts' in NXdetector.")) return NX_ERROR; + if (!ErrorHandler(NXgetdataID(fFileHandle, &nxLink), PNEXUS_LINKING_ERROR, "couldn't obtain link of 'counts' in NXdetector.")) return NX_ERROR; + nxLinkVec.push_back(nxLink); NXclosedata(fFileHandle); + // write time resolution + fdata = (float)fNxEntry2->GetInstrument()->GetDetector()->GetTimeResolution("ns"); + size = 1; + if (!ErrorHandler(NXmakedata(fFileHandle, "histogram_resolution", NX_FLOAT32, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'histogram_resolution' in NXdetector.")) return NX_ERROR; + if (!ErrorHandler(NXopendata(fFileHandle, "histogram_resolution"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'histogram_resolution' in NXdetector for writting.")) return NX_ERROR; + if (!ErrorHandler(NXputdata(fFileHandle, (void*)&fdata), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'histogram_resolution' in NXdetector.")) return NX_ERROR; + memset(cstr, '\0', sizeof(cstr)); + strncpy(cstr, "nano.second", sizeof(cstr)); + if (!ErrorHandler(NXputattr(fFileHandle, "units", cstr, strlen(cstr), NX_CHAR), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'units' for 'histogram_resolution' in NXdetector.")) return NX_ERROR; + // create link of 'histogram_resolution' for NXdata + if (!ErrorHandler(NXgetdataID(fFileHandle, &nxLink), PNEXUS_LINKING_ERROR, "couldn't obtain link of 'histogram_resolution' in NXdetector.")) return NX_ERROR; + nxLinkVec.push_back(nxLink); + NXclosedata(fFileHandle); + + // write detector_1 'raw_time' + size = (int)fNxEntry2->GetInstrument()->GetDetector()->GetRawTime()->size(); + float *p_fdata = new float[size]; + assert(p_fdata); + for (int i=0; iGetInstrument()->GetDetector()->GetRawTime()->at(i); + if (!ErrorHandler(NXmakedata(fFileHandle, "raw_time", NX_FLOAT32, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'raw_time' in NXdetector.")) return NX_ERROR; + if (!ErrorHandler(NXopendata(fFileHandle, "raw_time"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'raw_time' in NXdetector for writting.")) return NX_ERROR; + if (!ErrorHandler(NXputdata(fFileHandle, (void*)p_fdata), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'raw_time' in NXdetector.")) return NX_ERROR; + strncpy(cstr, fNxEntry2->GetInstrument()->GetDetector()->GetRawTimeUnit().c_str(), sizeof(cstr)); + if (!ErrorHandler(NXputattr(fFileHandle, "units", cstr, strlen(cstr), NX_CHAR), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'units' for 'raw_time' in NXdetector.")) return NX_ERROR; + strncpy(cstr, fNxEntry2->GetInstrument()->GetDetector()->GetRawTimeName().c_str(), sizeof(cstr)); + if (!ErrorHandler(NXputattr(fFileHandle, "long_name", cstr, strlen(cstr), NX_CHAR), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'long_name' for 'raw_time' in NXdetector.")) return NX_ERROR; + // create link of 'raw_time' for NXdata + if (!ErrorHandler(NXgetdataID(fFileHandle, &nxLink), PNEXUS_LINKING_ERROR, "couldn't obtain link of 'raw_time' in NXdetector.")) return NX_ERROR; + nxLinkVec.push_back(nxLink); + NXclosedata(fFileHandle); + // clean up + if (p_fdata) { + delete [] p_fdata; + p_fdata = 0; + } + // write detector_1 'spectrum_index' size = fNxEntry2->GetInstrument()->GetDetector()->GetSpectrumIndexSize(); int *p_idata = new int[size]; + assert(p_idata); for (int i=0; iGetInstrument()->GetDetector()->GetSpectrumIndex(i); if (!ErrorHandler(NXmakedata(fFileHandle, "spectrum_index", NX_INT32, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'spectrum_index' in NXdetector.")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "spectrum_index"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'spectrum_index' in NXdetector for writting.")) return NX_ERROR; if (!ErrorHandler(NXputdata(fFileHandle, (void*)p_idata), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'spectrum_index' in NXdetector.")) return NX_ERROR; + // create link of 'spectrum_index' for NXdata + if (!ErrorHandler(NXgetdataID(fFileHandle, &nxLink), PNEXUS_LINKING_ERROR, "couldn't obtain link of 'spectrum_index' in NXdetector.")) return NX_ERROR; + nxLinkVec.push_back(nxLink); NXclosedata(fFileHandle); if (p_idata) { delete [] p_idata; @@ -4910,6 +5098,13 @@ int PNeXus::WriteFileIdf2(const char* fileName, const NXaccess access) if (!ErrorHandler(NXputdata(fFileHandle, (void*)&idata), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'time_zero_bin' in NXdetector.")) return NX_ERROR; NXclosedata(fFileHandle); } else if (fNxEntry2->GetInstrument()->GetDetector()->GetT0Tag() == 2) { + int dims[1]; + dims[0] = fNxEntry2->GetInstrument()->GetDetector()->GetNoOfSpectra(); + if (!ErrorHandler(NXmakedata(fFileHandle, "time_zero_bin", NX_INT32, 1, dims), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'time_zero_bin' in NXdetector.")) return NX_ERROR; + if (!ErrorHandler(NXopendata(fFileHandle, "time_zero_bin"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'time_zero_bin' in NXdetector for writting.")) return NX_ERROR; + if (!ErrorHandler(NXputdata(fFileHandle, (void*)fNxEntry2->GetInstrument()->GetDetector()->GetT0s()), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'time_zero_bin' in NXdetector.")) return NX_ERROR; + NXclosedata(fFileHandle); + } else if (fNxEntry2->GetInstrument()->GetDetector()->GetT0Tag() == 3) { int dims[2]; dims[0] = fNxEntry2->GetInstrument()->GetDetector()->GetNoOfPeriods(); dims[1] = fNxEntry2->GetInstrument()->GetDetector()->GetNoOfSpectra(); @@ -4932,6 +5127,13 @@ int PNeXus::WriteFileIdf2(const char* fileName, const NXaccess access) if (!ErrorHandler(NXputdata(fFileHandle, (void*)&idata), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'first_good_bin' in NXdetector.")) return NX_ERROR; NXclosedata(fFileHandle); } else if (fNxEntry2->GetInstrument()->GetDetector()->GetT0Tag() == 2) { + int dims[1]; + dims[0] = fNxEntry2->GetInstrument()->GetDetector()->GetNoOfSpectra(); + if (!ErrorHandler(NXmakedata(fFileHandle, "first_good_bin", NX_INT32, 1, dims), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'first_good_bin' in NXdetector.")) return NX_ERROR; + if (!ErrorHandler(NXopendata(fFileHandle, "first_good_bin"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'first_good_bin' in NXdetector for writting.")) return NX_ERROR; + if (!ErrorHandler(NXputdata(fFileHandle, (void*)fNxEntry2->GetInstrument()->GetDetector()->GetFirstGoodBins()), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'first_good_bin' in NXdetector.")) return NX_ERROR; + NXclosedata(fFileHandle); + } else if (fNxEntry2->GetInstrument()->GetDetector()->GetT0Tag() == 3) { int dims[2]; dims[0] = fNxEntry2->GetInstrument()->GetDetector()->GetNoOfPeriods(); dims[1] = fNxEntry2->GetInstrument()->GetDetector()->GetNoOfSpectra(); @@ -4954,6 +5156,13 @@ int PNeXus::WriteFileIdf2(const char* fileName, const NXaccess access) if (!ErrorHandler(NXputdata(fFileHandle, (void*)&idata), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'last_good_bin' in NXdetector.")) return NX_ERROR; NXclosedata(fFileHandle); } else if (fNxEntry2->GetInstrument()->GetDetector()->GetT0Tag() == 2) { + int dims[1]; + dims[0] = fNxEntry2->GetInstrument()->GetDetector()->GetNoOfSpectra(); + if (!ErrorHandler(NXmakedata(fFileHandle, "last_good_bin", NX_INT32, 1, dims), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'last_good_bin' in NXdetector.")) return NX_ERROR; + if (!ErrorHandler(NXopendata(fFileHandle, "last_good_bin"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'last_good_bin' in NXdetector for writting.")) return NX_ERROR; + if (!ErrorHandler(NXputdata(fFileHandle, (void*)fNxEntry2->GetInstrument()->GetDetector()->GetLastGoodBins()), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'last_good_bin' in NXdetector.")) return NX_ERROR; + NXclosedata(fFileHandle); + } else if (fNxEntry2->GetInstrument()->GetDetector()->GetT0Tag() == 3) { int dims[2]; dims[0] = fNxEntry2->GetInstrument()->GetDetector()->GetNoOfPeriods(); dims[1] = fNxEntry2->GetInstrument()->GetDetector()->GetNoOfSpectra(); @@ -4977,7 +5186,10 @@ int PNeXus::WriteFileIdf2(const char* fileName, const NXaccess access) // open group 'detector_1' NXdata if (!ErrorHandler(NXopengroup(fFileHandle, "detector_1", "NXdata"), PNEXUS_GROUP_OPEN_ERROR, "couldn't open group 'detector_1' in NXroot.")) return NX_ERROR; - if (!ErrorHandler(NXmakelink(fFileHandle, &clink), PNEXUS_LINKING_ERROR, "couldn't create link to 'counts' in NXdetector.")) return NX_ERROR; + for (unsigned int i=0; i *GetRawTime() { return &fRawTime; } + virtual string GetRawTimeName() { return fRawTimeName; } + virtual string GetRawTimeUnit() { return fRawTimeUnit; } virtual bool IsT0Present() { return (fT0 == 0) ? false : true; } virtual int GetT0Tag() { return fT0Tag; } virtual int GetT0(int idxp=-1, int idxs=-1); @@ -393,7 +396,7 @@ class PNeXusDetector2 { virtual bool IsFirstGoodBinPresent() { return (fFirstGoodBin == 0) ? false : true; } virtual int GetFirstGoodBin(int idxp=-1, int idxs=-1); virtual int* GetFirstGoodBins() { return fFirstGoodBin; } - virtual bool IsLastGoodBinPresent() { return (fFirstGoodBin == 0) ? false : true; } + virtual bool IsLastGoodBinPresent() { return (fLastGoodBin == 0) ? false : true; } virtual int GetLastGoodBin(int idxp=-1, int idxs=-1); virtual int* GetLastGoodBins() { return fLastGoodBin; } virtual int GetNoOfPeriods() { return fNoOfPeriods; } @@ -407,6 +410,9 @@ class PNeXusDetector2 { virtual void SetDescription(string description) { fDescription = description; } virtual void SetTimeResolution(double val, string units); + virtual void SetRawTime(vector &rawTime); + virtual void SetRawTimeName(string rawTimeName) { fRawTimeName = rawTimeName; } + virtual void SetRawTimeUnit(string rawTimeUnit) { fRawTimeUnit = rawTimeUnit; } virtual void SetT0Tag(int tag) { fT0Tag = tag; } virtual int SetT0(int *t0); virtual int SetFirstGoodBin(int *fgb); @@ -423,12 +429,15 @@ class PNeXusDetector2 { string fDescription; ///< description of the detector double fTimeResolution; ///< keeps the time resolution in (ps) vector fSpectrumIndex; ///< list of global spectra + vector fRawTime; ///< keeps a raw time vector + string fRawTimeName; ///< name of the raw time vector + string fRawTimeUnit; ///< unit of the raw time vector int fNoOfPeriods; ///< number of periods or -1 if not defined int fNoOfSpectra; ///< number of spectra or -1 if not defined int fNoOfBins; ///< number of bins of a spectrum or -1 if not defined - int fT0Tag; ///< tag for t0, fgb, lgb structure. -1==not present, 1==NX_INT, 2=NX_INT[np][ns] + int fT0Tag; ///< tag for t0, fgb, lgb structure. -1==not present, 1==NX_INT, 2==NX_INT[ns], 3==NX_INT[np][ns] int *fT0; int *fFirstGoodBin; int *fLastGoodBin; diff --git a/src/include/PMusr.h b/src/include/PMusr.h index c52fc297..46438438 100644 --- a/src/include/PMusr.h +++ b/src/include/PMusr.h @@ -279,6 +279,8 @@ class PRawRunData { virtual const TString* GetBeamline() { return &fBeamline; } virtual const TString* GetInstrument() { return &fInstrument; } virtual const TString* GetRunName() { return &fRunName; } + virtual const TString* GetMuonSource() { return &fMuonSource; } + virtual const TString* GetMuonSpecies() { return &fMuonSpecies; } virtual const Int_t GetRunNumber() { return fRunNumber; } virtual const TString* GetRunTitle() { return &fRunTitle; } virtual const TString* GetSetup() { return &fSetup; } @@ -305,6 +307,7 @@ class PRawRunData { virtual const UInt_t GetT0EstimatedSize() { return fT0Estimated.size(); } virtual const Int_t GetT0Estimated(const UInt_t idx); virtual const PIntPair GetBkgBin(const UInt_t idx); + virtual const UInt_t GetGoodDataBinSize() { return fGoodDataBin.size(); } virtual const PIntPair GetGoodDataBin(const UInt_t idx); virtual const UInt_t GetNoOfHistos() { return fDataBin.size(); } virtual const PDoubleVector* GetDataBin(const UInt_t idx); @@ -313,6 +316,8 @@ class PRawRunData { virtual void SetLaboratory(const TString &str) { fLaboratory = str; } virtual void SetBeamline(const TString &str) { fBeamline = str; } virtual void SetInstrument(const TString &str) { fInstrument = str; } + virtual void SetMuonSource(const TString &str) { fMuonSource = str; } + virtual void SetMuonSpecies(const TString &str) { fMuonSpecies = str; } virtual void SetRunName(const TString &str) { fRunName = str; } virtual void SetRunNumber(const Int_t &val) { fRunNumber = val; } virtual void SetRunTitle(const TString str) { fRunTitle = str; } @@ -347,6 +352,8 @@ class PRawRunData { TString fLaboratory; ///< keeps the name of the laboratory, e.g. PSI, ISIS, TRIUMF, JPARC TString fBeamline; ///< keeps the name of the be beamline, e.g. muE4, piM3.1, ... TString fInstrument; ///< keeps the name of the instrument, e.g. LEM, GPS, MUSR, EMU, ... + TString fMuonSource; ///< keeps the type of muon source, e.g. continous surface beam, pulsed beam, low energy muon beam + TString fMuonSpecies; ///< positive muon or negative muon TString fRunName; ///< name of the run Int_t fRunNumber; ///< run number TString fRunTitle; ///< run title diff --git a/src/include/PRunDataHandler.h b/src/include/PRunDataHandler.h index fdaa639b..475a0db2 100644 --- a/src/include/PRunDataHandler.h +++ b/src/include/PRunDataHandler.h @@ -95,7 +95,7 @@ class PRunDataHandler virtual TString GetFileName(const TString extension, Bool_t &ok); virtual TString FileNameFromTemplate(TString &fileNameTemplate, Int_t run, TString &year, Bool_t &ok); - virtual TString GetMonth(Int_t month); + virtual bool DateToISO8601(string inDate, string &iso8601Date); virtual void SplitTimeDate(TString timeDate, TString &time, TString &date, Bool_t &ok); }; diff --git a/src/nexus_dump.cpp b/src/nexus_dump.cpp new file mode 100644 index 00000000..2cb58bac --- /dev/null +++ b/src/nexus_dump.cpp @@ -0,0 +1,74 @@ +/*************************************************************************** + + nexus_read_test.cpp + + Author: Andreas Suter + e-mail: andreas.suter@psi.ch + + $Id: nexus_read_test.cpp 4981 2011-08-23 17:22:29Z nemu $ + +***************************************************************************/ + +/*************************************************************************** + * Copyright (C) 2007-2011 by Andreas Suter * + * andreas.suter@psi.ch * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include +#include +#include + +#include +#include +#include +using namespace std; + +#include "PNeXus.h" + +//--------------------------------------------------------------------------------------- + +void nexus_read_test_syntax() +{ + cout << endl << ">>---------------------------------------------------------------------------------------"; + cout << endl << ">> usage: nexus_dump "; + cout << endl << ">> This will try to read a nexus-files and send the relevant"; + cout << endl << ">> information to the standard output."; + cout << endl << ">>---------------------------------------------------------------------------------------"; + cout << endl << endl; +} + +//--------------------------------------------------------------------------------------- + +int main(int argc, char *argv[]) +{ + if (argc !=2) { + nexus_read_test_syntax(); + return -1; + } + + PNeXus *nxs_file = new PNeXus(argv[1]); + + if (nxs_file->IsValid(false)) { + nxs_file->Dump(); + } + + if (nxs_file) + delete nxs_file; + + return 0; +} diff --git a/src/tests/nexus/Makefile b/src/tests/nexus/Makefile index b8595e49..8ad66028 100644 --- a/src/tests/nexus/Makefile +++ b/src/tests/nexus/Makefile @@ -6,12 +6,12 @@ NEXUS_CLASS_DIR = ../../external/nexus CXX = g++ CXXFLAGS = -g -Wall -fPIC -INCLUDES = -I /usr/local/include -I $(NEXUS_CLASS_DIR) +INCLUDES = -I /opt/nexus/include -I $(NEXUS_CLASS_DIR) LD = g++ LDFLAGS = -g -LIBS = -L /usr/local/lib -lNeXus -LIBS += -L /usr/lib -lhdf5 +LIBS = -L /opt/nexus/lib -lNeXus +LIBS += -L /opt/hdf/lib -lhdf5 EXEC = nexus_read_test diff --git a/src/tests/nexus/nexus_read_test.cpp b/src/tests/nexus/nexus_read_test.cpp index 9b421ad1..cbe4a9e9 100644 --- a/src/tests/nexus/nexus_read_test.cpp +++ b/src/tests/nexus/nexus_read_test.cpp @@ -67,7 +67,7 @@ int main(int argc, char *argv[]) PNeXus *nxs_file = new PNeXus(argv[1]); - if (nxs_file->IsValid(true)) { + if (nxs_file->IsValid(false)) { nxs_file->Dump(); if (argc == 5) {