Merge branch 'master' of gitorious:nemu/musrfit

This commit is contained in:
2016-02-03 08:56:05 +01:00
290 changed files with 33355 additions and 5900 deletions

View File

@ -16,21 +16,32 @@ if BUILD_MUSREDIT
EDITORDIR = musredit
endif
if BUILD_MUSREDIT_QT5
EDITORDIR = musredit_qt5
endif
SUBDIRS = external/MusrRoot \
external/TLemRunHeader \
external/MuSR_software \
external/mud \
$(PNEXUSDIRS) \
classes \
external
external \
musredit_qt5 \
musredit \
musrgui
if BUILD_MUSRGUI
SUBDIRS += $(EDITORDIR)
#SUBDIRS += $(EDITORDIR)
EXTRA_DIST = $(EDITORDIR)/Makefile
endif
if BUILD_MUSREDIT
SUBDIRS += $(EDITORDIR)
#SUBDIRS += $(EDITORDIR)
EXTRA_DIST = $(EDITORDIR)/Makefile
endif
if BUILD_MUSREDIT_QT5
EXTRA_DIST = $(EDITORDIR)/Makefile
endif

View File

@ -54,7 +54,7 @@ using namespace std;
void any2many_syntax()
{
cout << endl << "usage: any2many [--help] : will show this help.";
cout << endl << " any2many --version : will show the svn version.";
cout << endl << " any2many --version : will show the git version.";
cout << endl << " any2many -f <filenameList-input> | -r <runList-input>";
cout << endl << " -c <convert-options> [-p <output-path>] [-y <year>]";
cout << endl << " [-o <outputFileName> | -t <in-template> <out-template>] [-s]";
@ -83,6 +83,10 @@ void any2many_syntax()
cout << endl << " NeXus2-HDF4, NeXus2-HDF5, NeXus2-XML, WKM, ASCII";
cout << endl << " Comment: ROOT is superseeded by MusrRoot. If there is not a very good";
cout << endl << " reason, avoid it!";
cout << endl << " -h <histo-group-list> : This option is for MusrRoot input files only!";
cout << endl << " Select the the histo groups to be exported. <histo-group-list> is a space";
cout << endl << " separated list of the histo group, e.g. -h 0, 20 will try to export the histo";
cout << endl << " 0 (NPP) and 20 (PPC).";
cout << endl << " -p <output-path> : where <output-path> is the output path for the";
cout << endl << " converted files. If nothing is given, the current directory";
cout << endl << " will be used, unless the option '-s' is used.";
@ -190,7 +194,7 @@ int main(int argc, char *argv[])
// call any2many --help or any2many --version
if (argc == 2) {
if (strstr(argv[1], "--h"))
if (!strncmp(argv[1], "--help", 128))
any2many_syntax();
else if (strstr(argv[1], "--v")) {
#ifdef HAVE_CONFIG_H
@ -344,6 +348,21 @@ int main(int argc, char *argv[])
show_syntax = true;
break;
}
} else if (!strcmp(argv[i], "-h")) { // filter histo group list (for MusrRoot and ROOT (LEM) only!)
bool done = false;
int j = i+1;
do {
status = sscanf(argv[j], "%d", &ival);
if (status == 1) {
info.groupHistoList.push_back(ival);
j++;
} else {
done = true;
}
} while (!done && (j<argc));
i = j-1;
if (j >= argc) // make sure that counter is still in range
break;
} else if (!strcmp(argv[i], "-p")) { // filter output path name flag
if (i+1 < argc) {
info.outPath = argv[i+1];

View File

@ -15,12 +15,14 @@ h_sources = \
../include/PMusrT0.h \
../include/PPrepFourier.h \
../include/PRunAsymmetry.h \
../include/PRunAsymmetryRRF.h \
../include/PRunBase.h \
../include/PRunDataHandler.h \
../include/PRunListCollection.h \
../include/PRunNonMusr.h \
../include/PRunMuMinus.h \
../include/PRunSingleHisto.h \
../include/PRunSingleHistoRRF.h \
../include/PStartupHandler.h \
../include/PTheory.h
@ -59,12 +61,14 @@ cpp_sources = \
PMusrT0.cpp \
PPrepFourier.cpp \
PRunAsymmetry.cpp \
PRunAsymmetryRRF.cpp \
PRunBase.cpp \
PRunDataHandler.cpp \
PRunListCollection.cpp \
PRunNonMusr.cpp \
PRunMuMinus.cpp \
PRunSingleHisto.cpp \
PRunSingleHistoRRF.cpp \
PStartupHandler.cpp \
PTheory.cpp
@ -91,7 +95,7 @@ AM_LDFLAGS = $(LOCAL_LIB_LDFLAGS) -L@ROOTLIBDIR@
CLEANFILES = *Dict.cpp *Dict.h *~ core
%Dict.cpp %Dict.h: ../include/%.h ../include/%LinkDef.h
@ROOTCINT@ -v -f $*Dict.cpp -c -p $(INCLUDES) $^
@ROOTCINT@ -v -f $*Dict.cpp -c -p $(AM_CPPFLAGS) $^
lib_LTLIBRARIES = libPUserFcnBase.la libPMusr.la

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
@ -77,12 +77,16 @@ Double_t PFitterFcn::operator()(const std::vector<Double_t>& par) const
if (fUseChi2) { // chi square
value += fRunListCollection->GetSingleHistoChisq(par);
value += fRunListCollection->GetSingleHistoRRFChisq(par);
value += fRunListCollection->GetAsymmetryChisq(par);
value += fRunListCollection->GetAsymmetryRRFChisq(par);
value += fRunListCollection->GetMuMinusChisq(par);
value += fRunListCollection->GetNonMusrChisq(par);
} else { // max likelihood
value += fRunListCollection->GetSingleHistoMaximumLikelihood(par);
value += fRunListCollection->GetSingleHistoRRFMaximumLikelihood(par);
value += fRunListCollection->GetAsymmetryMaximumLikelihood(par);
value += fRunListCollection->GetAsymmetryRRFMaximumLikelihood(par);
value += fRunListCollection->GetMuMinusMaximumLikelihood(par);
value += fRunListCollection->GetNonMusrMaximumLikelihood(par);
}

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
@ -163,7 +163,7 @@ PFourier::~PFourier()
}
//--------------------------------------------------------------------------
// Transform
// Transform (public)
//--------------------------------------------------------------------------
/**
* <p>Carries out the Fourier transform. It is assumed that fStartTime is the time zero
@ -201,7 +201,24 @@ void PFourier::Transform(UInt_t apodizationTag)
}
//--------------------------------------------------------------------------
// GetRealFourier
// GetMaxFreq (public)
//--------------------------------------------------------------------------
/**
* <p>returns the maximal frequency in units choosen, i.e. Gauss, Tesla, MHz, Mc/s
*/
Double_t PFourier::GetMaxFreq()
{
UInt_t noOfFourierBins = 0;
if (fNoOfBins % 2 == 0)
noOfFourierBins = fNoOfBins/2;
else
noOfFourierBins = (fNoOfBins+1)/2;
return fResolution*noOfFourierBins;
}
//--------------------------------------------------------------------------
// GetRealFourier (public)
//--------------------------------------------------------------------------
/**
* <p>returns the real part Fourier as a histogram.
@ -242,7 +259,112 @@ TH1F* PFourier::GetRealFourier(const Double_t scale)
}
//--------------------------------------------------------------------------
// GetImaginaryFourier
// GetPhaseOptRealFourier (public)
//--------------------------------------------------------------------------
/**
* <p>returns the phase corrected real Fourier transform. The correction angle is
* past back as well.
* <p>Currently it simply does the following thing: (i) rotate the complex Fourier
* transform through all angles in 1/2° steps, i.e.
* \f$ f_{\rm rot} = (f_{\rm real} + i f_{\rm imag}) \exp(- \alpha)\f$,
* hence \f$ f_{\rm rot} = f_{\rm real} \cos(\alpha) + f_{\rm imag} \sin(\alpha)\f$.
* (ii) search the maximum of \f$ sum_{\alpha} {\cal R}\{f_{\rm rot}\}\f$ for all
* \f$\alpha\f$. From this one gets \f$\alpha_{\rm opt}\f$. (iii) The 'optimal'
* real Fourier transform is \f$f_{\rm opt} = (f_{\rm real} + i f_{\rm imag})
* \exp(- \alpha_{\rm opt})\f$.
*
* \return the TH1F histo of the phase 'optimzed' real Fourier transform.
*
* \param phase return value of the optimal phase
* \param scale normalisation factor
* \param min minimal freq / field from which to optimise. Given in the choosen unit.
* \param max maximal freq / field up to which to optimise. Given in the choosen unit.
*/
TH1F* PFourier::GetPhaseOptRealFourier(Double_t &phase, const Double_t scale, const Double_t min, const Double_t max)
{
UInt_t noOfFourierBins = 0;
if (fNoOfBins % 2 == 0)
noOfFourierBins = fNoOfBins/2;
else
noOfFourierBins = (fNoOfBins+1)/2;
UInt_t minBin = 0;
UInt_t maxBin = noOfFourierBins;
// check if minimum frequency is given. If yes, get the proper minBin
if (min != -1.0) {
minBin = (UInt_t)(min/fResolution);
}
// check if maximum frequency is given. If yes, get the proper maxBin
if (max != -1.0) {
maxBin = (UInt_t)(max/fResolution);
if (maxBin >= noOfFourierBins) {
maxBin = noOfFourierBins;
cerr << "**WARNING** maximum frequency/field out of range. Will adopted it." << endl;
}
}
// copy the real/imag Fourier from min to max
vector<Double_t> realF, imagF;
for (UInt_t i=minBin; i<=maxBin; i++) {
realF.push_back(fOut[i][0]);
imagF.push_back(fOut[i][1]);
}
// rotate trough real/imag Fourier through 360° with a 1/2° resolution and keep the integral
Double_t rotRealIntegral[720];
Double_t sum = 0.0;
Double_t da = 8.72664625997164774e-03; // pi / 360
for (UInt_t i=0; i<720; i++) {
sum = 0.0;
for (UInt_t j=0; j<realF.size(); j++) {
sum += realF[j]*cos(da*i) + imagF[j]*sin(da*i);
}
rotRealIntegral[i] = sum;
}
// find the maximum in rotRealIntegral
Double_t maxRot = 0.0;
UInt_t maxRotBin = 0;
for (UInt_t i=0; i<720; i++) {
if (maxRot < rotRealIntegral[i]) {
maxRot = rotRealIntegral[i];
maxRotBin = i;
}
}
// keep the optimal phase
phase = maxRotBin*da;
// clean up
realF.clear();
imagF.clear();
// invoke the real phase optimised histo to be filled. Caller is the owner!
Char_t name[256];
Char_t title[256];
snprintf(name, sizeof(name), "%s_Fourier_PhOptRe", fData->GetName());
snprintf(title, sizeof(title), "%s_Fourier_PhOptRe", fData->GetTitle());
TH1F *realPhaseOptFourier = new TH1F(name, title, noOfFourierBins, -fResolution/2.0, (Double_t)(noOfFourierBins-1)*fResolution+fResolution/2.0);
if (realPhaseOptFourier == 0) {
fValid = false;
cerr << endl << "**SEVERE ERROR** couldn't allocate memory for the real part of the Fourier transform." << endl;
return 0;
}
// fill realFourier vector
for (UInt_t i=0; i<noOfFourierBins; i++) {
realPhaseOptFourier->SetBinContent(i+1, scale*(fOut[i][0]*cos(phase) + fOut[i][1]*sin(phase)));
realPhaseOptFourier->SetBinError(i+1, 0.0);
}
return realPhaseOptFourier;
}
//--------------------------------------------------------------------------
// GetImaginaryFourier (public)
//--------------------------------------------------------------------------
/**
* <p>returns the imaginary part Fourier as a histogram.
@ -284,7 +406,7 @@ TH1F* PFourier::GetImaginaryFourier(const Double_t scale)
}
//--------------------------------------------------------------------------
// GetPowerFourier
// GetPowerFourier (public)
//--------------------------------------------------------------------------
/**
* <p>returns the Fourier power spectrum as a histogram.
@ -326,7 +448,7 @@ TH1F* PFourier::GetPowerFourier(const Double_t scale)
}
//--------------------------------------------------------------------------
// GetPhaseFourier
// GetPhaseFourier (public)
//--------------------------------------------------------------------------
/**
* <p>returns the Fourier phase spectrum as a histogram.
@ -385,7 +507,7 @@ TH1F* PFourier::GetPhaseFourier(const Double_t scale)
}
//--------------------------------------------------------------------------
// PrepareFFTwInputData
// PrepareFFTwInputData (private)
//--------------------------------------------------------------------------
/**
* <p>Feeds the Fourier data and apply the apodization.
@ -434,7 +556,7 @@ void PFourier::PrepareFFTwInputData(UInt_t apodizationTag)
}
//--------------------------------------------------------------------------
// ApodizeData
// ApodizeData (private)
//--------------------------------------------------------------------------
/**
* <p>Carries out the appodization of the data.

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2009-2014 by Bastian M. Wojek / Andreas Suter *
* Copyright (C) 2009-2016 by Bastian M. Wojek / Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
@ -170,7 +170,7 @@ int PMsr2Data::DetermineRunNumberDigits(unsigned int runNo, bool normalMode) con
string::size_type loc = firstOnLine.rfind(tempRunNumber.str());
if ( loc != string::npos ) {
while ( loc > 0 ) {
if(isdigit(firstOnLine.at(--loc))) {
if (isdigit(firstOnLine.at(--loc))) {
++fRunNumberDigits;
} else {
break;
@ -731,7 +731,7 @@ bool PMsr2Data::PrepareGlobalInputFile(unsigned int tempRun, const string &msrOu
msrParamList->at(i).fIsGlobal = true;
++fNumGlobalParam;
}
//cout << msrParamList->at(i).fNo << " is global: " << msrParamList->at(i).fIsGlobal << endl;
// cout << "debug> " << msrParamList->at(i).fNo << ": " << msrParamList->at(i).fName.Data() << " is global: " << msrParamList->at(i).fIsGlobal << endl;
}
// check if parameters have been sorted correctly from the beginning
@ -760,7 +760,7 @@ bool PMsr2Data::PrepareGlobalInputFile(unsigned int tempRun, const string &msrOu
bool mapExists(false);
for (unsigned int i(0); i < tempLines->size(); ++i) {
line = (*tempLines)[i].fLine.Data();
split( tempVec, line, is_any_of(" \t") ); // split the theory line at spaces
split( tempVec, line, is_any_of(" \t"), token_compress_on ); // split the theory line at spaces
for (unsigned int j(1); j < tempVec.size(); ++j) {
try {
tempPar = boost::lexical_cast<unsigned int>(tempVec[j]);
@ -1060,12 +1060,11 @@ bool PMsr2Data::PrepareGlobalInputFile(unsigned int tempRun, const string &msrOu
tempLines = fMsrHandler->GetMsrTheory();
for (unsigned int i(0); i < tempLines->size(); ++i) {
line = (*tempLines)[i].fLine.Data();
split( tempVec, line, is_any_of(" \t") ); // split the theory line at spaces
split( tempVec, line, is_any_of(" \t"), token_compress_on ); // split the theory line at spaces
for (unsigned int j(1); j < tempVec.size(); ++j) {
try {
tempPar = boost::lexical_cast<unsigned int>(tempVec[j]);
if (!msrParamList->at(tempPar - 1).fIsGlobal) {
cerr << endl << ">> msr2data: **WARNING** The parameter " << msrParamList->at(tempPar - 1).fName.Data() \
<< " is recognized as run specific!";
@ -1112,7 +1111,6 @@ bool PMsr2Data::PrepareGlobalInputFile(unsigned int tempRun, const string &msrOu
lineChanged = true;
}
}
break;
}
catch(boost::bad_lexical_cast &) {
// in case the cast does not work: do nothing - this means the entry is not a simple parameter
@ -2444,7 +2442,7 @@ void PMsr2Data::WriteValue(fstream &outFile, const double &value, const unsigned
if ((fabs(value) >= 1.0e6) || ((fabs(value) < 1.0e-4) && (fabs(value) > 0.0)))
outFile << scientific << setprecision(width - 8);
else
outFile.setf(ios::floatfield);
outFile.unsetf(ios::floatfield);
outFile << setw(width) << left << value;
}
@ -2469,7 +2467,7 @@ void PMsr2Data::WriteValue(fstream &outFile, const double &value, const double &
if ((fabs(value) >= 1.0e6) || ((fabs(value) < 1.0e-4) && (fabs(value) > 0)))
outFile << scientific;
else
outFile.setf(ios::floatfield);
outFile.unsetf(ios::floatfield);
outFile.precision(prec);
outFile << setw(width) << left << value;

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
@ -242,7 +242,7 @@ Int_t PMsrHandler::ReadMsrFile()
if (result == PMUSR_SUCCESS)
if (!HandleFunctionsEntry(functions))
result = PMUSR_MSR_SYNTAX_ERROR;
if (result == PMUSR_SUCCESS)
if ((result == PMUSR_SUCCESS) && (global.size()>0))
if (!HandleGlobalEntry(global))
result = PMUSR_MSR_SYNTAX_ERROR;
if (result == PMUSR_SUCCESS)
@ -311,6 +311,11 @@ Int_t PMsrHandler::ReadMsrFile()
if (!CheckAddRunParameters())
result = PMUSR_MSR_SYNTAX_ERROR;
// check that if RRF settings are present, the RUN block settings do correspond
if (result == PMUSR_SUCCESS)
if (!CheckRRFSettings())
result = PMUSR_MSR_SYNTAX_ERROR;
if (result == PMUSR_SUCCESS) {
CheckMaxLikelihood(); // check if the user wants to use max likelihood with asymmetry/non-muSR fit (which is not implemented)
CheckLegacyLifetimecorrection(); // check if lifetimecorrection is found in RUN blocks, if yes transfer it to PLOT blocks
@ -348,7 +353,7 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
{
const UInt_t prec = 6; // default output precision for float/doubles
UInt_t neededPrec = 0;
UInt_t neededWidth = 9;
UInt_t neededWidth = 9;
Int_t tag, lineNo = 0, number;
Int_t runNo = -1, addRunNo = 0;
@ -612,9 +617,15 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
case MSR_FITTYPE_SINGLE_HISTO:
fout << left << "fittype" << MSR_FITTYPE_SINGLE_HISTO << " (single histogram fit)" << endl;
break;
case MSR_FITTYPE_SINGLE_HISTO_RRF:
fout << left << "fittype" << MSR_FITTYPE_SINGLE_HISTO_RRF << " (single histogram RRF fit)" << endl;
break;
case MSR_FITTYPE_ASYM:
fout << left << "fittype" << MSR_FITTYPE_ASYM << " (asymmetry fit)" << endl ;
break;
case MSR_FITTYPE_ASYM_RRF:
fout << left << "fittype" << MSR_FITTYPE_ASYM_RRF << " (asymmetry RRF fit)" << endl ;
break;
case MSR_FITTYPE_MU_MINUS:
fout << left << "fittype" << MSR_FITTYPE_MU_MINUS << " (mu minus fit)" << endl ;
break;
@ -624,6 +635,27 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
default:
break;
}
} else if (sstr.BeginsWith("rrf_freq", TString::kIgnoreCase) && (fGlobal.GetFitType() == MSR_FITTYPE_SINGLE_HISTO_RRF)) {
fout.width(16);
fout << left << "rrf_freq ";
fout.width(8);
neededPrec = LastSignificant(fGlobal.GetRRFFreq(fGlobal.GetRRFUnit().Data()),10);
fout.precision(neededPrec);
fout << left << fixed << fGlobal.GetRRFFreq(fGlobal.GetRRFUnit().Data());
fout << " " << fGlobal.GetRRFUnit();
fout << endl;
} else if (sstr.BeginsWith("rrf_phase", TString::kIgnoreCase) && (fGlobal.GetFitType() == MSR_FITTYPE_SINGLE_HISTO_RRF)) {
fout.width(16);
fout << "rrf_phase ";
fout.width(8);
fout << left << fGlobal.GetRRFPhase();
fout << endl;
} else if (sstr.BeginsWith("rrf_packing", TString::kIgnoreCase) && (fGlobal.GetFitType() == MSR_FITTYPE_SINGLE_HISTO_RRF)) {
fout.width(16);
fout << "rrf_packing ";
fout.width(8);
fout << left << fGlobal.GetRRFPacking();
fout << endl;
} else if (sstr.BeginsWith("data")) {
fout.width(16);
fout << left << "data";
@ -749,9 +781,15 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
case MSR_FITTYPE_SINGLE_HISTO:
fout << left << "fittype" << MSR_FITTYPE_SINGLE_HISTO << " (single histogram fit)" << endl;
break;
case MSR_FITTYPE_SINGLE_HISTO_RRF:
fout << left << "fittype" << MSR_FITTYPE_SINGLE_HISTO_RRF << " (single histogram RRF fit)" << endl;
break;
case MSR_FITTYPE_ASYM:
fout << left << "fittype" << MSR_FITTYPE_ASYM << " (asymmetry fit)" << endl ;
break;
case MSR_FITTYPE_ASYM_RRF:
fout << left << "fittype" << MSR_FITTYPE_ASYM_RRF << " (asymmetry RRF fit)" << endl ;
break;
case MSR_FITTYPE_MU_MINUS:
fout << left << "fittype" << MSR_FITTYPE_MU_MINUS << " (mu minus fit)" << endl ;
break;
@ -1089,6 +1127,11 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
} else if (sstr.BeginsWith("range_for_phase_correction")) {
fout << "range_for_phase_correction " << fFourier.fRangeForPhaseCorrection[0] << " " << fFourier.fRangeForPhaseCorrection[1] << endl;
} else if (sstr.BeginsWith("range ")) {
fout.setf(ios::fixed,ios::floatfield);
neededPrec = LastSignificant(fFourier.fPlotRange[0]);
if (LastSignificant(fFourier.fPlotRange[1]) > neededPrec)
neededPrec = LastSignificant(fFourier.fPlotRange[1]);
fout.precision(neededPrec);
fout << "range " << fFourier.fPlotRange[0] << " " << fFourier.fPlotRange[1] << endl;
} else {
fout << str.Data() << endl;
@ -1102,9 +1145,15 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
case MSR_PLOT_SINGLE_HISTO:
fout << "PLOT " << fPlots[plotNo].fPlotType << " (single histo plot)" << endl;
break;
case MSR_PLOT_SINGLE_HISTO_RRF:
fout << "PLOT " << fPlots[plotNo].fPlotType << " (single histo RRF plot)" << endl;
break;
case MSR_PLOT_ASYM:
fout << "PLOT " << fPlots[plotNo].fPlotType << " (asymmetry plot)" << endl;
break;
case MSR_PLOT_ASYM_RRF:
fout << "PLOT " << fPlots[plotNo].fPlotType << " (asymmetry RRF plot)" << endl;
break;
case MSR_PLOT_MU_MINUS:
fout << "PLOT " << fPlots[plotNo].fPlotType << " (mu minus plot)" << endl;
break;
@ -1590,7 +1639,136 @@ Int_t PMsrHandler::WriteMsrFile(const Char_t *filename, map<UInt_t, TString> *co
// write GLOBAL block
if (fGlobal.IsPresent()) {
// not sure that anything needs to be done here ...
fout << "GLOBAL" << endl;
// fittype
if (fGlobal.GetFitType() != -1) {
fout.width(16);
switch (fGlobal.GetFitType()) {
case MSR_FITTYPE_SINGLE_HISTO:
fout << left << "fittype" << MSR_FITTYPE_SINGLE_HISTO << " (single histogram fit)" << endl;
break;
case MSR_FITTYPE_SINGLE_HISTO_RRF:
fout << left << "fittype" << MSR_FITTYPE_SINGLE_HISTO_RRF << " (single histogram RRF fit)" << endl;
break;
case MSR_FITTYPE_ASYM:
fout << left << "fittype" << MSR_FITTYPE_ASYM << " (asymmetry fit)" << endl ;
break;
case MSR_FITTYPE_ASYM_RRF:
fout << left << "fittype" << MSR_FITTYPE_ASYM_RRF << " (asymmetry RRF fit)" << endl ;
break;
case MSR_FITTYPE_MU_MINUS:
fout << left << "fittype" << MSR_FITTYPE_MU_MINUS << " (mu minus fit)" << endl ;
break;
case MSR_FITTYPE_NON_MUSR:
fout << left << "fittype" << MSR_FITTYPE_NON_MUSR << " (non muSR fit)" << endl ;
break;
default:
break;
}
}
// RRF related stuff
if ((fGlobal.GetRRFFreq(fGlobal.GetRRFUnit().Data()) > 0.0) && (fGlobal.GetFitType() == MSR_FITTYPE_SINGLE_HISTO_RRF)) {
fout.width(16);
fout << left << "rrf_freq ";
fout.width(8);
fout << left << fGlobal.GetRRFFreq(fGlobal.GetRRFUnit().Data());
fout << " " << fGlobal.GetRRFUnit();
fout << endl;
}
if ((fGlobal.GetRRFPhase() != 0.0) && (fGlobal.GetFitType() == MSR_FITTYPE_SINGLE_HISTO_RRF)) {
fout.width(16);
fout << "rrf_phase ";
fout.width(8);
fout << left << fGlobal.GetRRFPhase();
fout << endl;
}
if ((fGlobal.GetRRFPacking() != -1) && (fGlobal.GetFitType() == MSR_FITTYPE_SINGLE_HISTO_RRF)) {
fout.width(16);
fout << "rrf_packing ";
fout.width(8);
fout << left << fGlobal.GetRRFPacking();
fout << endl;
}
// data range
if ((fGlobal.GetDataRange(0) != -1) || (fGlobal.GetDataRange(1) != -1) || (fGlobal.GetDataRange(2) != -1) || (fGlobal.GetDataRange(3) != -1)) {
fout.width(16);
fout << left << "data";
for (UInt_t j=0; j<4; ++j) {
if (fGlobal.GetDataRange(j) > 0) {
fout.width(8);
fout << left << fGlobal.GetDataRange(j);
}
}
fout << endl;
}
// t0
if (fGlobal.GetT0BinSize() > 0) {
fout.width(16);
fout << left << "t0";
for (UInt_t j=0; j<fGlobal.GetT0BinSize(); ++j) {
fout.width(8);
fout.precision(1);
fout.setf(ios::fixed,ios::floatfield);
fout << left << fGlobal.GetT0Bin(j);
}
fout << endl;
}
// addt0
for (UInt_t j = 0; j < fGlobal.GetAddT0BinEntries(); ++j) {
if (fGlobal.GetAddT0BinSize(j) > 0) {
fout.width(16);
fout << left << "addt0";
for (Int_t k=0; k<fGlobal.GetAddT0BinSize(j); ++k) {
fout.width(8);
fout.precision(1);
fout.setf(ios::fixed,ios::floatfield);
fout << left << fGlobal.GetAddT0Bin(j, k);
}
fout << endl;
}
}
// fit range
if ( (fGlobal.IsFitRangeInBin() && fGlobal.GetFitRangeOffset(0) != -1) ||
(fGlobal.GetFitRange(0) != PMUSR_UNDEFINED) ) {
fout.width(16);
fout << left << "fit";
if (fGlobal.IsFitRangeInBin()) { // fit range given in bins
fout << "fgb";
if (fGlobal.GetFitRangeOffset(0) > 0)
fout << "+" << fGlobal.GetFitRangeOffset(0);
fout << " lgb";
if (fGlobal.GetFitRangeOffset(1) > 0)
fout << "-" << fGlobal.GetFitRangeOffset(1);
} else { // fit range given in time
for (UInt_t j=0; j<2; j++) {
if (fGlobal.GetFitRange(j) == -1)
break;
UInt_t neededWidth = 7;
UInt_t neededPrec = LastSignificant(fRuns[i].GetFitRange(j));
fout.width(neededWidth);
fout.precision(neededPrec);
fout << left << fixed << fGlobal.GetFitRange(j);
if (j==0)
fout << " ";
}
}
fout << endl;
}
// packing
if (fGlobal.GetPacking() != -1) {
fout.width(16);
fout << left << "packing";
fout << fGlobal.GetPacking() << endl;
}
fout << endl << hline.Data() << endl;
}
// write RUN blocks
@ -1655,22 +1833,30 @@ Int_t PMsrHandler::WriteMsrFile(const Char_t *filename, map<UInt_t, TString> *co
}
// fittype
fout.width(16);
switch (fRuns[i].GetFitType()) {
case MSR_FITTYPE_SINGLE_HISTO:
fout << left << "fittype" << MSR_FITTYPE_SINGLE_HISTO << " (single histogram fit)" << endl;
break;
case MSR_FITTYPE_ASYM:
fout << left << "fittype" << MSR_FITTYPE_ASYM << " (asymmetry fit)" << endl ;
break;
case MSR_FITTYPE_MU_MINUS:
fout << left << "fittype" << MSR_FITTYPE_MU_MINUS << " (mu minus fit)" << endl ;
break;
case MSR_FITTYPE_NON_MUSR:
fout << left << "fittype" << MSR_FITTYPE_NON_MUSR << " (non muSR fit)" << endl ;
break;
default:
break;
if (fRuns[i].GetFitType() != -1) {
fout.width(16);
switch (fRuns[i].GetFitType()) {
case MSR_FITTYPE_SINGLE_HISTO:
fout << left << "fittype" << MSR_FITTYPE_SINGLE_HISTO << " (single histogram fit)" << endl;
break;
case MSR_FITTYPE_SINGLE_HISTO_RRF:
fout << left << "fittype" << MSR_FITTYPE_SINGLE_HISTO_RRF << " (single histogram RRF fit)" << endl;
break;
case MSR_FITTYPE_ASYM:
fout << left << "fittype" << MSR_FITTYPE_ASYM << " (asymmetry fit)" << endl ;
break;
case MSR_FITTYPE_ASYM_RRF:
fout << left << "fittype" << MSR_FITTYPE_ASYM_RRF << " (asymmetry RRF fit)" << endl ;
break;
case MSR_FITTYPE_MU_MINUS:
fout << left << "fittype" << MSR_FITTYPE_MU_MINUS << " (mu minus fit)" << endl ;
break;
case MSR_FITTYPE_NON_MUSR:
fout << left << "fittype" << MSR_FITTYPE_NON_MUSR << " (non muSR fit)" << endl ;
break;
default:
break;
}
}
// alpha
@ -1810,17 +1996,19 @@ Int_t PMsrHandler::WriteMsrFile(const Char_t *filename, map<UInt_t, TString> *co
}
// addt0
for (UInt_t j = 0; j < fRuns[i].GetRunNameSize() - 1; ++j) {
if (fRuns[i].GetAddT0BinSize(j) > 0) {
fout.width(16);
fout << left << "addt0";
for (Int_t k=0; k<fRuns[i].GetAddT0BinSize(j); ++k) {
fout.width(8);
fout.precision(1);
fout.setf(ios::fixed,ios::floatfield);
fout << left << fRuns[i].GetAddT0Bin(j, k);
if (fRuns[i].GetAddT0BinEntries() > 0) {
for (UInt_t j = 0; j < fRuns[i].GetRunNameSize() - 1; ++j) {
if (fRuns[i].GetAddT0BinSize(j) > 0) {
fout.width(16);
fout << left << "addt0";
for (Int_t k=0; k<fRuns[i].GetAddT0BinSize(j); ++k) {
fout.width(8);
fout.precision(1);
fout.setf(ios::fixed,ios::floatfield);
fout << left << fRuns[i].GetAddT0Bin(j, k);
}
fout << endl;
}
fout << endl;
}
}
@ -1847,34 +2035,40 @@ Int_t PMsrHandler::WriteMsrFile(const Char_t *filename, map<UInt_t, TString> *co
}
// fit
fout.width(16);
fout << left << "fit";
if (fRuns[i].IsFitRangeInBin()) { // fit range given in bins
fout << "fgb";
if (fRuns[i].GetFitRangeOffset(0) > 0)
fout << "+" << fRuns[i].GetFitRangeOffset(0);
fout << " lgb";
if (fRuns[i].GetFitRangeOffset(1) > 0)
fout << "-" << fRuns[i].GetFitRangeOffset(1);
} else { // fit range given in time
for (UInt_t j=0; j<2; j++) {
if (fRuns[i].GetFitRange(j) == -1)
break;
UInt_t neededWidth = 7;
UInt_t neededPrec = LastSignificant(fRuns[i].GetFitRange(j));
fout.width(neededWidth);
fout.precision(neededPrec);
fout << left << fixed << fRuns[i].GetFitRange(j);
if (j==0)
fout << " ";
if ( (fRuns[i].IsFitRangeInBin() && fRuns[i].GetFitRangeOffset(0) != -1) ||
(fRuns[i].GetFitRange(0) != PMUSR_UNDEFINED) ) {
fout.width(16);
fout << left << "fit";
if (fRuns[i].IsFitRangeInBin()) { // fit range given in bins
fout << "fgb";
if (fRuns[i].GetFitRangeOffset(0) > 0)
fout << "+" << fRuns[i].GetFitRangeOffset(0);
fout << " lgb";
if (fRuns[i].GetFitRangeOffset(1) > 0)
fout << "-" << fRuns[i].GetFitRangeOffset(1);
} else { // fit range given in time
for (UInt_t j=0; j<2; j++) {
if (fRuns[i].GetFitRange(j) == -1)
break;
UInt_t neededWidth = 7;
UInt_t neededPrec = LastSignificant(fRuns[i].GetFitRange(j));
fout.width(neededWidth);
fout.precision(neededPrec);
fout << left << fixed << fRuns[i].GetFitRange(j);
if (j==0)
fout << " ";
}
}
fout << endl;
}
fout << endl;
// packing
fout.width(16);
fout << left << "packing";
fout << fRuns[i].GetPacking() << endl;
if (fRuns[i].GetPacking() != -1) {
fout.width(16);
fout << left << "packing";
fout << fRuns[i].GetPacking() << endl;
}
fout << endl;
}
@ -1971,6 +2165,11 @@ Int_t PMsrHandler::WriteMsrFile(const Char_t *filename, map<UInt_t, TString> *co
// range
if ((fFourier.fPlotRange[0] != -1.0) || (fFourier.fPlotRange[1] != -1.0)) {
fout.setf(ios::fixed,ios::floatfield);
UInt_t neededPrec = LastSignificant(fFourier.fPlotRange[0]);
if (LastSignificant(fFourier.fPlotRange[1]) > neededPrec)
neededPrec = LastSignificant(fFourier.fPlotRange[1]);
fout.precision(neededPrec);
fout << "range " << fFourier.fPlotRange[0] << " " << fFourier.fPlotRange[1] << endl;
}
@ -1989,9 +2188,15 @@ Int_t PMsrHandler::WriteMsrFile(const Char_t *filename, map<UInt_t, TString> *co
case MSR_PLOT_SINGLE_HISTO:
fout << "PLOT " << fPlots[i].fPlotType << " (single histo plot)" << endl;
break;
case MSR_PLOT_SINGLE_HISTO_RRF:
fout << "PLOT " << fPlots[i].fPlotType << " (single histo RRF plot)" << endl;
break;
case MSR_PLOT_ASYM:
fout << "PLOT " << fPlots[i].fPlotType << " (asymmetry plot)" << endl;
break;
case MSR_PLOT_ASYM_RRF:
fout << "PLOT " << fPlots[i].fPlotType << " (asymmetry RRF plot)" << endl;
break;
case MSR_PLOT_MU_MINUS:
fout << "PLOT " << fPlots[i].fPlotType << " (mu minus plot)" << endl;
break;
@ -2677,8 +2882,8 @@ Bool_t PMsrHandler::HandleGlobalEntry(PMsrLines &lines)
TString str;
TObjArray *tokens = 0;
TObjString *ostr = 0;
Int_t ival;
Double_t dval;
Int_t ival = 0;
Double_t dval = 0.0;
UInt_t addT0Counter = 0;
// since this routine is called, a GLOBAL block is present
@ -2709,7 +2914,9 @@ Bool_t PMsrHandler::HandleGlobalEntry(PMsrLines &lines)
if (str.IsDigit()) {
Int_t fittype = str.Atoi();
if ((fittype == MSR_FITTYPE_SINGLE_HISTO) ||
(fittype == MSR_FITTYPE_SINGLE_HISTO_RRF) ||
(fittype == MSR_FITTYPE_ASYM) ||
(fittype == MSR_FITTYPE_ASYM_RRF) ||
(fittype == MSR_FITTYPE_MU_MINUS) ||
(fittype == MSR_FITTYPE_NON_MUSR)) {
global.SetFitType(fittype);
@ -2720,6 +2927,55 @@ Bool_t PMsrHandler::HandleGlobalEntry(PMsrLines &lines)
error = true;
}
}
} else if (iter->fLine.BeginsWith("rrf_freq", TString::kIgnoreCase)) {
if (tokens->GetEntries() < 3) {
error = true;
} else {
ostr = dynamic_cast<TObjString*>(tokens->At(1));
str = ostr->GetString();
if (str.IsFloat()) {
dval = str.Atof();
if (dval <= 0.0)
error = true;
}
if (!error) {
ostr = dynamic_cast<TObjString*>(tokens->At(2));
str = ostr->GetString();
global.SetRRFFreq(dval, str.Data());
if (global.GetRRFFreq(str.Data()) == RRF_FREQ_UNDEF)
error = true;
}
}
} else if (iter->fLine.BeginsWith("rrf_packing", TString::kIgnoreCase)) {
if (tokens->GetEntries() < 2) {
error = true;
} else {
ostr = dynamic_cast<TObjString*>(tokens->At(1));
str = ostr->GetString();
if (str.IsDigit()) {
ival = str.Atoi();
if (ival > 0) {
global.SetRRFPacking(ival);
} else {
error = true;
}
} else {
error = true;
}
}
} else if (iter->fLine.BeginsWith("rrf_phase", TString::kIgnoreCase)) {
if (tokens->GetEntries() < 2) {
error = true;
} else {
ostr = dynamic_cast<TObjString*>(tokens->At(1));
str = ostr->GetString();
if (str.IsFloat()) {
dval = str.Atof();
global.SetRRFPhase(dval);
} else {
error = true;
}
}
} else if (iter->fLine.BeginsWith("data", TString::kIgnoreCase)) { // data
if (tokens->GetEntries() < 3) {
error = true;
@ -2861,29 +3117,6 @@ Bool_t PMsrHandler::HandleGlobalEntry(PMsrLines &lines)
fGlobal = global;
}
/*
cout << endl << "debug> PMsrHandler::HandleGlobalEntry: Global: fittype : " << fGlobal.GetFitType();
cout << endl << "debug> PMsrHandler::HandleGlobalEntry: Global: data bin range: ";
for (UInt_t i=0; i<4; i++) {
cout << fGlobal.GetDataRange(i) << ", ";
}
cout << endl << "debug> PMsrHandler::HandleGlobalEntry: Global: t0's : ";
for (UInt_t i=0; i<fGlobal.GetT0BinSize(); i++)
cout << fGlobal.GetT0Bin(i) << ", ";
cout << endl << "debug> PMsrHandler::HandleGlobalEntry: Global: addt0's : ";
for (UInt_t i=0; i<fGlobal.GetAddT0BinEntries(); i++) {
cout << endl << " debug> --> " << i << ": ";
for (UInt_t j=0; j<(UInt_t)fGlobal.GetAddT0BinSize(i); j++) {
cout << fGlobal.GetAddT0Bin(i,j) << ", ";
}
}
cout << endl << "debug> PMsrHandler::HandleGlobalEntry: Global: fit in bin: " << fGlobal.IsFitRangeInBin();
cout << endl << "debug> PMsrHandler::HandleGlobalEntry: Global: fit offset: " << fGlobal.GetFitRangeOffset(0) << ", " << fGlobal.GetFitRangeOffset(1);
cout << endl << "debug> PMsrHandler::HandleGlobalEntry: Global: fit : " << fGlobal.GetFitRange(0) << ", " << fGlobal.GetFitRange(1);
cout << endl << "debug> PMsrHandler::HandleGlobalEntry: Global: packing : " << fGlobal.GetPacking();
cout << endl;
*/
return !error;
}
@ -3017,7 +3250,9 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
if (str.IsDigit()) {
Int_t fittype = str.Atoi();
if ((fittype == MSR_FITTYPE_SINGLE_HISTO) ||
(fittype == MSR_FITTYPE_SINGLE_HISTO_RRF) ||
(fittype == MSR_FITTYPE_ASYM) ||
(fittype == MSR_FITTYPE_ASYM_RRF) ||
(fittype == MSR_FITTYPE_MU_MINUS) ||
(fittype == MSR_FITTYPE_NON_MUSR)) {
param.SetFitType(fittype);
@ -3188,15 +3423,19 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
if (tokens->GetEntries() < 2) {
error = true;
} else {
PIntVector group;
PUIntVector group;
str = iter->fLine;
if (ParseDetectorGrouping(str, group)) {
PStringNumberList *rl = new PStringNumberList(str.Data());
string errorMsg("");
if (rl->Parse(errorMsg, true)) {
group = rl->GetList();
for (UInt_t i=0; i<group.size(); i++) {
param.SetForwardHistoNo(group[i]);
}
} else {
error = true;
}
delete rl;
group.clear();
}
}
@ -3209,15 +3448,19 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
if (tokens->GetEntries() < 2) {
error = true;
} else {
PIntVector group;
PUIntVector group;
str = iter->fLine;
if (ParseDetectorGrouping(str, group)) {
PStringNumberList *rl = new PStringNumberList(str.Data());
string errorMsg("");
if (rl->Parse(errorMsg, true)) {
group = rl->GetList();
for (UInt_t i=0; i<group.size(); i++) {
param.SetBackwardHistoNo(group[i]);
}
} else {
error = true;
}
delete rl;
group.clear();
}
}
@ -3721,20 +3964,26 @@ Bool_t PMsrHandler::HandleFourierEntry(PMsrLines &lines)
ostr = dynamic_cast<TObjString*>(tokens->At(1));
str = ostr->GetString();
if (str.BeginsWith("par", TString::kIgnoreCase)) { // parameter value
Int_t no = 0;
if (FilterNumber(str, "par", 0, no)) {
// check that the parameter is in range
if ((Int_t)fParam.size() < no) {
if (fFourierOnly) {
cerr << endl << ">> PMsrHandler::HandleFourierEntry: **WARNING** Found phase parameter for Fourier only.";
cerr << endl << ">> This is currently not supported. Will set the phase to 0." << endl;
fourier.fPhase = 0.0;
} else {
Int_t no = 0;
if (FilterNumber(str, "par", 0, no)) {
// check that the parameter is in range
if ((Int_t)fParam.size() < no) {
error = true;
continue;
}
// keep the parameter number
fourier.fPhaseParamNo = no;
// get parameter value
fourier.fPhase = fParam[no-1].fValue;
} else {
error = true;
continue;
}
// keep the parameter number
fourier.fPhaseParamNo = no;
// get parameter value
fourier.fPhase = fParam[no-1].fValue;
} else {
error = true;
continue;
}
} else if (str.IsFloat()) { // phase value
fourier.fPhase = str.Atof();
@ -3909,39 +4158,34 @@ Bool_t PMsrHandler::HandlePlotEntry(PMsrLines &lines)
param.fLifeTimeCorrection = true;
} else if (iter1->fLine.Contains("runs", TString::kIgnoreCase)) { // handle plot runs
TComplex run;
PStringNumberList *rl;
string errorMsg;
PUIntVector runList;
switch (param.fPlotType) {
case -1:
error = true;
break;
case MSR_PLOT_SINGLE_HISTO: // like: runs 1 5 13
case MSR_PLOT_SINGLE_HISTO_RRF:
case MSR_PLOT_ASYM:
case MSR_PLOT_ASYM_RRF:
case MSR_PLOT_NON_MUSR:
case MSR_PLOT_MU_MINUS:
tokens = iter1->fLine.Tokenize(" \t");
if (!tokens) {
rl = new PStringNumberList(iter1->fLine.Data());
if (!rl->Parse(errorMsg, true)) {
cerr << endl << ">> PMsrHandler::HandlePlotEntry: **SEVERE ERROR** Couldn't tokenize PLOT in line " << iter1->fLineNo;
cerr << endl << ">> Error Message: " << errorMsg;
cerr << endl << endl;
return false;
}
if (tokens->GetEntries() < 2) { // runs missing
error = true;
} else {
for (Int_t i=1; i<tokens->GetEntries(); i++) {
ostr = dynamic_cast<TObjString*>(tokens->At(i));
str = ostr->GetString();
if (str.IsDigit()) {
run = TComplex(str.Atoi(),-1.0);
param.fRuns.push_back(run);
} else {
error = true;
}
}
runList = rl->GetList();
for (UInt_t i=0; i<runList.size(); i++) {
run = TComplex(runList[i], -1.0);
param.fRuns.push_back(run);
}
// clean up
if (tokens) {
delete tokens;
tokens = 0;
}
runList.clear();
delete rl;
break;
default:
error = true;
@ -4336,8 +4580,10 @@ Bool_t PMsrHandler::HandlePlotEntry(PMsrLines &lines)
cerr << endl << ">> [use_fit_ranges [ymin ymax]]";
cerr << endl << ">> [view_packing n]";
cerr << endl;
cerr << endl << ">> where <plot_type> is: 0=single histo asym,";
cerr << endl << ">> where <plot_type> is: 0=single histo,";
cerr << endl << ">> 1=RRF single histo,";
cerr << endl << ">> 2=forward-backward asym,";
cerr << endl << ">> 3=forward-backward RRF asym,";
cerr << endl << ">> 4=mu minus single histo,";
cerr << endl << ">> 8=non muSR.";
cerr << endl << ">> <run_list> is the list of runs, e.g. runs 1 3";
@ -5054,7 +5300,7 @@ Bool_t PMsrHandler::CheckRunBlockIntegrity()
cerr << endl << ">> forward parameter number not defined. Necessary for single histogram fits." << endl;
return false;
}
if (fRuns[i].GetNormParamNo() > static_cast<Int_t>(fParam.size())) {
if ((fRuns[i].GetNormParamNo() > static_cast<Int_t>(fParam.size())) && !fFourierOnly) {
// check if forward histogram number is a function
if (fRuns[i].GetNormParamNo() - MSR_PARAM_FUN_OFFSET > static_cast<Int_t>(fParam.size())) {
cerr << endl << ">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
@ -5090,6 +5336,53 @@ Bool_t PMsrHandler::CheckRunBlockIntegrity()
fRuns[i].SetPacking(1);
}
break;
case PRUN_SINGLE_HISTO_RRF:
// check that there is a forward parameter number
if (fRuns[i].GetForwardHistoNo() == -1) {
cerr << endl << ">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
cerr << endl << ">> forward parameter number not defined. Necessary for single histogram RRF fits." << endl;
return false;
}
if ((fRuns[i].GetNormParamNo() > static_cast<Int_t>(fParam.size())) && !fFourierOnly) {
// check if forward histogram number is a function
if (fRuns[i].GetNormParamNo() - MSR_PARAM_FUN_OFFSET > 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;
return false;
}
}
// check fit range
if (!fRuns[i].IsFitRangeInBin() && !fFourierOnly) { // fit range given as times in usec (RUN block)
if ((fRuns[i].GetFitRange(0) == PMUSR_UNDEFINED) || (fRuns[i].GetFitRange(1) == PMUSR_UNDEFINED)) { // check fit range in RUN block
if (!fGlobal.IsFitRangeInBin()) { // fit range given as times in usec (GLOBAL block)
if ((fGlobal.GetFitRange(0) == PMUSR_UNDEFINED) || (fGlobal.GetFitRange(1) == PMUSR_UNDEFINED)) { // check fit range in GLOBAL block
cerr << endl << "PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
cerr << endl << " Fit range is not defined. Necessary for single histogram fits." << endl;
return false;
}
}
}
}
// check number of T0's provided
if ((fRuns[i].GetT0BinSize() > fRuns[i].GetForwardHistoNoSize()) &&
(fGlobal.GetT0BinSize() > fRuns[i].GetForwardHistoNoSize())) {
cerr << endl << ">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
cerr << endl << ">> Found " << fRuns[i].GetT0BinSize() << " T0 entries. Expecting only " << fRuns[i].GetForwardHistoNoSize() << ". Needs to be fixed." << endl;
cerr << endl << ">> In GLOBAL block: " << fGlobal.GetT0BinSize() << " T0 entries. Expecting only " << fRuns[i].GetForwardHistoNoSize() << ". Needs to be fixed." << endl;
return false;
}
// check that RRF frequency is given
if (fGlobal.GetRRFUnitTag() == RRF_UNIT_UNDEF) {
cerr << endl << ">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** no RRF frequency found in the GLOBAL block." << endl;
return false;
}
// check that RRF packing is given
if (fGlobal.GetRRFPacking() == -1) {
cerr << endl << ">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** no RRF packing found in the GLOBAL block." << endl;
return false;
}
break;
case PRUN_ASYMMETRY:
// check alpha
if ((fRuns[i].GetAlphaParamNo() == -1) && !fFourierOnly) {
@ -5142,6 +5435,62 @@ Bool_t PMsrHandler::CheckRunBlockIntegrity()
fRuns[i].SetPacking(1);
}
break;
case PRUN_ASYMMETRY_RRF:
// check alpha
if ((fRuns[i].GetAlphaParamNo() == -1) && !fFourierOnly) {
cerr << endl << ">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
cerr << endl << ">> alpha parameter number missing which is needed for an asymmetry RRF fit.";
cerr << endl << ">> Consider to check the manual ;-)" << endl;
return false;
}
// check that there is a forward parameter number
if (fRuns[i].GetForwardHistoNo() == -1) {
cerr << endl << ">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
cerr << endl << ">> forward histogram number not defined. Necessary for asymmetry RRF fits." << endl;
return false;
}
// check that there is a backward parameter number
if (fRuns[i].GetBackwardHistoNo() == -1) {
cerr << endl << ">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
cerr << endl << ">> backward histogram number not defined. Necessary for asymmetry RRF fits." << endl;
return false;
}
// check fit range
if (!fRuns[i].IsFitRangeInBin()) { // fit range given as times in usec
if ((fRuns[i].GetFitRange(0) == PMUSR_UNDEFINED) || (fRuns[i].GetFitRange(1) == PMUSR_UNDEFINED)) {
if ((fGlobal.GetFitRange(0) == PMUSR_UNDEFINED) || (fGlobal.GetFitRange(1) == PMUSR_UNDEFINED)) {
cerr << endl << ">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
cerr << endl << ">> Fit range is not defined, also NOT present in the GLOBAL block. Necessary for asymmetry RRF fits." << endl;
return false;
}
}
}
// check number of T0's provided
if ((fRuns[i].GetT0BinSize() > 2*fRuns[i].GetForwardHistoNoSize()) &&
(fGlobal.GetT0BinSize() > 2*fRuns[i].GetForwardHistoNoSize())) {
cerr << endl << ">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
cerr << endl << ">> Found " << fRuns[i].GetT0BinSize() << " T0 entries. Expecting only " << 2*fRuns[i].GetForwardHistoNoSize() << " in forward. Needs to be fixed." << endl;
cerr << endl << ">> In GLOBAL block: " << fGlobal.GetT0BinSize() << " T0 entries. Expecting only " << 2*fRuns[i].GetForwardHistoNoSize() << ". Needs to be fixed." << endl;
return false;
}
if ((fRuns[i].GetT0BinSize() > 2*fRuns[i].GetBackwardHistoNoSize()) &&
(fGlobal.GetT0BinSize() > 2*fRuns[i].GetBackwardHistoNoSize())) {
cerr << endl << ">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
cerr << endl << ">> Found " << fRuns[i].GetT0BinSize() << " T0 entries. Expecting only " << 2*fRuns[i].GetBackwardHistoNoSize() << " in backward. Needs to be fixed." << endl;
cerr << endl << ">> In GLOBAL block: " << fGlobal.GetT0BinSize() << " T0 entries. Expecting only " << 2*fRuns[i].GetBackwardHistoNoSize() << ". Needs to be fixed." << endl;
return false;
}
// check that RRF frequency is given
if (fGlobal.GetRRFUnitTag() == RRF_UNIT_UNDEF) {
cerr << endl << ">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** no RRF frequency found in the GLOBAL block." << endl;
return false;
}
// check that RRF packing is given
if (fGlobal.GetRRFPacking() == -1) {
cerr << endl << ">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** no RRF packing found in the GLOBAL block." << endl;
return false;
}
break;
case PRUN_MU_MINUS:
// needs eventually to be implemented
break;
@ -5338,6 +5687,9 @@ Bool_t PMsrHandler::CheckFuncs()
{
Bool_t result = true;
if (fFourierOnly)
return result;
PIntVector funVec;
PIntVector funBlock;
PIntVector funLineBlockNo;
@ -5525,6 +5877,103 @@ void PMsrHandler::CheckMaxLikelihood()
}
}
//--------------------------------------------------------------------------
// CheckRRFSettings (public)
//--------------------------------------------------------------------------
/**
* <p>Make sure that if RRF settings are found in the GLOBAL section, the fit types
* in the RUN blocks correspond.
*/
Bool_t PMsrHandler::CheckRRFSettings()
{
Bool_t result = true;
Int_t fittype = fGlobal.GetFitType();
// first set of tests: if RRF parameters are set, check if RRF fit is chosen.
if (fGlobal.GetRRFFreq(fGlobal.GetRRFUnit().Data()) != RRF_FREQ_UNDEF) {
if (fittype != -1) { // check if GLOBAL fittype is set
if ((fittype != MSR_FITTYPE_SINGLE_HISTO_RRF) &&
(fittype != MSR_FITTYPE_ASYM_RRF)) {
cerr << endl << ">> PMsrHandler::CheckRRFSettings: **ERROR** found GLOBAL fittype " << fittype << " and";
cerr << endl << ">> RRF settings in the GLOBAL section. This is NOT compatible. Fix it first.";
result = false;
}
} else { // GLOBAL fittype is NOT set
for (UInt_t i=0; i<fRuns.size(); i++) {
fittype = fRuns[i].GetFitType();
if ((fittype != MSR_FITTYPE_SINGLE_HISTO_RRF) &&
(fittype != MSR_FITTYPE_ASYM_RRF)) {
cerr << endl << ">> PMsrHandler::CheckRRFSettings: **ERROR** found RUN with fittype " << fittype << " and";
cerr << endl << ">> RRF settings in the GLOBAL section. This is NOT compatible. Fix it first.";
result = false;
break;
}
}
}
} else {
if (fGlobal.GetRRFPacking() != -1) {
cerr << endl << ">> PMsrHandler::CheckRRFSettings: **WARNING** found in the GLOBAL section rrf_packing, without";
cerr << endl << ">> rrf_freq. Doesn't make any sense. Will drop rrf_packing";
cerr << endl << endl;
fGlobal.SetRRFPacking(-1);
}
if (fGlobal.GetRRFPhase() != 0.0) {
cerr << endl << ">> PMsrHandler::CheckRRFSettings: **WARNING** found in the GLOBAL section rrf_phase, without";
cerr << endl << ">> rrf_freq. Doesn't make any sense. Will drop rrf_phase";
cerr << endl << endl;
fGlobal.SetRRFPhase(0.0);
}
}
// if not a RRF fit, done at this point
if ((fittype != MSR_FITTYPE_SINGLE_HISTO_RRF) &&
(fittype != MSR_FITTYPE_ASYM_RRF)) {
return true;
}
// second set of tests: if RRF fit is chosen, do I find the necessary RRF parameters?
fittype = fGlobal.GetFitType();
if ((fittype == MSR_FITTYPE_SINGLE_HISTO_RRF) ||
(fittype == MSR_FITTYPE_ASYM_RRF)) { // make sure RRF freq and RRF packing are set
if (fGlobal.GetRRFFreq(fGlobal.GetRRFUnit().Data()) == RRF_FREQ_UNDEF) {
cerr << endl << ">> PMsrHandler::CheckRRFSettings: **ERROR** RRF fit chosen, but";
cerr << endl << ">> no RRF frequency found in the GLOBAL section! Fix it.";
return false;
}
if (fGlobal.GetRRFPacking() == -1) {
cerr << endl << ">> PMsrHandler::CheckRRFSettings: **ERROR** RRF fit chosen, but";
cerr << endl << ">> no RRF packing found in the GLOBAL section! Fix it.";
return false;
}
} else { // check single runs for RRF
UInt_t rrfFitCounter = 0;
for (UInt_t i=0; i<fRuns.size(); i++) {
fittype = fRuns[i].GetFitType();
if ((fittype == MSR_FITTYPE_SINGLE_HISTO_RRF) ||
(fittype == MSR_FITTYPE_ASYM_RRF)) { // make sure RRF freq and RRF packing are set
rrfFitCounter++;
}
}
if (rrfFitCounter != fRuns.size()) {
cerr << endl << ">> PMsrHandler::CheckRRFSettings: **ERROR** #Runs (" << fRuns.size() << ") != # RRF fits found (" << rrfFitCounter << ")";
cerr << endl << ">> This is currently not supported.";
return false;
}
if (fGlobal.GetRRFFreq(fGlobal.GetRRFUnit().Data()) == RRF_FREQ_UNDEF) {
cerr << endl << ">> PMsrHandler::CheckRRFSettings: **ERROR** RRF fit chosen, but";
cerr << endl << ">> no RRF frequency found in the GLOBAL section! Fix it.";
return false;
}
if (fGlobal.GetRRFPacking() == -1) {
cerr << endl << ">> PMsrHandler::CheckRRFSettings: **ERROR** RRF fit chosen, but";
cerr << endl << ">> no RRF packing found in the GLOBAL section! Fix it.";
return false;
}
}
return result;
}
//--------------------------------------------------------------------------
// GetGroupingString (public)
//--------------------------------------------------------------------------
@ -5658,86 +6107,6 @@ UInt_t PMsrHandler::LastSignificant(Double_t dval, UInt_t precLimit)
return lastSignificant;
}
//--------------------------------------------------------------------------
// ParseDetectorGrouping (private)
//--------------------------------------------------------------------------
/**
* <p>
*
* \param str forward/backward string to be decoded
* \param group decoded detector grouping vector
*
* <b>return:</b> true if parsing was successful, false otherwise.
*/
Bool_t PMsrHandler::ParseDetectorGrouping(TString str, PIntVector &group)
{
TObjArray *tok=0, *tok1=0;
TObjString *ostr=0;
Int_t first=0, last=0;
// change cn - cm to cn-cm. Will *NOT* handle cn - cm etc
str = str.ReplaceAll(" - ", "-");
group.clear();
tok = str.Tokenize(" \t");
// check that there are indeed enough tokens
if (tok->GetEntries() < 2) {
delete tok;
return false;
}
for (Int_t i=1; i<tok->GetEntries(); i++) {
ostr = dynamic_cast<TObjString*>(tok->At(i));
if (ostr->GetString().Contains("-")) { // hopefully a cn-cm token
tok1 = ostr->GetString().Tokenize("-");
if (tok1->GetEntries() == 2) {
ostr = dynamic_cast<TObjString*>(tok1->At(0));
if (ostr->GetString().IsDigit()) {
first = ostr->GetString().Atoi();
} else {
if (tok) delete tok;
if (tok1) delete tok1;
return false;
}
ostr = dynamic_cast<TObjString*>(tok1->At(1));
if (ostr->GetString().IsDigit()) {
last = ostr->GetString().Atoi();
} else {
if (tok) delete tok;
if (tok1) delete tok1;
return false;
}
if (last < first) {
if (tok) delete tok;
return false;
}
for (Int_t i=first; i<=last; i++)
group.push_back(i);
} else {
if (tok) delete tok;
if (tok1) delete tok1;
return false;
}
} else { // hopefully a number
if (ostr->GetString().IsDigit()) {
group.push_back(ostr->GetString().Atoi());
} else {
if (tok) delete tok;
return false;
}
}
}
// clean up
if (tok) delete tok;
if (tok1) delete tok1;
return true;
}
//--------------------------------------------------------------------------
// MakeDetectorGroupingString (private)
//--------------------------------------------------------------------------

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
@ -28,10 +28,14 @@
***************************************************************************/
#include <cassert>
#include <iostream>
using namespace std;
#include <boost/algorithm/string.hpp>
using namespace boost;
#include "TMath.h"
#include "PMusr.h"
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@ -706,6 +710,10 @@ void PRawRunData::SetTempError(const UInt_t idx, const Double_t errTemp)
PMsrGlobalBlock::PMsrGlobalBlock()
{
fGlobalPresent = false;
fRRFFreq = RRF_FREQ_UNDEF; // rotating reference frequency in units given by fRRFUnitTag. Only needed for fittype 1
fRRFUnitTag = RRF_UNIT_UNDEF; // RRF unit tag. Default: undefined
fRRFPhase = 0.0;
fRRFPacking = -1; // undefined RRF packing/rebinning
fFitType = -1; // undefined fit type
for (UInt_t i=0; i<4; i++) {
fDataRange[i] = -1; // undefined data bin range
@ -718,6 +726,135 @@ PMsrGlobalBlock::PMsrGlobalBlock()
fPacking = -1; // undefined packing/rebinning
}
//--------------------------------------------------------------------------
// GetRRFFreq (public)
//--------------------------------------------------------------------------
/**
* <p> get RRF frequency value in specific units. If units is unknown, RRF_UNDEF_FREQ will be returned.
*
* \param unit unit string in which the units shall be given
*/
Double_t PMsrGlobalBlock::GetRRFFreq(const char *unit)
{
Double_t freq = 0.0;
// check that the units given make sense
TString unitStr = unit;
Int_t unitTag = RRF_UNIT_UNDEF;
if (!unitStr.CompareTo("MHz", TString::kIgnoreCase))
unitTag = RRF_UNIT_MHz;
else if (!unitStr.CompareTo("Mc", TString::kIgnoreCase))
unitTag = RRF_UNIT_Mcs;
else if (!unitStr.CompareTo("T", TString::kIgnoreCase))
unitTag = RRF_UNIT_T;
else
return RRF_FREQ_UNDEF;
// calc the conversion factor
if (unitTag == fRRFUnitTag)
freq = fRRFFreq;
else if ((unitTag == RRF_UNIT_MHz) && (fRRFUnitTag == RRF_UNIT_Mcs))
freq = fRRFFreq/TMath::TwoPi();
else if ((unitTag == RRF_UNIT_MHz) && (fRRFUnitTag == RRF_UNIT_T))
freq = fRRFFreq*1e4*GAMMA_BAR_MUON; // 1e4 need for T -> G since GAMMA_BAR_MUON is given in MHz/G
else if ((unitTag == RRF_UNIT_Mcs) && (fRRFUnitTag == RRF_UNIT_MHz))
freq = fRRFFreq*TMath::TwoPi();
else if ((unitTag == RRF_UNIT_Mcs) && (fRRFUnitTag == RRF_UNIT_T))
freq = fRRFFreq*1e4*TMath::TwoPi()*GAMMA_BAR_MUON; // 1e4 need for T -> G since GAMMA_BAR_MUON is given in MHz/G
else if ((unitTag == RRF_UNIT_T) && (fRRFUnitTag == RRF_UNIT_MHz))
freq = fRRFFreq/GAMMA_BAR_MUON*1e-4; // 1e-4 need for G -> T since GAMMA_BAR_MUON is given in MHz/G
else if ((unitTag == RRF_UNIT_T) && (fRRFUnitTag == RRF_UNIT_Mcs))
freq = fRRFFreq/(TMath::TwoPi()*GAMMA_BAR_MUON)*1e-4; // 1e-4 need for G -> T since GAMMA_BAR_MUON is given in MHz/G
return freq;
}
//--------------------------------------------------------------------------
// SetRRFFreq (public)
//--------------------------------------------------------------------------
/**
* <p> set RRF frequency value in specific units. If units is unknown, 0.0 will be set.
*
* \param RRF frequency value
* \param unit unit string in which the units shall be given
*/
void PMsrGlobalBlock::SetRRFFreq(Double_t freq, const char *unit)
{
// check that the units given make sense
TString unitStr = unit;
Int_t unitTag = RRF_UNIT_UNDEF;
if (!unitStr.CompareTo("MHz", TString::kIgnoreCase))
unitTag = RRF_UNIT_MHz;
else if (!unitStr.CompareTo("Mc", TString::kIgnoreCase))
unitTag = RRF_UNIT_Mcs;
else if (!unitStr.CompareTo("T", TString::kIgnoreCase))
unitTag = RRF_UNIT_T;
else {
cerr << endl << ">> PMsrGlobalBlock::SetRRFFreq: **ERROR** found undefined RRF unit '" << unit << "'!";
cerr << endl << ">> Will set RRF frequency to 0.0." << endl;
fRRFFreq = 0.0;
fRRFUnitTag = RRF_UNIT_UNDEF;
}
fRRFFreq = freq;
fRRFUnitTag = unitTag;
}
//--------------------------------------------------------------------------
// GetRRFUnit (public)
//--------------------------------------------------------------------------
/**
* <p> returns RRF frequency unit.
*/
TString PMsrGlobalBlock::GetRRFUnit()
{
TString unit;
switch (fRRFUnitTag) {
case RRF_UNIT_UNDEF:
unit = TString("??");
break;
case RRF_UNIT_kHz:
unit = TString("kHz");
break;
case RRF_UNIT_MHz:
unit = TString("MHz");
break;
case RRF_UNIT_Mcs:
unit = TString("Mc");
break;
case RRF_UNIT_G:
unit = TString("G");
break;
case RRF_UNIT_T:
unit = TString("T");
break;
default:
unit = TString("??");
break;
}
return unit;
}
//--------------------------------------------------------------------------
// SetRRFPacking (public)
//--------------------------------------------------------------------------
/**
* <p> set RRF packing.
*
* \param RRF packing
*/
void PMsrGlobalBlock::SetRRFPacking(Int_t pack)
{
if (pack <= 0) {
cerr << endl << "PMsrGlobalBlock::SetRRFPacking: **WARNING** found RRF packing <= 0. Likely doesn't make any sense." << endl;
fRRFPacking = -1; // set to undefined
}
fRRFPacking = pack;
}
//--------------------------------------------------------------------------
// GetDataRange (public)
//--------------------------------------------------------------------------
@ -1741,3 +1878,167 @@ void PMsrRunBlock::SetMapGlobal(UInt_t idx, Int_t ival)
// else do nothing at the moment
return;
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// implementation PStringNumberList
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//--------------------------------------------------------------------------
// Parse (public)
//--------------------------------------------------------------------------
/**
* <p>Helper class which parses list of numbers of the following 3 forms and its combination.
* (i) list of integers separted by spaces, e.g. 1 3 7 14
* (ii) a range of integers of the form nS-nE, e.g. 13-27 which will generate 13, 14, 15, .., 26, 27
* (iii) a sequence of integers of the form nS:nE:nStep, e.g. 10:20:2 which will generate 10, 12, 14, .., 18, 20
*
* \param errorMsg error message
* \param ignoreFirstToken if true, the first parse token will be ignored
*
* @return true if parse has been successful, otherwise false
*/
bool PStringNumberList::Parse(string &errorMsg, bool ignoreFirstToken)
{
bool result=true;
vector<string> splitVec;
int ival;
// before checking tokens, remove 'forbidden' " - " and " : "
StripSpaces();
// split string into space separated tokens
split(splitVec, fString, is_any_of(" "), token_compress_on);
unsigned int start=0;
if (ignoreFirstToken)
start=1;
for (unsigned int i=start; i<splitVec.size(); i++) {
if (splitVec[i].length() != 0) { // ignore empty tokens
if (splitVec[i].find("-") != string::npos) { // check for potential range
vector<string> subSplitVec;
// split potential nS-nE token
split(subSplitVec, splitVec[i], is_any_of("-"), token_compress_on);
int start=-1, end=-1;
unsigned int count=0;
for (unsigned int j=0; j<subSplitVec.size(); j++) {
if (subSplitVec[j].length() != 0) { // ignore empty tokens
if (!IsNumber(subSplitVec[j])) {
result = false;
} else {
count++;
if (count == 1)
start = atoi(subSplitVec[j].c_str());
else if (count == 2)
end = atoi(subSplitVec[j].c_str());
else
result = false;
}
}
}
if ((start < 0) || (end < 0)) { // check that there is a vaild start and end
errorMsg = "**ERROR** start or end of a range is not valid";
result = false;
}
if (result) { // no error, hence check start and end
if (start > end) {
int swap = end;
cerr << "**WARNING** start=" << start << " > end=" << end << ", hence I will swap them" << endl;
end = start;
start = swap;
}
for (int j=start; j<=end; j++)
fList.push_back(j);
}
} else if (splitVec[i].find(":") != string::npos) { // check for potential sequence
vector<string> subSplitVec;
// split potential rStart:rEnd:rStep token
split(subSplitVec, splitVec[i], is_any_of(":"), token_compress_on);
int start=-1, end=-1, step=-1;
unsigned int count=0;
for (unsigned int j=0; j<subSplitVec.size(); j++) {
if (subSplitVec[j].length() != 0) { // ignore empty tokens
if (!IsNumber(subSplitVec[j])) {
result = false;
} else {
count++;
if (count == 1)
start = atoi(subSplitVec[j].c_str());
else if (count == 2)
end = atoi(subSplitVec[j].c_str());
else if (count == 3)
step = atoi(subSplitVec[j].c_str());
else
result = false;
}
}
}
if ((start < 0) || (end < 0) || (step < 0)) { // check that there is a vaild start and end
errorMsg = "**ERROR** start, end, or step of a sequence is not valid";
result = false;
}
if (result) { // no error, hence check start and end
if (start > end) {
int swap = end;
cerr << "**WARNING** start=" << start << " > end=" << end << ", hence I will swap them" << endl;
end = start;
start = swap;
}
for (int j=start; j<=end; j+=step)
fList.push_back(j);
}
} else if (IsNumber(splitVec[i])) {
ival = atoi(splitVec[i].c_str());
fList.push_back(ival);
} else {
errorMsg = "**ERROR** invalid token: " + splitVec[i];
result = false;
}
}
}
return result;
}
//--------------------------------------------------------------------------
// StripSpaces (private)
//--------------------------------------------------------------------------
/**
* <p>This routine removes arbitray number of spaces between '-' and ':',
* e.g. 123 - 125 will be converted to 123-125, etc.
*/
void PStringNumberList::StripSpaces()
{
string str=fString;
int pos=-1;
// backward scan
for (int i=str.size(); i>=0; --i) { // check if first space is found
if ((str[i] == ' ') && (pos == -1)) {
pos = i;
} else if ((str[i] == '-') || (str[i] == ':')) { // check for '-' or ':'
if (pos != -1) {
str.erase(i+1, pos-i);
}
} else if (str[i] != ' ') { // anything but different than a space leads to a reset of the pos counter
pos = -1;
}
}
// forward scan
for (unsigned int i=0; i<str.size(); i++) { // check if first space is found
if ((str[i] == ' ') && (pos == -1)) {
pos = i;
} else if ((str[i] == '-') || (str[i] == ':')) { // check for '-' or ':'
if (pos != -1) {
str.erase(pos, i-pos);
i = pos;
}
} else if (str[i] != ' ') { // anything but different than a space leads to a reset of the pos counter
pos = -1;
}
}
fString = str;
}

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
@ -35,10 +35,15 @@ using namespace std;
#include <TRandom.h>
#include <TROOT.h>
#include <TObjString.h>
#include <TGFileDialog.h>
#include "PMusrCanvas.h"
#include "PFourier.h"
static const char *gFiletypes[] = { "Data files", "*.dat",
"All files", "*",
0, 0 };
ClassImp(PMusrCanvasPlotRange)
//--------------------------------------------------------------------------
@ -70,7 +75,7 @@ PMusrCanvasPlotRange::PMusrCanvasPlotRange()
void PMusrCanvasPlotRange::SetXRange(Double_t xmin, Double_t xmax)
{
if (xmin > xmax) {
cerr << endl << "PMusrCanvasPlotRange::SetXRange: **WARNING** xmin > xmax, will swap them." << endl;
cerr << endl << ">> PMusrCanvasPlotRange::SetXRange(): **WARNING** xmin > xmax, will swap them." << endl;
fXmin = xmax;
fXmax = xmin;
} else {
@ -92,7 +97,7 @@ void PMusrCanvasPlotRange::SetXRange(Double_t xmin, Double_t xmax)
void PMusrCanvasPlotRange::SetYRange(Double_t ymin, Double_t ymax)
{
if (ymin > ymax) {
cerr << endl << "PMusrCanvasPlotRange::SetYRange: **WARNING** ymin > ymax, will swap them." << endl;
cerr << endl << ">> PMusrCanvasPlotRange::SetYRange(): **WARNING** ymin > ymax, will swap them." << endl;
fYmin = ymax;
fYmax = ymin;
} else {
@ -128,7 +133,6 @@ PMusrCanvas::PMusrCanvas()
fImp = 0;
fBar = 0;
fPopupMain = 0;
fPopupSave = 0;
fPopupFourier = 0;
fStyle = 0;
@ -181,8 +185,8 @@ PMusrCanvas::PMusrCanvas()
*/
PMusrCanvas::PMusrCanvas(const Int_t number, const Char_t* title,
Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh,
const Bool_t batch) :
fBatchMode(batch), fPlotNumber(number)
const Bool_t batch, const Bool_t fourier) :
fStartWithFourier(fourier), fBatchMode(batch), fPlotNumber(number)
{
fTimeout = 0;
fTimeoutTimer = 0;
@ -236,8 +240,8 @@ PMusrCanvas::PMusrCanvas(const Int_t number, const Char_t* title,
Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh,
PMsrFourierStructure fourierDefault,
const PIntVector markerList, const PIntVector colorList,
const Bool_t batch) :
fBatchMode(batch),
const Bool_t batch, const Bool_t fourier) :
fStartWithFourier(fourier), fBatchMode(batch),
fPlotNumber(number), fFourier(fourierDefault),
fMarkerList(markerList), fColorList(colorList)
{
@ -401,37 +405,76 @@ void PMusrCanvas::SetMsrHandler(PMsrHandler *msrHandler)
}
// check if RRF data are present
if ((fMsrHandler->GetMsrPlotList()->at(0).fRRFPacking > 0) &&
(fMsrHandler->GetMsrPlotList()->at(0).fRRFFreq != 0.0)) {
if (((fMsrHandler->GetMsrPlotList()->at(0).fRRFPacking > 0) &&
(fMsrHandler->GetMsrPlotList()->at(0).fRRFFreq != 0.0)) ||
(fMsrHandler->GetMsrGlobal()->GetRRFPacking() > 0 &&
fMsrHandler->GetMsrGlobal()->GetRRFUnit().CompareTo("??"))) {
fRRFLatexText = new TLatex();
fRRFLatexText->SetNDC(kTRUE);
fRRFLatexText->SetTextFont(62);
fRRFLatexText->SetTextSize(0.03);
fRRFText = new TString("RRF: ");
if (fMsrHandler->GetMsrPlotList()->at(0).fRRFUnit == RRF_UNIT_kHz) {
*fRRFText += TString("#nu_{RRF} = ");
*fRRFText += fMsrHandler->GetMsrPlotList()->at(0).fRRFFreq;
*fRRFText += TString(" (kHz)");
} else if (fMsrHandler->GetMsrPlotList()->at(0).fRRFUnit == RRF_UNIT_MHz) {
*fRRFText += TString("#nu_{RRF} = ");
*fRRFText += fMsrHandler->GetMsrPlotList()->at(0).fRRFFreq;
*fRRFText += TString(" (MHz)");
} else if (fMsrHandler->GetMsrPlotList()->at(0).fRRFUnit == RRF_UNIT_Mcs) {
*fRRFText += TString("#omega_{RRF} = ");
*fRRFText += fMsrHandler->GetMsrPlotList()->at(0).fRRFFreq;
*fRRFText += TString(" (Mc/s)");
} else if (fMsrHandler->GetMsrPlotList()->at(0).fRRFUnit == RRF_UNIT_G) {
*fRRFText += TString("B_{RRF} = ");
*fRRFText += fMsrHandler->GetMsrPlotList()->at(0).fRRFFreq;
*fRRFText += TString(" (G)");
} else if (fMsrHandler->GetMsrPlotList()->at(0).fRRFUnit == RRF_UNIT_T) {
*fRRFText += TString("B_{RRF} = ");
*fRRFText += fMsrHandler->GetMsrPlotList()->at(0).fRRFFreq;
*fRRFText += TString(" (T)");
Int_t rrfUnitTag = -1;
Double_t rrfFreq = 0.0;
if (fMsrHandler->GetMsrPlotList()->at(0).fRRFPacking > 0) { // RRF single histo PLOT
fRRFText = new TString("RRF: ");
rrfUnitTag = fMsrHandler->GetMsrPlotList()->at(0).fRRFUnit;
rrfFreq = fMsrHandler->GetMsrPlotList()->at(0).fRRFFreq;
TString rrfFreqStr("");
rrfFreqStr.Form("%.5g", rrfFreq);
if (rrfUnitTag == RRF_UNIT_kHz) {
*fRRFText += TString("#nu_{RRF} = ");
*fRRFText += rrfFreq;
*fRRFText += TString(" (kHz)");
} else if (rrfUnitTag == RRF_UNIT_MHz) {
*fRRFText += TString("#nu_{RRF} = ");
*fRRFText += rrfFreqStr;
*fRRFText += TString(" (MHz)");
} else if (rrfUnitTag == RRF_UNIT_Mcs) {
*fRRFText += TString("#omega_{RRF} = ");
*fRRFText += rrfFreqStr;
*fRRFText += TString(" (Mc/s)");
} else if (rrfUnitTag == RRF_UNIT_G) {
*fRRFText += TString("B_{RRF} = ");
*fRRFText += rrfFreqStr;
*fRRFText += TString(" (G)");
} else if (rrfUnitTag == RRF_UNIT_T) {
*fRRFText += TString("B_{RRF} = ");
*fRRFText += rrfFreqStr;
*fRRFText += TString(" (T)");
}
*fRRFText += TString(", RRF packing = ");
*fRRFText += fMsrHandler->GetMsrPlotList()->at(0).fRRFPacking;
} else { // RRF single histo FIT
fRRFText = new TString("RRF: ");
rrfUnitTag = fMsrHandler->GetMsrGlobal()->GetRRFUnitTag();
rrfFreq = fMsrHandler->GetMsrGlobal()->GetRRFFreq(fMsrHandler->GetMsrGlobal()->GetRRFUnit().Data());
TString rrfFreqStr("");
rrfFreqStr.Form("%.5g", rrfFreq);
if (rrfUnitTag == RRF_UNIT_kHz) {
*fRRFText += TString("#nu_{RRF} = ");
*fRRFText += rrfFreqStr;
*fRRFText += TString(" (kHz)");
} else if (rrfUnitTag == RRF_UNIT_MHz) {
*fRRFText += TString("#nu_{RRF} = ");
*fRRFText += rrfFreqStr;
*fRRFText += TString(" (MHz)");
} else if (rrfUnitTag == RRF_UNIT_Mcs) {
*fRRFText += TString("#omega_{RRF} = ");
*fRRFText += rrfFreqStr;
*fRRFText += TString(" (Mc/s)");
} else if (rrfUnitTag == RRF_UNIT_G) {
*fRRFText += TString("B_{RRF} = ");
*fRRFText += rrfFreqStr;
*fRRFText += TString(" (G)");
} else if (rrfUnitTag == RRF_UNIT_T) {
*fRRFText += TString("B_{RRF} = ");
*fRRFText += rrfFreqStr;
*fRRFText += TString(" (T)");
}
*fRRFText += TString(", RRF packing = ");
*fRRFText += fMsrHandler->GetMsrGlobal()->GetRRFPacking();
}
*fRRFText += TString(", RRF packing = ");
*fRRFText += fMsrHandler->GetMsrPlotList()->at(0).fRRFPacking;
}
}
@ -605,7 +648,7 @@ void PMusrCanvas::UpdateDataTheoryPad()
// first check that plot number is smaller than the maximal number of runs
if ((Int_t)plotInfo.fRuns[i] > (Int_t)runs.size()) {
fValid = false;
cerr << endl << "PMusrCanvas::UpdateDataTheoryPad: **ERROR** run plot number " << (Int_t)plotInfo.fRuns[i] << " is larger than the number of runs " << runs.size();
cerr << endl << ">> PMusrCanvas::UpdateDataTheoryPad(): **ERROR** run plot number " << (Int_t)plotInfo.fRuns[i] << " is larger than the number of runs " << runs.size();
cerr << endl;
return;
}
@ -616,7 +659,7 @@ void PMusrCanvas::UpdateDataTheoryPad()
}
if (fitType == -1) {
fValid = false;
cerr << endl << "PMusrCanvas::UpdateDataTheoryPad: **ERROR** plottype = " << fPlotType;
cerr << endl << ">> PMusrCanvas::UpdateDataTheoryPad(): **ERROR** plottype = " << fPlotType;
cerr << ", fittype = " << runs[runNo].GetFitType() << "(RUN block)/";
cerr << "fittype = " << globalBlock->GetFitType() << "(GLOBAL block). However, they have to correspond!";
cerr << endl;
@ -639,7 +682,19 @@ void PMusrCanvas::UpdateDataTheoryPad()
if (!data) { // something wrong
fValid = false;
// error message
cerr << endl << "PMusrCanvas::UpdateDataTheoryPad: **ERROR** couldn't obtain run no " << runNo << " for a single histogram plot";
cerr << endl << ">> PMusrCanvas::UpdateDataTheoryPad(): **ERROR** couldn't obtain run no " << runNo << " for a single histogram plot";
cerr << endl;
return;
}
// handle data
HandleDataSet(i, runNo, data);
break;
case MSR_FITTYPE_SINGLE_HISTO_RRF:
data = fRunList->GetSingleHistoRRF(runNo, PRunListCollection::kRunNo);
if (!data) { // something wrong
fValid = false;
// error message
cerr << endl << ">> PMusrCanvas::UpdateDataTheoryPad(): **ERROR** couldn't obtain run no " << runNo << " for a single histogram RRF plot";
cerr << endl;
return;
}
@ -651,7 +706,19 @@ void PMusrCanvas::UpdateDataTheoryPad()
if (!data) { // something wrong
fValid = false;
// error message
cerr << endl << "PMusrCanvas::UpdateDataTheoryPad: **ERROR** couldn't obtain run no " << runNo << " for a asymmetry plot";
cerr << endl << ">> PMusrCanvas::UpdateDataTheoryPad(): **ERROR** couldn't obtain run no " << runNo << " for a asymmetry plot";
cerr << endl;
return;
}
// handle data
HandleDataSet(i, runNo, data);
break;
case MSR_FITTYPE_ASYM_RRF:
data = fRunList->GetAsymmetryRRF(runNo, PRunListCollection::kRunNo);
if (!data) { // something wrong
fValid = false;
// error message
cerr << endl << ">> PMusrCanvas::UpdateDataTheoryPad(): **ERROR** couldn't obtain run no " << runNo << " for a asymmetry RRF plot";
cerr << endl;
return;
}
@ -663,7 +730,7 @@ void PMusrCanvas::UpdateDataTheoryPad()
if (!data) { // something wrong
fValid = false;
// error message
cerr << endl << "PMusrCanvas::UpdateDataTheoryPad: **ERROR** couldn't obtain run no " << runNo << " for a mu minus single histogram plot";
cerr << endl << ">> PMusrCanvas::UpdateDataTheoryPad(): **ERROR** couldn't obtain run no " << runNo << " for a mu minus single histogram plot";
cerr << endl;
return;
}
@ -675,7 +742,7 @@ void PMusrCanvas::UpdateDataTheoryPad()
if (!data) { // something wrong
fValid = false;
// error message
cerr << endl << "PMusrCanvas::UpdateDataTheoryPad: **ERROR** couldn't obtain run no " << runNo << " for a none musr data plot";
cerr << endl << ">> PMusrCanvas::UpdateDataTheoryPad(): **ERROR** couldn't obtain run no " << runNo << " for a none musr data plot";
cerr << endl;
return;
}
@ -695,7 +762,7 @@ void PMusrCanvas::UpdateDataTheoryPad()
default:
fValid = false;
// error message
cerr << endl << "PMusrCanvas::UpdateDataTheoryPad: **ERROR** wrong plottype tag?!";
cerr << endl << ">> PMusrCanvas::UpdateDataTheoryPad(): **ERROR** wrong plottype tag?!";
cerr << endl;
return;
break;
@ -703,7 +770,62 @@ void PMusrCanvas::UpdateDataTheoryPad()
}
// generate the histo plot
PlotData();
if (!fStartWithFourier || (fPlotType == MSR_PLOT_NON_MUSR)) {
PlotData();
} else { // show Fourier straight ahead.
// set the menu properly
if (!fBatchMode)
fPopupMain->UnCheckEntry(P_MENU_ID_DATA+P_MENU_PLOT_OFFSET*fPlotNumber);
// filter proper Fourier plot tag, and set the menu tags properly
switch (fFourier.fPlotTag) {
case FOURIER_PLOT_REAL:
fCurrentPlotView = PV_FOURIER_REAL;
if (!fBatchMode) {
fPopupFourier->CheckEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_REAL);
fPopupFourier->EnableEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_PLUS);
fPopupFourier->EnableEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_MINUS);
}
break;
case FOURIER_PLOT_IMAG:
fCurrentPlotView = PV_FOURIER_IMAG;
if (!fBatchMode) {
fPopupFourier->CheckEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_IMAG);
fPopupFourier->EnableEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_PLUS);
fPopupFourier->EnableEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_MINUS);
}
break;
case FOURIER_PLOT_REAL_AND_IMAG:
fCurrentPlotView = PV_FOURIER_REAL_AND_IMAG;
if (!fBatchMode) {
fPopupFourier->CheckEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_REAL_AND_IMAG);
fPopupFourier->EnableEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_PLUS);
fPopupFourier->EnableEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_MINUS);
}
break;
case FOURIER_PLOT_POWER:
fCurrentPlotView = PV_FOURIER_PWR;
if (!fBatchMode) {
fPopupFourier->CheckEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PWR);
}
break;
case FOURIER_PLOT_PHASE:
fCurrentPlotView = PV_FOURIER_PHASE;
if (!fBatchMode) {
fPopupFourier->CheckEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE);
}
break;
default:
fCurrentPlotView = PV_FOURIER_PWR;
if (!fBatchMode) {
fPopupFourier->CheckEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PWR);
}
break;
}
HandleFourier();
PlotFourier();
}
}
//--------------------------------------------------------------------------
@ -763,13 +885,15 @@ void PMusrCanvas::UpdateInfoPad()
else
tstr = *runs[runNo].GetRunName() + TString(","); // run_name
// histo info (depending on the fittype
if (runs[runNo].GetFitType() == MSR_FITTYPE_SINGLE_HISTO) {
if ((runs[runNo].GetFitType() == MSR_FITTYPE_SINGLE_HISTO) ||
(runs[runNo].GetFitType() == MSR_FITTYPE_SINGLE_HISTO_RRF)) {
tstr += TString("h:");
TString grouping;
fMsrHandler->GetGroupingString(runNo, "forward", grouping);
tstr += grouping;
tstr += TString(",");
} else if (runs[runNo].GetFitType() == MSR_FITTYPE_ASYM) {
} else if ((runs[runNo].GetFitType() == MSR_FITTYPE_ASYM) ||
(runs[runNo].GetFitType() == MSR_FITTYPE_ASYM_RRF)) {
tstr += TString("h:");
TString grouping;
fMsrHandler->GetGroupingString(runNo, "forward", grouping);
@ -1282,8 +1406,16 @@ void PMusrCanvas::HandleMenuPopup(Int_t id)
cout << "**INFO** averaging of a single data set doesn't make any sense, will ignore 'a' ..." << endl;
return;
}
} else if (id == P_MENU_ID_SAVE_DATA+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_SAVE_ASCII) {
SaveDataAscii();
} else if (id == P_MENU_ID_EXPORT_DATA+P_MENU_PLOT_OFFSET*fPlotNumber) {
static TString dir(".");
TGFileInfo fi;
fi.fFileTypes = gFiletypes;
fi.fIniDir = StrDup(dir);
fi.fOverwrite = true;
new TGFileDialog(0, fImp, kFDSave, &fi);
if (fi.fFilename && strlen(fi.fFilename)) {
ExportData(fi.fFilename);
}
}
// check if phase increment/decrement needs to be ghost
@ -1342,7 +1474,7 @@ void PMusrCanvas::SaveGraphicsAndQuit(Char_t *fileName, Char_t *graphicsFormat)
}
if (idx == -1) {
cerr << endl << "PMusrCanvas::SaveGraphicsAndQuit **ERROR**: fileName (" << fileName << ") is invalid." << endl;
cerr << endl << ">> PMusrCanvas::SaveGraphicsAndQuit(): **ERROR** fileName (" << fileName << ") is invalid." << endl;
return;
}
@ -1362,13 +1494,20 @@ void PMusrCanvas::SaveGraphicsAndQuit(Char_t *fileName, Char_t *graphicsFormat)
}
//--------------------------------------------------------------------------
// SaveDataAscii
// ExportData
//--------------------------------------------------------------------------
/**
* <p>Saves the currently seen data (data, difference, Fourier spectra, ...) in ascii column format.
*
* \param fileName file name to be used to save the data.
*/
void PMusrCanvas::SaveDataAscii()
void PMusrCanvas::ExportData(const Char_t *fileName)
{
if (fileName == 0) { // path file name NOT provided, generate a default path file name
cerr << endl << ">> PMusrCanvas::ExportData(): **ERROR** NO path file name provided. Will do nothing." << endl;
return;
}
// collect relevant data
PMusrCanvasAsciiDump dump;
PMusrCanvasAsciiDumpVector dumpVector;
@ -2014,35 +2153,13 @@ void PMusrCanvas::SaveDataAscii()
break;
}
// generate output filename
// in order to handle names with "." correctly this slightly odd data-filename generation
TObjArray *tokens = fMsrHandler->GetFileName().Tokenize(".");
TObjString *ostr;
TString str;
TString fln = TString("");
for (Int_t i=0; i<tokens->GetEntries()-1; i++) {
ostr = dynamic_cast<TObjString*>(tokens->At(i));
fln += ostr->GetString() + TString(".");
}
if (!fDifferenceView) {
fln += "data.ascii";
} else {
fln += "diff.ascii";
}
if (tokens) {
delete tokens;
tokens = 0;
}
// open file
ofstream fout;
// open output data-file
fout.open(fln.Data(), iostream::out);
fout.open(fileName, iostream::out);
if (!fout.is_open()) {
cerr << endl << ">> PMusrCanvas::SaveDataAscii: **ERROR** couldn't open file " << fln.Data() << " for writing." << endl;
cerr << endl << ">> PMusrCanvas::ExportData(): **ERROR** couldn't open file " << fileName << " for writing." << endl;
return;
}
@ -2366,7 +2483,6 @@ void PMusrCanvas::InitMusrCanvas(const Char_t* title, Int_t wtopx, Int_t wtopy,
fImp = 0;
fBar = 0;
fPopupMain = 0;
fPopupSave = 0;
fPopupFourier = 0;
fMainCanvas = 0;
@ -2382,7 +2498,7 @@ void PMusrCanvas::InitMusrCanvas(const Char_t* title, Int_t wtopx, Int_t wtopy,
canvasName += fPlotNumber;
fMainCanvas = new TCanvas(canvasName.Data(), title, wtopx, wtopy, ww, wh);
if (fMainCanvas == 0) {
cerr << endl << "PMusrCanvas::PMusrCanvas: **PANIC ERROR**: Couldn't invoke " << canvasName.Data();
cerr << endl << ">> PMusrCanvas::PMusrCanvas(): **PANIC ERROR** Couldn't invoke " << canvasName.Data();
cerr << endl;
return;
}
@ -2415,10 +2531,7 @@ void PMusrCanvas::InitMusrCanvas(const Char_t* title, Int_t wtopx, Int_t wtopy,
fPopupMain->AddEntry("Average", P_MENU_ID_AVERAGE+P_MENU_PLOT_OFFSET*fPlotNumber);
fPopupMain->AddSeparator();
fPopupSave = new TGPopupMenu();
fPopupSave->AddEntry("Save ascii", P_MENU_ID_SAVE_DATA+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_SAVE_ASCII);
fPopupMain->AddPopup("&Save Data", fPopupSave);
fPopupMain->AddEntry("Export Data", P_MENU_ID_EXPORT_DATA+P_MENU_PLOT_OFFSET*fPlotNumber);
fBar->MapSubwindows();
fBar->Layout();
@ -2431,7 +2544,7 @@ void PMusrCanvas::InitMusrCanvas(const Char_t* title, Int_t wtopx, Int_t wtopy,
// title pad
fTitlePad = new TPaveText(0.0, YTITLE, 1.0, 1.0, "NDC");
if (fTitlePad == 0) {
cerr << endl << "PMusrCanvas::PMusrCanvas: **PANIC ERROR**: Couldn't invoke fTitlePad";
cerr << endl << ">> PMusrCanvas::PMusrCanvas(): **PANIC ERROR** Couldn't invoke fTitlePad";
cerr << endl;
return;
}
@ -2443,7 +2556,7 @@ void PMusrCanvas::InitMusrCanvas(const Char_t* title, Int_t wtopx, Int_t wtopy,
// data/theory pad
fDataTheoryPad = new TPad("dataTheoryPad", "dataTheoryPad", 0.0, YINFO, XTHEO, YTITLE);
if (fDataTheoryPad == 0) {
cerr << endl << "PMusrCanvas::PMusrCanvas: **PANIC ERROR**: Couldn't invoke fDataTheoryPad";
cerr << endl << ">> PMusrCanvas::PMusrCanvas(): **PANIC ERROR** Couldn't invoke fDataTheoryPad";
cerr << endl;
return;
}
@ -2453,7 +2566,7 @@ void PMusrCanvas::InitMusrCanvas(const Char_t* title, Int_t wtopx, Int_t wtopy,
// parameter pad
fParameterPad = new TPaveText(XTHEO, 0.5, 1.0, YTITLE, "NDC");
if (fParameterPad == 0) {
cerr << endl << "PMusrCanvas::PMusrCanvas: **PANIC ERROR**: Couldn't invoke fParameterPad";
cerr << endl << ">> PMusrCanvas::PMusrCanvas(): **PANIC ERROR** Couldn't invoke fParameterPad";
cerr << endl;
return;
}
@ -2464,7 +2577,7 @@ void PMusrCanvas::InitMusrCanvas(const Char_t* title, Int_t wtopx, Int_t wtopy,
// theory pad
fTheoryPad = new TPaveText(XTHEO, 0.1, 1.0, 0.5, "NDC");
if (fTheoryPad == 0) {
cerr << endl << "PMusrCanvas::PMusrCanvas: **PANIC ERROR**: Couldn't invoke fTheoryPad";
cerr << endl << ">> PMusrCanvas::PMusrCanvas(): **PANIC ERROR** Couldn't invoke fTheoryPad";
cerr << endl;
return;
}
@ -2476,7 +2589,7 @@ void PMusrCanvas::InitMusrCanvas(const Char_t* title, Int_t wtopx, Int_t wtopy,
// info pad
fInfoPad = new TLegend(0.0, 0.0, 1.0, YINFO, "NDC");
if (fInfoPad == 0) {
cerr << endl << "PMusrCanvas::PMusrCanvas: **PANIC ERROR**: Couldn't invoke fInfoPad";
cerr << endl << ">> PMusrCanvas::PMusrCanvas(): **PANIC ERROR** Couldn't invoke fInfoPad";
cerr << endl;
return;
}
@ -2881,9 +2994,9 @@ void PMusrCanvas::HandleDataSet(UInt_t plotNo, UInt_t runNo, PRunData *data)
Double_t dval = (startFitRange - data->GetDataTimeStart())/data->GetDataTimeStep();
if (dval < 0.0) { // make sure that startBin >= 0
startBin = 0;
cerr << endl << "PMusrCanvas::HandleDataSet() **WARNING** found startBin data < 0 for 'use_fit_range', will set it to 0" << endl << endl;
cerr << endl << ">> PMusrCanvas::HandleDataSet(): **WARNING** found startBin data < 0 for 'use_fit_range', will set it to 0" << endl << endl;
} else if (dval >= (Double_t)data->GetValue()->size()) { // make sure that startBin <= length of data vector
cerr << endl << ">> PMusrCanvas::HandleDataSet() **WARNING** found startBin data=" << (UInt_t)dval << " >= data vector size=" << data->GetValue()->size() << " for 'use_fit_range',";
cerr << endl << ">> PMusrCanvas::HandleDataSet(): **WARNING** found startBin data=" << (UInt_t)dval << " >= data vector size=" << data->GetValue()->size() << " for 'use_fit_range',";
cerr << endl << ">> will set it to data vector size" << endl << endl;
startBin = data->GetValue()->size();
} else {
@ -2897,9 +3010,9 @@ void PMusrCanvas::HandleDataSet(UInt_t plotNo, UInt_t runNo, PRunData *data)
dval = (endFitRange - data->GetDataTimeStart())/data->GetDataTimeStep();
if (dval < 0.0) { // make sure that endBin >= 0
endBin = 0;
cerr << endl << "PMusrCanvas::HandleDataSet() **WARNING** found endBin data < 0 for 'use_fit_range', will set it to 0" << endl << endl;
cerr << endl << ">> PMusrCanvas::HandleDataSet(): **WARNING** found endBin data < 0 for 'use_fit_range', will set it to 0" << endl << endl;
} else if (dval >= (Double_t)data->GetValue()->size()) { // make sure that endBin <= length of data vector
cerr << endl << ">> PMusrCanvas::HandleDataSet() **WARNING** found endBin data=" << (UInt_t)dval << " >= data vector size=" << data->GetValue()->size() << " for 'use_fit_range',";
cerr << endl << ">> PMusrCanvas::HandleDataSet(): **WARNING** found endBin data=" << (UInt_t)dval << " >= data vector size=" << data->GetValue()->size() << " for 'use_fit_range',";
cerr << endl << ">> will set it to data vector size" << endl << endl;
endBin = data->GetValue()->size();
} else {
@ -2912,9 +3025,9 @@ void PMusrCanvas::HandleDataSet(UInt_t plotNo, UInt_t runNo, PRunData *data)
Double_t dval = (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin[runNo] - data->GetDataTimeStart())/data->GetDataTimeStep();
if (dval < 0.0) { // make sure that startBin >= 0
startBin = 0;
cerr << endl << "PMusrCanvas::HandleDataSet() **WARNING** found startBin data < 0 for 'sub_ranges', will set it to 0" << endl << endl;
cerr << endl << ">> PMusrCanvas::HandleDataSet(): **WARNING** found startBin data < 0 for 'sub_ranges', will set it to 0" << endl << endl;
} else if (dval >= (Double_t)data->GetValue()->size()) { // make sure that startBin <= length of data vector
cerr << endl << ">> PMusrCanvas::HandleDataSet() **WARNING** found startBin data=" << (UInt_t)dval << " >= data vector size=" << data->GetValue()->size() << " for 'sub_ranges',";
cerr << endl << ">> PMusrCanvas::HandleDataSet(): **WARNING** found startBin data=" << (UInt_t)dval << " >= data vector size=" << data->GetValue()->size() << " for 'sub_ranges',";
cerr << endl << ">> will set it to data vector size" << endl << endl;
startBin = data->GetValue()->size();
} else {
@ -2924,9 +3037,9 @@ void PMusrCanvas::HandleDataSet(UInt_t plotNo, UInt_t runNo, PRunData *data)
dval = (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmax[runNo] - data->GetDataTimeStart())/data->GetDataTimeStep();
if (dval < 0.0) { // make sure that endBin >= 0
endBin = 0;
cerr << endl << "PMusrCanvas::HandleDataSet() **WARNING** found endBin data < 0 for 'sub_ranges', will set it to 0" << endl << endl;
cerr << endl << ">> PMusrCanvas::HandleDataSet(): **WARNING** found endBin data < 0 for 'sub_ranges', will set it to 0" << endl << endl;
} else if (dval >= (Double_t)data->GetValue()->size()) { // make sure that endtBin <= length of data vector
cerr << endl << ">> PMusrCanvas::HandleDataSet() **WARNING** found endBin data=" << (UInt_t)dval << " >= data vector size=" << data->GetValue()->size() << " for 'sub_ranges',";
cerr << endl << ">> PMusrCanvas::HandleDataSet(): **WARNING** found endBin data=" << (UInt_t)dval << " >= data vector size=" << data->GetValue()->size() << " for 'sub_ranges',";
cerr << endl << ">> will set it to data vector size" << endl << endl;
endBin = data->GetValue()->size();
} else {
@ -3013,9 +3126,9 @@ void PMusrCanvas::HandleDataSet(UInt_t plotNo, UInt_t runNo, PRunData *data)
Double_t dval = (startFitRange - data->GetDataTimeStart())/data->GetTheoryTimeStep();
if (dval < 0.0) { // make sure that startBin >= 0
startBin = 0;
cerr << endl << "PMusrCanvas::HandleDataSet() **WARNING** found startBin theory < 0 for 'use_fit_range', will set it to 0" << endl << endl;
cerr << endl << ">> PMusrCanvas::HandleDataSet(): **WARNING** found startBin theory < 0 for 'use_fit_range', will set it to 0" << endl << endl;
} else if (dval >= (Double_t)data->GetTheory()->size()) { // make sure that startBin <= length of theory vector
cerr << endl << ">> PMusrCanvas::HandleDataSet() **WARNING** found startBin theory=" << (UInt_t)dval << " >= theory vector size=" << data->GetTheory()->size() << " for 'use_fit_range',";
cerr << endl << ">> PMusrCanvas::HandleDataSet(): **WARNING** found startBin theory=" << (UInt_t)dval << " >= theory vector size=" << data->GetTheory()->size() << " for 'use_fit_range',";
cerr << endl << ">> will set it to theory vector size" << endl << endl;
startBin = data->GetTheory()->size();
} else {
@ -3029,9 +3142,9 @@ void PMusrCanvas::HandleDataSet(UInt_t plotNo, UInt_t runNo, PRunData *data)
dval = (endFitRange - data->GetDataTimeStart())/data->GetTheoryTimeStep();
if (dval < 0.0) { // make sure that endBin >= 0
endBin = 0;
cerr << endl << "PMusrCanvas::HandleDataSet() **WARNING** found endBin theory < 0 for 'use_fit_range', will set it to 0" << endl << endl;
cerr << endl << ">> PMusrCanvas::HandleDataSet(): **WARNING** found endBin theory < 0 for 'use_fit_range', will set it to 0" << endl << endl;
} else if (dval >= (Double_t)data->GetTheory()->size()) { // make sure that endBin <= length of theory vector
cerr << endl << ">> PMusrCanvas::HandleDataSet() **WARNING** found endBin theory=" << (UInt_t)dval << " >= theory vector size=" << data->GetTheory()->size() << " for 'use_fit_range',";
cerr << endl << ">> PMusrCanvas::HandleDataSet(): **WARNING** found endBin theory=" << (UInt_t)dval << " >= theory vector size=" << data->GetTheory()->size() << " for 'use_fit_range',";
cerr << endl << ">> will set it to theory vector size" << endl << endl;
endBin = data->GetTheory()->size();
} else {
@ -3047,9 +3160,9 @@ void PMusrCanvas::HandleDataSet(UInt_t plotNo, UInt_t runNo, PRunData *data)
Double_t dval = (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin[runNo] -data->GetDataTimeStart())/data->GetTheoryTimeStep();
if (dval < 0.0) { // make sure that startBin >= 0
startBin = 0;
cerr << endl << "PMusrCanvas::HandleDataSet() **WARNING** found startBin theory < 0 for 'sub_ranges', will set it to 0" << endl << endl;
cerr << endl << ">> PMusrCanvas::HandleDataSet(): **WARNING** found startBin theory < 0 for 'sub_ranges', will set it to 0" << endl << endl;
} else if (dval >= (Double_t)data->GetTheory()->size()) { // make sure that startBin <= length of theory vector
cerr << endl << ">> PMusrCanvas::HandleDataSet() **WARNING** found startBin theory=" << (UInt_t)dval << " >= theory vector size=" << data->GetTheory()->size() << " for 'sub_ranges',";
cerr << endl << ">> PMusrCanvas::HandleDataSet(): **WARNING** found startBin theory=" << (UInt_t)dval << " >= theory vector size=" << data->GetTheory()->size() << " for 'sub_ranges',";
cerr << endl << ">> will set it to theory vector size" << endl << endl;
startBin = data->GetTheory()->size();
} else {
@ -3059,9 +3172,9 @@ void PMusrCanvas::HandleDataSet(UInt_t plotNo, UInt_t runNo, PRunData *data)
dval = (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmax[runNo] -data->GetDataTimeStart())/data->GetTheoryTimeStep();
if (dval < 0.0) { // make sure that endBin >= 0
endBin = 0;
cerr << endl << "PMusrCanvas::HandleDataSet() **WARNING** found endBin theory < 0 for 'sub_ranges', will set it to 0" << endl << endl;
cerr << endl << ">> PMusrCanvas::HandleDataSet(): **WARNING** found endBin theory < 0 for 'sub_ranges', will set it to 0" << endl << endl;
} else if (dval >= (Double_t)data->GetTheory()->size()) { // make sure that endtBin <= length of theory vector
cerr << endl << ">> PMusrCanvas::HandleDataSet() **WARNING** found endBin theory=" << (UInt_t)dval << " >= theory vector size=" << data->GetTheory()->size() << " for 'sub_ranges',";
cerr << endl << ">> PMusrCanvas::HandleDataSet(): **WARNING** found endBin theory=" << (UInt_t)dval << " >= theory vector size=" << data->GetTheory()->size() << " for 'sub_ranges',";
cerr << endl << ">> will set it to theory vector size" << endl << endl;
endBin = data->GetTheory()->size();
} else {
@ -3358,15 +3471,19 @@ void PMusrCanvas::HandleFourier()
// check if fourier needs to be calculated
if (fData[0].dataFourierRe == 0) {
Int_t bin;
bin = fHistoFrame->GetXaxis()->GetFirst();
double startTime = fHistoFrame->GetBinCenter(bin);
bin = fHistoFrame->GetXaxis()->GetLast();
double endTime = fHistoFrame->GetBinCenter(bin);
double startTime = fXmin;
double endTime = fXmax;
if (!fStartWithFourier) { // fHistoFrame presen, hence get start/end from it
bin = fHistoFrame->GetXaxis()->GetFirst();
startTime = fHistoFrame->GetBinCenter(bin);
bin = fHistoFrame->GetXaxis()->GetLast();
endTime = fHistoFrame->GetBinCenter(bin);
}
for (UInt_t i=0; i<fData.size(); i++) {
// calculate fourier transform of the data
PFourier fourierData(fData[i].data, fFourier.fUnits, startTime, endTime, fFourier.fDCCorrected, fFourier.fFourierPower);
if (!fourierData.IsValid()) {
cerr << endl << "**SEVERE ERROR** PMusrCanvas::HandleFourier: couldn't invoke PFourier to calculate the Fourier data ..." << endl;
cerr << endl << ">> PMusrCanvas::HandleFourier(): **SEVERE ERROR** couldn't invoke PFourier to calculate the Fourier data ..." << endl;
return;
}
fourierData.Transform(fFourier.fApodization);
@ -3406,7 +3523,7 @@ void PMusrCanvas::HandleFourier()
Int_t powerPad = (Int_t)round(log((endTime-startTime)/fData[i].theory->GetBinWidth(1))/log(2))+3;
PFourier fourierTheory(fData[i].theory, fFourier.fUnits, startTime, endTime, fFourier.fDCCorrected, powerPad);
if (!fourierTheory.IsValid()) {
cerr << endl << "**SEVERE ERROR** PMusrCanvas::HandleFourier: couldn't invoke PFourier to calculate the Fourier theory ..." << endl;
cerr << endl << ">> PMusrCanvas::HandleFourier(): **SEVERE ERROR** couldn't invoke PFourier to calculate the Fourier theory ..." << endl;
return;
}
fourierTheory.Transform(fFourier.fApodization);
@ -3526,7 +3643,7 @@ void PMusrCanvas::HandleDifferenceFourier()
// calculate fourier transform of the data
PFourier fourierData(fData[i].diff, fFourier.fUnits, startTime, endTime, fFourier.fDCCorrected, fFourier.fFourierPower);
if (!fourierData.IsValid()) {
cerr << endl << "**SEVERE ERROR** PMusrCanvas::HandleFourier: couldn't invoke PFourier to calculate the Fourier diff ..." << endl;
cerr << endl << ">> PMusrCanvas::HandleFourier(): **SEVERE ERROR** couldn't invoke PFourier to calculate the Fourier diff ..." << endl;
return;
}
fourierData.Transform(fFourier.fApodization);
@ -3800,7 +3917,7 @@ void PMusrCanvas::HandleAverage()
for (Int_t i=0; i<fData[0].data->GetNbinsX(); i++) {
dval = 0.0;
for (UInt_t j=0; j<fData.size(); j++) {
dval += GetInterpolatedValue(fData[j].data, fData[0].data->GetBinContent(i));
dval += GetInterpolatedValue(fData[j].data, fData[0].data->GetBinCenter(i));
}
fDataAvg.data->SetBinContent(i, dval/fData.size());
}
@ -3814,7 +3931,7 @@ void PMusrCanvas::HandleAverage()
for (Int_t i=0; i<fData[0].dataFourierRe->GetNbinsX(); i++) {
dval = 0.0;
for (UInt_t j=0; j<fData.size(); j++) {
dval += GetInterpolatedValue(fData[j].dataFourierRe, fData[0].dataFourierRe->GetBinContent(i));
dval += GetInterpolatedValue(fData[j].dataFourierRe, fData[0].dataFourierRe->GetBinCenter(i));
}
fDataAvg.dataFourierRe->SetBinContent(i, dval/fData.size());
}
@ -3828,7 +3945,7 @@ void PMusrCanvas::HandleAverage()
for (Int_t i=0; i<fData[0].dataFourierIm->GetNbinsX(); i++) {
dval = 0.0;
for (UInt_t j=0; j<fData.size(); j++) {
dval += GetInterpolatedValue(fData[j].dataFourierIm, fData[0].dataFourierIm->GetBinContent(i));
dval += GetInterpolatedValue(fData[j].dataFourierIm, fData[0].dataFourierIm->GetBinCenter(i));
}
fDataAvg.dataFourierIm->SetBinContent(i, dval/fData.size());
}
@ -3842,7 +3959,7 @@ void PMusrCanvas::HandleAverage()
for (Int_t i=0; i<fData[0].dataFourierPwr->GetNbinsX(); i++) {
dval = 0.0;
for (UInt_t j=0; j<fData.size(); j++) {
dval += GetInterpolatedValue(fData[j].dataFourierPwr, fData[0].dataFourierPwr->GetBinContent(i));
dval += GetInterpolatedValue(fData[j].dataFourierPwr, fData[0].dataFourierPwr->GetBinCenter(i));
}
fDataAvg.dataFourierPwr->SetBinContent(i, dval/fData.size());
}
@ -3856,7 +3973,7 @@ void PMusrCanvas::HandleAverage()
for (Int_t i=0; i<fData[0].dataFourierPhase->GetNbinsX(); i++) {
dval = 0.0;
for (UInt_t j=0; j<fData.size(); j++) {
dval += GetInterpolatedValue(fData[j].dataFourierPhase, fData[0].dataFourierPhase->GetBinContent(i));
dval += GetInterpolatedValue(fData[j].dataFourierPhase, fData[0].dataFourierPhase->GetBinCenter(i));
}
fDataAvg.dataFourierPhase->SetBinContent(i, dval/fData.size());
}
@ -3870,7 +3987,7 @@ void PMusrCanvas::HandleAverage()
for (Int_t i=0; i<fData[0].theory->GetNbinsX(); i++) {
dval = 0.0;
for (UInt_t j=0; j<fData.size(); j++) {
dval += GetInterpolatedValue(fData[j].theory, fData[0].theory->GetBinContent(i));
dval += GetInterpolatedValue(fData[j].theory, fData[0].theory->GetBinCenter(i));
}
fDataAvg.theory->SetBinContent(i, dval/fData.size());
}
@ -3880,7 +3997,7 @@ void PMusrCanvas::HandleAverage()
for (Int_t i=0; i<fData[0].theoryFourierRe->GetNbinsX(); i++) {
dval = 0.0;
for (UInt_t j=0; j<fData.size(); j++) {
dval += GetInterpolatedValue(fData[j].theoryFourierRe, fData[0].theoryFourierRe->GetBinContent(i));
dval += GetInterpolatedValue(fData[j].theoryFourierRe, fData[0].theoryFourierRe->GetBinCenter(i));
}
fDataAvg.theoryFourierRe->SetBinContent(i, dval/fData.size());
}
@ -3894,7 +4011,7 @@ void PMusrCanvas::HandleAverage()
for (Int_t i=0; i<fData[0].theoryFourierIm->GetNbinsX(); i++) {
dval = 0.0;
for (UInt_t j=0; j<fData.size(); j++) {
dval += GetInterpolatedValue(fData[j].theoryFourierIm, fData[0].theoryFourierIm->GetBinContent(i));
dval += GetInterpolatedValue(fData[j].theoryFourierIm, fData[0].theoryFourierIm->GetBinCenter(i));
}
fDataAvg.theoryFourierIm->SetBinContent(i, dval/fData.size());
}
@ -3908,7 +4025,7 @@ void PMusrCanvas::HandleAverage()
for (Int_t i=0; i<fData[0].theoryFourierPwr->GetNbinsX(); i++) {
dval = 0.0;
for (UInt_t j=0; j<fData.size(); j++) {
dval += GetInterpolatedValue(fData[j].theoryFourierPwr, fData[0].theoryFourierPwr->GetBinContent(i));
dval += GetInterpolatedValue(fData[j].theoryFourierPwr, fData[0].theoryFourierPwr->GetBinCenter(i));
}
fDataAvg.theoryFourierPwr->SetBinContent(i, dval/fData.size());
}
@ -3922,7 +4039,7 @@ void PMusrCanvas::HandleAverage()
for (Int_t i=0; i<fData[0].theoryFourierPhase->GetNbinsX(); i++) {
dval = 0.0;
for (UInt_t j=0; j<fData.size(); j++) {
dval += GetInterpolatedValue(fData[j].theoryFourierPhase, fData[0].theoryFourierPhase->GetBinContent(i));
dval += GetInterpolatedValue(fData[j].theoryFourierPhase, fData[0].theoryFourierPhase->GetBinCenter(i));
}
fDataAvg.theoryFourierPhase->SetBinContent(i, dval/fData.size());
}
@ -3936,7 +4053,7 @@ void PMusrCanvas::HandleAverage()
for (Int_t i=0; i<fData[0].diff->GetNbinsX(); i++) {
dval = 0.0;
for (UInt_t j=0; j<fData.size(); j++) {
dval += GetInterpolatedValue(fData[j].diff, fData[0].diff->GetBinContent(i));
dval += GetInterpolatedValue(fData[j].diff, fData[0].diff->GetBinCenter(i));
}
fDataAvg.diff->SetBinContent(i, dval/fData.size());
}
@ -3950,7 +4067,7 @@ void PMusrCanvas::HandleAverage()
for (Int_t i=0; i<fData[0].diffFourierRe->GetNbinsX(); i++) {
dval = 0.0;
for (UInt_t j=0; j<fData.size(); j++) {
dval += GetInterpolatedValue(fData[j].diffFourierRe, fData[0].diffFourierRe->GetBinContent(i));
dval += GetInterpolatedValue(fData[j].diffFourierRe, fData[0].diffFourierRe->GetBinCenter(i));
}
fDataAvg.diffFourierRe->SetBinContent(i, dval/fData.size());
}
@ -3964,7 +4081,7 @@ void PMusrCanvas::HandleAverage()
for (Int_t i=0; i<fData[0].diffFourierIm->GetNbinsX(); i++) {
dval = 0.0;
for (UInt_t j=0; j<fData.size(); j++) {
dval += GetInterpolatedValue(fData[j].diffFourierIm, fData[0].diffFourierIm->GetBinContent(i));
dval += GetInterpolatedValue(fData[j].diffFourierIm, fData[0].diffFourierIm->GetBinCenter(i));
}
fDataAvg.diffFourierIm->SetBinContent(i, dval/fData.size());
}
@ -3978,7 +4095,7 @@ void PMusrCanvas::HandleAverage()
for (Int_t i=0; i<fData[0].diffFourierPwr->GetNbinsX(); i++) {
dval = 0.0;
for (UInt_t j=0; j<fData.size(); j++) {
dval += GetInterpolatedValue(fData[j].diffFourierPwr, fData[0].diffFourierPwr->GetBinContent(i));
dval += GetInterpolatedValue(fData[j].diffFourierPwr, fData[0].diffFourierPwr->GetBinCenter(i));
}
fDataAvg.diffFourierPwr->SetBinContent(i, dval/fData.size());
}
@ -3992,7 +4109,7 @@ void PMusrCanvas::HandleAverage()
for (Int_t i=0; i<fData[0].diffFourierPhase->GetNbinsX(); i++) {
dval = 0.0;
for (UInt_t j=0; j<fData.size(); j++) {
dval += GetInterpolatedValue(fData[j].diffFourierPhase, fData[0].diffFourierPhase->GetBinContent(i));
dval += GetInterpolatedValue(fData[j].diffFourierPhase, fData[0].diffFourierPhase->GetBinCenter(i));
}
fDataAvg.diffFourierPhase->SetBinContent(i, dval/fData.size());
}
@ -4596,14 +4713,14 @@ void PMusrCanvas::PlotData(Bool_t unzoom)
fDataTheoryPad->SetLogy(1);
// set x-axis label
fHistoFrame->GetXaxis()->SetTitle("time (#mus)");
fHistoFrame->GetXaxis()->SetTitle("Time (#mus)");
// set y-axis label
TString yAxisTitle;
PMsrRunList *runList = fMsrHandler->GetMsrRunList();
switch (fPlotType) {
case MSR_PLOT_SINGLE_HISTO:
if (runList->at(0).IsLifetimeCorrected()) { // lifetime correction
yAxisTitle = "asymmetry";
yAxisTitle = "Asymmetry";
} else { // no liftime correction
if (fScaleN0AndBkg)
yAxisTitle = "N(t) per nsec";
@ -4611,8 +4728,12 @@ void PMusrCanvas::PlotData(Bool_t unzoom)
yAxisTitle = "N(t) per bin";
}
break;
case MSR_PLOT_SINGLE_HISTO_RRF:
case MSR_PLOT_ASYM_RRF:
yAxisTitle = "RRF Asymmetry";
break;
case MSR_PLOT_ASYM:
yAxisTitle = "asymmetry";
yAxisTitle = "Asymmetry";
break;
case MSR_PLOT_MU_MINUS:
yAxisTitle = "N(t) per bin";
@ -4728,18 +4849,22 @@ void PMusrCanvas::PlotData(Bool_t unzoom)
// add all data to fMultiGraphData
for (UInt_t i=0; i<fNonMusrData.size(); i++) {
// the next two lines are ugly but needed for the following reasons:
// the next three lines are ugly but needed for the following reasons:
// TMultiGraph is taking ownership of the TGraphErrors, hence a deep copy is needed.
// This is not resulting in a memory leak, since the TMultiGraph object will do the cleanup
TGraphErrors *ge = new TGraphErrors(*(fNonMusrData[i].data));
// Data points and model curves should be fixed on the graph and not dragged around using, e.g., the mouse.
ge->SetEditable(false);
fMultiGraphData->Add(ge, "p");
}
// add all the theory to fMultiGraphData
for (UInt_t i=0; i<fNonMusrData.size(); i++) {
// the next two lines are ugly but needed for the following reasons:
// the next three lines are ugly but needed for the following reasons:
// TMultiGraph is taking ownership of the TGraphErrors, hence a deep copy is needed.
// This is not resulting in a memory leak, since the TMultiGraph object will do the cleanup
TGraphErrors *ge = new TGraphErrors(*(fNonMusrData[i].theory));
// Data points and model curves should be fixed on the graph and not dragged around using, e.g., the mouse.
ge->SetEditable(false);
fMultiGraphData->Add(ge, "l");
}
@ -4784,6 +4909,11 @@ void PMusrCanvas::PlotData(Bool_t unzoom)
if (fMultiGraphLegend)
fMultiGraphLegend->Draw();
}
// report canvas status events in non-musr plots
if (!fMainCanvas->GetShowEventStatus()) {
fMainCanvas->ToggleEventStatus();
}
}
fDataTheoryPad->Update();
@ -4966,10 +5096,12 @@ void PMusrCanvas::PlotDifference(Bool_t unzoom)
// add all diff data to fMultiGraphDiff
for (UInt_t i=0; i<fNonMusrData.size(); i++) {
// the next two lines are ugly but needed for the following reasons:
// the next three lines are ugly but needed for the following reasons:
// TMultiGraph is taking ownership of the TGraphErrors, hence a deep copy is needed.
// This is not resulting in a memory leak, since the TMultiGraph object will do the cleaing
TGraphErrors *ge = new TGraphErrors(*(fNonMusrData[i].diff));
// Data points and model curves should be fixed on the graph and not dragged around using, e.g., the mouse.
ge->SetEditable(false);
fMultiGraphDiff->Add(ge, "p");
}
@ -6043,6 +6175,11 @@ void PMusrCanvas::PlotAverage(Bool_t unzoom)
break;
}
// check if RRF and if yes show a label
if ((fRRFText != 0) && (fRRFLatexText != 0)) {
fRRFLatexText->DrawLatex(0.1, 0.92, fRRFText->Data());
}
fDataTheoryPad->Update();
fMainCanvas->cd();

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2015 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
@ -27,6 +27,8 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <cmath>
#include "PPrepFourier.h"
//--------------------------------------------------------------------------
@ -48,10 +50,11 @@ PPrepFourier::PPrepFourier()
/**
* <p>Constructor.
*/
PPrepFourier::PPrepFourier(const Int_t *bkgRange, const Int_t packing) :
PPrepFourier::PPrepFourier(const Int_t packing, const Int_t *bkgRange, PDoubleVector bkg) :
fPacking(packing)
{
SetBkgRange(bkgRange);
SetBkg(bkg);
}
//--------------------------------------------------------------------------
@ -76,7 +79,7 @@ PPrepFourier::~PPrepFourier()
*/
void PPrepFourier::SetBkgRange(const Int_t *bkgRange)
{
int err=0;
Int_t err=0;
if (bkgRange[0] >= -1) {
fBkgRange[0] = bkgRange[0];
} else {
@ -112,6 +115,20 @@ void PPrepFourier::SetBkgRange(const Int_t *bkgRange)
}
}
//--------------------------------------------------------------------------
// SetBkgRange
//--------------------------------------------------------------------------
/**
* <p>set the background values for all the histos.
*
* \param bkg vector
*/
void PPrepFourier::SetBkg(PDoubleVector bkg)
{
for (UInt_t i=0; i<bkg.size(); i++)
fBkg.push_back(bkg[i]);
}
//--------------------------------------------------------------------------
// SetPacking
//--------------------------------------------------------------------------
@ -157,29 +174,46 @@ void PPrepFourier::DoBkgCorrection()
}
// if no bkg-range is given, nothing needs to be done
if ((fBkgRange[0] == -1) && (fBkgRange[1] == -1)) {
if ((fBkgRange[0] == -1) && (fBkgRange[1] == -1) && (fBkg.size() == 0)) {
return;
}
// make sure that the bkg range is ok
for (unsigned int i=0; i<fRawData.size(); i++) {
if ((fBkgRange[0] >= fRawData[i].rawData.size()) || (fBkgRange[1] >= fRawData[i].rawData.size())) {
cerr << endl << "PPrepFourier::DoBkgCorrection() **ERROR** bkg-range out of data-range!";
if ((fBkgRange[0] != -1) && (fBkgRange[1] != -1)) { // background range is given
// make sure that the bkg range is ok
for (UInt_t i=0; i<fRawData.size(); i++) {
if ((fBkgRange[0] >= (Int_t)fRawData[i].rawData.size()) || (fBkgRange[1] >= (Int_t)fRawData[i].rawData.size())) {
cerr << endl << "PPrepFourier::DoBkgCorrection() **ERROR** bkg-range out of data-range!";
return;
}
}
Double_t bkg=0.0;
for (UInt_t i=0; i<fRawData.size(); i++) {
// calculate the bkg for the given range
for (Int_t j=fBkgRange[0]; j<=fBkgRange[1]; j++) {
bkg += fRawData[i].rawData[j];
}
bkg /= (fBkgRange[1]-fBkgRange[0]+1);
cout << "info> background " << i << ": " << bkg << endl;
// correct data
for (UInt_t j=0; j<fData[i].size(); j++)
fData[i][j] -= bkg;
}
} else { // there might be an explicit background list
// check if there is a background list
if (fBkg.size() == 0)
return;
// check if there are as many background values than data values
if (fBkg.size() != fData.size()) {
cerr << endl << "PPrepFourier::DoBkgCorrection() **ERROR** #bkg values != #histos. Will do nothing here." << endl;
return;
}
}
Double_t bkg=0.0;
for (unsigned int i=0; i<fRawData.size(); i++) {
// calculate the bkg for the given range
for (int j=fBkgRange[0]; j<=fBkgRange[1]; j++) {
bkg += fRawData[i].rawData[j];
}
bkg /= (fBkgRange[1]-fBkgRange[0]+1);
// correct data
for (unsigned int j=0; j<fData[i].size(); j++)
fData[i][j] -= bkg;
for (UInt_t i=0; i<fData.size(); i++)
for (UInt_t j=0; j<fData[i].size(); j++)
fData[i][j] -= fBkg[i];
}
}
@ -201,10 +235,10 @@ void PPrepFourier::DoPacking()
PDoubleVector tmpData;
Double_t dval = 0.0;
for (unsigned int i=0; i<fData.size(); i++) {
for (UInt_t i=0; i<fData.size(); i++) {
tmpData.clear();
dval = 0.0;
for (unsigned int j=0; j<fData[i].size(); j++) {
for (UInt_t j=0; j<fData[i].size(); j++) {
if ((j % fPacking == 0) && (j != 0)) {
tmpData.push_back(dval);
dval = 0.0;
@ -218,20 +252,6 @@ void PPrepFourier::DoPacking()
}
}
//--------------------------------------------------------------------------
// DoFiltering
//--------------------------------------------------------------------------
/**
* <p>Not implemented yet.
*/
void PPrepFourier::DoFiltering()
{
// make sure fData are already present, and if not create the necessary data sets
if (fData.size() != fRawData.size()) {
InitData();
}
}
//--------------------------------------------------------------------------
// DoLifeTimeCorrection
//--------------------------------------------------------------------------
@ -251,9 +271,9 @@ void PPrepFourier::DoLifeTimeCorrection(Double_t fudge)
// calc exp(+t/tau)*N(t), where N(t) is already background corrected
Double_t scale;
for (unsigned int i=0; i<fData.size(); i++) {
for (UInt_t i=0; i<fData.size(); i++) {
scale = fRawData[i].timeResolution / PMUON_LIFETIME;
for (unsigned int j=0; j<fData[i].size(); j++) {
for (UInt_t j=0; j<fData[i].size(); j++) {
fData[i][j] *= exp(j*scale);
}
}
@ -261,14 +281,14 @@ void PPrepFourier::DoLifeTimeCorrection(Double_t fudge)
// calc N0
Double_t dval;
Double_t N0;
for (unsigned int i=0; i<fData.size(); i++) {
for (UInt_t i=0; i<fData.size(); i++) {
dval = 0.0;
for (unsigned int j=0; j<fData[i].size(); j++) {
for (UInt_t j=0; j<fData[i].size(); j++) {
dval += fData[i][j];
}
N0 = dval/fData[i].size();
N0 *= fudge;
for (unsigned int j=0; j<fData[i].size(); j++) {
for (UInt_t j=0; j<fData[i].size(); j++) {
fData[i][j] -= N0;
fData[i][j] /= N0;
}
@ -293,6 +313,24 @@ TString PPrepFourier::GetInfo(const UInt_t idx)
return info;
}
//--------------------------------------------------------------------------
// GetDataSetTag
//--------------------------------------------------------------------------
/**
* <p>Returns the data set tag of the object
*
* \param idx index of the object
*/
Int_t PPrepFourier::GetDataSetTag(const UInt_t idx)
{
Int_t result = -1;
if (idx < fRawData.size())
result = fRawData[idx].dataSetTag;
return result;
}
//--------------------------------------------------------------------------
// GetData
//--------------------------------------------------------------------------
@ -317,7 +355,7 @@ vector<TH1F*> PPrepFourier::GetData()
UInt_t startIdx;
UInt_t endIdx;
for (unsigned int i=0; i<fData.size(); i++) {
for (UInt_t i=0; i<fData.size(); i++) {
name = TString::Format("histo%2d", i);
dt = fRawData[i].timeResolution*fPacking;
start = fRawData[i].timeRange[0];
@ -353,7 +391,7 @@ vector<TH1F*> PPrepFourier::GetData()
}
data[i] = new TH1F(name.Data(), fRawData[i].info.Data(), size, start, end);
for (unsigned int j=startIdx; j<endIdx; j++)
for (UInt_t j=startIdx; j<endIdx; j++)
data[i]->SetBinContent(j-startIdx+1, fData[i][j]);
}
@ -410,14 +448,14 @@ TH1F *PPrepFourier::GetData(const UInt_t idx)
}
TH1F *data = new TH1F(name.Data(), fRawData[idx].info.Data(), size, start, end);
for (unsigned int i=startIdx; i<endIdx; i++)
for (UInt_t i=startIdx; i<endIdx; i++)
data->SetBinContent(i-startIdx+1, fData[idx][i]);
return data;
}
//--------------------------------------------------------------------------
// InitData
// InitData (private)
//--------------------------------------------------------------------------
/**
* <p>Copy raw-data to internal data from t0 to the size of raw-data.
@ -425,13 +463,13 @@ TH1F *PPrepFourier::GetData(const UInt_t idx)
void PPrepFourier::InitData()
{
fData.resize(fRawData.size());
unsigned int t0;
for (unsigned int i=0; i<fRawData.size(); i++) {
UInt_t t0;
for (UInt_t i=0; i<fRawData.size(); i++) {
if (fRawData[i].t0 >= 0)
t0 = fRawData[i].t0;
else
t0 = 0;
for (unsigned int j=t0; j<fRawData[i].rawData.size(); j++) {
for (UInt_t j=t0; j<fRawData[i].rawData.size(); j++) {
fData[i].push_back(fRawData[i].rawData[j]);
}
}

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
@ -87,7 +87,7 @@ PRunAsymmetry::PRunAsymmetry(PMsrHandler *msrInfo, PRunDataHandler *rawData, UIn
fPacking = fMsrInfo->GetMsrGlobal()->GetPacking();
}
if (fPacking == -1) { // this should NOT happen, somethin is severely wrong
cerr << endl << ">> PRunAsymmetry::PRunAsymmetry: **SEVERE ERROR**: Couldn't find any packing information!";
cerr << endl << ">> PRunAsymmetry::PRunAsymmetry(): **SEVERE ERROR**: Couldn't find any packing information!";
cerr << endl << ">> This is very bad :-(, will quit ...";
cerr << endl;
fValid = false;
@ -342,7 +342,7 @@ void PRunAsymmetry::SetFitRangeBin(const TString fitRange)
Int_t pos = 2*(fRunNo+1)-1;
if (pos + 1 >= tok->GetEntries()) {
cerr << endl << ">> PRunSingleHisto::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'";
cerr << endl << ">> PRunAsymmetry::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'";
cerr << endl << ">> will ignore it. Sorry ..." << endl;
} else {
// handle fgb+n0 entry
@ -370,7 +370,7 @@ void PRunAsymmetry::SetFitRangeBin(const TString fitRange)
fFitEndTime = (fGoodBins[1] - offset - fT0s[0]) * fTimeResolution;
}
} else { // error
cerr << endl << ">> PRunSingleHisto::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'";
cerr << endl << ">> PRunAsymmetry::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'";
cerr << endl << ">> will ignore it. Sorry ..." << endl;
}

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
@ -280,7 +280,8 @@ void PRunDataHandler::ReadData()
fAllDataAvailable = ReadRootFile();
} else if ((fFileFormat == "NeXus") || (fFileFormat == "nexus")) {
fAllDataAvailable = ReadNexusFile();
} else if ((fFileFormat == "PsiBin") || (fFileFormat == "psibin")) {
} else if ((fFileFormat == "PsiBin") || (fFileFormat == "psibin") ||
(fFileFormat == "PsiMdu") || (fFileFormat == "psimdu")) {
fAllDataAvailable = ReadPsiBinFile();
} else if ((fFileFormat == "Mud") || (fFileFormat == "mud")) {
fAllDataAvailable = ReadMudFile();
@ -1733,8 +1734,33 @@ Bool_t PRunDataHandler::ReadRootFile()
header->Get("RunInfo/RedGreen Offsets", ivec, ok);
if (ok) {
redGreenOffsets = ivec;
runData.SetRedGreenOffset(ivec);
// check if any2many is used and a group histo list is defined, if NOT, only take the 0-offset data!
if (fAny2ManyInfo) { // i.e. any2many is called
if (fAny2ManyInfo->groupHistoList.size() == 0) { // NO group list defined -> use only the 0-offset data
redGreenOffsets.push_back(0);
} else { // group list defined
// make sure that the group list elements is a subset of present RedGreen offsets
Bool_t found = false;
for (UInt_t i=0; i<fAny2ManyInfo->groupHistoList.size(); i++) {
found = false;
for (UInt_t j=0; j<ivec.size(); j++) {
if (fAny2ManyInfo->groupHistoList[i] == ivec[j])
found = true;
}
if (!found) {
cerr << endl << ">> PRunDataHandler::ReadRootFile: **ERROR** requested histo group " << fAny2ManyInfo->groupHistoList[i];
cerr << endl << ">> which is NOT present in the data file." << endl;
return false;
}
}
// found all requested histo groups, hence stuff it to the right places
redGreenOffsets = fAny2ManyInfo->groupHistoList;
runData.SetRedGreenOffset(fAny2ManyInfo->groupHistoList);
}
} else { // not any2many, i.e. musrfit, musrview, ...
redGreenOffsets = ivec;
runData.SetRedGreenOffset(ivec);
}
}
// check further for LEM specific stuff in RunInfo
@ -5058,7 +5084,11 @@ Bool_t PRunDataHandler::WriteWkmFile(TString fln)
if (lem_wkm_style)
cout << endl << "TOF(M3S1): nocut";
cout << endl << "Groups: " << fData[0].GetNoOfHistos();
cout << endl << "Channels: " << static_cast<UInt_t>(fData[0].GetDataBin(1)->size()/fAny2ManyInfo->rebin);
UInt_t histo0 = 1;
if (fAny2ManyInfo->groupHistoList.size() != 0) { // red/green list found
histo0 = fAny2ManyInfo->groupHistoList[0]+1; // take the first available red/green entry
}
cout << endl << "Channels: " << static_cast<UInt_t>(fData[0].GetDataBin(histo0)->size()/fAny2ManyInfo->rebin);
cout.precision(10);
cout << endl << "Resolution: " << fData[0].GetTimeResolution()*fAny2ManyInfo->rebin/1.0e3; // ns->us
cout.setf(ios::fixed,ios::floatfield); // floatfield set to fixed
@ -5147,7 +5177,11 @@ Bool_t PRunDataHandler::WritePsiBinFile(TString fln)
// run number
psibin.put_runNumber_int(fData[0].GetRunNumber());
// length of histograms
psibin.put_histoLength_bin((int)(fData[0].GetDataBin(1)->size()/fAny2ManyInfo->rebin));
UInt_t histo0 = 1;
if (fAny2ManyInfo->groupHistoList.size() != 0) { // red/green list found
histo0 = fAny2ManyInfo->groupHistoList[0]+1; // take the first available red/green entry
}
psibin.put_histoLength_bin((int)(fData[0].GetDataBin(histo0)->size()/fAny2ManyInfo->rebin));
// number of histograms
psibin.put_numberHisto_int((int)fData[0].GetNoOfHistos());
// run title = sample (10 char) / temp (10 char) / field (10 char) / orientation (10 char)
@ -5436,7 +5470,7 @@ Bool_t PRunDataHandler::WriteMudFile(TString fln)
noOfEvents = 0;
k = 0;
for (UInt_t j=0; j<dataSet->GetData()->size(); j++) {
if ((j != 0) && (j % fAny2ManyInfo->rebin == 0)) {
if ((j > 0) && (j % fAny2ManyInfo->rebin == 0)) {
data[k] = ival;
noOfEvents += ival;
k++;
@ -5621,7 +5655,7 @@ Bool_t PRunDataHandler::WriteAsciiFile(TString fln)
}
for (UInt_t i=0; i<length; i++) {
if ((i % fAny2ManyInfo->rebin) == 0) {
if ((i > 0) && ((i % fAny2ManyInfo->rebin) == 0)) {
cout << endl;
for (UInt_t j=0; j<dataRebin.size(); j++) {
cout.width(8);

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
@ -58,12 +58,24 @@ PRunListCollection::~PRunListCollection()
}
fRunSingleHistoList.clear();
for (UInt_t i=0; i<fRunSingleHistoRRFList.size(); i++) {
fRunSingleHistoRRFList[i]->CleanUp();
fRunSingleHistoRRFList[i]->~PRunSingleHistoRRF();
}
fRunSingleHistoRRFList.clear();
for (UInt_t i=0; i<fRunAsymmetryList.size(); i++) {
fRunAsymmetryList[i]->CleanUp();
fRunAsymmetryList[i]->~PRunAsymmetry();
}
fRunAsymmetryList.clear();
for (UInt_t i=0; i<fRunAsymmetryRRFList.size(); i++) {
fRunAsymmetryRRFList[i]->CleanUp();
fRunAsymmetryRRFList[i]->~PRunAsymmetryRRF();
}
fRunAsymmetryRRFList.clear();
for (UInt_t i=0; i<fRunMuMinusList.size(); i++) {
fRunMuMinusList[i]->CleanUp();
fRunMuMinusList[i]->~PRunMuMinus();
@ -106,11 +118,21 @@ Bool_t PRunListCollection::Add(Int_t runNo, EPMusrHandleTag tag)
if (!fRunSingleHistoList[fRunSingleHistoList.size()-1]->IsValid())
success = false;
break;
case PRUN_SINGLE_HISTO_RRF:
fRunSingleHistoRRFList.push_back(new PRunSingleHistoRRF(fMsrInfo, fData, runNo, tag));
if (!fRunSingleHistoRRFList[fRunSingleHistoRRFList.size()-1]->IsValid())
success = false;
break;
case PRUN_ASYMMETRY:
fRunAsymmetryList.push_back(new PRunAsymmetry(fMsrInfo, fData, runNo, tag));
if (!fRunAsymmetryList[fRunAsymmetryList.size()-1]->IsValid())
success = false;
break;
case PRUN_ASYMMETRY_RRF:
fRunAsymmetryRRFList.push_back(new PRunAsymmetryRRF(fMsrInfo, fData, runNo, tag));
if (!fRunAsymmetryRRFList[fRunAsymmetryRRFList.size()-1]->IsValid())
success = false;
break;
case PRUN_MU_MINUS:
fRunMuMinusList.push_back(new PRunMuMinus(fMsrInfo, fData, runNo, tag));
if (!fRunMuMinusList[fRunMuMinusList.size()-1]->IsValid())
@ -147,8 +169,12 @@ void PRunListCollection::SetFitRange(const TString fitRange)
{
for (UInt_t i=0; i<fRunSingleHistoList.size(); i++)
fRunSingleHistoList[i]->SetFitRangeBin(fitRange);
for (UInt_t i=0; i<fRunSingleHistoRRFList.size(); i++)
fRunSingleHistoRRFList[i]->SetFitRangeBin(fitRange);
for (UInt_t i=0; i<fRunAsymmetryList.size(); i++)
fRunAsymmetryList[i]->SetFitRangeBin(fitRange);
for (UInt_t i=0; i<fRunAsymmetryRRFList.size(); i++)
fRunAsymmetryRRFList[i]->SetFitRangeBin(fitRange);
for (UInt_t i=0; i<fRunMuMinusList.size(); i++)
fRunMuMinusList[i]->SetFitRangeBin(fitRange);
for (UInt_t i=0; i<fRunNonMusrList.size(); i++)
@ -169,8 +195,12 @@ void PRunListCollection::SetFitRange(const PDoublePairVector fitRange)
{
for (UInt_t i=0; i<fRunSingleHistoList.size(); i++)
fRunSingleHistoList[i]->SetFitRange(fitRange);
for (UInt_t i=0; i<fRunSingleHistoRRFList.size(); i++)
fRunSingleHistoRRFList[i]->SetFitRange(fitRange);
for (UInt_t i=0; i<fRunAsymmetryList.size(); i++)
fRunAsymmetryList[i]->SetFitRange(fitRange);
for (UInt_t i=0; i<fRunAsymmetryRRFList.size(); i++)
fRunAsymmetryRRFList[i]->SetFitRange(fitRange);
for (UInt_t i=0; i<fRunMuMinusList.size(); i++)
fRunMuMinusList[i]->SetFitRange(fitRange);
for (UInt_t i=0; i<fRunNonMusrList.size(); i++)
@ -198,6 +228,27 @@ Double_t PRunListCollection::GetSingleHistoChisq(const std::vector<Double_t>& pa
return chisq;
}
//--------------------------------------------------------------------------
// GetSingleHistoRRFChisq (public)
//--------------------------------------------------------------------------
/**
* <p>Calculates chi-square of <em>all</em> single histogram RRF runs of a msr-file.
*
* <b>return:</b>
* - chi-square of all single histogram RRF runs of the msr-file
*
* \param par fit parameter vector
*/
Double_t PRunListCollection::GetSingleHistoRRFChisq(const std::vector<Double_t>& par) const
{
Double_t chisq = 0.0;
for (UInt_t i=0; i<fRunSingleHistoRRFList.size(); i++)
chisq += fRunSingleHistoRRFList[i]->CalcChiSquare(par);
return chisq;
}
//--------------------------------------------------------------------------
// GetAsymmetryChisq (public)
//--------------------------------------------------------------------------
@ -219,6 +270,27 @@ Double_t PRunListCollection::GetAsymmetryChisq(const std::vector<Double_t>& par)
return chisq;
}
//--------------------------------------------------------------------------
// GetAsymmetryRRFChisq (public)
//--------------------------------------------------------------------------
/**
* <p>Calculates chi-square of <em>all</em> asymmetry RRF runs of a msr-file.
*
* <b>return:</b>
* - chi-square of all asymmetry RRF runs of the msr-file
*
* \param par fit parameter vector
*/
Double_t PRunListCollection::GetAsymmetryRRFChisq(const std::vector<Double_t>& par) const
{
Double_t chisq = 0.0;
for (UInt_t i=0; i<fRunAsymmetryRRFList.size(); i++)
chisq += fRunAsymmetryRRFList[i]->CalcChiSquare(par);
return chisq;
}
//--------------------------------------------------------------------------
// GetMuMinusChisq (public)
//--------------------------------------------------------------------------
@ -299,9 +371,15 @@ Double_t PRunListCollection::GetSingleHistoChisqExpected(const std::vector<Doubl
case PRUN_SINGLE_HISTO:
expectedChisq = fRunSingleHistoList[subIdx]->CalcChiSquareExpected(par);
break;
case PRUN_SINGLE_HISTO_RRF:
expectedChisq = fRunSingleHistoRRFList[subIdx]->CalcChiSquareExpected(par);
break;
case PRUN_ASYMMETRY:
expectedChisq = fRunAsymmetryList[subIdx]->CalcChiSquareExpected(par);
break;
case PRUN_ASYMMETRY_RRF:
expectedChisq = fRunAsymmetryRRFList[subIdx]->CalcChiSquareExpected(par);
break;
case PRUN_MU_MINUS:
expectedChisq = fRunMuMinusList[subIdx]->CalcChiSquareExpected(par);
break;
@ -336,16 +414,17 @@ Double_t PRunListCollection::GetSingleRunChisq(const std::vector<Double_t>& par,
return chisq;
}
Int_t subIdx = 0;
Int_t type = fMsrInfo->GetMsrRunList()->at(idx).GetFitType();
if (type == -1) { // i.e. not forun in the RUN block, try the GLOBAL block
if (type == -1) { // i.e. not found in the RUN block, try the GLOBAL block
type = fMsrInfo->GetMsrGlobal()->GetFitType();
}
// count how many entries of this fit-type are present up to idx
UInt_t subIdx = 0;
for (UInt_t i=0; i<idx; i++) {
if (fMsrInfo->GetMsrRunList()->at(i).GetFitType() == type)
subIdx++;
subIdx = idx;
} else { // found in the RUN block
// count how many entries of this fit-type are present up to idx
for (UInt_t i=0; i<idx; i++) {
if (fMsrInfo->GetMsrRunList()->at(i).GetFitType() == type)
subIdx++;
}
}
// return the chisq of the single run
@ -353,9 +432,15 @@ Double_t PRunListCollection::GetSingleRunChisq(const std::vector<Double_t>& par,
case PRUN_SINGLE_HISTO:
chisq = fRunSingleHistoList[subIdx]->CalcChiSquare(par);
break;
case PRUN_SINGLE_HISTO_RRF:
chisq = fRunSingleHistoRRFList[subIdx]->CalcChiSquare(par);
break;
case PRUN_ASYMMETRY:
chisq = fRunAsymmetryList[subIdx]->CalcChiSquare(par);
break;
case PRUN_ASYMMETRY_RRF:
chisq = fRunAsymmetryRRFList[subIdx]->CalcChiSquare(par);
break;
case PRUN_MU_MINUS:
chisq = fRunMuMinusList[subIdx]->CalcChiSquare(par);
break;
@ -376,7 +461,7 @@ Double_t PRunListCollection::GetSingleRunChisq(const std::vector<Double_t>& par,
* <p>Calculates log max-likelihood of <em>all</em> single histogram runs of a msr-file.
*
* <b>return:</b>
* - chi-square of all single histogram runs of the msr-file
* - log max-likelihood of all single histogram runs of the msr-file
*
* \param par fit parameter vector
*/
@ -390,6 +475,27 @@ Double_t PRunListCollection::GetSingleHistoMaximumLikelihood(const std::vector<D
return mlh;
}
//--------------------------------------------------------------------------
// GetSingleHistoRRFMaximumLikelihood (public)
//--------------------------------------------------------------------------
/**
* <p>Calculates log max-likelihood of <em>all</em> single histogram RRF runs of a msr-file.
*
* <b>return:</b>
* - log max-likelihood of all single histogram runs of the msr-file
*
* \param par fit parameter vector
*/
Double_t PRunListCollection::GetSingleHistoRRFMaximumLikelihood(const std::vector<Double_t>& par) const
{
Double_t mlh = 0.0;
for (UInt_t i=0; i<fRunSingleHistoRRFList.size(); i++)
mlh += fRunSingleHistoRRFList[i]->CalcMaxLikelihood(par);
return mlh;
}
//--------------------------------------------------------------------------
// GetAsymmetryMaximumLikelihood (public)
//--------------------------------------------------------------------------
@ -412,6 +518,28 @@ Double_t PRunListCollection::GetAsymmetryMaximumLikelihood(const std::vector<Dou
return mlh;
}
//--------------------------------------------------------------------------
// GetAsymmetryRRFMaximumLikelihood (public)
//--------------------------------------------------------------------------
/**
* <p> Since it is not clear yet how to handle asymmetry fits with max likelihood
* the chi square will be used!
*
* <b>return:</b>
* - chi-square of all asymmetry RRF runs of the msr-file
*
* \param par fit parameter vector
*/
Double_t PRunListCollection::GetAsymmetryRRFMaximumLikelihood(const std::vector<Double_t>& par) const
{
Double_t mlh = 0.0;
for (UInt_t i=0; i<fRunAsymmetryRRFList.size(); i++)
mlh += fRunAsymmetryRRFList[i]->CalcChiSquare(par);
return mlh;
}
//--------------------------------------------------------------------------
// GetMuMinusMaximumLikelihood (public)
//--------------------------------------------------------------------------
@ -419,7 +547,7 @@ Double_t PRunListCollection::GetAsymmetryMaximumLikelihood(const std::vector<Dou
* <p>Calculates log max-likelihood of <em>all</em> mu minus runs of a msr-file.
*
* <b>return:</b>
* - chi-square of all mu minus runs of the msr-file
* - log max-likelihood of all mu minus runs of the msr-file
*
* \param par fit parameter vector
*/
@ -493,9 +621,15 @@ UInt_t PRunListCollection::GetNoOfBinsFitted(const UInt_t idx) const
case PRUN_SINGLE_HISTO:
result = fRunSingleHistoList[subIdx]->GetNoOfFitBins();
break;
case PRUN_SINGLE_HISTO_RRF:
result = fRunSingleHistoRRFList[subIdx]->GetNoOfFitBins();
break;
case PRUN_ASYMMETRY:
result = fRunAsymmetryList[subIdx]->GetNoOfFitBins();
break;
case PRUN_ASYMMETRY_RRF:
result = fRunAsymmetryRRFList[subIdx]->GetNoOfFitBins();
break;
case PRUN_MU_MINUS:
result = fRunMuMinusList[subIdx]->GetNoOfFitBins();
break;
@ -526,9 +660,15 @@ UInt_t PRunListCollection::GetTotalNoOfBinsFitted() const
for (UInt_t i=0; i<fRunSingleHistoList.size(); i++)
counts += fRunSingleHistoList[i]->GetNoOfFitBins();
for (UInt_t i=0; i<fRunSingleHistoRRFList.size(); i++)
counts += fRunSingleHistoRRFList[i]->GetNoOfFitBins();
for (UInt_t i=0; i<fRunAsymmetryList.size(); i++)
counts += fRunAsymmetryList[i]->GetNoOfFitBins();
for (UInt_t i=0; i<fRunAsymmetryRRFList.size(); i++)
counts += fRunAsymmetryRRFList[i]->GetNoOfFitBins();
for (UInt_t i=0; i<fRunMuMinusList.size(); i++)
counts += fRunMuMinusList[i]->GetNoOfFitBins();
@ -558,7 +698,7 @@ PRunData* PRunListCollection::GetSingleHisto(UInt_t index, EDataSwitch tag)
switch (tag) {
case kIndex:
if ((index < 0) || (index >= fRunSingleHistoList.size())) {
cerr << endl << "PRunListCollection::GetSingleHisto: **ERROR** index = " << index << " out of bounds";
cerr << endl << ">> PRunListCollection::GetSingleHisto(): **ERROR** index = " << index << " out of bounds";
cerr << endl;
return 0;
}
@ -581,6 +721,49 @@ PRunData* PRunListCollection::GetSingleHisto(UInt_t index, EDataSwitch tag)
return data;
}
//--------------------------------------------------------------------------
// GetSingleHistoRRF (public)
//--------------------------------------------------------------------------
/**
* <p>Get a processed single histogram RRF data set.
*
* <b>return:</b>
* - pointer to the run data set (processed data) if data set is found
* - null pointer otherwise
*
* \param index msr-file run index
* \param tag kIndex -> data at index, kRunNo -> data of given run no
*/
PRunData* PRunListCollection::GetSingleHistoRRF(UInt_t index, EDataSwitch tag)
{
PRunData *data = 0;
switch (tag) {
case kIndex:
if ((index < 0) || (index >= fRunSingleHistoRRFList.size())) {
cerr << endl << ">> PRunListCollection::GetSingleHistoRRF(): **ERROR** index = " << index << " out of bounds";
cerr << endl;
return 0;
}
fRunSingleHistoRRFList[index]->CalcTheory();
data = fRunSingleHistoRRFList[index]->GetData();
break;
case kRunNo:
for (UInt_t i=0; i<fRunSingleHistoRRFList.size(); i++) {
if (fRunSingleHistoRRFList[i]->GetRunNo() == index) {
data = fRunSingleHistoRRFList[i]->GetData();
break;
}
}
break;
default: // error
break;
}
return data;
}
//--------------------------------------------------------------------------
// GetAsymmetry (public)
//--------------------------------------------------------------------------
@ -601,7 +784,7 @@ PRunData* PRunListCollection::GetAsymmetry(UInt_t index, EDataSwitch tag)
switch (tag) {
case kIndex: // called from musrfit when dumping the data
if ((index < 0) || (index > fRunAsymmetryList.size())) {
cerr << endl << "PRunListCollection::GetAsymmetry: **ERROR** index = " << index << " out of bounds";
cerr << endl << ">> PRunListCollection::GetAsymmetry(): **ERROR** index = " << index << " out of bounds";
cerr << endl;
return 0;
}
@ -624,6 +807,49 @@ PRunData* PRunListCollection::GetAsymmetry(UInt_t index, EDataSwitch tag)
return data;
}
//--------------------------------------------------------------------------
// GetAsymmetryRRF (public)
//--------------------------------------------------------------------------
/**
* <p>Get a processed asymmetry RRF data set.
*
* <b>return:</b>
* - pointer to the run data set (processed data) if data set is found
* - null pointer otherwise
*
* \param index msr-file run index
* \param tag kIndex -> data at index, kRunNo -> data of given run no
*/
PRunData* PRunListCollection::GetAsymmetryRRF(UInt_t index, EDataSwitch tag)
{
PRunData *data = 0;
switch (tag) {
case kIndex: // called from musrfit when dumping the data
if ((index < 0) || (index > fRunAsymmetryRRFList.size())) {
cerr << endl << ">> PRunListCollection::GetAsymmetryRRF(): **ERROR** index = " << index << " out of bounds";
cerr << endl;
return 0;
}
fRunAsymmetryRRFList[index]->CalcTheory();
data = fRunAsymmetryRRFList[index]->GetData();
break;
case kRunNo: // called from PMusrCanvas
for (UInt_t i=0; i<fRunAsymmetryRRFList.size(); i++) {
if (fRunAsymmetryRRFList[i]->GetRunNo() == index) {
data = fRunAsymmetryRRFList[i]->GetData();
break;
}
}
break;
default: // error
break;
}
return data;
}
//--------------------------------------------------------------------------
// GetMuMinus (public)
//--------------------------------------------------------------------------
@ -644,7 +870,7 @@ PRunData* PRunListCollection::GetMuMinus(UInt_t index, EDataSwitch tag)
switch (tag) {
case kIndex:
if ((index < 0) || (index > fRunMuMinusList.size())) {
cerr << endl << "PRunListCollection::GetMuMinus: **ERROR** index = " << index << " out of bounds";
cerr << endl << ">> PRunListCollection::GetMuMinus(): **ERROR** index = " << index << " out of bounds";
cerr << endl;
return 0;
}
@ -686,7 +912,7 @@ PRunData* PRunListCollection::GetNonMusr(UInt_t index, EDataSwitch tag)
switch (tag) {
case kIndex:
if ((index < 0) || (index > fRunNonMusrList.size())) {
cerr << endl << "PRunListCollection::GetNonMusr: **ERROR** index = " << index << " out of bounds";
cerr << endl << ">> PRunListCollection::GetNonMusr(): **ERROR** index = " << index << " out of bounds";
cerr << endl;
return 0;
}

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
@ -861,7 +861,7 @@ Bool_t PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const UInt_t hi
if (fScaleN0AndBkg) {
dataNorm = 1.0/ (packing * (fTimeResolution * 1.0e3)); // fTimeResolution us->ns
} else if (!fScaleN0AndBkg && (fMsrInfo->GetMsrPlotList()->at(0).fViewPacking > 0)) {
theoryNorm = (Double_t)fMsrInfo->GetMsrPlotList()->at(0).fViewPacking/(Double_t)packing;
theoryNorm = (Double_t)fMsrInfo->GetMsrPlotList()->at(0).fViewPacking/(Double_t)fPacking;
}
// raw data, since PMusrCanvas is doing ranging etc.
@ -1052,7 +1052,7 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo
if (fScaleN0AndBkg) {
dataNorm = 1.0/ (packing * (fTimeResolution * 1.0e3)); // fTimeResolution us->ns
} else if (!fScaleN0AndBkg && (fMsrInfo->GetMsrPlotList()->at(0).fViewPacking > 0)) {
theoryNorm = (Double_t)fMsrInfo->GetMsrPlotList()->at(0).fViewPacking/(Double_t)packing;
theoryNorm = (Double_t)fMsrInfo->GetMsrPlotList()->at(0).fViewPacking/(Double_t)fPacking;
}
// transform raw histo data. This is done the following way (for details see the manual):

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
@ -2307,7 +2307,7 @@ Double_t PTheory::SkewedGauss(register Double_t t, const PDoubleVector& paramVal
Double_t freq = TWO_PI*val[1];
if ((zp >= 25.0) || (zm >= 25.0)) // needed to prevent crash of 1F1
skg = 2.0e300;
skg = 2.0e6;
else if (fabs(val[2]) == fabs(val[3])) // sigma+ == sigma- -> Gaussian
skg = TMath::Cos(phase+freq*tt) * gp;
else

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@ -1437,14 +1437,14 @@ bool TMusrRunHeader::UpdateFolder(TObject *treeObj, TString path)
// remove the first path element
if (!RemoveFirst(path, '/')) {
cerr << endl << ">> TMusrRunHeader::FillFolder(): **ERROR** couldn't tokenize path!!" << endl;
cerr << endl << ">> TMusrRunHeader::UpdateFolder(): **ERROR** couldn't tokenize path!!" << endl;
return false;
}
if (!obj) { // required object not present, create it
TObjArray *oarray = new TObjArray();
if (!oarray) {
cerr << endl << ">> TMusrRunHeader::FillFolder(): **ERROR** couldn't create header structure!!" << endl;
cerr << endl << ">> TMusrRunHeader::UpdateFolder(): **ERROR** couldn't create header structure!!" << endl;
return false;
}
// set the name of the new TObjArray
@ -1636,7 +1636,7 @@ TObjString TMusrRunHeader::GetHeaderString(UInt_t idx)
str += subStr;
str += "; ";
}
subStr.Form(fmt, dvec.size()-1);
subStr.Form(fmt, dvec[dvec.size()-1]);
str += subStr;
str += " -@";
str += MRH_DOUBLE_VECTOR;

Binary file not shown.

View File

@ -12,6 +12,7 @@
\usepackage{rotating}
\usepackage{dcolumn}
\usepackage{geometry}
\usepackage{color}
\geometry{a4paper,left=20mm,right=20mm,top=20mm,bottom=20mm}
@ -72,7 +73,7 @@ E-Mail: & \verb?andreas.suter@psi.ch? &&
%
\section*{\musrfithead plug-in for the calculation of the temperature dependence of $\bm{1/\lambda^2}$ for various gap symmetries}%
This memo is intended to give a short summary of the background on which the \gapint plug-in for \musrfit \cite{musrfit} has been developped. The aim of this implementation is the efficient calculation of integrals of the form
This memo is intended to give a short summary of the background on which the \gapint plug-in for \musrfit \cite{musrfit} has been developed. The aim of this implementation is the efficient calculation of integrals of the form
\begin{equation}\label{int}
I(T) = 1 + \frac{1}{\pi}\int_0^{2\pi}\int_{\Delta(\varphi,T)}^{\infty}\left(\frac{\partial f}{\partial E}\right) \frac{E}{\sqrt{E^2-\Delta^2(\varphi,T)}}\mathrm{d}E\mathrm{d}\varphi\,,
\end{equation}
@ -104,18 +105,27 @@ For the numerical integration we use algorithms of the \textsc{Cuba} library \ci
\subsection*{Implemented gap functions and function calls from MUSRFIT}
Currently the calculation of $\tilde{I}(T)$ is implemented for various gap functions.
The temperature dependence of the gap functions is either given by Eq.(\ref{eq:gapT_Prozorov}) \cite{Prozorov}, or by Eq.(\ref{eq:gapT_Manzano}) \cite{Manzano}.
\vspace{2mm}
\noindent \color{red}\textbf{A few words of warning:~}\color{black} The temperature dependence of the gap function is typically derived from within the BCS framework,
and strongly links $T_c$ and $\Delta_0$ (e.g.\xspace $\Delta_0 = 1.76\, k_{\rm B} T_c$ for an s-wave superconductor). In a self-consistent
description this would mean that $\Delta_0$ of $\Delta(\varphi)$ is locked to $T_c$ as well. In the implementation provided, this limitation
is lifted, and therefore the \emph{user} should judge and question the result if the ratio $\Delta_0/(k_{\rm B}T_c)$ is strongly deviating from
BCS values!
\begin{equation}\label{eq:gapT_Prozorov}
\Delta(\varphi,T) \simeq \Delta(\varphi,0)\,\tanh\left[\frac{\pi k_{\rm B} T_{\rm c}}{\Delta_0}\sqrt{a_{\rm G} \left(\frac{T_{\rm c}}{T}-1\right)}\right]
\Delta(\varphi,T) \simeq \Delta(\varphi)\,\tanh\left[c_0\,\sqrt{a_{\rm G} \left(\frac{T_{\rm c}}{T}-1\right)}\right]
\end{equation}
\noindent with $\Delta_0$ as given below, and $a_{\rm G}$ depends on the pairing state:
\noindent with $\Delta(\varphi)$ as given below, and $c_0$ and $a_{\rm G}$ depends on the pairing state:
\begin{description}
\item [\textit{s}-wave:] $a_{\rm G}=1$ \qquad with $\Delta_0 = 1.76\, k_{\rm B} T_c$
\item [\textit{d}-wave:] $a_{\rm G}=4/3$ \quad with $\Delta_0 = 2.14\, k_{\rm B} T_c$
\item [\textit{s}-wave:] $a_{\rm G}=1$ \qquad with $c_0 = \frac{\displaystyle\pi k_{\rm B} T_{\rm c}}{\displaystyle\Delta_0} = \pi/1.76 = 1.785$
\item [\textit{d}-wave:] $a_{\rm G}=4/3$ \quad with $c_0 = \frac{\displaystyle\pi k_{\rm B} T_{\rm c}}{\displaystyle\Delta_0} = \pi/2.14 = 1.468$
\end{description}
\begin{equation}\label{eq:gapT_Manzano}
\Delta(\varphi,T) \simeq \Delta(\varphi)\tanh\left(1.82\left(1.018\left(\frac{T_{\mathrm c}}{T}-1\right)\right)^{0.51}\right)\,.
\Delta(\varphi,T) \simeq \Delta(\varphi)\tanh\left[1.82\left(1.018\left(\frac{T_{\mathrm c}}{T}-1\right)\right)^{0.51}\right]\,.
\end{equation}
The \gapint plug-in calculates $\tilde{I}(T)$ for the following $\Delta(\varphi)$:
@ -124,37 +134,39 @@ The \gapint plug-in calculates $\tilde{I}(T)$ for the following $\Delta(\varphi)
\begin{equation}
\Delta(\varphi) = \Delta_0
\end{equation}
\musrfit theory line: \verb?userFcn libGapIntegrals TGapSWave 1 2 [3]?\\
(Parameters: $T_{\mathrm c}~(\mathrm{K})$, $\Delta_0~(\mathrm{meV})$, $[a_{\rm G}~(1)]$. If $a_{\rm G}$ is given, the temperature dependence
according to Eq.(\ref{eq:gapT_Prozorov}) will be used, otherwise Eq.(\ref{eq:gapT_Manzano}) will be utilized.)
\musrfit theory line: \verb?userFcn libGapIntegrals TGapSWave 1 2 [3 4]?\\[1.5ex]
Parameters: $T_{\mathrm c}~(\mathrm{K})$, $\Delta_0~(\mathrm{meV})$, $[c_0~(1),~ a_{\rm G}~(1)]$. If $c_0$ and $a_{\rm G}$ are provided,
the temperature dependence according to Eq.(\ref{eq:gapT_Prozorov}) will be used, otherwise Eq.(\ref{eq:gapT_Manzano}) will be utilized.
\item[\textit{d}-wave gap \cite{Deutscher}:]
\begin{equation}
\Delta(\varphi) = \Delta_0\cos\left(2\varphi\right)
\end{equation}
\musrfit theory line: \verb?userFcn libGapIntegrals TGapDWave 1 2 [3]?\\
(Parameters: $T_{\mathrm c}~(\mathrm{K})$, $\Delta_0~(\mathrm{meV})$, $[a_{\rm G}~(1)]$. If $a_{\rm G}$ is given, the temperature dependence
according to Eq.(\ref{eq:gapT_Prozorov}) will be used, otherwise Eq.(\ref{eq:gapT_Manzano}) will be utilized.)
\musrfit theory line: \verb?userFcn libGapIntegrals TGapDWave 1 2 [3 4]?\\[1.5ex]
Parameters: $T_{\mathrm c}~(\mathrm{K})$, $\Delta_0~(\mathrm{meV})$, $[c_0~(1),~a_{\rm G}~(1)]$. If $c_0$ and $a_{\rm G}$ are provided,
the temperature dependence according to Eq.(\ref{eq:gapT_Prozorov}) will be used, otherwise Eq.(\ref{eq:gapT_Manzano}) will be utilized.
\item[non-monotonic \textit{d}-wave gap \cite{Matsui}:]
\begin{equation}
\Delta(\varphi) = \Delta_0\left[a \cos\left(2\varphi\right) + (1-a)\cos\left(6\varphi\right)\right]
\end{equation}
\musrfit theory line: \verb?userFcn libGapIntegrals TGapNonMonDWave1 1 2 3 [4]?\\
(Parameters: $T_{\mathrm c}~(\mathrm{K})$, $\Delta_0~(\mathrm{meV})$, $a~(1)$, $[a_{\rm G}~(1)]$. If $a_{\rm G}$ is given, the temperature dependence
according to Eq.(\ref{eq:gapT_Prozorov}) will be used, otherwise Eq.(\ref{eq:gapT_Manzano}) will be utilized.)
\musrfit theory line: \verb?userFcn libGapIntegrals TGapNonMonDWave1 1 2 3 [4 5]?\\[1.5ex]
Parameters: $T_{\mathrm c}~(\mathrm{K})$, $\Delta_0~(\mathrm{meV})$, $a~(1)$, $[c_0~(1),~a_{\rm G}~(1)]$. If $c_0$ and $a_{\rm G}$ are provided,
the temperature dependence according to Eq.(\ref{eq:gapT_Prozorov}) will be used, otherwise Eq.(\ref{eq:gapT_Manzano}) will be utilized.
\item[non-monotonic \textit{d}-wave gap \cite{Eremin}:]
\begin{equation}
\Delta(\varphi) = \Delta_0\left[\frac{2}{3} \sqrt{\frac{a}{3}}\cos\left(2\varphi\right) / \left( 1 + a\cos^2\left(2\varphi\right)\right)^{\frac{3}{2}}\right],\,a>1/2
\end{equation}
\musrfit theory line: \verb?userFcn libGapIntegrals TGapNonMonDWave2 1 2 3 [4]?\\
(Parameters: $T_{\mathrm c}~(\mathrm{K})$, $\Delta_0~(\mathrm{meV})$, $a~(1)$, $a~(1)$, $[a_{\rm G}~(1)]$. If $a_{\rm G}$ is given, the temperature dependence
according to Eq.(\ref{eq:gapT_Prozorov}) will be used, otherwise Eq.(\ref{eq:gapT_Manzano}) will be utilized.)
\musrfit theory line: \verb?userFcn libGapIntegrals TGapNonMonDWave2 1 2 3 [4 5]?\\[1.5ex]
Parameters: $T_{\mathrm c}~(\mathrm{K})$, $\Delta_0~(\mathrm{meV})$, $a~(1)$, $a~(1)$, $[c_0~(1),~a_{\rm G}~(1)]$.
If $c_0$ and $a_{\rm G}$ are provided, the temperature dependence according to Eq.(\ref{eq:gapT_Prozorov}) will be used,
otherwise Eq.(\ref{eq:gapT_Manzano}) will be utilized.
\item[anisotropic \textit{s}-wave gap \cite{AnisotropicSWave}:]
\begin{equation}
\Delta(\varphi) = \Delta_0\left[1+a\cos\left(4\varphi\right)\right]\,,\,0\leqslant a\leqslant1
\end{equation}
\musrfit theory line: \verb?userFcn libGapIntegrals TGapAnSWave 1 2 3 [4]?\\
(Parameters: $T_{\mathrm c}~(\mathrm{K})$, $\Delta_0~(\mathrm{meV})$, $a~(1)$, $[a_{\rm G}~(1)]$. If $a_{\rm G}$ is given, the temperature dependence
according to Eq.(\ref{eq:gapT_Prozorov}) will be used, otherwise Eq.(\ref{eq:gapT_Manzano}) will be utilized.)
\musrfit theory line: \verb?userFcn libGapIntegrals TGapAnSWave 1 2 3 [4 5]?\\[1.5ex]
Parameters: $T_{\mathrm c}~(\mathrm{K})$, $\Delta_0~(\mathrm{meV})$, $a~(1)$, $[c_0~(1),~a_{\rm G}~(1)]$.
If $c_0$ and $a_{\rm G}$ are provided, the temperature dependence according to Eq.(\ref{eq:gapT_Prozorov}) will be used,
otherwise Eq.(\ref{eq:gapT_Manzano}) will be utilized.
\end{description}
\noindent It is also possible to calculate a power law temperature dependence (in the two fluid approximation $n=4$) and the dirty \textit{s}-wave expression.
@ -164,16 +176,16 @@ Obviously for this no integration is needed.
\begin{equation}
\frac{\lambda(0)^2}{\lambda(T)^2} = 1-\left(\frac{T}{T_{\mathrm c}}\right)^n
\end{equation}
\musrfit theory line: \verb?userFcn libGapIntegrals TGapPowerLaw 1 2?\\
(Parameters: $T_{\mathrm c}~(\mathrm{K})$, $n~(1)$)
\musrfit theory line: \verb?userFcn libGapIntegrals TGapPowerLaw 1 2?\\[1.5ex]
Parameters: $T_{\mathrm c}~(\mathrm{K})$, $n~(1)$
\item[dirty \textit{s}-wave \cite{Tinkham}:]
\begin{equation}
\frac{\lambda(0)^2}{\lambda(T)^2} = \frac{\Delta(T)}{\Delta_0}\,\tanh\left[\frac{\Delta(T)}{2 k_{\rm B} T}\right]
\end{equation}
with $\Delta(T)$ given by Eq.(\ref{eq:gapT}).\\
\musrfit theory line: \verb?userFcn libGapIntegrals TGapDirtySWave 1 2 [3]?\\
(Parameters: $T_{\mathrm c}~(\mathrm{K})$, $\Delta_0~(\mathrm{meV})$, $[a_{\rm G}~(1)]$. If $a_{\rm G}$ is given, the temperature dependence
according to Eq.(\ref{eq:gapT_Prozorov}) will be used, otherwise Eq.(\ref{eq:gapT_Manzano}) will be utilized.)
\musrfit theory line: \verb?userFcn libGapIntegrals TGapDirtySWave 1 2 [3 4]?\\[1.5ex]
Parameters: $T_{\mathrm c}~(\mathrm{K})$, $\Delta_0~(\mathrm{meV})$, $[c_0~(1),~a_{\rm G}~(1)]$.
If $c_0$ and $a_{\rm G}$ are provided, the temperature dependence according to Eq.(\ref{eq:gapT_Prozorov}) will be used,
otherwise Eq.(\ref{eq:gapT_Manzano}) will be utilized.
\end{description}
\noindent Currently there are two gap functions to be found in the code which are \emph{not} documented here:
@ -187,7 +199,8 @@ The \gapint library is free software; you can redistribute it and/or modify it u
\bibliographystyle{plain}
\begin{thebibliography}{1}
\bibitem{musrfit} A.~Suter, \textit{\musrfit User Manual}, https://wiki.intranet.psi.ch/MUSR/MusrFit
\bibitem{musrfit} A. Suter, and B.M. Wojek, Physics Procedia \textbf{30}, 69 (2012).
A.~Suter, \textit{\musrfit User Manual}, http://lmu.web.psi.ch/musrfit/user/MUSR/WebHome.html
\bibitem{cuba} T.~Hahn, \textit{Cuba -- a library for multidimensional numerical integration}, Comput.~Phys.~Commun.~\textbf{168}~(2005)~78-95, http://www.feynarts.de/cuba/
\bibitem{Prozorov} R.~Prozorov and R.W.~Giannetta, \textit{Magnetic penetration depth in unconventional superconductors}, Supercond.\ Sci.\ Technol.\ \textbf{19}~(2006)~R41-R67, and Erratum in Supercond.\ Sci.\ Technol.\ \textbf{21}~(2008)~082003.
\bibitem{Manzano} A.~Carrington and F.~Manzano, Physica~C~\textbf{385}~(2003)~205

View File

@ -459,10 +459,12 @@ TLambdaInvNonMonDWave2::~TLambdaInvNonMonDWave2() {
*/
double TGapSWave::operator()(double t, const vector<double> &par) const {
assert((par.size() == 2) || (par.size() == 3)); // two or three parameters: Tc (K), Delta(0) (meV), [a (1)]
// 2 parameters: see A.~Carrington and F.~Manzano, Physica~C~\textbf{385}~(2003)~205
// 3 parameters: see R. Prozorov and R. Giannetta, Supercond. Sci. Technol. 19 (2006) R41-R67
// parameters: [0] Tc (K), [1] Delta0 (meV), [[2] c0 (1), [3] aG (1)]
assert((par.size() == 2) || (par.size() == 4)); // 2 parameters: see A.~Carrington and F.~Manzano, Physica~C~\textbf{385}~(2003)~205
// 4 parameters: see R. Prozorov and R. Giannetta, Supercond. Sci. Technol. 19 (2006) R41-R67
// and Erratum Supercond. Sci. Technol. 21 (2008) 082003
// c0 in the original context is c0 = (pi kB Tc) / Delta0
if (t<=0.0)
return 1.0;
else if (t >= par[0])
@ -509,7 +511,7 @@ double TGapSWave::operator()(double t, const vector<double> &par) const {
if (par.size() == 2) { // Carrington/Manzano
intPar.push_back(par[1]*tanh(1.82*pow(1.018*(par[0]/t-1.0),0.51)));
} else { // Prozorov/Giannetta
intPar.push_back(par[1]*tanh(0.2707214816*par[0]/par[1]*sqrt(par[2]*(par[0]/t-1.0)))); // tanh(pi kB Tc / Delta(0) * sqrt()), pi kB = 0.2707214816 meV/K
intPar.push_back(par[1]*tanh(par[2]*sqrt(par[3]*(par[0]/t-1.0)))); // Delta0*tanh(c0*sqrt(aG*(Tc/T-1)))
}
fGapIntegral->SetParameters(intPar);
@ -536,10 +538,12 @@ double TGapSWave::operator()(double t, const vector<double> &par) const {
*/
double TGapDWave::operator()(double t, const vector<double> &par) const {
assert((par.size() == 2) || (par.size() == 3)); // two or three parameters: Tc (K), Delta(0) (meV), [a (1)]
// 2 parameters: see A.~Carrington and F.~Manzano, Physica~C~\textbf{385}~(2003)~205
// 3 parameters: see R. Prozorov and R. Giannetta, Supercond. Sci. Technol. 19 (2006) R41-R67
// parameters: [0] Tc (K), [1] Delta0 (meV), [[2] c0 (1), [3] aG (1)]
assert((par.size() == 2) || (par.size() == 4)); // 2 parameters: see A.~Carrington and F.~Manzano, Physica~C~\textbf{385}~(2003)~205
// 4 parameters: see R. Prozorov and R. Giannetta, Supercond. Sci. Technol. 19 (2006) R41-R67
// and Erratum Supercond. Sci. Technol. 21 (2008) 082003
// c0 in the original context is c0 = (pi kB Tc) / Delta0
if (t<=0.0)
return 1.0;
else if (t >= par[0])
@ -585,7 +589,7 @@ double TGapDWave::operator()(double t, const vector<double> &par) const {
if (par.size() == 2) { // Carrington/Manzano
intPar.push_back(par[1]*tanh(1.82*pow(1.018*(par[0]/t-1.0),0.51)));
} else { // Prozorov/Giannetta
intPar.push_back(par[1]*tanh(0.2707214816*par[0]/par[1]*sqrt(par[2]*(par[0]/t-1.0)))); // tanh(pi kB Tc / Delta(0) * sqrt()), pi kB = 0.2707214816 meV/K
intPar.push_back(par[1]*tanh(par[2]*sqrt(par[3]*(par[0]/t-1.0)))); // Delta0*tanh(c0*sqrt(aG*(Tc/T-1)))
}
intPar.push_back(4.0*(t+intPar[1])); // upper limit of energy-integration: cutoff energy
intPar.push_back(TMath::PiOver2()); // upper limit of phi-integration
@ -618,9 +622,10 @@ double TGapDWave::operator()(double t, const vector<double> &par) const {
*/
double TGapCosSqDWave::operator()(double t, const vector<double> &par) const {
assert((par.size() == 3) || (par.size() == 5)); // three or five parameters: Tc (K), DeltaD(0) (meV), DeltaS(0) (meV), [aD (1), aS (1)]
// 3 parameters: see A.~Carrington and F.~Manzano, Physica~C~\textbf{385}~(2003)~205
// 5 parameters: see R. Prozorov and R. Giannetta, Supercond. Sci. Technol. 19 (2006) R41-R67
// parameters: [0] Tc (K), [1] Delta0_D (meV), [2] Delta0_S (meV) [[3] c0_D (1), [4] aG_D (1), [5] c0_S (1), [6] aG_S (1)]
assert((par.size() == 3) || (par.size() == 7)); // 3 parameters: see A.~Carrington and F.~Manzano, Physica~C~\textbf{385}~(2003)~205
// 7 parameters: see R. Prozorov and R. Giannetta, Supercond. Sci. Technol. 19 (2006) R41-R67
// and Erratum Supercond. Sci. Technol. 21 (2008) 082003
if (t<=0.0)
return 1.0;
@ -667,14 +672,14 @@ double TGapCosSqDWave::operator()(double t, const vector<double> &par) const {
if (par.size() == 3) { // Carrington/Manzano
intPar.push_back(par[1]*tanh(1.82*pow(1.018*(par[0]/t-1.0),0.51)));
} else { // Prozorov/Giannetta
intPar.push_back(par[1]*tanh(0.2707214816*par[0]/par[1]*sqrt(par[3]*(par[0]/t-1.0)))); // DeltaD(T) : tanh(pi kB Tc / Delta(0) * sqrt()), pi kB = 0.2707214816 meV/K
intPar.push_back(par[1]*tanh(par[3]*sqrt(par[4]*(par[0]/t-1.0)))); // Delta0_D*tanh(c0_D*sqrt(aG_D*(Tc/T-1)))
}
intPar.push_back(1.0*(t+intPar[1])); // upper limit of energy-integration: cutoff energy
intPar.push_back(TMath::Pi()); // upper limit of phi-integration
if (par.size() == 3) { // Carrington/Manzano
intPar.push_back(par[2]*tanh(1.82*pow(1.018*(par[0]/t-1.0),0.51)));
} else { // Prozorov/Giannetta
intPar.push_back(par[2]*tanh(0.2707214816*par[0]/par[2]*sqrt(par[4]*(par[0]/t-1.0)))); // DeltaS(T) : tanh(pi kB Tc / Delta(0) * sqrt()), pi kB = 0.2707214816 meV/K
intPar.push_back(par[2]*tanh(par[5]*sqrt(par[6]*(par[0]/t-1.0)))); // Delta0_S*tanh(c0_S*sqrt(aG_S*(Tc/T-1)))
}
// double xl[] = {0.0, 0.0}; // lower bound E, phi
@ -705,10 +710,12 @@ double TGapCosSqDWave::operator()(double t, const vector<double> &par) const {
*/
double TGapSinSqDWave::operator()(double t, const vector<double> &par) const {
assert((par.size() == 3) || (par.size() == 5)); // three or five parameters: Tc (K), DeltaD(0) (meV), DeltaS(0) (meV), [aD (1), aS (1)]
// 3 parameters: see A.~Carrington and F.~Manzano, Physica~C~\textbf{385}~(2003)~205
// 5 parameters: see R. Prozorov and R. Giannetta, Supercond. Sci. Technol. 19 (2006) R41-R67
// parameters: [0] Tc (K), [1] Delta0_D (meV), [2] Delta0_S (meV) [[3] c0_D (1), [4] aG_D (1), [5] c0_S (1), [6] aG_S (1)]
assert((par.size() == 3) || (par.size() == 7)); // 3 parameters: see A.~Carrington and F.~Manzano, Physica~C~\textbf{385}~(2003)~205
// 7 parameters: see R. Prozorov and R. Giannetta, Supercond. Sci. Technol. 19 (2006) R41-R67
// and Erratum Supercond. Sci. Technol. 21 (2008) 082003
// c0 in the original context is c0 = (pi kB Tc) / Delta0
if (t<=0.0)
return 1.0;
else if (t >= par[0])
@ -754,14 +761,14 @@ double TGapSinSqDWave::operator()(double t, const vector<double> &par) const {
if (par.size() == 3) { // Carrington/Manzano
intPar.push_back(par[1]*tanh(1.82*pow(1.018*(par[0]/t-1.0),0.51)));
} else { // Prozorov/Giannetta
intPar.push_back(par[1]*tanh(0.2707214816*par[0]/par[1]*sqrt(par[3]*(par[0]/t-1.0)))); // DeltaD(T) : tanh(pi kB Tc / Delta(0) * sqrt()), pi kB = 0.2707214816 meV/K
intPar.push_back(par[1]*tanh(par[3]*sqrt(par[4]*(par[0]/t-1.0)))); // Delta0_D*tanh(c0_D*sqrt(aG_D*(Tc/T-1)))
}
intPar.push_back(1.0*(t+intPar[1])); // upper limit of energy-integration: cutoff energy
intPar.push_back(TMath::Pi()); // upper limit of phi-integration
if (par.size() == 3) { // Carrington/Manzano
intPar.push_back(par[2]*tanh(1.82*pow(1.018*(par[0]/t-1.0),0.51)));
} else { // Prozorov/Giannetta
intPar.push_back(par[2]*tanh(0.2707214816*par[0]/par[2]*sqrt(par[4]*(par[0]/t-1.0)))); // DeltaS(T) : tanh(pi kB Tc / Delta(0) * sqrt()), pi kB = 0.2707214816 meV/K
intPar.push_back(par[2]*tanh(par[5]*sqrt(par[6]*(par[0]/t-1.0)))); // Delta0_S*tanh(c0_S*sqrt(aG_S*(Tc/T-1)))
}
// double xl[] = {0.0, 0.0}; // lower bound E, phi
@ -792,10 +799,13 @@ double TGapSinSqDWave::operator()(double t, const vector<double> &par) const {
*/
double TGapAnSWave::operator()(double t, const vector<double> &par) const {
assert((par.size() == 3) || (par.size() == 4)); // three or four parameters: Tc (K), Delta(0) (meV), a (1), [aS_Gap (1)]
// 3 parameters: see A.~Carrington and F.~Manzano, Physica~C~\textbf{385}~(2003)~205
// 4 parameters: see R. Prozorov and R. Giannetta, Supercond. Sci. Technol. 19 (2006) R41-R67
// parameters: [0] Tc (K), [1] Delta0 (meV), [2] a (1), [[3] c0 (1), [4] aG (1)]
assert((par.size() == 3) || (par.size() == 5)); // 3 parameters: see A.~Carrington and F.~Manzano, Physica~C~\textbf{385}~(2003)~205
// 5 parameters: see R. Prozorov and R. Giannetta, Supercond. Sci. Technol. 19 (2006) R41-R67
// and Erratum Supercond. Sci. Technol. 21 (2008) 082003
// c0 in the original context is c0 = (pi kB Tc) / Delta0
if (t<=0.0)
return 1.0;
else if (t >= par[0])
@ -841,7 +851,7 @@ double TGapAnSWave::operator()(double t, const vector<double> &par) const {
if (par.size() == 3) { // Carrington/Manzano
intPar.push_back(par[1]*tanh(1.82*pow(1.018*(par[0]/t-1.0),0.51)));
} else { // Prozorov/Giannetta
intPar.push_back(par[1]*tanh(0.2707214816*par[0]/par[1]*sqrt(par[3]*(par[0]/t-1.0)))); // DeltaS(T) : tanh(pi kB Tc / Delta(0) * sqrt()), pi kB = 0.2707214816 meV/K
intPar.push_back(par[1]*tanh(par[3]*sqrt(par[4]*(par[0]/t-1.0)))); // Delta0*tanh(c0*sqrt(aG*(Tc/T-1)))
}
intPar.push_back(par[2]);
intPar.push_back(4.0*(t+(1.0+par[2])*intPar[1])); // upper limit of energy-integration: cutoff energy
@ -875,10 +885,12 @@ double TGapAnSWave::operator()(double t, const vector<double> &par) const {
*/
double TGapNonMonDWave1::operator()(double t, const vector<double> &par) const {
assert((par.size() == 3) || (par.size() == 4)); // three or four parameters: Tc (K), Delta(0) (meV), a (1), [aD_Gap (1)]
// 3 parameters: see A.~Carrington and F.~Manzano, Physica~C~\textbf{385}~(2003)~205
// 4 parameters: see R. Prozorov and R. Giannetta, Supercond. Sci. Technol. 19 (2006) R41-R67
// parameters: [0] Tc (K), [1] Delta0 (meV), [2] a (1), [[3] c0 (1), [4] aG (1)]
assert((par.size() == 3) || (par.size() == 5)); // 3 parameters: see A.~Carrington and F.~Manzano, Physica~C~\textbf{385}~(2003)~205
// 5 parameters: see R. Prozorov and R. Giannetta, Supercond. Sci. Technol. 19 (2006) R41-R67
// and Erratum Supercond. Sci. Technol. 21 (2008) 082003
// c0 in the original context is c0 = (pi kB Tc) / Delta0
if (t<=0.0)
return 1.0;
else if (t >= par[0])
@ -924,7 +936,7 @@ double TGapNonMonDWave1::operator()(double t, const vector<double> &par) const {
if (par.size() == 3) { // Carrington/Manzano
intPar.push_back(par[1]*tanh(1.82*pow(1.018*(par[0]/t-1.0),0.51)));
} else { // Prozorov/Giannetta
intPar.push_back(par[1]*tanh(0.2707214816*par[0]/par[1]*sqrt(par[3]*(par[0]/t-1.0)))); // DeltaD(T) : tanh(pi kB Tc / Delta(0) * sqrt()), pi kB = 0.2707214816 meV/K
intPar.push_back(par[1]*tanh(par[3]*sqrt(par[4]*(par[0]/t-1.0)))); // Delta0*tanh(c0*sqrt(aG*(Tc/T-1)))
}
intPar.push_back(par[2]);
intPar.push_back(4.0*(t+intPar[1])); // upper limit of energy-integration: cutoff energy
@ -955,10 +967,12 @@ double TGapNonMonDWave1::operator()(double t, const vector<double> &par) const {
*/
double TGapNonMonDWave2::operator()(double t, const vector<double> &par) const {
assert((par.size() == 3) || (par.size() == 4)); // three parameters: Tc (K), Delta(0) (meV), a (1), [aD_Gap (1)]
// 3 parameters: see A.~Carrington and F.~Manzano, Physica~C~\textbf{385}~(2003)~205
// 4 parameters: see R. Prozorov and R. Giannetta, Supercond. Sci. Technol. 19 (2006) R41-R67
// parameters: [0] Tc (K), [1] Delta0 (meV), [2] a (1), [[3] c0 (1), [4] aG (1)]
assert((par.size() == 3) || (par.size() == 5)); // 3 parameters: see A.~Carrington and F.~Manzano, Physica~C~\textbf{385}~(2003)~205
// 5 parameters: see R. Prozorov and R. Giannetta, Supercond. Sci. Technol. 19 (2006) R41-R67
// and Erratum Supercond. Sci. Technol. 21 (2008) 082003
// c0 in the original context is c0 = (pi kB Tc) / Delta0
if (t<=0.0)
return 1.0;
else if (t >= par[0])
@ -1004,7 +1018,7 @@ double TGapNonMonDWave2::operator()(double t, const vector<double> &par) const {
if (par.size() == 3) { // Carrington/Manzano
intPar.push_back(par[1]*tanh(1.82*pow(1.018*(par[0]/t-1.0),0.51)));
} else { // Prozorov/Giannetta
intPar.push_back(par[1]*tanh(0.2707214816*par[0]/par[1]*sqrt(par[3]*(par[0]/t-1.0)))); // DeltaD(T) : tanh(pi kB Tc / Delta(0) * sqrt()), pi kB = 0.2707214816 meV/K
intPar.push_back(par[1]*tanh(par[3]*sqrt(par[4]*(par[0]/t-1.0)))); // Delta0*tanh(c0*sqrt(aG*(Tc/T-1)))
}
intPar.push_back(par[2]);
intPar.push_back(4.0*(t+intPar[1])); // upper limit of energy-integration: cutoff energy
@ -1056,9 +1070,10 @@ double TGapPowerLaw::operator()(double t, const vector<double> &par) const {
*/
double TGapDirtySWave::operator()(double t, const vector<double> &par) const {
assert((par.size() == 2) || (par.size() == 3)); // two or three parameters: Tc (K), Delta(0) (meV) [a (1)]
// 2 parameters: see A.~Carrington and F.~Manzano, Physica~C~\textbf{385}~(2003)~205
// 3 parameters: see R. Prozorov and R. Giannetta, Supercond. Sci. Technol. 19 (2006) R41-R67
// parameters: [0] Tc (K), [1] Delta0 (meV), [[2] c0 (1), [3] aG (1)]
assert((par.size() == 2) || (par.size() == 4)); // 2 parameters: see A.~Carrington and F.~Manzano, Physica~C~\textbf{385}~(2003)~205
// 4 parameters: see R. Prozorov and R. Giannetta, Supercond. Sci. Technol. 19 (2006) R41-R67
// and Erratum Supercond. Sci. Technol. 21 (2008) 082003
if (t<=0.0)
return 1.0;
@ -1069,7 +1084,7 @@ double TGapDirtySWave::operator()(double t, const vector<double> &par) const {
if (par.size() == 2) { // Carrington/Manzano
deltaT = tanh(1.82*pow(1.018*(par[0]/t-1.0),0.51));
} else { // Prozorov/Giannetta
deltaT = tanh(0.2707214816*par[0]/par[1]*sqrt(par[2]*(par[0]/t-1.0))); // tanh(pi kB Tc / Delta(0) * sqrt()), pi kB = 0.2707214816 meV/K
deltaT = tanh(par[2]*sqrt(par[3]*(par[0]/t-1.0))); // tanh(c0*sqrt(aG*(Tc/T-1)))
}
return deltaT*tanh(par[1]*deltaT/(0.172346648*t)); // Delta(T)/Delta(0)*tanh(Delta(T)/2 kB T), kB in meV/K

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2015 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
@ -55,7 +55,9 @@ class PFourier
virtual const char* GetDataTitle() { return fData->GetTitle(); }
virtual const Int_t GetUnitTag() { return fUnitTag; }
virtual Double_t GetResolution() { return fResolution; }
virtual Double_t GetMaxFreq();
virtual TH1F* GetRealFourier(const Double_t scale = 1.0);
virtual TH1F* GetPhaseOptRealFourier(Double_t &phase, const Double_t scale = 1.0, const Double_t min = -1.0, const Double_t max = -1.0);
virtual TH1F* GetImaginaryFourier(const Double_t scale = 1.0);
virtual TH1F* GetPowerFourier(const Double_t scale = 1.0);
virtual TH1F* GetPhaseFourier(const Double_t scale = 1.0);

View File

@ -1,5 +1,14 @@
/***************************************************************************
* Copyright (C) 2007-2015 by Andreas Suter *
PFourierCanvas.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
@ -38,27 +47,31 @@
#include "PFourier.h"
// Canvas menu id's
#define P_MENU_ID_FOURIER 10001
#define P_MENU_ID_AVERAGE 10002
#define P_MENU_ID_EXPORT_DATA 10003
#define P_MENU_ID_FOURIER 10001
#define P_MENU_ID_AVERAGE 10002
#define P_MENU_ID_AVERAGE_PER_DATA_SET 10003
#define P_MENU_ID_EXPORT_DATA 10004
#define P_MENU_ID_FOURIER_REAL 100
#define P_MENU_ID_FOURIER_IMAG 101
#define P_MENU_ID_FOURIER_REAL_AND_IMAG 102
#define P_MENU_ID_FOURIER_PWR 103
#define P_MENU_ID_FOURIER_PHASE 104
#define P_MENU_ID_FOURIER_PHASE_PLUS 105
#define P_MENU_ID_FOURIER_PHASE_MINUS 106
#define P_MENU_ID_FOURIER_REAL 100
#define P_MENU_ID_FOURIER_IMAG 101
#define P_MENU_ID_FOURIER_REAL_AND_IMAG 102
#define P_MENU_ID_FOURIER_PWR 103
#define P_MENU_ID_FOURIER_PHASE 104
#define P_MENU_ID_FOURIER_PHASE_OPT_REAL 105
#define P_MENU_ID_FOURIER_PHASE_PLUS 106
#define P_MENU_ID_FOURIER_PHASE_MINUS 107
//------------------------------------------------------------------------
/**
* <p>Structure holding all necessary Fourier histograms.
*/
typedef struct {
TH1F *dataFourierRe; ///< real part of the Fourier transform of the data histogram
TH1F *dataFourierIm; ///< imaginary part of the Fourier transform of the data histogram
TH1F *dataFourierPwr; ///< power spectrum of the Fourier transform of the data histogram
TH1F *dataFourierPhase; ///< phase spectrum of the Fourier transform of the data histogram
TH1F *dataFourierRe; ///< real part of the Fourier transform of the data histogram
TH1F *dataFourierIm; ///< imaginary part of the Fourier transform of the data histogram
TH1F *dataFourierPwr; ///< power spectrum of the Fourier transform of the data histogram
TH1F *dataFourierPhase; ///< phase spectrum of the Fourier transform of the data histogram
TH1F *dataFourierPhaseOptReal; ///< phase otpimized real Fourier transform of the data histogram
Double_t optPhase; ///< optimal phase which maximizes the real Fourier
} PFourierCanvasDataSet;
//------------------------------------------------------------------------
@ -75,10 +88,12 @@ class PFourierCanvas : public TObject, public TQObject
{
public:
PFourierCanvas();
PFourierCanvas(vector<PFourier*> &fourier, const Char_t* title, const Bool_t showAverage,
PFourierCanvas(vector<PFourier*> &fourier, PIntVector dataSetTag, const Char_t* title,
const Bool_t showAverage, const Bool_t showAveragePerDataSet,
const Int_t fourierPlotOpt, Double_t fourierXrange[2], Double_t phase,
Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh, const Bool_t batch);
PFourierCanvas(vector<PFourier*> &fourier, const Char_t* title, const Bool_t showAverage,
PFourierCanvas(vector<PFourier*> &fourier, PIntVector dataSetTag, const Char_t* title,
const Bool_t showAverage, const Bool_t showAveragePerDataSet,
const Int_t fourierPlotOpt, Double_t fourierXrange[2], Double_t phase,
Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh,
const PIntVector markerList, const PIntVector colorList, const Bool_t batch);
@ -103,7 +118,9 @@ class PFourierCanvas : public TObject, public TQObject
Int_t fTimeout; ///< timeout after which the Done signal should be emited. If timeout <= 0, no timeout is taking place
Bool_t fBatchMode; ///< musrview in ROOT batch mode
Bool_t fValid; ///< if true, everything looks OK
Bool_t fAveragedView; ///< tag showing that the averaged view or normal view should be presented.
Bool_t fAveragedView; ///< tag showing that the averaged view for ALL data or normal view should be presented.
Bool_t fAveragedViewPerDataSet; ///< tag showing that the averaged view for individual data sets or normal view should be presented.
PIntVector fDataSetTag; ///< vector holding the data set tags
Int_t fCurrentPlotView; ///< tag showing what the current plot view is: real, imag, power, phase, ...
Double_t fInitialXRange[2]; ///< keeps the initial x-range
Double_t fInitialYRange[2]; ///< keeps the initial y-range
@ -112,7 +129,7 @@ class PFourierCanvas : public TObject, public TQObject
TString fXaxisTitle;
vector<PFourier*> fFourier; ///< keeps all the Fourier data, ownership is with the caller
PFourierCanvasDataList fFourierHistos; ///< keeps all the Fourier histos
PFourierCanvasDataSet fFourierAverage; ///< keeps the average of the Fourier histos
PFourierCanvasDataList fFourierAverage; ///< keeps the average of the Fourier histos
Double_t fCurrentFourierPhase; ///< keeps the current Fourier phase (real/imag)
TLatex *fCurrentFourierPhaseText; ///< used in Re/Im Fourier to show the current phase in the pad
@ -127,7 +144,6 @@ class PFourierCanvas : public TObject, public TQObject
TRootCanvas *fImp; ///< ROOT native GUI version of main window with menubar and drawing area
TGMenuBar *fBar; ///< menu bar
TGPopupMenu *fPopupMain; ///< popup menu MusrFT in the main menu bar
// TGPopupMenu *fPopupSave; ///< popup menu of the MusrFT/Save Data sub menu
TGPopupMenu *fPopupFourier; ///< popup menu of the MusrFT/Fourier sub menu
// canvas related variables
@ -135,6 +151,7 @@ class PFourierCanvas : public TObject, public TQObject
TPaveText *fTitlePad; ///< title pad used to display a title
TPad *fFourierPad; ///< fourier pad used to display the fourier
TLegend *fInfoPad; ///< info pad used to display a legend of the data plotted
TLegend *fLegAvgPerDataSet; ///< legend used for averaged per data set view
virtual void CreateXaxisTitle();
virtual void CreateStyle();
@ -152,6 +169,7 @@ class PFourierCanvas : public TObject, public TQObject
virtual Double_t GetMaximum(TH1F* histo, Double_t xmin=-1.0, Double_t xmax=-1.0);
virtual Double_t GetMinimum(TH1F* histo, Double_t xmin=-1.0, Double_t xmax=-1.0);
virtual Double_t GetInterpolatedValue(TH1F* histo, Double_t xVal);
virtual TString GetDataSetName(TString title);
ClassDef(PFourierCanvas, 1)
};

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2015 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2009-2014 by Bastian M. Wojek / Andreas Suter *
* Copyright (C) 2009-2016 by Bastian M. Wojek / Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
@ -102,6 +102,7 @@ class PMsrHandler
virtual Bool_t CheckFuncs();
virtual Bool_t CheckHistoGrouping();
virtual Bool_t CheckAddRunParameters();
virtual Bool_t CheckRRFSettings();
virtual void CheckMaxLikelihood();
virtual void GetGroupingString(Int_t runNo, TString detector, TString &groupingStr);
@ -152,7 +153,6 @@ class PMsrHandler
virtual UInt_t NeededPrecision(Double_t dval, UInt_t precLimit=13);
virtual UInt_t LastSignificant(Double_t dval, UInt_t precLimit=6);
virtual Bool_t ParseDetectorGrouping(TString str, PIntVector &group);
virtual void MakeDetectorGroupingString(TString str, PIntVector &group, TString &result, Bool_t includeDetector = true);
virtual void CheckLegacyLifetimecorrection();

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2015 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
@ -36,6 +36,12 @@ using namespace std;
#include <TString.h>
// the following ifdef is needed for GCC 4.6 or higher, fftw 3.3 or higher and root 5.30.03 or lower
#ifdef __CINT__
typedef struct { char a[7]; } __float128; // needed since cint doesn't know it
#endif
#include "fftw3.h"
#define PMUSR_SUCCESS 0
#define PMUSR_WRONG_STARTUP_SYNTAX -1
#define PMUSR_MSR_FILE_NOT_FOUND -2
@ -46,10 +52,12 @@ using namespace std;
#define PMUSR_MSR_FILE_WRITE_ERROR -7
#define PMUSR_DATA_FILE_READ_ERROR -8
#define PRUN_SINGLE_HISTO 0
#define PRUN_ASYMMETRY 2
#define PRUN_MU_MINUS 4
#define PRUN_NON_MUSR 8
#define PRUN_SINGLE_HISTO 0
#define PRUN_SINGLE_HISTO_RRF 1
#define PRUN_ASYMMETRY 2
#define PRUN_ASYMMETRY_RRF 3
#define PRUN_MU_MINUS 4
#define PRUN_NON_MUSR 8
// muon life time in (us), see PRL99, 032001 (2007)
#define PMUON_LIFETIME 2.197019
@ -86,17 +94,21 @@ using namespace std;
//-------------------------------------------------------------
// msr fit type tags
#define MSR_FITTYPE_SINGLE_HISTO 0
#define MSR_FITTYPE_ASYM 2
#define MSR_FITTYPE_MU_MINUS 4
#define MSR_FITTYPE_NON_MUSR 8
#define MSR_FITTYPE_SINGLE_HISTO 0
#define MSR_FITTYPE_SINGLE_HISTO_RRF 1
#define MSR_FITTYPE_ASYM 2
#define MSR_FITTYPE_ASYM_RRF 3
#define MSR_FITTYPE_MU_MINUS 4
#define MSR_FITTYPE_NON_MUSR 8
//-------------------------------------------------------------
// msr plot type tags
#define MSR_PLOT_SINGLE_HISTO 0
#define MSR_PLOT_ASYM 2
#define MSR_PLOT_MU_MINUS 4
#define MSR_PLOT_NON_MUSR 8
#define MSR_PLOT_SINGLE_HISTO 0
#define MSR_PLOT_SINGLE_HISTO_RRF 1
#define MSR_PLOT_ASYM 2
#define MSR_PLOT_ASYM_RRF 3
#define MSR_PLOT_MU_MINUS 4
#define MSR_PLOT_NON_MUSR 8
//-------------------------------------------------------------
// map and fun offsets for parameter parsing
@ -117,20 +129,24 @@ using namespace std;
#define FOURIER_APOD_MEDIUM 3
#define FOURIER_APOD_STRONG 4
#define FOURIER_PLOT_NOT_GIVEN 0
#define FOURIER_PLOT_REAL 1
#define FOURIER_PLOT_IMAG 2
#define FOURIER_PLOT_REAL_AND_IMAG 3
#define FOURIER_PLOT_POWER 4
#define FOURIER_PLOT_PHASE 5
#define FOURIER_PLOT_NOT_GIVEN 0
#define FOURIER_PLOT_REAL 1
#define FOURIER_PLOT_IMAG 2
#define FOURIER_PLOT_REAL_AND_IMAG 3
#define FOURIER_PLOT_POWER 4
#define FOURIER_PLOT_PHASE 5
#define FOURIER_PLOT_PHASE_OPT_REAL 6
//-------------------------------------------------------------
// RRF related tags
#define RRF_UNIT_kHz 0
#define RRF_UNIT_MHz 1
#define RRF_UNIT_Mcs 2
#define RRF_UNIT_G 3
#define RRF_UNIT_T 4
#define RRF_UNIT_UNDEF -1
#define RRF_UNIT_kHz 0
#define RRF_UNIT_MHz 1
#define RRF_UNIT_Mcs 2
#define RRF_UNIT_G 3
#define RRF_UNIT_T 4
#define RRF_FREQ_UNDEF 1.0e10
//-------------------------------------------------------------
/**
@ -535,6 +551,11 @@ class PMsrGlobalBlock {
virtual ~PMsrGlobalBlock() {}
virtual Bool_t IsPresent() { return fGlobalPresent; }
virtual Double_t GetRRFFreq(const char *unit);
virtual TString GetRRFUnit();
virtual Int_t GetRRFUnitTag() { return fRRFUnitTag; }
virtual Double_t GetRRFPhase() { return fRRFPhase; }
virtual Int_t GetRRFPacking() { return fRRFPacking; }
virtual Int_t GetFitType() { return fFitType; }
virtual Int_t GetDataRange(UInt_t idx);
virtual UInt_t GetT0BinSize() { return fT0.size(); }
@ -548,6 +569,9 @@ class PMsrGlobalBlock {
virtual Int_t GetPacking() { return fPacking; }
virtual void SetGlobalPresent(Bool_t bval) { fGlobalPresent = bval; }
virtual void SetRRFFreq(Double_t freq, const char *unit);
virtual void SetRRFPhase(Double_t phase) { fRRFPhase = phase; }
virtual void SetRRFPacking(Int_t pack);
virtual void SetFitType(Int_t ival) { fFitType = ival; }
virtual void SetDataRange(Int_t ival, Int_t idx);
virtual void SetT0Bin(Double_t dval, Int_t idx=-1);
@ -559,10 +583,14 @@ class PMsrGlobalBlock {
private:
Bool_t fGlobalPresent; ///< flag showing if a GLOBAL block is present at all.
Int_t fFitType; ///< fit type: 0=single histo fit, 2=asymmetry fit, 4=mu^- single histo fit, 8=non muSR fit
Int_t fDataRange[4]; ///< data bin range (fit type 0, 2, 4)
PDoubleVector fT0; ///< t0 bins (fit type 0, 2, 4). if fit type 0 -> f0, f1, f2, ...; if fit type 2, 4 -> f0, b0, f1, b1, ...
vector<PDoubleVector> fAddT0; ///< addt0 bins (fit type 0, 2, 4). if fit type 0 -> f0, f1, f2, ...; if fit type 2, 4 -> f0, b0, f1, b1, ...
Double_t fRRFFreq; ///< RRF frequency given in units of (MHz, Mc, T)
Int_t fRRFUnitTag; ///< RRF unit tag
Double_t fRRFPhase; ///< RRF phase in (°)
Int_t fRRFPacking; ///< RRF packing
Int_t fFitType; ///< fit type: 0=single histo fit, 1=single histo RRF fit, 2=asymmetry fit, 4=mu^- single histo fit, 8=non muSR fit
Int_t fDataRange[4]; ///< data bin range (fit type 0, 1, 2, 4)
PDoubleVector fT0; ///< t0 bins (fit type 0, 1, 2, 4). if fit type 0 -> f0, f1, f2, ...; if fit type 2, 4 -> f0, b0, f1, b1, ...
vector<PDoubleVector> fAddT0; ///< addt0 bins (fit type 0, 1, 2, 4). if fit type 0 -> f0, f1, f2, ...; if fit type 2, 4 -> f0, b0, f1, b1, ...
Bool_t fFitRangeInBins; ///< flag telling if fit range is given in time or in bins
Double_t fFitRange[2]; ///< fit range in (us)
Int_t fFitRangeOffset[2]; ///< if fit range is given in bins it can have the form fit fgb+n0 lgb-n1. This variable holds the n0 and n1.
@ -774,6 +802,7 @@ typedef struct {
TString outTemplate; ///< holds the output file template
TString year; ///< holds the information about the year to be used
PIntVector runList; ///< holds the run number list to be converted
PIntVector groupHistoList; ///< holds the histo group list offset (used to define for MusrRoot files, what to be exported)
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
@ -794,4 +823,29 @@ typedef struct {
Double_t alphaEstimateN0; ///< relates the Bkg to N0, i.e. Bkg = alpha*N0
} PStartupOptions;
//-------------------------------------------------------------
/**
* <p>Helper class which parses list of numbers of the following 3 forms and its combination.
* (i) list of integers separted by spaces, e.g. 1 3 7 14
* (ii) a range of integers of the form nS-nE, e.g. 13-27 which will generate 13, 14, 15, .., 26, 27
* (iii) a sequence of integers of the form nS:nE:nStep, e.g. 10:20:2 which will generate 10, 12, 14, .., 18, 20
*/
class PStringNumberList {
public:
PStringNumberList(char *str) { fString = str; }
PStringNumberList(string str) { fString = str; }
virtual ~PStringNumberList() { fList.clear(); }
virtual bool Parse(string &errorMsg, bool ignoreFirstToken=false);
virtual PUIntVector GetList() { return fList; }
private:
string fString;
bool fIsValid;
PUIntVector fList;
virtual bool IsNumber(string &str) { return (str.find_first_not_of("0123456789") == string::npos); }
virtual void StripSpaces();
};
#endif // _PMUSR_H_

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
@ -67,7 +67,7 @@
#define P_MENU_ID_FOURIER 10002
#define P_MENU_ID_DIFFERENCE 10003
#define P_MENU_ID_AVERAGE 10004
#define P_MENU_ID_SAVE_DATA 10005
#define P_MENU_ID_EXPORT_DATA 10005
#define P_MENU_PLOT_OFFSET 1000
@ -79,8 +79,6 @@
#define P_MENU_ID_FOURIER_PHASE_PLUS 105
#define P_MENU_ID_FOURIER_PHASE_MINUS 106
#define P_MENU_ID_SAVE_ASCII 200
//------------------------------------------------------------------------
/**
* <p>
@ -204,11 +202,13 @@ class PMusrCanvas : public TObject, public TQObject
public:
PMusrCanvas();
PMusrCanvas(const Int_t number, const Char_t* title,
Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh, const Bool_t batch);
Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh, const Bool_t batch,
const Bool_t fourier=false);
PMusrCanvas(const Int_t number, const Char_t* title,
Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh,
PMsrFourierStructure fourierDefault,
const PIntVector markerList, const PIntVector colorList, const Bool_t batch);
const PIntVector markerList, const PIntVector colorList, const Bool_t batch,
const Bool_t fourier=false);
virtual ~PMusrCanvas();
virtual Bool_t IsValid() { return fValid; }
@ -229,9 +229,10 @@ class PMusrCanvas : public TObject, public TQObject
virtual void LastCanvasClosed(); // SLOT
virtual void SaveGraphicsAndQuit(Char_t *fileName, Char_t *graphicsFormat);
virtual void SaveDataAscii();
virtual void ExportData(const Char_t *fileName);
private:
Bool_t fStartWithFourier; ///< flag if true, the Fourier transform will be presented bypassing the time domain representation
Int_t fTimeout; ///< timeout after which the Done signal should be emited. If timeout <= 0, no timeout is taking place
Bool_t fScaleN0AndBkg; ///< true=N0 and background is scaled to (1/ns), otherwise (1/bin) for the single histogram case
Bool_t fBatchMode; ///< musrview in ROOT batch mode
@ -259,7 +260,6 @@ class PMusrCanvas : public TObject, public TQObject
TRootCanvas *fImp; ///< ROOT native GUI version of main window with menubar and drawing area
TGMenuBar *fBar; ///< menu bar
TGPopupMenu *fPopupMain; ///< popup menu Musrfit in the main menu bar
TGPopupMenu *fPopupSave; ///< popup menu of the Musrfit/Save Data sub menu
TGPopupMenu *fPopupFourier; ///< popup menu of the Musrfit/Fourier sub menu
// canvas related variables

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2015 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
@ -34,7 +34,8 @@
#include <vector>
using namespace std;
#include "TH1F.h"
#include <TH1F.h>
#include <TMath.h>
#include "PMusr.h"
@ -44,11 +45,12 @@ using namespace std;
* necessary meta information.
*/
typedef struct {
TString info; ///< keeps all the meta information
double timeResolution; ///< time resolution in (usec)
int t0; ///< keep the t0 bin
Double_t timeRange[2]; ///< time range to be used, given in (usec).
PDoubleVector rawData; ///< a single time domain data vector
Int_t dataSetTag; ///< tag to label the data set. Needed for average-per-data-set
TString info; ///< keeps all the meta information
Double_t timeResolution; ///< time resolution in (usec)
Int_t t0; ///< keep the t0 bin
Double_t timeRange[2]; ///< time range to be used, given in (usec).
PDoubleVector rawData; ///< a single time domain data vector
} musrFT_data;
//----------------------------------------------------------------------------
@ -59,18 +61,19 @@ typedef struct {
class PPrepFourier {
public:
PPrepFourier();
PPrepFourier(const Int_t *bkgRange, const Int_t packing);
PPrepFourier(const Int_t packing, const Int_t *bkgRange, PDoubleVector bkg);
virtual ~PPrepFourier();
void SetBkgRange(const Int_t *bkgRange);
void SetPacking(const Int_t packing);
void AddData(musrFT_data &data);
void DoBkgCorrection();
void DoPacking();
void DoFiltering();
void DoLifeTimeCorrection(Double_t fudge);
virtual void SetBkgRange(const Int_t *bkgRange);
virtual void SetBkg(PDoubleVector bkg);
virtual void SetPacking(const Int_t packing);
virtual void AddData(musrFT_data &data);
virtual void DoBkgCorrection();
virtual void DoPacking();
virtual void DoLifeTimeCorrection(Double_t fudge);
TString GetInfo(const UInt_t idx);
Int_t GetDataSetTag(const UInt_t idx);
UInt_t GetNoOfData() { return fRawData.size(); }
vector<TH1F*> GetData();
TH1F *GetData(const UInt_t idx);
@ -79,9 +82,10 @@ class PPrepFourier {
vector<musrFT_data> fRawData;
vector<PDoubleVector>fData;
Int_t fBkgRange[2];
PDoubleVector fBkg;
Int_t fPacking;
void InitData();
virtual void InitData();
};
#endif // _PPREPFOURIER_H_

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@ -0,0 +1,81 @@
/***************************************************************************
PRunAsymmetryRRF.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef _PRUNASYMMETRYRRF_H_
#define _PRUNASYMMETRYRRF_H_
#include "PRunBase.h"
//---------------------------------------------------------------------------
/**
* <p>Class handling the asymmetry fit.
*/
class PRunAsymmetryRRF : public PRunBase
{
public:
PRunAsymmetryRRF();
PRunAsymmetryRRF(PMsrHandler *msrInfo, PRunDataHandler *rawData, UInt_t runNo, EPMusrHandleTag tag);
virtual ~PRunAsymmetryRRF();
virtual Double_t CalcChiSquare(const std::vector<Double_t>& par);
virtual Double_t CalcChiSquareExpected(const std::vector<Double_t>& par);
virtual Double_t CalcMaxLikelihood(const std::vector<Double_t>& par);
virtual void CalcTheory();
virtual UInt_t GetNoOfFitBins();
virtual void SetFitRangeBin(const TString fitRange);
protected:
virtual void CalcNoOfFitBins();
virtual Bool_t PrepareData();
virtual Bool_t PrepareFitData();
virtual Bool_t PrepareViewData(PRawRunData* runData, UInt_t histoNo[2]);
private:
UInt_t fAlphaBetaTag; ///< \f$ 1 \to \alpha = \beta = 1\f$; \f$ 2 \to \alpha \neq 1, \beta = 1\f$; \f$ 3 \to \alpha = 1, \beta \neq 1\f$; \f$ 4 \to \alpha \neq 1, \beta \neq 1\f$.
UInt_t fNoOfFitBins; ///< number of bins to be be fitted
Int_t fRRFPacking; ///< RRF packing for this particular run. Given in the GLOBAL-block.
PDoubleVector fForward; ///< forward histo data
PDoubleVector fForwardErr; ///< forward histo errors
PDoubleVector fBackward; ///< backward histo data
PDoubleVector fBackwardErr; ///< backward histo errors
Int_t fGoodBins[4]; ///< keep first/last good bins. 0=fgb, 1=lgb (forward); 2=fgb, 3=lgb (backward)
Bool_t SubtractFixBkg();
Bool_t SubtractEstimatedBkg();
virtual Bool_t GetProperT0(PRawRunData* runData, PMsrGlobalBlock *globalBlock, PUIntVector &forwardHisto, PUIntVector &backwardHistoNo);
virtual Bool_t GetProperDataRange(PRawRunData* runData, UInt_t histoNo[2]);
virtual void GetProperFitRange(PMsrGlobalBlock *globalBlock);
};
#endif // _PRUNASYMMETRYRRF_H_

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2015 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
@ -61,7 +61,7 @@ class PRunDataHandler
virtual Bool_t IsAllDataAvailable() const { return fAllDataAvailable; }
virtual PRawRunData* GetRunData(const TString &runName);
virtual PRawRunData* GetRunData(const UInt_t idx=0);
virtual TString GetRunPathName() {return fRunPathName; }
virtual Int_t GetNoOfRunData() {return fData.size(); }
private:
PMsrHandler *fMsrInfo; ///< pointer to the msr-file handler

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
@ -37,7 +37,9 @@ using namespace std;
#include "PMsrHandler.h"
#include "PRunDataHandler.h"
#include "PRunSingleHisto.h"
#include "PRunSingleHistoRRF.h"
#include "PRunAsymmetry.h"
#include "PRunAsymmetryRRF.h"
#include "PRunMuMinus.h"
#include "PRunNonMusr.h"
@ -58,7 +60,9 @@ class PRunListCollection
virtual void SetFitRange(const TString fitRange);
virtual Double_t GetSingleHistoChisq(const std::vector<Double_t>& par) const;
virtual Double_t GetSingleHistoRRFChisq(const std::vector<Double_t>& par) const;
virtual Double_t GetAsymmetryChisq(const std::vector<Double_t>& par) const;
virtual Double_t GetAsymmetryRRFChisq(const std::vector<Double_t>& par) const;
virtual Double_t GetMuMinusChisq(const std::vector<Double_t>& par) const;
virtual Double_t GetNonMusrChisq(const std::vector<Double_t>& par) const;
@ -66,7 +70,9 @@ class PRunListCollection
virtual Double_t GetSingleRunChisq(const std::vector<Double_t>& par, const UInt_t idx) const;
virtual Double_t GetSingleHistoMaximumLikelihood(const std::vector<Double_t>& par) const;
virtual Double_t GetSingleHistoRRFMaximumLikelihood(const std::vector<Double_t>& par) const;
virtual Double_t GetAsymmetryMaximumLikelihood(const std::vector<Double_t>& par) const;
virtual Double_t GetAsymmetryRRFMaximumLikelihood(const std::vector<Double_t>& par) const;
virtual Double_t GetMuMinusMaximumLikelihood(const std::vector<Double_t>& par) const;
virtual Double_t GetNonMusrMaximumLikelihood(const std::vector<Double_t>& par) const;
@ -74,12 +80,16 @@ class PRunListCollection
virtual UInt_t GetTotalNoOfBinsFitted() const;
virtual UInt_t GetNoOfSingleHisto() const { return fRunSingleHistoList.size(); } ///< returns the number of single histogram data sets present in the msr-file
virtual UInt_t GetNoOfSingleHistoRRF() const { return fRunSingleHistoRRFList.size(); } ///< returns the number of single histogram RRF data sets present in the msr-file
virtual UInt_t GetNoOfAsymmetry() const { return fRunAsymmetryList.size(); } ///< returns the number of asymmetry data sets present in the msr-file
virtual UInt_t GetNoOfAsymmetryRRF() const { return fRunAsymmetryRRFList.size(); } ///< returns the number of asymmetry RRF data sets present in the msr-file
virtual UInt_t GetNoOfMuMinus() const { return fRunMuMinusList.size(); } ///< returns the number of mu minus data sets present in the msr-file
virtual UInt_t GetNoOfNonMusr() const { return fRunNonMusrList.size(); } ///< returns the number of non-muSR data sets present in the msr-file
virtual PRunData* GetSingleHisto(UInt_t index, EDataSwitch tag=kIndex);
virtual PRunData* GetSingleHistoRRF(UInt_t index, EDataSwitch tag=kIndex);
virtual PRunData* GetAsymmetry(UInt_t index, EDataSwitch tag=kIndex);
virtual PRunData* GetAsymmetryRRF(UInt_t index, EDataSwitch tag=kIndex);
virtual PRunData* GetMuMinus(UInt_t index, EDataSwitch tag=kIndex);
virtual PRunData* GetNonMusr(UInt_t index, EDataSwitch tag=kIndex);
@ -94,10 +104,12 @@ class PRunListCollection
PMsrHandler *fMsrInfo; ///< pointer to the msr-file handler
PRunDataHandler *fData; ///< pointer to the run-data handler
vector<PRunSingleHisto*> fRunSingleHistoList; ///< stores all processed single histogram data
vector<PRunAsymmetry*> fRunAsymmetryList; ///< stores all processed asymmetry data
vector<PRunMuMinus*> fRunMuMinusList; ///< stores all processed mu-minus data
vector<PRunNonMusr*> fRunNonMusrList; ///< stores all processed non-muSR data
vector<PRunSingleHisto*> fRunSingleHistoList; ///< stores all processed single histogram data
vector<PRunSingleHistoRRF*> fRunSingleHistoRRFList; ///< stores all processed single histogram RRF data
vector<PRunAsymmetry*> fRunAsymmetryList; ///< stores all processed asymmetry data
vector<PRunAsymmetryRRF*> fRunAsymmetryRRFList; ///< stores all processed asymmetry RRF data
vector<PRunMuMinus*> fRunMuMinusList; ///< stores all processed mu-minus data
vector<PRunNonMusr*> fRunNonMusrList; ///< stores all processed non-muSR data
};
#endif // _PRUNLISTCOLLECTION_H_

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@ -0,0 +1,83 @@
/***************************************************************************
PRunSingleHistoRRF.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef _PRUNSINGLEHISTORRF_H_
#define _PRUNSINGLEHISTORRF_H_
#include "PRunBase.h"
/**
* <p>Class handling single histogram fit type.
*/
class PRunSingleHistoRRF : public PRunBase
{
public:
PRunSingleHistoRRF();
PRunSingleHistoRRF(PMsrHandler *msrInfo, PRunDataHandler *rawData, UInt_t runNo, EPMusrHandleTag tag);
virtual ~PRunSingleHistoRRF();
virtual Double_t CalcChiSquare(const std::vector<Double_t>& par);
virtual Double_t CalcChiSquareExpected(const std::vector<Double_t>& par);
virtual Double_t CalcMaxLikelihood(const std::vector<Double_t>& par);
virtual void CalcTheory();
virtual UInt_t GetNoOfFitBins();
virtual void SetFitRangeBin(const TString fitRange);
protected:
virtual void CalcNoOfFitBins();
virtual Bool_t PrepareData();
virtual Bool_t PrepareFitData(PRawRunData* runData, const UInt_t histoNo);
virtual Bool_t PrepareViewData(PRawRunData* runData, const UInt_t histoNo);
private:
static const Double_t fN0EstimateEndTime = 1.0; ///< end time in (us) over which N0 is estimated. Should eventually be estimated automatically ...
UInt_t fNoOfFitBins; ///< number of bins to be fitted
Double_t fBackground; ///< needed if background range is given (units: 1/bin)
Int_t fRRFPacking; ///< RRF packing for this particular run. Given in the GLOBAL-block.
Int_t fGoodBins[2]; ///< keep first/last good bins. 0=fgb, 1=lgb
PDoubleVector fForward; ///< forward histo data
PDoubleVector fM; ///< vector holding M(t) = [N(t)-N_bkg] exp(+t/tau). Needed to estimate N0.
PDoubleVector fMerr; ///< vector holding the error of M(t): M_err = exp(+t/tau) sqrt(N(t)).
PDoubleVector fW; ///< vector holding the weight needed to estimate N0, and errN0.
PDoubleVector fAerr; ///< vector holding the errors of estimated A(t)
virtual Bool_t GetProperT0(PRawRunData* runData, PMsrGlobalBlock *globalBlock, PUIntVector &histoNo);
virtual Bool_t GetProperDataRange();
virtual void GetProperFitRange(PMsrGlobalBlock *globalBlock);
virtual Double_t GetMainFrequency(PDoubleVector &data);
virtual Double_t EstimateN0(Double_t &errN0, Double_t freqMax);
virtual Bool_t EstimateBkg(UInt_t histoNo);
};
#endif // _PRUNSINGLEHISTORRF_H_

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@ -8,7 +8,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter *
* Copyright (C) 2007-2016 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *

View File

@ -37,6 +37,7 @@
#endif
#include "git-revision.h"
#include "PMusr.h"
#include "PMsr2Data.h"
#include <algorithm>
@ -87,12 +88,17 @@ void msr2data_syntax()
cout << endl << " [fit [-k] [-t] | fit-<template>[!] [-k] [-t] | msr-<template>]";
cout << endl << "usage 2: msr2data <run1> <run2> <extension> [-o<outputfile>] [new] [data] [[no]header] [nosummary] [global[+[!]]]";
cout << endl << " [fit [-k] [-t] | fit-<template>[!] [-k] [-t] | msr-<template>]";
cout << endl << "usage 3: msr2data \\[<run1> <run2> ... <runN>\\] <extension> [-o<outputfile> ] [new] [data] [[no]header] [nosummary] [global[+[!]]]";
cout << endl << "usage 3: msr2data \\[<runList>\\] <extension> [-o<outputfile> ] [new] [data] [[no]header] [nosummary] [global[+[!]]]";
cout << endl << " [fit [-k] [-t] | fit-<template>[!] [-k] [-t] | msr-<template>]";
cout << endl << "usage 4: msr2data <runlist> <extension> [-o<outputfile>] [new] [data] [[no]header] [nosummary] [global[+[!]]]";
cout << endl << " [fit [-k] [-t] | fit-<template>[!] [-k] [-t] | msr-<template>]";
cout << endl;
cout << endl << " <run>, <run1>, <run2>, ... <runN> : run numbers";
cout << endl << " <runList> can be:";
cout << endl << " (i) <run0>, <run1>, <run2>, ... <runN> : run numbers, e.g. 123 124";
cout << endl << " (ii) <run0>-<runN> : a range, e.g. 123-125 -> 123 124 125";
cout << endl << " (iii) <run0>:<runN>:<step> : a sequence, e.g. 123:127:2 -> 123 125 127";
cout << endl << " <step> will give the step width and has to be a positive number!";
cout << endl << " a <runList> can also combine (i)-(iii), e.g. 123 128-130 133, etc.";
cout << endl << " <extension> : msr-file extension, e.g. _tf_h13 for the file name 8472_tf_h13.msr";
cout << endl << " -o<outputfile> : specify the name of the DB or column-data output file; default: out.db/out.dat";
cout << endl << " if the option '-o none' is used, no output file will be written.";
@ -125,9 +131,27 @@ void msr2data_syntax()
cout << endl << " from this pre-analysis for each run---they are not just copied from the template.";
cout << endl << " The specification of '!' determines which fit mode (see above) is used for this pre-analysis.";
cout << endl;
cout << endl << " Typical examples:";
cout << endl;
cout << endl << " msr2data 2047 2050 _tf_histo fit-2046";
cout << endl << " will use 2046_tf_histo.msr as templete, and subsequently generating 2047_tf_histo.msr until";
cout << endl << " 2050_tf_histo.msr and fit them.";
cout << endl;
cout << endl << " msr2data 2047 2050 _tf_histo msr-2046";
cout << endl << " will use 2046_tf_histo.msr as templete, and subsequently generating 2047_tf_histo.msr until";
cout << endl << " 2050_tf_histo.msr, but NO fitting will be done.";
cout << endl;
cout << endl << " msr2data 2046 2050 _tf_histo -o fitParam.db";
cout << endl << " will collect the fit parameters from runs 2046-2050 (msr-files 2046_tf_histo.msr etc.) and";
cout << endl << " write them to the file fitParam.db (DB-format).";
cout << endl;
cout << endl << " msr2data [2047:2053:2 2056] _tf_histo fit-2045";
cout << endl << " will use 2045_tf_histo.msr as templete, and subsequently generating msr-files from the run-list:";
cout << endl << " 2047 2049 2051 2053 2056 (2047_tf_histo.msr etc.) and fit them.";
cout << endl;
cout << endl << " For further information please refer to";
cout << endl << " https://intranet.psi.ch/MUSR/Msr2Data";
cout << endl << " http://lmu.web.psi.ch/facilities/software/musrfit/user/intranet.psi.ch/MUSR/Msr2Data.html";
cout << endl << " http://lmu.web.psi.ch/musrfit/user/MUSR/Msr2Data.html";
cout << endl << " https://intranet.psi.ch/MUSR/Msr2Data";
cout << endl << endl;
}
@ -449,8 +473,26 @@ int main(int argc, char *argv[])
return 0;
}
for (unsigned int i(firstRunNumberInArg); i<=lastRunNumberInArg; ++i)
run_vec.push_back(boost::lexical_cast<unsigned int>(arg[i]));
// generate run_list string
for (unsigned int i(firstRunNumberInArg); i<=lastRunNumberInArg; ++i) {
run_list += arg[i] + " ";
}
// parse run_list string
PStringNumberList *nl = new PStringNumberList(run_list);
if (nl == 0) { // couldn't invoke object
cerr << endl;
cerr << ">> msr2data: **ERROR** Couldn't invoke run_list parser object! Quitting now." << endl;
return 0;
}
string errorMsg("");
if (!nl->Parse(errorMsg)) {
cerr << endl;
cerr << ">> msr2data: " << errorMsg << " - Quitting now." << endl;
return 0;
}
// get run list vector
run_vec = nl->GetList();
delete nl;
msrExtension = arg[rightbracket + 1];

View File

@ -59,26 +59,28 @@ using namespace std;
* <p>Structure keeping the command line options.
*/
typedef struct {
vector<TString> msrFln; ///< msr-file names to be used.
vector<TString> dataFln; ///< raw-data-file names to be used.
vector<TString> dataFileFormat; ///< file format guess
PStringVector msrFln; ///< msr-file names to be used.
PStringVector dataFln; ///< raw-data-file names to be used.
PStringVector dataFileFormat; ///< file format guess
TString graphicFormat; ///< format for the graphical output dump
TString dumpFln; ///< dump file name for Fourier data output
TString msrFlnOut; ///< dump file name for msr-file generation
int bkg[2]; ///< background range
TString fourierOpt; ///< Fourier options, i.e. real, imag, power, phase
Int_t bkg_range[2]; ///< background range
PDoubleVector bkg; ///< background value
TString fourierOpt; ///< Fourier options, i.e. real, imag, power, phase, phaseOptReal
TString apodization; ///< apodization setting: none, weak, medium, strong
int fourierPower; ///< Fourier power for zero padding, i.e. 2^fourierPower points
Int_t fourierPower; ///< Fourier power for zero padding, i.e. 2^fourierPower points
TString fourierUnits; ///< wished Fourier units: Gauss, Tesla, MHz, Mc/s
double initialPhase; ///< inital Fourier phase for Real/Imag
double fourierRange[2]; ///< Fourier range to be plotted. Given in the choosen units.
double timeRange[2]; ///< time range used for the Fourier
vector<int> histo; ///< selection of the histos used from at data file for Fourier
bool showAverage; ///< flag indicating if initially the Fourier average over the given histos shall be plotted.
vector<int> t0; ///< t0 vector for the histos. If not given t0's will be estimated.
int packing; ///< packing for rebinning the time histograms before Fourier transform.
Double_t initialPhase; ///< inital Fourier phase for Real/Imag
Double_t fourierRange[2]; ///< Fourier range to be plotted. Given in the choosen units.
Double_t timeRange[2]; ///< time range used for the Fourier
PIntVector histo; ///< selection of the histos used from at data file for Fourier
Bool_t showAverage; ///< flag indicating if initially the Fourier average over the given histos shall be plotted, this over ALL data sets.
Bool_t showAveragePerDataSet; ///< flag indicating if initially the Fourier average over the given histos shall be plotted, this per data set.
PIntVector t0; ///< t0 vector for the histos. If not given t0's will be estimated.
Int_t packing; ///< packing for rebinning the time histograms before Fourier transform.
TString title; ///< title to be shown for the Fourier plot.
double lifetimecorrection; ///< is == 0.0 for NO life time correction, otherwise it holds the fudge factor
Double_t lifetimecorrection; ///< is == 0.0 for NO life time correction, otherwise it holds the fudge factor
Int_t timeout; ///< timeout in (sec) after which musrFT will terminate. if <= 0, no automatic termination will take place.
} musrFT_startup_param;
@ -95,7 +97,7 @@ void musrFT_syntax()
cout << endl << " -df, --data-file <data-file> : This allows to feed only muSR data file(s) to";
cout << endl << " perform the Fourier transform. Since the extended <msr-file> information";
cout << endl << " are missing, they will need to be provided by to options, or musrFT";
cout << endl << " tries to guess, based on musrFT_startup.xml settings.";
cout << endl << " tries to guess, based on musrfit_startup.xml settings.";
cout << endl << " Options: ";
cout << endl << " --help : display this help and exit";
cout << endl << " --version : output version information and exit";
@ -106,13 +108,13 @@ void musrFT_syntax()
cout << endl << " Supported graphic-format-extension: eps, pdf, gif, jpg, png, svg, xpm, root";
cout << endl << " --dump <fln> : rather than starting a root session and showing Fourier graphs of the data,";
cout << endl << " it will output the Fourier data in an ascii file <fln>.";
cout << endl << " --filter : filter and filter-specific-information -- ***TO BE WRITTEN YET***.";
cout << endl << " -b, --background <start> <end>: background interval used to estimate the backround to be";
cout << endl << " -br, --background-range <start> <end>: background interval used to estimate the background to be";
cout << endl << " subtracted before the Fourier transform. <start>, <end> to be given in bins.";
cout << endl << " -fo, --fourier-option <fopt>: <fopt> can be 'real', 'imag', 'real+imag', 'power', or 'phase'.";
cout << endl << " If this is not defined (neither on the command line nor in the musrFT_startup.xml),";
cout << endl << " -bg, --background <list> : gives the background explicit for each histogram.";
cout << endl << " -fo, --fourier-option <fopt>: <fopt> can be 'real', 'imag', 'real+imag', 'power', 'phase', or 'phaseOptReal'.";
cout << endl << " If this is not defined (neither on the command line nor in the musrfit_startup.xml),";
cout << endl << " default will be 'power'.";
cout << endl << " -apod, --apodization <val> : <val> can be either 'none', 'weak', 'medium', 'strong'.";
cout << endl << " -ap, --apodization <val> : <val> can be either 'none', 'weak', 'medium', 'strong'.";
cout << endl << " Default will be 'none'.";
cout << endl << " -fp, --fourier-power <N> : <N> being the Fourier power, i.e. 2^<N> used for zero padding.";
cout << endl << " Default is -1, i.e. no zero padding will be performed.";
@ -132,9 +134,11 @@ void musrFT_syntax()
cout << endl << " E.g. musrFT -df lem15_his_01234.root --histo 1 3, will only be needed together with";
cout << endl << " the option --data-file. If multiple data file are given, <list> will apply";
cout << endl << " to all data-files given. If --histo is not given, all histos of a data file will be used.";
cout << endl << " -a, --average : show the average of all Fourier transformed data.";
cout << endl << " <list> can be anything like: 2 3 6, or 2-17, or 1-6 9, etc.";
cout << endl << " -a, --average : show the average of ALL Fourier transformed data.";
cout << endl << " -ad, --average-per-data-set : show the average of the Fourier transformed data per data set.";
cout << endl << " --t0 <list> : A list of t0's can be provided. This in conjunction with --data-file and";
cout << endl << " --fourier-option real allows to get the proper inital phase if t0's are known.";
cout << endl << " --fourier-option real allows to get the proper initial phase if t0's are known.";
cout << endl << " If a single t0 for multiple histos is given, it is assume, that this t0 is common";
cout << endl << " to all histos.";
cout << endl << " Example: musrFT -df lem15_his_01234.root -fo real --t0 2750 --histo 1 3";
@ -160,8 +164,8 @@ void musrFT_init(musrFT_startup_param &startupParam)
startupParam.graphicFormat = TString("");
startupParam.dumpFln = TString("");
startupParam.msrFlnOut = TString("");
startupParam.bkg[0] = -1;
startupParam.bkg[1] = -1;
startupParam.bkg_range[0] = -1;
startupParam.bkg_range[1] = -1;
startupParam.fourierOpt = TString("??");
startupParam.apodization = TString("none");
startupParam.fourierPower = -1;
@ -172,6 +176,7 @@ void musrFT_init(musrFT_startup_param &startupParam)
startupParam.timeRange[0] = -1.0;
startupParam.timeRange[1] = -1.0;
startupParam.showAverage = false;
startupParam.showAveragePerDataSet = false;
startupParam.packing = 1;
startupParam.title = TString("");
startupParam.lifetimecorrection = 0.0;
@ -194,9 +199,9 @@ void musrFT_init(musrFT_startup_param &startupParam)
* \param argv list of command line tokens
* \param startupParam startup parameter structure
*/
bool musrFT_filter_histo(int &i, int argc, char *argv[], musrFT_startup_param &startupParam)
Bool_t musrFT_filter_histo(Int_t &i, Int_t argc, Char_t *argv[], musrFT_startup_param &startupParam)
{
int start = i+1, end = 0;
Int_t start = i+1, end = 0;
// find last element of histo option
while (++i < argc) {
@ -215,7 +220,7 @@ bool musrFT_filter_histo(int &i, int argc, char *argv[], musrFT_startup_param &s
// handle histo arguments
TString tstr("");
for (int j=start; j<end; j++) {
for (Int_t j=start; j<end; j++) {
tstr = argv[j];
if (!tstr.Contains("-")) { // likely to be a single number
if (tstr.IsDigit()) {
@ -234,7 +239,7 @@ bool musrFT_filter_histo(int &i, int argc, char *argv[], musrFT_startup_param &s
}
TObjString *ostr;
TString sstr("");
int first=0, last=0;
Int_t first=0, last=0;
ostr = dynamic_cast<TObjString*>(tok->At(0));
sstr = ostr->GetString();
if (sstr.IsDigit()) {
@ -262,7 +267,7 @@ bool musrFT_filter_histo(int &i, int argc, char *argv[], musrFT_startup_param &s
return false;
}
for (int k=first; k<=last; k++) {
for (Int_t k=first; k<=last; k++) {
startupParam.histo.push_back(k);
}
@ -285,11 +290,11 @@ bool musrFT_filter_histo(int &i, int argc, char *argv[], musrFT_startup_param &s
* \param argv command line argument array
* \param startupParam command line data structure
*/
int musrFT_parse_options(int argc, char *argv[], musrFT_startup_param &startupParam)
Int_t musrFT_parse_options(Int_t argc, Char_t *argv[], musrFT_startup_param &startupParam)
{
TString tstr("");
for (int i=1; i<argc; i++) {
for (Int_t i=1; i<argc; i++) {
tstr = argv[i];
if (tstr.BeginsWith("--version")) {
#ifdef HAVE_CONFIG_H
@ -321,40 +326,58 @@ int musrFT_parse_options(int argc, char *argv[], musrFT_startup_param &startupPa
}
startupParam.dumpFln = argv[i+1];
i++;
} else if (tstr.Contains("--filter")) {
cout << endl << "debug> found option filter. NOT YET ANY FUNCTIONALITY." << endl;
} else if (tstr.Contains("-b") || tstr.Contains("--background")) {
} else if (tstr.Contains("-br") || tstr.Contains("--background-range")) {
if (i+2 >= argc) { // something is wrong since there needs to be two arguments here
cerr << endl << ">> musrFT **ERROR** found option --background with wrong number of arguments." << endl;
cerr << endl << ">> musrFT **ERROR** found option --background-range with wrong number of arguments." << endl;
return 2;
}
TString bkg[2];
bkg[0] = argv[i+1];
bkg[1] = argv[i+2];
if (!bkg[0].IsDigit()) {
cerr << endl << ">> musrFT **ERROR** <start> bin of option --background is NOT an int-number! ('" << bkg[0] << "')." << endl;
TString bkgRange[2];
bkgRange[0] = argv[i+1];
bkgRange[1] = argv[i+2];
if (!bkgRange[0].IsDigit()) {
cerr << endl << ">> musrFT **ERROR** <start> bin of option --background-range is NOT an int-number! ('" << bkgRange[0] << "')." << endl;
return 2;
}
if (!bkg[1].IsDigit()) {
cerr << endl << ">> musrFT **ERROR** <end> bin of option --background is NOT an int-number! ('" << bkg[1] << "')." << endl;
if (!bkgRange[1].IsDigit()) {
cerr << endl << ">> musrFT **ERROR** <end> bin of option --background-range is NOT an int-number! ('" << bkgRange[1] << "')." << endl;
return 2;
}
startupParam.bkg[0] = bkg[0].Atoi();
startupParam.bkg[1] = bkg[1].Atoi();
startupParam.bkg_range[0] = bkgRange[0].Atoi();
startupParam.bkg_range[1] = bkgRange[1].Atoi();
i += 2;
} else if (tstr.BeginsWith("-bg") || !tstr.CompareTo("--background")) {
TString topt("");
while (++i < argc) {
if (argv[i][0] == '-') {
--i;
break;
} else {
topt = argv[i];
if (!topt.IsFloat()) {
cerr << endl << ">> musrFT **ERROR** found option --background='" << topt << "' which is not a float" << endl;
return 2;
}
startupParam.bkg.push_back(topt.Atoi());
}
}
if (startupParam.bkg.size() == 0) { // something is wrong since there needs to be an argument here
cerr << endl << ">> musrFT **ERROR** found option --background without argument!" << endl;
return 2;
}
} else if (tstr.BeginsWith("-fo") || tstr.BeginsWith("--fourier-option")) {
if (i+1 >= argc) { // something is wrong since there needs to be two arguments here
cerr << endl << ">> musrFT **ERROR** found option --fourier-option without arguments." << endl;
return 2;
}
TString topt(argv[i+1]);
if (!topt.BeginsWith("real") && !topt.BeginsWith("imag") && !topt.BeginsWith("power") && !topt.BeginsWith("phase")) {
if (!topt.BeginsWith("real") && !topt.BeginsWith("imag") && !topt.BeginsWith("power") &&
!topt.BeginsWith("phase") && !topt.BeginsWith("phaseOptReal")) {
cerr << endl << ">> musrFT **ERROR** found option --fourier-option with unrecognized argument '" << topt << "'." << endl;
return 2;
}
startupParam.fourierOpt = topt;
i++;
} else if (tstr.BeginsWith("-apod") || tstr.BeginsWith("--apodization")) {
} else if (tstr.BeginsWith("-ap") || tstr.BeginsWith("--apodization")) {
if (i+1 >= argc) { // something is wrong since there needs to be two arguments here
cerr << endl << ">> musrFT **ERROR** found option --apodization without arguments." << endl;
return 2;
@ -433,8 +456,10 @@ int musrFT_parse_options(int argc, char *argv[], musrFT_startup_param &startupPa
startupParam.timeRange[0] = timeRange[0].Atof();
startupParam.timeRange[1] = timeRange[1].Atof();
i += 2;
} else if (tstr.BeginsWith("-a") || tstr.BeginsWith("--average")) {
} else if (!tstr.CompareTo("-a") || !tstr.CompareTo("--average")) {
startupParam.showAverage = true;
} else if (!tstr.CompareTo("-ad") || !tstr.CompareTo("--average-per-data-set")) {
startupParam.showAveragePerDataSet = true;
} else if (tstr.BeginsWith("--histo")) {
if (!musrFT_filter_histo(i, argc, argv, startupParam))
return 2;
@ -453,7 +478,7 @@ int musrFT_parse_options(int argc, char *argv[], musrFT_startup_param &startupPa
startupParam.t0.push_back(topt.Atoi());
}
}
if (startupParam.dataFln.size() == 0) { // something is wrong since there needs to be an argument here
if (startupParam.t0.size() == 0) { // something is wrong since there needs to be an argument here
cerr << endl << ">> musrFT **ERROR** found option --t0 without argument!" << endl;
return 2;
}
@ -518,8 +543,10 @@ int musrFT_parse_options(int argc, char *argv[], musrFT_startup_param &startupPa
TString fileFormat("??");
if (fln.Contains(".root", TString::kIgnoreCase))
fileFormat = "MusrRoot";
else if (fln.Contains(".bin", TString::kIgnoreCase) || fln.Contains(".mdu", TString::kIgnoreCase))
else if (fln.Contains(".bin", TString::kIgnoreCase))
fileFormat = "PsiBin";
else if (fln.Contains(".mdu", TString::kIgnoreCase))
fileFormat = "PsiMdu";
else if (fln.Contains(".nxs", TString::kIgnoreCase))
fileFormat = "NeXus";
else if (fln.Contains(".msr", TString::kIgnoreCase))
@ -550,18 +577,22 @@ int musrFT_parse_options(int argc, char *argv[], musrFT_startup_param &startupPa
cerr << endl << ">> musrFT **ERROR** neither <msr-file> nor <data-file> defined." << endl;
return 2;
}
if (startupParam.bkg[0] > startupParam.bkg[1]) {
cerr << endl << ">> musrFT **WARNING** in --background, start=" << startupParam.bkg[0] << " > end=" << startupParam.bkg[1] << ", will swap them." << endl;
double swap = startupParam.bkg[0];
startupParam.bkg[0] = startupParam.bkg[1];
startupParam.bkg[1] = swap;
if (startupParam.bkg_range[0] > startupParam.bkg_range[1]) {
cerr << endl << ">> musrFT **WARNING** in --background-range, start=" << startupParam.bkg_range[0] << " > end=" << startupParam.bkg_range[1] << ", will swap them." << endl;
Double_t swap = startupParam.bkg_range[0];
startupParam.bkg_range[0] = startupParam.bkg_range[1];
startupParam.bkg_range[1] = swap;
}
if (startupParam.fourierRange[0] > startupParam.fourierRange[1]) {
cerr << endl << ">> musrFT **WARNING** in --fourier-range, start=" << startupParam.fourierRange[0] << " > end=" << startupParam.fourierRange[1] << ", will swap them." << endl;
double swap = startupParam.fourierRange[0];
Double_t swap = startupParam.fourierRange[0];
startupParam.fourierRange[0] = startupParam.fourierRange[1];
startupParam.fourierRange[1] = swap;
}
if (startupParam.showAverage && startupParam.showAveragePerDataSet) {
cerr << endl << ">> musrFT **WARNING** Options: --average and --average-per-data-set exclude each other, will choose the latter." << endl;
startupParam.showAverage = false;
}
return 0;
}
@ -576,7 +607,7 @@ int musrFT_parse_options(int argc, char *argv[], musrFT_startup_param &startupPa
*/
void musrFT_getMetaInfo(const TString fln, PRawRunData *rawRunData, TString &metaInfo)
{
double dval;
Double_t dval;
TString str = fln;
// file name
// trunc it in case a path-name is given
@ -625,12 +656,12 @@ void musrFT_estimateT0(musrFT_data &rd)
cout << endl << " '" << rd.info << "'";
cout << endl << " NO warranty this is sensible!" << endl;
unsigned int idx = 0;
double max = rd.rawData[0];
for (unsigned int i=1; i<rd.rawData.size(); i++) {
UInt_t idx = 0;
Double_t max = rd.rawData[0];
for (UInt_t i=1; i<rd.rawData.size(); i++) {
if (rd.rawData[i] > max) {
max = rd.rawData[i];
idx = (int)i;
idx = (Int_t)i;
}
}
cout << endl << ">> musrFT_estimateT0: estimated t0=" << idx << endl;
@ -660,7 +691,7 @@ void musrFT_cleanup(TH1F *h)
* \param start starting point from where the data shall be written to file.
* \param end ending point up to where the data shall be written to file.
*/
int musrFT_dumpData(TString fln, vector<PFourier*> &fourierData, double start, double end)
Int_t musrFT_dumpData(TString fln, vector<PFourier*> &fourierData, Double_t start, Double_t end)
{
vector<PDoubleVector> data;
PDoubleVector freq;
@ -678,19 +709,19 @@ int musrFT_dumpData(TString fln, vector<PFourier*> &fourierData, double start, d
end = hRe->GetBinCenter(hRe->GetNbinsX());
}
unsigned int minSize = hRe->GetNbinsX()-1;
UInt_t minSize = hRe->GetNbinsX()-1;
musrFT_cleanup(hRe);
for (unsigned int i=1; i<fourierData.size(); i++) {
for (UInt_t i=1; i<fourierData.size(); i++) {
hRe = fourierData[i]->GetRealFourier();
if (hRe->GetNbinsX()-1 < minSize)
minSize = hRe->GetNbinsX()-1;
musrFT_cleanup(hRe);
}
for (unsigned int i=0; i<fourierData.size(); i++) {
for (UInt_t i=0; i<fourierData.size(); i++) {
hRe = fourierData[i]->GetRealFourier();
hIm = fourierData[i]->GetImaginaryFourier();
for (int j=1; j<minSize; j++) {
for (Int_t j=1; j<minSize; j++) {
dval = hRe->GetBinCenter(j);
if ((dval >= start) && (dval <= end)) {
freq.push_back(dval);
@ -716,13 +747,13 @@ int musrFT_dumpData(TString fln, vector<PFourier*> &fourierData, double start, d
// write header
fout << "% ";
for (unsigned int i=0; i<fourierData.size()-1; i++)
for (UInt_t i=0; i<fourierData.size()-1; i++)
fout << "freq" << i << ", Re[d" << i << "], Im[d" << i << "], Pwr[d" << i << "], ";
fout << "freq" << fourierData.size()-1 << ", Re[d" << fourierData.size()-1 << "], Im[d" << fourierData.size()-1 << "], Pwr[d" << fourierData.size()-1 << "]" << endl;
// write data
for (unsigned int j=0; j<data[0].size(); j++) {
for (unsigned int i=0; i<data.size()-1; i++) {
for (UInt_t j=0; j<data[0].size(); j++) {
for (UInt_t i=0; i<data.size()-1; i++) {
fout << data[i][j] << ", ";
}
fout << data[data.size()-1][j] << endl;
@ -742,7 +773,7 @@ int musrFT_dumpData(TString fln, vector<PFourier*> &fourierData, double start, d
* \param run reference to the relevant RUN block of the msr-file
* \param rd data collection which will hold the grouped histograms.
*/
int musrFT_groupHistos(PRunDataHandler *runDataHandler, PMsrGlobalBlock *global, PMsrRunBlock &run, musrFT_data &rd)
Int_t musrFT_groupHistos(PRunDataHandler *runDataHandler, PMsrGlobalBlock *global, PMsrRunBlock &run, musrFT_data &rd)
{
// get proper raw run data set
TString runName = *(run.GetRunName());
@ -754,7 +785,7 @@ int musrFT_groupHistos(PRunDataHandler *runDataHandler, PMsrGlobalBlock *global,
// keep histo list
PIntVector histoList;
for (unsigned int i=0; i<run.GetForwardHistoNoSize(); i++) {
for (UInt_t i=0; i<run.GetForwardHistoNoSize(); i++) {
histoList.push_back(run.GetForwardHistoNo(i));
}
@ -762,10 +793,10 @@ int musrFT_groupHistos(PRunDataHandler *runDataHandler, PMsrGlobalBlock *global,
PDoubleVector t0;
t0.resize(histoList.size());
// init t0 vector
for (unsigned int i=0; i<t0.size(); i++)
for (UInt_t i=0; i<t0.size(); i++)
t0[i] = -1.0;
// 1st: check in the global block
for (unsigned int i=0; i<global->GetT0BinSize(); i++) {
for (UInt_t i=0; i<global->GetT0BinSize(); i++) {
if (i >= t0.size()) { // something is VERY strange
cerr << endl << ">> musrFT_groupHistos **WARNING** found #t0's in GLOBAL block > #histos!";
cerr << endl << ">> This should NEVER happen. Will ignore these entries.";
@ -775,7 +806,7 @@ int musrFT_groupHistos(PRunDataHandler *runDataHandler, PMsrGlobalBlock *global,
}
}
// 2nd: check in the run block
for (unsigned int i=0; i<run.GetT0BinSize(); i++) {
for (UInt_t i=0; i<run.GetT0BinSize(); i++) {
if (i >= t0.size()) { // something is VERY strange
cerr << endl << ">> musrFT_groupHistos **WARNING** found #t0's in RUN block > #histos!";
cerr << endl << ">> This should NEVER happen. Will ignore these entries.";
@ -785,15 +816,15 @@ int musrFT_groupHistos(PRunDataHandler *runDataHandler, PMsrGlobalBlock *global,
}
}
// if still some t0's are == -1, estimate t0
unsigned int idx;
double max;
for (unsigned int i=0; i<t0.size(); i++) {
UInt_t idx;
Double_t max;
for (UInt_t i=0; i<t0.size(); i++) {
if (t0[i] == -1.0) {
cout << endl << ">> musrFT_groupHistos **WARNING** try to estimate t0 from maximum in the data set";
cout << endl << ">> '" << runName << "', histo " << histoList[i] << ". NO warranty this is sensible!";
idx = 0;
max = rawRunData->GetDataBin(histoList[i])->at(0);
for (unsigned int j=1; j<rawRunData->GetDataBin(histoList[i])->size(); j++) {
for (UInt_t j=1; j<rawRunData->GetDataBin(histoList[i])->size(); j++) {
if (rawRunData->GetDataBin(histoList[i])->at(j) > max) {
max = rawRunData->GetDataBin(histoList[i])->at(j);
idx = j;
@ -806,8 +837,8 @@ int musrFT_groupHistos(PRunDataHandler *runDataHandler, PMsrGlobalBlock *global,
// group histos
PDoubleVector data = *(rawRunData->GetDataBin(histoList[0]));
for (unsigned int i=1; i<histoList.size(); i++) {
for (unsigned int j=0; j<data.size(); j++) {
for (UInt_t i=1; i<histoList.size(); i++) {
for (UInt_t j=0; j<data.size(); j++) {
if ((j+t0[i]-t0[0] >= 0) && (j+t0[i]-t0[0] < rawRunData->GetDataBin(histoList[i])->size())) {
data[j] += rawRunData->GetDataBin(histoList[i])->at(j);
}
@ -816,7 +847,7 @@ int musrFT_groupHistos(PRunDataHandler *runDataHandler, PMsrGlobalBlock *global,
rd.rawData.clear();
rd.rawData = data;
rd.t0 = (int)t0[0];
rd.t0 = (Int_t)t0[0];
return 0;
}
@ -862,21 +893,23 @@ void musrFT_dumpMsrFile(musrFT_startup_param &param)
// write RUN block
// get extension of the data file
TString fileFormat("MUSR-ROOT");
for (unsigned int i=0; i<param.dataFln.size(); i++) {
for (UInt_t i=0; i<param.dataFln.size(); i++) {
if (param.dataFileFormat[i].BeginsWith("PsiBin"))
fileFormat = TString("PSI-BIN");
else if (param.dataFileFormat[i].BeginsWith("PsiMdu"))
fileFormat = TString("PSI-MDU");
else if (param.dataFileFormat[i].BeginsWith("NeXus"))
fileFormat = TString("NEXUS");
else if (param.dataFileFormat[i].BeginsWith("Mud"))
fileFormat = TString("MUD");
for (unsigned int j=0; j<param.histo.size(); j++) {
for (UInt_t j=0; j<param.histo.size(); j++) {
fout << "RUN " << param.dataFln[i] << " BXXX IXX " << fileFormat << " (name beamline institute data-file-format)" << endl;
fout << "forward " << param.histo[j] << endl;
if ((param.t0.size() > 1) && (j < param.t0.size())) {
fout << "t0 " << param.t0[j] << endl;
}
if ((param.bkg[0] > -1) && (param.bkg[1] > -1))
fout << "background " << param.bkg[0] << " " << param.bkg[1] << endl;
if ((param.bkg_range[0] > -1) && (param.bkg_range[1] > -1))
fout << "background " << param.bkg_range[0] << " " << param.bkg_range[1] << endl;
fout << "#--------------------------------------------------------------" << endl;
}
}
@ -889,7 +922,7 @@ void musrFT_dumpMsrFile(musrFT_startup_param &param)
fout << "runs 1" << endl;
} else {
fout << "runs ";
for (unsigned int i=0; i<param.histo.size(); i++)
for (UInt_t i=0; i<param.histo.size(); i++)
fout << i+1 << " ";
fout << endl;
}
@ -909,9 +942,9 @@ void musrFT_dumpMsrFile(musrFT_startup_param &param)
fout << "units " << param.fourierUnits << " # units either 'Gauss', 'MHz', or 'Mc/s'" << endl;
}
if (param.fourierOpt.BeginsWith("??")) { // Fourier plot option not given, hence choose POWER
fout << "plot POWER # REAL, IMAG, REAL_AND_IMAG, POWER, PHASE" << endl;
fout << "plot POWER # REAL, IMAG, REAL_AND_IMAG, POWER, PHASE, PHASE_OPT_REAL" << endl;
} else {
fout << "plot " << param.fourierOpt << " # REAL, IMAG, REAL_AND_IMAG, POWER, PHASE" << endl;
fout << "plot " << param.fourierOpt << " # REAL, IMAG, REAL_AND_IMAG, POWER, PHASE, PHASE_OPT_REAL" << endl;
}
if (param.fourierPower > 1) {
fout << "fourier_power " << param.fourierPower << endl;
@ -930,12 +963,12 @@ void musrFT_dumpMsrFile(musrFT_startup_param &param)
*
* <b>return:</b> time stamp with msec resolution.
*/
double millitime()
Double_t millitime()
{
struct timeval now;
gettimeofday(&now, 0);
return ((double)now.tv_sec * 1.0e6 + (double)now.tv_usec)/1.0e3;
return ((Double_t)now.tv_sec * 1.0e6 + (Double_t)now.tv_usec)/1.0e3;
}
//-------------------------------------------------------------------------
@ -949,7 +982,7 @@ double millitime()
* \param argc number of command line arguments
* \param argv command line argument array
*/
int main(int argc, char *argv[])
Int_t main(Int_t argc, Char_t *argv[])
{
Int_t unitTag = FOURIER_UNIT_NOT_GIVEN;
Int_t apodTag = F_APODIZATION_NONE;
@ -966,9 +999,9 @@ int main(int argc, char *argv[])
musrFT_init(startupParam);
// parse command line options
int status = musrFT_parse_options(argc, argv, startupParam);
Int_t status = musrFT_parse_options(argc, argv, startupParam);
if (status != 0) {
int retVal = PMUSR_SUCCESS;
Int_t retVal = PMUSR_SUCCESS;
if (status == 2) {
musrFT_syntax();
retVal = PMUSR_WRONG_STARTUP_SYNTAX;
@ -983,7 +1016,7 @@ int main(int argc, char *argv[])
}
// read startup file
char startup_path_name[128];
Char_t startup_path_name[128];
PStartupOptions startup_options;
startup_options.writeExpectedChisq = false;
startup_options.estimateN0 = true;
@ -1027,12 +1060,12 @@ int main(int argc, char *argv[])
startupHandler->SetStartupOptions(startup_options);
// defines the raw time-domain data vector
PPrepFourier data(startupParam.bkg, startupParam.packing);
PPrepFourier data(startupParam.packing, startupParam.bkg_range, startupParam.bkg);
// load msr-file(s)
vector<PMsrHandler*> msrHandler;
msrHandler.resize(startupParam.msrFln.size());
for (unsigned int i=0; i<startupParam.msrFln.size(); i++) {
for (UInt_t i=0; i<startupParam.msrFln.size(); i++) {
msrHandler[i] = new PMsrHandler(startupParam.msrFln[i].Data(), startupHandler->GetStartupOptions(), true);
status = msrHandler[i]->ReadMsrFile();
if (status != PMUSR_SUCCESS) {
@ -1054,7 +1087,7 @@ int main(int argc, char *argv[])
vector<PRunDataHandler*> runDataHandler;
runDataHandler.resize(startupParam.msrFln.size()+startupParam.dataFln.size()); // resize to the total number of run data provided
// load data-file(s) related to msr-file
for (unsigned int i=0; i<msrHandler.size(); i++) {
for (UInt_t i=0; i<msrHandler.size(); i++) {
// create run data handler
if (startupHandler)
runDataHandler[i] = new PRunDataHandler(msrHandler[i], startupHandler->GetDataPathList());
@ -1063,7 +1096,7 @@ int main(int argc, char *argv[])
}
// load data-file(s) provided directly
for (unsigned int i=msrHandler.size(); i<msrHandler.size()+startupParam.dataFln.size(); i++) {
for (UInt_t i=msrHandler.size(); i<msrHandler.size()+startupParam.dataFln.size(); i++) {
// create run data handler
if (startupHandler)
runDataHandler[i] = new PRunDataHandler(startupParam.dataFln[i-msrHandler.size()], startupParam.dataFileFormat[i-msrHandler.size()], startupHandler->GetDataPathList());
@ -1072,7 +1105,14 @@ int main(int argc, char *argv[])
}
// read all the data files
for (unsigned int i=0; i<runDataHandler.size(); i++) {
musrFT_data rd;
rd.dataSetTag = -1;
Int_t dataSetTagCounter = 0;
TString prevDataSetPathName("");
TString str(""), fln("");
UInt_t idx=0;
for (UInt_t i=0; i<runDataHandler.size(); i++) {
runDataHandler[i]->ReadData();
if (!runDataHandler[i]->IsAllDataAvailable()) {
@ -1097,8 +1137,8 @@ int main(int argc, char *argv[])
// first check of histo list makes sense
if (i >= msrHandler.size()) { // only check if originating from data-files (not msr-files)
for (unsigned int j=0; j<startupParam.histo.size(); j++) {
if ((unsigned int)startupParam.histo[j] > rawRunData->GetNoOfHistos()) {
for (UInt_t j=0; j<startupParam.histo.size(); j++) {
if ((UInt_t)startupParam.histo[j] > rawRunData->GetNoOfHistos()) {
cerr << endl << ">> musrFT **ERROR** found histo no " << startupParam.histo[j] << " > # of histo in the file (";
cerr << startupParam.dataFln[i] << " // # histo: " << rawRunData->GetNoOfHistos() << ")." << endl;
return PMUSR_DATA_FILE_READ_ERROR;
@ -1106,14 +1146,11 @@ int main(int argc, char *argv[])
}
if (startupParam.histo.size() == 0) { // no histo list given
// set histo list to ALL available histos for the data file
for (unsigned int j=0; j<rawRunData->GetNoOfHistos(); j++)
for (UInt_t j=0; j<rawRunData->GetNoOfHistos(); j++)
startupParam.histo.push_back(j+1);
}
}
musrFT_data rd;
TString str(""), fln("");
unsigned int idx=0;
// get meta info, time resolution, time range, raw data sets
if (i < msrHandler.size()) { // obtain info from msr-files
// keep title if not overwritten by the command line
@ -1146,13 +1183,44 @@ int main(int argc, char *argv[])
if (fourierBlock->fFourierBlockPresent) {
// get units
unitTag = fourierBlock->fUnits;
if (startupParam.fourierUnits.BeginsWith("??")) {
switch (unitTag) {
case FOURIER_UNIT_GAUSS:
startupParam.fourierUnits = TString("Gauss");
break;
case FOURIER_UNIT_TESLA:
startupParam.fourierUnits = TString("Tesla");
break;
case FOURIER_UNIT_FREQ:
startupParam.fourierUnits = TString("MHz");
break;
case FOURIER_UNIT_CYCLES:
startupParam.fourierUnits = TString("Mc/s");
break;
default:
break;
}
}
// get fourier power
if (startupParam.fourierPower == -1) { // no Fourier power given from the command line, hence check FOURIER block
if (fourierBlock->fFourierPower > 1)
startupParam.fourierPower = fourierBlock->fFourierPower;
}
// get apodization tag
apodTag = fourierBlock->fApodization;
switch (fourierBlock->fApodization) {
case FOURIER_APOD_WEAK:
startupParam.apodization = "weak";
break;
case FOURIER_APOD_MEDIUM:
startupParam.apodization = "medium";
break;
case FOURIER_APOD_STRONG:
startupParam.apodization = "strong";
break;
default:
startupParam.apodization = "none";
break;
}
// get range
if ((startupParam.fourierRange[0] == -1) && (startupParam.fourierRange[1] == -1)) { // no Fourier range given from the command line
startupParam.fourierRange[0] = fourierBlock->fPlotRange[0];
@ -1169,20 +1237,27 @@ int main(int argc, char *argv[])
PIntVector runList = plot->at(0).fRuns;
// loop over all runs listed in the msr-file PLOT block
for (unsigned int j=0; j<runList.size(); j++) {
for (UInt_t j=0; j<runList.size(); j++) {
// check if the data set name has changed
str = *(runs->at(runList[j]-1).GetRunName()); // get the name from the msr-file RUN block
if (prevDataSetPathName.CompareTo(str)) { // i.e. data set name changed
rd.dataSetTag = dataSetTagCounter++;
prevDataSetPathName = str;
}
// keep forward histo list
PIntVector histoList;
for (unsigned int k=0; k<runs->at(runList[j]-1).GetForwardHistoNoSize(); k++) {
for (UInt_t k=0; k<runs->at(runList[j]-1).GetForwardHistoNoSize(); k++) {
histoList.push_back(runs->at(runList[j]-1).GetForwardHistoNo(k));
}
// handle meta information
fln = runDataHandler[i]->GetRunPathName();
fln = *(runs->at(runList[j]-1).GetRunName()); // get the name from the msr-file RUN block
musrFT_getMetaInfo(fln, rawRunData, str);
TString hh("");
hh = TString::Format("h%d", histoList[0]);
for (unsigned int k=1; k<histoList.size(); k++)
for (UInt_t k=1; k<histoList.size(); k++)
hh += TString::Format("/%d", histoList[k]);
hh += ":";
rd.info = hh;
@ -1222,10 +1297,28 @@ int main(int argc, char *argv[])
if (startupParam.packing > 1)
pack = startupParam.packing;
data.SetPacking(pack);
// get background range
Int_t bkgStart=-1, bkgEnd=-1;
bkgStart = runs->at(runList[j]-1).GetBkgRange(0);
bkgEnd = runs->at(runList[j]-1).GetBkgRange(1);
if ((startupParam.bkg_range[0] == -1) && (bkgStart != -1))
startupParam.bkg_range[0] = bkgStart;
if ((startupParam.bkg_range[1] == -1) && (bkgEnd != -1))
startupParam.bkg_range[1] = bkgEnd;
data.SetBkgRange(startupParam.bkg_range);
}
} else { // obtain info from command line options for direct data-file read
// check if the data set name has changed
// since data-files are given, each PRunDataHandler object contains only a SINGLE data file.
str = *(runDataHandler[i]->GetRunData()->GetFileName()); // get the data set name
if (prevDataSetPathName.CompareTo(str)) { // i.e. data set name changed
rd.dataSetTag = dataSetTagCounter++;
prevDataSetPathName = str;
}
musrFT_getMetaInfo(startupParam.dataFln[i-msrHandler.size()], rawRunData, str);
for (unsigned int j=0; j<startupParam.histo.size(); j++) {
for (UInt_t j=0; j<startupParam.histo.size(); j++) {
idx = startupParam.histo[j];
// handle meta information
@ -1258,6 +1351,12 @@ int main(int argc, char *argv[])
}
}
// generate data set label vector
PIntVector dataSetTag;
for (UInt_t i=0; i<data.GetNoOfData(); i++) {
dataSetTag.push_back(data.GetDataSetTag(i));
}
// make sure Fourier plot tag is set
if (fourierPlotTag == FOURIER_PLOT_NOT_GIVEN) {
if (!startupParam.fourierOpt.CompareTo("real", TString::kIgnoreCase))
@ -1270,6 +1369,8 @@ int main(int argc, char *argv[])
fourierPlotTag = FOURIER_PLOT_POWER;
else if (!startupParam.fourierOpt.CompareTo("phase", TString::kIgnoreCase))
fourierPlotTag = FOURIER_PLOT_PHASE;
else if (!startupParam.fourierOpt.CompareTo("phaseoptreal", TString::kIgnoreCase))
fourierPlotTag = FOURIER_PLOT_PHASE_OPT_REAL;
else
fourierPlotTag = FOURIER_PLOT_POWER;
}
@ -1277,9 +1378,6 @@ int main(int argc, char *argv[])
// calculate background levels and subtract them from the data
data.DoBkgCorrection();
// do the time domain filtering now
data.DoFiltering();
// do lifetime correction
if (startupParam.lifetimecorrection != 0.0)
data.DoLifeTimeCorrection(startupParam.lifetimecorrection);
@ -1304,7 +1402,7 @@ int main(int argc, char *argv[])
vector<PFourier*> fourier;
fourier.resize(histo.size());
for (unsigned int i=0; i<fourier.size(); i++) {
for (UInt_t i=0; i<fourier.size(); i++) {
fourier[i] = new PFourier(histo[i], unitTag, 0.0, 0.0, true, startupParam.fourierPower);
}
@ -1316,12 +1414,18 @@ int main(int argc, char *argv[])
else if (startupParam.apodization.BeginsWith("strong", TString::kIgnoreCase))
apodTag = F_APODIZATION_STRONG;
double start = millitime();
for (unsigned int i=0; i<fourier.size(); i++) {
Double_t start = millitime();
for (UInt_t i=0; i<fourier.size(); i++) {
fourier[i]->Transform(apodTag);
}
double end = millitime();
cout << endl << "debug> after FFT. calculation time: " << (end-start)/1.0e3 << " (sec)." << endl;
Double_t end = millitime();
cout << endl << "info> after FFT. calculation time: " << (end-start)/1.0e3 << " (sec)." << endl;
// make sure that a Fourier range is provided, if not calculate one
if ((startupParam.fourierRange[0] == -1.0) && (startupParam.fourierRange[1] == -1.0)) {
startupParam.fourierRange[0] = 0.0;
startupParam.fourierRange[1] = fourier[0]->GetMaxFreq();
}
PFourierCanvas *fourierCanvas = 0;
@ -1334,7 +1438,7 @@ int main(int argc, char *argv[])
Bool_t batch = false;
if (startupParam.graphicFormat.Length() != 0) {
batch = true;
argv[argc] = (char*)malloc(16*sizeof(char));
argv[argc] = (Char_t*)malloc(16*sizeof(Char_t));
strcpy(argv[argc], "-b");
argc++;
}
@ -1343,17 +1447,17 @@ int main(int argc, char *argv[])
TApplication app("App", &argc, argv);
if (startupHandler) {
fourierCanvas = new PFourierCanvas(fourier, startupParam.title.Data(),
startupParam.showAverage, fourierPlotTag,
startupParam.fourierRange, startupParam.initialPhase,
fourierCanvas = new PFourierCanvas(fourier, dataSetTag, startupParam.title.Data(),
startupParam.showAverage, startupParam.showAveragePerDataSet,
fourierPlotTag, startupParam.fourierRange, startupParam.initialPhase,
10, 10, 800, 800,
startupHandler->GetMarkerList(),
startupHandler->GetColorList(),
batch);
} else {
fourierCanvas = new PFourierCanvas(fourier, startupParam.title.Data(),
startupParam.showAverage, fourierPlotTag,
startupParam.fourierRange, startupParam.initialPhase,
fourierCanvas = new PFourierCanvas(fourier, dataSetTag, startupParam.title.Data(),
startupParam.showAverage, startupParam.showAveragePerDataSet,
fourierPlotTag, startupParam.fourierRange, startupParam.initialPhase,
10, 10, 800, 800,
batch);
}
@ -1403,23 +1507,23 @@ int main(int argc, char *argv[])
if (startupHandler)
delete startupHandler;
for (unsigned int i=0; i<msrHandler.size(); i++)
for (UInt_t i=0; i<msrHandler.size(); i++)
if (msrHandler[i])
delete msrHandler[i];
msrHandler.clear();
for (unsigned int i=0; i<runDataHandler.size(); i++)
for (UInt_t i=0; i<runDataHandler.size(); i++)
if (runDataHandler[i])
delete runDataHandler[i];
runDataHandler.clear();
if (histo.size() > 0) {
for (unsigned int i=0; i<histo.size(); i++)
for (UInt_t i=0; i<histo.size(); i++)
delete histo[i];
histo.clear();
}
if (fourier.size() > 0) {
for (unsigned int i=0; i<fourier.size(); i++)
for (UInt_t i=0; i<fourier.size(); i++)
delete fourier[i];
fourier.clear();
}

5
src/musredit/Makefile.am Normal file
View File

@ -0,0 +1,5 @@
## Process this file with automake to create Makefile.in
CLEANFILES = *~ core moc_* ui_*

View File

@ -85,6 +85,8 @@ bool PAdminXMLParser::startElement( const QString&, const QString&,
fKeyWord = eDefaultSavePath;
} else if (qName == "title_from_data_file") {
fKeyWord = eTitleFromDataFile;
} else if (qName == "musrview_show_fourier") {
fKeyWord = eMusrviewShowFourier;
} else if (qName == "enable_musrt0") {
fKeyWord = eEnableMusrT0;
} else if (qName == "keep_minuit2_output") {
@ -130,7 +132,9 @@ bool PAdminXMLParser::startElement( const QString&, const QString&,
} else if (qName == "musr_web_statistic") {
fKeyWord = eHelpStatistic;
} else if (qName == "musr_web_msr2data") {
fKeyWord = eHelpMsr2Data;
fKeyWord = eHelpMsr2Data;
} else if (qName == "musr_web_musrFT") {
fKeyWord = eHelpMusrFT;
} else if (qName == "chain_fit") {
fKeyWord = eChainFit;
} else if (qName == "write_data_header") {
@ -240,6 +244,13 @@ bool PAdminXMLParser::characters(const QString& str)
flag = false;
fAdmin->setTitleFromDataFileFlag(flag);
break;
case eMusrviewShowFourier:
if (str == "y")
flag = true;
else
flag = false;
fAdmin->setMusrviewShowFourierFlag(flag);
break;
case eEnableMusrT0:
if (str == "y")
flag = true;
@ -338,6 +349,9 @@ bool PAdminXMLParser::characters(const QString& str)
case eHelpMsr2Data:
fAdmin->setHelpUrl("msr2data", str);
break;
case eHelpMusrFT:
fAdmin->setHelpUrl("musrFT", str);
break;
case eChainFit:
if (str == "y")
flag = true;
@ -598,6 +612,8 @@ PAdmin::PAdmin() : QObject()
fInstitute = QString("");
fFileFormat = QString("");
fMusrviewShowFourier = false;
fTitleFromDataFile = false;
fEnableMusrT0 = false;
fLifetimeCorrection = true;

View File

@ -69,12 +69,12 @@ class PAdminXMLParser : public QXmlDefaultHandler
private:
enum EAdminKeyWords {eEmpty, eTimeout, eKeepMinuit2Output, eDumpAscii, eDumpRoot,
eTitleFromDataFile, eChisqPreRunBlock, eEstimateN0, eEnableMusrT0,
eTitleFromDataFile, eChisqPreRunBlock, eEstimateN0, eMusrviewShowFourier, eEnableMusrT0,
eFontName, eFontSize, eExecPath, eDefaultSavePath,
eRecentFile, eBeamline, eInstitute, eFileFormat, eLifetimeCorrection, eMsrDefaultFilePath,
eTheoFuncPixmapPath, eFunc, eFuncName, eFuncComment, eFuncLabel,
eFuncPixmap, eFuncParams, eHelpMain, eHelpTitle, eHelpParameters, eHelpTheory, eHelpFunctions,
eHelpRun, eHelpCommand, eHelpFourier, eHelpPlot, eHelpStatistic, eHelpMsr2Data,
eHelpRun, eHelpCommand, eHelpFourier, eHelpPlot, eHelpStatistic, eHelpMsr2Data, eHelpMusrFT,
eChainFit, eWriteDataHeader, eIgnoreDataHeaderInfo, eWriteColumnData,
eRecreateDataFile, eOpenFileAfterFitting, eCreateMsrFileOnly, eFitOnly, eGlobal, eGlobalPlus};
@ -118,6 +118,7 @@ class PAdmin : public QObject
QString getExecPath() { return fExecPath; }
QString getDefaultSavePath() { return fDefaultSavePath; }
bool getTitleFromDataFileFlag() { return fTitleFromDataFile; }
bool getMusrviewShowFourierFlag() { return fMusrviewShowFourier; }
bool getEnableMusrT0Flag() { return fEnableMusrT0; }
bool getKeepMinuit2OutputFlag() { return fKeepMinuit2Output; }
bool getDumpAsciiFlag() { return fDumpAscii; }
@ -139,6 +140,7 @@ class PAdmin : public QObject
void setTimeout(const int ival) { fTimeout = ival; }
void setTitleFromDataFileFlag(const bool flag) { fTitleFromDataFile = flag; }
void setMusrviewShowFourierFlag(const bool flag) { fMusrviewShowFourier = flag; }
void setEnableMusrT0Flag(const bool flag) { fEnableMusrT0 = flag; }
void setKeepMinuit2OutputFlag(const bool flag) { fKeepMinuit2Output = flag; }
void setDumpAsciiFlag(const bool flag) { fDumpAscii = flag; }
@ -180,13 +182,14 @@ class PAdmin : public QObject
QVector<QString> fRecentFile; ///< keep vector of recent path-file names
bool fKeepMinuit2Output; ///< flag indicating if the Minuit2 output shall be kept (default: no)
bool fDumpAscii; ///< flag indicating if musrfit shall make an ascii-dump file (for debugging purposes, default: no).
bool fDumpRoot; ///< flag indicating if musrfit shall make an root-dump file (for debugging purposes, default: no).
bool fTitleFromDataFile; ///< flag indicating if the title should be extracted from the data file (default: yes).
bool fChisqPreRunBlock; ///< flag indicating if musrfit shall write 'per run block' chisq to the msr-file (default: no).
bool fEstimateN0; ///< flag indicating if musrfit shall estimate N0 for single histogram fits (default: yes).
bool fEnableMusrT0; ///< flag indicating if musrT0 shall be enabled at startup from within musredit (default: yes).
bool fMusrviewShowFourier; ///< flag indicating if musrview should show at startup data (=false) or Fourier of data (=true).
bool fKeepMinuit2Output; ///< flag indicating if the Minuit2 output shall be kept (default: no)
bool fDumpAscii; ///< flag indicating if musrfit shall make an ascii-dump file (for debugging purposes, default: no).
bool fDumpRoot; ///< flag indicating if musrfit shall make an root-dump file (for debugging purposes, default: no).
bool fTitleFromDataFile; ///< flag indicating if the title should be extracted from the data file (default: yes).
bool fChisqPreRunBlock; ///< flag indicating if musrfit shall write 'per run block' chisq to the msr-file (default: no).
bool fEstimateN0; ///< flag indicating if musrfit shall estimate N0 for single histogram fits (default: yes).
bool fEnableMusrT0; ///< flag indicating if musrT0 shall be enabled at startup from within musredit (default: yes).
QString fBeamline; ///< name of the beamline. Used to generate default run header lines.
QString fInstitute; ///< name of the institute. Used to generate default run header lines.

View File

@ -0,0 +1,599 @@
/****************************************************************************
PGetMusrFTOptionsDialog.cpp
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
*****************************************************************************/
/***************************************************************************
* Copyright (C) 2009-2015 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <QLineEdit>
#include <QValidator>
#include <QComboBox>
#include <QMessageBox>
#include "PHelp.h"
#include "PGetMusrFTOptionsDialog.h"
#define MUSRFT_OPT_UNDEF 0
#define MUSRFT_OPT_REAL 1
#define MUSRFT_OPT_IMAG 2
#define MUSRFT_OPT_REAL_AND_IMAG 3
#define MUSRFT_OPT_POWER 4
#define MUSRFT_OPT_PHASE 5
#define MUSRFT_OPT_PHASE_OPT_REAL 6
#define MUSRFT_APOD_UNDEF 0
#define MUSRFT_APOD_WEAK 1
#define MUSRFT_APOD_MEDIUM 2
#define MUSRFT_APOD_STRONG 3
#define MUSRFT_UNIT_UNDEF 0
#define MUSRFT_UNIT_GAUSS 1
#define MUSRFT_UNIT_TESLA 2
#define MUSRFT_UNIT_FREQ 3
#define MUSRFT_UNIT_CYCLE 4
//----------------------------------------------------------------------------------------------------
/**
* <p>Constructor.
*
* \param currentMsrFile path-file name of the currently active msr-file in musredit
* \param prevCmd list of the last (potential) previously call.
* \param helpUrl help url for the asymmetry run block
*/
PGetMusrFTOptionsDialog::PGetMusrFTOptionsDialog(QString currentMsrFile, QStringList &prevCmd, const QString helpUrl) :
fCurrentMsrFileName(currentMsrFile), fHelpUrl(helpUrl)
{
setupUi(this);
setModal(true);
fBkgRangeStartBin_lineEdit->setValidator( new QIntValidator(fBkgRangeStartBin_lineEdit) );
fBkgRangeEndBin_lineEdit->setValidator( new QIntValidator(fBkgRangeEndBin_lineEdit) );
fPacking_lineEdit->setValidator( new QIntValidator(fPacking_lineEdit) );
fTimeRangeStart_lineEdit->setValidator( new QDoubleValidator(fTimeRangeStart_lineEdit) );
fTimeRangeEnd_lineEdit->setValidator( new QDoubleValidator(fTimeRangeEnd_lineEdit) );
fFourierPower_lineEdit->setValidator( new QIntValidator(fFourierPower_lineEdit) );
fLifetimeCorrection_lineEdit->setValidator( new QDoubleValidator(fLifetimeCorrection_lineEdit) );
fFourierRangeStart_lineEdit->setValidator( new QDoubleValidator(fFourierRangeStart_lineEdit) );
fFourierRangeEnd_lineEdit->setValidator( new QDoubleValidator(fFourierRangeEnd_lineEdit) );
fPacking_lineEdit->setText("1");
// populate dialog with the previous cmd call
bool msrTag = true;
QString str, str1, line;
int idx;
for (int i=0; i<prevCmd.size(); i++) {
// collect msr-file-names
if (msrTag) {
line = "";
while (prevCmd[i].contains(".msr") && (i<prevCmd.size())) {
// split msr-file path-name into path and name
str = prevCmd[i];
idx = str.lastIndexOf("/");
str1 = str;
str.remove(idx, str.length()-idx);
fMsrFilePaths << str;
str1.remove(0, idx+1);
fMsrFileNames << str1;
line += str1 + " ";
i++;
}
line.remove(line.length()-1, 1);
fMsrFileSelector_lineEdit->setText(line);
msrTag = false;
}
// collect data-file-names
if (prevCmd[i] == "-df") {
i++;
line = "";
while (!prevCmd[i].startsWith("-") && (i<prevCmd.size())) {
// split msr-file path-name into path and name
str = prevCmd[i];
idx = str.lastIndexOf("/");
str1 = str;
str.remove(idx, str.length()-idx);
fDataFilePaths << str;
str1.remove(0, idx+1);
fDataFileNames << str1;
line += str1 + " ";
i++;
}
line.remove(line.length()-1, 1);
fDataFileSelector_lineEdit->setText(line);
}
// background-range
if (prevCmd[i] == "-br") {
fBkgRangeStartBin_lineEdit->setText(prevCmd[++i]);
fBkgRangeEndBin_lineEdit->setText(prevCmd[++i]);
}
// fourier-option
if (prevCmd[i] == "-fo") {
if (prevCmd[i+1] == "real")
fFourierOption_comboBox->setCurrentIndex(MUSRFT_OPT_REAL);
else if (prevCmd[i+1] == "imag")
fFourierOption_comboBox->setCurrentIndex(MUSRFT_OPT_IMAG);
else if (prevCmd[i+1] == "real+imag")
fFourierOption_comboBox->setCurrentIndex(MUSRFT_OPT_REAL_AND_IMAG);
else if (prevCmd[i+1] == "power")
fFourierOption_comboBox->setCurrentIndex(MUSRFT_OPT_POWER);
else if (prevCmd[i+1] == "phase")
fFourierOption_comboBox->setCurrentIndex(MUSRFT_OPT_PHASE);
else if (prevCmd[i+1] == "phaseOptReal")
fFourierOption_comboBox->setCurrentIndex(MUSRFT_OPT_PHASE_OPT_REAL);
else
fFourierOption_comboBox->setCurrentIndex(MUSRFT_OPT_UNDEF);
i++;
}
// apodization
if (prevCmd[i] == "-ap") {
if (prevCmd[i+1] == "weak")
fApodization_comboBox->setCurrentIndex(MUSRFT_APOD_WEAK);
else if (prevCmd[i+1] == "medium")
fApodization_comboBox->setCurrentIndex(MUSRFT_APOD_MEDIUM);
else if (prevCmd[i+1] == "strong")
fApodization_comboBox->setCurrentIndex(MUSRFT_APOD_STRONG);
else
fApodization_comboBox->setCurrentIndex(MUSRFT_APOD_UNDEF);
i++;
}
// fourier-power
if (prevCmd[i] == "-fp") {
fFourierPower_lineEdit->setText(prevCmd[++i]);
}
// units
if (prevCmd[i] == "-u") {
if (prevCmd[i+1] == "Gauss")
fFourierUnits_comboBox->setCurrentIndex(MUSRFT_UNIT_GAUSS);
else if (prevCmd[i+1] == "Tesla")
fFourierUnits_comboBox->setCurrentIndex(MUSRFT_UNIT_TESLA);
else if (prevCmd[i+1] == "MHz")
fFourierUnits_comboBox->setCurrentIndex(MUSRFT_UNIT_FREQ);
else if (prevCmd[i+1] == "Mc/s")
fFourierUnits_comboBox->setCurrentIndex(MUSRFT_UNIT_CYCLE);
else
fFourierUnits_comboBox->setCurrentIndex(MUSRFT_UNIT_UNDEF);
i++;
}
// phase
if (prevCmd[i] == "-ph") {
// NOT YET IMPLEMENTED
}
// fourier-range
if (prevCmd[i] == "-fr") {
fFourierRangeStart_lineEdit->setText(prevCmd[++i]);
fFourierRangeEnd_lineEdit->setText(prevCmd[++i]);
}
// time-range
if (prevCmd[i] == "-tr") {
fTimeRangeStart_lineEdit->setText(prevCmd[++i]);
fTimeRangeEnd_lineEdit->setText(prevCmd[++i]);
}
// histo list
if (prevCmd[i] == "--histo") {
i++;
line = "";
while (!prevCmd[i].startsWith("-") && (i<prevCmd.size())) {
line += prevCmd[i++] + " ";
}
line.remove(line.length()-1, 1);
fHistoList_lineEdit->setText(line);
}
// average ALL tag
if (prevCmd[i] == "-a") {
fAveragedView_checkBox->setCheckState(Qt::Checked);
}
// average per data set tag
if (prevCmd[i] == "-ad") {
fAveragePerDataSet_checkBox->setCheckState(Qt::Checked);
}
// t0 list
if (prevCmd[i] == "--t0") {
i++;
line = "";
while (!prevCmd[i].startsWith("-") && (i<prevCmd.size())) {
line += prevCmd[i++] + " ";
}
line.remove(line.length()-1, 1);
fT0_lineEdit->setText(line);
}
// packing
if (prevCmd[i] == "-pa") {
fPacking_lineEdit->setText(prevCmd[++i]);
}
// title
if (prevCmd[i] == "--title") {
fFourierTitle_lineEdit->setText(prevCmd[i+1]);
}
// create msr-file tag
if (prevCmd[i] == "--create-msr-file") {
fCreateMsrFileName = prevCmd[++i];
fCreateMsrFile_checkBox->setCheckState(Qt::Checked);
}
// lifetime correction
if (prevCmd[i] == "-lc") {
fLifetimeCorrection_lineEdit->setText(prevCmd[++i]);
}
}
// connect all necessary single and slots
connect(fCurrentMsrFile_checkBox, SIGNAL( stateChanged(int) ), this, SLOT( currentMsrFileTagChanged(int) ) );
connect(fAllMsrFiles_checkBox, SIGNAL( stateChanged(int) ), this, SLOT( allMsrFileTagChanged(int) ) );
connect(fMsrFileSelector_pushButton, SIGNAL( clicked() ), this, SLOT( selectMsrFileNames() ) );
connect(fDataFileSelector_pushButton, SIGNAL( clicked() ), this, SLOT( selectDataFileNames() ) );
connect(fCreateMsrFile_checkBox, SIGNAL( stateChanged(int) ), this, SLOT( createMsrFileChanged(int) ) );
connect(fMsrFileNameClear_pushButton, SIGNAL (clicked() ), this, SLOT( clearMsrFileNames() ) );
connect(fDataFileNameClear_pushButton, SIGNAL (clicked() ), this, SLOT( clearDataFileNames() ) );
connect(fResetAll_pushButton, SIGNAL( clicked() ), this, SLOT( resetAll() ) );
connect(fAveragedView_checkBox, SIGNAL ( stateChanged(int) ), this, SLOT( averagedAll(int) ) );
connect(fAveragePerDataSet_checkBox, SIGNAL ( stateChanged(int) ), this, SLOT( averagedPerDataSet(int) ) );
}
//----------------------------------------------------------------------------------------------------
/**
* <p>returns the musrFT command line options.
*/
QStringList PGetMusrFTOptionsDialog::getMusrFTOptions()
{
QStringList cmd;
QString str("");
QStringList strList;
// check if currently active msr-file shall be used
if (fCurrentMsrFile_checkBox->checkState() == Qt::Checked) {
cmd << fCurrentMsrFileName;
} else {
// msr-files
for (int i=0; i<fMsrFilePaths.size(); i++) {
str = fMsrFilePaths[i]+"/"+fMsrFileNames[i];
cmd << str;
}
// data-files
if (fDataFilePaths.size() > 0) {
cmd << "-df";
for (int i=0; i<fDataFilePaths.size(); i++) {
str = fDataFilePaths[i]+"/"+fDataFileNames[i];
cmd << str;
}
}
}
// background range
if ((fBkgRangeStartBin_lineEdit->text().length() > 0) && (fBkgRangeEndBin_lineEdit->text().length() > 0)) {
cmd << "-br";
cmd << fBkgRangeStartBin_lineEdit->text();
cmd << fBkgRangeEndBin_lineEdit->text();
}
// background values
if (fBkgList_lineEdit->text().length() > 0) {
}
// fourier-option
if (fFourierOption_comboBox->currentText() != "UnDef") {
cmd << "-fo";
cmd << fFourierOption_comboBox->currentText();
}
// apodization
cmd << "-ap";
cmd << fApodization_comboBox->currentText();
// fourier-power
if (fFourierPower_lineEdit->text().length() > 0) {
cmd << "-fp";
cmd << fFourierPower_lineEdit->text();
}
// units
if (fFourierUnits_comboBox->currentText() != "UnDef") {
cmd << "-u";
cmd << fFourierUnits_comboBox->currentText();
}
// phase
// fourier-range
if ((fFourierRangeStart_lineEdit->text().length() > 0) && (fFourierRangeEnd_lineEdit->text().length() > 0)) {
cmd << "-fr";
cmd << fFourierRangeStart_lineEdit->text();
cmd << fFourierRangeEnd_lineEdit->text();
}
// time-range
if ((fTimeRangeStart_lineEdit->text().length() > 0) && (fTimeRangeEnd_lineEdit->text().length() > 0)) {
cmd << "-tr";
cmd << fTimeRangeStart_lineEdit->text();
cmd << fTimeRangeEnd_lineEdit->text();
}
// histo list
if (fHistoList_lineEdit->text().length() > 0) {
cmd << "--histo";
strList = fHistoList_lineEdit->text().split(" ", QString::SkipEmptyParts);
for (int i=0; i<strList.size(); i++)
cmd << strList[i];
}
// averaged view ALL
if (fAveragedView_checkBox->checkState() == Qt::Checked)
cmd << "-a";
// averaged view per data set
if (fAveragePerDataSet_checkBox->checkState() == Qt::Checked)
cmd << "-ad";
// t0 list
if (fT0_lineEdit->text().length() > 0) {
cmd << "--t0";
strList = fT0_lineEdit->text().split(" ", QString::SkipEmptyParts);
for (int i=0; i<strList.size(); i++)
cmd << strList[i];
}
// packing
if (fPacking_lineEdit->text().length() > 0) {
cmd << "-pa";
cmd << fPacking_lineEdit->text();
}
// title
if (fFourierTitle_lineEdit->text().length() > 0) {
cmd << "--title";
cmd << fFourierTitle_lineEdit->text();
}
// create-msr-file
if (fCreateMsrFile_checkBox->checkState() == Qt::Checked) {
cmd << "--create-msr-file";
cmd << fCreateMsrFileName;
}
// lifetimecorrection
if (fLifetimeCorrection_lineEdit->text().length() > 0) {
cmd << "-lc";
cmd << fLifetimeCorrection_lineEdit->text();
}
return cmd;
}
//----------------------------------------------------------------------------------------------------
/**
* <p>SLOT called when fCurrentMsrFile_checkBox is checked/unchecked. If checked, it will clean up
* the msr-file path-file list and the data-file path-file list.
*/
void PGetMusrFTOptionsDialog::currentMsrFileTagChanged(int state)
{
if (state == Qt::Checked) {
fAllMsrFiles_checkBox->setCheckState(Qt::Unchecked);
// remove all msr-data-file-names and data-path-file-names
fMsrFilePaths.clear();
fMsrFileNames.clear();
fMsrFileSelector_lineEdit->setText("");
fDataFilePaths.clear();
fDataFileNames.clear();
fDataFileSelector_lineEdit->setText("");
}
}
//----------------------------------------------------------------------------------------------------
/**
* <p>SLOT called when fAllMsrFiles_checkBox is checked/unchecked. Currently it has no functionality.
*/
void PGetMusrFTOptionsDialog::allMsrFileTagChanged(int state)
{
if (state == Qt::Checked) {
fCurrentMsrFile_checkBox->setCheckState(Qt::Unchecked);
}
}
//----------------------------------------------------------------------------------------------------
/**
* <p>SLOT called when fMsrFileSelector_pushButton is clicked. Collects the msr-file path-name list.
*/
void PGetMusrFTOptionsDialog::selectMsrFileNames()
{
QStringList flns = QFileDialog::getOpenFileNames( this, tr("Open msr-File(s)"), tr( "./" ),
tr( "msr-Files (*.msr);;All Files (*)" ));
QString str(""), str1("");
int idx;
if (flns.size() > 0) {
// delete already present elements
fMsrFilePaths.clear();
fMsrFileNames.clear();
// split path-name into path and name
for (int i=0; i<flns.size(); i++) {
str = flns[i];
idx = str.lastIndexOf("/");
str1 = str;
str.remove(idx, str.length()-idx);
fMsrFilePaths << str;
str1.remove(0, idx+1);
fMsrFileNames << str1;
}
// populate fMsrFileSelector_lineEdit
str = QString("");
for (int i=0; i<fMsrFileNames.size()-1; i++) {
str += fMsrFileNames[i] + " ";
}
str += fMsrFileNames[fMsrFileNames.size()-1];
fMsrFileSelector_lineEdit->setText(str);
}
}
//----------------------------------------------------------------------------------------------------
/**
* <p>SLOT called when the fMsrFileNameClear_pushButton is clicked.
*/
void PGetMusrFTOptionsDialog::clearMsrFileNames()
{
fMsrFileSelector_lineEdit->setText("");
fMsrFilePaths.clear();
fMsrFileNames.clear();
}
//----------------------------------------------------------------------------------------------------
/**
* <p>SLOT called when fDataFileSelector_pushButton is clicked. Collects the data-file path-name list.
*/
void PGetMusrFTOptionsDialog::selectDataFileNames()
{
QStringList flns = QFileDialog::getOpenFileNames( this, tr("Open msr-File(s)"), tr( "./" ),
tr( "data-Files (*.root *.bin *.msr *.nxs *.mdu);;All Files (*)" ));
QString str(""), str1("");
int idx;
if (flns.size() > 0) {
// delete already present elements
fDataFilePaths.clear();
fDataFileNames.clear();
// split path-name into path and name
for (int i=0; i<flns.size(); i++) {
str = flns[i];
idx = str.lastIndexOf("/");
str1 = str;
str.remove(idx, str.length()-idx);
fDataFilePaths << str;
str1.remove(0, idx+1);
fDataFileNames << str1;
}
// populate fMsrFileSelector_lineEdit
str = QString("");
for (int i=0; i<fDataFileNames.size()-1; i++) {
str += fDataFileNames[i] + " ";
}
str += fDataFileNames[fDataFileNames.size()-1];
fDataFileSelector_lineEdit->setText(str);
}
}
//----------------------------------------------------------------------------------------------------
/**
* <p>SLOT called when the fDataFileNameClear_pushButton is clicked.
*/
void PGetMusrFTOptionsDialog::clearDataFileNames()
{
fDataFileSelector_lineEdit->setText("");
fDataFilePaths.clear();
fDataFileNames.clear();
}
//----------------------------------------------------------------------------------------------------
/**
* <p>SLOT called when the create-msr-file tag has changed
*/
void PGetMusrFTOptionsDialog::createMsrFileChanged(int state)
{
if (state == Qt::Checked) {
fCreateMsrFileName = QFileDialog::getSaveFileName(this, tr("Create msr-file"), "./", tr("msr-Files (*.msr);;All Files (*)"));
if (fCreateMsrFileName.length() == 0)
fCreateMsrFile_checkBox->setCheckState(Qt::Unchecked);
} else {
fCreateMsrFileName = "";
}
}
//----------------------------------------------------------------------------------------------------
/**
* <p>SLOT called when the Reset All button is pressed. Will remove all settings.
*/
void PGetMusrFTOptionsDialog::resetAll()
{
fCurrentMsrFile_checkBox->setCheckState(Qt::Unchecked);
fAllMsrFiles_checkBox->setCheckState(Qt::Unchecked);
fMsrFilePaths.clear();
fMsrFileNames.clear();
fMsrFileSelector_lineEdit->setText("");
fDataFilePaths.clear();
fDataFileNames.clear();
fDataFileSelector_lineEdit->setText("");
fBkgRangeStartBin_lineEdit->setText("");
fBkgRangeEndBin_lineEdit->setText("");
fBkgList_lineEdit->setText("");
fApodization_comboBox->setCurrentIndex(MUSRFT_APOD_UNDEF);
fPacking_lineEdit->setText("");
fTimeRangeStart_lineEdit->setText("");
fTimeRangeEnd_lineEdit->setText("");
fHistoList_lineEdit->setText("");
fT0_lineEdit->setText("");
fFourierOption_comboBox->setCurrentIndex(MUSRFT_OPT_UNDEF);
fFourierUnits_comboBox->setCurrentIndex(MUSRFT_UNIT_UNDEF);
fFourierPower_lineEdit->setText("");
fLifetimeCorrection_lineEdit->setText("");
fFourierRangeStart_lineEdit->setText("");
fFourierRangeEnd_lineEdit->setText("");
fAveragedView_checkBox->setCheckState(Qt::Unchecked);
fAveragePerDataSet_checkBox->setCheckState(Qt::Unchecked);
fCreateMsrFile_checkBox->setCheckState(Qt::Unchecked);
fFourierTitle_lineEdit->setText("");
}
//----------------------------------------------------------------------------------------------------
/**
* <p>SLOT called when averaged view for ALL data is checked.
*/
void PGetMusrFTOptionsDialog::averagedAll(int state)
{
if ((state == Qt::Checked) && fAveragePerDataSet_checkBox->isChecked())
fAveragePerDataSet_checkBox->setCheckState(Qt::Unchecked);
}
//----------------------------------------------------------------------------------------------------
/**
* <p>SLOT called when averaged view per data set is checked.
*/
void PGetMusrFTOptionsDialog::averagedPerDataSet(int state)
{
if ((state == Qt::Checked) && fAveragedView_checkBox->isChecked())
fAveragedView_checkBox->setCheckState(Qt::Unchecked);
}
//----------------------------------------------------------------------------------------------------
/**
* <p>Generates a help content window showing the description for musrFT.
*/
void PGetMusrFTOptionsDialog::helpContent()
{
if (fHelpUrl.isEmpty()) {
QMessageBox::information(this, "**INFO**", "Will eventually show a help window");
} else {
#ifdef _WIN32GCC
QMessageBox::information(this, "**INFO**", "If a newer Qt version was available, a help window would be shown!");
#else
PHelp *help = new PHelp(fHelpUrl);
help->show();
#endif // _WIN32GCC
}
}

View File

@ -0,0 +1,71 @@
/****************************************************************************
PGetMusrFTOptionsDialog.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
*****************************************************************************/
/***************************************************************************
* Copyright (C) 2010-2015 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef _PGETMUSRFTOPTIONSDIALOG_H_
#define _PGETMUSRFTOPTIONSDIALOG_H_
#include <QDialog>
#include <QStringList>
#include "ui_PGetMusrFTOptionsDialog.h"
class PGetMusrFTOptionsDialog : public QDialog, private Ui::PGetMusrFTOptionsDialog
{
Q_OBJECT
public:
PGetMusrFTOptionsDialog(QString currentMsrFile, QStringList &prevCmd, const QString helpUrl);
QStringList getMusrFTOptions();
public slots:
void helpContent();
private slots:
void currentMsrFileTagChanged(int state);
void allMsrFileTagChanged(int state);
void selectMsrFileNames();
void clearMsrFileNames();
void selectDataFileNames();
void clearDataFileNames();
void createMsrFileChanged(int state);
void resetAll();
void averagedAll(int state);
void averagedPerDataSet(int state);
private:
QStringList fMsrFilePaths; ///< list keeping all the paths from the msr-file path-name list
QStringList fMsrFileNames; ///< list keeping all the names from the msr-file path-name list
QStringList fDataFilePaths; ///< list keeping all the paths from the data-file path-name list
QStringList fDataFileNames; ///< list keeping all the names from the data-file path-name list
QString fCreateMsrFileName; ///< keeps the msr-path-file name for msr-file creation
QString fCurrentMsrFileName; ///< keeps the msr-path-file name of the currently active msr-file in musredit.
QString fHelpUrl; ///< help url for the asymmetry run block
};
#endif // _PGETMUSRFTOPTIONSDIALOG_H_

View File

@ -61,6 +61,7 @@ PPrefsDialog::PPrefsDialog(PAdmin *admin) : fAdmin(admin)
fEnableMusrT0_checkBox->setChecked(fAdmin->getEnableMusrT0Flag());
fPerRunBlockChisq_checkBox->setChecked(fAdmin->getChisqPerRunBlockFlag());
fEstimateN0_checkBox->setChecked(fAdmin->getEstimateN0Flag());
fFourier_checkBox->setChecked(fAdmin->getMusrviewShowFourierFlag());
fTimeout_lineEdit->setText(QString("%1").arg(fAdmin->getTimeout()));
fTimeout_lineEdit->setValidator(new QIntValidator(fTimeout_lineEdit));

View File

@ -46,6 +46,7 @@ class PPrefsDialog : public QDialog, private Ui::PPrefsDialog
public:
PPrefsDialog(PAdmin *admin);
bool getMusrviewShowFourierFlag() { return fFourier_checkBox->isChecked(); }
bool getKeepMinuit2OutputFlag() { return fKeepMn2Output_checkBox->isChecked(); }
bool getTitleFromDataFileFlag() { return fTitleFromData_checkBox->isChecked(); }
bool getEnableMusrT0Flag() { return fEnableMusrT0_checkBox->isChecked(); }

View File

@ -28,6 +28,7 @@
***************************************************************************/
#include <iostream>
#include <string>
using namespace std;
#include <QTextEdit>
@ -55,6 +56,7 @@ using namespace std;
#include <QTextBlock>
#include <QTextDocumentFragment>
#include <QTextList>
#include <QProcess>
#include <QtDebug>
@ -68,6 +70,7 @@ using namespace std;
#include "PFitOutputHandler.h"
#include "PDumpOutputHandler.h"
#include "PPrefsDialog.h"
#include "PGetMusrFTOptionsDialog.h"
#include "PGetDefaultDialog.h"
#include "PMusrEditAbout.h"
#include "PMsr2DataDialog.h"
@ -550,6 +553,12 @@ void PTextEdit::setupMusrActions()
menu->addAction(fMusrT0Action);
fMusrT0Action->setEnabled(fAdmin->getEnableMusrT0Flag());
a = new QAction( QIcon( QPixmap (":/images/musrFT.xpm") ), tr( "Raw Fourier" ), this );
a->setStatusTip( tr("Start musrFT") );
connect( a, SIGNAL( triggered() ), this, SLOT( musrFT() ) );
tb->addAction(a);
menu->addAction(a);
a = new QAction( QIcon( QPixmap( ":/images/musrprefs.xpm" ) ), tr( "&Preferences" ), this );
a->setStatusTip( tr("Show Preferences") );
connect( a, SIGNAL( triggered() ), this, SLOT( musrPrefs() ) );
@ -671,42 +680,6 @@ void PTextEdit::doConnections( PSubTextEdit *e )
connect( e, SIGNAL( cursorPositionChanged() ), this, SLOT( currentCursorPosition() ));
}
//----------------------------------------------------------------------------------------------------
/**
* <p>Validates a given runlist.
*
* \param runList run list string which should be a space separated list of run numbers.
*/
bool PTextEdit::validRunList(const QString runList)
{
bool success = true;
int i = 0;
QString subStr;
bool done = false;
int val = 0;
bool ok;
while (!done) {
subStr = runList.section(' ', i, i, QString::SectionSkipEmpty);
if (subStr.isEmpty()) {
done = true;
continue;
}
i++;
val = subStr.toInt(&ok);
if (!ok) {
done = true;
success = false;
}
}
if (i == 0) { // no token found
success = false;
}
return success;
}
//----------------------------------------------------------------------------------------------------
/**
* <p>Start the dialog to enter a msr-file title. See also https://intranet.psi.ch/MUSR/MusrFit#4_1_The_Title
@ -1884,12 +1857,6 @@ void PTextEdit::musrMsr2Data()
break;
case 1: // run list
runList = fMsr2DataParam->runList;
if (!validRunList(runList)) {
QMessageBox::critical(this, "**ERROR**",
"Invalid Run List!\nThe run list needs to be a space separated list of run numbers.",
QMessageBox::Ok, QMessageBox::NoButton);
return;
}
break;
case 2: // run list file name
runListFileName = fMsr2DataParam->runListFileName;
@ -2183,7 +2150,10 @@ void PTextEdit::musrView()
str = *fFilenames.find( currentEditor() );
QString numStr;
numStr.setNum(fAdmin->getTimeout());
cmd += str + "\" --timeout " + numStr + " &";
cmd += str + "\" --timeout " + numStr;
if (fAdmin->getMusrviewShowFourierFlag())
cmd += " -f ";
cmd += " &";
int status=system(cmd.toLatin1());
}
@ -2223,6 +2193,34 @@ void PTextEdit::musrT0()
QString fln = *fFilenames.find( currentEditor() );
}
//----------------------------------------------------------------------------------------------------
/**
* <p>Calls musrFT via selection/option dialog. It will ask the user if he/she wants to overwrite some
* of the default settings.
*/
void PTextEdit::musrFT()
{
PGetMusrFTOptionsDialog *dlg = new PGetMusrFTOptionsDialog(*fFilenames.find( currentEditor() ), fMusrFTPrevCmd, fAdmin->getHelpUrl("musrFT"));
if (dlg == 0) {
QMessageBox::critical(this, "**ERROR** musrFT", "Couldn't invoke musrFT Options Dialog.");
return;
}
if (dlg->exec() == QDialog::Accepted) {
fMusrFTPrevCmd = dlg->getMusrFTOptions();
QProcess proc(this);
proc.setStandardOutputFile("musrFT.log");
proc.setStandardErrorFile("musrFT.log");
QString cmd = fAdmin->getExecPath() + "/musrFT";
proc.startDetached(cmd, fMusrFTPrevCmd);
}
delete dlg;
dlg = 0;
}
//----------------------------------------------------------------------------------------------------
/**
* <p>Calls the preferences dialog which is used to set some global options.
@ -2237,6 +2235,7 @@ void PTextEdit::musrPrefs()
}
if (dlg->exec() == QDialog::Accepted) {
fAdmin->setMusrviewShowFourierFlag(dlg->getMusrviewShowFourierFlag());
fAdmin->setKeepMinuit2OutputFlag(dlg->getKeepMinuit2OutputFlag());
fAdmin->setTitleFromDataFileFlag(dlg->getTitleFromDataFileFlag());
fAdmin->setEnableMusrT0Flag(dlg->getEnableMusrT0Flag());

View File

@ -77,7 +77,6 @@ private:
void load( const QString &f, const int index=-1 );
PSubTextEdit *currentEditor() const;
void doConnections( PSubTextEdit *e );
bool validRunList(const QString runList);
void fileSystemWatcherActivation();
private slots:
@ -131,6 +130,7 @@ private slots:
void musrMsr2Data();
void musrView();
void musrT0();
void musrFT();
void musrPrefs();
void musrSwapMsrMlog();
void musrDump();
@ -157,6 +157,7 @@ private:
bool fFileSystemWatcherActive; ///< flag to enable/disable the file system watcher
QTimer fFileSystemWatcherTimeout; ///< timer used to re-enable file system watcher. Needed to delay the re-enabling
QString fLastDirInUse; ///< string holding the path from where the last file was loaded.
QStringList fMusrFTPrevCmd;
QAction *fMusrT0Action;

View File

@ -0,0 +1,868 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PGetMusrFTOptionsDialog</class>
<widget class="QDialog" name="PGetMusrFTOptionsDialog">
<property name="windowModality">
<enum>Qt::WindowModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>711</width>
<height>650</height>
</rect>
</property>
<property name="windowTitle">
<string>musrFT Options</string>
</property>
<widget class="QGroupBox" name="fFourier_groupBox">
<property name="geometry">
<rect>
<x>20</x>
<y>400</y>
<width>671</width>
<height>201</height>
</rect>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="title">
<string> Fourier </string>
</property>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>21</x>
<y>31</y>
<width>641</width>
<height>156</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_22">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_13">
<item>
<widget class="QLabel" name="fFourierOptions_label">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Options&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="fFourierOption_comboBox">
<item>
<property name="text">
<string>UnDef</string>
</property>
</item>
<item>
<property name="text">
<string>real</string>
</property>
</item>
<item>
<property name="text">
<string>imag</string>
</property>
</item>
<item>
<property name="text">
<string>real+imag</string>
</property>
</item>
<item>
<property name="text">
<string>power</string>
</property>
</item>
<item>
<property name="text">
<string>phase</string>
</property>
</item>
<item>
<property name="text">
<string>phaseOptReal</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>218</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_14">
<item>
<widget class="QLabel" name="fFourierUnits_label">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Units&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="fFourierUnits_comboBox">
<item>
<property name="text">
<string>UnDef</string>
</property>
</item>
<item>
<property name="text">
<string>Gauss</string>
</property>
</item>
<item>
<property name="text">
<string>Tesla</string>
</property>
</item>
<item>
<property name="text">
<string>MHz</string>
</property>
</item>
<item>
<property name="text">
<string>Mc/s</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_23">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_19">
<item>
<widget class="QLabel" name="fFourierPower_label">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Power&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="fFourierPower_lineEdit"/>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>88</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_17">
<item>
<widget class="QLabel" name="fLifetimeCorrection_label">
<property name="text">
<string>Lifetime Correction</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="fLifetimeCorrection_lineEdit"/>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_20">
<item>
<widget class="QLabel" name="fFourierRange_label">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Range&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_16">
<item>
<widget class="QLabel" name="fFourierRangeStart_label">
<property name="text">
<string>Start</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="fFourierRangeStart_lineEdit"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_15">
<item>
<widget class="QLabel" name="fFourierRangeEnd_label">
<property name="text">
<string>End</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="fFourierRangeEnd_lineEdit"/>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>118</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_18">
<item>
<widget class="QCheckBox" name="fAveragedView_checkBox">
<property name="text">
<string>Average All</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="fAveragePerDataSet_checkBox">
<property name="text">
<string>Average per Data Set</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>88</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="fCreateMsrFile_checkBox">
<property name="text">
<string>Create msr-File</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_21">
<item>
<widget class="QLabel" name="fFourierTitle_label">
<property name="text">
<string>Title</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="fFourierTitle_lineEdit"/>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<widget class="QGroupBox" name="fHistoInfo_groupBox">
<property name="geometry">
<rect>
<x>20</x>
<y>160</y>
<width>671</width>
<height>231</height>
</rect>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="title">
<string> Histo Info </string>
</property>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>20</x>
<y>30</y>
<width>641</width>
<height>188</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="fBkgRange_label">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Background Range (in Bins)</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="fBkgStartBin_label">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:10pt; font-weight:600; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;StartBin&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="fBkgRangeStartBin_lineEdit"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="fBkgEndBin_label">
<property name="text">
<string>EndBin:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="fBkgRangeEndBin_lineEdit"/>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="fBkgList_label">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Background List&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="fBkgList_lineEdit"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="fApodization_label">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Apodization&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="fApodization_comboBox">
<item>
<property name="text">
<string>none</string>
</property>
</item>
<item>
<property name="text">
<string>weak</string>
</property>
</item>
<item>
<property name="text">
<string>medium</string>
</property>
</item>
<item>
<property name="text">
<string>strong</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="fPacking_label">
<property name="text">
<string>Packing</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="fPacking_lineEdit"/>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>168</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QLabel" name="fTimeRange_label">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:10pt; font-weight:600; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Time Range (usec)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QLabel" name="fTimeRangeStart_label">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:10pt; font-weight:600; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Start&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="fTimeRangeStart_lineEdit"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QLabel" name="fTimeRangeEnd_label">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:10pt; font-weight:600; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;End&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="fTimeRangeEnd_lineEdit"/>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<widget class="QLabel" name="fHistoList_label">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:10pt; font-weight:600; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Histo List&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="fHistoList_lineEdit"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<widget class="QLabel" name="fT0_label">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:10pt; font-weight:600; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;T0's&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="fT0_lineEdit"/>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<widget class="QGroupBox" name="fFileSelection_groupBox">
<property name="geometry">
<rect>
<x>20</x>
<y>10</y>
<width>671</width>
<height>141</height>
</rect>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="title">
<string>File Selection</string>
</property>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>19</x>
<y>31</y>
<width>641</width>
<height>96</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_27">
<item>
<widget class="QCheckBox" name="fCurrentMsrFile_checkBox">
<property name="text">
<string>Current msr-File</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="fAllMsrFiles_checkBox">
<property name="text">
<string>ALL msr-Files</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>318</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_25">
<item>
<widget class="QPushButton" name="fMsrFileSelector_pushButton">
<property name="text">
<string>Select msr-File(s)</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="fMsrFileSelector_lineEdit">
<property name="minimumSize">
<size>
<width>0</width>
<height>23</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="fMsrFileNameClear_pushButton">
<property name="toolTip">
<string>clear msr-file name list</string>
</property>
<property name="text">
<string>Clear</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_26">
<item>
<widget class="QPushButton" name="fDataFileSelector_pushButton">
<property name="text">
<string>Select data-File(s)</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="fDataFileSelector_lineEdit">
<property name="minimumSize">
<size>
<width>0</width>
<height>23</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="fDataFileNameClear_pushButton">
<property name="toolTip">
<string>clear data-file name list</string>
</property>
<property name="text">
<string>Clear</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>20</x>
<y>610</y>
<width>671</width>
<height>29</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_24">
<item>
<widget class="QPushButton" name="fHelp_pushButton">
<property name="text">
<string>Help</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>78</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="fResetAll_pushButton">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Reset All</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<tabstops>
<tabstop>fCurrentMsrFile_checkBox</tabstop>
<tabstop>fAllMsrFiles_checkBox</tabstop>
<tabstop>fMsrFileSelector_pushButton</tabstop>
<tabstop>fMsrFileSelector_lineEdit</tabstop>
<tabstop>fMsrFileNameClear_pushButton</tabstop>
<tabstop>fDataFileSelector_pushButton</tabstop>
<tabstop>fDataFileSelector_lineEdit</tabstop>
<tabstop>fDataFileNameClear_pushButton</tabstop>
<tabstop>fBkgRangeStartBin_lineEdit</tabstop>
<tabstop>fBkgRangeEndBin_lineEdit</tabstop>
<tabstop>fBkgList_lineEdit</tabstop>
<tabstop>fApodization_comboBox</tabstop>
<tabstop>fPacking_lineEdit</tabstop>
<tabstop>fTimeRangeStart_lineEdit</tabstop>
<tabstop>fTimeRangeEnd_lineEdit</tabstop>
<tabstop>fHistoList_lineEdit</tabstop>
<tabstop>fT0_lineEdit</tabstop>
<tabstop>fFourierOption_comboBox</tabstop>
<tabstop>fFourierUnits_comboBox</tabstop>
<tabstop>fFourierPower_lineEdit</tabstop>
<tabstop>fLifetimeCorrection_lineEdit</tabstop>
<tabstop>fFourierRangeStart_lineEdit</tabstop>
<tabstop>fFourierRangeEnd_lineEdit</tabstop>
<tabstop>fAveragedView_checkBox</tabstop>
<tabstop>fCreateMsrFile_checkBox</tabstop>
<tabstop>fFourierTitle_lineEdit</tabstop>
<tabstop>fResetAll_pushButton</tabstop>
<tabstop>fHelp_pushButton</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>PGetMusrFTOptionsDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>683</x>
<y>611</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>PGetMusrFTOptionsDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>689</x>
<y>611</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>fHelp_pushButton</sender>
<signal>clicked()</signal>
<receiver>PGetMusrFTOptionsDialog</receiver>
<slot>helpContent()</slot>
<hints>
<hint type="sourcelabel">
<x>85</x>
<y>627</y>
</hint>
<hint type="destinationlabel">
<x>147</x>
<y>624</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>helpContent()</slot>
</slots>
</ui>

View File

@ -33,9 +33,9 @@
<item>
<widget class="QTabWidget" name="fTabWidget">
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab_3">
<widget class="QWidget" name="fGeneral_tab">
<attribute name="title">
<string>general</string>
</attribute>
@ -75,7 +75,7 @@
</layout>
</widget>
</widget>
<widget class="QWidget" name="tab">
<widget class="QWidget" name="fMusrfit_tab">
<attribute name="title">
<string>musrfit</string>
</attribute>
@ -158,7 +158,25 @@
</property>
</widget>
</widget>
<widget class="QWidget" name="tab_2">
<widget class="QWidget" name="fMusrview_tab">
<attribute name="title">
<string>musrview</string>
</attribute>
<widget class="QCheckBox" name="fFourier_checkBox">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>141</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string>start with Fourier</string>
</property>
</widget>
</widget>
<widget class="QWidget" name="fMusrt0_tab">
<attribute name="title">
<string>musrt0</string>
</attribute>

View File

@ -0,0 +1,28 @@
/* XPM */
static char *dummy[]={
"22 22 3 1",
". c None",
"# c #000000",
"a c #ff0000",
"..##....###...##......",
"......................",
"######################",
"......................",
".........a............",
".........a............",
".........a............",
".........a............",
".........aa...........",
"........aaa...........",
"........aaa...........",
"........a.a...........",
"........a.a...........",
".......aa.aa..........",
".......aa..aa.........",
"a.aaa..a....aaa...aa..",
"aa.aaa.a......aaa.aaaa",
"......a..........aa...",
"######################",
"......................",
".#######.####..####...",
"......................"};

Binary file not shown.

View File

@ -83,6 +83,7 @@ HEADERS = musredit.h \
PFitOutputHandler.h \
PDumpOutputHandler.h \
PPrefsDialog.h \
PGetMusrFTOptionsDialog.h \
PGetDefaultDialog.h \
PGetTitleBlockDialog.h \
PGetParameterBlockDialog.h \
@ -106,6 +107,7 @@ SOURCES = PHelp.cpp \
PFitOutputHandler.cpp \
PDumpOutputHandler.cpp \
PPrefsDialog.cpp \
PGetMusrFTOptionsDialog.cpp \
PGetDefaultDialog.cpp \
PGetTitleBlockDialog.cpp \
PGetParameterBlockDialog.cpp \
@ -126,6 +128,7 @@ FORMS = forms/PFindDialog.ui \
forms/PGetDefaultDialog.ui \
forms/PMusrEditAbout.ui \
forms/PPrefsDialog.ui \
forms/PGetMusrFTOptionsDialog.ui \
forms/PGetTitleBlockDialog.ui \
forms/PGetParameterBlockDialog.ui \
forms/PGetTheoryBlockDialog.ui \
@ -138,3 +141,5 @@ FORMS = forms/PFindDialog.ui \
forms/PMsr2DataDialog.ui
RESOURCES = musredit.qrc
macx:ICON = images/musredit.icns

View File

@ -1,40 +1,41 @@
<RCC>
<qresource>
<file>images/editcopy.xpm</file>
<file>images/editcut.xpm</file>
<file>images/editfind.xpm</file>
<file>images/editnext.xpm</file>
<file>images/editpaste.xpm</file>
<file>images/editprevious.xpm</file>
<file>images/editredo.xpm</file>
<file>images/editundo.xpm</file>
<file>images/filenew.xpm</file>
<file>images/fileopen.xpm</file>
<file>images/fileprint.xpm</file>
<file>images/filereload.xpm</file>
<file>images/filesave.xpm</file>
<file>images/musrasym.xpm</file>
<file>images/musrcalcchisq.xpm</file>
<file>images/musrfit.xpm</file>
<file>images/musrmsr2data.xpm</file>
<file>images/musrprefs.xpm</file>
<file>images/musrsinglehisto.xpm</file>
<file>images/musrswap.xpm</file>
<file>images/musrt0.xpm</file>
<file>images/musrview.xpm</file>
<file>images/musrdump.xpm</file>
<file>latex_images/abragam.png</file>
<file>latex_images/asymmetry.png</file>
<file>latex_images/bessel.png</file>
<file>latex_images/combiLGKT.png</file>
<file>latex_images/generalExp.png</file>
<file>latex_images/internalBessel.png</file>
<file>latex_images/internalField.png</file>
<file>latex_images/polynom.png</file>
<file>latex_images/simpleExp.png</file>
<file>latex_images/simpleGauss.png</file>
<file>latex_images/statExpKT.png</file>
<file>latex_images/statGssKT.png</file>
<file>latex_images/tfCos.png</file>
</qresource>
<qresource prefix="/">
<file>images/editcopy.xpm</file>
<file>images/editcut.xpm</file>
<file>images/editfind.xpm</file>
<file>images/editnext.xpm</file>
<file>images/editpaste.xpm</file>
<file>images/editprevious.xpm</file>
<file>images/editredo.xpm</file>
<file>images/editundo.xpm</file>
<file>images/filenew.xpm</file>
<file>images/fileopen.xpm</file>
<file>images/fileprint.xpm</file>
<file>images/filereload.xpm</file>
<file>images/filesave.xpm</file>
<file>images/musrasym.xpm</file>
<file>images/musrcalcchisq.xpm</file>
<file>images/musrfit.xpm</file>
<file>images/musrmsr2data.xpm</file>
<file>images/musrprefs.xpm</file>
<file>images/musrsinglehisto.xpm</file>
<file>images/musrswap.xpm</file>
<file>images/musrt0.xpm</file>
<file>images/musrview.xpm</file>
<file>images/musrFT.xpm</file>
<file>images/musrdump.xpm</file>
<file>latex_images/abragam.png</file>
<file>latex_images/asymmetry.png</file>
<file>latex_images/bessel.png</file>
<file>latex_images/combiLGKT.png</file>
<file>latex_images/generalExp.png</file>
<file>latex_images/internalBessel.png</file>
<file>latex_images/internalField.png</file>
<file>latex_images/polynom.png</file>
<file>latex_images/simpleExp.png</file>
<file>latex_images/simpleGauss.png</file>
<file>latex_images/statExpKT.png</file>
<file>latex_images/statGssKT.png</file>
<file>latex_images/tfCos.png</file>
</qresource>
</RCC>

View File

@ -31,6 +31,7 @@
<musr_web_plot>file://@DOCDIR@/html/user/MUSR/MusrFit.html#ThePlotBlock</musr_web_plot>
<musr_web_statistic>file://@DOCDIR@/html/user/MUSR/MusrFit.html#TheStatisticBlock</musr_web_statistic>
<musr_web_msr2data>file://@DOCDIR@/html/user/MUSR/Msr2Data.html</musr_web_msr2data>
<musr_web_musrFT>file://@DOCDIR@/html/user/MUSR/MusrFit.html#A_2.3_musrFT</musr_web_musrFT>
</help_section>
<font_settings>
<font_name>Courier New</font_name>

View File

@ -0,0 +1,5 @@
## Process this file with automake to create Makefile.in
CLEANFILES = *~ core moc_* ui_*

967
src/musredit_qt5/PAdmin.cpp Normal file
View File

@ -0,0 +1,967 @@
/****************************************************************************
PAdmin.cpp
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
*****************************************************************************/
/***************************************************************************
* Copyright (C) 2010-2014 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <cstdlib>
#include <iostream>
using namespace std;
#include <QMessageBox>
#include <QString>
#include <QFile>
#include <QTextStream>
#include <QVector>
#include "PAdmin.h"
//--------------------------------------------------------------------------
// implementation of PAdminXMLParser class
//--------------------------------------------------------------------------
/**
* <p>XML Parser class for the musredit administration file.
*
* \param admin pointer to an admin class instance.
*/
PAdminXMLParser::PAdminXMLParser(PAdmin *admin) : fAdmin(admin)
{
fKeyWord = eEmpty;
fFunc = false;
}
//--------------------------------------------------------------------------
/**
* <p>Routine called at the beginning of the XML parsing process.
*/
bool PAdminXMLParser::startDocument()
{
return true;
}
//--------------------------------------------------------------------------
/**
* <p>Routine called when a new XML tag is found. Here it is used
* to set a tag for filtering afterwards the content.
*
* \param qName name of the XML tag.
*/
bool PAdminXMLParser::startElement( const QString&, const QString&,
const QString& qName,
const QXmlAttributes& )
{
if (qName == "timeout") {
fKeyWord = eTimeout;
} else if (qName == "font_name") {
fKeyWord = eFontName;
} else if (qName == "font_size") {
fKeyWord = eFontSize;
} else if (qName == "exec_path") {
fKeyWord = eExecPath;
} else if (qName == "default_save_path") {
fKeyWord = eDefaultSavePath;
} else if (qName == "title_from_data_file") {
fKeyWord = eTitleFromDataFile;
} else if (qName == "musrview_show_fourier") {
fKeyWord = eMusrviewShowFourier;
} else if (qName == "enable_musrt0") {
fKeyWord = eEnableMusrT0;
} else if (qName == "keep_minuit2_output") {
fKeyWord = eKeepMinuit2Output;
} else if (qName == "dump_ascii") {
fKeyWord = eDumpAscii;
} else if (qName == "dump_root") {
fKeyWord = eDumpRoot;
} else if (qName == "estimate_n0") {
fKeyWord = eEstimateN0;
} else if (qName == "chisq_per_run_block") {
fKeyWord = eChisqPreRunBlock;
} else if (qName == "path_file_name") {
fKeyWord = eRecentFile;
} else if (qName == "beamline") {
fKeyWord = eBeamline;
} else if (qName == "institute") {
fKeyWord = eInstitute;
} else if (qName == "file_format") {
fKeyWord = eFileFormat;
} else if (qName == "lifetime_correction") {
fKeyWord = eLifetimeCorrection;
} else if (qName == "msr_default_file_path") {
fKeyWord = eMsrDefaultFilePath;
} else if (qName == "musr_web_main") {
fKeyWord = eHelpMain;
} else if (qName == "musr_web_title") {
fKeyWord = eHelpTitle;
} else if (qName == "musr_web_parameters") {
fKeyWord = eHelpParameters;
} else if (qName == "musr_web_theory") {
fKeyWord = eHelpTheory;
} else if (qName == "musr_web_functions") {
fKeyWord = eHelpFunctions;
} else if (qName == "musr_web_run") {
fKeyWord = eHelpRun;
} else if (qName == "musr_web_command") {
fKeyWord = eHelpCommand;
} else if (qName == "musr_web_fourier") {
fKeyWord = eHelpFourier;
} else if (qName == "musr_web_plot") {
fKeyWord = eHelpPlot;
} else if (qName == "musr_web_statistic") {
fKeyWord = eHelpStatistic;
} else if (qName == "musr_web_msr2data") {
fKeyWord = eHelpMsr2Data;
} else if (qName == "musr_web_musrFT") {
fKeyWord = eHelpMusrFT;
} else if (qName == "chain_fit") {
fKeyWord = eChainFit;
} else if (qName == "write_data_header") {
fKeyWord = eWriteDataHeader;
} else if (qName == "ignore_data_header_info") {
fKeyWord = eIgnoreDataHeaderInfo;
} else if (qName == "keep_minuit2_output") {
fKeyWord = eKeepMinuit2Output;
} else if (qName == "write_column_data") {
fKeyWord = eWriteColumnData;
} else if (qName == "recreate_data_file") {
fKeyWord = eRecreateDataFile;
} else if (qName == "open_file_after_fitting") {
fKeyWord = eOpenFileAfterFitting;
} else if (qName == "create_msr_file_only") {
fKeyWord = eCreateMsrFileOnly;
} else if (qName == "fit_only") {
fKeyWord = eFitOnly;
} else if (qName == "global") {
fKeyWord = eGlobal;
} else if (qName == "global_plus") {
fKeyWord = eGlobalPlus;
} else if (qName == "func_pixmap_path") {
fKeyWord = eTheoFuncPixmapPath;
} else if (qName == "func") {
fKeyWord = eFunc;
fFunc = true;
// init theory item
fTheoryItem.name = "";
fTheoryItem.comment = "";
fTheoryItem.label = "";
fTheoryItem.pixmapName = "";
fTheoryItem.pixmap = QPixmap();
fTheoryItem.params = -1;
} else if (qName == "name") {
fKeyWord = eFuncName;
} else if (qName == "comment") {
fKeyWord = eFuncComment;
} else if (qName == "label") {
fKeyWord = eFuncLabel;
} else if (qName == "pixmap") {
fKeyWord = eFuncPixmap;
} else if (qName == "params") {
fKeyWord = eFuncParams;
}
return true;
}
//--------------------------------------------------------------------------
/**
* <p>Routine called when the end XML tag is found. It is used to
* put the filtering tag to 'empty'. It also resets the fFunc flag in case
* the entry was a theory function.
*
* \param qName name of the element.
*/
bool PAdminXMLParser::endElement( const QString&, const QString&, const QString &qName )
{
fKeyWord = eEmpty;
if (qName == "func") {
fFunc = false;
fAdmin->addTheoryItem(fTheoryItem);
}
return true;
}
//--------------------------------------------------------------------------
/**
* <p>This routine delivers the content of an XML tag. It fills the
* content into the load data structure.
*
* \param str keeps the content of the XML tag.
*/
bool PAdminXMLParser::characters(const QString& str)
{
QString help;
bool flag, ok;
int ival;
switch (fKeyWord) {
case eTimeout:
ival = QString(str.toLatin1()).trimmed().toInt(&ok);
if (ok)
fAdmin->setTimeout(ival);
break;
case eFontName:
fAdmin->setFontName(QString(str.toLatin1()).trimmed());
break;
case eFontSize:
ival = QString(str.toLatin1()).trimmed().toInt(&ok);
if (ok)
fAdmin->setFontSize(ival);
break;
case eExecPath:
fAdmin->setExecPath(QString(str.toLatin1()).trimmed());
break;
case eDefaultSavePath:
fAdmin->setDefaultSavePath(QString(str.toLatin1()).trimmed());
break;
case eTitleFromDataFile:
if (str == "y")
flag = true;
else
flag = false;
fAdmin->setTitleFromDataFileFlag(flag);
break;
case eMusrviewShowFourier:
if (str == "y")
flag = true;
else
flag = false;
fAdmin->setMusrviewShowFourierFlag(flag);
break;
case eEnableMusrT0:
if (str == "y")
flag = true;
else
flag = false;
fAdmin->setEnableMusrT0Flag(flag);
break;
case eKeepMinuit2Output:
if (str == "y")
flag = true;
else
flag = false;
fAdmin->fMsr2DataParam.keepMinuit2Output = flag;
fAdmin->setKeepMinuit2OutputFlag(flag);
break;
case eDumpAscii:
if (str == "y")
flag = true;
else
flag = false;
fAdmin->setDumpAsciiFlag(flag);
break;
case eDumpRoot:
if (str == "y")
flag = true;
else
flag = false;
fAdmin->setDumpRootFlag(flag);
break;
case eEstimateN0:
if (str == "y")
flag = true;
else
flag = false;
fAdmin->setEstimateN0Flag(flag);
break;
case eChisqPreRunBlock:
if (str == "y")
flag = true;
else
flag = false;
fAdmin->setChisqPerRunBlockFlag(flag);
break;
case eRecentFile:
fAdmin->addRecentFile(QString(str.toLatin1()).trimmed());
break;
case eBeamline:
fAdmin->setBeamline(QString(str.toLatin1()).trimmed());
break;
case eInstitute:
fAdmin->setInstitute(QString(str.toLatin1()).trimmed());
break;
case eFileFormat:
fAdmin->setFileFormat(QString(str.toLatin1()).trimmed());
break;
case eLifetimeCorrection:
if (str == "y")
flag = true;
else
flag = false;
fAdmin->setLifetimeCorrectionFlag(flag);
break;
case eMsrDefaultFilePath:
fAdmin->setMsrDefaultFilePath(QString(str.toLatin1()).trimmed());
break;
case eHelpMain:
fAdmin->setHelpUrl("main", str);
break;
case eHelpTitle:
fAdmin->setHelpUrl("title", str);
break;
case eHelpParameters:
fAdmin->setHelpUrl("parameters", str);
break;
case eHelpTheory:
fAdmin->setHelpUrl("theory", str);
break;
case eHelpFunctions:
fAdmin->setHelpUrl("functions", str);
break;
case eHelpRun:
fAdmin->setHelpUrl("run", str);
break;
case eHelpCommand:
fAdmin->setHelpUrl("command", str);
break;
case eHelpFourier:
fAdmin->setHelpUrl("fourier", str);
break;
case eHelpPlot:
fAdmin->setHelpUrl("plot", str);
break;
case eHelpStatistic:
fAdmin->setHelpUrl("statistic", str);
break;
case eHelpMsr2Data:
fAdmin->setHelpUrl("msr2data", str);
break;
case eHelpMusrFT:
fAdmin->setHelpUrl("musrFT", str);
break;
case eChainFit:
if (str == "y")
flag = true;
else
flag = false;
fAdmin->fMsr2DataParam.chainFit = flag;
break;
case eWriteDataHeader:
if (str == "y")
flag = true;
else
flag = false;
fAdmin->fMsr2DataParam.writeDbHeader = flag;
break;
case eIgnoreDataHeaderInfo:
if (str == "y")
flag = true;
else
flag = false;
fAdmin->fMsr2DataParam.ignoreDataHeaderInfo = flag;
break;
case eWriteColumnData:
if (str == "y")
flag = true;
else
flag = false;
fAdmin->fMsr2DataParam.writeColumnData = flag;
break;
case eRecreateDataFile:
if (str == "y")
flag = true;
else
flag = false;
fAdmin->fMsr2DataParam.recreateDbFile = flag;
break;
case eOpenFileAfterFitting:
if (str == "y")
flag = true;
else
flag = false;
fAdmin->fMsr2DataParam.openFilesAfterFitting = flag;
break;
case eCreateMsrFileOnly:
if (str == "y")
flag = true;
else
flag = false;
fAdmin->fMsr2DataParam.createMsrFileOnly = flag;
break;
case eFitOnly:
if (str == "y")
flag = true;
else
flag = false;
fAdmin->fMsr2DataParam.fitOnly = flag;
break;
case eGlobal:
if (str == "y")
flag = true;
else
flag = false;
fAdmin->fMsr2DataParam.global = flag;
break;
case eGlobalPlus:
if (str == "y")
flag = true;
else
flag = false;
fAdmin->fMsr2DataParam.globalPlus = flag;
break;
case eTheoFuncPixmapPath:
fAdmin->setTheoFuncPixmapPath(QString(str.toLatin1()).trimmed());
break;
default:
break;
}
if (fFunc) {
bool ok;
switch (fKeyWord) {
case eFuncName:
fTheoryItem.name = QString(str.toLatin1()).trimmed();
break;
case eFuncComment:
fTheoryItem.comment = QString(str.toLatin1()).trimmed();
break;
case eFuncLabel:
fTheoryItem.label = QString(str.toLatin1()).trimmed();
break;
case eFuncPixmap:
fTheoryItem.pixmapName = QString(str.toLatin1()).trimmed();
break;
case eFuncParams:
fTheoryItem.params = str.toInt(&ok);
if (!ok)
return false;
break;
default:
break;
}
}
return true;
}
//--------------------------------------------------------------------------
/**
* <p>Called at the end of the XML parse process. It checks if default paths
* contain system variables, and if so expand them for the further use.
*/
bool PAdminXMLParser::endDocument()
{
// check if all necessary items are found
QString str;
if (fAdmin->getExecPath().indexOf('$') >= 0) {
str = expandPath(fAdmin->getExecPath());
if (!str.isEmpty())
fAdmin->setExecPath(str);
}
if (fAdmin->getDefaultSavePath().indexOf('$') >= 0) {
str = expandPath(fAdmin->getDefaultSavePath());
if (!str.isEmpty())
fAdmin->setDefaultSavePath(str);
}
if (fAdmin->getMsrDefaultFilePath().indexOf('$') >= 0) {
str = expandPath(fAdmin->getMsrDefaultFilePath());
if (!str.isEmpty())
fAdmin->setMsrDefaultFilePath(str);
}
if (fAdmin->getTheoFuncPixmapPath().indexOf('$') >=0) {
str = expandPath(fAdmin->getTheoFuncPixmapPath());
if (!str.isEmpty())
fAdmin->setTheoFuncPixmapPath(str);
}
return true;
}
//--------------------------------------------------------------------------
/**
* <p>Report XML warnings.
*
* \param exception holds the information of the XML warning
*/
bool PAdminXMLParser::warning( const QXmlParseException & exception )
{
QString msg;
msg = QString("**WARNING** while parsing musredit_startup.xml in line no %1\n").arg(exception.lineNumber());
msg += QString("**WARNING MESSAGE** ") + exception.message();
qWarning() << endl << msg << endl;
QMessageBox::warning(0, "WARNING", msg, QMessageBox::Ok, QMessageBox::NoButton);
return true;
}
//--------------------------------------------------------------------------
/**
* <p>Report recoverable XML errors.
*
* \param exception holds the information of the XML recoverable errors.
*/
bool PAdminXMLParser::error( const QXmlParseException & exception )
{
QString msg;
msg = QString("**ERROR** while parsing musredit_startup.xml in line no %1\n").arg(exception.lineNumber());
msg += QString("**ERROR MESSAGE** ") + exception.message();
qWarning() << endl << msg << endl;
QMessageBox::critical(0, "ERROR", msg, QMessageBox::Ok, QMessageBox::NoButton);
return true;
}
//--------------------------------------------------------------------------
/**
* <p>Report fatal XML errors.
*
* \param exception holds the information of the XML fatal errors.
*/
bool PAdminXMLParser::fatalError( const QXmlParseException & exception )
{
QString msg;
msg = QString("**FATAL ERROR** while parsing musredit_startup.xml in line no %1\n").arg(exception.lineNumber());
msg += QString("**FATAL ERROR MESSAGE** ") + exception.message();
qWarning() << endl << msg << endl;
QMessageBox::critical(0, "FATAL ERROR", msg, QMessageBox::Ok, QMessageBox::NoButton);
return true;
}
//--------------------------------------------------------------------------
/**
* <p>Expands system variables to full path, e.g. <tt>$HOME -> \home\user</tt>
*
* \param str path string with none expanded system variables.
*/
QString PAdminXMLParser::expandPath(const QString &str)
{
QString token;
QString path;
QString msg;
QString newStr="";
QStringList list = str.split("/");
for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
token = *it;
if (token.contains("$")) {
token.remove('$');
path = std::getenv(token.toLatin1());
if (path.isEmpty()) {
msg = QString("Couldn't expand '%1'. Some things might not work properly").arg(token);
QMessageBox::warning(0, "**WARNING**", msg, QMessageBox::Ok, QMessageBox::NoButton);
newStr = "";
break;
}
newStr += path;
} else {
newStr += "/" + token;
}
}
return newStr;
}
//--------------------------------------------------------------------------
// implementation of PAdmin class
//--------------------------------------------------------------------------
/**
* <p>Initializes that PAdmin object, and calls the XML parser which feeds
* the object variables.
*/
PAdmin::PAdmin() : QObject()
{
fTimeout = 3600;
fFontName = QString("Courier"); // default font
fFontSize = 11; // default font size
fExecPath = QString("");
fDefaultSavePath = QString("");
fMsrDefaultFilePath = QString("");
fTheoFuncPixmapPath = QString("");
fBeamline = QString("");
fInstitute = QString("");
fFileFormat = QString("");
fMusrviewShowFourier = false;
fTitleFromDataFile = false;
fEnableMusrT0 = false;
fLifetimeCorrection = true;
fEstimateN0 = true;
fChisqPreRunBlock = false;
fMsr2DataParam.firstRun = -1;
fMsr2DataParam.lastRun = -1;
fMsr2DataParam.runList = QString("");
fMsr2DataParam.runListFileName = QString("");
fMsr2DataParam.msrFileExtension = QString("");
fMsr2DataParam.templateRunNo = -1;
fMsr2DataParam.dbOutputFileName = QString("");
fMsr2DataParam.writeDbHeader = true;
fMsr2DataParam.ignoreDataHeaderInfo = false;
fMsr2DataParam.keepMinuit2Output = false;
fMsr2DataParam.writeColumnData = false;
fMsr2DataParam.recreateDbFile = false;
fMsr2DataParam.chainFit = true;
fMsr2DataParam.openFilesAfterFitting = true;
fMsr2DataParam.titleFromDataFile = true;
fMsr2DataParam.createMsrFileOnly = false;
fMsr2DataParam.fitOnly = false;
fMsr2DataParam.global = false;
fMsr2DataParam.globalPlus = false;
// XML Parser part
QString fln = "musredit_startup.xml";
// check if it is a MacOSX
#ifdef Q_OS_OSX
fln = "./musredit_startup.xml";
if (!QFile::exists(fln)) {
fln = "/Applications/musredit.app/Contents/Resources/musredit_startup.xml";
}
#else
fln = "./musredit_startup.xml";
if (!QFile::exists(fln)) {
QString path = std::getenv("MUSRFITPATH");
QString rootsys = std::getenv("ROOTSYS");
if (path.isEmpty())
path = rootsys + "/bin";
fln = path + "/musredit_startup.xml";
}
#endif
loadPrefs(fln);
}
//--------------------------------------------------------------------------
/**
* <p>Destructor
*/
PAdmin::~PAdmin()
{
saveRecentFiles();
}
//--------------------------------------------------------------------------
/**
* <p>returns the help url corresponding the the tag.
*
* \param tag to map the help url. At the moment the following tags should be present:
* main, title, parameters, theory, functions, run, command, fourier, plot, statistic
*/
QString PAdmin::getHelpUrl(QString tag)
{
return fHelpUrl[tag];
}
//--------------------------------------------------------------------------
/**
* <p>returns a theory item from position idx. If idx is out of the range, a null pointer is returned.
*
* \param idx position of the theory item.
*/
PTheory* PAdmin::getTheoryItem(const unsigned int idx)
{
if (idx > (unsigned int)fTheory.size())
return 0;
else
return &fTheory[idx];
}
//--------------------------------------------------------------------------
/**
* <p>returns the recent path-file name at position idx. If idx is out of scope,
* an empty string is returned.
*
* \param idx index of the recent path-file name to be retrieved.
*/
QString PAdmin::getRecentFile(int idx)
{
if (idx >= fRecentFile.size())
return QString("");
return fRecentFile[idx];
}
//--------------------------------------------------------------------------
/**
* <p>set the help url, addressed via a tag. At the moment the following tags should be present:
* main, title, parameters, theory, functions, run, command, fourier, plot, statistic, msr2data
*
* \param tag to address the help url
* \param url help url corresponding to the tag.
*/
void PAdmin::setHelpUrl(const QString tag, const QString url)
{
fHelpUrl[tag] = url;
}
//--------------------------------------------------------------------------
/**
* <p>Loads the preference file fln.
*
* <b>return:</b> 1 on success, 0 otherwise
*
* \param fln path-file name of the preference file to be loaded.
*/
int PAdmin::loadPrefs(QString fln)
{
if (QFile::exists(fln)) { // administration file present
PAdminXMLParser handler(this);
QFile xmlFile(fln);
QXmlInputSource source( &xmlFile );
QXmlSimpleReader reader;
reader.setContentHandler( &handler );
reader.setErrorHandler( &handler );
if (!reader.parse( source )) {
QMessageBox::critical(0, "ERROR",
"Error parsing musredit_startup.xml settings file.\nProbably a few things will not work porperly.\nPlease fix this first.",
QMessageBox::Ok, QMessageBox::NoButton);
return 0;
}
} else {
QMessageBox::critical(0, "ERROR",
"Couldn't find the musredit_startup.xml settings file.\nProbably a few things will not work porperly.\nPlease fix this first.",
QMessageBox::Ok, QMessageBox::NoButton);
return 0;
}
return 1;
}
//--------------------------------------------------------------------------
/**
* <p>Save the preference file pref_fln.
*
* <b>return:</b> 1 on success, 0 otherwise
*
* \param pref_fln preference path-file name
*/
int PAdmin::savePrefs(QString pref_fln)
{
// check if musredit_startup.xml is present in the current directory, and if yes, use this file to
// save the recent file names otherwise use the "master" musredit_startup.xml
QString str;
QString fln = "musredit_startup.xml";
// check if it is a MacOSX
#ifdef Q_OS_OSX
fln = "./musredit_startup.xml";
if (!QFile::exists(fln)) {
fln = "/Applications/musredit.app/Contents/Resources/musredit_startup.xml";
}
#else
fln = "./musredit_startup.xml";
if (!QFile::exists(fln)) {
QString path = std::getenv("MUSRFITPATH");
QString rootsys = std::getenv("ROOTSYS");
if (path.isEmpty())
path = rootsys + "/bin";
fln = path + "/musredit_startup.xml";
}
#endif
if (QFile::exists(fln)) { // administration file present
QVector<QString> data;
QFile file(fln);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
cerr << endl << ">> PAdmin::savePrefs: **ERROR** Cannot open " << fln.toLatin1().data() << " for reading." << endl;
return 1;
}
QTextStream fin(&file);
while (!fin.atEnd()) {
data.push_back(fin.readLine());
}
file.close();
// replace all the prefs
for (int i=0; i<data.size(); i++) {
if (data[i].contains("<timeout>") && data[i].contains("</timeout>")) {
data[i] = " <timeout>" + QString("%1").arg(fTimeout) + "</timeout>";
}
if (data[i].contains("<keep_minuit2_output>") && data[i].contains("</keep_minuit2_output>")) {
if (fKeepMinuit2Output)
data[i] = " <keep_minuit2_output>y</keep_minuit2_output>";
else
data[i] = " <keep_minuit2_output>n</keep_minuit2_output>";
}
if (data[i].contains("<dump_ascii>") && data[i].contains("</dump_ascii>")) {
if (fDumpAscii)
data[i] = " <dump_ascii>y</dump_ascii>";
else
data[i] = " <dump_ascii>n</dump_ascii>";
}
if (data[i].contains("<dump_root>") && data[i].contains("</dump_root>")) {
if (fDumpRoot)
data[i] = " <dump_root>y</dump_root>";
else
data[i] = " <dump_root>n</dump_root>";
}
if (data[i].contains("<title_from_data_file>") && data[i].contains("</title_from_data_file>")) {
if (fTitleFromDataFile)
data[i] = " <title_from_data_file>y</title_from_data_file>";
else
data[i] = " <title_from_data_file>n</title_from_data_file>";
}
if (data[i].contains("<chisq_per_run_block>") && data[i].contains("</chisq_per_run_block>")) {
if (fChisqPreRunBlock)
data[i] = " <chisq_per_run_block>y</chisq_per_run_block>";
else
data[i] = " <chisq_per_run_block>n</chisq_per_run_block>";
}
if (data[i].contains("<estimate_n0>") && data[i].contains("</estimate_n0>")) {
if (fEstimateN0)
data[i] = " <estimate_n0>y</estimate_n0>";
else
data[i] = " <estimate_n0>n</estimate_n0>";
}
if (data[i].contains("<enable_musrt0>") && data[i].contains("</enable_musrt0>")) {
if (fEnableMusrT0)
data[i] = " <enable_musrt0>y</enable_musrt0>";
else
data[i] = " <enable_musrt0>n</enable_musrt0>";
}
}
// write prefs
file.setFileName(pref_fln);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
cerr << endl << ">> PAdmin::savePrefs: **ERROR** Cannot open " << fln.toLatin1().data() << " for writing." << endl;
return 0;
}
fin.setDevice(&file);
for (int i=0; i<data.size(); i++)
fin << data[i] << endl;
file.close();
}
return 1;
}
//--------------------------------------------------------------------------
/**
* <p>Add recent path-file name to the internal ring-buffer.
*
* \param str recent path-file name to be added
*/
void PAdmin::addRecentFile(const QString str)
{
// check if file name is not already present
for (int i=0; i<fRecentFile.size(); i++) {
if (str == fRecentFile[i])
return;
}
fRecentFile.push_front(str);
if (fRecentFile.size() > MAX_RECENT_FILES)
fRecentFile.resize(MAX_RECENT_FILES);
}
//--------------------------------------------------------------------------
/**
* <p>Merges the recent file ring buffer into musredit_startup.xml and saves it.
* If a local copy is present it will be saved there, otherwise the master file
* will be used.
*/
void PAdmin::saveRecentFiles()
{
// check if musredit_startup.xml is present in the current directory, and if yes, use this file to
// save the recent file names otherwise use the "master" musredit_startup.xml
QString str;
QString fln = "musredit_startup.xml";
// check if it is a MacOSX
#ifdef Q_OS_OSX
fln = "./musredit_startup.xml";
if (!QFile::exists(fln)) {
fln = "/Applications/musredit.app/Contents/Resources/musredit_startup.xml";
}
#else
fln = "./musredit_startup.xml";
if (!QFile::exists(fln)) {
QString path = std::getenv("MUSRFITPATH");
QString rootsys = std::getenv("ROOTSYS");
if (path.isEmpty())
path = rootsys + "/bin";
fln = path + "/musredit_startup.xml";
}
#endif
if (QFile::exists(fln)) { // administration file present
QVector<QString> data;
QFile file(fln);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
cerr << endl << ">> PAdmin::saveRecentFile: **ERROR** Cannot open " << fln.toLatin1().data() << " for reading." << endl;
return;
}
QTextStream fin(&file);
while (!fin.atEnd()) {
data.push_back(fin.readLine());
}
file.close();
// remove <path_file_name> from data
for (QVector<QString>::iterator it = data.begin(); it != data.end(); ++it) {
if (it->contains("<path_file_name>")) {
it = data.erase(it);
--it;
}
}
// add recent files
int i;
for (i=0; i<data.size(); i++) {
if (data[i].contains("<recent_files>"))
break;
}
if (i == data.size()) {
cerr << endl << ">> PAdmin::saveRecentFile: **ERROR** " << fln.toLatin1().data() << " seems to be corrupt." << endl;
return;
}
i++;
for (int j=0; j<fRecentFile.size(); j++) {
str = " <path_file_name>" + fRecentFile[j] + "</path_file_name>";
data.insert(i++, str);
}
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
cerr << endl << ">> PAdmin::saveRecentFile: **ERROR** Cannot open " << fln.toLatin1().data() << " for reading." << endl;
return;
}
fin.setDevice(&file);
for (int i=0; i<data.size(); i++)
fin << data[i] << endl;
file.close();
}
}
//--------------------------------------------------------------------------
// END
//--------------------------------------------------------------------------

208
src/musredit_qt5/PAdmin.h Normal file
View File

@ -0,0 +1,208 @@
/****************************************************************************
PAdmin.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
*****************************************************************************/
/***************************************************************************
* Copyright (C) 2010-2014 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef _PADMIN_H_
#define _PADMIN_H_
#include <QString>
#include <QVector>
#include <QMap>
#include <QPixmap>
#include <QtXml>
#include <musredit.h>
class PAdmin;
//---------------------------------------------------------------------------
/**
* <p>This structure is keeping informations necessary to handle musrfit
* theory functions (see also <code>https://intranet.psi.ch/MUSR/MusrFit#4_3_The_THEORY_Block</code>).
*/
typedef struct {
QString name;
QString comment;
QString label;
QString pixmapName;
QPixmap pixmap;
int params;
} PTheory;
//---------------------------------------------------------------------------
/**
* PAdminXMLParser is an XML parser class used to handle the musredit startup
* XML-file called <tt>musredit_startup.xml</tt>. This startup file contains
* necessary informations about executable pathes, online help informations,
* default font sizes, etc.
*/
class PAdminXMLParser : public QXmlDefaultHandler
{
public:
PAdminXMLParser(PAdmin*);
virtual ~PAdminXMLParser() {}
private:
enum EAdminKeyWords {eEmpty, eTimeout, eKeepMinuit2Output, eDumpAscii, eDumpRoot,
eTitleFromDataFile, eChisqPreRunBlock, eEstimateN0, eMusrviewShowFourier, eEnableMusrT0,
eFontName, eFontSize, eExecPath, eDefaultSavePath,
eRecentFile, eBeamline, eInstitute, eFileFormat, eLifetimeCorrection, eMsrDefaultFilePath,
eTheoFuncPixmapPath, eFunc, eFuncName, eFuncComment, eFuncLabel,
eFuncPixmap, eFuncParams, eHelpMain, eHelpTitle, eHelpParameters, eHelpTheory, eHelpFunctions,
eHelpRun, eHelpCommand, eHelpFourier, eHelpPlot, eHelpStatistic, eHelpMsr2Data, eHelpMusrFT,
eChainFit, eWriteDataHeader, eIgnoreDataHeaderInfo, eWriteColumnData,
eRecreateDataFile, eOpenFileAfterFitting, eCreateMsrFileOnly, eFitOnly, eGlobal, eGlobalPlus};
bool startDocument();
bool startElement( const QString&, const QString&, const QString& ,
const QXmlAttributes& );
bool endElement( const QString&, const QString&, const QString& );
bool characters(const QString&);
bool endDocument();
bool warning( const QXmlParseException & exception );
bool error( const QXmlParseException & exception );
bool fatalError( const QXmlParseException & exception );
QString expandPath(const QString&);
EAdminKeyWords fKeyWord; ///< key word tag to know how to handle the content
bool fFunc; ///< flag needed to indicate that a new theory function is found
PTheory fTheoryItem; ///< holding the informations necessary for a theory item
PAdmin *fAdmin; ///< a pointer to the main administration class object
};
//---------------------------------------------------------------------------
/**
* The PAdmin class is handling the informations contained in the XML startup file,
* <tt>musredit_startup.xml</tt>. This startup file contains
* necessary informations about executable pathes, online help informations,
* default font sizes, etc. The XML parsing is done with the help of the PAdminXMLParser
* class.
*/
class PAdmin : public QObject
{
public:
PAdmin();
virtual ~PAdmin();
int getTimeout() { return fTimeout; }
QString getFontName() { return fFontName; }
int getFontSize() { return fFontSize; }
QString getExecPath() { return fExecPath; }
QString getDefaultSavePath() { return fDefaultSavePath; }
bool getTitleFromDataFileFlag() { return fTitleFromDataFile; }
bool getMusrviewShowFourierFlag() { return fMusrviewShowFourier; }
bool getEnableMusrT0Flag() { return fEnableMusrT0; }
bool getKeepMinuit2OutputFlag() { return fKeepMinuit2Output; }
bool getDumpAsciiFlag() { return fDumpAscii; }
bool getDumpRootFlag() { return fDumpRoot; }
bool getEstimateN0Flag() { return fEstimateN0; }
bool getChisqPerRunBlockFlag() { return fChisqPreRunBlock; }
QString getBeamline() { return fBeamline; }
QString getInstitute() { return fInstitute; }
QString getFileFormat() { return fFileFormat; }
bool getLifetimeCorrectionFlag() { return fLifetimeCorrection; }
QString getMsrDefaultFilePath() { return fMsrDefaultFilePath; }
QString getHelpUrl(QString tag);
QString getTheoFuncPixmapPath() { return fTheoFuncPixmapPath; }
unsigned int getTheoryCounts() { return fTheory.size(); }
PTheory* getTheoryItem(const unsigned int idx);
PMsr2DataParam getMsr2DataParam() { return fMsr2DataParam; }
int getNumRecentFiles() { return fRecentFile.size(); }
QString getRecentFile(int idx);
void setTimeout(const int ival) { fTimeout = ival; }
void setTitleFromDataFileFlag(const bool flag) { fTitleFromDataFile = flag; }
void setMusrviewShowFourierFlag(const bool flag) { fMusrviewShowFourier = flag; }
void setEnableMusrT0Flag(const bool flag) { fEnableMusrT0 = flag; }
void setKeepMinuit2OutputFlag(const bool flag) { fKeepMinuit2Output = flag; }
void setDumpAsciiFlag(const bool flag) { fDumpAscii = flag; }
void setDumpRootFlag(const bool flag) { fDumpRoot = flag; }
void setEstimateN0Flag(const bool flag) { fEstimateN0 = flag; }
void setChisqPerRunBlockFlag(const bool flag) { fChisqPreRunBlock = flag; }
void setFontName(const QString str) { fFontName = str; }
void setFontSize(const int ival) { fFontSize = ival; }
void addRecentFile(const QString str);
int loadPrefs(QString fln);
int savePrefs(QString pref_fln);
protected:
void setExecPath(const QString str) { fExecPath = str; }
void setDefaultSavePath(const QString str) { fDefaultSavePath = str; }
void setBeamline(const QString str) { fBeamline = str; }
void setInstitute(const QString str) { fInstitute = str; }
void setFileFormat(const QString str) { fFileFormat = str; }
void setLifetimeCorrectionFlag(const bool flag) { fLifetimeCorrection = flag; }
void setMsrDefaultFilePath(const QString str) { fMsrDefaultFilePath = str; }
void setHelpUrl(const QString tag, const QString url);
void setTheoFuncPixmapPath (const QString str) { fTheoFuncPixmapPath = str; }
void addTheoryItem(const PTheory theo) { fTheory.push_back(theo); }
private:
friend class PAdminXMLParser;
int fTimeout; ///< timeout in seconds
QString fFontName; ///< default font name
int fFontSize; ///< default font size
QString fExecPath; ///< system path to the musrfit executables
QString fDefaultSavePath; ///< default path where the msr-file should be saved
QString fMsrDefaultFilePath; ///< path where to find musredit source
QString fTheoFuncPixmapPath; ///< path where the default pixmaps can be found
QVector<QString> fRecentFile; ///< keep vector of recent path-file names
bool fMusrviewShowFourier; ///< flag indicating if musrview should show at startup data (=false) or Fourier of data (=true).
bool fKeepMinuit2Output; ///< flag indicating if the Minuit2 output shall be kept (default: no)
bool fDumpAscii; ///< flag indicating if musrfit shall make an ascii-dump file (for debugging purposes, default: no).
bool fDumpRoot; ///< flag indicating if musrfit shall make an root-dump file (for debugging purposes, default: no).
bool fTitleFromDataFile; ///< flag indicating if the title should be extracted from the data file (default: yes).
bool fChisqPreRunBlock; ///< flag indicating if musrfit shall write 'per run block' chisq to the msr-file (default: no).
bool fEstimateN0; ///< flag indicating if musrfit shall estimate N0 for single histogram fits (default: yes).
bool fEnableMusrT0; ///< flag indicating if musrT0 shall be enabled at startup from within musredit (default: yes).
QString fBeamline; ///< name of the beamline. Used to generate default run header lines.
QString fInstitute; ///< name of the institute. Used to generate default run header lines.
QString fFileFormat; ///< default file format. Used to generate default run header lines.
bool fLifetimeCorrection; ///< flag indicating if by default the lifetime-correction-flag in a single histo file shall be set.
mutable PMsr2DataParam fMsr2DataParam; ///< keeps msr2data default parameter flags
QMap<QString, QString> fHelpUrl; ///< maps tag to help url
QVector<PTheory> fTheory; ///< stores all known theories. Needed when generating theory blocks from within musredit.
void saveRecentFiles(); ///< save recent file list
};
#endif // _PADMIN_H_

View File

@ -0,0 +1,153 @@
/****************************************************************************
PDumpOutputHandler.cpp
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
*****************************************************************************/
/***************************************************************************
* Copyright (C) 2012-2014 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <QTimer>
#include <QtDebug>
#include "PDumpOutputHandler.h"
//----------------------------------------------------------------------------------------------------
/**
* <p>Sets up the dump output handler GUI and starts the actual dump_header command
*
* \param cmd command string vector. From this the actual dump_header command will be generated and executed.
*/
PDumpOutputHandler::PDumpOutputHandler(QVector<QString> &cmd)
{
if (cmd.empty())
return;
// Layout
fVbox = new QVBoxLayout( this );
fOutput = new QTextEdit();
fVbox->addWidget(fOutput);
fOutput->setMinimumSize(600, 755);
fOutput->setReadOnly(true);
connect( fOutput, SIGNAL( destroyed() ), this, SLOT( quitButtonPressed() ) );
fQuitButton = new QPushButton( tr("Quit") );
fVbox->addWidget(fQuitButton);
connect( fQuitButton, SIGNAL( clicked() ), this, SLOT( quitButtonPressed() ) );
resize( 600, 800 );
fQuitButton->setFocus();
// QProcess related code
fProc = new QProcess( this );
// Set up the command and arguments.
QString program = cmd[0];
QStringList arguments;
for (int i=1; i<cmd.size(); i++)
arguments << cmd[i];
connect( fProc, SIGNAL( readyReadStandardOutput() ), this, SLOT( readFromStdOut() ) );
connect( fProc, SIGNAL( readyReadStandardError() ), this, SLOT( readFromStdErr() ) );
fProc->start(program, arguments);
if ( !fProc->waitForStarted() ) {
// error handling
QString msg(tr("Could not execute the output command: ")+cmd[0]);
QMessageBox::critical( 0,
tr("Fatal error"),
msg,
tr("Quit") );
done(0);
}
fProcPID = fProc->pid();
}
//----------------------------------------------------------------------------------------------------
/**
* <p>Destructor. Checks if the a dump_header is still running and if yes try to kill it.
*/
PDumpOutputHandler::~PDumpOutputHandler()
{
if (fProc->state() == QProcess::Running) {
fProc->terminate();
if (!fProc->waitForFinished()) {
qDebug() << "fProc still running, will call kill." << endl;
fProc->kill();
}
fProc->waitForFinished();
}
if (fProc->state() == QProcess::Running) {
QString cmd = "kill -9 "+ fProcPID;
QString msg = "fProc still running even after Qt kill, will try system kill cmd: "+cmd;
qDebug() << msg << endl;
system(cmd.toLatin1());
}
if (fProc) {
delete fProc;
fProc = 0;
}
}
//----------------------------------------------------------------------------------------------------
/**
* <p>Captures the standard output and adds it to the output text edit.
*/
void PDumpOutputHandler::readFromStdOut()
{
// Read and process the data.
// Bear in mind that the data might be output in chunks.
fOutput->append( fProc->readAllStandardOutput() );
}
//----------------------------------------------------------------------------------------------------
/**
* <p>Captures the standard error and adds it to the output text edit.
*/
void PDumpOutputHandler::readFromStdErr()
{
// Read and process the data.
// Bear in mind that the data might be output in chunks.
fOutput->append( fProc->readAllStandardError() );
}
//----------------------------------------------------------------------------------------------------
/**
* <p>If the quit button is pressed while the dump_header is still running, try to terminate dump_header, if this
* does not work, try to kill dump_header.
*/
void PDumpOutputHandler::quitButtonPressed()
{
// if the fitting is still taking place, kill it
if (fProc->state() == QProcess::Running) {
fProc->terminate();
if (!fProc->waitForFinished()) {
fProc->kill();
}
}
accept();
}
//----------------------------------------------------------------------------------------------------
// END
//----------------------------------------------------------------------------------------------------

View File

@ -0,0 +1,72 @@
/****************************************************************************
PDumpOutputHandler.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
*****************************************************************************/
/***************************************************************************
* Copyright (C) 2012-2014 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef _PDUMPOUTPUTHANDLER_H_
#define _PDUMPOUTPUTHANDLER_H_
#include <QObject>
#include <QProcess>
#include <QDialog>
#include <QVBoxLayout>
#include <QTextEdit>
#include <QPushButton>
#include <QMessageBox>
#include <QVector>
#include <cstdlib>
//---------------------------------------------------------------------------------------
/**
* <p>This class is the capturing the output of musrfit and displays it in a dialog so
* the user has the chance to follow the fitting process, warnings, error messages of
* musrfit.
*/
class PDumpOutputHandler : public QDialog
{
Q_OBJECT
public:
PDumpOutputHandler(QVector<QString> &cmd);
virtual ~PDumpOutputHandler();
private slots:
virtual void readFromStdOut();
virtual void readFromStdErr();
virtual void quitButtonPressed();
private:
Q_PID fProcPID; ///< keeps the process PID
QProcess *fProc; ///< pointer to the dump_header process
QVBoxLayout *fVbox; ///< pointer to the dialog layout manager
QTextEdit *fOutput; ///< the captured dump_header output is written (read only) into this text edit object.
QPushButton *fQuitButton; ///< quit button
};
#endif // _PDUMPOUTPUTHANDLER_H_

View File

@ -0,0 +1,108 @@
/****************************************************************************
PFindDialog.cpp
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
*****************************************************************************/
/***************************************************************************
* Copyright (C) 2009-2014 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <QPushButton>
#include <QComboBox>
#include <QCheckBox>
#include <QMessageBox>
#include "PFindDialog.h"
//----------------------------------------------------------------------------------------------------
/**
* <p>Sets up the find dialog.
*
* \param data pointer to the find/replace data structure needed to perform the task.
* \param selection flag indicating if the find shall be restricted to the selected area
* \param parent pointer to the parent object
* \param f qt specific window flags
*/
PFindDialog::PFindDialog(PFindReplaceData *data, const bool selection, QWidget *parent, Qt::WindowFlags f) :
QDialog(parent, f), fData(data)
{
setupUi(this);
setModal(true);
// if only empty text, disable find button
if (fData->findText == "") {
fFind_pushButton->setEnabled(false);
}
// if there is no selection, disable that option
if (!selection) {
fSelectedText_checkBox->setChecked(false);
fSelectedText_checkBox->setEnabled(false);
}
fFind_comboBox->setItemText(0, fData->findText);
fCaseSensitive_checkBox->setChecked(fData->caseSensitive);
fWholeWordsOnly_checkBox->setChecked(fData->wholeWordsOnly);
fFromCursor_checkBox->setChecked(fData->fromCursor);
fFindBackwards_checkBox->setChecked(fData->findBackwards);
if (selection) {
fSelectedText_checkBox->setChecked(fData->selectedText);
}
}
//----------------------------------------------------------------------------------------------------
/**
* <p>Extracts all the necessary informations from the find dialog, feeds it to the find/replace
* structure and returns a point to this structure.
*/
PFindReplaceData* PFindDialog::getData()
{
fData->findText = fFind_comboBox->currentText();
fData->caseSensitive = fCaseSensitive_checkBox->isChecked();
fData->wholeWordsOnly = fWholeWordsOnly_checkBox->isChecked();
fData->fromCursor = fFromCursor_checkBox->isChecked();
fData->findBackwards = fFindBackwards_checkBox->isChecked();
if (fSelectedText_checkBox->isEnabled())
fData->selectedText = fSelectedText_checkBox->isChecked();
return fData;
}
//----------------------------------------------------------------------------------------------------
/**
* <p>Enables the find button only if there is any find text entered.
*/
void PFindDialog::onFindTextAvailable(const QString&)
{
if (fFind_comboBox->currentText() != "")
fFind_pushButton->setEnabled(true);
else
fFind_pushButton->setEnabled(false);
}
//----------------------------------------------------------------------------------------------------
// END
//----------------------------------------------------------------------------------------------------

View File

@ -0,0 +1,57 @@
/****************************************************************************
PFindDialog.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
*****************************************************************************/
/***************************************************************************
* Copyright (C) 2010-2014 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef _PFINDDIALOG_H_
#define _PFINDDIALOG_H_
#include "musredit.h"
#include "ui_PFindDialog.h"
//--------------------------------------------------------------------------------------------------
/**
* <p>PFindDialog is the class handling the find dialog.
*/
class PFindDialog : public QDialog, private Ui::PFindDialog
{
Q_OBJECT
public:
PFindDialog(PFindReplaceData *data, const bool selection, QWidget *parent = 0, Qt::WindowFlags f = 0);
virtual ~PFindDialog() {}
virtual PFindReplaceData *getData();
protected slots:
virtual void onFindTextAvailable(const QString&);
private:
PFindReplaceData *fData; ///< stores the data necessary to perform find/replace.
};
#endif // _PFINDDIALOG_H_

View File

@ -0,0 +1,172 @@
/****************************************************************************
PFitOutputHandler.cpp
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
*****************************************************************************/
/***************************************************************************
* Copyright (C) 2009-2014 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <QTimer>
#include <QtDebug>
#include "PFitOutputHandler.h"
//----------------------------------------------------------------------------------------------------
/**
* <p>Sets up the fit output handler GUI and starts the actual fit
*
* \param workingDirectory string holding the working directory wished. In this directory the mlog-file will be saved.
* \param cmd command string vector. From this the actuall fit command will be generated and executed.
*/
PFitOutputHandler::PFitOutputHandler(QString workingDirectory, QVector<QString> &cmd)
{
if (cmd.empty())
return;
// Layout
fVbox = new QVBoxLayout( this );
//Qt.3x fVbox->resize(800, 500);
fOutput = new QTextEdit();
fVbox->addWidget(fOutput);
fOutput->setMinimumSize(800, 455);
fOutput->setReadOnly(true);
connect( fOutput, SIGNAL( destroyed() ), this, SLOT( quitButtonPressed() ) );
fQuitButton = new QPushButton( tr("Fitting...") );
fVbox->addWidget(fQuitButton);
connect( fQuitButton, SIGNAL( clicked() ), this, SLOT( quitButtonPressed() ) );
resize( 800, 500 );
fQuitButton->setFocus();
// QProcess related code
fProc = new QProcess( this );
fProc->setWorkingDirectory(workingDirectory);
// Set up the command and arguments.
QString program = cmd[0];
QStringList arguments;
for (int i=1; i<cmd.size(); i++)
arguments << cmd[i];
connect( fProc, SIGNAL( readyReadStandardOutput() ), this, SLOT( readFromStdOut() ) );
connect( fProc, SIGNAL( readyReadStandardError() ), this, SLOT( readFromStdErr() ) );
connect( fProc, SIGNAL( finished(int, QProcess::ExitStatus) ), this, SLOT( processDone(int, QProcess::ExitStatus) ) );
fProc->start(program, arguments);
if ( !fProc->waitForStarted() ) {
// error handling
QString msg(tr("Could not execute the output command: ")+cmd[0]);
QMessageBox::critical( 0,
tr("Fatal error"),
msg,
tr("Quit") );
done(0);
}
fProcPID = fProc->pid();
}
//----------------------------------------------------------------------------------------------------
/**
* <p>Destructor. Checks if the a fit is still running and if yes try to kill it.
*/
PFitOutputHandler::~PFitOutputHandler()
{
if (fProc->state() == QProcess::Running) {
fProc->terminate();
if (!fProc->waitForFinished()) {
qDebug() << "fProc still running, will call kill." << endl;
fProc->kill();
}
fProc->waitForFinished();
}
if (fProc->state() == QProcess::Running) {
QString cmd = "kill -9 "+ fProcPID;
QString msg = "fProc still running even after Qt kill, will try system kill cmd: "+cmd;
qDebug() << msg << endl;
system(cmd.toLatin1());
}
if (fProc) {
delete fProc;
fProc = 0;
}
}
//----------------------------------------------------------------------------------------------------
/**
* <p>Captures the standard output and adds it to the output text edit.
*/
void PFitOutputHandler::readFromStdOut()
{
// Read and process the data.
// Bear in mind that the data might be output in chunks.
fOutput->append( fProc->readAllStandardOutput() );
}
//----------------------------------------------------------------------------------------------------
/**
* <p>Captures the standard error and adds it to the output text edit.
*/
void PFitOutputHandler::readFromStdErr()
{
// Read and process the data.
// Bear in mind that the data might be output in chunks.
fOutput->append( fProc->readAllStandardError() );
}
//----------------------------------------------------------------------------------------------------
/**
* <p>If musrfit finishes, crashes, ..., the quit button text will be changed to done.
*
* \param exitCode exit code of musrfit
* \param exitStatus exit status of musrfit
*/
void PFitOutputHandler::processDone(int exitCode, QProcess::ExitStatus exitStatus)
{
if ((exitStatus == QProcess::CrashExit) && (exitCode != 0))
qDebug() << "**ERROR** PFitOutputHandler::processDone: exitCode = " << exitCode << endl;
fQuitButton->setText("Done");
}
//----------------------------------------------------------------------------------------------------
/**
* <p>If the quit button is pressed while the fit is still running, try to terminate musrfit, if this
* does not work, try to kill musrfit.
*/
void PFitOutputHandler::quitButtonPressed()
{
// if the fitting is still taking place, kill it
if (fProc->state() == QProcess::Running) {
fProc->terminate();
if (!fProc->waitForFinished()) {
fProc->kill();
}
}
accept();
}
//----------------------------------------------------------------------------------------------------
// END
//----------------------------------------------------------------------------------------------------

View File

@ -0,0 +1,73 @@
/****************************************************************************
PFitOutputHandler.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
*****************************************************************************/
/***************************************************************************
* Copyright (C) 2010-2014 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef _PFITOUTPUTHANDLER_H_
#define _PFITOUTPUTHANDLER_H_
#include <QObject>
#include <QProcess>
#include <QDialog>
#include <QVBoxLayout>
#include <QTextEdit>
#include <QPushButton>
#include <QMessageBox>
#include <QVector>
#include <cstdlib>
//---------------------------------------------------------------------------------------
/**
* <p>This class is the capturing the output of musrfit and displays it in a dialog so
* the user has the chance to follow the fitting process, warnings, error messages of
* musrfit.
*/
class PFitOutputHandler : public QDialog
{
Q_OBJECT
public:
PFitOutputHandler(QString workingDirectory, QVector<QString> &cmd);
virtual ~PFitOutputHandler();
private slots:
virtual void readFromStdOut();
virtual void readFromStdErr();
virtual void quitButtonPressed();
virtual void processDone(int exitCode, QProcess::ExitStatus exitStatus);
private:
Q_PID fProcPID; ///< keeps the process PID
QProcess *fProc; ///< pointer to the musrfit process
QVBoxLayout *fVbox; ///< pointer to the dialog layout manager
QTextEdit *fOutput; ///< the captured musrfit output is written (read only) into this text edit object.
QPushButton *fQuitButton; ///< quit button, either to interrupt the fit or to close the dialog at the end of the fit.
};
#endif // _PFITOUTPUTHANDLER_H_

View File

@ -0,0 +1,298 @@
/****************************************************************************
PGetAsymmetryRunBlockDialog.cpp
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
*****************************************************************************/
/***************************************************************************
* Copyright (C) 2009-2014 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <QLineEdit>
#include <QValidator>
#include <QComboBox>
#include <QMessageBox>
#include "PHelp.h"
#include "PGetAsymmetryRunBlockDialog.h"
//----------------------------------------------------------------------------------------------------
/**
* <p>Constructor.
*
* \param helpUrl help url for the asymmetry run block
*/
PGetAsymmetryRunBlockDialog::PGetAsymmetryRunBlockDialog(const QString helpUrl) : fHelpUrl(helpUrl)
{
setupUi(this);
setModal(true);
fForwardHistoNo_lineEdit->setValidator( new QIntValidator(fForwardHistoNo_lineEdit) );
fBackwardHistoNo_lineEdit->setValidator( new QIntValidator(fBackwardHistoNo_lineEdit) );
fDataForwardStart_lineEdit->setValidator( new QIntValidator(fDataForwardStart_lineEdit) );
fDataForwardEnd_lineEdit->setValidator( new QIntValidator(fDataForwardEnd_lineEdit) );
fDataBackwardStart_lineEdit->setValidator( new QIntValidator(fDataBackwardStart_lineEdit) );
fDataBackwardEnd_lineEdit->setValidator( new QIntValidator(fDataBackwardEnd_lineEdit) );
fBackgroundForwardStart_lineEdit->setValidator( new QIntValidator(fBackgroundForwardStart_lineEdit) );
fBackgroundForwardEnd_lineEdit->setValidator( new QIntValidator(fBackgroundForwardEnd_lineEdit) );
fBackgroundBackwardStart_lineEdit->setValidator( new QIntValidator(fBackgroundBackwardStart_lineEdit) );
fBackgroundBackwardEnd_lineEdit->setValidator( new QIntValidator(fBackgroundBackwardEnd_lineEdit) );
fBackgroundForwardFix_lineEdit->setValidator( new QDoubleValidator(fBackgroundForwardFix_lineEdit) );
fBackgroundBackwardFix_lineEdit->setValidator( new QDoubleValidator(fBackgroundBackwardFix_lineEdit) );
fFitRangeStart_lineEdit->setValidator( new QDoubleValidator(fFitRangeStart_lineEdit) );
fFitRangeEnd_lineEdit->setValidator( new QDoubleValidator(fFitRangeEnd_lineEdit) );
fPacking_lineEdit->setValidator( new QIntValidator(fPacking_lineEdit) );
fAlpha_lineEdit->setValidator( new QIntValidator(fAlpha_lineEdit) );
fBeta_lineEdit->setValidator( new QIntValidator(fBeta_lineEdit) );
fT0Forward_lineEdit->setValidator( new QIntValidator(fT0Forward_lineEdit) );
fT0Backward_lineEdit->setValidator( new QIntValidator(fT0Backward_lineEdit) );
}
//----------------------------------------------------------------------------------------------------
/**
* <p>returns the run information line of the asymmetry run block.
*/
QString PGetAsymmetryRunBlockDialog::getRunHeaderInfo()
{
QString str;
str = "RUN " + fRunFileName_lineEdit->text() + " ";
str += fBeamline_lineEdit->text().toUpper() + " ";
str += fInstitute_comboBox->currentText() + " ";
str += fFileFormat_comboBox->currentText() + " (name beamline institute data-file-format)\n";
return str;
}
//----------------------------------------------------------------------------------------------------
/**
* <p>returns the alpha parameter for the asymmetry run block.
*
* \param present flag indicating if the alpha parameter is used, or a default alpha==1 is going to be used.
*/
QString PGetAsymmetryRunBlockDialog::getAlphaParameter(bool &present)
{
QString str = "alpha " + fAlpha_lineEdit->text() + "\n";
if (str.isEmpty())
present = false;
else
present = true;
return str;
}
//----------------------------------------------------------------------------------------------------
/**
* <p>returns the beta parameter for the asymmetry run block
*
* \param present flag indicating if the beta parameter is used, or a default beta==1 is going to be used.
*/
QString PGetAsymmetryRunBlockDialog::getBetaParameter(bool &present)
{
QString str = "beta " + fBeta_lineEdit->text() + "\n";
if (str.isEmpty())
present = false;
else
present = true;
return str;
}
//----------------------------------------------------------------------------------------------------
/**
* <p>returns the map for the asymmetry run block.
*
* \param valid flag indicating if the map is potentially valid.
*/
QString PGetAsymmetryRunBlockDialog::getMap(bool &valid)
{
QString str = fMap_lineEdit->text().trimmed().remove(" ");
// check if potentially proper map line
for (int i=0; i<str.length(); i++) {
if (!str[i].isDigit()) {
valid = false;
break;
}
}
str = "map " + fMap_lineEdit->text() + "\n";
return str;
}
//----------------------------------------------------------------------------------------------------
/**
* <p>returns the background information for the asymmetry run block.
*
* \param valid flag indicating if a valid background (either backgr.fix or background is given, but not both)
* is present.
*/
QString PGetAsymmetryRunBlockDialog::getBackground(bool &valid)
{
QString str = "";
valid = true;
// check that either backgr.fix or background is given, but not both
if (fBackgroundForwardStart_lineEdit->text().isEmpty() && fBackgroundForwardEnd_lineEdit->text().isEmpty() &&
fBackgroundBackwardStart_lineEdit->text().isEmpty() && fBackgroundBackwardEnd_lineEdit->text().isEmpty() &&
fBackgroundForwardFix_lineEdit->text().isEmpty() && fBackgroundBackwardFix_lineEdit->text().isEmpty()) {
valid = false;
str = "background 0 10 0 10\n";
} else {
if (!fBackgroundForwardStart_lineEdit->text().isEmpty()) { // assume the rest is given, not fool prove but ...
str = "background ";
str += fBackgroundForwardStart_lineEdit->text() + " ";
str += fBackgroundForwardEnd_lineEdit->text() + " ";
str += fBackgroundBackwardStart_lineEdit->text() + " ";
str += fBackgroundBackwardEnd_lineEdit->text() + "\n";
}
if (!fBackgroundForwardFix_lineEdit->text().isEmpty()) { // assume the rest is given, not fool prove but ...
str = "backgr.fix ";
str += fBackgroundForwardFix_lineEdit->text() + " ";
str += fBackgroundBackwardFix_lineEdit->text() + "\n";
}
}
return str;
}
//----------------------------------------------------------------------------------------------------
/**
* <p>returns a data range (in bins) entry for the asymmetry run block.
*
* \param valid flag indicating if the data entries are valid.
*/
QString PGetAsymmetryRunBlockDialog::getData(bool &valid)
{
QString str = "";
if (fDataForwardStart_lineEdit->text().isEmpty() || fDataForwardEnd_lineEdit->text().isEmpty() ||
fDataBackwardStart_lineEdit->text().isEmpty() || fDataBackwardEnd_lineEdit->text().isEmpty()) {
valid = false;
} else {
str = "data ";
str += fDataForwardStart_lineEdit->text() + " ";
str += fDataForwardEnd_lineEdit->text() + " ";
str += fDataBackwardStart_lineEdit->text() + " ";
str += fDataBackwardEnd_lineEdit->text() + "\n";
valid = true;
}
return str;
}
//----------------------------------------------------------------------------------------------------
/**
* <p>returns a t0 parameter for the asymmetry run block.
*
* \param present flag indicating if a t0 parameter is set.
*/
QString PGetAsymmetryRunBlockDialog::getT0(bool &present)
{
QString str = "";
if (!fT0Forward_lineEdit->text().isEmpty() && !fT0Forward_lineEdit->text().isEmpty()) {
str = "t0 ";
str += fT0Forward_lineEdit->text() + " ";
str += fT0Backward_lineEdit->text() + "\n";
present = true;
} else {
present = false;
}
return str;
}
//----------------------------------------------------------------------------------------------------
/**
* <p>returns a fit range entry for the asymmetry run block. If no fit range has been provided,
* a fit range [0,10] will be set and the valid flag will be set to false.
*
* \param valid flag indicating if a fit range was provided.
*/
QString PGetAsymmetryRunBlockDialog::getFitRange(bool &valid)
{
QString str = "";
if (fFitRangeStart_lineEdit->text().isEmpty() || fFitRangeEnd_lineEdit->text().isEmpty()) {
str += "fit 0.0 10.0\n";
valid = false;
} else {
str += "fit ";
str += fFitRangeStart_lineEdit->text() + " ";
str += fFitRangeEnd_lineEdit->text() + "\n";
valid = true;
}
return str;
}
//----------------------------------------------------------------------------------------------------
/**
* <p>returns the packing/binning of the asymmetry run block. If no packing has been provided,
* a packing of '1' will be set and the present flag will be set to false.
*
* \param present flag indicating if a packing parameter was provided.
*/
QString PGetAsymmetryRunBlockDialog::getPacking(bool &present)
{
QString str = "";
if (fPacking_lineEdit->text().isEmpty()) {
present = false;
str += "packing 1\n";
} else {
present = true;
str += "packing " + fPacking_lineEdit->text() + "\n\n";
}
return str;
}
//----------------------------------------------------------------------------------------------------
/**
* <p>Generates a help content window showing the description of the asymmetry run block.
*/
void PGetAsymmetryRunBlockDialog::helpContent()
{
if (fHelpUrl.isEmpty()) {
QMessageBox::information(this, "**INFO**", "Will eventually show a help window");
} else {
#ifdef _WIN32GCC
QMessageBox::information(this, "**INFO**", "If a newer Qt version was available, a help window would be shown!");
#else
PHelp *help = new PHelp(fHelpUrl);
help->show();
#endif // _WIN32GCC
}
}
//----------------------------------------------------------------------------------------------------
// END
//----------------------------------------------------------------------------------------------------

View File

@ -0,0 +1,65 @@
/****************************************************************************
PGetAsymmetryRunBlockDialog.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
*****************************************************************************/
/***************************************************************************
* Copyright (C) 2009-2014 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef _PGETASYMMETRYRUNBLOCKDIALOG_H_
#define _PGETASYMMETRYRUNBLOCKDIALOG_H_
#include "ui_PGetAsymmetryRunBlockDialog.h"
//---------------------------------------------------------------------------
/**
* <p>Class handling the content of the menu: Edit/Add Block/Asymmetry Run Block.
*/
class PGetAsymmetryRunBlockDialog : public QDialog, private Ui::PGetAsymmetryRunBlockDialog
{
Q_OBJECT
public:
PGetAsymmetryRunBlockDialog(const QString helpUrl);
QString getRunHeaderInfo();
QString getAlphaParameter(bool &present);
QString getBetaParameter(bool &present);
QString getMap(bool &valid);
QString getForward() { return QString("forward " + fForwardHistoNo_lineEdit->text() + "\n"); }
QString getBackward() { return QString("backward " + fBackwardHistoNo_lineEdit->text() + "\n"); }
QString getBackground(bool &valid);
QString getData(bool &valid);
QString getT0(bool &present);
QString getFitRange(bool &valid);
QString getPacking(bool &present);
private slots:
void helpContent();
private:
QString fHelpUrl; ///< help url for the asymmetry run block
};
#endif // _PGETASYMMETRYRUNBLOCKDIALOG_H_

View File

@ -0,0 +1,118 @@
/****************************************************************************
PGetDefaultDialog.cpp
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
*****************************************************************************/
/***************************************************************************
* Copyright (C) 2009-2014 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <QObject>
#include <QComboBox>
#include <QMessageBox>
#include "PHelp.h"
#include "PGetDefaultDialog.h"
#define INSTITUTE_PSI 0
#define INSTITUTE_RAL 1
#define INSTITUTE_TRIUMF 2
#define INSTITUTE_JPARC 3
#define FILE_FORMAT_NEXUS 0
#define FILE_FORMAT_ROOT_NPP 1
#define FILE_FORMAT_ROOT_PPC 2
#define FILE_FORMAT_PSIBIN 3
#define FILE_FORMAT_MUD 4
#define FILE_FORMAT_WKM 5
#define FILE_FORMAT_ASCII 6
#define FILE_FORMAT_DB 7
//---------------------------------------------------------------------------
/**
* <p>Constructor
*
* \param helpUrl help url for the default dialog
*/
PGetDefaultDialog::PGetDefaultDialog(const QString helpUrl) : fHelpUrl(helpUrl)
{
setupUi(this);
setModal(true);
}
//---------------------------------------------------------------------------
/**
* <p>Finds the name of the institute in the combo box and selects it.
*
* \param str name of the institute
*/
void PGetDefaultDialog::setInstitute(const QString &str) {
for (int i=0; i<fInstitute_comboBox->count(); i++) {
if (fInstitute_comboBox->itemText(i).toLower() == str.toLower()) {
fInstitute_comboBox->setCurrentIndex(i);
break;
}
}
}
//---------------------------------------------------------------------------
/**
* <p>Finds the file format in the combo box and selects it.
*
* \param str file format
*/
void PGetDefaultDialog::setFileFormat(const QString &str)
{
for (int i=0; i<fFileFormat_comboBox->count(); i++) {
if (fFileFormat_comboBox->itemText(i).toLower() == str.toLower()) {
fFileFormat_comboBox->setCurrentIndex(i);
break;
}
}
}
//---------------------------------------------------------------------------
/**
* <p>Generates a help content window showing the description fitting the default dialog.
*/
void PGetDefaultDialog::helpContent()
{
#ifdef _WIN32GCC
QMessageBox::information(this, "**INFO**", "If a newer Qt version was available, a help window would be shown!");
#else
PHelp *help = new PHelp(fHelpUrl);
help->show();
#endif // _WIN32GCC
}
//---------------------------------------------------------------------------
// END
//---------------------------------------------------------------------------

View File

@ -0,0 +1,69 @@
/****************************************************************************
PGetDefaultDialog.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
*****************************************************************************/
/***************************************************************************
* Copyright (C) 2010-2014 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef _PGETDEFAULTDIALOG_H_
#define _PGETDEFAULTDIALOG_H_
#include <QString>
#include <QWidget>
#include <QLineEdit>
#include <QComboBox>
#include "ui_PGetDefaultDialog.h"
//---------------------------------------------------------------------------
/**
* <p>Handels the default dialog which is used to generate a default asymmetry or
* single histogram msr input file.
*/
class PGetDefaultDialog : public QDialog, private Ui::PGetDefaultDialog
{
Q_OBJECT
public:
PGetDefaultDialog(const QString helpUrl = "");
virtual ~PGetDefaultDialog() {}
virtual const QString getRunFileName() const { return fRunFileName_lineEdit->text(); }
virtual const QString getBeamline() const { return fBeamline_lineEdit->text(); }
virtual const QString getInstitute() const { return fInstitute_comboBox->currentText(); }
virtual const QString getFileFormat() const { return fFileFormat_comboBox->currentText(); }
virtual void setBeamline(const QString &str) { fBeamline_lineEdit->setText(str); }
virtual void setInstitute(const QString &str);
virtual void setFileFormat(const QString &str);
protected slots:
virtual void helpContent();
private:
QString fHelpUrl; ///< help url for the default dialog
};
#endif // _PGETDEFAULTDIALOG_H_

View File

@ -0,0 +1,146 @@
/****************************************************************************
PGetFourierBlockDialog.cpp
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
*****************************************************************************/
/***************************************************************************
* Copyright (C) 2009-2014 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <QObject>
#include <QComboBox>
#include <QValidator>
#include <QLineEdit>
#include <QPushButton>
#include <QMessageBox>
#include "PHelp.h"
#include "PGetFourierBlockDialog.h"
//----------------------------------------------------------------------------------------------------
/**
* <p>Constructor
*
* \param helpUrl help url address for the Fourier block.
*/
PGetFourierBlockDialog::PGetFourierBlockDialog(const QString helpUrl) : fHelpUrl(helpUrl)
{
setupUi(this);
setModal(true);
fFourierBlock = "";
fFourierPower_lineEdit->setValidator( new QIntValidator(fFourierPower_lineEdit) );
fPhaseCorrectionRangeLow_lineEdit->setValidator( new QDoubleValidator(fPhaseCorrectionRangeLow_lineEdit) );
fPhaseCorrectionRangeUp_lineEdit->setValidator( new QDoubleValidator(fPhaseCorrectionRangeUp_lineEdit) );
fRangeLow_lineEdit->setValidator( new QDoubleValidator(fRangeLow_lineEdit) );
fRangeUp_lineEdit->setValidator( new QDoubleValidator(fRangeUp_lineEdit) );
connect( fPhase_lineEdit, SIGNAL( lostFocus() ), this, SLOT( checkPhaseParameter() ) );
}
//----------------------------------------------------------------------------------------------------
/**
* <p>Checks if the phase parameter is either a number are has the form parXX, where XX is a number.
*/
void PGetFourierBlockDialog::checkPhaseParameter()
{
QString str = fPhase_lineEdit->text();
if (str.isEmpty())
return;
bool ok;
int ival;
ival = str.toInt(&ok);
if (!ok) { // i.e. the phase entry is not a number. Check for parXX
str.trimmed();
if (str.startsWith("par")) { //
str.remove("par");
ival = str.toInt(&ok);
if (!ok) {
fPhase_lineEdit->clear();
QMessageBox::critical(this, "**ERROR**",
"Allowed phase entries are either a parameter number,\n or an parXX entry, where XX is a parameter number",
QMessageBox::Ok, QMessageBox::NoButton);
fPhase_lineEdit->setFocus();
}
} else { // neither a parXX nor a number
fPhase_lineEdit->clear();
QMessageBox::critical(this, "**ERROR**",
"Allowed phase entries are either a parameter number,\n or an parXX entry, where XX is a parameter number",
QMessageBox::Ok, QMessageBox::NoButton);
fPhase_lineEdit->setFocus();
}
}
}
//----------------------------------------------------------------------------------------------------
/**
* <p>Transfers the data of the dialog into a valid msr-file Fourier block string.
*/
void PGetFourierBlockDialog::fillFourierBlock()
{
fFourierBlock = "###############################################################\n";
fFourierBlock += "FOURIER\n";
fFourierBlock += "units " + fUnits_comboBox->currentText() + "\n";
QString str = fFourierPower_lineEdit->text();
if (!str.isEmpty())
fFourierBlock += "fourier_power " + str + "\n";
fFourierBlock += "apodization " + fApodization_comboBox->currentText() + "\n";
fFourierBlock += "plot " + fPlot_comboBox->currentText() + "\n";
str = fPhase_lineEdit->text();
if (!str.isEmpty())
fFourierBlock += "phase " + str + "\n";
if (!fPhaseCorrectionRangeLow_lineEdit->text().isEmpty() && !fPhaseCorrectionRangeUp_lineEdit->text().isEmpty()) {
fFourierBlock += "range_for_phase_correction " + fPhaseCorrectionRangeLow_lineEdit->text() + " " +
fPhaseCorrectionRangeUp_lineEdit->text() + "\n";
}
if (!fRangeLow_lineEdit->text().isEmpty() && !fRangeUp_lineEdit->text().isEmpty()) {
fFourierBlock += "range " + fRangeLow_lineEdit->text() + " " + fRangeUp_lineEdit->text() + "\n";
}
}
//----------------------------------------------------------------------------------------------------
/**
* <p>Generates a help content window showing the description of the Fourier block.
*/
void PGetFourierBlockDialog::helpContent()
{
if (fHelpUrl.isEmpty()) {
QMessageBox::information(this, "**INFO**", "Will eventually show a help window");
} else {
#ifdef _WIN32GCC
QMessageBox::information(this, "**INFO**", "If a newer Qt version was available, a help window would be shown!");
#else
PHelp *help = new PHelp(fHelpUrl);
help->show();
#endif // _WIN32GCC
}
}
//----------------------------------------------------------------------------------------------------
// END
//----------------------------------------------------------------------------------------------------

View File

@ -0,0 +1,60 @@
/****************************************************************************
PGetFourierBlockDialog.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
*****************************************************************************/
/***************************************************************************
* Copyright (C) 2009-2014 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef _PGETFOURIERBLOCKDIALOG_H_
#define _PGETFOURIERBLOCKDIALOG_H_
#include <QString>
#include "ui_PGetFourierBlockDialog.h"
//-------------------------------------------------------------------------------
/**
* <p>Handles the Fourier dialog.
*/
class PGetFourierBlockDialog : public QDialog, private Ui::PGetFourierBlockDialog
{
Q_OBJECT
public:
PGetFourierBlockDialog(const QString helpUrl);
QString getFourierBlock() { return fFourierBlock; }
private slots:
void checkPhaseParameter();
void fillFourierBlock();
void helpContent();
private:
QString fFourierBlock; ///< keeps the msr Fourier block
QString fHelpUrl; ///< help url for the Fourier block
};
#endif // _PGETFOURIERBLOCKDIALOG_H_

View File

@ -0,0 +1,122 @@
/****************************************************************************
PGetFunctionsBlockDialog.cpp
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
*****************************************************************************/
/***************************************************************************
* Copyright (C) 2009-2014 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <QTextEdit>
#include <QLineEdit>
#include <QMessageBox>
#include <QRegExp>
#include <QEvent>
#include <QtDebug>
#include "PHelp.h"
#include "PGetFunctionsBlockDialog.h"
//----------------------------------------------------------------------------------------------------
/**
* <p>Constructor.
*
* \param helpUrl help url for the FUNCTIONS block.
*/
PGetFunctionsBlockDialog::PGetFunctionsBlockDialog(const QString helpUrl) : fHelpUrl(helpUrl)
{
setupUi(this);
setModal(true);
fFunctionInput_lineEdit->setFocus();
}
//----------------------------------------------------------------------------------------------------
/**
* <p>Adds a function to the FUNCTIONS block text edit after carrying out some primitve tests about
* the consistency of the function (far from being a syntax/semantic checker!!).
*/
void PGetFunctionsBlockDialog::addFunction()
{
QString str = fFunctionInput_lineEdit->text();
if (str.isEmpty())
return;
// validation
// check that the function string starts with 'fun'
if (!str.trimmed().startsWith("fun")) {
QMessageBox::critical(this, "addFunction",
"a function has to start with 'funX' (X a number).\nNeeds to be fixed.",
QMessageBox::Ok, QMessageBox::NoButton);
return;
}
// check if function string contains 'funX ='
if (str.indexOf( QRegExp("fun\\d+\\s*=") ) == -1) {
QMessageBox::critical(this, "addFunction",
"a function has to start with 'funX =' (X a positive number).\nNeeds to be fixed.",
QMessageBox::Ok, QMessageBox::NoButton);
return;
}
// check if function string contains more than one 'funX'
if (str.trimmed().lastIndexOf("fun", -1, Qt::CaseInsensitive) > 0) {
QMessageBox::critical(this, "addFunction",
"a function cannot contain more than one function,\ni.e. fun2 = fun1 + par1 is not OK.",
QMessageBox::Ok, QMessageBox::NoButton);
return;
}
// add to Functions block
fFunctionBlock_plainTextEdit->appendPlainText(str);
// clear functions input text
fFunctionInput_lineEdit->clear();
}
//----------------------------------------------------------------------------------------------------
/**
* <p>Generates a help content window showing the description of the FUNCTIONS block.
*/
void PGetFunctionsBlockDialog::helpContent()
{
if (fHelpUrl.isEmpty()) {
QMessageBox::information(this, "**INFO**", "Will eventually show a help window");
} else {
#ifdef _WIN32GCC
QMessageBox::information(this, "**INFO**", "If a newer Qt version was available, a help window would be shown!");
#else
PHelp *help = new PHelp(fHelpUrl);
help->show();
#endif // _WIN32GCC
}
}
//----------------------------------------------------------------------------------------------------
// END
//----------------------------------------------------------------------------------------------------

View File

@ -0,0 +1,56 @@
/****************************************************************************
PGetFunctionsBlockDialog.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
*****************************************************************************/
/***************************************************************************
* Copyright (C) 2009-2014 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef _PGETFUNCTIONSBLOCKDIALOG_H_
#define _PGETFUNCTIONSBLOCKDIALOG_H_
#include "ui_PGetFunctionsBlockDialog.h"
//-----------------------------------------------------------------------------------
/**
* <p>Handles the content of the FUNCTIONS block dialog.
*/
class PGetFunctionsBlockDialog : public QDialog, private Ui::PGetFunctionsBlockDialog
{
Q_OBJECT
public:
PGetFunctionsBlockDialog(const QString helpUrl = "");
QString getFunctionsBlock() { return fFunctionBlock_plainTextEdit->toPlainText(); }
private slots:
void addFunction();
void helpContent();
private:
QString fHelpUrl; ///< help url address for the FUNCTIONS block.
};
#endif // _PGETFUNCTIONSBLOCKDIALOG_H_

View File

@ -0,0 +1,596 @@
/****************************************************************************
PGetMusrFTOptionsDialog.cpp
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
*****************************************************************************/
/***************************************************************************
* Copyright (C) 2009-2015 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <QLineEdit>
#include <QValidator>
#include <QComboBox>
#include <QMessageBox>
#include "PHelp.h"
#include "PGetMusrFTOptionsDialog.h"
#define MUSRFT_OPT_UNDEF 0
#define MUSRFT_OPT_REAL 1
#define MUSRFT_OPT_IMAG 2
#define MUSRFT_OPT_REAL_AND_IMAG 3
#define MUSRFT_OPT_POWER 4
#define MUSRFT_OPT_PHASE 5
#define MUSRFT_APOD_UNDEF 0
#define MUSRFT_APOD_WEAK 1
#define MUSRFT_APOD_MEDIUM 2
#define MUSRFT_APOD_STRONG 3
#define MUSRFT_UNIT_UNDEF 0
#define MUSRFT_UNIT_GAUSS 1
#define MUSRFT_UNIT_TESLA 2
#define MUSRFT_UNIT_FREQ 3
#define MUSRFT_UNIT_CYCLE 4
//----------------------------------------------------------------------------------------------------
/**
* <p>Constructor.
*
* \param currentMsrFile path-file name of the currently active msr-file in musredit
* \param prevCmd list of the last (potential) previously call.
* \param helpUrl help url for the asymmetry run block
*/
PGetMusrFTOptionsDialog::PGetMusrFTOptionsDialog(QString currentMsrFile, QStringList &prevCmd, const QString helpUrl) :
fCurrentMsrFileName(currentMsrFile), fHelpUrl(helpUrl)
{
setupUi(this);
setModal(true);
fBkgRangeStartBin_lineEdit->setValidator( new QIntValidator(fBkgRangeStartBin_lineEdit) );
fBkgRangeEndBin_lineEdit->setValidator( new QIntValidator(fBkgRangeEndBin_lineEdit) );
fPacking_lineEdit->setValidator( new QIntValidator(fPacking_lineEdit) );
fTimeRangeStart_lineEdit->setValidator( new QDoubleValidator(fTimeRangeStart_lineEdit) );
fTimeRangeEnd_lineEdit->setValidator( new QDoubleValidator(fTimeRangeEnd_lineEdit) );
fFourierPower_lineEdit->setValidator( new QIntValidator(fFourierPower_lineEdit) );
fLifetimeCorrection_lineEdit->setValidator( new QDoubleValidator(fLifetimeCorrection_lineEdit) );
fFourierRangeStart_lineEdit->setValidator( new QDoubleValidator(fFourierRangeStart_lineEdit) );
fFourierRangeEnd_lineEdit->setValidator( new QDoubleValidator(fFourierRangeEnd_lineEdit) );
fPacking_lineEdit->setText("1");
// populate dialog with the previous cmd call
bool msrTag = true;
QString str, str1, line;
int idx;
for (int i=0; i<prevCmd.size(); i++) {
// collect msr-file-names
if (msrTag) {
line = "";
while (prevCmd[i].contains(".msr") && (i<prevCmd.size())) {
// split msr-file path-name into path and name
str = prevCmd[i];
idx = str.lastIndexOf("/");
str1 = str;
str.remove(idx, str.length()-idx);
fMsrFilePaths << str;
str1.remove(0, idx+1);
fMsrFileNames << str1;
line += str1 + " ";
i++;
}
line.remove(line.length()-1, 1);
fMsrFileSelector_lineEdit->setText(line);
msrTag = false;
}
// collect data-file-names
if (prevCmd[i] == "-df") {
i++;
line = "";
while (!prevCmd[i].startsWith("-") && (i<prevCmd.size())) {
// split msr-file path-name into path and name
str = prevCmd[i];
idx = str.lastIndexOf("/");
str1 = str;
str.remove(idx, str.length()-idx);
fDataFilePaths << str;
str1.remove(0, idx+1);
fDataFileNames << str1;
line += str1 + " ";
i++;
}
line.remove(line.length()-1, 1);
fDataFileSelector_lineEdit->setText(line);
}
// background-range
if (prevCmd[i] == "-br") {
fBkgRangeStartBin_lineEdit->setText(prevCmd[++i]);
fBkgRangeEndBin_lineEdit->setText(prevCmd[++i]);
}
// fourier-option
if (prevCmd[i] == "-fo") {
if (prevCmd[i+1] == "real")
fFourierOption_comboBox->setCurrentIndex(MUSRFT_OPT_REAL);
else if (prevCmd[i+1] == "imag")
fFourierOption_comboBox->setCurrentIndex(MUSRFT_OPT_IMAG);
else if (prevCmd[i+1] == "real+imag")
fFourierOption_comboBox->setCurrentIndex(MUSRFT_OPT_REAL_AND_IMAG);
else if (prevCmd[i+1] == "power")
fFourierOption_comboBox->setCurrentIndex(MUSRFT_OPT_POWER);
else if (prevCmd[i+1] == "phase")
fFourierOption_comboBox->setCurrentIndex(MUSRFT_OPT_PHASE);
else
fFourierOption_comboBox->setCurrentIndex(MUSRFT_OPT_UNDEF);
i++;
}
// apodization
if (prevCmd[i] == "-ap") {
if (prevCmd[i+1] == "weak")
fApodization_comboBox->setCurrentIndex(MUSRFT_APOD_WEAK);
else if (prevCmd[i+1] == "medium")
fApodization_comboBox->setCurrentIndex(MUSRFT_APOD_MEDIUM);
else if (prevCmd[i+1] == "strong")
fApodization_comboBox->setCurrentIndex(MUSRFT_APOD_STRONG);
else
fApodization_comboBox->setCurrentIndex(MUSRFT_APOD_UNDEF);
i++;
}
// fourier-power
if (prevCmd[i] == "-fp") {
fFourierPower_lineEdit->setText(prevCmd[++i]);
}
// units
if (prevCmd[i] == "-u") {
if (prevCmd[i+1] == "Gauss")
fFourierUnits_comboBox->setCurrentIndex(MUSRFT_UNIT_GAUSS);
else if (prevCmd[i+1] == "Tesla")
fFourierUnits_comboBox->setCurrentIndex(MUSRFT_UNIT_TESLA);
else if (prevCmd[i+1] == "MHz")
fFourierUnits_comboBox->setCurrentIndex(MUSRFT_UNIT_FREQ);
else if (prevCmd[i+1] == "Mc/s")
fFourierUnits_comboBox->setCurrentIndex(MUSRFT_UNIT_CYCLE);
else
fFourierUnits_comboBox->setCurrentIndex(MUSRFT_UNIT_UNDEF);
i++;
}
// phase
if (prevCmd[i] == "-ph") {
// NOT YET IMPLEMENTED
}
// fourier-range
if (prevCmd[i] == "-fr") {
fFourierRangeStart_lineEdit->setText(prevCmd[++i]);
fFourierRangeEnd_lineEdit->setText(prevCmd[++i]);
}
// time-range
if (prevCmd[i] == "-tr") {
fTimeRangeStart_lineEdit->setText(prevCmd[++i]);
fTimeRangeEnd_lineEdit->setText(prevCmd[++i]);
}
// histo list
if (prevCmd[i] == "--histo") {
i++;
line = "";
while (!prevCmd[i].startsWith("-") && (i<prevCmd.size())) {
line += prevCmd[i++] + " ";
}
line.remove(line.length()-1, 1);
fHistoList_lineEdit->setText(line);
}
// average ALL tag
if (prevCmd[i] == "-a") {
fAveragedView_checkBox->setCheckState(Qt::Checked);
}
// average per data set tag
if (prevCmd[i] == "-ad") {
fAveragePerDataSet_checkBox->setCheckState(Qt::Checked);
}
// t0 list
if (prevCmd[i] == "--t0") {
i++;
line = "";
while (!prevCmd[i].startsWith("-") && (i<prevCmd.size())) {
line += prevCmd[i++] + " ";
}
line.remove(line.length()-1, 1);
fT0_lineEdit->setText(line);
}
// packing
if (prevCmd[i] == "-pa") {
fPacking_lineEdit->setText(prevCmd[++i]);
}
// title
if (prevCmd[i] == "--title") {
fFourierTitle_lineEdit->setText(prevCmd[i+1]);
}
// create msr-file tag
if (prevCmd[i] == "--create-msr-file") {
fCreateMsrFileName = prevCmd[++i];
fCreateMsrFile_checkBox->setCheckState(Qt::Checked);
}
// lifetime correction
if (prevCmd[i] == "-lc") {
fLifetimeCorrection_lineEdit->setText(prevCmd[++i]);
}
}
// connect all necessary single and slots
connect(fCurrentMsrFile_checkBox, SIGNAL( stateChanged(int) ), this, SLOT( currentMsrFileTagChanged(int) ) );
connect(fAllMsrFiles_checkBox, SIGNAL( stateChanged(int) ), this, SLOT( allMsrFileTagChanged(int) ) );
connect(fMsrFileSelector_pushButton, SIGNAL( clicked() ), this, SLOT( selectMsrFileNames() ) );
connect(fDataFileSelector_pushButton, SIGNAL( clicked() ), this, SLOT( selectDataFileNames() ) );
connect(fCreateMsrFile_checkBox, SIGNAL( stateChanged(int) ), this, SLOT( createMsrFileChanged(int) ) );
connect(fMsrFileNameClear_pushButton, SIGNAL (clicked() ), this, SLOT( clearMsrFileNames() ) );
connect(fDataFileNameClear_pushButton, SIGNAL (clicked() ), this, SLOT( clearDataFileNames() ) );
connect(fResetAll_pushButton, SIGNAL( clicked() ), this, SLOT( resetAll() ) );
connect(fAveragedView_checkBox, SIGNAL ( stateChanged(int) ), this, SLOT( averagedAll(int) ) );
connect(fAveragePerDataSet_checkBox, SIGNAL ( stateChanged(int) ), this, SLOT( averagedPerDataSet(int) ) );
}
//----------------------------------------------------------------------------------------------------
/**
* <p>returns the musrFT command line options.
*/
QStringList PGetMusrFTOptionsDialog::getMusrFTOptions()
{
QStringList cmd;
QString str("");
QStringList strList;
// check if currently active msr-file shall be used
if (fCurrentMsrFile_checkBox->checkState() == Qt::Checked) {
cmd << fCurrentMsrFileName;
} else {
// msr-files
for (int i=0; i<fMsrFilePaths.size(); i++) {
str = fMsrFilePaths[i]+"/"+fMsrFileNames[i];
cmd << str;
}
// data-files
if (fDataFilePaths.size() > 0) {
cmd << "-df";
for (int i=0; i<fDataFilePaths.size(); i++) {
str = fDataFilePaths[i]+"/"+fDataFileNames[i];
cmd << str;
}
}
}
// background range
if ((fBkgRangeStartBin_lineEdit->text().length() > 0) && (fBkgRangeEndBin_lineEdit->text().length() > 0)) {
cmd << "-br";
cmd << fBkgRangeStartBin_lineEdit->text();
cmd << fBkgRangeEndBin_lineEdit->text();
}
// background values
if (fBkgList_lineEdit->text().length() > 0) {
}
// fourier-option
if (fFourierOption_comboBox->currentText() != "UnDef") {
cmd << "-fo";
cmd << fFourierOption_comboBox->currentText();
}
// apodization
cmd << "-ap";
cmd << fApodization_comboBox->currentText();
// fourier-power
if (fFourierPower_lineEdit->text().length() > 0) {
cmd << "-fp";
cmd << fFourierPower_lineEdit->text();
}
// units
if (fFourierUnits_comboBox->currentText() != "UnDef") {
cmd << "-u";
cmd << fFourierUnits_comboBox->currentText();
}
// phase
// fourier-range
if ((fFourierRangeStart_lineEdit->text().length() > 0) && (fFourierRangeEnd_lineEdit->text().length() > 0)) {
cmd << "-fr";
cmd << fFourierRangeStart_lineEdit->text();
cmd << fFourierRangeEnd_lineEdit->text();
}
// time-range
if ((fTimeRangeStart_lineEdit->text().length() > 0) && (fTimeRangeEnd_lineEdit->text().length() > 0)) {
cmd << "-tr";
cmd << fTimeRangeStart_lineEdit->text();
cmd << fTimeRangeEnd_lineEdit->text();
}
// histo list
if (fHistoList_lineEdit->text().length() > 0) {
cmd << "--histo";
strList = fHistoList_lineEdit->text().split(" ", QString::SkipEmptyParts);
for (int i=0; i<strList.size(); i++)
cmd << strList[i];
}
// averaged view ALL
if (fAveragedView_checkBox->checkState() == Qt::Checked)
cmd << "-a";
// averaged view per data set
if (fAveragePerDataSet_checkBox->checkState() == Qt::Checked)
cmd << "-ad";
// t0 list
if (fT0_lineEdit->text().length() > 0) {
cmd << "--t0";
strList = fT0_lineEdit->text().split(" ", QString::SkipEmptyParts);
for (int i=0; i<strList.size(); i++)
cmd << strList[i];
}
// packing
if (fPacking_lineEdit->text().length() > 0) {
cmd << "-pa";
cmd << fPacking_lineEdit->text();
}
// title
if (fFourierTitle_lineEdit->text().length() > 0) {
cmd << "--title";
cmd << fFourierTitle_lineEdit->text();
}
// create-msr-file
if (fCreateMsrFile_checkBox->checkState() == Qt::Checked) {
cmd << "--create-msr-file";
cmd << fCreateMsrFileName;
}
// lifetimecorrection
if (fLifetimeCorrection_lineEdit->text().length() > 0) {
cmd << "-lc";
cmd << fLifetimeCorrection_lineEdit->text();
}
return cmd;
}
//----------------------------------------------------------------------------------------------------
/**
* <p>SLOT called when fCurrentMsrFile_checkBox is checked/unchecked. If checked, it will clean up
* the msr-file path-file list and the data-file path-file list.
*/
void PGetMusrFTOptionsDialog::currentMsrFileTagChanged(int state)
{
if (state == Qt::Checked) {
fAllMsrFiles_checkBox->setCheckState(Qt::Unchecked);
// remove all msr-data-file-names and data-path-file-names
fMsrFilePaths.clear();
fMsrFileNames.clear();
fMsrFileSelector_lineEdit->setText("");
fDataFilePaths.clear();
fDataFileNames.clear();
fDataFileSelector_lineEdit->setText("");
}
}
//----------------------------------------------------------------------------------------------------
/**
* <p>SLOT called when fAllMsrFiles_checkBox is checked/unchecked. Currently it has no functionality.
*/
void PGetMusrFTOptionsDialog::allMsrFileTagChanged(int state)
{
if (state == Qt::Checked) {
fCurrentMsrFile_checkBox->setCheckState(Qt::Unchecked);
}
}
//----------------------------------------------------------------------------------------------------
/**
* <p>SLOT called when fMsrFileSelector_pushButton is clicked. Collects the msr-file path-name list.
*/
void PGetMusrFTOptionsDialog::selectMsrFileNames()
{
QStringList flns = QFileDialog::getOpenFileNames( this, tr("Open msr-File(s)"), tr( "./" ),
tr( "msr-Files (*.msr);;All Files (*)" ));
QString str(""), str1("");
int idx;
if (flns.size() > 0) {
// delete already present elements
fMsrFilePaths.clear();
fMsrFileNames.clear();
// split path-name into path and name
for (int i=0; i<flns.size(); i++) {
str = flns[i];
idx = str.lastIndexOf("/");
str1 = str;
str.remove(idx, str.length()-idx);
fMsrFilePaths << str;
str1.remove(0, idx+1);
fMsrFileNames << str1;
}
// populate fMsrFileSelector_lineEdit
str = QString("");
for (int i=0; i<fMsrFileNames.size()-1; i++) {
str += fMsrFileNames[i] + " ";
}
str += fMsrFileNames[fMsrFileNames.size()-1];
fMsrFileSelector_lineEdit->setText(str);
}
}
//----------------------------------------------------------------------------------------------------
/**
* <p>SLOT called when the fMsrFileNameClear_pushButton is clicked.
*/
void PGetMusrFTOptionsDialog::clearMsrFileNames()
{
fMsrFileSelector_lineEdit->setText("");
fMsrFilePaths.clear();
fMsrFileNames.clear();
}
//----------------------------------------------------------------------------------------------------
/**
* <p>SLOT called when fDataFileSelector_pushButton is clicked. Collects the data-file path-name list.
*/
void PGetMusrFTOptionsDialog::selectDataFileNames()
{
QStringList flns = QFileDialog::getOpenFileNames( this, tr("Open msr-File(s)"), tr( "./" ),
tr( "data-Files (*.root *.bin *.msr *.nxs *.mdu);;All Files (*)" ));
QString str(""), str1("");
int idx;
if (flns.size() > 0) {
// delete already present elements
fDataFilePaths.clear();
fDataFileNames.clear();
// split path-name into path and name
for (int i=0; i<flns.size(); i++) {
str = flns[i];
idx = str.lastIndexOf("/");
str1 = str;
str.remove(idx, str.length()-idx);
fDataFilePaths << str;
str1.remove(0, idx+1);
fDataFileNames << str1;
}
// populate fMsrFileSelector_lineEdit
str = QString("");
for (int i=0; i<fDataFileNames.size()-1; i++) {
str += fDataFileNames[i] + " ";
}
str += fDataFileNames[fDataFileNames.size()-1];
fDataFileSelector_lineEdit->setText(str);
}
}
//----------------------------------------------------------------------------------------------------
/**
* <p>SLOT called when the fDataFileNameClear_pushButton is clicked.
*/
void PGetMusrFTOptionsDialog::clearDataFileNames()
{
fDataFileSelector_lineEdit->setText("");
fDataFilePaths.clear();
fDataFileNames.clear();
}
//----------------------------------------------------------------------------------------------------
/**
* <p>SLOT called when the create-msr-file tag has changed
*/
void PGetMusrFTOptionsDialog::createMsrFileChanged(int state)
{
if (state == Qt::Checked) {
fCreateMsrFileName = QFileDialog::getSaveFileName(this, tr("Create msr-file"), "./", tr("msr-Files (*.msr);;All Files (*)"));
if (fCreateMsrFileName.length() == 0)
fCreateMsrFile_checkBox->setCheckState(Qt::Unchecked);
} else {
fCreateMsrFileName = "";
}
}
//----------------------------------------------------------------------------------------------------
/**
* <p>SLOT called when the Reset All button is pressed. Will remove all settings.
*/
void PGetMusrFTOptionsDialog::resetAll()
{
fCurrentMsrFile_checkBox->setCheckState(Qt::Unchecked);
fAllMsrFiles_checkBox->setCheckState(Qt::Unchecked);
fMsrFilePaths.clear();
fMsrFileNames.clear();
fMsrFileSelector_lineEdit->setText("");
fDataFilePaths.clear();
fDataFileNames.clear();
fDataFileSelector_lineEdit->setText("");
fBkgRangeStartBin_lineEdit->setText("");
fBkgRangeEndBin_lineEdit->setText("");
fBkgList_lineEdit->setText("");
fApodization_comboBox->setCurrentIndex(MUSRFT_APOD_UNDEF);
fPacking_lineEdit->setText("");
fTimeRangeStart_lineEdit->setText("");
fTimeRangeEnd_lineEdit->setText("");
fHistoList_lineEdit->setText("");
fT0_lineEdit->setText("");
fFourierOption_comboBox->setCurrentIndex(MUSRFT_OPT_UNDEF);
fFourierUnits_comboBox->setCurrentIndex(MUSRFT_UNIT_UNDEF);
fFourierPower_lineEdit->setText("");
fLifetimeCorrection_lineEdit->setText("");
fFourierRangeStart_lineEdit->setText("");
fFourierRangeEnd_lineEdit->setText("");
fAveragedView_checkBox->setCheckState(Qt::Unchecked);
fAveragePerDataSet_checkBox->setCheckState(Qt::Unchecked);
fCreateMsrFile_checkBox->setCheckState(Qt::Unchecked);
fFourierTitle_lineEdit->setText("");
}
//----------------------------------------------------------------------------------------------------
/**
* <p>SLOT called when averaged view for ALL data is checked.
*/
void PGetMusrFTOptionsDialog::averagedAll(int state)
{
if ((state == Qt::Checked) && fAveragePerDataSet_checkBox->isChecked())
fAveragePerDataSet_checkBox->setCheckState(Qt::Unchecked);
}
//----------------------------------------------------------------------------------------------------
/**
* <p>SLOT called when averaged view per data set is checked.
*/
void PGetMusrFTOptionsDialog::averagedPerDataSet(int state)
{
if ((state == Qt::Checked) && fAveragedView_checkBox->isChecked())
fAveragedView_checkBox->setCheckState(Qt::Unchecked);
}
//----------------------------------------------------------------------------------------------------
/**
* <p>Generates a help content window showing the description for musrFT.
*/
void PGetMusrFTOptionsDialog::helpContent()
{
if (fHelpUrl.isEmpty()) {
QMessageBox::information(this, "**INFO**", "Will eventually show a help window");
} else {
#ifdef _WIN32GCC
QMessageBox::information(this, "**INFO**", "If a newer Qt version was available, a help window would be shown!");
#else
PHelp *help = new PHelp(fHelpUrl);
help->show();
#endif // _WIN32GCC
}
}

View File

@ -0,0 +1,71 @@
/****************************************************************************
PGetMusrFTOptionsDialog.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
*****************************************************************************/
/***************************************************************************
* Copyright (C) 2010-2015 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef _PGETMUSRFTOPTIONSDIALOG_H_
#define _PGETMUSRFTOPTIONSDIALOG_H_
#include <QDialog>
#include <QStringList>
#include "ui_PGetMusrFTOptionsDialog.h"
class PGetMusrFTOptionsDialog : public QDialog, private Ui::PGetMusrFTOptionsDialog
{
Q_OBJECT
public:
PGetMusrFTOptionsDialog(QString currentMsrFile, QStringList &prevCmd, const QString helpUrl);
QStringList getMusrFTOptions();
public slots:
void helpContent();
private slots:
void currentMsrFileTagChanged(int state);
void allMsrFileTagChanged(int state);
void selectMsrFileNames();
void clearMsrFileNames();
void selectDataFileNames();
void clearDataFileNames();
void createMsrFileChanged(int state);
void resetAll();
void averagedAll(int state);
void averagedPerDataSet(int state);
private:
QStringList fMsrFilePaths; ///< list keeping all the paths from the msr-file path-name list
QStringList fMsrFileNames; ///< list keeping all the names from the msr-file path-name list
QStringList fDataFilePaths; ///< list keeping all the paths from the data-file path-name list
QStringList fDataFileNames; ///< list keeping all the names from the data-file path-name list
QString fCreateMsrFileName; ///< keeps the msr-path-file name for msr-file creation
QString fCurrentMsrFileName; ///< keeps the msr-path-file name of the currently active msr-file in musredit.
QString fHelpUrl; ///< help url for the asymmetry run block
};
#endif // _PGETMUSRFTOPTIONSDIALOG_H_

Some files were not shown because too many files have changed in this diff Show More