any2many: force the user to define the exact NeXus ouput formate (HDF4,HDF5,XML)

This commit is contained in:
nemu 2011-04-14 08:01:44 +00:00
parent e77cb772e6
commit 2f8e393dfa
4 changed files with 55 additions and 29 deletions

View File

@ -6,6 +6,8 @@
changes since 0.9.0 changes since 0.9.0
=================================== ===================================
NEW any2many: force the user to define the exact NeXus ouput formate (HDF4,
HDF5, XML)
FIXED Makefiles so that the NeXus support will not be built if it has not been enabled during the configure stage FIXED Makefiles so that the NeXus support will not be built if it has not been enabled during the configure stage
FIXED ASCII export from musrview in case of a Fourier-Power- or Fourier-Phase-difference plot FIXED ASCII export from musrview in case of a Fourier-Power- or Fourier-Phase-difference plot
FIXED bug in asymmetry fit with fixed background FIXED bug in asymmetry fit with fixed background

View File

@ -64,9 +64,9 @@ void any2many_syntax()
cout << endl << " etc., or a sequence of runs <runStart>-<runEnd>, e.g. 111-222"; cout << endl << " etc., or a sequence of runs <runStart>-<runEnd>, e.g. 111-222";
cout << endl << " -c <convert-options> : <inFormat> <outFormat>"; cout << endl << " -c <convert-options> : <inFormat> <outFormat>";
cout << endl << " <inFormat> : input data file format. Supported formats are:"; cout << endl << " <inFormat> : input data file format. Supported formats are:";
cout << endl << " PSI-BIN, ROOT (LEM), MUD, NeXuS, PSI-MDU, WKM"; cout << endl << " PSI-BIN, ROOT (LEM), MUD, NeXus, PSI-MDU, WKM";
cout << endl << " <outFormat> : ouput data file format. Supported formats are:"; cout << endl << " <outFormat> : ouput data file format. Supported formats are:";
cout << endl << " PSI-BIN, ROOT (LEM), MUD, NeXuS, WKM, ASCII"; cout << endl << " PSI-BIN, ROOT (LEM), MUD, NeXus-HDF4, NeXus-HDF5, NeXus-XML, WKM, ASCII";
cout << endl << " -p <output-path> : where <output-path> is the output path for the"; cout << endl << " -p <output-path> : where <output-path> is the output path for the";
cout << endl << " converted files. If nothing is given, the current directory"; cout << endl << " converted files. If nothing is given, the current directory";
cout << endl << " will be used, unless the option '-s' is used."; cout << endl << " will be used, unless the option '-s' is used.";
@ -149,7 +149,9 @@ int main(int argc, char *argv[])
outputFormat.push_back("psi-bin"); outputFormat.push_back("psi-bin");
outputFormat.push_back("root"); outputFormat.push_back("root");
outputFormat.push_back("mud"); outputFormat.push_back("mud");
outputFormat.push_back("nexus"); outputFormat.push_back("nexus-hdf4");
outputFormat.push_back("nexus-hdf5");
outputFormat.push_back("nexus-xml");
outputFormat.push_back("wkm"); outputFormat.push_back("wkm");
outputFormat.push_back("ascii"); outputFormat.push_back("ascii");

View File

