added NeXus support. Still a lot of testing will be needed, documentation updated, etc.
This commit is contained in:
@ -66,7 +66,7 @@ dict_cpp_sources = \
|
||||
include_HEADERS = $(h_sources)
|
||||
noinst_HEADERS = $(h_linkdef) $(dict_h_sources)
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/src/include $(PSIBIN_CFLAGS) $(MUD_CFLAGS) $(LEM_CFLAGS) $(FFTW3_CFLAGS) $(GSL_CFLAGS) $(BOOST_CFLAGS) $(ROOT_CFLAGS)
|
||||
INCLUDES = -I$(top_srcdir)/src/include $(PSIBIN_CFLAGS) $(MUD_CFLAGS) $(LEM_CFLAGS) $(FFTW3_CFLAGS) $(GSL_CFLAGS) $(BOOST_CFLAGS) $(ROOT_CFLAGS) $(PNEXUS_CXXFLAGS)
|
||||
AM_CXXFLAGS = $(LOCAL_LIB_CXXFLAGS)
|
||||
|
||||
BUILT_SOURCES = $(dict_cpp_sources) $(dict_h_sources)
|
||||
@ -79,7 +79,7 @@ CLEANFILES = *Dict.cpp *Dict.h *~ core
|
||||
lib_LTLIBRARIES = libPMusr.la
|
||||
|
||||
libPMusr_la_SOURCES = $(h_sources) $(cpp_sources) $(dict_h_sources) $(dict_cpp_sources)
|
||||
libPMusr_la_LIBADD = $(LEM_LIBS) $(PSIBIN_LIBS) $(MUD_LIBS) $(FFTW3_LIBS) $(GSL_LIBS) $(ROOT_LIBS)
|
||||
libPMusr_la_LIBADD = $(LEM_LIBS) $(PSIBIN_LIBS) $(MUD_LIBS) $(PNEXUS_LIBS) $(FFTW3_LIBS) $(GSL_LIBS) $(ROOT_LIBS)
|
||||
libPMusr_la_LDFLAGS = -version-info $(MUSR_LIBRARY_VERSION) -release $(MUSR_RELEASE) $(AM_LDFLAGS)
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
|
@ -4268,7 +4268,7 @@ Bool_t PMsrHandler::CheckRunBlockIntegrity()
|
||||
cerr << endl << " forward parameter number not defined. Necessary for single histogram fits." << endl;
|
||||
return false;
|
||||
}
|
||||
if (fRuns[i].GetForwardHistoNo() > 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;
|
||||
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;
|
||||
|
@ -162,7 +162,7 @@ PNonMusrRawRunData::~PNonMusrRawRunData()
|
||||
void PNonMusrRawRunData::SetLabel(const UInt_t idx, const TString str)
|
||||
{
|
||||
if (idx >= fLabels.size()) {
|
||||
cerr << endl << "**WARNING** PNonMusrRawRunData::SetLabel: idx=" << idx << " is out of range [0," << fLabels.size() << "[.";
|
||||
cerr << endl << ">> PNonMusrRawRunData::SetLabel: **WARNING** idx=" << idx << " is out of range [0," << fLabels.size() << "[.";
|
||||
cerr << endl;
|
||||
return;
|
||||
}
|
||||
@ -182,7 +182,7 @@ void PNonMusrRawRunData::SetLabel(const UInt_t idx, const TString str)
|
||||
void PNonMusrRawRunData::AppendSubData(const UInt_t idx, const Double_t dval)
|
||||
{
|
||||
if (idx >= fData.size()) {
|
||||
cerr << endl << "**WARNING** PNonMusrRawRunData::AppendSubData: idx=" << idx << " is out of range [0," << fData.size() << "[.";
|
||||
cerr << endl << ">> PNonMusrRawRunData::AppendSubData: **WARNING** idx=" << idx << " is out of range [0," << fData.size() << "[.";
|
||||
cerr << endl;
|
||||
return;
|
||||
}
|
||||
@ -202,7 +202,7 @@ void PNonMusrRawRunData::AppendSubData(const UInt_t idx, const Double_t dval)
|
||||
void PNonMusrRawRunData::AppendSubErrData(const UInt_t idx, const Double_t dval)
|
||||
{
|
||||
if (idx >= fErrData.size()) {
|
||||
cerr << endl << "**WARNING** PNonMusrRawRunData::AppendSubErrData: idx=" << idx << " is out of range [0," << fErrData.size() << "[.";
|
||||
cerr << endl << ">> PNonMusrRawRunData::AppendSubErrData: **WARNING** idx=" << idx << " is out of range [0," << fErrData.size() << "[.";
|
||||
cerr << endl;
|
||||
return;
|
||||
}
|
||||
@ -221,16 +221,18 @@ void PNonMusrRawRunData::AppendSubErrData(const UInt_t idx, const Double_t dval)
|
||||
*/
|
||||
PRawRunData::PRawRunData()
|
||||
{
|
||||
fRunName = TString("");
|
||||
fRunName = TString("n/a");
|
||||
fRunNumber = -1;
|
||||
fRunTitle = TString("");
|
||||
fSetup = TString("");
|
||||
fStartTime = TString("");
|
||||
fStartDate = TString("");
|
||||
fRunTitle = TString("n/a");
|
||||
fSetup = TString("n/a");
|
||||
fStartTime = TString("n/a");
|
||||
fStartDate = TString("n/a");
|
||||
fStartDateTimeSec = 0;
|
||||
fStopTime = TString("");
|
||||
fStopDate = TString("");
|
||||
fStopTime = TString("n/a");
|
||||
fStopDate = TString("n/a");
|
||||
fStopDateTimeSec = 0;
|
||||
fSample = TString("n/a");
|
||||
fOrientation = TString("n/a");
|
||||
fField = PMUSR_UNDEFINED;
|
||||
fEnergy = PMUSR_UNDEFINED;
|
||||
fTransport = PMUSR_UNDEFINED;
|
||||
@ -271,7 +273,7 @@ PRawRunData::~PRawRunData()
|
||||
const Double_t PRawRunData::GetTemperature(const UInt_t idx)
|
||||
{
|
||||
if (idx >= fTemp.size()) {
|
||||
cerr << endl << "**WARNING** PRawRunData::GetTemperature: idx=" << idx << " is out of range [0," << fTemp.size() << "[.";
|
||||
cerr << endl << ">> PRawRunData::GetTemperature: **WARNING** idx=" << idx << " is out of range [0," << fTemp.size() << "[.";
|
||||
cerr << endl;
|
||||
return PMUSR_UNDEFINED;
|
||||
}
|
||||
@ -293,7 +295,7 @@ const Double_t PRawRunData::GetTemperature(const UInt_t idx)
|
||||
const Double_t PRawRunData::GetTempError(const UInt_t idx)
|
||||
{
|
||||
if (idx >= fTemp.size()) {
|
||||
cerr << endl << "**WARNING** PRawRunData::GetTempError: idx=" << idx << " is out of range [0," << fTemp.size() << "[.";
|
||||
cerr << endl << ">> PRawRunData::GetTempError: **WARNING** idx=" << idx << " is out of range [0," << fTemp.size() << "[.";
|
||||
cerr << endl;
|
||||
return PMUSR_UNDEFINED;
|
||||
}
|
||||
@ -315,7 +317,7 @@ const Double_t PRawRunData::GetTempError(const UInt_t idx)
|
||||
const Double_t PRawRunData::GetRingAnode(const UInt_t idx)
|
||||
{
|
||||
if (idx >= fRingAnode.size()) {
|
||||
cerr << endl << "**WARNING** PRawRunData::GetRingAnode: idx=" << idx << " is out of range [0," << fRingAnode.size() << "[.";
|
||||
cerr << endl << ">> PRawRunData::GetRingAnode: **WARNING** idx=" << idx << " is out of range [0," << fRingAnode.size() << "[.";
|
||||
cerr << endl;
|
||||
return PMUSR_UNDEFINED;
|
||||
}
|
||||
@ -337,7 +339,7 @@ const Double_t PRawRunData::GetRingAnode(const UInt_t idx)
|
||||
const Int_t PRawRunData::GetT0(const UInt_t idx)
|
||||
{
|
||||
if (idx >= fT0s.size()) {
|
||||
cerr << endl << "**WARNING** PRawRunData::GetT0: idx=" << idx << " is out of range [0," << fT0s.size() << "[.";
|
||||
cerr << endl << ">> PRawRunData::GetT0: **WARNING** idx=" << idx << " is out of range [0," << fT0s.size() << "[.";
|
||||
cerr << endl;
|
||||
return -1;
|
||||
}
|
||||
@ -359,7 +361,7 @@ const Int_t PRawRunData::GetT0(const UInt_t idx)
|
||||
const Int_t PRawRunData::GetT0Estimated(const UInt_t idx)
|
||||
{
|
||||
if (idx >= fT0Estimated.size()) {
|
||||
cerr << endl << "**WARNING** PRawRunData::GetT0Estimated: idx=" << idx << " is out of range [0," << fT0Estimated.size() << "[.";
|
||||
cerr << endl << ">> PRawRunData::GetT0Estimated: **WARNING** idx=" << idx << " is out of range [0," << fT0Estimated.size() << "[.";
|
||||
cerr << endl;
|
||||
return -1;
|
||||
}
|
||||
@ -384,7 +386,7 @@ const PIntPair PRawRunData::GetBkgBin(const UInt_t idx)
|
||||
PIntPair pair(-1, -1);
|
||||
|
||||
if (idx >= fBkgBin.size()) {
|
||||
cerr << endl << "**WARNING** PRawRunData::GetBkgBin: idx=" << idx << " is out of range [0," << fBkgBin.size() << "[.";
|
||||
cerr << endl << ">> PRawRunData::GetBkgBin: **WARNING** idx=" << idx << " is out of range [0," << fBkgBin.size() << "[.";
|
||||
cerr << endl;
|
||||
return pair;
|
||||
}
|
||||
@ -413,7 +415,7 @@ const PIntPair PRawRunData::GetGoodDataBin(const UInt_t idx)
|
||||
PIntPair pair(-1, -1);
|
||||
|
||||
if (idx >= fGoodDataBin.size()) {
|
||||
cerr << endl << "**WARNING** PRawRunData::GetGoodDataBin: idx=" << idx << " is out of range [0," << fGoodDataBin.size() << "[.";
|
||||
cerr << endl << ">> PRawRunData::GetGoodDataBin: **WARNING** idx=" << idx << " is out of range [0," << fGoodDataBin.size() << "[.";
|
||||
cerr << endl;
|
||||
return pair;
|
||||
}
|
||||
@ -439,7 +441,7 @@ const PIntPair PRawRunData::GetGoodDataBin(const UInt_t idx)
|
||||
const PDoubleVector* PRawRunData::GetDataBin(const UInt_t idx)
|
||||
{
|
||||
if (idx >= fDataBin.size()) {
|
||||
cerr << endl << "**WARNING** PRawRunData::GetDataBin: idx=" << idx << " is out of range [0," << fDataBin.size() << "[.";
|
||||
cerr << endl << ">> PRawRunData::GetDataBin: **WARNING** idx=" << idx << " is out of range [0," << fDataBin.size() << "[.";
|
||||
cerr << endl;
|
||||
return 0;
|
||||
}
|
||||
@ -514,13 +516,13 @@ void PRawRunData::SetTempError(const UInt_t idx, const Double_t errTemp)
|
||||
void PRawRunData::SetDataBin(const UInt_t histoNo, const UInt_t bin, const Double_t dval)
|
||||
{
|
||||
if (histoNo > fDataBin.size()) {
|
||||
cerr << endl << "**WARNING** PRawRunData::SetDataBin: histoNo=" << histoNo << " is out of range [0," << fDataBin.size() << "].";
|
||||
cerr << endl << ">> PRawRunData::SetDataBin: **WARNING** histoNo=" << histoNo << " is out of range [0," << fDataBin.size() << "].";
|
||||
cerr << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (bin > fDataBin[histoNo].size()) {
|
||||
cerr << endl << "**WARNING** PRawRunData::SetDataBin: bin=" << bin << " is out of range [0," << fDataBin[histoNo].size() << "].";
|
||||
cerr << endl << ">> PRawRunData::SetDataBin: **WARNING** bin=" << bin << " is out of range [0," << fDataBin[histoNo].size() << "].";
|
||||
cerr << endl;
|
||||
return;
|
||||
}
|
||||
@ -541,13 +543,13 @@ void PRawRunData::SetDataBin(const UInt_t histoNo, const UInt_t bin, const Doubl
|
||||
void PRawRunData::AddDataBin(const UInt_t histoNo, const UInt_t bin, const Double_t dval)
|
||||
{
|
||||
if (histoNo > fDataBin.size()) {
|
||||
cerr << endl << "**WARNING** PRawRunData::AddDataBin: histoNo=" << histoNo << " is out of range [0," << fDataBin.size() << "].";
|
||||
cerr << endl << ">> PRawRunData::AddDataBin: **WARNING** histoNo=" << histoNo << " is out of range [0," << fDataBin.size() << "].";
|
||||
cerr << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (bin > fDataBin[histoNo].size()) {
|
||||
cerr << endl << "**WARNING** PRawRunData::AddDataBin: bin=" << bin << " is out of range [0," << fDataBin[histoNo].size() << "].";
|
||||
cerr << endl << ">> PRawRunData::AddDataBin: **WARNING** bin=" << bin << " is out of range [0," << fDataBin[histoNo].size() << "].";
|
||||
cerr << endl;
|
||||
return;
|
||||
}
|
||||
@ -985,7 +987,7 @@ Double_t PMsrRunBlock::GetBkgFix(UInt_t idx)
|
||||
void PMsrRunBlock::SetBkgFix(Double_t dval, Int_t idx)
|
||||
{
|
||||
if (idx >= 2) {
|
||||
cerr << endl << "PMsrRunBlock::SetBkgFix: **WARNING** idx=" << idx << ", only idx=0,1 are sensible.";
|
||||
cerr << endl << ">> PMsrRunBlock::SetBkgFix: **WARNING** idx=" << idx << ", only idx=0,1 are sensible.";
|
||||
cerr << endl;
|
||||
return;
|
||||
}
|
||||
@ -1026,7 +1028,7 @@ Int_t PMsrRunBlock::GetBkgRange(UInt_t idx)
|
||||
void PMsrRunBlock::SetBkgRange(Int_t ival, Int_t idx)
|
||||
{
|
||||
if (idx >= 4) {
|
||||
cerr << endl << "PMsrRunBlock::SetBkgRange: **WARNING** idx=" << idx << ", only idx=0..3 are sensible.";
|
||||
cerr << endl << ">> PMsrRunBlock::SetBkgRange: **WARNING** idx=" << idx << ", only idx=0..3 are sensible.";
|
||||
cerr << endl;
|
||||
return;
|
||||
}
|
||||
@ -1068,7 +1070,7 @@ Int_t PMsrRunBlock::GetDataRange(UInt_t idx)
|
||||
void PMsrRunBlock::SetDataRange(Int_t ival, Int_t idx)
|
||||
{
|
||||
if (idx >= 4) {
|
||||
cerr << endl << "PMsrRunBlock::SetDataRange: **WARNING** idx=" << idx << ", only idx=0..3 are sensible.";
|
||||
cerr << endl << ">> PMsrRunBlock::SetDataRange: **WARNING** idx=" << idx << ", only idx=0..3 are sensible.";
|
||||
cerr << endl;
|
||||
return;
|
||||
}
|
||||
|
@ -29,6 +29,10 @@
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <iostream>
|
||||
@ -50,6 +54,10 @@ using namespace std;
|
||||
#include "MuSR_td_PSI_bin.h"
|
||||
#include "mud.h"
|
||||
|
||||
#ifdef PNEXUS_ENABLED
|
||||
#include "PNeXus.h"
|
||||
#endif
|
||||
|
||||
#include "PRunDataHandler.h"
|
||||
|
||||
#define ROOT_ALL 0
|
||||
@ -610,7 +618,7 @@ Bool_t PRunDataHandler::FileExistsCheck(PMsrRunBlock &runInfo, const UInt_t idx)
|
||||
else if (!runInfo.GetFileFormat(idx)->CompareTo("root-ppc")) // post pile up corrected histos
|
||||
ext = TString("root");
|
||||
else if (!runInfo.GetFileFormat(idx)->CompareTo("nexus"))
|
||||
ext = TString("nexus");
|
||||
ext = TString("NXS");
|
||||
else if (!runInfo.GetFileFormat(idx)->CompareTo("psi-bin"))
|
||||
ext = TString("bin");
|
||||
else if (!runInfo.GetFileFormat(idx)->CompareTo("psi-mdu"))
|
||||
@ -640,7 +648,7 @@ Bool_t PRunDataHandler::FileExistsCheck(PMsrRunBlock &runInfo, const UInt_t idx)
|
||||
assert(0);
|
||||
}
|
||||
pstr->ToUpper();
|
||||
cerr << endl << ">> **ERROR** File Format '" << pstr->Data() << "' unsupported.";
|
||||
cerr << endl << ">> PRunDataHandler::FileExistsCheck: **ERROR** File Format '" << pstr->Data() << "' unsupported.";
|
||||
cerr << endl << ">> support file formats are:";
|
||||
cerr << endl << ">> ROOT-NPP -> root not post pileup corrected for lem";
|
||||
cerr << endl << ">> ROOT-PPC -> root post pileup corrected for lem";
|
||||
@ -794,7 +802,7 @@ Bool_t PRunDataHandler::FileExistsCheck(const Bool_t fileName, const Int_t idx)
|
||||
}
|
||||
// check for input/output templates
|
||||
if ((fAny2ManyInfo->inTemplate.Length() == 0) || (fAny2ManyInfo->outTemplate.Length() == 0)) {
|
||||
cerr << endl << ">> PRunDataHandler::FileExistsCheck(): **ERROR** when using run lists, input/ouput templates are needed as well." << endl;
|
||||
cerr << endl << ">> PRunDataHandler::FileExistsCheck(): **ERROR** when using run lists, input/output templates are needed as well." << endl;
|
||||
return false;
|
||||
}
|
||||
// make the input file name according to the input template
|
||||
@ -1214,8 +1222,106 @@ Bool_t PRunDataHandler::ReadRootFile(UInt_t tag)
|
||||
*/
|
||||
Bool_t PRunDataHandler::ReadNexusFile()
|
||||
{
|
||||
cout << endl << "PRunDataHandler::ReadNexusFile(): Sorry, not yet implemented, ask Alex Amato and Stephen Cottrell ...";
|
||||
return false;
|
||||
#ifdef PNEXUS_ENABLED
|
||||
cout << endl << ">> PRunDataHandler::ReadNexusFile(): Will read nexus file " << fRunPathName.Data() << " ...";
|
||||
|
||||
PDoubleVector histoData;
|
||||
PRawRunData runData;
|
||||
TString str;
|
||||
Double_t dval;
|
||||
|
||||
PNeXus *nxs_file = new PNeXus(fRunPathName.Data());
|
||||
if (!nxs_file->IsValid()) {
|
||||
cerr << endl << ">> PRunDataHandler::ReadNexusFile(): Not a valid NeXus file.";
|
||||
cerr << endl << ">> Error Message: " << nxs_file->GetErrorMsg().data() << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// get header information
|
||||
|
||||
// get/set run title
|
||||
str = TString(nxs_file->GetRunTitle());
|
||||
runData.SetRunTitle(str);
|
||||
|
||||
// get/set run number
|
||||
runData.SetRunNumber(nxs_file->GetRunNumber());
|
||||
|
||||
// get/set temperature
|
||||
runData.SetTemperature(0, nxs_file->GetSampleTemperature(), 0.0);
|
||||
|
||||
// get/set field
|
||||
dval = nxs_file->GetMagneticField();
|
||||
str = TString(nxs_file->GetMagneticFieldUnits());
|
||||
// since field has to be given in Gauss, check the units
|
||||
Double_t factor=1.0;
|
||||
if (!str.CompareTo("gauss", TString::kIgnoreCase))
|
||||
factor=1.0;
|
||||
else if (!str.CompareTo("tesla", TString::kIgnoreCase))
|
||||
factor=1.0e4;
|
||||
else
|
||||
factor=1.0;
|
||||
runData.SetField(factor*dval);
|
||||
|
||||
// get/set implantation energy
|
||||
runData.SetEnergy(PMUSR_UNDEFINED);
|
||||
|
||||
// get/set moderator HV
|
||||
runData.SetTransport(PMUSR_UNDEFINED);
|
||||
|
||||
// get/set RA HV's (LEM specific)
|
||||
for (UInt_t i=0; i<4; i++)
|
||||
runData.SetRingAnode(i, PMUSR_UNDEFINED);
|
||||
|
||||
// get/set setup
|
||||
runData.SetSetup(nxs_file->GetRunNotes());
|
||||
|
||||
// get/set sample
|
||||
runData.SetSample(nxs_file->GetSampleName());
|
||||
|
||||
// get/set orientation
|
||||
runData.SetOrientation("??");
|
||||
|
||||
// get/set time resolution (ns)
|
||||
runData.SetTimeResolution(nxs_file->GetTimeResolution());
|
||||
|
||||
// get/set start/stop time
|
||||
runData.SetStartTime(nxs_file->GetStartTime());
|
||||
runData.SetStartDate(nxs_file->GetStartDate());
|
||||
runData.SetStopTime(nxs_file->GetStopTime());
|
||||
runData.SetStopDate(nxs_file->GetStopDate());
|
||||
|
||||
// get t0, firstGoodBin, lastGoodBin, data
|
||||
UInt_t t0=nxs_file->GetT0();
|
||||
PIntPair goodDataBin;
|
||||
goodDataBin.first = nxs_file->GetFirstGoodBin();
|
||||
goodDataBin.second = nxs_file->GetLastGoodBin();
|
||||
PDoubleVector data;
|
||||
for (Int_t i=0; i<nxs_file->GetNoHistos(); i++) {
|
||||
runData.AppendT0(t0);
|
||||
runData.AppendGoodDataBin(goodDataBin);
|
||||
data.clear();
|
||||
for (UInt_t j=0; j<nxs_file->GetHisto(i)->size(); j++) {
|
||||
data.push_back((Double_t)nxs_file->GetHisto(i)->at(j));
|
||||
}
|
||||
runData.AppendDataBin(data);
|
||||
}
|
||||
data.clear();
|
||||
|
||||
// keep run name from the msr-file
|
||||
runData.SetRunName(fRunName);
|
||||
|
||||
// keep the information
|
||||
fData.push_back(runData);
|
||||
|
||||
// clean up
|
||||
if (nxs_file) {
|
||||
delete nxs_file;
|
||||
nxs_file = 0;
|
||||
}
|
||||
#else
|
||||
cout << endl << ">> PRunDataHandler::ReadNexusFile(): Sorry, not enabled at configuration level, i.e. --enable-NeXus when executing configure" << endl << endl;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@ -1620,6 +1726,7 @@ Bool_t PRunDataHandler::ReadPsiBinFile()
|
||||
}
|
||||
runData.SetStopDate(sDateTime[0]);
|
||||
runData.SetStopTime(sDateTime[1]);
|
||||
sDateTime.clear();
|
||||
|
||||
// fill raw data
|
||||
PDoubleVector histoData;
|
||||
@ -2988,21 +3095,10 @@ Bool_t PRunDataHandler::WriteRootFile(TString fln)
|
||||
// generate output file name if needed
|
||||
if (!fAny2ManyInfo->useStandardOutput || (fAny2ManyInfo->compressionTag > 0)) {
|
||||
if (fln.Length() == 0) {
|
||||
Int_t start = fRunPathName.Last('/');
|
||||
Int_t end = fRunPathName.Last('.');
|
||||
if (end == -1) {
|
||||
cerr << endl << ">> PRunDataHandler::WriteRootFile(): **ERROR** couldn't generate the output file name ..." << endl;
|
||||
Bool_t ok = false;
|
||||
fln = GetFileName(".root", ok);
|
||||
if (!ok)
|
||||
return false;
|
||||
}
|
||||
// cut out the filename (get rid of the extension, and the path)
|
||||
Char_t str1[1024], str2[1024];
|
||||
strncpy(str1, fRunPathName.Data(), sizeof(str1));
|
||||
for (Int_t i=0; i<end-start-1; i++) {
|
||||
str2[i] = str1[i+start+1];
|
||||
}
|
||||
str2[end-start-1] = 0;
|
||||
|
||||
fln = fAny2ManyInfo->outPath + str2 + ".root";
|
||||
} else {
|
||||
fln.Prepend(fAny2ManyInfo->outPath);
|
||||
}
|
||||
@ -3183,8 +3279,92 @@ Bool_t PRunDataHandler::WriteRootFile(TString fln)
|
||||
* \param fln file name. If empty, the routine will try to construct one
|
||||
*/
|
||||
Bool_t PRunDataHandler::WriteNexusFile(TString fln)
|
||||
{
|
||||
cout << endl << ">> PRunDataHandler::WriteNexusFile(): will write a nexus data file. Not yet implemented ... " << endl;
|
||||
{
|
||||
#ifdef PNEXUS_ENABLED
|
||||
// generate output file name
|
||||
if (fln.Length() == 0) {
|
||||
Bool_t ok = false;
|
||||
fln = GetFileName(".nxs", ok);
|
||||
if (!ok)
|
||||
return false;
|
||||
} else {
|
||||
fln.Prepend(fAny2ManyInfo->outPath);
|
||||
}
|
||||
// keep the file name if compression is whished
|
||||
fAny2ManyInfo->outPathFileName.push_back(fln);
|
||||
|
||||
if (!fAny2ManyInfo->useStandardOutput)
|
||||
cout << endl << ">> PRunDataHandler::WriteNexusFile(): writing a NeXus data file (" << fln.Data() << ") ... " << endl;
|
||||
|
||||
// create NeXus object
|
||||
PNeXus *nxs = new PNeXus();
|
||||
if (nxs == 0) {
|
||||
cerr << endl << ">> PRunDataHandler::WriteNexusFile(): **ERROR** couldn't invoke the NeXus object." << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// fill necessary data structures
|
||||
nxs->SetFileName(fln.Data());
|
||||
nxs->SetIDFVersion(1);
|
||||
nxs->SetProgramName("any2many");
|
||||
nxs->SetProgramVersion("$Id$");
|
||||
nxs->SetRunNumber(fData[0].GetRunNumber());
|
||||
nxs->SetRunTitle(fData[0].GetRunTitle()->Data());
|
||||
nxs->SetRunNotes("n/a");
|
||||
nxs->SetAnalysisTag("n/a");
|
||||
nxs->SetLab("PSI");
|
||||
nxs->SetBeamline("n/a");
|
||||
nxs->SetStartDate(fData[0].GetStartDate()->Data());
|
||||
nxs->SetStartTime(fData[0].GetStartTime()->Data());
|
||||
nxs->SetStopDate(fData[0].GetStopDate()->Data());
|
||||
nxs->SetStopTime(fData[0].GetStopTime()->Data());
|
||||
nxs->SetSwitchingState(0);
|
||||
nxs->SetUser("n/a");
|
||||
nxs->SetExperimentNumber("n/a");
|
||||
nxs->SetSampleName(fData[0].GetSample()->Data());
|
||||
nxs->SetSampleTemperature(fData[0].GetTemperature(0));
|
||||
nxs->SetSampleTemperatureUints("Kelvin");
|
||||
nxs->SetMagneticField(fData[0].GetField());
|
||||
nxs->SetMagneticFieldUnits("Gauss");
|
||||
nxs->SetSampleEnvironment("n/a");
|
||||
nxs->SetSampleShape("n/a");
|
||||
nxs->SetMagneticFieldVectorAvailable(0);
|
||||
nxs->SetExperimentName("n/a");
|
||||
nxs->SetNoDetectors(fData[0].GetNoOfHistos());
|
||||
nxs->SetCollimatorType("n/a");
|
||||
nxs->SetTimeResolution(fData[0].GetTimeResolution());
|
||||
if (fData[0].GetT0(0) == -1)
|
||||
nxs->SetT0(0);
|
||||
else
|
||||
nxs->SetT0(fData[0].GetT0(0)); // this needs to be changed in the long term, since for continous sources each detector has its one t0!!
|
||||
if (fData[0].GetGoodDataBin(0).first == -1) {
|
||||
nxs->SetFirstGoodBin(0);
|
||||
nxs->SetLastGoodBin(0);
|
||||
} else {
|
||||
nxs->SetFirstGoodBin(fData[0].GetGoodDataBin(0).first);
|
||||
nxs->SetLastGoodBin(fData[0].GetGoodDataBin(0).second);
|
||||
}
|
||||
// feed real histogram data
|
||||
PUIntVector data;
|
||||
for (UInt_t i=0; i<fData[0].GetNoOfHistos(); i++) {
|
||||
for (UInt_t j=0; j<fData[0].GetDataBin(i)->size(); j++) {
|
||||
data.push_back((UInt_t)fData[0].GetDataBin(i)->at(j));
|
||||
}
|
||||
nxs->SetHisto(i, data);
|
||||
data.clear();
|
||||
}
|
||||
|
||||
// write file
|
||||
nxs->WriteFile(fln);
|
||||
|
||||
// clean up
|
||||
if (nxs != 0) {
|
||||
delete nxs;
|
||||
nxs = 0;
|
||||
}
|
||||
#else
|
||||
cout << endl << ">> PRunDataHandler::WriteNexusFile(): Sorry, not enabled at configuration level, i.e. --enable-NeXus when executing configure" << endl << endl;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -3204,21 +3384,10 @@ Bool_t PRunDataHandler::WriteWkmFile(TString fln)
|
||||
{
|
||||
// generate output file name
|
||||
if (fln.Length() == 0) {
|
||||
Int_t start = fRunPathName.Last('/');
|
||||
Int_t end = fRunPathName.Last('.');
|
||||
if (end == -1) {
|
||||
cerr << endl << ">> PRunDataHandler::WriteWkmFile(): **ERROR** couldn't generate the output file name ..." << endl;
|
||||
Bool_t ok = false;
|
||||
fln = GetFileName(".wkm", ok);
|
||||
if (!ok)
|
||||
return false;
|
||||
}
|
||||
// cut out the filename (get rid of the extension, and the path)
|
||||
Char_t str1[1024], str2[1024];
|
||||
strncpy(str1, fRunPathName.Data(), sizeof(str1));
|
||||
for (Int_t i=0; i<end-start-1; i++) {
|
||||
str2[i] = str1[i+start+1];
|
||||
}
|
||||
str2[end-start-1] = 0;
|
||||
|
||||
fln = fAny2ManyInfo->outPath + str2 + ".wkm";
|
||||
} else {
|
||||
fln.Prepend(fAny2ManyInfo->outPath);
|
||||
}
|
||||
@ -3244,7 +3413,7 @@ Bool_t PRunDataHandler::WriteWkmFile(TString fln)
|
||||
// save output buffer of the stream
|
||||
strm_buffer = cout.rdbuf();
|
||||
|
||||
// redirect ouput into the file
|
||||
// redirect output into the file
|
||||
cout.rdbuf(fout.rdbuf());
|
||||
}
|
||||
|
||||
@ -3266,7 +3435,7 @@ Bool_t PRunDataHandler::WriteWkmFile(TString fln)
|
||||
} else {
|
||||
cout << endl << "Field : ??";
|
||||
}
|
||||
cout << endl << "Date : ??";
|
||||
cout << endl << "Date : " << fData[0].GetStartTime()->Data() << " " << fData[0].GetStartDate()->Data() << " / " << fData[0].GetStopTime()->Data() << " " << fData[0].GetStopDate()->Data();
|
||||
cout << endl << "Setup : " << fData[0].GetSetup()->Data();
|
||||
cout << endl << "Groups : " << fData[0].GetNoOfHistos();
|
||||
cout << endl << "Channels : " << static_cast<UInt_t>(fData[0].GetDataBin(0)->size()/fAny2ManyInfo->rebin);
|
||||
@ -3334,21 +3503,10 @@ Bool_t PRunDataHandler::WritePsiBinFile(TString fln)
|
||||
// generate output file name if needed
|
||||
if (!fAny2ManyInfo->useStandardOutput || (fAny2ManyInfo->compressionTag > 0)) {
|
||||
if (fln.Length() == 0) {
|
||||
Int_t start = fRunPathName.Last('/');
|
||||
Int_t end = fRunPathName.Last('.');
|
||||
if (end == -1) {
|
||||
cerr << endl << ">> PRunDataHandler::WritePsiBinFile(): **ERROR** couldn't generate the output file name ..." << endl;
|
||||
Bool_t ok = false;
|
||||
fln = GetFileName(".bin", ok);
|
||||
if (!ok)
|
||||
return false;
|
||||
}
|
||||
// cut out the filename (get rid of the extension, and the path)
|
||||
Char_t str1[1024], str2[1024];
|
||||
strncpy(str1, fRunPathName.Data(), sizeof(str1));
|
||||
for (Int_t i=0; i<end-start-1; i++) {
|
||||
str2[i] = str1[i+start+1];
|
||||
}
|
||||
str2[end-start-1] = 0;
|
||||
|
||||
fln = fAny2ManyInfo->outPath + str2 + ".bin";
|
||||
} else {
|
||||
fln.Prepend(fAny2ManyInfo->outPath);
|
||||
}
|
||||
@ -3522,21 +3680,10 @@ Bool_t PRunDataHandler::WriteMudFile(TString fln)
|
||||
// generate output file name if needed
|
||||
if (!fAny2ManyInfo->useStandardOutput || (fAny2ManyInfo->compressionTag > 0)) {
|
||||
if (fln.Length() == 0) {
|
||||
Int_t start = fRunPathName.Last('/');
|
||||
Int_t end = fRunPathName.Last('.');
|
||||
if (end == -1) {
|
||||
cerr << endl << ">> PRunDataHandler::WriteMudFile(): **ERROR** couldn't generate the output file name ..." << endl;
|
||||
Bool_t ok = false;
|
||||
fln = GetFileName(".msr", ok);
|
||||
if (!ok)
|
||||
return false;
|
||||
}
|
||||
// cut out the filename (get rid of the extension, and the path)
|
||||
Char_t str1[1024], str2[1024];
|
||||
strncpy(str1, fRunPathName.Data(), sizeof(str1));
|
||||
for (Int_t i=0; i<end-start-1; i++) {
|
||||
str2[i] = str1[i+start+1];
|
||||
}
|
||||
str2[end-start-1] = 0;
|
||||
|
||||
fln = fAny2ManyInfo->outPath + str2 + ".msr";
|
||||
} else {
|
||||
fln.Prepend(fAny2ManyInfo->outPath);
|
||||
}
|
||||
@ -3700,21 +3847,10 @@ Bool_t PRunDataHandler::WriteAsciiFile(TString fln)
|
||||
{
|
||||
// generate output file name
|
||||
if (fln.Length() == 0) {
|
||||
Int_t start = fRunPathName.Last('/');
|
||||
Int_t end = fRunPathName.Last('.');
|
||||
if (end == -1) {
|
||||
cerr << endl << ">> PRunDataHandler::WriteAsciiFile(): **ERROR** couldn't generate the output file name ..." << endl;
|
||||
Bool_t ok = false;
|
||||
fln = GetFileName(".ascii", ok);
|
||||
if (!ok)
|
||||
return false;
|
||||
}
|
||||
// cut out the filename (get rid of the extension, and the path)
|
||||
Char_t str1[1024], str2[1024];
|
||||
strncpy(str1, fRunPathName.Data(), sizeof(str1));
|
||||
for (Int_t i=0; i<end-start-1; i++) {
|
||||
str2[i] = str1[i+start+1];
|
||||
}
|
||||
str2[end-start-1] = 0;
|
||||
|
||||
fln = fAny2ManyInfo->outPath + str2 + ".ascii";
|
||||
} else {
|
||||
fln.Prepend(fAny2ManyInfo->outPath);
|
||||
}
|
||||
@ -3740,7 +3876,7 @@ Bool_t PRunDataHandler::WriteAsciiFile(TString fln)
|
||||
// save output buffer of the stream
|
||||
strm_buffer = cout.rdbuf();
|
||||
|
||||
// redirect ouput into the file
|
||||
// redirect output into the file
|
||||
cout.rdbuf(fout.rdbuf());
|
||||
}
|
||||
|
||||
@ -3754,6 +3890,8 @@ Bool_t PRunDataHandler::WriteAsciiFile(TString fln)
|
||||
if (fData[0].GetSetup()->Length() > 0)
|
||||
cout << endl << "% setup : " << fData[0].GetSetup()->Data();
|
||||
cout << endl << "% field : " << fData[0].GetField() << " (G)";
|
||||
if (fData[0].GetStartTime()->Length() > 0)
|
||||
cout << endl << "% date : " << fData[0].GetStartTime()->Data() << " " << fData[0].GetStartDate()->Data() << " / " << fData[0].GetStopTime()->Data() << " " << fData[0].GetStopDate()->Data();
|
||||
if (fData[0].GetNoOfTemperatures() > 0) {
|
||||
cout << endl << "% temperature : ";
|
||||
for (UInt_t i=0; i<fData[0].GetNoOfTemperatures()-1; i++) {
|
||||
@ -4058,6 +4196,51 @@ Int_t PRunDataHandler::GetDataTagIndex(TString &str, const PStringVector* dataTa
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// GetFileName (private)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Construct the file name based on the any2many request.
|
||||
*
|
||||
* <b>return:</b>
|
||||
* - constructed file name
|
||||
* - empty string
|
||||
*
|
||||
* \param extension if the file name to be constructed
|
||||
* \param ok flag which is 'true' if the file name could be constructed, 'false' otherwise
|
||||
*/
|
||||
TString PRunDataHandler::GetFileName(const TString extension, Bool_t &ok)
|
||||
{
|
||||
TString fileName = "";
|
||||
ok = true;
|
||||
|
||||
Int_t start = fRunPathName.Last('/');
|
||||
Int_t end = fRunPathName.Last('.');
|
||||
if (end == -1) {
|
||||
cerr << endl << ">> PRunDataHandler::GetFileName(): **ERROR** couldn't generate the output file name ..." << endl;
|
||||
ok = false;
|
||||
return fileName;
|
||||
}
|
||||
// cut out the filename (get rid of the extension, and the path)
|
||||
Char_t str1[1024], str2[1024];
|
||||
strncpy(str1, fRunPathName.Data(), sizeof(str1));
|
||||
for (Int_t i=0; i<end-start-1; i++) {
|
||||
str2[i] = str1[i+start+1];
|
||||
}
|
||||
str2[end-start-1] = 0;
|
||||
|
||||
if (fAny2ManyInfo->inFormat == fAny2ManyInfo->outFormat) { // only rebinning
|
||||
TString rebinStr;
|
||||
rebinStr += fAny2ManyInfo->rebin;
|
||||
fileName = fAny2ManyInfo->outPath + str2 + "_rebin" + rebinStr + extension;
|
||||
} else { // real conversion
|
||||
fileName = fAny2ManyInfo->outPath + str2 + extension;
|
||||
}
|
||||
|
||||
return fileName;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// FileNameFromTemplate (private)
|
||||
//--------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user