more work on the conversion routines, NeXus, etc.

This commit is contained in:
suter_a 2011-12-16 15:22:35 +00:00
parent 8f5b5609bc
commit 60a11bffa5
5 changed files with 349 additions and 181 deletions

View File

@ -59,9 +59,19 @@ void any2many_syntax()
cout << endl << " -f <filenameList-input> : where <filenameList-input> is space"; cout << endl << " -f <filenameList-input> : where <filenameList-input> is space";
cout << endl << " separeted a list of file names (not starting with a '-'),"; cout << endl << " separeted a list of file names (not starting with a '-'),";
cout << endl << " e.g. 2010/lem10_his_0111.root 2010/lem10_his_0112.root"; cout << endl << " e.g. 2010/lem10_his_0111.root 2010/lem10_his_0112.root";
cout << endl << " -o <outputFileName> : this option only makes sense, if <filenameList-input>";
cout << endl << " is a single input file name!";
cout << endl << " -r <runList-input> : where <runList-input> is a list of run numbers"; cout << endl << " -r <runList-input> : where <runList-input> is a list of run numbers";
cout << endl << " separated by spaces ' ' of the form: <run1> <run2> <run3>"; cout << endl << " separated by spaces ' ' of the form: <run1> <run2> <run3>";
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 << " -t <in-template> <out-template> : ";
cout << endl << " <in-/out-template> : template file name. Needed for run-lists in";
cout << endl << " order to generate the proper file names. The following template";
cout << endl << " tags can be used: [yy] for year, and [rrrr] for the run number.";
cout << endl << " If the run number tag is used, the number of 'r' will give the";
cout << endl << " number of digits used with leading zeros, e.g. [rrrrrr] and run";
cout << endl << " number 123 will result in 000123. The same is true for the";
cout << endl << " year, i.e. [yyyy] will result in something like 1999.";
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, NeXus1, NeXus2, PSI-MDU, WKM"; cout << endl << " PSI-BIN, ROOT (LEM), MUD, NeXus1, NeXus2, PSI-MDU, WKM";
@ -74,14 +84,6 @@ void any2many_syntax()
cout << endl << " -y <year> : if the option -y is used, here a year in the form 'yy' can"; cout << endl << " -y <year> : if the option -y is used, here a year in the form 'yy' can";
cout << endl << " be given, if this is the case, any automatic file name"; cout << endl << " be given, if this is the case, any automatic file name";
cout << endl << " generation needs a year, this number will be used."; cout << endl << " generation needs a year, this number will be used.";
cout << endl << " -t <in-template> <out-template> : ";
cout << endl << " <in-/out-template> : template file name. Needed for run-lists in";
cout << endl << " order to generate the proper file names. The following template";
cout << endl << " tags can be used: [yy] for year, and [rrrr] for the run number.";
cout << endl << " If the run number tag is used, the number of 'r' will give the";
cout << endl << " number of digits used with leading zeros, e.g. [rrrrrr] and run";
cout << endl << " number 123 will result in 000123. The same is true for the";
cout << endl << " year, i.e. [yyyy] will result in something like 1999.";
cout << endl << " -s : with this option the output data file will be sent to the stdout."; cout << endl << " -s : with this option the output data file will be sent to the stdout.";
cout << endl << " -rebin <n> : where <n> is the number of bins to be packed"; cout << endl << " -rebin <n> : where <n> is the number of bins to be packed";
cout << endl << " -z [g|b] <compressed> : where <compressed> is the output file name"; cout << endl << " -z [g|b] <compressed> : where <compressed> is the output file name";
@ -97,6 +99,10 @@ void any2many_syntax()
cout << endl << " Will take the LEM ROOT file '2010/lem10_his_0123.root' rebin it with 25"; cout << endl << " Will take the LEM ROOT file '2010/lem10_his_0123.root' rebin it with 25";
cout << endl << " and convert it to ASCII. The output file name will be"; cout << endl << " and convert it to ASCII. The output file name will be";
cout << endl << " lem10_his_0123.ascii, and the file will be saved in the current directory." << endl; cout << endl << " lem10_his_0123.ascii, and the file will be saved in the current directory." << endl;
cout << endl << " any2many -f 2010/lem10_his_0123.root -c ROOT NEXUS2-HDF5 -o 2010/lem10_his_0123_v2.nxs";
cout << endl << " Will take the LEM ROOT file '2010/lem10_his_0123.root' ";
cout << endl << " and convert it to NeXus IDF V2. The output file name will be";
cout << endl << " lem10_his_0123_v2.nxs, and the file will be saved in the current directory." << endl;
cout << endl << " any2many -r 123 137 -c PSI-BIN MUD -t d[yyyy]/deltat_tdc_gps_[rrrr].bin \\"; cout << endl << " any2many -r 123 137 -c PSI-BIN MUD -t d[yyyy]/deltat_tdc_gps_[rrrr].bin \\";
cout << endl << " [rrrrrr].msr -y 2001"; cout << endl << " [rrrrrr].msr -y 2001";
cout << endl << " Will take the run 123 and 137, will generate the input file names:"; cout << endl << " Will take the run 123 and 137, will generate the input file names:";
@ -137,6 +143,7 @@ int main(int argc, char *argv[])
PAny2ManyInfo info; PAny2ManyInfo info;
PStringVector inputFormat; PStringVector inputFormat;
PStringVector outputFormat; PStringVector outputFormat;
TString outputFileName = TString("");
// init inputFormat // init inputFormat
inputFormat.push_back("psi-bin"); inputFormat.push_back("psi-bin");
@ -164,6 +171,9 @@ int main(int argc, char *argv[])
info.rebin = 1; info.rebin = 1;
info.compressionTag = 0; // no compression as default info.compressionTag = 0; // no compression as default
info.idf = 0; // undefined info.idf = 0; // undefined
info.inTemplate = TString("");
info.outTemplate = TString("");
info.outFileName = TString("");
// call any2many without arguments // call any2many without arguments
if (argc == 1) { if (argc == 1) {
@ -236,6 +246,18 @@ int main(int argc, char *argv[])
} }
} }
// handle output file name option '-o'
if (!strcmp(argv[i], "-o")) {
if (i+1 < argc) {
outputFileName = argv[i+1];
i++;
} else {
cerr << endl << ">> any2many **ERROR** found output file name option '-o' without any arguments" << endl;
show_syntax = true;
break;
}
}
if (!strcmp(argv[i], "-r")) { if (!strcmp(argv[i], "-r")) {
if (i+1 < argc) { if (i+1 < argc) {
// first check for run list sequence of the form <runStartNo>-<runEndNo> // first check for run list sequence of the form <runStartNo>-<runEndNo>
@ -327,6 +349,7 @@ int main(int argc, char *argv[])
info.outPath = argv[i+1]; info.outPath = argv[i+1];
if (!info.outPath.EndsWith("/")) if (!info.outPath.EndsWith("/"))
info.outPath += "/"; info.outPath += "/";
i++;
} else { } else {
cerr << endl << ">> any2many **ERROR** found output option '-p' without any argument." << endl; cerr << endl << ">> any2many **ERROR** found output option '-p' without any argument." << endl;
show_syntax = true; show_syntax = true;
@ -415,6 +438,22 @@ int main(int argc, char *argv[])
if (info.outFormat.Contains("nexus2", TString::kIgnoreCase)) if (info.outFormat.Contains("nexus2", TString::kIgnoreCase))
info.idf = 2; info.idf = 2;
// in case the '-o' is present, make sure that inFileName is only a single file name
if (outputFileName.Length() > 0) {
if (info.inFileName.size() == 1) {
// make sure there is not in addition the template option given
if ((info.inTemplate.Length() == 0) && (info.outTemplate.Length() == 0)) {
info.outFileName = outputFileName;
} else {
cerr << endl << ">> any2many **ERROR** found option '-o' cannot be combined with option '-t'." << endl;
show_syntax = true;
}
} else {
cerr << endl << ">> any2many **ERROR** found option '-o' with multiple input file names, which doesn't make any sense." << endl;
show_syntax = true;
}
}
if (show_syntax) { if (show_syntax) {
info.runList.clear(); info.runList.clear();
any2many_syntax(); any2many_syntax();

View File

@ -221,6 +221,9 @@ void PNonMusrRawRunData::AppendSubErrData(const UInt_t idx, const Double_t dval)
*/ */
PRawRunData::PRawRunData() PRawRunData::PRawRunData()
{ {
fLaboratory = TString("n/a");
fBeamline = TString("n/a");
fInstrument = TString("n/a");
fRunName = TString("n/a"); fRunName = TString("n/a");
fRunNumber = -1; fRunNumber = -1;
fRunTitle = TString("n/a"); fRunTitle = TString("n/a");

View File

@ -355,25 +355,46 @@ Bool_t PRunDataHandler::ReadWriteFilesList()
success = false; success = false;
switch (outTag) { switch (outTag) {
case A2M_ROOT: case A2M_ROOT:
success = WriteRootFile(); if (fAny2ManyInfo->outFileName.Length() == 0)
success = WriteRootFile();
else
success = WriteRootFile(fAny2ManyInfo->outFileName);
break; break;
case A2M_PSIBIN: case A2M_PSIBIN:
success = WritePsiBinFile(); if (fAny2ManyInfo->outFileName.Length() == 0)
success = WritePsiBinFile();
else
success = WritePsiBinFile(fAny2ManyInfo->outFileName);
break; break;
case A2M_PSIMDU: case A2M_PSIMDU:
success = WritePsiBinFile(); if (fAny2ManyInfo->outFileName.Length() == 0)
success = WritePsiBinFile();
else
success = WritePsiBinFile(fAny2ManyInfo->outFileName);
break; break;
case A2M_NEXUS: case A2M_NEXUS:
success = WriteNexusFile(); if (fAny2ManyInfo->outFileName.Length() == 0)
success = WriteNexusFile();
else
success = WriteNexusFile(fAny2ManyInfo->outFileName);
break; break;
case A2M_MUD: case A2M_MUD:
success = WriteMudFile(); if (fAny2ManyInfo->outFileName.Length() == 0)
success = WriteMudFile();
else
success = WriteMudFile(fAny2ManyInfo->outFileName);
break; break;
case A2M_WKM: case A2M_WKM:
success = WriteWkmFile(); if (fAny2ManyInfo->outFileName.Length() == 0)
success = WriteWkmFile();
else
success = WriteWkmFile(fAny2ManyInfo->outFileName);
break; break;
case A2M_ASCII: case A2M_ASCII:
success = WriteAsciiFile(); if (fAny2ManyInfo->outFileName.Length() == 0)
success = WriteAsciiFile();
else
success = WriteAsciiFile(fAny2ManyInfo->outFileName);
break; break;
default: default:
break; break;
@ -1018,6 +1039,11 @@ Bool_t PRunDataHandler::ReadRootFile(UInt_t tag)
return false; return false;
} }
// set laboratory / beamline / instrument
runData.SetLaboratory("PSI");
runData.SetBeamline("muE4");
runData.SetInstrument("LEM");
// get run title // get run title
TObjString ostr = runHeader->GetRunTitle(); TObjString ostr = runHeader->GetRunTitle();
runData.SetRunTitle(ostr.GetString()); runData.SetRunTitle(ostr.GetString());
@ -1365,6 +1391,18 @@ Bool_t PRunDataHandler::ReadNexusFile()
// get header information // get header information
// get/set laboratory
str = TString(nxs_file->GetEntryIdf1()->GetLaboratory());
runData.SetLaboratory(str);
// get/set beamline
str = TString(nxs_file->GetEntryIdf1()->GetBeamline());
runData.SetBeamline(str);
// get/set instrument
str = TString(nxs_file->GetEntryIdf1()->GetInstrument()->GetName());
runData.SetInstrument(str);
// get/set run title // get/set run title
str = TString(nxs_file->GetEntryIdf1()->GetTitle()); str = TString(nxs_file->GetEntryIdf1()->GetTitle());
runData.SetRunTitle(str); runData.SetRunTitle(str);
@ -1967,6 +2005,34 @@ Bool_t PRunDataHandler::ReadPsiBinFile()
PIntVector ivec; PIntVector ivec;
PRawRunData runData; PRawRunData runData;
Double_t dval; Double_t dval;
// set laboratory
runData.SetLaboratory("PSI");
// filter from the file name the instrument
TString instrument("n/a"), beamline("n/a");
if (fRunPathName.Contains("_gps_", TString::kIgnoreCase)) {
instrument = "GPS";
beamline = "piM3.2";
} else if (fRunPathName.Contains("_ltf_", TString::kIgnoreCase)) {
instrument = "LTF";
beamline = "piM3.3";
} else if (fRunPathName.Contains("_gpd_", TString::kIgnoreCase)) {
instrument = "GPD";
beamline = "muE1";
} else if (fRunPathName.Contains("_dolly_", TString::kIgnoreCase)) {
instrument = "DOLLY";
beamline = "piE1";
} else if (fRunPathName.Contains("_alc_", TString::kIgnoreCase)) {
instrument = "ALC";
beamline = "piE3";
} else if (fRunPathName.Contains("_hifi_", TString::kIgnoreCase)) {
instrument = "HIFI";
beamline = "piE3";
}
runData.SetInstrument(instrument);
runData.SetBeamline(beamline);
// keep run name // keep run name
runData.SetRunName(fRunName); runData.SetRunName(fRunName);
// get run title // get run title
@ -2098,6 +2164,33 @@ Bool_t PRunDataHandler::ReadMudFile()
// keep run name // keep run name
runData.SetRunName(fRunName); runData.SetRunName(fRunName);
// get/set the lab
success = MUD_getLab( fh, str, sizeof(str) );
if ( !success ) {
cerr << endl << ">> **WARNING** Couldn't obtain the laboratory name of run " << fRunName.Data();
cerr << endl;
strcpy(str, "n/a");
}
runData.SetLaboratory(TString(str));
// get/set the beamline
success = MUD_getArea( fh, str, sizeof(str) );
if ( !success ) {
cerr << endl << ">> **WARNING** Couldn't obtain the beamline of run " << fRunName.Data();
cerr << endl;
strcpy(str, "n/a");
}
runData.SetBeamline(TString(str));
// get/set the instrument
success = MUD_getApparatus( fh, str, sizeof(str) );
if ( !success ) {
cerr << endl << ">> **WARNING** Couldn't obtain the instrument name of run " << fRunName.Data();
cerr << endl;
strcpy(str, "n/a");
}
runData.SetInstrument(TString(str));
// get run title // get run title
success = MUD_getTitle( fh, str, sizeof(str) ); success = MUD_getTitle( fh, str, sizeof(str) );
if ( !success ) { if ( !success ) {
@ -3641,14 +3734,16 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln)
nxs->GetEntryIdf1()->SetRunNumber(fData[0].GetRunNumber()); nxs->GetEntryIdf1()->SetRunNumber(fData[0].GetRunNumber());
nxs->GetEntryIdf1()->SetTitle(fData[0].GetRunTitle()->Data()); nxs->GetEntryIdf1()->SetTitle(fData[0].GetRunTitle()->Data());
nxs->GetEntryIdf1()->SetNotes("n/a"); nxs->GetEntryIdf1()->SetNotes("n/a");
nxs->GetEntryIdf1()->SetAnalysis("n/a"); nxs->GetEntryIdf1()->SetAnalysis("muonTD");
nxs->GetEntryIdf1()->SetLaboratory("PSI"); if (*fData[0].GetLaboratory() != "n/a")
nxs->GetEntryIdf1()->SetBeamline("n/a"); 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(" ") + string(fData[0].GetStartTime()->Data());
nxs->GetEntryIdf1()->SetStartTime(str); nxs->GetEntryIdf1()->SetStartTime(str);
str = string(fData[0].GetStopDate()->Data()) + string(" ") + string(fData[0].GetStopTime()->Data()); str = string(fData[0].GetStopDate()->Data()) + string(" ") + string(fData[0].GetStopTime()->Data());
nxs->GetEntryIdf1()->SetStopTime(str); nxs->GetEntryIdf1()->SetStopTime(str);
nxs->GetEntryIdf1()->SetSwitchingState(0); nxs->GetEntryIdf1()->SetSwitchingState(1);
nxs->GetEntryIdf1()->GetUser()->SetName("n/a"); nxs->GetEntryIdf1()->GetUser()->SetName("n/a");
nxs->GetEntryIdf1()->GetUser()->SetExperimentNumber("n/a"); nxs->GetEntryIdf1()->GetUser()->SetExperimentNumber("n/a");
nxs->GetEntryIdf1()->GetSample()->SetName(fData[0].GetSample()->Data()); nxs->GetEntryIdf1()->GetSample()->SetName(fData[0].GetSample()->Data());
@ -3657,17 +3752,22 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln)
nxs->GetEntryIdf1()->GetSample()->SetEnvironment("n/a"); nxs->GetEntryIdf1()->GetSample()->SetEnvironment("n/a");
nxs->GetEntryIdf1()->GetSample()->SetShape("n/a"); nxs->GetEntryIdf1()->GetSample()->SetShape("n/a");
nxs->GetEntryIdf1()->GetSample()->SetMagneticFieldVectorAvailable(0); nxs->GetEntryIdf1()->GetSample()->SetMagneticFieldVectorAvailable(0);
nxs->GetEntryIdf1()->GetInstrument()->SetName("n/a"); 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()->GetDetector()->SetNumber(fData[0].GetNoOfHistos());
nxs->GetEntryIdf1()->GetInstrument()->GetCollimator()->SetType("n/a"); nxs->GetEntryIdf1()->GetInstrument()->GetCollimator()->SetType("n/a");
nxs->GetEntryIdf1()->GetData()->SetTimeResolution(fData[0].GetTimeResolution(), "ns"); nxs->GetEntryIdf1()->GetData()->SetTimeResolution(fData[0].GetTimeResolution(), "ns");
if (fData[0].GetT0(0) == -1)
nxs->GetEntryIdf1()->GetData()->SetT0(0); // t0
if (fData[0].GetT0(0) == -1) // t0 not povided in the raw data file header
nxs->GetEntryIdf1()->GetData()->SetT0(fData[0].GetT0Estimated(0)); // take the estimated t0 value
else else
nxs->GetEntryIdf1()->GetData()->SetT0(fData[0].GetT0(0)); // this needs to be changed in the long term, since for continous sources each detector has its one t0!! nxs->GetEntryIdf1()->GetData()->SetT0(fData[0].GetT0(0)); // this needs to be changed in the long term, since for continous sources each detector has its one t0!!
int time_bin_offset = (int)(10.0 / fData[0].GetTimeResolution()); // 10ns time offset for fgb if not given
if (fData[0].GetGoodDataBin(0).first == -1) { if (fData[0].GetGoodDataBin(0).first == -1) {
nxs->GetEntryIdf1()->GetData()->SetFirstGoodBin(0); nxs->GetEntryIdf1()->GetData()->SetFirstGoodBin(nxs->GetEntryIdf1()->GetData()->GetT0(0)+time_bin_offset);
nxs->GetEntryIdf1()->GetData()->SetLastGoodBin(0); nxs->GetEntryIdf1()->GetData()->SetLastGoodBin(fData[0].GetDataBin(0)->size()-1);
} else { } else {
nxs->GetEntryIdf1()->GetData()->SetFirstGoodBin(fData[0].GetGoodDataBin(0).first); nxs->GetEntryIdf1()->GetData()->SetFirstGoodBin(fData[0].GetGoodDataBin(0).first);
nxs->GetEntryIdf1()->GetData()->SetLastGoodBin(fData[0].GetGoodDataBin(0).second); nxs->GetEntryIdf1()->GetData()->SetLastGoodBin(fData[0].GetGoodDataBin(0).second);

View File

@ -2927,14 +2927,30 @@ int PNeXus::ReadFileIdf1()
// close subgroup NXinstrument // close subgroup NXinstrument
NXclosegroup(fFileHandle); NXclosegroup(fFileHandle);
// find the first occuring NXdata class
found = false;
do {
status = NXgetnextentry(fFileHandle, nxname, nxclass, &dataType);
if (strstr(nxclass, "NXdata") != NULL)
found = true;
} while (!found || (status == NX_EOD));
// make sure any NXentry has been found
if (!found) {
fErrorCode = PNEXUS_GROUP_OPEN_ERROR;
fErrorMsg = ">> **ERROR** Couldn't find any NXdata!";
return NX_ERROR;
}
// open subgroup NXdata (this is for Version 1, only and is subject to change in the near future!) // open subgroup NXdata (this is for Version 1, only and is subject to change in the near future!)
if (!ErrorHandler(NXopengroup(fFileHandle, "histogram_data_1", "NXdata"), PNEXUS_GROUP_OPEN_ERROR, "couldn't open NeXus subgroup histogram_data_1!")) return NX_ERROR; memset(cstr, '\0', sizeof(cstr));
snprintf(cstr, sizeof(cstr), "couldn't open NeXus subgroup %s!", nxname);
if (!ErrorHandler(NXopengroup(fFileHandle, nxname, "NXdata"), PNEXUS_GROUP_OPEN_ERROR, cstr)) return NX_ERROR;
// get time resolution // get time resolution
if (!ErrorHandler(NXopendata(fFileHandle, "resolution"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'resolution' data in histogram_data_1 group!")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "resolution"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'resolution' data in NXdata group!")) return NX_ERROR;
if (!ErrorHandler(NXgetdata(fFileHandle, &ival), PNEXUS_GET_DATA_ERROR, "couldn't read 'resolution' data in histogram_data_1 group!")) return NX_ERROR; if (!ErrorHandler(NXgetdata(fFileHandle, &ival), PNEXUS_GET_DATA_ERROR, "couldn't read 'resolution' data in NXdata group!")) return NX_ERROR;
if (!ErrorHandler(GetStringAttr("units", str), PNEXUS_GET_ATTR_ERROR, "couldn't read 'resolution'' units!")) return NX_ERROR; if (!ErrorHandler(GetStringAttr("units", str), PNEXUS_GET_ATTR_ERROR, "couldn't read 'resolution' units!")) return NX_ERROR;
if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'resolution' data in histogram_data_1 group")) return NX_ERROR; if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'resolution' data in NXdata group")) return NX_ERROR;
if (!strcmp(str.c_str(), "picoseconds")) { if (!strcmp(str.c_str(), "picoseconds")) {
fNxEntry1->GetData()->SetTimeResolution((double)ival, "ps"); fNxEntry1->GetData()->SetTimeResolution((double)ival, "ps");
} else if (!strcmp(str.c_str(), "femtoseconds")) { } else if (!strcmp(str.c_str(), "femtoseconds")) {
@ -2942,7 +2958,7 @@ int PNeXus::ReadFileIdf1()
} }
// get data, t0, first good bin, last good bin, data // get data, t0, first good bin, last good bin, data
if (!ErrorHandler(NXopendata(fFileHandle, "counts"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'counts' data in histogram_data_1 group!")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "counts"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'counts' data in NXdata group!")) return NX_ERROR;
int histoLength=0; int histoLength=0;
int noOfHistos=0; int noOfHistos=0;
@ -2951,14 +2967,14 @@ int PNeXus::ReadFileIdf1()
attType = NX_INT32; attType = NX_INT32;
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, "number", sizeof(cstr)); strncpy(cstr, "number", sizeof(cstr));
if (!ErrorHandler(NXgetattr(fFileHandle, cstr, &noOfHistos, &attLen, &attType), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'number' data in histogram_data_1 group!")) return NX_ERROR; if (!ErrorHandler(NXgetattr(fFileHandle, cstr, &noOfHistos, &attLen, &attType), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'number' data in NXdata group!")) return NX_ERROR;
// get histo length // get histo length
attLen = 1; attLen = 1;
attType = NX_INT32; attType = NX_INT32;
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, "length", sizeof(cstr)); strncpy(cstr, "length", sizeof(cstr));
if (!ErrorHandler(NXgetattr(fFileHandle, cstr, &histoLength, &attLen, &attType), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'length' data in histogram_data_1 group!")) return NX_ERROR; if (!ErrorHandler(NXgetattr(fFileHandle, cstr, &histoLength, &attLen, &attType), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'length' data in NXdata group!")) return NX_ERROR;
// get t0 // get t0
attLen = 1; attLen = 1;
@ -2969,7 +2985,7 @@ int PNeXus::ReadFileIdf1()
cout << endl << ">> **WARNING** didn't find attribute 'T0_bin' in NXdata/counts, will try 't0_bin'." << endl; cout << endl << ">> **WARNING** didn't find attribute 'T0_bin' in NXdata/counts, will try 't0_bin'." << endl;
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, "t0_bin", sizeof(cstr)); strncpy(cstr, "t0_bin", sizeof(cstr));
if (!ErrorHandler(NXgetattr(fFileHandle, cstr, &ival, &attLen, &attType), PNEXUS_OPEN_DATA_ERROR, "couldn't open 't0_bin' data in histogram_data_1 group!")) return NX_ERROR; if (!ErrorHandler(NXgetattr(fFileHandle, cstr, &ival, &attLen, &attType), PNEXUS_OPEN_DATA_ERROR, "couldn't open 't0_bin' data in NXdata group!")) return NX_ERROR;
} }
fNxEntry1->GetData()->SetT0(ival); fNxEntry1->GetData()->SetT0(ival);
@ -2978,7 +2994,7 @@ int PNeXus::ReadFileIdf1()
attType = NX_INT32; attType = NX_INT32;
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, "first_good_bin", sizeof(cstr)); strncpy(cstr, "first_good_bin", sizeof(cstr));
if (!ErrorHandler(NXgetattr(fFileHandle, cstr, &ival, &attLen, &attType), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'first_good_bin' data in histogram_data_1 group!")) return NX_ERROR; if (!ErrorHandler(NXgetattr(fFileHandle, cstr, &ival, &attLen, &attType), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'first_good_bin' data in NXdata group!")) return NX_ERROR;
fNxEntry1->GetData()->SetFirstGoodBin(ival); fNxEntry1->GetData()->SetFirstGoodBin(ival);
// get last good bin // get last good bin
@ -2986,7 +3002,7 @@ int PNeXus::ReadFileIdf1()
attType = NX_INT32; attType = NX_INT32;
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, "last_good_bin", sizeof(cstr)); strncpy(cstr, "last_good_bin", sizeof(cstr));
if (!ErrorHandler(NXgetattr(fFileHandle, cstr, &ival, &attLen, &attType), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'last_good_bin' data in histogram_data_1 group!")) return NX_ERROR; if (!ErrorHandler(NXgetattr(fFileHandle, cstr, &ival, &attLen, &attType), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'last_good_bin' data in NXdata group!")) return NX_ERROR;
fNxEntry1->GetData()->SetLastGoodBin(ival); fNxEntry1->GetData()->SetLastGoodBin(ival);
// get data // get data
@ -3042,22 +3058,22 @@ int PNeXus::ReadFileIdf1()
delete [] data_ptr; delete [] data_ptr;
} }
if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'counts' data in histogram_data_1 group")) return NX_ERROR; if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'counts' data in NXdata group")) return NX_ERROR;
// get grouping // get grouping
if (!ErrorHandler(NXopendata(fFileHandle, "grouping"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'grouping' data in histogram_data_1 group!")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "grouping"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'grouping' data in NXdata group!")) return NX_ERROR;
attLen = 1; attLen = 1;
attType = NX_INT32; attType = NX_INT32;
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, "available", sizeof(cstr)); strncpy(cstr, "available", sizeof(cstr));
if (!ErrorHandler(NXgetattr(fFileHandle, cstr, &ival, &attLen, &attType), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'grouping available' data in histogram_data_1 group!")) return NX_ERROR; if (!ErrorHandler(NXgetattr(fFileHandle, cstr, &ival, &attLen, &attType), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'grouping available' data in NXdata group!")) return NX_ERROR;
if (ival) { if (ival) {
vector<int> grouping; vector<int> grouping;
if (!ErrorHandler(GetIntVectorData(grouping), PNEXUS_GET_DATA_ERROR, "couldn't read 'grouping' data in histogram_data_1 group!")) return NX_ERROR; if (!ErrorHandler(GetIntVectorData(grouping), PNEXUS_GET_DATA_ERROR, "couldn't read 'grouping' data in NXdata group!")) return NX_ERROR;
fNxEntry1->GetData()->SetGrouping(grouping); fNxEntry1->GetData()->SetGrouping(grouping);
grouping.clear(); grouping.clear();
} }
if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'grouping' data in histogram_data_1 group")) return NX_ERROR; if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'grouping' data in NXdata group")) return NX_ERROR;
// if grouping has been available check for consistency // if grouping has been available check for consistency
bool ok=true; bool ok=true;
@ -3080,12 +3096,12 @@ int PNeXus::ReadFileIdf1()
} }
// get alpha // get alpha
if (!ErrorHandler(NXopendata(fFileHandle, "alpha"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'alpha' data in histogram_data_1 group!")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "alpha"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'alpha' data in NXdata group!")) return NX_ERROR;
attLen = 1; attLen = 1;
attType = NX_INT32; attType = NX_INT32;
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, "available", sizeof(cstr)); strncpy(cstr, "available", sizeof(cstr));
if (!ErrorHandler(NXgetattr(fFileHandle, cstr, &ival, &attLen, &attType), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'alpha available' data in histogram_data_1 group!")) return NX_ERROR; if (!ErrorHandler(NXgetattr(fFileHandle, cstr, &ival, &attLen, &attType), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'alpha available' data in NXdata group!")) return NX_ERROR;
if (ival) { if (ival) {
if (!ErrorHandler(NXgetinfo(fFileHandle, &rank, dims, &type), PNEXUS_GET_META_INFO_ERROR, "couldn't get alpha info!")) return NX_ERROR; if (!ErrorHandler(NXgetinfo(fFileHandle, &rank, dims, &type), PNEXUS_GET_META_INFO_ERROR, "couldn't get alpha info!")) return NX_ERROR;
// calculate the needed size // calculate the needed size
@ -3136,7 +3152,7 @@ int PNeXus::ReadFileIdf1()
delete [] data_ptr; delete [] data_ptr;
} }
} }
if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'alpha' data in histogram_data_1 group")) return NX_ERROR; if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'alpha' data in NXdata group")) return NX_ERROR;
// close subgroup NXdata // close subgroup NXdata
NXclosegroup(fFileHandle); NXclosegroup(fFileHandle);
@ -4020,191 +4036,191 @@ int PNeXus::WriteFileIdf1(const char* fileName, const NXaccess access)
if (!ErrorHandler(NXputattr(fFileHandle, "user", cstr, strlen(cstr), NX_CHAR), PNEXUS_SET_ATTR_ERROR, "couldn't set NXfile attributes")) return NX_ERROR; if (!ErrorHandler(NXputattr(fFileHandle, "user", cstr, strlen(cstr), NX_CHAR), PNEXUS_SET_ATTR_ERROR, "couldn't set NXfile attributes")) return NX_ERROR;
// make group 'run' // make group 'run'
if (!ErrorHandler(NXmakegroup(fFileHandle, "run", "NXentry"), PNEXUS_CREATE_GROUP_ERROR, "couldn't create group 'run'.")) return NX_ERROR; if (!ErrorHandler(NXmakegroup(fFileHandle, "run", "NXentry"), PNEXUS_CREATE_GROUP_ERROR, "couldn't create group 'NXfile/run'.")) return NX_ERROR;
// open group 'run' // open group 'run'
if (!ErrorHandler(NXopengroup(fFileHandle, "run", "NXentry"), PNEXUS_GROUP_OPEN_ERROR, "couldn't open group 'run' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopengroup(fFileHandle, "run", "NXentry"), PNEXUS_GROUP_OPEN_ERROR, "couldn't open group 'NXfile/run' for writting.")) return NX_ERROR;
// write IDF_version // write IDF_version
size = 1; size = 1;
if (!ErrorHandler(NXmakedata(fFileHandle, "IDF_version", NX_INT32, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'IDF_version'.")) return NX_ERROR; if (!ErrorHandler(NXmakedata(fFileHandle, "IDF_version", NX_INT32, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'NXentry/IDF_version'.")) return NX_ERROR;
if (!ErrorHandler(NXopendata(fFileHandle, "IDF_version"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'IDF_version' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "IDF_version"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'NXentry/IDF_version' for writting.")) return NX_ERROR;
idata = fIdfVersion; idata = fIdfVersion;
if (!ErrorHandler(NXputdata(fFileHandle, &idata), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'IDF_version'.")) return NX_ERROR; if (!ErrorHandler(NXputdata(fFileHandle, &idata), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXentry/IDF_version'.")) return NX_ERROR;
NXclosedata(fFileHandle); NXclosedata(fFileHandle);
// write program_name, and attribute version // write program_name, and attribute version
size = fNxEntry1->GetProgramName().length(); size = fNxEntry1->GetProgramName().length();
if (!ErrorHandler(NXmakedata(fFileHandle, "program_name", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'program_name'.")) return NX_ERROR; if (!ErrorHandler(NXmakedata(fFileHandle, "program_name", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'NXentry/program_name'.")) return NX_ERROR;
if (!ErrorHandler(NXopendata(fFileHandle, "program_name"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'program_name' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "program_name"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'NXentry/program_name' for writting.")) return NX_ERROR;
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, fNxEntry1->GetProgramName().c_str(), sizeof(cstr)); strncpy(cstr, fNxEntry1->GetProgramName().c_str(), sizeof(cstr));
if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'program_name'.")) return NX_ERROR; if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXentry/program_name'.")) return NX_ERROR;
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, fNxEntry1->GetProgramVersion().c_str(), sizeof(cstr)); strncpy(cstr, fNxEntry1->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'")) return NX_ERROR; if (!ErrorHandler(NXputattr(fFileHandle, "version", cstr, strlen(cstr), NX_CHAR), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'version' for 'NXentry/program_name'")) return NX_ERROR;
NXclosedata(fFileHandle); NXclosedata(fFileHandle);
// write run 'number' // write run 'number'
size = 1; size = 1;
if (!ErrorHandler(NXmakedata(fFileHandle, "number", NX_INT32, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'number'.")) return NX_ERROR; if (!ErrorHandler(NXmakedata(fFileHandle, "number", NX_INT32, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'NXentry/number'.")) return NX_ERROR;
if (!ErrorHandler(NXopendata(fFileHandle, "number"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'number' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "number"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'NXentry/number' for writting.")) return NX_ERROR;
idata = fNxEntry1->GetRunNumber(); idata = fNxEntry1->GetRunNumber();
if (!ErrorHandler(NXputdata(fFileHandle, &idata), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'number'.")) return NX_ERROR; if (!ErrorHandler(NXputdata(fFileHandle, &idata), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXentry/number'.")) return NX_ERROR;
NXclosedata(fFileHandle); NXclosedata(fFileHandle);
// write run 'title' // write run 'title'
size = fNxEntry1->GetTitle().length(); size = fNxEntry1->GetTitle().length();
if (!ErrorHandler(NXmakedata(fFileHandle, "title", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'title'.")) return NX_ERROR; if (!ErrorHandler(NXmakedata(fFileHandle, "title", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'NXentry/title'.")) return NX_ERROR;
if (!ErrorHandler(NXopendata(fFileHandle, "title"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'title' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "title"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'NXentry/title' for writting.")) return NX_ERROR;
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, fNxEntry1->GetTitle().c_str(), sizeof(cstr)); strncpy(cstr, fNxEntry1->GetTitle().c_str(), sizeof(cstr));
if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'title'.")) return NX_ERROR; if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXentry/title'.")) return NX_ERROR;
NXclosedata(fFileHandle); NXclosedata(fFileHandle);
// write run 'notes' // write run 'notes'
size = fNxEntry1->GetNotes().length(); size = fNxEntry1->GetNotes().length();
if (!ErrorHandler(NXmakedata(fFileHandle, "notes", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'notes'.")) return NX_ERROR; if (!ErrorHandler(NXmakedata(fFileHandle, "notes", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'NXentry/notes'.")) return NX_ERROR;
if (!ErrorHandler(NXopendata(fFileHandle, "notes"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'notes' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "notes"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'NXentry/notes' for writting.")) return NX_ERROR;
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, fNxEntry1->GetNotes().c_str(), sizeof(cstr)); strncpy(cstr, fNxEntry1->GetNotes().c_str(), sizeof(cstr));
if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'notes'.")) return NX_ERROR; if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXentry/notes'.")) return NX_ERROR;
NXclosedata(fFileHandle); NXclosedata(fFileHandle);
// write run 'analysis' // write run 'analysis'
size = fNxEntry1->GetAnalysis().length(); size = fNxEntry1->GetAnalysis().length();
if (!ErrorHandler(NXmakedata(fFileHandle, "analysis", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'analysis'.")) return NX_ERROR; if (!ErrorHandler(NXmakedata(fFileHandle, "analysis", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'NXentry/analysis'.")) return NX_ERROR;
if (!ErrorHandler(NXopendata(fFileHandle, "analysis"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'analysis' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "analysis"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'NXentry/analysis' for writting.")) return NX_ERROR;
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, fNxEntry1->GetAnalysis().c_str(), sizeof(cstr)); strncpy(cstr, fNxEntry1->GetAnalysis().c_str(), sizeof(cstr));
if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'analysis'.")) return NX_ERROR; if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXentry/analysis'.")) return NX_ERROR;
NXclosedata(fFileHandle); NXclosedata(fFileHandle);
// write run 'lab' // write run 'lab'
size = fNxEntry1->GetLaboratory().length(); size = fNxEntry1->GetLaboratory().length();
if (!ErrorHandler(NXmakedata(fFileHandle, "lab", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'lab'.")) return NX_ERROR; if (!ErrorHandler(NXmakedata(fFileHandle, "lab", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'NXentry/lab'.")) return NX_ERROR;
if (!ErrorHandler(NXopendata(fFileHandle, "lab"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'lab' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "lab"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'NXentry/lab' for writting.")) return NX_ERROR;
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, fNxEntry1->GetLaboratory().c_str(), sizeof(cstr)); strncpy(cstr, fNxEntry1->GetLaboratory().c_str(), sizeof(cstr));
if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'lab'.")) return NX_ERROR; if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXentry/lab'.")) return NX_ERROR;
NXclosedata(fFileHandle); NXclosedata(fFileHandle);
// write run 'beamline' // write run 'beamline'
size = fNxEntry1->GetBeamline().length(); size = fNxEntry1->GetBeamline().length();
if (!ErrorHandler(NXmakedata(fFileHandle, "beamline", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'beamline'.")) return NX_ERROR; if (!ErrorHandler(NXmakedata(fFileHandle, "beamline", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'NXentry/beamline'.")) return NX_ERROR;
if (!ErrorHandler(NXopendata(fFileHandle, "beamline"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'beamline' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "beamline"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'NXentry/beamline' for writting.")) return NX_ERROR;
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, fNxEntry1->GetBeamline().c_str(), sizeof(cstr)); strncpy(cstr, fNxEntry1->GetBeamline().c_str(), sizeof(cstr));
if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'beamline'.")) return NX_ERROR; if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXentry/beamline'.")) return NX_ERROR;
NXclosedata(fFileHandle); NXclosedata(fFileHandle);
// write run 'start_time' // write run 'start_time'
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, fNxEntry1->GetStartTime().c_str(), sizeof(cstr)); strncpy(cstr, fNxEntry1->GetStartTime().c_str(), sizeof(cstr));
size = strlen(cstr); size = strlen(cstr);
if (!ErrorHandler(NXmakedata(fFileHandle, "start_time", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'start_time'.")) return NX_ERROR; if (!ErrorHandler(NXmakedata(fFileHandle, "start_time", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'NXentry/start_time'.")) return NX_ERROR;
if (!ErrorHandler(NXopendata(fFileHandle, "start_time"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'start_time' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "start_time"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'NXentry/start_time' for writting.")) return NX_ERROR;
if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'start_time'.")) return NX_ERROR; if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXentry/start_time'.")) return NX_ERROR;
NXclosedata(fFileHandle); NXclosedata(fFileHandle);
// write run 'stop_time' // write run 'stop_time'
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, fNxEntry1->GetStopTime().c_str(), sizeof(cstr)); strncpy(cstr, fNxEntry1->GetStopTime().c_str(), sizeof(cstr));
size = strlen(cstr); size = strlen(cstr);
if (!ErrorHandler(NXmakedata(fFileHandle, "stop_time", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'stop_time'.")) return NX_ERROR; if (!ErrorHandler(NXmakedata(fFileHandle, "stop_time", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'NXentry/stop_time'.")) return NX_ERROR;
if (!ErrorHandler(NXopendata(fFileHandle, "stop_time"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'stop_time' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "stop_time"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'NXentry/stop_time' for writting.")) return NX_ERROR;
if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'stop_time'.")) return NX_ERROR; if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXentry/stop_time'.")) return NX_ERROR;
NXclosedata(fFileHandle); NXclosedata(fFileHandle);
// write run 'switching_states' // write run 'switching_states'
size = 1; size = 1;
if (!ErrorHandler(NXmakedata(fFileHandle, "switching_states", NX_INT32, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'switching_states'.")) return NX_ERROR; if (!ErrorHandler(NXmakedata(fFileHandle, "switching_states", NX_INT32, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'NXentry/switching_states'.")) return NX_ERROR;
if (!ErrorHandler(NXopendata(fFileHandle, "switching_states"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'switching_states' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "switching_states"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'NXentry/switching_states' for writting.")) return NX_ERROR;
idata = fNxEntry1->GetSwitchingState(); idata = fNxEntry1->GetSwitchingState();
if (!ErrorHandler(NXputdata(fFileHandle, &idata), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'switching_states'.")) return NX_ERROR; if (!ErrorHandler(NXputdata(fFileHandle, &idata), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXentry/switching_states'.")) return NX_ERROR;
NXclosedata(fFileHandle); NXclosedata(fFileHandle);
// make group 'user' // make group 'user'
if (!ErrorHandler(NXmakegroup(fFileHandle, "user", "NXuser"), PNEXUS_CREATE_GROUP_ERROR, "couldn't create group 'user'.")) return NX_ERROR; if (!ErrorHandler(NXmakegroup(fFileHandle, "user", "NXuser"), PNEXUS_CREATE_GROUP_ERROR, "couldn't create group 'NXuser/user'.")) return NX_ERROR;
// open group 'user' // open group 'user'
if (!ErrorHandler(NXopengroup(fFileHandle, "user", "NXuser"), PNEXUS_GROUP_OPEN_ERROR, "couldn't open group 'user' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopengroup(fFileHandle, "user", "NXuser"), PNEXUS_GROUP_OPEN_ERROR, "couldn't open group 'NXuser/user' for writting.")) return NX_ERROR;
// write user 'name' // write user 'name'
size = fNxEntry1->GetUser()->GetName().length(); size = fNxEntry1->GetUser()->GetName().length();
if (!ErrorHandler(NXmakedata(fFileHandle, "name", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'name'.")) return NX_ERROR; if (!ErrorHandler(NXmakedata(fFileHandle, "name", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'NXuser/name'.")) return NX_ERROR;
if (!ErrorHandler(NXopendata(fFileHandle, "name"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'name' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "name"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'NXuser/name' for writting.")) return NX_ERROR;
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, fNxEntry1->GetUser()->GetName().c_str(), sizeof(cstr)); strncpy(cstr, fNxEntry1->GetUser()->GetName().c_str(), sizeof(cstr));
if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'name'.")) return NX_ERROR; if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXuser/name'.")) return NX_ERROR;
NXclosedata(fFileHandle); NXclosedata(fFileHandle);
// write user 'experiment_number' // write user 'experiment_number'
size = fNxEntry1->GetUser()->GetExperimentNumber().length(); size = fNxEntry1->GetUser()->GetExperimentNumber().length();
if (!ErrorHandler(NXmakedata(fFileHandle, "experiment_number", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'experiment_number'.")) return NX_ERROR; if (!ErrorHandler(NXmakedata(fFileHandle, "experiment_number", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'NXuser/experiment_number'.")) return NX_ERROR;
if (!ErrorHandler(NXopendata(fFileHandle, "experiment_number"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'experiment_number' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "experiment_number"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'NXuser/experiment_number' for writting.")) return NX_ERROR;
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, fNxEntry1->GetUser()->GetExperimentNumber().c_str(), sizeof(cstr)); strncpy(cstr, fNxEntry1->GetUser()->GetExperimentNumber().c_str(), sizeof(cstr));
if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'experiment_number'.")) return NX_ERROR; if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXuser/experiment_number'.")) return NX_ERROR;
NXclosedata(fFileHandle); NXclosedata(fFileHandle);
// close group 'user' // close group 'user'
NXclosegroup(fFileHandle); NXclosegroup(fFileHandle);
// make group 'sample' // make group 'sample'
if (!ErrorHandler(NXmakegroup(fFileHandle, "sample", "NXsample"), PNEXUS_CREATE_GROUP_ERROR, "couldn't create group 'sample'.")) return NX_ERROR; if (!ErrorHandler(NXmakegroup(fFileHandle, "sample", "NXsample"), PNEXUS_CREATE_GROUP_ERROR, "couldn't create group 'NXsample/sample'.")) return NX_ERROR;
// open group 'sample' // open group 'sample'
if (!ErrorHandler(NXopengroup(fFileHandle, "sample", "NXsample"), PNEXUS_GROUP_OPEN_ERROR, "couldn't open group 'sample' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopengroup(fFileHandle, "sample", "NXsample"), PNEXUS_GROUP_OPEN_ERROR, "couldn't open group 'NXsample/sample' for writting.")) return NX_ERROR;
// write sample 'name' // write sample 'name'
size = fNxEntry1->GetSample()->GetName().length(); size = fNxEntry1->GetSample()->GetName().length();
if (!ErrorHandler(NXmakedata(fFileHandle, "name", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'name'.")) return NX_ERROR; if (!ErrorHandler(NXmakedata(fFileHandle, "name", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'NXsample/name'.")) return NX_ERROR;
if (!ErrorHandler(NXopendata(fFileHandle, "name"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'name' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "name"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'NXsample/name' for writting.")) return NX_ERROR;
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, fNxEntry1->GetSample()->GetName().c_str(), sizeof(cstr)); strncpy(cstr, fNxEntry1->GetSample()->GetName().c_str(), sizeof(cstr));
if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'name'.")) return NX_ERROR; if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXsample/name'.")) return NX_ERROR;
NXclosedata(fFileHandle); NXclosedata(fFileHandle);
// write sample 'temperature' // write sample 'temperature'
size = 1; size = 1;
if (!ErrorHandler(NXmakedata(fFileHandle, "temperature", NX_FLOAT32, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'temperature'.")) return NX_ERROR; if (!ErrorHandler(NXmakedata(fFileHandle, "temperature", NX_FLOAT32, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'NXsample/temperature'.")) return NX_ERROR;
if (!ErrorHandler(NXopendata(fFileHandle, "temperature"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'temperature' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "temperature"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'NXsample/temperature' for writting.")) return NX_ERROR;
fdata = (float)fNxEntry1->GetSample()->GetPhysPropValue(string("temperature"), ok); fdata = (float)fNxEntry1->GetSample()->GetPhysPropValue(string("temperature"), ok);
if (!ErrorHandler(NXputdata(fFileHandle, &fdata), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'temperature'.")) return NX_ERROR; if (!ErrorHandler(NXputdata(fFileHandle, &fdata), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXsample/temperature'.")) return NX_ERROR;
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
str = string("n/a"); str = string("n/a");
fNxEntry1->GetSample()->GetPhysPropUnit(string("temperature"), str, ok); fNxEntry1->GetSample()->GetPhysPropUnit(string("temperature"), str, ok);
strncpy(cstr, str.c_str(), sizeof(cstr)); strncpy(cstr, str.c_str(), sizeof(cstr));
if (!ErrorHandler(NXputattr(fFileHandle, "units", cstr, strlen(cstr), NX_CHAR), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'units' for 'temperature'")) return NX_ERROR; if (!ErrorHandler(NXputattr(fFileHandle, "units", cstr, strlen(cstr), NX_CHAR), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'units' for 'NXsample/temperature'")) return NX_ERROR;
NXclosedata(fFileHandle); NXclosedata(fFileHandle);
// write sample 'magnetic_field' // write sample 'magnetic_field'
size = 1; size = 1;
if (!ErrorHandler(NXmakedata(fFileHandle, "magnetic_field", NX_FLOAT32, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'magnetic_field'.")) return NX_ERROR; if (!ErrorHandler(NXmakedata(fFileHandle, "magnetic_field", NX_FLOAT32, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'NXsample/magnetic_field'.")) return NX_ERROR;
if (!ErrorHandler(NXopendata(fFileHandle, "magnetic_field"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'magnetic_field' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "magnetic_field"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'NXsample/magnetic_field' for writting.")) return NX_ERROR;
fdata = (float)fNxEntry1->GetSample()->GetPhysPropValue(string("magnetic_field"), ok); fdata = (float)fNxEntry1->GetSample()->GetPhysPropValue(string("magnetic_field"), ok);
if (!ErrorHandler(NXputdata(fFileHandle, &fdata), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'magnetic_field'.")) return NX_ERROR; if (!ErrorHandler(NXputdata(fFileHandle, &fdata), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXsample/magnetic_field'.")) return NX_ERROR;
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
str = string("n/a"); str = string("n/a");
fNxEntry1->GetSample()->GetPhysPropUnit(string("magnetic_field"), str, ok); fNxEntry1->GetSample()->GetPhysPropUnit(string("magnetic_field"), str, ok);
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, str.c_str(), sizeof(cstr)); strncpy(cstr, str.c_str(), sizeof(cstr));
if (!ErrorHandler(NXputattr(fFileHandle, "units", cstr, strlen(cstr), NX_CHAR), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'units' for 'magnetic_field'")) return NX_ERROR; if (!ErrorHandler(NXputattr(fFileHandle, "units", cstr, strlen(cstr), NX_CHAR), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'units' for 'NXsample/magnetic_field'")) return NX_ERROR;
NXclosedata(fFileHandle); NXclosedata(fFileHandle);
// write sample 'shape' // write sample 'shape'
size = fNxEntry1->GetSample()->GetShape().length(); size = fNxEntry1->GetSample()->GetShape().length();
if (!ErrorHandler(NXmakedata(fFileHandle, "shape", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'shape'.")) return NX_ERROR; 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 'shape' for writting.")) 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)); strncpy(cstr, fNxEntry1->GetSample()->GetShape().c_str(), sizeof(cstr));
if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'shape'.")) return NX_ERROR; if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXsample/shape'.")) return NX_ERROR;
NXclosedata(fFileHandle); NXclosedata(fFileHandle);
// write sample 'magnetic_field_state' // write sample 'magnetic_field_state'
size = fNxEntry1->GetSample()->GetMagneticFieldState().length(); size = fNxEntry1->GetSample()->GetMagneticFieldState().length();
if (!ErrorHandler(NXmakedata(fFileHandle, "magnetic_field_state", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'magnetic_field_state'.")) return NX_ERROR; if (!ErrorHandler(NXmakedata(fFileHandle, "magnetic_field_state", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'NXsample/magnetic_field_state'.")) return NX_ERROR;
if (!ErrorHandler(NXopendata(fFileHandle, "magnetic_field_state"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'magnetic_field_state' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "magnetic_field_state"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'NXsample/magnetic_field_state' for writting.")) return NX_ERROR;
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, fNxEntry1->GetSample()->GetMagneticFieldState().c_str(), sizeof(cstr)); strncpy(cstr, fNxEntry1->GetSample()->GetMagneticFieldState().c_str(), sizeof(cstr));
if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'magnetic_field_state'.")) return NX_ERROR; if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXsample/magnetic_field_state'.")) return NX_ERROR;
NXclosedata(fFileHandle); NXclosedata(fFileHandle);
// write sample 'magnetic_field_vector' // write sample 'magnetic_field_vector'
@ -4222,16 +4238,16 @@ int PNeXus::WriteFileIdf1(const char* fileName, const NXaccess access)
for (int i=0; i<size; i++) for (int i=0; i<size; i++)
magFieldVec[i] = 0.0; magFieldVec[i] = 0.0;
} }
if (!ErrorHandler(NXmakedata(fFileHandle, "magnetic_field_vector", NX_FLOAT32, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'magnetic_field_vector'.")) return NX_ERROR; if (!ErrorHandler(NXmakedata(fFileHandle, "magnetic_field_vector", NX_FLOAT32, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'NXsample/magnetic_field_vector'.")) return NX_ERROR;
if (!ErrorHandler(NXopendata(fFileHandle, "magnetic_field_vector"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'magnetic_field_vector' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "magnetic_field_vector"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'NXsample/magnetic_field_vector' for writting.")) return NX_ERROR;
if (!ErrorHandler(NXputdata(fFileHandle, magFieldVec), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'magnetic_field_vector'.")) return NX_ERROR; if (!ErrorHandler(NXputdata(fFileHandle, magFieldVec), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXsample/magnetic_field_vector'.")) return NX_ERROR;
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, fNxEntry1->GetSample()->GetMagneticFieldVectorCoordinateSystem().c_str(), sizeof(cstr)); strncpy(cstr, fNxEntry1->GetSample()->GetMagneticFieldVectorCoordinateSystem().c_str(), sizeof(cstr));
if (!ErrorHandler(NXputattr(fFileHandle, "coordinate_system", cstr, strlen(cstr), NX_CHAR), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'coordinate_system' for 'magnetic_field_vector'")) return NX_ERROR; if (!ErrorHandler(NXputattr(fFileHandle, "coordinate_system", cstr, strlen(cstr), NX_CHAR), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'coordinate_system' for 'NXsample/magnetic_field_vector'")) return NX_ERROR;
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, fNxEntry1->GetSample()->GetMagneticFieldVectorUnits().c_str(), sizeof(cstr)); strncpy(cstr, fNxEntry1->GetSample()->GetMagneticFieldVectorUnits().c_str(), sizeof(cstr));
if (!ErrorHandler(NXputattr(fFileHandle, "units", cstr, strlen(cstr), NX_CHAR), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'units' for 'magnetic_field_vector'")) return NX_ERROR; if (!ErrorHandler(NXputattr(fFileHandle, "units", cstr, strlen(cstr), NX_CHAR), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'units' for 'NXsample/magnetic_field_vector'")) return NX_ERROR;
if (!ErrorHandler(NXputattr(fFileHandle, "available", &idata, 1, NX_INT32), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'available' for 'magnetic_field_vector'")) return NX_ERROR; if (!ErrorHandler(NXputattr(fFileHandle, "available", &idata, 1, NX_INT32), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'available' for 'NXsample/magnetic_field_vector'")) return NX_ERROR;
NXclosedata(fFileHandle); NXclosedata(fFileHandle);
if (magFieldVec) { if (magFieldVec) {
delete [] magFieldVec; delete [] magFieldVec;
@ -4240,76 +4256,76 @@ int PNeXus::WriteFileIdf1(const char* fileName, const NXaccess access)
// write sample 'environment' // write sample 'environment'
size = fNxEntry1->GetSample()->GetEnvironment().length(); size = fNxEntry1->GetSample()->GetEnvironment().length();
if (!ErrorHandler(NXmakedata(fFileHandle, "environment", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'environment'.")) return NX_ERROR; if (!ErrorHandler(NXmakedata(fFileHandle, "environment", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'NXsample/environment'.")) return NX_ERROR;
if (!ErrorHandler(NXopendata(fFileHandle, "environment"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'environment' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "environment"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'NXsample/environment' for writting.")) return NX_ERROR;
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, fNxEntry1->GetSample()->GetEnvironment().c_str(), sizeof(cstr)); strncpy(cstr, fNxEntry1->GetSample()->GetEnvironment().c_str(), sizeof(cstr));
if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'environment'.")) return NX_ERROR; if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXsample/environment'.")) return NX_ERROR;
NXclosedata(fFileHandle); NXclosedata(fFileHandle);
// close group 'sample' // close group 'sample'
NXclosegroup(fFileHandle); NXclosegroup(fFileHandle);
// make group 'instrument' // make group 'instrument'
if (!ErrorHandler(NXmakegroup(fFileHandle, "instrument", "NXinstrument"), PNEXUS_CREATE_GROUP_ERROR, "couldn't create group 'instrument'.")) return NX_ERROR; if (!ErrorHandler(NXmakegroup(fFileHandle, "instrument", "NXinstrument"), PNEXUS_CREATE_GROUP_ERROR, "couldn't create group 'NXinstrument/instrument'.")) return NX_ERROR;
// open group 'instrument' // open group 'instrument'
if (!ErrorHandler(NXopengroup(fFileHandle, "instrument", "NXinstrument"), PNEXUS_GROUP_OPEN_ERROR, "couldn't open group 'instrument' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopengroup(fFileHandle, "instrument", "NXinstrument"), PNEXUS_GROUP_OPEN_ERROR, "couldn't open group 'NXinstrument/instrument' for writting.")) return NX_ERROR;
// write instrument 'name' // write instrument 'name'
size = fNxEntry1->GetInstrument()->GetName().length(); size = fNxEntry1->GetInstrument()->GetName().length();
if (!ErrorHandler(NXmakedata(fFileHandle, "name", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'name'.")) return NX_ERROR; if (!ErrorHandler(NXmakedata(fFileHandle, "name", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'NXinstrument/name'.")) return NX_ERROR;
if (!ErrorHandler(NXopendata(fFileHandle, "name"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'name' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "name"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'NXinstrument/name' for writting.")) return NX_ERROR;
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, fNxEntry1->GetInstrument()->GetName().c_str(), sizeof(cstr)); strncpy(cstr, fNxEntry1->GetInstrument()->GetName().c_str(), sizeof(cstr));
if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'name'.")) return NX_ERROR; if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXinstrument/name'.")) return NX_ERROR;
NXclosedata(fFileHandle); NXclosedata(fFileHandle);
// make group 'detector' // make group 'detector'
if (!ErrorHandler(NXmakegroup(fFileHandle, "detector", "NXdetector"), PNEXUS_CREATE_GROUP_ERROR, "couldn't create group 'detector'.")) return NX_ERROR; if (!ErrorHandler(NXmakegroup(fFileHandle, "detector", "NXdetector"), PNEXUS_CREATE_GROUP_ERROR, "couldn't create group 'NXdetector/detector'.")) return NX_ERROR;
// open group 'detector' // open group 'detector'
if (!ErrorHandler(NXopengroup(fFileHandle, "detector", "NXdetector"), PNEXUS_GROUP_OPEN_ERROR, "couldn't open group 'detector' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopengroup(fFileHandle, "detector", "NXdetector"), PNEXUS_GROUP_OPEN_ERROR, "couldn't open group 'NXdetector/detector' for writting.")) return NX_ERROR;
// write detector 'number' // write detector 'number'
size = 1; size = 1;
if (!ErrorHandler(NXmakedata(fFileHandle, "number", NX_INT32, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'number'.")) return NX_ERROR; if (!ErrorHandler(NXmakedata(fFileHandle, "number", NX_INT32, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'NXdetector/number'.")) return NX_ERROR;
if (!ErrorHandler(NXopendata(fFileHandle, "number"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'number' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "number"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'NXdetector/number' for writting.")) return NX_ERROR;
idata = fNxEntry1->GetInstrument()->GetDetector()->GetNumber(); idata = fNxEntry1->GetInstrument()->GetDetector()->GetNumber();
if (!ErrorHandler(NXputdata(fFileHandle, &idata), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'number'.")) return NX_ERROR; if (!ErrorHandler(NXputdata(fFileHandle, &idata), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXdetector/number'.")) return NX_ERROR;
NXclosedata(fFileHandle); NXclosedata(fFileHandle);
// close group 'detector' // close group 'detector'
NXclosegroup(fFileHandle); NXclosegroup(fFileHandle);
// make group 'collimator' // make group 'collimator'
if (!ErrorHandler(NXmakegroup(fFileHandle, "collimator", "NXcollimator"), PNEXUS_CREATE_GROUP_ERROR, "couldn't create group 'collimator'.")) return NX_ERROR; if (!ErrorHandler(NXmakegroup(fFileHandle, "collimator", "NXcollimator"), PNEXUS_CREATE_GROUP_ERROR, "couldn't create group 'NXcollimator/collimator'.")) return NX_ERROR;
// open group 'collimator' // open group 'collimator'
if (!ErrorHandler(NXopengroup(fFileHandle, "collimator", "NXcollimator"), PNEXUS_GROUP_OPEN_ERROR, "couldn't open group 'collimator' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopengroup(fFileHandle, "collimator", "NXcollimator"), PNEXUS_GROUP_OPEN_ERROR, "couldn't open group 'NXcollimator/collimator' for writting.")) return NX_ERROR;
// write collimator 'type' // write collimator 'type'
size = fNxEntry1->GetInstrument()->GetCollimator()->GetType().length(); size = fNxEntry1->GetInstrument()->GetCollimator()->GetType().length();
if (!ErrorHandler(NXmakedata(fFileHandle, "type", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'type'.")) return NX_ERROR; if (!ErrorHandler(NXmakedata(fFileHandle, "type", NX_CHAR, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'NXcollimator/type'.")) return NX_ERROR;
if (!ErrorHandler(NXopendata(fFileHandle, "type"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'type' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "type"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'NXcollimator/type' for writting.")) return NX_ERROR;
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, fNxEntry1->GetInstrument()->GetCollimator()->GetType().c_str(), sizeof(cstr)); strncpy(cstr, fNxEntry1->GetInstrument()->GetCollimator()->GetType().c_str(), sizeof(cstr));
if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'type'.")) return NX_ERROR; if (!ErrorHandler(NXputdata(fFileHandle, cstr), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXcollimator/type'.")) return NX_ERROR;
NXclosedata(fFileHandle); NXclosedata(fFileHandle);
// close group 'collimator' // close group 'collimator'
NXclosegroup(fFileHandle); NXclosegroup(fFileHandle);
// make group 'beam' // make group 'beam'
if (!ErrorHandler(NXmakegroup(fFileHandle, "beam", "NXbeam"), PNEXUS_CREATE_GROUP_ERROR, "couldn't create group 'beam'.")) return NX_ERROR; if (!ErrorHandler(NXmakegroup(fFileHandle, "beam", "NXbeam"), PNEXUS_CREATE_GROUP_ERROR, "couldn't create group 'NXbeam/beam'.")) return NX_ERROR;
// open group 'beam' // open group 'beam'
if (!ErrorHandler(NXopengroup(fFileHandle, "beam", "NXbeam"), PNEXUS_GROUP_OPEN_ERROR, "couldn't open group 'beam' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopengroup(fFileHandle, "beam", "NXbeam"), PNEXUS_GROUP_OPEN_ERROR, "couldn't open group 'NXbeam/beam' for writting.")) return NX_ERROR;
size = 1; size = 1;
if (!ErrorHandler(NXmakedata(fFileHandle, "total_counts", NX_FLOAT32, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'total_counts'.")) return NX_ERROR; if (!ErrorHandler(NXmakedata(fFileHandle, "total_counts", NX_FLOAT32, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'NXbeam/total_counts'.")) return NX_ERROR;
if (!ErrorHandler(NXopendata(fFileHandle, "total_counts"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'total_counts' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "total_counts"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'NXbeam/total_counts' for writting.")) return NX_ERROR;
fdata = (float)fNxEntry1->GetInstrument()->GetBeam()->GetTotalCounts(); fdata = (float)fNxEntry1->GetInstrument()->GetBeam()->GetTotalCounts();
if (!ErrorHandler(NXputdata(fFileHandle, &fdata), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'total_counts'.")) return NX_ERROR; if (!ErrorHandler(NXputdata(fFileHandle, &fdata), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXbeam/total_counts'.")) return NX_ERROR;
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, fNxEntry1->GetInstrument()->GetBeam()->GetUnits().c_str(), sizeof(cstr)); strncpy(cstr, fNxEntry1->GetInstrument()->GetBeam()->GetUnits().c_str(), sizeof(cstr));
if (!ErrorHandler(NXputattr(fFileHandle, "units", cstr, strlen(cstr), NX_CHAR), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'units' for 'total_counts'")) return NX_ERROR; if (!ErrorHandler(NXputattr(fFileHandle, "units", cstr, strlen(cstr), NX_CHAR), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'units' for 'NXbeam/total_counts'")) return NX_ERROR;
NXclosedata(fFileHandle); NXclosedata(fFileHandle);
// close group 'beam' // close group 'beam'
@ -4319,9 +4335,9 @@ int PNeXus::WriteFileIdf1(const char* fileName, const NXaccess access)
NXclosegroup(fFileHandle); NXclosegroup(fFileHandle);
// make group 'histogram_data_1' // make group 'histogram_data_1'
if (!ErrorHandler(NXmakegroup(fFileHandle, "histogram_data_1", "NXdata"), PNEXUS_CREATE_GROUP_ERROR, "couldn't create group 'histogram_data_1'.")) return NX_ERROR; if (!ErrorHandler(NXmakegroup(fFileHandle, "histogram_data_1", "NXdata"), PNEXUS_CREATE_GROUP_ERROR, "couldn't create group 'NXdata/histogram_data_1'.")) return NX_ERROR;
// open group 'histogram_data_1' // open group 'histogram_data_1'
if (!ErrorHandler(NXopengroup(fFileHandle, "histogram_data_1", "NXdata"), PNEXUS_GROUP_OPEN_ERROR, "couldn't open group 'histogram_data_1' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopengroup(fFileHandle, "histogram_data_1", "NXdata"), PNEXUS_GROUP_OPEN_ERROR, "couldn't open group 'NXdata/histogram_data_1' for writting.")) return NX_ERROR;
// write data 'counts' // write data 'counts'
int *histo_data=0; int *histo_data=0;
@ -4342,26 +4358,26 @@ int PNeXus::WriteFileIdf1(const char* fileName, const NXaccess access)
histo_size[1] = histoLength; histo_size[1] = histoLength;
} }
if (!ErrorHandler(NXcompmakedata(fFileHandle, "counts", NX_INT32, 2, histo_size, NX_COMP_LZW, histo_size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'counts'.")) return NX_ERROR; if (!ErrorHandler(NXcompmakedata(fFileHandle, "counts", NX_INT32, 2, histo_size, NX_COMP_LZW, histo_size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'NXdata/counts'.")) return NX_ERROR;
if (!ErrorHandler(NXopendata(fFileHandle, "counts"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'counts' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "counts"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'NXdata/counts' for writting.")) return NX_ERROR;
if (!ErrorHandler(NXputdata(fFileHandle, (void*)histo_data), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'counts'.")) return NX_ERROR; if (!ErrorHandler(NXputdata(fFileHandle, (void*)histo_data), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXdata/counts'.")) return NX_ERROR;
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, "counts", sizeof(cstr)); strncpy(cstr, "counts", sizeof(cstr));
if (!ErrorHandler(NXputattr(fFileHandle, "units", cstr, strlen(cstr), NX_CHAR), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'units' for 'counts'")) return NX_ERROR; if (!ErrorHandler(NXputattr(fFileHandle, "units", cstr, strlen(cstr), NX_CHAR), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'units' for 'NXdata/counts'")) return NX_ERROR;
idata = 1; idata = 1;
if (!ErrorHandler(NXputattr(fFileHandle, "signal", &idata, 1, NX_INT32), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'signal' for 'counts'")) return NX_ERROR; if (!ErrorHandler(NXputattr(fFileHandle, "signal", &idata, 1, NX_INT32), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'signal' for 'NXdata/counts'")) return NX_ERROR;
idata = fNxEntry1->GetData()->GetNoOfHistos(); idata = fNxEntry1->GetData()->GetNoOfHistos();
if (!ErrorHandler(NXputattr(fFileHandle, "number", &idata, 1, NX_INT32), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'number' for 'counts'")) return NX_ERROR; if (!ErrorHandler(NXputattr(fFileHandle, "number", &idata, 1, NX_INT32), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'number' for 'NXdata/counts'")) return NX_ERROR;
idata = fNxEntry1->GetData()->GetHistoLength(); idata = fNxEntry1->GetData()->GetHistoLength();
if (!ErrorHandler(NXputattr(fFileHandle, "length", &idata, 1, NX_INT32), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'length' for 'counts'")) return NX_ERROR; if (!ErrorHandler(NXputattr(fFileHandle, "length", &idata, 1, NX_INT32), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'length' for 'NXdata/counts'")) return NX_ERROR;
idata = fNxEntry1->GetData()->GetT0(0); idata = fNxEntry1->GetData()->GetT0(0);
if (!ErrorHandler(NXputattr(fFileHandle, "T0_bin", &idata, 1, NX_INT32), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'T0_bin' for 'counts'")) return NX_ERROR; if (!ErrorHandler(NXputattr(fFileHandle, "t0_bin", &idata, 1, NX_INT32), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'T0_bin' for 'NXdata/counts'")) return NX_ERROR;
idata = fNxEntry1->GetData()->GetFirstGoodBin(0); idata = fNxEntry1->GetData()->GetFirstGoodBin(0);
if (!ErrorHandler(NXputattr(fFileHandle, "first_good_bin", &idata, 1, NX_INT32), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'first_good_bin' for 'counts'")) return NX_ERROR; if (!ErrorHandler(NXputattr(fFileHandle, "first_good_bin", &idata, 1, NX_INT32), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'first_good_bin' for 'NXdata/counts'")) return NX_ERROR;
idata = fNxEntry1->GetData()->GetLastGoodBin(0); idata = fNxEntry1->GetData()->GetLastGoodBin(0);
if (!ErrorHandler(NXputattr(fFileHandle, "last_good_bin", &idata, 1, NX_INT32), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'last_good_bin' for 'counts'")) return NX_ERROR; if (!ErrorHandler(NXputattr(fFileHandle, "last_good_bin", &idata, 1, NX_INT32), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'last_good_bin' for 'NXdata/counts'")) return NX_ERROR;
fdata = (float)fNxEntry1->GetData()->GetTimeResolution("ps")/2.0; fdata = (float)fNxEntry1->GetData()->GetTimeResolution("ps")/2.0;
if (!ErrorHandler(NXputattr(fFileHandle, "offset", &fdata, 1, NX_FLOAT32), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'offset' for 'counts'")) return NX_ERROR; if (!ErrorHandler(NXputattr(fFileHandle, "offset", &fdata, 1, NX_FLOAT32), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'offset' for 'NXdata/counts'")) return NX_ERROR;
NXclosedata(fFileHandle); NXclosedata(fFileHandle);
if (histo_data) { if (histo_data) {
@ -4370,27 +4386,27 @@ int PNeXus::WriteFileIdf1(const char* fileName, const NXaccess access)
// write data 'resolution' // write data 'resolution'
size = 1; size = 1;
if (!ErrorHandler(NXmakedata(fFileHandle, "resolution", NX_INT32, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'resolution'.")) return NX_ERROR; if (!ErrorHandler(NXmakedata(fFileHandle, "resolution", NX_INT32, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'NXdata/resolution'.")) return NX_ERROR;
if (!ErrorHandler(NXopendata(fFileHandle, "resolution"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'resolution' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "resolution"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'NXdata/resolution' for writting.")) return NX_ERROR;
fdata = fNxEntry1->GetData()->GetTimeResolution("fs"); fdata = fNxEntry1->GetData()->GetTimeResolution("fs");
idata = (int)fdata; idata = (int)fdata;
if (!ErrorHandler(NXputdata(fFileHandle, &idata), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'resolution'.")) return NX_ERROR; if (!ErrorHandler(NXputdata(fFileHandle, &idata), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXdata/resolution'.")) return NX_ERROR;
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, "femtoseconds", sizeof(cstr)); strncpy(cstr, "femtoseconds", sizeof(cstr));
if (!ErrorHandler(NXputattr(fFileHandle, "units", cstr, strlen(cstr), NX_CHAR), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'units' for 'resolution'")) return NX_ERROR; if (!ErrorHandler(NXputattr(fFileHandle, "units", cstr, strlen(cstr), NX_CHAR), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'units' for 'NXdata/resolution'")) return NX_ERROR;
NXclosedata(fFileHandle); NXclosedata(fFileHandle);
// write data 'time_zero' always set to 0 since the T0_bin attribute of counts is relevant only // write data 'time_zero' based on t0_bin which is the master!
size = 1; size = 1;
if (!ErrorHandler(NXmakedata(fFileHandle, "time_zero", NX_FLOAT32, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'time_zero'.")) return NX_ERROR; if (!ErrorHandler(NXmakedata(fFileHandle, "time_zero", NX_FLOAT32, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'NXdata/time_zero'.")) return NX_ERROR;
if (!ErrorHandler(NXopendata(fFileHandle, "time_zero"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'time_zero' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "time_zero"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'NXdata/time_zero' for writting.")) return NX_ERROR;
fdata = 0.0; fdata = (float)fNxEntry1->GetData()->GetT0(0) * (float)fNxEntry1->GetData()->GetTimeResolution("us");
if (!ErrorHandler(NXputdata(fFileHandle, &fdata), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'time_zero'.")) return NX_ERROR; if (!ErrorHandler(NXputdata(fFileHandle, &fdata), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXdata/time_zero'.")) return NX_ERROR;
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, "microseconds", sizeof(cstr)); strncpy(cstr, "microseconds", sizeof(cstr));
if (!ErrorHandler(NXputattr(fFileHandle, "units", cstr, strlen(cstr), NX_CHAR), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'units' for 'time_zero'")) return NX_ERROR; if (!ErrorHandler(NXputattr(fFileHandle, "units", cstr, strlen(cstr), NX_CHAR), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'units' for 'NXdata/time_zero'")) return NX_ERROR;
idata = 0; idata = 1;
if (!ErrorHandler(NXputattr(fFileHandle, "available", &idata, 1, NX_INT32), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'available' for 'time_zero'")) return NX_ERROR; if (!ErrorHandler(NXputattr(fFileHandle, "available", &idata, 1, NX_INT32), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'available' for 'NXdata/time_zero'")) return NX_ERROR;
NXclosedata(fFileHandle); NXclosedata(fFileHandle);
// write data 'raw_time' // write data 'raw_time'
@ -4406,16 +4422,16 @@ int PNeXus::WriteFileIdf1(const char* fileName, const NXaccess access)
raw_time[i] = (float)fNxEntry1->GetData()->GetTimeResolution("us") * (float)i; // raw time in (us) raw_time[i] = (float)fNxEntry1->GetData()->GetTimeResolution("us") * (float)i; // raw time in (us)
} }
size = histoLength; size = histoLength;
if (!ErrorHandler(NXmakedata(fFileHandle, "raw_time", NX_FLOAT32, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'raw_time'.")) return NX_ERROR; if (!ErrorHandler(NXmakedata(fFileHandle, "raw_time", NX_FLOAT32, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'NXdata/raw_time'.")) return NX_ERROR;
if (!ErrorHandler(NXopendata(fFileHandle, "raw_time"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'raw_time' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "raw_time"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'NXdata/raw_time' for writting.")) return NX_ERROR;
if (!ErrorHandler(NXputdata(fFileHandle, raw_time), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'raw_time'.")) return NX_ERROR; if (!ErrorHandler(NXputdata(fFileHandle, raw_time), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXdata/raw_time'.")) return NX_ERROR;
idata = 1; idata = 1;
if (!ErrorHandler(NXputattr(fFileHandle, "axis", &idata, 1, NX_INT32), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'axis' for 'raw_time'")) return NX_ERROR; if (!ErrorHandler(NXputattr(fFileHandle, "axis", &idata, 1, NX_INT32), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'axis' for 'NXdata/raw_time'")) return NX_ERROR;
idata = 1; idata = 1;
if (!ErrorHandler(NXputattr(fFileHandle, "primary", &idata, 1, NX_INT32), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'primary' for 'raw_time'")) return NX_ERROR; if (!ErrorHandler(NXputattr(fFileHandle, "primary", &idata, 1, NX_INT32), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'primary' for 'NXdata/raw_time'")) return NX_ERROR;
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, "microseconds", sizeof(cstr)); strncpy(cstr, "microseconds", sizeof(cstr));
if (!ErrorHandler(NXputattr(fFileHandle, "units", cstr, strlen(cstr), NX_CHAR), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'units' for 'raw_time'")) return NX_ERROR; if (!ErrorHandler(NXputattr(fFileHandle, "units", cstr, strlen(cstr), NX_CHAR), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'units' for 'NXdata/raw_time'")) return NX_ERROR;
NXclosedata(fFileHandle); NXclosedata(fFileHandle);
if (raw_time) { if (raw_time) {
delete [] raw_time; delete [] raw_time;
@ -4428,14 +4444,14 @@ int PNeXus::WriteFileIdf1(const char* fileName, const NXaccess access)
corrected_time[i] = (float)fNxEntry1->GetData()->GetTimeResolution("us") * (float)((int)i-(int)fNxEntry1->GetData()->GetT0(0)+1); // raw time in (us) corrected_time[i] = (float)fNxEntry1->GetData()->GetTimeResolution("us") * (float)((int)i-(int)fNxEntry1->GetData()->GetT0(0)+1); // raw time in (us)
} }
size = histoLength; size = histoLength;
if (!ErrorHandler(NXmakedata(fFileHandle, "corrected_time", NX_FLOAT32, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'corrected_time'.")) return NX_ERROR; if (!ErrorHandler(NXmakedata(fFileHandle, "corrected_time", NX_FLOAT32, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'NXdata/corrected_time'.")) return NX_ERROR;
if (!ErrorHandler(NXopendata(fFileHandle, "corrected_time"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'corrected_time' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "corrected_time"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'NXdata/corrected_time' for writting.")) return NX_ERROR;
if (!ErrorHandler(NXputdata(fFileHandle, corrected_time), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'corrected_time'.")) return NX_ERROR; if (!ErrorHandler(NXputdata(fFileHandle, corrected_time), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXdata/corrected_time'.")) return NX_ERROR;
idata = 1; idata = 1;
if (!ErrorHandler(NXputattr(fFileHandle, "axis", &idata, 1, NX_INT32), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'axis' for 'corrected_time'")) return NX_ERROR; if (!ErrorHandler(NXputattr(fFileHandle, "axis", &idata, 1, NX_INT32), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'axis' for 'NXdata/corrected_time'")) return NX_ERROR;
memset(cstr, '\0', sizeof(cstr)); memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, "microseconds", sizeof(cstr)); strncpy(cstr, "microseconds", sizeof(cstr));
if (!ErrorHandler(NXputattr(fFileHandle, "units", cstr, strlen(cstr), NX_CHAR), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'units' for 'corrected_time'")) return NX_ERROR; if (!ErrorHandler(NXputattr(fFileHandle, "units", cstr, strlen(cstr), NX_CHAR), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'units' for 'NXdata/corrected_time'")) return NX_ERROR;
NXclosedata(fFileHandle); NXclosedata(fFileHandle);
if (corrected_time) { if (corrected_time) {
delete [] corrected_time; delete [] corrected_time;
@ -4467,11 +4483,11 @@ int PNeXus::WriteFileIdf1(const char* fileName, const NXaccess access)
} }
} }
size = noOfHistos; size = noOfHistos;
if (!ErrorHandler(NXmakedata(fFileHandle, "grouping", NX_INT32, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'grouping'.")) return NX_ERROR; if (!ErrorHandler(NXmakedata(fFileHandle, "grouping", NX_INT32, 1, &size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'NXdata/grouping'.")) return NX_ERROR;
if (!ErrorHandler(NXopendata(fFileHandle, "grouping"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'grouping' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "grouping"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'NXdata/grouping' for writting.")) return NX_ERROR;
if (!ErrorHandler(NXputdata(fFileHandle, grouping), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'grouping'.")) return NX_ERROR; if (!ErrorHandler(NXputdata(fFileHandle, grouping), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXdata/grouping'.")) return NX_ERROR;
idata = groupNo.size(); idata = groupNo.size();
if (!ErrorHandler(NXputattr(fFileHandle, "available", &idata, 1, NX_INT32), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'available' for 'grouping'")) return NX_ERROR; if (!ErrorHandler(NXputattr(fFileHandle, "available", &idata, 1, NX_INT32), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'available' for 'NXdata/grouping'")) return NX_ERROR;
NXclosedata(fFileHandle); NXclosedata(fFileHandle);
if (grouping) { if (grouping) {
delete [] grouping; delete [] grouping;
@ -4499,11 +4515,11 @@ int PNeXus::WriteFileIdf1(const char* fileName, const NXaccess access)
array_size[0] = fNxEntry1->GetData()->GetAlpha()->size(); array_size[0] = fNxEntry1->GetData()->GetAlpha()->size();
array_size[1] = 3; array_size[1] = 3;
} }
if (!ErrorHandler(NXmakedata(fFileHandle, "alpha", NX_FLOAT32, 2, array_size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'alpha'.")) return NX_ERROR; if (!ErrorHandler(NXmakedata(fFileHandle, "alpha", NX_FLOAT32, 2, array_size), PNEXUS_MAKE_DATA_ERROR, "couldn't create data entry 'NXdata/alpha'.")) return NX_ERROR;
if (!ErrorHandler(NXopendata(fFileHandle, "alpha"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'alpha' for writting.")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "alpha"), PNEXUS_OPEN_DATA_ERROR, "couldn't open data 'NXdata/alpha' for writting.")) return NX_ERROR;
if (!ErrorHandler(NXputdata(fFileHandle, (void*)alpha), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'alpha'.")) return NX_ERROR; if (!ErrorHandler(NXputdata(fFileHandle, (void*)alpha), PNEXUS_PUT_DATA_ERROR, "couldn't put data 'NXdata/alpha'.")) return NX_ERROR;
idata = fNxEntry1->GetData()->GetAlpha()->size(); idata = fNxEntry1->GetData()->GetAlpha()->size();
if (!ErrorHandler(NXputattr(fFileHandle, "available", &idata, 1, NX_INT32), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'available' for 'alpha'")) return NX_ERROR; if (!ErrorHandler(NXputattr(fFileHandle, "available", &idata, 1, NX_INT32), PNEXUS_PUT_ATTR_ERROR, "couldn't put attribute 'available' for 'NXdata/alpha'")) return NX_ERROR;
if (alpha) { if (alpha) {
delete [] alpha; delete [] alpha;
} }

View File

@ -275,6 +275,9 @@ class PRawRunData {
PRawRunData(); PRawRunData();
virtual ~PRawRunData(); virtual ~PRawRunData();
virtual const TString* GetLaboratory() { return &fLaboratory; }
virtual const TString* GetBeamline() { return &fBeamline; }
virtual const TString* GetInstrument() { return &fInstrument; }
virtual const TString* GetRunName() { return &fRunName; } virtual const TString* GetRunName() { return &fRunName; }
virtual const Int_t GetRunNumber() { return fRunNumber; } virtual const Int_t GetRunNumber() { return fRunNumber; }
virtual const TString* GetRunTitle() { return &fRunTitle; } virtual const TString* GetRunTitle() { return &fRunTitle; }
@ -307,6 +310,9 @@ class PRawRunData {
virtual const PDoubleVector* GetDataBin(const UInt_t idx); virtual const PDoubleVector* GetDataBin(const UInt_t idx);
virtual const PNonMusrRawRunData* GetDataNonMusr() { return &fDataNonMusr; } virtual const PNonMusrRawRunData* GetDataNonMusr() { return &fDataNonMusr; }
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 SetRunName(const TString &str) { fRunName = str; } virtual void SetRunName(const TString &str) { fRunName = str; }
virtual void SetRunNumber(const Int_t &val) { fRunNumber = val; } virtual void SetRunNumber(const Int_t &val) { fRunNumber = val; }
virtual void SetRunTitle(const TString str) { fRunTitle = str; } virtual void SetRunTitle(const TString str) { fRunTitle = str; }
@ -338,6 +344,9 @@ class PRawRunData {
PNonMusrRawRunData fDataNonMusr; ///< keeps all ascii- or db-file info in case of nonMusr fit PNonMusrRawRunData fDataNonMusr; ///< keeps all ascii- or db-file info in case of nonMusr fit
private: private:
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 fRunName; ///< name of the run TString fRunName; ///< name of the run
Int_t fRunNumber; ///< run number Int_t fRunNumber; ///< run number
TString fRunTitle; ///< run title TString fRunTitle; ///< run title
@ -355,7 +364,7 @@ class PRawRunData {
Double_t fEnergy; ///< implantation energy of the muon Double_t fEnergy; ///< implantation energy of the muon
Double_t fTransport; ///< LEM transport settings (Moderator HV) Double_t fTransport; ///< LEM transport settings (Moderator HV)
PDoubleVector fRingAnode; ///< LEM ring anode HVs (L,R[,T,B]) PDoubleVector fRingAnode; ///< LEM ring anode HVs (L,R[,T,B])
Double_t fTimeResolution; ///< time resolution of the run Double_t fTimeResolution; ///< time resolution of the run in (ns)
PIntVector fT0s; ///< vector of t0's of a run PIntVector fT0s; ///< vector of t0's of a run
PIntVector fT0Estimated; ///< vector of t0's estimated based on the maximum of the histogram PIntVector fT0Estimated; ///< vector of t0's estimated based on the maximum of the histogram
PIntPairVector fBkgBin; ///< background bins (first/last) PIntPairVector fBkgBin; ///< background bins (first/last)
@ -607,6 +616,7 @@ typedef struct {
TString year; ///< holds the information about the year to be used TString year; ///< holds the information about the year to be used
PIntVector runList; ///< holds the run number list to be converted PIntVector runList; ///< holds the run number list to be converted
PStringVector inFileName; ///< holds the file name of the input data file PStringVector inFileName; ///< holds the file name of the input data file
TString outFileName; ///< holds the output file name
PStringVector outPathFileName; ///< holds the out path/file name PStringVector outPathFileName; ///< holds the out path/file name
TString outPath; ///< holds the output path TString outPath; ///< holds the output path
UInt_t rebin; ///< holds the number of bins to be packed UInt_t rebin; ///< holds the number of bins to be packed