@ -4269,10 +4269,13 @@ Bool_t PMsrHandler::CheckRunBlockIntegrity()
return false; return false;
} }
if (fRuns[i].GetNormParamNo() > static_cast<Int_t>(fParam.size())) { if (fRuns[i].GetNormParamNo() > static_cast<Int_t>(fParam.size())) {
cerr << endl << "PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1; // check if forward histogram number is a function
cerr << endl << " forward histogram number " << fRuns[i].GetNormParamNo() << " is larger than the number of fit parameters (" << fParam.size() << ")."; if (fRuns[i].GetNormParamNo() - MSR_PARAM_FUN_OFFSET > static_cast<Int_t>(fParam.size())) {
cerr << endl << " Consider to check the manual ;-)" << endl; cerr << endl << "PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
return false; cerr << endl << " forward histogram number " << fRuns[i].GetNormParamNo() << " is larger than the number of fit parameters (" << fParam.size() << ").";
cerr << endl << " Consider to check the manual ;-)" << endl;
return false;
}
} }
// check fit range // check fit range
if ((fRuns[i].GetFitRange(0) == PMUSR_UNDEFINED) || (fRuns[i].GetFitRange(1) == PMUSR_UNDEFINED)) { if ((fRuns[i].GetFitRange(0) == PMUSR_UNDEFINED) || (fRuns[i].GetFitRange(1) == PMUSR_UNDEFINED)) {

View File

@ -64,14 +64,14 @@ using namespace std;
#define ROOT_NPP 1 #define ROOT_NPP 1
#define ROOT_PPC 2 #define ROOT_PPC 2
#define A2M_UNDEFINED 0 #define A2M_UNDEFINED 0
#define A2M_ROOT 1 #define A2M_ROOT 1
#define A2M_PSIBIN 2 #define A2M_PSIBIN 2
#define A2M_PSIMDU 3 #define A2M_PSIMDU 3
#define A2M_MUD 4 #define A2M_MUD 4
#define A2M_NEXUS 5 #define A2M_NEXUS 5
#define A2M_WKM 6 #define A2M_WKM 6
#define A2M_ASCII 7 #define A2M_ASCII 7
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// Constructor // Constructor
@ -279,7 +279,7 @@ Bool_t PRunDataHandler::ReadWriteFilesList()
outTag = A2M_PSIBIN; outTag = A2M_PSIBIN;
else if (!fAny2ManyInfo->outFormat.CompareTo("mud",TString::kIgnoreCase)) else if (!fAny2ManyInfo->outFormat.CompareTo("mud",TString::kIgnoreCase))
outTag = A2M_MUD; outTag = A2M_MUD;
else if (!fAny2ManyInfo->outFormat.CompareTo("nexus", TString::kIgnoreCase)) else if (fAny2ManyInfo->outFormat.BeginsWith("nexus", TString::kIgnoreCase))
outTag = A2M_NEXUS; outTag = A2M_NEXUS;
else if (!fAny2ManyInfo->outFormat.CompareTo("wkm", TString::kIgnoreCase)) else if (!fAny2ManyInfo->outFormat.CompareTo("wkm", TString::kIgnoreCase))
outTag = A2M_WKM; outTag = A2M_WKM;
@ -617,7 +617,7 @@ Bool_t PRunDataHandler::FileExistsCheck(PMsrRunBlock &runInfo, const UInt_t idx)
ext = TString("root"); ext = TString("root");
else if (!runInfo.GetFileFormat(idx)->CompareTo("root-ppc")) // post pile up corrected histos else if (!runInfo.GetFileFormat(idx)->CompareTo("root-ppc")) // post pile up corrected histos
ext = TString("root"); ext = TString("root");
else if (!runInfo.GetFileFormat(idx)->CompareTo("nexus")) else if ((!runInfo.GetFileFormat(idx)->CompareTo("nexus-hdf4")) || (!runInfo.GetFileFormat(idx)->CompareTo("nexus-hdf5")) || (!runInfo.GetFileFormat(idx)->CompareTo("nexus-xml")))
ext = TString("NXS"); ext = TString("NXS");
else if (!runInfo.GetFileFormat(idx)->CompareTo("psi-bin")) else if (!runInfo.GetFileFormat(idx)->CompareTo("psi-bin"))
ext = TString("bin"); ext = TString("bin");
@ -650,16 +650,16 @@ Bool_t PRunDataHandler::FileExistsCheck(PMsrRunBlock &runInfo, const UInt_t idx)
pstr->ToUpper(); pstr->ToUpper();
cerr << endl << ">> PRunDataHandler::FileExistsCheck: **ERROR** File Format '" << pstr->Data() << "' unsupported."; cerr << endl << ">> PRunDataHandler::FileExistsCheck: **ERROR** File Format '" << pstr->Data() << "' unsupported.";
cerr << endl << ">> support file formats are:"; cerr << endl << ">> support file formats are:";
cerr << endl << ">> ROOT-NPP -> root not post pileup corrected for lem"; cerr << endl << ">> ROOT-NPP -> root not post pileup corrected for lem";
cerr << endl << ">> ROOT-PPC -> root post pileup corrected for lem"; cerr << endl << ">> ROOT-PPC -> root post pileup corrected for lem";
cerr << endl << ">> NEXUS -> nexus file format"; cerr << endl << ">> NEXUS -> nexus file format, HDF4, HDF5, or XML";
cerr << endl << ">> PSI-BIN -> psi bin file format"; cerr << endl << ">> PSI-BIN -> psi bin file format";
cerr << endl << ">> PSI-MDU -> psi mdu file format (see also MDU-ASCII)"; cerr << endl << ">> PSI-MDU -> psi mdu file format (see also MDU-ASCII)";
cerr << endl << ">> MUD -> triumf mud file format"; cerr << endl << ">> MUD -> triumf mud file format";
cerr << endl << ">> WKM -> wkm ascii file format"; cerr << endl << ">> WKM -> wkm ascii file format";
cerr << endl << ">> MDU-ASCII -> psi mdu ascii file format"; cerr << endl << ">> MDU-ASCII -> psi mdu ascii file format";
cerr << endl << ">> ASCII -> column like file format"; cerr << endl << ">> ASCII -> column like file format";
cerr << endl << ">> DB -> triumf db file \"format\""; cerr << endl << ">> DB -> triumf db file \"format\"";
cerr << endl; cerr << endl;
return success; return success;
} }
@ -3354,8 +3354,27 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln)
data.clear(); data.clear();
} }
// filter out the proper file type, i.e. HDF4, HDF5, or XML
char fileType[32];
memset(fileType, '\0', 32);
if (!fAny2ManyInfo->outFormat.CompareTo("nexus-hdf4", TString::kIgnoreCase))
strncpy(fileType, "hdf4", sizeof(fileType));
else if (!fAny2ManyInfo->outFormat.CompareTo("nexus-hdf5", TString::kIgnoreCase))
strncpy(fileType, "hdf5", sizeof(fileType));
else if (!fAny2ManyInfo->outFormat.CompareTo("nexus-xml", TString::kIgnoreCase))
strncpy(fileType, "xml", sizeof(fileType));
else {
cerr << endl << ">> PRunDataHandler::WriteNexusFile(): **ERROR** undefined output NeXus format " << fAny2ManyInfo->outFormat.Data() << " found.";
cerr << endl << ">> Allowed are: hdf4, hdf5, xml" << endl;
if (nxs != 0) {
delete nxs;
nxs = 0;
}
return false;
}
// write file // write file
nxs->WriteFile(fln); nxs->WriteFile(fln, fileType);
// clean up // clean up
if (nxs != 0) { if (nxs != 0) {
@ -4022,7 +4041,7 @@ Bool_t PRunDataHandler::StripWhitespace(TString &str)
return false; return false;
strncpy(subs, s+start, end-start+1); strncpy(subs, s+start, end-start+1);
subs[end-start+1] = 0; subs[end-start+1] = '\0';
str = TString(subs); str = TString(subs);