resolved merge conflicts with master
This commit is contained in:
@ -1664,73 +1664,68 @@ Bool_t PFitter::ExecuteSave(Bool_t firstSave)
|
||||
}
|
||||
|
||||
// handle expected chisq if applicable
|
||||
if (fUseChi2) {
|
||||
fParams = *(fRunInfo->GetMsrParamList()); // get the update parameters back
|
||||
fParams = *(fRunInfo->GetMsrParamList()); // get the update parameters back
|
||||
|
||||
// calculate expected chisq
|
||||
std::vector<Double_t> param;
|
||||
Double_t totalExpectedChisq = 0.0;
|
||||
std::vector<Double_t> expectedChisqPerHisto;
|
||||
std::vector<UInt_t> ndfPerHisto;
|
||||
// calculate expected chisq
|
||||
std::vector<Double_t> param;
|
||||
Double_t totalExpectedChisq = 0.0;
|
||||
std::vector<Double_t> expectedChisqPerHisto;
|
||||
std::vector<UInt_t> ndfPerHisto;
|
||||
|
||||
for (UInt_t i=0; i<fParams.size(); i++)
|
||||
param.push_back(fParams[i].fValue);
|
||||
for (UInt_t i=0; i<fParams.size(); i++)
|
||||
param.push_back(fParams[i].fValue);
|
||||
|
||||
if (fDKSReady)
|
||||
fFitterFcnDKS->CalcExpectedChiSquare(param, totalExpectedChisq, expectedChisqPerHisto);
|
||||
else
|
||||
fFitterFcn->CalcExpectedChiSquare(param, totalExpectedChisq, expectedChisqPerHisto);
|
||||
// CalcExpectedChiSquare handles both, chisq and mlh
|
||||
if (fDKSReady)
|
||||
fFitterFcnDKS->CalcExpectedChiSquare(param, totalExpectedChisq, expectedChisqPerHisto);
|
||||
else
|
||||
fFitterFcn->CalcExpectedChiSquare(param, totalExpectedChisq, expectedChisqPerHisto);
|
||||
|
||||
// calculate chisq per run
|
||||
std::vector<Double_t> chisqPerHisto;
|
||||
for (UInt_t i=0; i<fRunInfo->GetMsrRunList()->size(); i++) {
|
||||
// calculate chisq per run
|
||||
std::vector<Double_t> chisqPerHisto;
|
||||
for (UInt_t i=0; i<fRunInfo->GetMsrRunList()->size(); i++) {
|
||||
if (fUseChi2)
|
||||
chisqPerHisto.push_back(fRunListCollection->GetSingleRunChisq(param, i));
|
||||
}
|
||||
|
||||
if (totalExpectedChisq != 0.0) { // i.e. applicable for single histogram fits only
|
||||
// get the ndf's of the histos
|
||||
UInt_t ndf_histo;
|
||||
for (UInt_t i=0; i<expectedChisqPerHisto.size(); i++) {
|
||||
if (fDKSReady)
|
||||
ndf_histo = fFitterFcnDKS->GetNoOfFittedBins(i) - fRunInfo->GetNoOfFitParameters(i);
|
||||
else
|
||||
ndf_histo = fFitterFcn->GetNoOfFittedBins(i) - fRunInfo->GetNoOfFitParameters(i);
|
||||
ndfPerHisto.push_back(ndf_histo);
|
||||
}
|
||||
|
||||
// feed the msr-file handler
|
||||
PMsrStatisticStructure *statistics = fRunInfo->GetMsrStatistic();
|
||||
if (statistics) {
|
||||
statistics->fMinPerHisto = chisqPerHisto;
|
||||
statistics->fMinExpected = totalExpectedChisq;
|
||||
statistics->fMinExpectedPerHisto = expectedChisqPerHisto;
|
||||
statistics->fNdfPerHisto = ndfPerHisto;
|
||||
}
|
||||
} else if (chisqPerHisto.size() > 1) { // in case expected chisq is not applicable like for asymmetry fits
|
||||
UInt_t ndf_histo = 0;
|
||||
for (UInt_t i=0; i<chisqPerHisto.size(); i++) {
|
||||
if (fDKSReady)
|
||||
ndf_histo = fFitterFcnDKS->GetNoOfFittedBins(i) - fRunInfo->GetNoOfFitParameters(i);
|
||||
else
|
||||
ndf_histo = fFitterFcn->GetNoOfFittedBins(i) - fRunInfo->GetNoOfFitParameters(i);
|
||||
ndfPerHisto.push_back(ndf_histo);
|
||||
}
|
||||
|
||||
// feed the msr-file handler
|
||||
PMsrStatisticStructure *statistics = fRunInfo->GetMsrStatistic();
|
||||
if (statistics) {
|
||||
statistics->fMinPerHisto = chisqPerHisto;
|
||||
statistics->fNdfPerHisto = ndfPerHisto;
|
||||
}
|
||||
}
|
||||
|
||||
// clean up
|
||||
param.clear();
|
||||
expectedChisqPerHisto.clear();
|
||||
ndfPerHisto.clear();
|
||||
chisqPerHisto.clear();
|
||||
else
|
||||
chisqPerHisto.push_back(fRunListCollection->GetSingleRunMaximumLikelihood(param, i));
|
||||
}
|
||||
|
||||
if (totalExpectedChisq != 0.0) { // i.e. applicable for single histogram fits only
|
||||
// get the ndf's of the histos
|
||||
UInt_t ndf_histo;
|
||||
for (UInt_t i=0; i<expectedChisqPerHisto.size(); i++) {
|
||||
if (fDKSReady)
|
||||
ndf_histo = fFitterFcnDKS->GetNoOfFittedBins(i) - fRunInfo->GetNoOfFitParameters(i);
|
||||
else
|
||||
ndf_histo = fFitterFcn->GetNoOfFittedBins(i) - fRunInfo->GetNoOfFitParameters(i);
|
||||
ndfPerHisto.push_back(ndf_histo);
|
||||
}
|
||||
|
||||
// feed the msr-file handler
|
||||
PMsrStatisticStructure *statistics = fRunInfo->GetMsrStatistic();
|
||||
if (statistics) {
|
||||
statistics->fMinPerHisto = chisqPerHisto;
|
||||
statistics->fMinExpected = totalExpectedChisq;
|
||||
statistics->fMinExpectedPerHisto = expectedChisqPerHisto;
|
||||
statistics->fNdfPerHisto = ndfPerHisto;
|
||||
}
|
||||
} else if (chisqPerHisto.size() > 1) { // in case expected chisq is not applicable like for asymmetry fits
|
||||
UInt_t ndf_histo = 0;
|
||||
for (UInt_t i=0; i<chisqPerHisto.size(); i++) {
|
||||
if (fDKSReady)
|
||||
ndf_histo = fFitterFcnDKS->GetNoOfFittedBins(i) - fRunInfo->GetNoOfFitParameters(i);
|
||||
else
|
||||
ndf_histo = fFitterFcn->GetNoOfFittedBins(i) - fRunInfo->GetNoOfFitParameters(i);
|
||||
ndfPerHisto.push_back(ndf_histo);
|
||||
}
|
||||
}
|
||||
|
||||
// clean up
|
||||
param.clear();
|
||||
expectedChisqPerHisto.clear();
|
||||
ndfPerHisto.clear();
|
||||
chisqPerHisto.clear();
|
||||
|
||||
cout << ">> PFitter::ExecuteSave(): will write minuit2 output file ..." << endl;
|
||||
|
||||
ofstream fout;
|
||||
|
@ -42,8 +42,8 @@ using namespace std;
|
||||
* \param useChi2 if true, a chisq fit will be performed, otherwise a log max-likelihood fit will be carried out.
|
||||
*/
|
||||
PFitterFcn::PFitterFcn(PRunListCollection *runList, Bool_t useChi2) :
|
||||
fRunListCollection(runList),
|
||||
fUseChi2(useChi2)
|
||||
fUseChi2(useChi2),
|
||||
fRunListCollection(runList)
|
||||
{
|
||||
if (fUseChi2)
|
||||
fUp = 1.0;
|
||||
@ -108,15 +108,32 @@ void PFitterFcn::CalcExpectedChiSquare(const std::vector<Double_t> &par, Double_
|
||||
totalExpectedChisq = 0.0;
|
||||
expectedChisqPerRun.clear();
|
||||
|
||||
// only do something for chisq
|
||||
Double_t value = 0.0;
|
||||
if (fUseChi2) {
|
||||
Double_t value = 0.0;
|
||||
|
||||
// single histo
|
||||
for (UInt_t i=0; i<fRunListCollection->GetNoOfSingleHisto(); i++) {
|
||||
value = fRunListCollection->GetSingleRunChisqExpected(par, i); // calculate the expected chisq for single histo run block 'i'
|
||||
expectedChisqPerRun.push_back(value);
|
||||
totalExpectedChisq += value;
|
||||
}
|
||||
// mu minus
|
||||
for (UInt_t i=0; i<fRunListCollection->GetNoOfMuMinus(); i++) {
|
||||
value = fRunListCollection->GetSingleRunChisqExpected(par, i); // calculate the expected chisq for mu minus run block 'i'
|
||||
expectedChisqPerRun.push_back(value);
|
||||
totalExpectedChisq += value;
|
||||
}
|
||||
} else { // log max. likelihood
|
||||
// single histo
|
||||
for (UInt_t i=0; i<fRunListCollection->GetNoOfSingleHisto(); i++) {
|
||||
value = fRunListCollection->GetSingleHistoMaximumLikelihoodExpected(par, i); // calculate the expected mlh for single histo run block 'i'
|
||||
expectedChisqPerRun.push_back(value);
|
||||
totalExpectedChisq += value;
|
||||
}
|
||||
// mu minus
|
||||
for (UInt_t i=0; i<fRunListCollection->GetNoOfMuMinus(); i++) {
|
||||
value = fRunListCollection->GetSingleHistoMaximumLikelihoodExpected(par, i); // calculate the expected maxLH for mu minus run block 'i'
|
||||
expectedChisqPerRun.push_back(value);
|
||||
totalExpectedChisq += value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -188,22 +188,33 @@ void PFitterFcnDKS::CalcExpectedChiSquare(const std::vector<Double_t> &par, Doub
|
||||
expectedChisqPerRun.clear();
|
||||
|
||||
// only do something for chisq
|
||||
Double_t value = 0.0;
|
||||
if (fUseChi2) {
|
||||
Double_t value = 0.0;
|
||||
|
||||
// single histo
|
||||
for (UInt_t i=0; i<fRunListCollection->GetNoOfSingleHisto(); i++) {
|
||||
value = fRunListCollection->GetSingleRunChisqExpected(par, i); // calculate the expected chisq for single histo run block 'i'
|
||||
expectedChisqPerRun.push_back(value);
|
||||
totalExpectedChisq += value;
|
||||
}
|
||||
|
||||
// mu minus
|
||||
for (UInt_t i=0; i<fRunListCollection->GetNoOfMuMinus(); i++) {
|
||||
value = fRunListCollection->GetSingleRunChisqExpected(par, i); // calculate the expected chisq for mu minus run block 'i'
|
||||
expectedChisqPerRun.push_back(value);
|
||||
totalExpectedChisq += value;
|
||||
}
|
||||
} else {
|
||||
// single histo
|
||||
for (UInt_t i=0; i<fRunListCollection->GetNoOfSingleHisto(); i++) {
|
||||
value = fRunListCollection->GetSingleHistoMaximumLikelihoodExpected(par, i); // calculate the expected maxLH for single histo run block 'i'
|
||||
expectedChisqPerRun.push_back(value);
|
||||
totalExpectedChisq += value;
|
||||
}
|
||||
// mu minus
|
||||
for (UInt_t i=0; i<fRunListCollection->GetNoOfMuMinus(); i++) {
|
||||
value = fRunListCollection->GetSingleHistoMaximumLikelihoodExpected(par, i); // calculate the expected maxLH for mu minus run block 'i'
|
||||
expectedChisqPerRun.push_back(value);
|
||||
totalExpectedChisq += value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,12 +37,237 @@ using namespace std;
|
||||
#include "TF1.h"
|
||||
#include "TAxis.h"
|
||||
|
||||
#include "Minuit2/FunctionMinimum.h"
|
||||
#include "Minuit2/MnUserParameters.h"
|
||||
#include "Minuit2/MnMinimize.h"
|
||||
|
||||
#include "PMusr.h"
|
||||
#include "PFourier.h"
|
||||
|
||||
#define PI 3.14159265358979312
|
||||
#define PI_HALF 1.57079632679489656
|
||||
|
||||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// PFTPhaseCorrection
|
||||
//--------------------------------------------------------------------------
|
||||
// Constructor
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
*
|
||||
*/
|
||||
PFTPhaseCorrection::PFTPhaseCorrection(const Int_t minBin, const Int_t maxBin) :
|
||||
fMinBin(minBin), fMaxBin(maxBin)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Constructor
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
*
|
||||
*/
|
||||
PFTPhaseCorrection::PFTPhaseCorrection(vector<Double_t> &reFT, vector<Double_t> &imFT, const Int_t minBin, const Int_t maxBin) :
|
||||
fReal(reFT), fImag(imFT), fMinBin(minBin), fMaxBin(maxBin)
|
||||
{
|
||||
Init();
|
||||
|
||||
if (fMinBin == -1)
|
||||
fMinBin = 0;
|
||||
if (fMaxBin == -1)
|
||||
fMaxBin = fReal.size();
|
||||
if (fMaxBin > fReal.size())
|
||||
fMaxBin = fReal.size();
|
||||
|
||||
fRealPh.resize(fReal.size());
|
||||
fImagPh.resize(fReal.size());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Minimize (public)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void PFTPhaseCorrection::Minimize()
|
||||
{
|
||||
// create Minuit2 parameters
|
||||
ROOT::Minuit2::MnUserParameters upar;
|
||||
|
||||
upar.Add("c0", fPh_c0, 2.0);
|
||||
upar.Add("c1", fPh_c1, 2.0);
|
||||
|
||||
// create minimizer
|
||||
ROOT::Minuit2::MnMinimize mn_min(*this, upar);
|
||||
|
||||
// minimize
|
||||
ROOT::Minuit2::FunctionMinimum min = mn_min();
|
||||
|
||||
if (min.IsValid()) {
|
||||
fPh_c0 = min.UserState().Value("c0");
|
||||
fPh_c1 = min.UserState().Value("c1");
|
||||
fMin = min.Fval();
|
||||
} else {
|
||||
fMin = -1.0;
|
||||
fValid = false;
|
||||
cout << endl << ">> **WARNING** minimize failed to find a minimum for the real FT phase correction ..." << endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// GetPhaseCorrectionParam (public)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
*
|
||||
*/
|
||||
Double_t PFTPhaseCorrection::GetPhaseCorrectionParam(UInt_t idx)
|
||||
{
|
||||
Double_t result=0.0;
|
||||
|
||||
if (idx == 0)
|
||||
result = fPh_c0;
|
||||
else if (idx == 1)
|
||||
result = fPh_c1;
|
||||
else
|
||||
cerr << ">> **ERROR** requested phase correction parameter with index=" << idx << " does not exist!" << endl;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// GetMinimum (public)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
*
|
||||
*/
|
||||
Double_t PFTPhaseCorrection::GetMinimum()
|
||||
{
|
||||
if (!fValid) {
|
||||
cerr << ">> **ERROR** requested minimum is invalid!" << endl;
|
||||
return -1.0;
|
||||
}
|
||||
|
||||
return fMin;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Init (private)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void PFTPhaseCorrection::Init()
|
||||
{
|
||||
fValid = true;
|
||||
fPh_c0 = 0.0;
|
||||
fPh_c1 = 0.0;
|
||||
fGamma = 1.0;
|
||||
fMin = -1.0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// CalcPhasedFT (private)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void PFTPhaseCorrection::CalcPhasedFT() const
|
||||
{
|
||||
Double_t phi=0.0;
|
||||
Double_t w=0.0;
|
||||
|
||||
for (UInt_t i=0; i<fRealPh.size(); i++) {
|
||||
w = (Double_t)i / (Double_t)fReal.size();
|
||||
phi = fPh_c0 + fPh_c1 * w;
|
||||
fRealPh[i] = fReal[i]*cos(phi) - fImag[i]*sin(phi);
|
||||
fImagPh[i] = fReal[i]*sin(phi) + fImag[i]*cos(phi);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// CalcRealPhFTDerivative (private)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void PFTPhaseCorrection::CalcRealPhFTDerivative() const
|
||||
{
|
||||
fRealPhD.resize(fRealPh.size());
|
||||
|
||||
fRealPhD[0] = 1.0;
|
||||
fRealPhD[fRealPh.size()-1] = 1.0;
|
||||
|
||||
for (UInt_t i=1; i<fRealPh.size()-1; i++)
|
||||
fRealPhD[i] = fRealPh[i+1]-fRealPh[i];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Penalty (private)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
*
|
||||
*/
|
||||
Double_t PFTPhaseCorrection::Penalty() const
|
||||
{
|
||||
Double_t penalty = 0.0;
|
||||
|
||||
for (UInt_t i=fMinBin; i<fMaxBin; i++) {
|
||||
if (fRealPh[i] < 0.0)
|
||||
penalty += fRealPh[i]*fRealPh[i];
|
||||
}
|
||||
|
||||
return fGamma*penalty;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Entropy (private)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
*
|
||||
*/
|
||||
Double_t PFTPhaseCorrection::Entropy() const
|
||||
{
|
||||
Double_t norm = 0.0;
|
||||
|
||||
for (UInt_t i=fMinBin; i<fMaxBin; i++)
|
||||
norm += fabs(fRealPhD[i]);
|
||||
|
||||
Double_t entropy = 0.0;
|
||||
Double_t dval = 0.0, hh = 0.0;
|
||||
|
||||
for (UInt_t i=fMinBin; i<fMaxBin; i++) {
|
||||
dval = fabs(fRealPhD[i]);
|
||||
if (dval > 1.0e-15) {
|
||||
hh = dval / norm;
|
||||
entropy -= hh * log(hh);
|
||||
}
|
||||
}
|
||||
|
||||
return entropy;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// operator() (private)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
*
|
||||
*/
|
||||
double PFTPhaseCorrection::operator()(const vector<double> &par) const
|
||||
{
|
||||
// par : [0]: c0, [1]: c1
|
||||
|
||||
fPh_c0 = par[0];
|
||||
fPh_c1 = par[1];
|
||||
|
||||
CalcPhasedFT();
|
||||
CalcRealPhFTDerivative();
|
||||
|
||||
return Entropy()+Penalty();
|
||||
}
|
||||
|
||||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// PFourier
|
||||
//--------------------------------------------------------------------------
|
||||
// Constructor
|
||||
//--------------------------------------------------------------------------
|
||||
@ -72,6 +297,7 @@ PFourier::PFourier(TH1F *data, Int_t unitTag, Double_t startTime, Double_t endTi
|
||||
fUseFFTW = true;
|
||||
fIn = 0;
|
||||
fOut = 0;
|
||||
|
||||
#ifdef HAVE_DKS
|
||||
fInDKS = 0;
|
||||
fOutDKS = 0;
|
||||
@ -377,123 +603,101 @@ TH1F* PFourier::GetRealFourier(const Double_t scale)
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// GetPhaseOptRealFourier (public)
|
||||
// GetPhaseOptRealFourier (public, static)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <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$.
|
||||
* <p>returns the phase corrected real Fourier transform.
|
||||
*
|
||||
* \return the TH1F histo of the phase 'optimzed' real Fourier transform.
|
||||
*
|
||||
* \param phase return value of the optimal phase
|
||||
* \param re real part Fourier histogram
|
||||
* \param im imaginary part Fourier histogram
|
||||
* \param phase return value of the optimal phase dispersion phase[0]+phase[1]*i/N
|
||||
* \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)
|
||||
TH1F* PFourier::GetPhaseOptRealFourier(const TH1F *re, const TH1F *im, vector<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;
|
||||
if ((re == 0) || (im == 0))
|
||||
return 0;
|
||||
|
||||
UInt_t minBin = 0;
|
||||
UInt_t maxBin = noOfFourierBins;
|
||||
phase.resize(2); // c0, c1
|
||||
|
||||
TAxis *axis = re->GetXaxis();
|
||||
|
||||
Int_t minBin = 1;
|
||||
Int_t maxBin = axis->GetNbins();
|
||||
Int_t noOfBins = axis->GetNbins();
|
||||
Double_t res = axis->GetBinWidth(1);
|
||||
|
||||
// check if minimum frequency is given. If yes, get the proper minBin
|
||||
if (min != -1.0) {
|
||||
minBin = (UInt_t)(min/fResolution);
|
||||
minBin = axis->FindFixBin(min);
|
||||
if ((minBin == 0) || (minBin > maxBin)) {
|
||||
minBin = 1;
|
||||
cerr << "**WARNING** minimum frequency/field out of range. Will adopted it." << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// 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;
|
||||
maxBin = axis->FindFixBin(max);
|
||||
if ((maxBin == 0) || (maxBin > axis->GetNbins())) {
|
||||
maxBin = axis->GetNbins();
|
||||
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;
|
||||
if (fUseFFTW) {
|
||||
for (UInt_t i=minBin; i<=maxBin; i++) {
|
||||
realF.push_back(fOut[i][0]);
|
||||
imagF.push_back(fOut[i][1]);
|
||||
}
|
||||
} else {
|
||||
for (UInt_t i=minBin; i<=maxBin; i++) {
|
||||
#ifdef HAVE_DKS
|
||||
realF.push_back(fOutDKS[i].real());
|
||||
imagF.push_back(fOutDKS[i].imag());
|
||||
#endif
|
||||
}
|
||||
for (Int_t i=minBin; i<=maxBin; i++) {
|
||||
realF.push_back(re->GetBinContent(i));
|
||||
imagF.push_back(im->GetBinContent(i));
|
||||
}
|
||||
|
||||
// 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;
|
||||
// optimize real FT phase
|
||||
PFTPhaseCorrection *phCorrectedReFT = new PFTPhaseCorrection(realF, imagF);
|
||||
if (phCorrectedReFT == 0) {
|
||||
cerr << endl << "**SEVERE ERROR** couldn't invoke PFTPhaseCorrection object." << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
phCorrectedReFT->Minimize();
|
||||
if (!phCorrectedReFT->IsValid()) {
|
||||
cerr << endl << "**ERROR** could not find a valid phase correction minimum." << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// keep the optimal phase
|
||||
phase = maxRotBin*da;
|
||||
phase[0] = phCorrectedReFT->GetPhaseCorrectionParam(0);
|
||||
phase[1] = phCorrectedReFT->GetPhaseCorrectionParam(1);
|
||||
|
||||
// clean up
|
||||
if (phCorrectedReFT) {
|
||||
delete phCorrectedReFT;
|
||||
phCorrectedReFT = 0;
|
||||
}
|
||||
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());
|
||||
snprintf(name, sizeof(name), "%s_Fourier_PhOptRe", re->GetName());
|
||||
snprintf(title, sizeof(title), "%s_Fourier_PhOptRe", re->GetTitle());
|
||||
|
||||
TH1F *realPhaseOptFourier = new TH1F(name, title, noOfFourierBins, -fResolution/2.0, (Double_t)(noOfFourierBins-1)*fResolution+fResolution/2.0);
|
||||
TH1F *realPhaseOptFourier = new TH1F(name, title, noOfBins, -res/2.0, (Double_t)(noOfBins-1)*res+res/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
|
||||
if (fUseFFTW) {
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
#ifdef HAVE_DKS
|
||||
for (UInt_t i=0; i<noOfFourierBins; i++) {
|
||||
realPhaseOptFourier->SetBinContent(i+1, scale*(fOutDKS[i].real()*cos(phase) + fOutDKS[i].imag()*sin(phase)));
|
||||
realPhaseOptFourier->SetBinError(i+1, 0.0);
|
||||
}
|
||||
#endif
|
||||
Double_t ph;
|
||||
for (Int_t i=0; i<noOfBins; i++) {
|
||||
ph = phase[0] + phase[1] * (Double_t)((Int_t)i-(Int_t)minBin) / (Double_t)(maxBin-minBin);
|
||||
realPhaseOptFourier->SetBinContent(i+1, scale*(re->GetBinContent(i+1)*cos(ph) - im->GetBinContent(i+1)*sin(ph)));
|
||||
realPhaseOptFourier->SetBinError(i+1, 0.0);
|
||||
}
|
||||
|
||||
return realPhaseOptFourier;
|
||||
|
@ -341,6 +341,16 @@ void PFourierCanvas::HandleCmdKey(Int_t event, Int_t x, Int_t y, TObject *select
|
||||
CleanupAverage();
|
||||
PlotFourier();
|
||||
}
|
||||
} else if (x == 'c') {
|
||||
Int_t state = fFourierPad->GetCrosshair();
|
||||
if (state == 0) {
|
||||
fMainCanvas->ToggleEventStatus();
|
||||
fFourierPad->SetCrosshair(2);
|
||||
} else {
|
||||
fMainCanvas->ToggleEventStatus();
|
||||
fFourierPad->SetCrosshair(0);
|
||||
}
|
||||
fMainCanvas->Update();
|
||||
} else if (x == '+') { // increment phase (Fourier real/imag)
|
||||
IncrementFourierPhase();
|
||||
} else if (x == '-') { // decrement phase (Fourier real/imag)
|
||||
@ -366,32 +376,62 @@ void PFourierCanvas::HandleMenuPopup(Int_t id)
|
||||
fPopupFourier->UnCheckEntries();
|
||||
fPopupFourier->CheckEntry(P_MENU_ID_FOURIER+P_MENU_ID_FOURIER_REAL);
|
||||
fCurrentPlotView = FOURIER_PLOT_REAL;
|
||||
PlotFourier();
|
||||
if (!fAveragedView) {
|
||||
PlotFourier();
|
||||
} else {
|
||||
HandleAverage();
|
||||
PlotAverage();
|
||||
}
|
||||
} else if (id == P_MENU_ID_FOURIER+P_MENU_ID_FOURIER_IMAG) {
|
||||
fPopupFourier->UnCheckEntries();
|
||||
fPopupFourier->CheckEntry(P_MENU_ID_FOURIER+P_MENU_ID_FOURIER_IMAG);
|
||||
fCurrentPlotView = FOURIER_PLOT_IMAG;
|
||||
PlotFourier();
|
||||
if (!fAveragedView) {
|
||||
PlotFourier();
|
||||
} else {
|
||||
HandleAverage();
|
||||
PlotAverage();
|
||||
}
|
||||
} else if (id == P_MENU_ID_FOURIER+P_MENU_ID_FOURIER_REAL_AND_IMAG) {
|
||||
fPopupFourier->UnCheckEntries();
|
||||
fPopupFourier->CheckEntry(P_MENU_ID_FOURIER+P_MENU_ID_FOURIER_REAL_AND_IMAG);
|
||||
fCurrentPlotView = P_MENU_ID_FOURIER_REAL_AND_IMAG;
|
||||
PlotFourier();
|
||||
if (!fAveragedView) {
|
||||
PlotFourier();
|
||||
} else {
|
||||
HandleAverage();
|
||||
PlotAverage();
|
||||
}
|
||||
} else if (id == P_MENU_ID_FOURIER+P_MENU_ID_FOURIER_PWR) {
|
||||
fPopupFourier->UnCheckEntries();
|
||||
fPopupFourier->CheckEntry(P_MENU_ID_FOURIER+P_MENU_ID_FOURIER_PWR);
|
||||
fCurrentPlotView = FOURIER_PLOT_POWER;
|
||||
PlotFourier();
|
||||
if (!fAveragedView) {
|
||||
PlotFourier();
|
||||
} else {
|
||||
HandleAverage();
|
||||
PlotAverage();
|
||||
}
|
||||
} else if (id == P_MENU_ID_FOURIER+P_MENU_ID_FOURIER_PHASE) {
|
||||
fPopupFourier->UnCheckEntries();
|
||||
fPopupFourier->CheckEntry(P_MENU_ID_FOURIER+P_MENU_ID_FOURIER_PHASE);
|
||||
fCurrentPlotView = FOURIER_PLOT_PHASE;
|
||||
PlotFourier();
|
||||
if (!fAveragedView) {
|
||||
PlotFourier();
|
||||
} else {
|
||||
HandleAverage();
|
||||
PlotAverage();
|
||||
}
|
||||
} else if (id == P_MENU_ID_FOURIER+P_MENU_ID_FOURIER_PHASE_OPT_REAL) {
|
||||
fPopupFourier->UnCheckEntries();
|
||||
fPopupFourier->CheckEntry(P_MENU_ID_FOURIER+P_MENU_ID_FOURIER_PHASE_OPT_REAL);
|
||||
fCurrentPlotView = FOURIER_PLOT_PHASE_OPT_REAL;
|
||||
PlotFourier();
|
||||
if (!fAveragedView) {
|
||||
PlotFourier();
|
||||
} else {
|
||||
HandleAverage();
|
||||
PlotAverage();
|
||||
}
|
||||
} else if (id == P_MENU_ID_FOURIER+P_MENU_ID_FOURIER_PHASE_PLUS) {
|
||||
IncrementFourierPhase();
|
||||
} else if (id == P_MENU_ID_FOURIER+P_MENU_ID_FOURIER_PHASE_MINUS) {
|
||||
@ -624,6 +664,12 @@ void PFourierCanvas::ExportData(const Char_t *pathFileName)
|
||||
xMinBin = fFourierHistos[0].dataFourierIm->GetXaxis()->GetFirst();
|
||||
xMaxBin = fFourierHistos[0].dataFourierIm->GetXaxis()->GetLast();
|
||||
break;
|
||||
case FOURIER_PLOT_REAL_AND_IMAG:
|
||||
xAxis = fFourierHistos[0].dataFourierRe->GetXaxis()->GetTitle();
|
||||
yAxis = TString("Real+Imag");
|
||||
xMinBin = fFourierHistos[0].dataFourierRe->GetXaxis()->GetFirst();
|
||||
xMaxBin = fFourierHistos[0].dataFourierRe->GetXaxis()->GetLast();
|
||||
break;
|
||||
case FOURIER_PLOT_POWER:
|
||||
xAxis = fFourierHistos[0].dataFourierPwr->GetXaxis()->GetTitle();
|
||||
yAxis = TString("Power");
|
||||
@ -703,42 +749,46 @@ void PFourierCanvas::ExportData(const Char_t *pathFileName)
|
||||
for (UInt_t j=0; j<fFourierHistos.size()-1; j++) {
|
||||
switch (fCurrentPlotView) {
|
||||
case FOURIER_PLOT_REAL:
|
||||
fout << fFourierHistos[j].dataFourierRe->GetBinCenter(i) << ", " << fFourierHistos[j].dataFourierRe->GetBinContent(i) << ", ";
|
||||
break;
|
||||
fout << fFourierHistos[j].dataFourierRe->GetBinCenter(i) << ", " << fFourierHistos[j].dataFourierRe->GetBinContent(i) << ", ";
|
||||
break;
|
||||
case FOURIER_PLOT_IMAG:
|
||||
fout << fFourierHistos[j].dataFourierIm->GetBinCenter(i) << ", " << fFourierHistos[j].dataFourierIm->GetBinContent(i) << ", ";
|
||||
break;
|
||||
fout << fFourierHistos[j].dataFourierIm->GetBinCenter(i) << ", " << fFourierHistos[j].dataFourierIm->GetBinContent(i) << ", ";
|
||||
break;
|
||||
case FOURIER_PLOT_REAL_AND_IMAG:
|
||||
break;
|
||||
case FOURIER_PLOT_POWER:
|
||||
fout << fFourierHistos[j].dataFourierPwr->GetBinCenter(i) << ", " << fFourierHistos[j].dataFourierPwr->GetBinContent(i) << ", ";
|
||||
break;
|
||||
fout << fFourierHistos[j].dataFourierPwr->GetBinCenter(i) << ", " << fFourierHistos[j].dataFourierPwr->GetBinContent(i) << ", ";
|
||||
break;
|
||||
case FOURIER_PLOT_PHASE:
|
||||
fout << fFourierHistos[j].dataFourierPhase->GetBinCenter(i) << ", " << fFourierHistos[j].dataFourierPhase->GetBinContent(i) << ", ";
|
||||
break;
|
||||
fout << fFourierHistos[j].dataFourierPhase->GetBinCenter(i) << ", " << fFourierHistos[j].dataFourierPhase->GetBinContent(i) << ", ";
|
||||
break;
|
||||
case FOURIER_PLOT_PHASE_OPT_REAL:
|
||||
fout << fFourierHistos[j].dataFourierPhaseOptReal->GetBinCenter(i) << ", " << fFourierHistos[j].dataFourierPhaseOptReal->GetBinContent(i) << ", ";
|
||||
break;
|
||||
fout << fFourierHistos[j].dataFourierPhaseOptReal->GetBinCenter(i) << ", " << fFourierHistos[j].dataFourierPhaseOptReal->GetBinContent(i) << ", ";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch (fCurrentPlotView) {
|
||||
case FOURIER_PLOT_REAL:
|
||||
fout << fFourierHistos[fFourierHistos.size()-1].dataFourierRe->GetBinCenter(i) << ", " << fFourierHistos[fFourierHistos.size()-1].dataFourierRe->GetBinContent(i) << endl;
|
||||
break;
|
||||
fout << fFourierHistos[fFourierHistos.size()-1].dataFourierRe->GetBinCenter(i) << ", " << fFourierHistos[fFourierHistos.size()-1].dataFourierRe->GetBinContent(i) << endl;
|
||||
break;
|
||||
case FOURIER_PLOT_IMAG:
|
||||
fout << fFourierHistos[fFourierHistos.size()-1].dataFourierIm->GetBinCenter(i) << ", " << fFourierHistos[fFourierHistos.size()-1].dataFourierIm->GetBinContent(i) << endl;
|
||||
break;
|
||||
fout << fFourierHistos[fFourierHistos.size()-1].dataFourierIm->GetBinCenter(i) << ", " << fFourierHistos[fFourierHistos.size()-1].dataFourierIm->GetBinContent(i) << endl;
|
||||
break;
|
||||
case FOURIER_PLOT_REAL_AND_IMAG:
|
||||
break;
|
||||
case FOURIER_PLOT_POWER:
|
||||
fout << fFourierHistos[fFourierHistos.size()-1].dataFourierPwr->GetBinCenter(i) << ", " << fFourierHistos[fFourierHistos.size()-1].dataFourierPwr->GetBinContent(i) << endl;
|
||||
break;
|
||||
fout << fFourierHistos[fFourierHistos.size()-1].dataFourierPwr->GetBinCenter(i) << ", " << fFourierHistos[fFourierHistos.size()-1].dataFourierPwr->GetBinContent(i) << endl;
|
||||
break;
|
||||
case FOURIER_PLOT_PHASE:
|
||||
fout << fFourierHistos[fFourierHistos.size()-1].dataFourierPhase->GetBinCenter(i) << ", " << fFourierHistos[fFourierHistos.size()-1].dataFourierPhase->GetBinContent(i) << endl;
|
||||
break;
|
||||
fout << fFourierHistos[fFourierHistos.size()-1].dataFourierPhase->GetBinCenter(i) << ", " << fFourierHistos[fFourierHistos.size()-1].dataFourierPhase->GetBinContent(i) << endl;
|
||||
break;
|
||||
case FOURIER_PLOT_PHASE_OPT_REAL:
|
||||
fout << fFourierHistos[fFourierHistos.size()-1].dataFourierPhaseOptReal->GetBinCenter(i) << ", " << fFourierHistos[fFourierHistos.size()-1].dataFourierPhaseOptReal->GetBinContent(i) << endl;
|
||||
break;
|
||||
fout << fFourierHistos[fFourierHistos.size()-1].dataFourierPhaseOptReal->GetBinCenter(i) << ", " << fFourierHistos[fFourierHistos.size()-1].dataFourierPhaseOptReal->GetBinContent(i) << endl;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -804,8 +854,10 @@ void PFourierCanvas::InitFourierDataSets()
|
||||
fFourierHistos[i].dataFourierIm = fFourier[i]->GetImaginaryFourier();
|
||||
fFourierHistos[i].dataFourierPwr = fFourier[i]->GetPowerFourier();
|
||||
fFourierHistos[i].dataFourierPhase = fFourier[i]->GetPhaseFourier();
|
||||
fFourierHistos[i].dataFourierPhaseOptReal = fFourier[i]->GetPhaseOptRealFourier(fFourierHistos[i].optPhase, 1.0, fInitialXRange[0], fInitialXRange[1]);
|
||||
cout << "debug> histo[" << i << "]: opt. phase = " << fFourierHistos[i].optPhase * 180.0 / TMath::Pi() << "°" << endl;
|
||||
if (fCurrentPlotView == FOURIER_PLOT_PHASE_OPT_REAL) {
|
||||
fFourierHistos[i].dataFourierPhaseOptReal = fFourier[i]->GetPhaseOptRealFourier(fFourierHistos[i].dataFourierRe,
|
||||
fFourierHistos[i].dataFourierIm, fFourierHistos[i].optPhase, 1.0, fInitialXRange[0], fInitialXRange[1]);
|
||||
}
|
||||
}
|
||||
|
||||
// rescale histo to abs(maximum) == 1
|
||||
@ -870,17 +922,19 @@ void PFourierCanvas::InitFourierDataSets()
|
||||
}
|
||||
}
|
||||
|
||||
// phase opt real
|
||||
for (UInt_t i=0; i<fFourierHistos.size(); i++) {
|
||||
for (Int_t j=start; j<=end; j++) {
|
||||
dval = fFourierHistos[i].dataFourierPhaseOptReal->GetBinContent(j);
|
||||
if (fabs(dval) > max)
|
||||
max = dval;
|
||||
if (fCurrentPlotView == FOURIER_PLOT_PHASE_OPT_REAL) {
|
||||
// phase opt real
|
||||
for (UInt_t i=0; i<fFourierHistos.size(); i++) {
|
||||
for (Int_t j=start; j<=end; j++) {
|
||||
dval = fFourierHistos[i].dataFourierPhaseOptReal->GetBinContent(j);
|
||||
if (fabs(dval) > max)
|
||||
max = dval;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (UInt_t i=0; i<fFourierHistos.size(); i++) {
|
||||
for (Int_t j=1; j<fFourierHistos[i].dataFourierPhaseOptReal->GetNbinsX(); j++) {
|
||||
fFourierHistos[i].dataFourierPhaseOptReal->SetBinContent(j, fFourierHistos[i].dataFourierPhaseOptReal->GetBinContent(j)/fabs(max));
|
||||
for (UInt_t i=0; i<fFourierHistos.size(); i++) {
|
||||
for (Int_t j=1; j<fFourierHistos[i].dataFourierPhaseOptReal->GetNbinsX(); j++) {
|
||||
fFourierHistos[i].dataFourierPhaseOptReal->SetBinContent(j, fFourierHistos[i].dataFourierPhaseOptReal->GetBinContent(j)/fabs(max));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -894,8 +948,10 @@ void PFourierCanvas::InitFourierDataSets()
|
||||
fFourierHistos[i].dataFourierPwr->SetLineColor(fColorList[i]);
|
||||
fFourierHistos[i].dataFourierPhase->SetMarkerColor(fColorList[i]);
|
||||
fFourierHistos[i].dataFourierPhase->SetLineColor(fColorList[i]);
|
||||
fFourierHistos[i].dataFourierPhaseOptReal->SetMarkerColor(fColorList[i]);
|
||||
fFourierHistos[i].dataFourierPhaseOptReal->SetLineColor(fColorList[i]);
|
||||
if (fCurrentPlotView == FOURIER_PLOT_PHASE_OPT_REAL) {
|
||||
fFourierHistos[i].dataFourierPhaseOptReal->SetMarkerColor(fColorList[i]);
|
||||
fFourierHistos[i].dataFourierPhaseOptReal->SetLineColor(fColorList[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// set the marker symbol and size
|
||||
@ -908,8 +964,10 @@ void PFourierCanvas::InitFourierDataSets()
|
||||
fFourierHistos[i].dataFourierPwr->SetMarkerSize(0.7);
|
||||
fFourierHistos[i].dataFourierPhase->SetMarkerStyle(fMarkerList[i]);
|
||||
fFourierHistos[i].dataFourierPhase->SetMarkerSize(0.7);
|
||||
fFourierHistos[i].dataFourierPhaseOptReal->SetMarkerStyle(fMarkerList[i]);
|
||||
fFourierHistos[i].dataFourierPhaseOptReal->SetMarkerSize(0.7);
|
||||
if (fCurrentPlotView == FOURIER_PLOT_PHASE_OPT_REAL) {
|
||||
fFourierHistos[i].dataFourierPhaseOptReal->SetMarkerStyle(fMarkerList[i]);
|
||||
fFourierHistos[i].dataFourierPhaseOptReal->SetMarkerSize(0.7);
|
||||
}
|
||||
}
|
||||
|
||||
// initialize average histos
|
||||
@ -1107,6 +1165,10 @@ void PFourierCanvas::HandleAverage()
|
||||
TString name("");
|
||||
Double_t dval=0.0;
|
||||
|
||||
Bool_t phaseOptRealPresent = false;
|
||||
if (fFourierHistos[0].dataFourierPhaseOptReal != 0)
|
||||
phaseOptRealPresent = true;
|
||||
|
||||
// check if ALL data shall be averaged
|
||||
if (fAveragedView) {
|
||||
fFourierAverage.resize(1);
|
||||
@ -1132,10 +1194,12 @@ void PFourierCanvas::HandleAverage()
|
||||
fFourierHistos[0].dataFourierPhase->GetXaxis()->GetXmin(),
|
||||
fFourierHistos[0].dataFourierPhase->GetXaxis()->GetXmax());
|
||||
|
||||
name = TString(fFourierHistos[0].dataFourierPhaseOptReal->GetTitle()) + "_avg";
|
||||
fFourierAverage[0].dataFourierPhaseOptReal = new TH1F(name, name, fFourierHistos[0].dataFourierPhaseOptReal->GetNbinsX(),
|
||||
fFourierHistos[0].dataFourierPhaseOptReal->GetXaxis()->GetXmin(),
|
||||
fFourierHistos[0].dataFourierPhaseOptReal->GetXaxis()->GetXmax());
|
||||
if (phaseOptRealPresent) {
|
||||
name = TString(fFourierHistos[0].dataFourierPhaseOptReal->GetTitle()) + "_avg";
|
||||
fFourierAverage[0].dataFourierPhaseOptReal = new TH1F(name, name, fFourierHistos[0].dataFourierPhaseOptReal->GetNbinsX(),
|
||||
fFourierHistos[0].dataFourierPhaseOptReal->GetXaxis()->GetXmin(),
|
||||
fFourierHistos[0].dataFourierPhaseOptReal->GetXaxis()->GetXmax());
|
||||
}
|
||||
|
||||
// real average
|
||||
for (Int_t j=0; j<fFourierHistos[0].dataFourierRe->GetNbinsX(); j++) {
|
||||
@ -1197,20 +1261,22 @@ void PFourierCanvas::HandleAverage()
|
||||
fFourierAverage[0].dataFourierPhase->SetMarkerSize(0.8);
|
||||
fFourierAverage[0].dataFourierPhase->SetMarkerStyle(22);
|
||||
|
||||
// phase optimised real average
|
||||
for (Int_t j=0; j<fFourierHistos[0].dataFourierPhaseOptReal->GetNbinsX(); j++) {
|
||||
dval = 0.0;
|
||||
for (UInt_t i=0; i<fFourierHistos.size(); i++) {
|
||||
if (j < fFourierHistos[i].dataFourierPhaseOptReal->GetNbinsX())
|
||||
dval += GetInterpolatedValue(fFourierHistos[i].dataFourierPhaseOptReal, fFourierHistos[0].dataFourierPhaseOptReal->GetBinCenter(j));
|
||||
if (phaseOptRealPresent) {
|
||||
// phase optimised real average
|
||||
for (Int_t j=0; j<fFourierHistos[0].dataFourierPhaseOptReal->GetNbinsX(); j++) {
|
||||
dval = 0.0;
|
||||
for (UInt_t i=0; i<fFourierHistos.size(); i++) {
|
||||
if (j < fFourierHistos[i].dataFourierPhaseOptReal->GetNbinsX())
|
||||
dval += GetInterpolatedValue(fFourierHistos[i].dataFourierPhaseOptReal, fFourierHistos[0].dataFourierPhaseOptReal->GetBinCenter(j));
|
||||
}
|
||||
fFourierAverage[0].dataFourierPhaseOptReal->SetBinContent(j, dval/fFourierHistos.size());
|
||||
}
|
||||
fFourierAverage[0].dataFourierPhaseOptReal->SetBinContent(j, dval/fFourierHistos.size());
|
||||
// set marker color, line color, maker size, marker type
|
||||
fFourierAverage[0].dataFourierPhaseOptReal->SetMarkerColor(kBlack);
|
||||
fFourierAverage[0].dataFourierPhaseOptReal->SetLineColor(kBlack);
|
||||
fFourierAverage[0].dataFourierPhaseOptReal->SetMarkerSize(0.8);
|
||||
fFourierAverage[0].dataFourierPhaseOptReal->SetMarkerStyle(22);
|
||||
}
|
||||
// set marker color, line color, maker size, marker type
|
||||
fFourierAverage[0].dataFourierPhaseOptReal->SetMarkerColor(kBlack);
|
||||
fFourierAverage[0].dataFourierPhaseOptReal->SetLineColor(kBlack);
|
||||
fFourierAverage[0].dataFourierPhaseOptReal->SetMarkerSize(0.8);
|
||||
fFourierAverage[0].dataFourierPhaseOptReal->SetMarkerStyle(22);
|
||||
}
|
||||
|
||||
// check if per data set shall be averaged
|
||||
@ -1274,10 +1340,12 @@ void PFourierCanvas::HandleAverage()
|
||||
fFourierHistos[0].dataFourierPhase->GetXaxis()->GetXmin(),
|
||||
fFourierHistos[0].dataFourierPhase->GetXaxis()->GetXmax());
|
||||
|
||||
name = TString(fFourierHistos[start].dataFourierPhaseOptReal->GetTitle()) + "_avg";
|
||||
fFourierAverage[i].dataFourierPhaseOptReal = new TH1F(name, name, fFourierHistos[0].dataFourierPhaseOptReal->GetNbinsX(),
|
||||
fFourierHistos[0].dataFourierPhaseOptReal->GetXaxis()->GetXmin(),
|
||||
fFourierHistos[0].dataFourierPhaseOptReal->GetXaxis()->GetXmax());
|
||||
if (phaseOptRealPresent) {
|
||||
name = TString(fFourierHistos[start].dataFourierPhaseOptReal->GetTitle()) + "_avg";
|
||||
fFourierAverage[i].dataFourierPhaseOptReal = new TH1F(name, name, fFourierHistos[0].dataFourierPhaseOptReal->GetNbinsX(),
|
||||
fFourierHistos[0].dataFourierPhaseOptReal->GetXaxis()->GetXmin(),
|
||||
fFourierHistos[0].dataFourierPhaseOptReal->GetXaxis()->GetXmax());
|
||||
}
|
||||
|
||||
// real average
|
||||
for (Int_t j=0; j<fFourierHistos[0].dataFourierRe->GetNbinsX(); j++) {
|
||||
@ -1339,24 +1407,61 @@ void PFourierCanvas::HandleAverage()
|
||||
fFourierAverage[i].dataFourierPhase->SetMarkerSize(0.8);
|
||||
fFourierAverage[i].dataFourierPhase->SetMarkerStyle(22); // closed up triangle
|
||||
|
||||
// phase optimised real average
|
||||
for (Int_t j=0; j<fFourierHistos[0].dataFourierPhaseOptReal->GetNbinsX(); j++) {
|
||||
dval = 0.0;
|
||||
for (Int_t k=start; k<=end; k++) {
|
||||
if (j < fFourierHistos[k].dataFourierPhaseOptReal->GetNbinsX())
|
||||
dval += GetInterpolatedValue(fFourierHistos[k].dataFourierPhaseOptReal, fFourierHistos[0].dataFourierPhaseOptReal->GetBinCenter(j));
|
||||
if (phaseOptRealPresent) {
|
||||
// phase optimised real average
|
||||
for (Int_t j=0; j<fFourierHistos[0].dataFourierPhaseOptReal->GetNbinsX(); j++) {
|
||||
dval = 0.0;
|
||||
for (Int_t k=start; k<=end; k++) {
|
||||
if (j < fFourierHistos[k].dataFourierPhaseOptReal->GetNbinsX())
|
||||
dval += GetInterpolatedValue(fFourierHistos[k].dataFourierPhaseOptReal, fFourierHistos[0].dataFourierPhaseOptReal->GetBinCenter(j));
|
||||
}
|
||||
fFourierAverage[i].dataFourierPhaseOptReal->SetBinContent(j, dval/(end-start+1));
|
||||
}
|
||||
fFourierAverage[i].dataFourierPhaseOptReal->SetBinContent(j, dval/(end-start+1));
|
||||
// set marker color, line color, maker size, marker type
|
||||
fFourierAverage[i].dataFourierPhaseOptReal->SetMarkerColor(fColorList[i]);
|
||||
fFourierAverage[i].dataFourierPhaseOptReal->SetLineColor(fColorList[i]);
|
||||
fFourierAverage[i].dataFourierPhaseOptReal->SetMarkerSize(0.8);
|
||||
fFourierAverage[i].dataFourierPhaseOptReal->SetMarkerStyle(22); // closed up triangle
|
||||
}
|
||||
// set marker color, line color, maker size, marker type
|
||||
fFourierAverage[i].dataFourierPhaseOptReal->SetMarkerColor(fColorList[i]);
|
||||
fFourierAverage[i].dataFourierPhaseOptReal->SetLineColor(fColorList[i]);
|
||||
fFourierAverage[i].dataFourierPhaseOptReal->SetMarkerSize(0.8);
|
||||
fFourierAverage[i].dataFourierPhaseOptReal->SetMarkerStyle(22); // closed up triangle
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// CalcPhaseOptReal (private)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>calculate the phase opt. real FT
|
||||
*/
|
||||
void PFourierCanvas::CalcPhaseOptReal()
|
||||
{
|
||||
Int_t start = fFourierHistos[0].dataFourierRe->FindFixBin(fInitialXRange[0]);
|
||||
Int_t end = fFourierHistos[0].dataFourierRe->FindFixBin(fInitialXRange[1]);
|
||||
|
||||
Double_t dval=0.0, max=0.0;
|
||||
for (UInt_t i=0; i<fFourierHistos.size(); i++) {
|
||||
fFourierHistos[i].dataFourierPhaseOptReal = fFourier[i]->GetPhaseOptRealFourier(fFourierHistos[i].dataFourierRe,
|
||||
fFourierHistos[i].dataFourierIm, fFourierHistos[i].optPhase, 1.0, fInitialXRange[0], fInitialXRange[1]);
|
||||
// normalize it
|
||||
max = 0.0;
|
||||
for (Int_t j=start; j<=end; j++) {
|
||||
dval = fFourierHistos[i].dataFourierPhaseOptReal->GetBinContent(j);
|
||||
if (fabs(dval) > max)
|
||||
max = dval;
|
||||
}
|
||||
for (Int_t j=1; j<fFourierHistos[i].dataFourierPhaseOptReal->GetNbinsX(); j++) {
|
||||
fFourierHistos[i].dataFourierPhaseOptReal->SetBinContent(j, fFourierHistos[i].dataFourierPhaseOptReal->GetBinContent(j)/fabs(max));
|
||||
}
|
||||
// set the marker and line color
|
||||
fFourierHistos[i].dataFourierPhaseOptReal->SetMarkerColor(fColorList[i]);
|
||||
fFourierHistos[i].dataFourierPhaseOptReal->SetLineColor(fColorList[i]);
|
||||
|
||||
// set the marker symbol and size
|
||||
fFourierHistos[i].dataFourierPhaseOptReal->SetMarkerStyle(fMarkerList[i]);
|
||||
fFourierHistos[i].dataFourierPhaseOptReal->SetMarkerSize(0.7);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// PlotFourier (private)
|
||||
//--------------------------------------------------------------------------
|
||||
@ -1365,6 +1470,14 @@ void PFourierCanvas::HandleAverage()
|
||||
*/
|
||||
void PFourierCanvas::PlotFourier()
|
||||
{
|
||||
// check if phase opt real Fourier spectra already exists if requested,
|
||||
// and if not calculate them first
|
||||
if (fCurrentPlotView == FOURIER_PLOT_PHASE_OPT_REAL) {
|
||||
if (fFourierHistos[0].dataFourierPhaseOptReal == 0) { // not yet calculated
|
||||
CalcPhaseOptReal();
|
||||
}
|
||||
}
|
||||
|
||||
fFourierPad->cd();
|
||||
|
||||
Double_t xmin=0, xmax=0;
|
||||
@ -1660,6 +1773,11 @@ void PFourierCanvas::PlotAverage()
|
||||
fFourierAverage[0].dataFourierPhase->Draw("p");
|
||||
break;
|
||||
case FOURIER_PLOT_PHASE_OPT_REAL:
|
||||
if (fFourierHistos[0].dataFourierPhaseOptReal == 0) {
|
||||
cout << "debug> need to calculate phase opt. average first ..." << endl;
|
||||
CalcPhaseOptReal();
|
||||
HandleAverage();
|
||||
}
|
||||
fFourierAverage[0].dataFourierPhaseOptReal->GetXaxis()->SetRangeUser(xmin, xmax);
|
||||
ymin = GetMinimum(fFourierAverage[0].dataFourierPhaseOptReal, xmin, xmax);
|
||||
ymax = GetMaximum(fFourierAverage[0].dataFourierPhaseOptReal, xmin, xmax);
|
||||
|
@ -827,13 +827,7 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
|
||||
fout << left << "lifetime";
|
||||
fout << fRuns[runNo].GetLifetimeParamNo() << endl;
|
||||
} else if (sstr.BeginsWith("lifetimecorrection")) {
|
||||
/* obsolate, hence do nothing here
|
||||
if ((fRuns[runNo].IsLifetimeCorrected()) &&
|
||||
((fRuns[runNo].GetFitType() == MSR_FITTYPE_SINGLE_HISTO) ||
|
||||
(fGlobal.GetFitType() == MSR_FITTYPE_SINGLE_HISTO))) {
|
||||
fout << "lifetimecorrection" << endl;
|
||||
}
|
||||
*/
|
||||
// obsolate, hence do nothing here
|
||||
} else if (sstr.BeginsWith("map")) {
|
||||
fout << "map ";
|
||||
for (UInt_t j=0; j<fRuns[runNo].GetMap()->size(); j++) {
|
||||
@ -1115,8 +1109,10 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
|
||||
fout << "POWER";
|
||||
} else if (fFourier.fPlotTag == FOURIER_PLOT_PHASE) {
|
||||
fout << "PHASE";
|
||||
} else if (fFourier.fPlotTag == FOURIER_PLOT_PHASE_OPT_REAL) {
|
||||
fout << "PHASE_OPT_REAL";
|
||||
}
|
||||
fout << " # REAL, IMAG, REAL_AND_IMAG, POWER, PHASE";
|
||||
fout << " # REAL, IMAG, REAL_AND_IMAG, POWER, PHASE, PHASE_OPT_REAL";
|
||||
fout << endl;
|
||||
} else if (sstr.BeginsWith("phase")) {
|
||||
if (fFourier.fPhaseParamNo > 0) {
|
||||
@ -1215,38 +1211,38 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
|
||||
if (fStatistic.fValid) { // valid fit result
|
||||
if (fStatistic.fChisq) {
|
||||
str.Form(" chisq = %.1lf, NDF = %d, chisq/NDF = %lf", fStatistic.fMin, fStatistic.fNdf, fStatistic.fMin / fStatistic.fNdf);
|
||||
fout << str.Data() << endl;
|
||||
} else {
|
||||
str.Form(" maxLH = %.1lf, NDF = %d, maxLH/NDF = %lf", fStatistic.fMin, fStatistic.fNdf, fStatistic.fMin / fStatistic.fNdf);
|
||||
}
|
||||
fout << str.Data() << endl;
|
||||
if (messages)
|
||||
cout << endl << str.Data() << endl;
|
||||
|
||||
// check if expected chisq needs to be written
|
||||
if (fStatistic.fMinExpected != 0.0) {
|
||||
if (fStatistic.fChisq) {
|
||||
str.Form(" expected chisq = %.1lf, NDF = %d, expected chisq/NDF = %lf",
|
||||
fStatistic.fMinExpected, fStatistic.fNdf, fStatistic.fMinExpected/fStatistic.fNdf);
|
||||
} else {
|
||||
str.Form(" expected maxLH = %.1lf, NDF = %d, expected maxLH/NDF = %lf",
|
||||
fStatistic.fMinExpected, fStatistic.fNdf, fStatistic.fMinExpected/fStatistic.fNdf);
|
||||
}
|
||||
if (fStartupOptions) {
|
||||
if (fStartupOptions->writeExpectedChisq)
|
||||
fout << str.Data() << endl;
|
||||
}
|
||||
if (messages)
|
||||
cout << endl << str.Data() << endl;
|
||||
|
||||
// check if expected chisq needs to be written
|
||||
if (fStatistic.fMinExpected != 0.0) {
|
||||
str.Form(" expected chisq = %.1lf, NDF = %d, expected chisq/NDF = %lf",
|
||||
fStatistic.fMinExpected, fStatistic.fNdf, fStatistic.fMinExpected/fStatistic.fNdf);
|
||||
if (fStartupOptions) {
|
||||
if (fStartupOptions->writeExpectedChisq)
|
||||
fout << str.Data() << endl;
|
||||
}
|
||||
if (messages)
|
||||
cout << endl << str.Data() << endl;
|
||||
|
||||
for (UInt_t i=0; i<fStatistic.fMinExpectedPerHisto.size(); i++) {
|
||||
if (fStatistic.fNdfPerHisto[i] > 0) {
|
||||
for (UInt_t i=0; i<fStatistic.fMinExpectedPerHisto.size(); i++) {
|
||||
if (fStatistic.fNdfPerHisto[i] > 0) {
|
||||
if (fStatistic.fChisq) {
|
||||
str.Form(" run block %d: (NDF/red.chisq/red.chisq_e) = (%d/%lf/%lf)",
|
||||
i+1, fStatistic.fNdfPerHisto[i], fStatistic.fMinPerHisto[i]/fStatistic.fNdfPerHisto[i], fStatistic.fMinExpectedPerHisto[i]/fStatistic.fNdfPerHisto[i]);
|
||||
if (fStartupOptions) {
|
||||
if (fStartupOptions->writeExpectedChisq)
|
||||
fout << str.Data() << endl;
|
||||
}
|
||||
|
||||
if (messages)
|
||||
cout << str.Data() << endl;
|
||||
} else {
|
||||
str.Form(" run block %d: (NDF/red.maxLH/red.maxLH_e) = (%d/%lf/%lf)",
|
||||
i+1, fStatistic.fNdfPerHisto[i], fStatistic.fMinPerHisto[i]/fStatistic.fNdfPerHisto[i], fStatistic.fMinExpectedPerHisto[i]/fStatistic.fNdfPerHisto[i]);
|
||||
}
|
||||
}
|
||||
} else if (fStatistic.fNdfPerHisto.size() > 1) { // check if per run chisq needs to be written
|
||||
for (UInt_t i=0; i<fStatistic.fNdfPerHisto.size(); i++) {
|
||||
str.Form(" run block %d: (NDF/red.chisq) = (%d/%lf)",
|
||||
i+1, fStatistic.fNdfPerHisto[i], fStatistic.fMinPerHisto[i]/fStatistic.fNdfPerHisto[i]);
|
||||
if (fStartupOptions) {
|
||||
if (fStartupOptions->writeExpectedChisq)
|
||||
fout << str.Data() << endl;
|
||||
@ -1256,11 +1252,23 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
|
||||
cout << str.Data() << endl;
|
||||
}
|
||||
}
|
||||
} else { // maxLH
|
||||
str.Form(" maxLH = %.1lf, NDF = %d, maxLH/NDF = %lf", fStatistic.fMin, fStatistic.fNdf, fStatistic.fMin / fStatistic.fNdf);
|
||||
fout << str.Data() << endl;
|
||||
if (messages)
|
||||
cout << endl << str.Data() << endl;
|
||||
} else if (fStatistic.fNdfPerHisto.size() > 1) { // check if per run chisq needs to be written
|
||||
for (UInt_t i=0; i<fStatistic.fNdfPerHisto.size(); i++) {
|
||||
if (fStatistic.fChisq) {
|
||||
str.Form(" run block %d: (NDF/red.chisq) = (%d/%lf)",
|
||||
i+1, fStatistic.fNdfPerHisto[i], fStatistic.fMinPerHisto[i]/fStatistic.fNdfPerHisto[i]);
|
||||
} else {
|
||||
str.Form(" run block %d: (NDF/maxLH.chisq) = (%d/%lf)",
|
||||
i+1, fStatistic.fNdfPerHisto[i], fStatistic.fMinPerHisto[i]/fStatistic.fNdfPerHisto[i]);
|
||||
}
|
||||
if (fStartupOptions) {
|
||||
if (fStartupOptions->writeExpectedChisq)
|
||||
fout << str.Data() << endl;
|
||||
}
|
||||
|
||||
if (messages)
|
||||
cout << str.Data() << endl;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fout << "*** FIT DID NOT CONVERGE ***" << endl;
|
||||
@ -1272,38 +1280,38 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
|
||||
if (fStatistic.fValid) { // valid fit result
|
||||
if (fStatistic.fChisq) { // chisq
|
||||
str.Form(" chisq = %.1lf, NDF = %d, chisq/NDF = %lf", fStatistic.fMin, fStatistic.fNdf, fStatistic.fMin / fStatistic.fNdf);
|
||||
fout << str.Data() << endl;
|
||||
if (messages)
|
||||
cout << endl << str.Data() << endl;
|
||||
} else {
|
||||
str.Form(" maxLH = %.1lf, NDF = %d, maxLH/NDF = %lf", fStatistic.fMin, fStatistic.fNdf, fStatistic.fMin / fStatistic.fNdf);
|
||||
}
|
||||
fout << str.Data() << endl;
|
||||
if (messages)
|
||||
cout << endl << str.Data() << endl;
|
||||
|
||||
// check if expected chisq needs to be written
|
||||
if (fStatistic.fMinExpected != 0.0) {
|
||||
// check if expected chisq needs to be written
|
||||
if (fStatistic.fMinExpected != 0.0) {
|
||||
if (fStatistic.fChisq) { // chisq
|
||||
str.Form(" expected chisq = %.1lf, NDF = %d, expected chisq/NDF = %lf",
|
||||
fStatistic.fMinExpected, fStatistic.fNdf, fStatistic.fMinExpected/fStatistic.fNdf);
|
||||
if (fStartupOptions) {
|
||||
if (fStartupOptions->writeExpectedChisq)
|
||||
fout << str.Data() << endl;
|
||||
}
|
||||
if (messages)
|
||||
cout << str.Data() << endl;
|
||||
} else {
|
||||
str.Form(" expected maxLH = %.1lf, NDF = %d, expected maxLH/NDF = %lf",
|
||||
fStatistic.fMinExpected, fStatistic.fNdf, fStatistic.fMinExpected/fStatistic.fNdf);
|
||||
}
|
||||
if (fStartupOptions) {
|
||||
if (fStartupOptions->writeExpectedChisq)
|
||||
fout << str.Data() << endl;
|
||||
}
|
||||
if (messages)
|
||||
cout << str.Data() << endl;
|
||||
|
||||
for (UInt_t i=0; i<fStatistic.fMinExpectedPerHisto.size(); i++) {
|
||||
if (fStatistic.fNdfPerHisto[i] > 0) {
|
||||
for (UInt_t i=0; i<fStatistic.fMinExpectedPerHisto.size(); i++) {
|
||||
if (fStatistic.fNdfPerHisto[i] > 0) {
|
||||
if (fStatistic.fChisq) { // chisq
|
||||
str.Form(" run block %d: (NDF/red.chisq/red.chisq_e) = (%d/%lf/%lf)",
|
||||
i+1, fStatistic.fNdfPerHisto[i], fStatistic.fMinPerHisto[i]/fStatistic.fNdfPerHisto[i], fStatistic.fMinExpectedPerHisto[i]/fStatistic.fNdfPerHisto[i]);
|
||||
if (fStartupOptions) {
|
||||
if (fStartupOptions->writeExpectedChisq)
|
||||
fout << str.Data() << endl;
|
||||
}
|
||||
|
||||
if (messages)
|
||||
cout << str.Data() << endl;
|
||||
} else {
|
||||
str.Form(" run block %d: (NDF/red.maxLH/red.maxLH_e) = (%d/%lf/%lf)",
|
||||
i+1, fStatistic.fNdfPerHisto[i], fStatistic.fMinPerHisto[i]/fStatistic.fNdfPerHisto[i], fStatistic.fMinExpectedPerHisto[i]/fStatistic.fNdfPerHisto[i]);
|
||||
}
|
||||
}
|
||||
} else if (fStatistic.fNdfPerHisto.size() > 1) { // check if per run chisq needs to be written
|
||||
for (UInt_t i=0; i<fStatistic.fNdfPerHisto.size(); i++) {
|
||||
str.Form(" run block %d: (NDF/red.chisq) = (%d/%lf)",
|
||||
i+1, fStatistic.fNdfPerHisto[i], fStatistic.fMinPerHisto[i]/fStatistic.fNdfPerHisto[i]);
|
||||
if (fStartupOptions) {
|
||||
if (fStartupOptions->writeExpectedChisq)
|
||||
fout << str.Data() << endl;
|
||||
@ -1313,11 +1321,23 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
|
||||
cout << str.Data() << endl;
|
||||
}
|
||||
}
|
||||
} else { // max. log. liklihood
|
||||
str.Form(" maxLH = %.1lf, NDF = %d, maxLH/NDF = %lf", fStatistic.fMin, fStatistic.fNdf, fStatistic.fMin / fStatistic.fNdf);
|
||||
fout << str.Data() << endl;
|
||||
if (messages)
|
||||
cout << endl << str.Data() << endl;
|
||||
} else if (fStatistic.fNdfPerHisto.size() > 1) { // check if per run chisq needs to be written
|
||||
for (UInt_t i=0; i<fStatistic.fNdfPerHisto.size(); i++) {
|
||||
if (fStatistic.fChisq) { // chisq
|
||||
str.Form(" run block %d: (NDF/red.chisq) = (%d/%lf)",
|
||||
i+1, fStatistic.fNdfPerHisto[i], fStatistic.fMinPerHisto[i]/fStatistic.fNdfPerHisto[i]);
|
||||
} else {
|
||||
str.Form(" run block %d: (NDF/red.maxLH) = (%d/%lf)",
|
||||
i+1, fStatistic.fNdfPerHisto[i], fStatistic.fMinPerHisto[i]/fStatistic.fNdfPerHisto[i]);
|
||||
}
|
||||
if (fStartupOptions) {
|
||||
if (fStartupOptions->writeExpectedChisq)
|
||||
fout << str.Data() << endl;
|
||||
}
|
||||
|
||||
if (messages)
|
||||
cout << str.Data() << endl;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fout << "*** FIT DID NOT CONVERGE ***" << endl;
|
||||
@ -1328,7 +1348,7 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
|
||||
if (str.Length() > 0) {
|
||||
sstr = str;
|
||||
sstr.Remove(TString::kLeading, ' ');
|
||||
if (!sstr.BeginsWith("expected chisq") && !sstr.BeginsWith("run block"))
|
||||
if (!sstr.BeginsWith("expected chisq") && !sstr.BeginsWith("expected maxLH") && !sstr.BeginsWith("run block"))
|
||||
fout << str.Data() << endl;
|
||||
} else { // only write endl if not eof is reached. This is preventing growing msr-files, i.e. more and more empty lines at the end of the file
|
||||
if (!fin.eof())
|
||||
@ -1351,38 +1371,38 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
|
||||
if (fStatistic.fValid) { // valid fit result
|
||||
if (fStatistic.fChisq) {
|
||||
str.Form(" chisq = %.1lf, NDF = %d, chisq/NDF = %lf", fStatistic.fMin, fStatistic.fNdf, fStatistic.fMin / fStatistic.fNdf);
|
||||
fout << str.Data() << endl;
|
||||
if (messages)
|
||||
cout << endl << str.Data() << endl;
|
||||
} else {
|
||||
str.Form(" maxLH = %.1lf, NDF = %d, maxLH/NDF = %lf", fStatistic.fMin, fStatistic.fNdf, fStatistic.fMin / fStatistic.fNdf);
|
||||
}
|
||||
fout << str.Data() << endl;
|
||||
if (messages)
|
||||
cout << endl << str.Data() << endl;
|
||||
|
||||
// check if expected chisq needs to be written
|
||||
if (fStatistic.fMinExpected != 0.0) {
|
||||
// check if expected chisq needs to be written
|
||||
if (fStatistic.fMinExpected != 0.0) {
|
||||
if (fStatistic.fChisq) {
|
||||
str.Form(" expected chisq = %.1lf, NDF = %d, expected chisq/NDF = %lf",
|
||||
fStatistic.fMinExpected, fStatistic.fNdf, fStatistic.fMinExpected/fStatistic.fNdf);
|
||||
if (fStartupOptions) {
|
||||
if (fStartupOptions->writeExpectedChisq)
|
||||
fout << str.Data() << endl;
|
||||
}
|
||||
if (messages)
|
||||
cout << str.Data() << endl;
|
||||
} else {
|
||||
str.Form(" expected maxLH = %.1lf, NDF = %d, expected maxLH/NDF = %lf",
|
||||
fStatistic.fMinExpected, fStatistic.fNdf, fStatistic.fMinExpected/fStatistic.fNdf);
|
||||
}
|
||||
if (fStartupOptions) {
|
||||
if (fStartupOptions->writeExpectedChisq)
|
||||
fout << str.Data() << endl;
|
||||
}
|
||||
if (messages)
|
||||
cout << str.Data() << endl;
|
||||
|
||||
for (UInt_t i=0; i<fStatistic.fMinExpectedPerHisto.size(); i++) {
|
||||
if (fStatistic.fNdfPerHisto[i] > 0) {
|
||||
for (UInt_t i=0; i<fStatistic.fMinExpectedPerHisto.size(); i++) {
|
||||
if (fStatistic.fNdfPerHisto[i] > 0) {
|
||||
if (fStatistic.fChisq) {
|
||||
str.Form(" run block %d: (NDF/red.chisq/red.chisq_e) = (%d/%lf/%lf)",
|
||||
i+1, fStatistic.fNdfPerHisto[i], fStatistic.fMinPerHisto[i]/fStatistic.fNdfPerHisto[i], fStatistic.fMinExpectedPerHisto[i]/fStatistic.fNdfPerHisto[i]);
|
||||
if (fStartupOptions) {
|
||||
if (fStartupOptions->writeExpectedChisq)
|
||||
fout << str.Data() << endl;
|
||||
}
|
||||
|
||||
if (messages)
|
||||
cout << str.Data() << endl;
|
||||
} else {
|
||||
str.Form(" run block %d: (NDF/red.maxLH/red.maxLH_e) = (%d/%lf/%lf)",
|
||||
i+1, fStatistic.fNdfPerHisto[i], fStatistic.fMinPerHisto[i]/fStatistic.fNdfPerHisto[i], fStatistic.fMinExpectedPerHisto[i]/fStatistic.fNdfPerHisto[i]);
|
||||
}
|
||||
}
|
||||
} else if (fStatistic.fNdfPerHisto.size() > 1) { // check if per run chisq needs to be written
|
||||
for (UInt_t i=0; i<fStatistic.fNdfPerHisto.size(); i++) {
|
||||
str.Form(" run block %d: (NDF/red.chisq) = (%d/%lf)",
|
||||
i+1, fStatistic.fNdfPerHisto[i], fStatistic.fMinPerHisto[i]/fStatistic.fNdfPerHisto[i]);
|
||||
if (fStartupOptions) {
|
||||
if (fStartupOptions->writeExpectedChisq)
|
||||
fout << str.Data() << endl;
|
||||
@ -1392,13 +1412,23 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
|
||||
cout << str.Data() << endl;
|
||||
}
|
||||
}
|
||||
} else { // maxLH
|
||||
str.Form(" maxLH = %.1lf, NDF = %d, maxLH/NDF = %lf", fStatistic.fMin, fStatistic.fNdf, fStatistic.fMin / fStatistic.fNdf);
|
||||
fout << str.Data() << endl;
|
||||
if (messages)
|
||||
cout << endl << str.Data() << endl;
|
||||
} else if (fStatistic.fNdfPerHisto.size() > 1) { // check if per run chisq needs to be written
|
||||
for (UInt_t i=0; i<fStatistic.fNdfPerHisto.size(); i++) {
|
||||
if (fStatistic.fChisq) {
|
||||
str.Form(" run block %d: (NDF/red.chisq) = (%d/%lf)",
|
||||
i+1, fStatistic.fNdfPerHisto[i], fStatistic.fMinPerHisto[i]/fStatistic.fNdfPerHisto[i]);
|
||||
} else {
|
||||
str.Form(" run block %d: (NDF/red.maxLH) = (%d/%lf)",
|
||||
i+1, fStatistic.fNdfPerHisto[i], fStatistic.fMinPerHisto[i]/fStatistic.fNdfPerHisto[i]);
|
||||
}
|
||||
if (fStartupOptions) {
|
||||
if (fStartupOptions->writeExpectedChisq)
|
||||
fout << str.Data() << endl;
|
||||
}
|
||||
|
||||
// check if per run block maxLH needs to be written
|
||||
if (messages)
|
||||
cout << str.Data() << endl;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fout << "*** FIT DID NOT CONVERGE ***" << endl;
|
||||
@ -1416,38 +1446,38 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
|
||||
if (fStatistic.fValid) { // valid fit result
|
||||
if (fStatistic.fChisq) { // chisq
|
||||
str.Form(" chisq = %.1lf, NDF = %d, chisq/NDF = %lf", fStatistic.fMin, fStatistic.fNdf, fStatistic.fMin / fStatistic.fNdf);
|
||||
fout << str.Data() << endl;
|
||||
if (messages)
|
||||
cout << endl << str.Data() << endl;
|
||||
} else {
|
||||
str.Form(" maxLH = %.1lf, NDF = %d, maxLH/NDF = %lf", fStatistic.fMin, fStatistic.fNdf, fStatistic.fMin / fStatistic.fNdf);
|
||||
}
|
||||
fout << str.Data() << endl;
|
||||
if (messages)
|
||||
cout << endl << str.Data() << endl;
|
||||
|
||||
// check if expected chisq needs to be written
|
||||
if (fStatistic.fMinExpected != 0.0) {
|
||||
// check if expected chisq needs to be written
|
||||
if (fStatistic.fMinExpected != 0.0) {
|
||||
if (fStatistic.fChisq) { // chisq
|
||||
str.Form(" expected chisq = %.1lf, NDF = %d, expected chisq/NDF = %lf",
|
||||
fStatistic.fMinExpected, fStatistic.fNdf, fStatistic.fMinExpected/fStatistic.fNdf);
|
||||
if (fStartupOptions) {
|
||||
if (fStartupOptions->writeExpectedChisq)
|
||||
fout << str.Data() << endl;
|
||||
}
|
||||
if (messages)
|
||||
cout << str.Data() << endl;
|
||||
} else {
|
||||
str.Form(" expected maxLH = %.1lf, NDF = %d, expected maxLH/NDF = %lf",
|
||||
fStatistic.fMinExpected, fStatistic.fNdf, fStatistic.fMinExpected/fStatistic.fNdf);
|
||||
}
|
||||
if (fStartupOptions) {
|
||||
if (fStartupOptions->writeExpectedChisq)
|
||||
fout << str.Data() << endl;
|
||||
}
|
||||
if (messages)
|
||||
cout << str.Data() << endl;
|
||||
|
||||
for (UInt_t i=0; i<fStatistic.fMinExpectedPerHisto.size(); i++) {
|
||||
if (fStatistic.fNdfPerHisto[i] > 0) {
|
||||
for (UInt_t i=0; i<fStatistic.fMinExpectedPerHisto.size(); i++) {
|
||||
if (fStatistic.fNdfPerHisto[i] > 0) {
|
||||
if (fStatistic.fChisq) { // chisq
|
||||
str.Form(" run block %d: (NDF/red.chisq/red.chisq_e) =(%d/%lf/%lf)",
|
||||
i+1, fStatistic.fNdfPerHisto[i], fStatistic.fMinExpectedPerHisto[i]/fStatistic.fNdfPerHisto[i], fStatistic.fMinExpectedPerHisto[i]/fStatistic.fNdfPerHisto[i]);
|
||||
if (fStartupOptions) {
|
||||
if (fStartupOptions->writeExpectedChisq)
|
||||
fout << str.Data() << endl;
|
||||
}
|
||||
|
||||
if (messages)
|
||||
cout << str.Data() << endl;
|
||||
} else {
|
||||
str.Form(" run block %d: (NDF/red.maxLH/red.maxLH_e) =(%d/%lf/%lf)",
|
||||
i+1, fStatistic.fNdfPerHisto[i], fStatistic.fMinExpectedPerHisto[i]/fStatistic.fNdfPerHisto[i], fStatistic.fMinExpectedPerHisto[i]/fStatistic.fNdfPerHisto[i]);
|
||||
}
|
||||
}
|
||||
} else if (fStatistic.fNdfPerHisto.size() > 1) { // check if per run chisq needs to be written
|
||||
for (UInt_t i=0; i<fStatistic.fNdfPerHisto.size(); i++) {
|
||||
str.Form(" run block %d: (NDF/red.chisq) = (%d/%lf)",
|
||||
i+1, fStatistic.fNdfPerHisto[i], fStatistic.fMinPerHisto[i]/fStatistic.fNdfPerHisto[i]);
|
||||
if (fStartupOptions) {
|
||||
if (fStartupOptions->writeExpectedChisq)
|
||||
fout << str.Data() << endl;
|
||||
@ -1457,11 +1487,23 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
|
||||
cout << str.Data() << endl;
|
||||
}
|
||||
}
|
||||
} else { // max. log. liklihood
|
||||
str.Form(" maxLH = %.1lf, NDF = %d, maxLH/NDF = %lf", fStatistic.fMin, fStatistic.fNdf, fStatistic.fMin / fStatistic.fNdf);
|
||||
fout << str.Data() << endl;
|
||||
if (messages)
|
||||
cout << endl << str.Data() << endl;
|
||||
} else if (fStatistic.fNdfPerHisto.size() > 1) { // check if per run chisq needs to be written
|
||||
for (UInt_t i=0; i<fStatistic.fNdfPerHisto.size(); i++) {
|
||||
if (fStatistic.fChisq) { // chisq
|
||||
str.Form(" run block %d: (NDF/red.chisq) = (%d/%lf)",
|
||||
i+1, fStatistic.fNdfPerHisto[i], fStatistic.fMinPerHisto[i]/fStatistic.fNdfPerHisto[i]);
|
||||
} else {
|
||||
str.Form(" run block %d: (NDF/red.maxLH) = (%d/%lf)",
|
||||
i+1, fStatistic.fNdfPerHisto[i], fStatistic.fMinPerHisto[i]/fStatistic.fNdfPerHisto[i]);
|
||||
}
|
||||
if (fStartupOptions) {
|
||||
if (fStartupOptions->writeExpectedChisq)
|
||||
fout << str.Data() << endl;
|
||||
}
|
||||
|
||||
if (messages)
|
||||
cout << str.Data() << endl;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fout << "*** FIT DID NOT CONVERGE (4) ***" << endl;
|
||||
@ -2148,8 +2190,10 @@ Int_t PMsrHandler::WriteMsrFile(const Char_t *filename, map<UInt_t, TString> *co
|
||||
fout << "POWER";
|
||||
} else if (fFourier.fPlotTag == FOURIER_PLOT_PHASE) {
|
||||
fout << "PHASE";
|
||||
} else if (fFourier.fPlotTag == FOURIER_PLOT_PHASE_OPT_REAL) {
|
||||
fout << "PHASE_OPT_REAL";
|
||||
}
|
||||
fout << " # REAL, IMAG, REAL_AND_IMAG, POWER, PHASE";
|
||||
fout << " # REAL, IMAG, REAL_AND_IMAG, POWER, PHASE, PHASE_OPT_REAL";
|
||||
fout << endl;
|
||||
}
|
||||
|
||||
@ -3846,7 +3890,7 @@ Bool_t PMsrHandler::HandleFourierEntry(PMsrLines &lines)
|
||||
|
||||
TObjArray *tokens = 0;
|
||||
TObjString *ostr = 0;
|
||||
TString str;
|
||||
TString str, pcStr=TString("");
|
||||
|
||||
Int_t ival;
|
||||
|
||||
@ -3953,6 +3997,8 @@ Bool_t PMsrHandler::HandleFourierEntry(PMsrLines &lines)
|
||||
fourier.fPlotTag = FOURIER_PLOT_POWER;
|
||||
} else if (!str.CompareTo("phase", TString::kIgnoreCase)) {
|
||||
fourier.fPlotTag = FOURIER_PLOT_PHASE;
|
||||
} else if (!str.CompareTo("phase_opt_real", TString::kIgnoreCase)) {
|
||||
fourier.fPlotTag = FOURIER_PLOT_PHASE_OPT_REAL;
|
||||
} else { // unrecognized plot tag
|
||||
error = true;
|
||||
continue;
|
||||
@ -3995,21 +4041,10 @@ Bool_t PMsrHandler::HandleFourierEntry(PMsrLines &lines)
|
||||
}
|
||||
}
|
||||
} else if (iter->fLine.BeginsWith("range_for_phase_correction", TString::kIgnoreCase)) {
|
||||
if (tokens->GetEntries() < 3) { // range values are missing
|
||||
error = true;
|
||||
continue;
|
||||
} else {
|
||||
for (UInt_t i=0; i<2; i++) {
|
||||
ostr = dynamic_cast<TObjString*>(tokens->At(i+1));
|
||||
str = ostr->GetString();
|
||||
if (str.IsFloat()) {
|
||||
fourier.fRangeForPhaseCorrection[i] = str.Atof();
|
||||
} else {
|
||||
error = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
// keep the string. It can only be handled at the very end of the FOURIER block evaluation
|
||||
// since it needs potentially the range input and there is no guaranty this is already
|
||||
// available at this point.
|
||||
pcStr = iter->fLine;
|
||||
} else if (iter->fLine.BeginsWith("range", TString::kIgnoreCase)) { // fourier plot range
|
||||
if (tokens->GetEntries() < 3) { // plot range values are missing
|
||||
error = true;
|
||||
@ -4047,6 +4082,45 @@ Bool_t PMsrHandler::HandleFourierEntry(PMsrLines &lines)
|
||||
tokens = 0;
|
||||
}
|
||||
|
||||
// handle range_for_phase_correction if present
|
||||
if ((pcStr.Length() != 0) && !error) {
|
||||
// tokenize line
|
||||
tokens = pcStr.Tokenize(" \t");
|
||||
|
||||
switch (tokens->GetEntries()) {
|
||||
case 2:
|
||||
ostr = dynamic_cast<TObjString*>(tokens->At(1));
|
||||
str = ostr->GetString();
|
||||
if (!str.CompareTo("all", TString::kIgnoreCase)) {
|
||||
fourier.fRangeForPhaseCorrection[0] = fourier.fPlotRange[0];
|
||||
fourier.fRangeForPhaseCorrection[1] = fourier.fPlotRange[1];
|
||||
} else {
|
||||
error = true;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
for (UInt_t i=0; i<2; i++) {
|
||||
ostr = dynamic_cast<TObjString*>(tokens->At(i+1));
|
||||
str = ostr->GetString();
|
||||
if (str.IsFloat()) {
|
||||
fourier.fRangeForPhaseCorrection[i] = str.Atof();
|
||||
} else {
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
error = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// clean up
|
||||
if (tokens) {
|
||||
delete tokens;
|
||||
tokens = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (error) {
|
||||
cerr << endl << ">> PMsrHandler::HandleFourierEntry: **ERROR** in line " << iter->fLineNo << ":";
|
||||
cerr << endl;
|
||||
@ -4061,9 +4135,9 @@ Bool_t PMsrHandler::HandleFourierEntry(PMsrLines &lines)
|
||||
cerr << endl << ">> 0 <= n <= 20 are allowed values";
|
||||
cerr << endl << ">> [dc-corrected true | false]";
|
||||
cerr << endl << ">> [apodization none | weak | medium | strong]";
|
||||
cerr << endl << ">> [plot real | imag | real_and_imag | power | phase]";
|
||||
cerr << endl << ">> [plot real | imag | real_and_imag | power | phase | phase_opt_real]";
|
||||
cerr << endl << ">> [phase value]";
|
||||
cerr << endl << ">> [range_for_phase_correction min max]";
|
||||
cerr << endl << ">> [range_for_phase_correction min max | all]";
|
||||
cerr << endl << ">> [range min max]";
|
||||
cerr << endl;
|
||||
} else { // save last run found
|
||||
@ -4643,7 +4717,8 @@ Bool_t PMsrHandler::HandleStatisticEntry(PMsrLines &lines)
|
||||
if (tstr.Length() > 0) {
|
||||
if (!tstr.BeginsWith("#") && !tstr.BeginsWith("STATISTIC") && !tstr.BeginsWith("chisq") &&
|
||||
!tstr.BeginsWith("maxLH") && !tstr.BeginsWith("*** FIT DID NOT CONVERGE ***") &&
|
||||
!tstr.BeginsWith("expected chisq") && !tstr.BeginsWith("run block")) {
|
||||
!tstr.BeginsWith("expected chisq") && !tstr.BeginsWith("expected maxLH") &&
|
||||
!tstr.BeginsWith("run block")) {
|
||||
cerr << endl << ">> PMsrHandler::HandleStatisticEntry: **SYNTAX ERROR** in line " << lines[i].fLineNo;
|
||||
cerr << endl << ">> '" << lines[i].fLine.Data() << "'";
|
||||
cerr << endl << ">> not a valid STATISTIC block line";
|
||||
@ -6033,20 +6108,6 @@ Bool_t PMsrHandler::EstimateN0()
|
||||
return fStartupOptions->estimateN0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// GetAlphaEstimateN0 (public)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>returns alpha to estimate N0
|
||||
*/
|
||||
Double_t PMsrHandler::GetAlphaEstimateN0()
|
||||
{
|
||||
if (fStartupOptions == 0)
|
||||
return 0.0;
|
||||
|
||||
return fStartupOptions->alphaEstimateN0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// GetDKSTheoryString (public)
|
||||
//--------------------------------------------------------------------------
|
||||
|
@ -184,11 +184,14 @@ PMusrCanvas::PMusrCanvas()
|
||||
* \param wh height (in pixels) of the canvas.
|
||||
* \param batch flag: if set true, the canvas will not be displayed. This is used when just dumping of a
|
||||
* graphical output file is wished.
|
||||
* \param fourier flag: if set true, the canvas will present the Fourier view.
|
||||
* \param avg flag: if set true, the canvas will present the averages data/Fourier view.
|
||||
*/
|
||||
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, const Bool_t fourier, const Bool_t useDKS) :
|
||||
fStartWithFourier(fourier), fUseDKS(useDKS), fBatchMode(batch), fPlotNumber(number)
|
||||
const Bool_t batch, const Bool_t fourier, const Bool_t avg, const Bool_t useDKS) :
|
||||
fStartWithFourier(fourier), fStartWithAvg(avg), fUseDKS(useDKS),
|
||||
fBatchMode(batch), fPlotNumber(number)
|
||||
{
|
||||
fTimeout = 0;
|
||||
fTimeoutTimer = 0;
|
||||
@ -237,15 +240,17 @@ PMusrCanvas::PMusrCanvas(const Int_t number, const Char_t* title,
|
||||
* \param colorList pre-defined list of colors
|
||||
* \param batch flag: if set true, the canvas will not be displayed. This is used when just dumping of a
|
||||
* graphical output file is wished.
|
||||
* \param fourier flag: if set true, the canvas will present the Fourier view.
|
||||
* \param avg flag: if set true, the canvas will present the averages data/Fourier view.
|
||||
*/
|
||||
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, const Bool_t fourier, const Bool_t useDKS) :
|
||||
fStartWithFourier(fourier), fUseDKS(useDKS), fBatchMode(batch),
|
||||
fPlotNumber(number), fFourier(fourierDefault),
|
||||
fMarkerList(markerList), fColorList(colorList)
|
||||
const Bool_t batch, const Bool_t fourier, const Bool_t avg, const Bool_t useDKS) :
|
||||
fStartWithFourier(fourier), fStartWithAvg(avg), fUseDKS(useDKS),
|
||||
fBatchMode(batch), fPlotNumber(number), fFourier(fourierDefault),
|
||||
fMarkerList(markerList), fColorList(colorList)
|
||||
{
|
||||
fTimeout = 0;
|
||||
fTimeoutTimer = 0;
|
||||
@ -817,6 +822,12 @@ void PMusrCanvas::UpdateDataTheoryPad()
|
||||
fPopupFourier->CheckEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE);
|
||||
}
|
||||
break;
|
||||
case FOURIER_PLOT_PHASE_OPT_REAL:
|
||||
fCurrentPlotView = PV_FOURIER_PHASE_OPT_REAL;
|
||||
if (!fBatchMode) {
|
||||
fPopupFourier->CheckEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_OPT_REAL);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
fCurrentPlotView = PV_FOURIER_PWR;
|
||||
if (!fBatchMode) {
|
||||
@ -828,6 +839,12 @@ void PMusrCanvas::UpdateDataTheoryPad()
|
||||
HandleFourier();
|
||||
PlotFourier();
|
||||
}
|
||||
|
||||
// if fStartWithAvg=true, start with averaged data/Fourier representation
|
||||
// fStartWithAvg is given at the command line level
|
||||
if (fStartWithAvg) {
|
||||
HandleCmdKey(kKeyPress, (Int_t)'a', 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@ -1098,6 +1115,11 @@ void PMusrCanvas::HandleCmdKey(Int_t event, Int_t x, Int_t y, TObject *selected)
|
||||
fCurrentPlotView = PV_FOURIER_PHASE;
|
||||
fPopupFourier->CheckEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE);
|
||||
break;
|
||||
case FOURIER_PLOT_PHASE_OPT_REAL:
|
||||
fPreviousPlotView = fCurrentPlotView;
|
||||
fCurrentPlotView = PV_FOURIER_PHASE_OPT_REAL;
|
||||
fPopupFourier->CheckEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_OPT_REAL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -1144,10 +1166,13 @@ void PMusrCanvas::HandleCmdKey(Int_t event, Int_t x, Int_t y, TObject *selected)
|
||||
}
|
||||
} else if (x == 'c') {
|
||||
Int_t state = fDataTheoryPad->GetCrosshair();
|
||||
if (state == 0)
|
||||
if (state == 0) {
|
||||
fMainCanvas->ToggleEventStatus();
|
||||
fDataTheoryPad->SetCrosshair(2);
|
||||
else
|
||||
} else {
|
||||
fMainCanvas->ToggleEventStatus();
|
||||
fDataTheoryPad->SetCrosshair(0);
|
||||
}
|
||||
fMainCanvas->Update();
|
||||
} else {
|
||||
fMainCanvas->Update();
|
||||
@ -1341,6 +1366,36 @@ void PMusrCanvas::HandleMenuPopup(Int_t id)
|
||||
HandleFourierDifference();
|
||||
PlotFourierDifference();
|
||||
}
|
||||
} else if (id == P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_OPT_REAL) {
|
||||
// set appropriate plot view
|
||||
fPreviousPlotView = fCurrentPlotView;
|
||||
fCurrentPlotView = PV_FOURIER_PHASE_OPT_REAL;
|
||||
// make sure that phase opt. real indeed exists
|
||||
if (fData[0].dataFourierPhaseOptReal == 0) {
|
||||
if (fData[0].dataFourierRe == 0)
|
||||
HandleFourier();
|
||||
else
|
||||
CalcPhaseOptReFT();
|
||||
}
|
||||
// uncheck data
|
||||
fPopupMain->UnCheckEntry(P_MENU_ID_DATA+P_MENU_PLOT_OFFSET*fPlotNumber);
|
||||
// check appropriate fourier popup item
|
||||
fPopupFourier->UnCheckEntries();
|
||||
fPopupFourier->CheckEntry(id);
|
||||
// enable phase increment/decrement
|
||||
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);
|
||||
// handle fourier phase
|
||||
if (!fDifferenceView) {
|
||||
HandleFourier();
|
||||
PlotFourier();
|
||||
} else {
|
||||
if (previousPlotView == PV_DATA)
|
||||
HandleDifferenceFourier();
|
||||
else
|
||||
HandleFourierDifference();
|
||||
PlotFourierDifference();
|
||||
}
|
||||
} else if (id == P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_PLUS) {
|
||||
IncrementFourierPhase();
|
||||
} else if (id == P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_MINUS) {
|
||||
@ -1748,6 +1803,24 @@ void PMusrCanvas::ExportData(const Char_t *fileName)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PV_FOURIER_PHASE_OPT_REAL:
|
||||
// get current x-range
|
||||
xminBin = fData[0].dataFourierPhaseOptReal->GetXaxis()->GetFirst(); // first bin of the zoomed range
|
||||
xmaxBin = fData[0].dataFourierPhaseOptReal->GetXaxis()->GetLast(); // last bin of the zoomed range
|
||||
xmin = fData[0].dataFourierPhaseOptReal->GetXaxis()->GetBinCenter(xminBin);
|
||||
xmax = fData[0].dataFourierPhaseOptReal->GetXaxis()->GetBinCenter(xmaxBin);
|
||||
|
||||
// fill ascii dump data
|
||||
if (fAveragedView) {
|
||||
GetExportDataSet(fDataAvg.dataFourierPhaseOptReal, xmin, xmax, dumpVector, false);
|
||||
GetExportDataSet(fDataAvg.theoryFourierPhaseOptReal, xmin, xmax, dumpVector, false);
|
||||
} else { // go through all the histogramms
|
||||
for (UInt_t i=0; i<fData.size(); i++) {
|
||||
GetExportDataSet(fData[i].dataFourierPhaseOptReal, xmin, xmax, dumpVector, false);
|
||||
GetExportDataSet(fData[i].theoryFourierPhaseOptReal, xmin, xmax, dumpVector, false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -2239,16 +2312,19 @@ void PMusrCanvas::InitAverage()
|
||||
fDataAvg.dataFourierIm = 0;
|
||||
fDataAvg.dataFourierPwr = 0;
|
||||
fDataAvg.dataFourierPhase = 0;
|
||||
fDataAvg.dataFourierPhaseOptReal = 0;
|
||||
fDataAvg.theory = 0;
|
||||
fDataAvg.theoryFourierRe = 0;
|
||||
fDataAvg.theoryFourierIm = 0;
|
||||
fDataAvg.theoryFourierPwr = 0;
|
||||
fDataAvg.theoryFourierPhase = 0;
|
||||
fDataAvg.theoryFourierPhaseOptReal = 0;
|
||||
fDataAvg.diff = 0;
|
||||
fDataAvg.diffFourierRe = 0;
|
||||
fDataAvg.diffFourierIm = 0;
|
||||
fDataAvg.diffFourierPwr = 0;
|
||||
fDataAvg.diffFourierPhase = 0;
|
||||
fDataAvg.diffFourierPhaseOptReal = 0;
|
||||
fDataAvg.dataRange = 0;
|
||||
fDataAvg.diffFourierTag = 0;
|
||||
}
|
||||
@ -2314,6 +2390,7 @@ void PMusrCanvas::InitMusrCanvas(const Char_t* title, Int_t wtopx, Int_t wtopy,
|
||||
fPopupFourier->AddEntry("Show Real+Imag", P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_REAL_AND_IMAG);
|
||||
fPopupFourier->AddEntry("Show Power", P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PWR);
|
||||
fPopupFourier->AddEntry("Show Phase", P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE);
|
||||
fPopupFourier->AddEntry("Show PhaseOptReal", P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_OPT_REAL);
|
||||
fPopupFourier->AddSeparator();
|
||||
fPopupFourier->AddEntry("Phase +", P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_PLUS);
|
||||
fPopupFourier->AddEntry("Phase -", P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_MINUS);
|
||||
@ -2416,16 +2493,19 @@ void PMusrCanvas::InitDataSet(PMusrCanvasDataSet &dataSet)
|
||||
dataSet.dataFourierIm = 0;
|
||||
dataSet.dataFourierPwr = 0;
|
||||
dataSet.dataFourierPhase = 0;
|
||||
dataSet.dataFourierPhaseOptReal = 0;
|
||||
dataSet.theory = 0;
|
||||
dataSet.theoryFourierRe = 0;
|
||||
dataSet.theoryFourierIm = 0;
|
||||
dataSet.theoryFourierPwr = 0;
|
||||
dataSet.theoryFourierPhase = 0;
|
||||
dataSet.theoryFourierPhaseOptReal = 0;
|
||||
dataSet.diff = 0;
|
||||
dataSet.diffFourierRe = 0;
|
||||
dataSet.diffFourierIm = 0;
|
||||
dataSet.diffFourierPwr = 0;
|
||||
dataSet.diffFourierPhase = 0;
|
||||
dataSet.diffFourierPhaseOptReal = 0;
|
||||
dataSet.dataRange = 0;
|
||||
}
|
||||
|
||||
@ -2487,6 +2567,10 @@ void PMusrCanvas::CleanupDataSet(PMusrCanvasDataSet &dataSet)
|
||||
delete dataSet.dataFourierPhase;
|
||||
dataSet.dataFourierPhase = 0;
|
||||
}
|
||||
if (dataSet.dataFourierPhaseOptReal) {
|
||||
delete dataSet.dataFourierPhaseOptReal;
|
||||
dataSet.dataFourierPhaseOptReal = 0;
|
||||
}
|
||||
if (dataSet.theory) {
|
||||
delete dataSet.theory;
|
||||
dataSet.theory = 0;
|
||||
@ -2507,6 +2591,10 @@ void PMusrCanvas::CleanupDataSet(PMusrCanvasDataSet &dataSet)
|
||||
delete dataSet.theoryFourierPhase;
|
||||
dataSet.theoryFourierPhase = 0;
|
||||
}
|
||||
if (dataSet.theoryFourierPhaseOptReal) {
|
||||
delete dataSet.theoryFourierPhaseOptReal;
|
||||
dataSet.theoryFourierPhaseOptReal = 0;
|
||||
}
|
||||
if (dataSet.diff) {
|
||||
delete dataSet.diff;
|
||||
dataSet.diff = 0;
|
||||
@ -2527,6 +2615,10 @@ void PMusrCanvas::CleanupDataSet(PMusrCanvasDataSet &dataSet)
|
||||
delete dataSet.diffFourierPhase;
|
||||
dataSet.diffFourierPhase = 0;
|
||||
}
|
||||
if (dataSet.diffFourierPhaseOptReal) {
|
||||
delete dataSet.diffFourierPhaseOptReal;
|
||||
dataSet.diffFourierPhaseOptReal = 0;
|
||||
}
|
||||
if (dataSet.dataRange) {
|
||||
delete dataSet.dataRange;
|
||||
dataSet.dataRange = 0;
|
||||
@ -3259,6 +3351,8 @@ void PMusrCanvas::HandleDifference()
|
||||
*/
|
||||
void PMusrCanvas::HandleFourier()
|
||||
{
|
||||
Double_t re, im;
|
||||
|
||||
// check if plot type is appropriate for fourier
|
||||
if (fPlotType == MSR_PLOT_NON_MUSR)
|
||||
return;
|
||||
@ -3268,11 +3362,11 @@ void PMusrCanvas::HandleFourier()
|
||||
Int_t bin;
|
||||
double startTime = fXmin;
|
||||
double endTime = fXmax;
|
||||
if (!fStartWithFourier) { // fHistoFrame presen, hence get start/end from it
|
||||
if (!fStartWithFourier) { // fHistoFrame present, hence get start/end from it
|
||||
bin = fHistoFrame->GetXaxis()->GetFirst();
|
||||
startTime = fHistoFrame->GetBinCenter(bin);
|
||||
startTime = fHistoFrame->GetBinLowEdge(bin);
|
||||
bin = fHistoFrame->GetXaxis()->GetLast();
|
||||
endTime = fHistoFrame->GetBinCenter(bin);
|
||||
endTime = fHistoFrame->GetBinLowEdge(bin)+fHistoFrame->GetBinWidth(bin);
|
||||
}
|
||||
for (UInt_t i=0; i<fData.size(); i++) {
|
||||
// calculate fourier transform of the data
|
||||
@ -3308,6 +3402,7 @@ void PMusrCanvas::HandleFourier()
|
||||
fData[i].dataFourierIm->SetMarkerSize(1);
|
||||
fData[i].dataFourierPwr->SetMarkerSize(1);
|
||||
fData[i].dataFourierPhase->SetMarkerSize(1);
|
||||
|
||||
// set marker type
|
||||
fData[i].dataFourierRe->SetMarkerStyle(fData[i].data->GetMarkerStyle());
|
||||
fData[i].dataFourierIm->SetMarkerStyle(fData[i].data->GetMarkerStyle());
|
||||
@ -3335,7 +3430,7 @@ void PMusrCanvas::HandleFourier()
|
||||
// get power part of the data
|
||||
fData[i].theoryFourierPwr = fourierTheory.GetPowerFourier(scale);
|
||||
// get phase part of the data
|
||||
fData[i].theoryFourierPhase = fourierTheory.GetPhaseFourier();
|
||||
fData[i].theoryFourierPhase = fourierTheory.GetPhaseFourier();
|
||||
|
||||
// set line colors for the theory
|
||||
fData[i].theoryFourierRe->SetLineColor(fData[i].theory->GetLineColor());
|
||||
@ -3344,9 +3439,13 @@ void PMusrCanvas::HandleFourier()
|
||||
fData[i].theoryFourierPhase->SetLineColor(fData[i].theory->GetLineColor());
|
||||
}
|
||||
|
||||
// phase opt. real FT requested initially in the msr-file, hence calculate it here
|
||||
if (fCurrentPlotView == PV_FOURIER_PHASE_OPT_REAL) {
|
||||
CalcPhaseOptReFT();
|
||||
}
|
||||
|
||||
// apply global phase if present
|
||||
if (fFourier.fPhase != 0.0) {
|
||||
double re, im;
|
||||
const double cp = TMath::Cos(fFourier.fPhase/180.0*TMath::Pi());
|
||||
const double sp = TMath::Sin(fFourier.fPhase/180.0*TMath::Pi());
|
||||
|
||||
@ -3375,40 +3474,6 @@ void PMusrCanvas::HandleFourier()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// find optimal Fourier phase if range is given
|
||||
if ((fFourier.fRangeForPhaseCorrection[0] != -1.0) && (fFourier.fRangeForPhaseCorrection[1] != -1.0)) {
|
||||
|
||||
fCurrentFourierPhase = FindOptimalFourierPhase();
|
||||
|
||||
// apply optimal Fourier phase
|
||||
double re, im;
|
||||
const double cp = TMath::Cos(fCurrentFourierPhase/180.0*TMath::Pi());
|
||||
const double sp = TMath::Sin(fCurrentFourierPhase/180.0*TMath::Pi());
|
||||
|
||||
for (UInt_t i=0; i<fData.size(); i++) { // loop over all data sets
|
||||
if ((fData[i].dataFourierRe != 0) && (fData[i].dataFourierIm != 0)) {
|
||||
for (Int_t j=0; j<fData[i].dataFourierRe->GetNbinsX(); j++) { // loop over a fourier data set
|
||||
// calculate new fourier data set value
|
||||
re = fData[i].dataFourierRe->GetBinContent(j) * cp + fData[i].dataFourierIm->GetBinContent(j) * sp;
|
||||
im = fData[i].dataFourierIm->GetBinContent(j) * cp - fData[i].dataFourierRe->GetBinContent(j) * sp;
|
||||
// overwrite fourier data set value
|
||||
fData[i].dataFourierRe->SetBinContent(j, re);
|
||||
fData[i].dataFourierIm->SetBinContent(j, im);
|
||||
}
|
||||
}
|
||||
if ((fData[i].theoryFourierRe != 0) && (fData[i].theoryFourierIm != 0)) {
|
||||
for (Int_t j=0; j<fData[i].theoryFourierRe->GetNbinsX(); j++) { // loop over a fourier data set
|
||||
// calculate new fourier data set value
|
||||
re = fData[i].theoryFourierRe->GetBinContent(j) * cp + fData[i].theoryFourierIm->GetBinContent(j) * sp;
|
||||
im = fData[i].theoryFourierIm->GetBinContent(j) * cp - fData[i].theoryFourierRe->GetBinContent(j) * sp;
|
||||
// overwrite fourier data set value
|
||||
fData[i].theoryFourierRe->SetBinContent(j, re);
|
||||
fData[i].theoryFourierIm->SetBinContent(j, im);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3550,6 +3615,12 @@ void PMusrCanvas::HandleFourierDifference()
|
||||
fData[i].dataFourierPhase->GetXaxis()->GetXmin(),
|
||||
fData[i].dataFourierPhase->GetXaxis()->GetXmax());
|
||||
|
||||
// phase optimized real part
|
||||
name = TString(fData[i].dataFourierPhaseOptReal->GetTitle()) + "_diff";
|
||||
fData[i].diffFourierPhaseOptReal = new TH1F(name, name, fData[i].dataFourierPhaseOptReal->GetNbinsX(),
|
||||
fData[i].dataFourierPhaseOptReal->GetXaxis()->GetXmin(),
|
||||
fData[i].dataFourierPhaseOptReal->GetXaxis()->GetXmax());
|
||||
|
||||
// calculate difference
|
||||
for (UInt_t j=1; j<fData[i].dataFourierRe->GetEntries(); j++) {
|
||||
dvalx = fData[i].dataFourierRe->GetXaxis()->GetBinCenter(j); // get x-axis value of bin j
|
||||
@ -3568,6 +3639,10 @@ void PMusrCanvas::HandleFourierDifference()
|
||||
theoBin = fData[i].theoryFourierPhase->FindBin(dvalx); // get the theory x-axis bin
|
||||
dval = fData[i].dataFourierPhase->GetBinContent(j) - fData[i].theoryFourierPhase->GetBinContent(theoBin);
|
||||
fData[i].diffFourierPhase->SetBinContent(j, dval);
|
||||
dvalx = fData[i].dataFourierPhaseOptReal->GetXaxis()->GetBinCenter(j); // get x-axis value of bin j
|
||||
theoBin = fData[i].theoryFourierPhaseOptReal->FindBin(dvalx); // get the theory x-axis bin
|
||||
dval = fData[i].dataFourierPhaseOptReal->GetBinContent(j) - fData[i].theoryFourierPhaseOptReal->GetBinContent(theoBin);
|
||||
fData[i].diffFourierPhaseOptReal->SetBinContent(j, dval);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3581,17 +3656,21 @@ void PMusrCanvas::HandleFourierDifference()
|
||||
fData[i].diffFourierPwr->SetLineColor(fData[i].dataFourierPwr->GetLineColor());
|
||||
fData[i].diffFourierPhase->SetMarkerColor(fData[i].dataFourierPhase->GetMarkerColor());
|
||||
fData[i].diffFourierPhase->SetLineColor(fData[i].dataFourierPhase->GetLineColor());
|
||||
fData[i].diffFourierPhaseOptReal->SetMarkerColor(fData[i].dataFourierPhaseOptReal->GetMarkerColor());
|
||||
fData[i].diffFourierPhaseOptReal->SetLineColor(fData[i].dataFourierPhaseOptReal->GetLineColor());
|
||||
|
||||
// set marker size
|
||||
fData[i].diffFourierRe->SetMarkerSize(1);
|
||||
fData[i].diffFourierIm->SetMarkerSize(1);
|
||||
fData[i].diffFourierPwr->SetMarkerSize(1);
|
||||
fData[i].diffFourierPhase->SetMarkerSize(1);
|
||||
fData[i].diffFourierPhaseOptReal->SetMarkerSize(1);
|
||||
// set marker type
|
||||
fData[i].diffFourierRe->SetMarkerStyle(fData[i].dataFourierRe->GetMarkerStyle());
|
||||
fData[i].diffFourierIm->SetMarkerStyle(fData[i].dataFourierIm->GetMarkerStyle());
|
||||
fData[i].diffFourierPwr->SetMarkerStyle(fData[i].dataFourierPwr->GetMarkerStyle());
|
||||
fData[i].diffFourierPhase->SetMarkerStyle(fData[i].dataFourierPhase->GetMarkerStyle());
|
||||
fData[i].diffFourierPhaseOptReal->SetMarkerStyle(fData[i].dataFourierPhaseOptReal->GetMarkerStyle());
|
||||
|
||||
// set diffFourierTag
|
||||
fData[i].diffFourierTag = 2; // f-d
|
||||
@ -3650,6 +3729,12 @@ void PMusrCanvas::HandleAverage()
|
||||
fData[0].dataFourierPhase->GetXaxis()->GetXmin(),
|
||||
fData[0].dataFourierPhase->GetXaxis()->GetXmax());
|
||||
}
|
||||
if (fData[0].dataFourierPhaseOptReal != 0) {
|
||||
name = TString(fData[0].dataFourierPhaseOptReal->GetTitle()) + "_avg";
|
||||
fDataAvg.dataFourierPhaseOptReal = new TH1F(name, name, fData[0].dataFourierPhaseOptReal->GetNbinsX(),
|
||||
fData[0].dataFourierPhaseOptReal->GetXaxis()->GetXmin(),
|
||||
fData[0].dataFourierPhaseOptReal->GetXaxis()->GetXmax());
|
||||
}
|
||||
if (fData[0].theory != 0) {
|
||||
name = TString(fData[0].theory->GetTitle()) + "_avg";
|
||||
fDataAvg.theory = new TH1F(name, name, fData[0].theory->GetNbinsX(),
|
||||
@ -3680,6 +3765,12 @@ void PMusrCanvas::HandleAverage()
|
||||
fData[0].theoryFourierPhase->GetXaxis()->GetXmin(),
|
||||
fData[0].theoryFourierPhase->GetXaxis()->GetXmax());
|
||||
}
|
||||
if (fData[0].theoryFourierPhaseOptReal != 0) {
|
||||
name = TString(fData[0].theoryFourierPhaseOptReal->GetTitle()) + "_avg";
|
||||
fDataAvg.theoryFourierPhaseOptReal = new TH1F(name, name, fData[0].theoryFourierPhaseOptReal->GetNbinsX(),
|
||||
fData[0].theoryFourierPhaseOptReal->GetXaxis()->GetXmin(),
|
||||
fData[0].theoryFourierPhaseOptReal->GetXaxis()->GetXmax());
|
||||
}
|
||||
if (fData[0].diff != 0) {
|
||||
name = TString(fData[0].diff->GetTitle()) + "_avg";
|
||||
fDataAvg.diff = new TH1F(name, name, fData[0].diff->GetNbinsX(),
|
||||
@ -3710,6 +3801,12 @@ void PMusrCanvas::HandleAverage()
|
||||
fData[0].diffFourierPhase->GetXaxis()->GetXmin(),
|
||||
fData[0].diffFourierPhase->GetXaxis()->GetXmax());
|
||||
}
|
||||
if (fData[0].diffFourierPhaseOptReal != 0) {
|
||||
name = TString(fData[0].diffFourierPhaseOptReal->GetTitle()) + "_avg";
|
||||
fDataAvg.diffFourierPhaseOptReal = new TH1F(name, name, fData[0].diffFourierPhaseOptReal->GetNbinsX(),
|
||||
fData[0].diffFourierPhaseOptReal->GetXaxis()->GetXmin(),
|
||||
fData[0].diffFourierPhaseOptReal->GetXaxis()->GetXmax());
|
||||
}
|
||||
|
||||
// calculate all the average data sets
|
||||
double dval;
|
||||
@ -3783,6 +3880,20 @@ void PMusrCanvas::HandleAverage()
|
||||
fDataAvg.dataFourierPhase->SetMarkerSize(fData[0].dataFourierPhase->GetMarkerSize());
|
||||
fDataAvg.dataFourierPhase->SetMarkerStyle(fData[0].dataFourierPhase->GetMarkerStyle());
|
||||
}
|
||||
if (fDataAvg.dataFourierPhaseOptReal != 0) {
|
||||
for (Int_t i=0; i<fData[0].dataFourierPhaseOptReal->GetNbinsX(); i++) {
|
||||
dval = 0.0;
|
||||
for (UInt_t j=0; j<fData.size(); j++) {
|
||||
dval += GetInterpolatedValue(fData[j].dataFourierPhaseOptReal, fData[0].dataFourierPhaseOptReal->GetBinCenter(i));
|
||||
}
|
||||
fDataAvg.dataFourierPhaseOptReal->SetBinContent(i, dval/fData.size());
|
||||
}
|
||||
// set marker color, line color, maker size, marker type
|
||||
fDataAvg.dataFourierPhaseOptReal->SetMarkerColor(fData[0].dataFourierPhaseOptReal->GetMarkerColor());
|
||||
fDataAvg.dataFourierPhaseOptReal->SetLineColor(fData[0].dataFourierPhaseOptReal->GetLineColor());
|
||||
fDataAvg.dataFourierPhaseOptReal->SetMarkerSize(fData[0].dataFourierPhaseOptReal->GetMarkerSize());
|
||||
fDataAvg.dataFourierPhaseOptReal->SetMarkerStyle(fData[0].dataFourierPhaseOptReal->GetMarkerStyle());
|
||||
}
|
||||
if (fDataAvg.theory != 0) {
|
||||
for (Int_t i=0; i<fData[0].theory->GetNbinsX(); i++) {
|
||||
dval = 0.0;
|
||||
@ -3849,6 +3960,20 @@ void PMusrCanvas::HandleAverage()
|
||||
fDataAvg.theoryFourierPhase->SetMarkerSize(fData[0].theoryFourierPhase->GetMarkerSize());
|
||||
fDataAvg.theoryFourierPhase->SetMarkerStyle(fData[0].theoryFourierPhase->GetMarkerStyle());
|
||||
}
|
||||
if (fDataAvg.theoryFourierPhaseOptReal != 0) {
|
||||
for (Int_t i=0; i<fData[0].theoryFourierPhaseOptReal->GetNbinsX(); i++) {
|
||||
dval = 0.0;
|
||||
for (UInt_t j=0; j<fData.size(); j++) {
|
||||
dval += GetInterpolatedValue(fData[j].theoryFourierPhaseOptReal, fData[0].theoryFourierPhaseOptReal->GetBinCenter(i));
|
||||
}
|
||||
fDataAvg.theoryFourierPhaseOptReal->SetBinContent(i, dval/fData.size());
|
||||
}
|
||||
// set marker color, line color, maker size, marker type
|
||||
fDataAvg.theoryFourierPhaseOptReal->SetMarkerColor(fData[0].theoryFourierPhaseOptReal->GetMarkerColor());
|
||||
fDataAvg.theoryFourierPhaseOptReal->SetLineColor(fData[0].theoryFourierPhaseOptReal->GetLineColor());
|
||||
fDataAvg.theoryFourierPhaseOptReal->SetMarkerSize(fData[0].theoryFourierPhaseOptReal->GetMarkerSize());
|
||||
fDataAvg.theoryFourierPhaseOptReal->SetMarkerStyle(fData[0].theoryFourierPhaseOptReal->GetMarkerStyle());
|
||||
}
|
||||
if (fDataAvg.diff != 0) {
|
||||
for (Int_t i=0; i<fData[0].diff->GetNbinsX(); i++) {
|
||||
dval = 0.0;
|
||||
@ -3914,83 +4039,25 @@ void PMusrCanvas::HandleAverage()
|
||||
fDataAvg.diffFourierPhase->SetBinContent(i, dval/fData.size());
|
||||
}
|
||||
// set marker color, line color, maker size, marker type
|
||||
fDataAvg.diffFourierPhase->SetMarkerColor(fData[0].dataFourierRe->GetMarkerColor());
|
||||
fDataAvg.diffFourierPhase->SetLineColor(fData[0].dataFourierRe->GetLineColor());
|
||||
fDataAvg.diffFourierPhase->SetMarkerSize(fData[0].dataFourierRe->GetMarkerSize());
|
||||
fDataAvg.diffFourierPhase->SetMarkerStyle(fData[0].dataFourierRe->GetMarkerStyle());
|
||||
fDataAvg.diffFourierPhase->SetMarkerColor(fData[0].dataFourierPhase->GetMarkerColor());
|
||||
fDataAvg.diffFourierPhase->SetLineColor(fData[0].dataFourierPhase->GetLineColor());
|
||||
fDataAvg.diffFourierPhase->SetMarkerSize(fData[0].dataFourierPhase->GetMarkerSize());
|
||||
fDataAvg.diffFourierPhase->SetMarkerStyle(fData[0].dataFourierPhase->GetMarkerStyle());
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// FindOptimalFourierPhase (private)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p> The idea to estimate the optimal phase is that the imaginary part of the fourier should be
|
||||
* an antisymmetric function around the resonance, hence the asymmetry defined as asymmetry = max+min,
|
||||
* where max/min is the maximum and minimum of the imaginary part, should be a minimum for the correct phase.
|
||||
*/
|
||||
double PMusrCanvas::FindOptimalFourierPhase()
|
||||
{
|
||||
// check that Fourier is really present
|
||||
if ((fData[0].dataFourierRe == 0) || (fData[0].dataFourierIm == 0))
|
||||
return 0.0;
|
||||
|
||||
Double_t minPhase, x, valIm, val_xMin = 0.0, val_xMax = 0.0;
|
||||
Double_t minIm = 0.0, maxIm = 0.0, asymmetry;
|
||||
// get min/max of the imaginary part for phase = 0.0 as a starting point
|
||||
minPhase = 0.0;
|
||||
Bool_t first = true;
|
||||
for (Int_t i=0; i<fData[0].dataFourierIm->GetNbinsX(); i++) {
|
||||
x = fData[0].dataFourierIm->GetBinCenter(i);
|
||||
if ((x > fFourier.fRangeForPhaseCorrection[0]) && (x < fFourier.fRangeForPhaseCorrection[1])) {
|
||||
valIm = fData[0].dataFourierIm->GetBinContent(i);
|
||||
if (first) {
|
||||
minIm = valIm;
|
||||
maxIm = valIm;
|
||||
val_xMin = valIm;
|
||||
first = false;
|
||||
} else {
|
||||
if (valIm < minIm)
|
||||
minIm = valIm;
|
||||
if (valIm > maxIm)
|
||||
maxIm = valIm;
|
||||
val_xMax = valIm;
|
||||
if (fDataAvg.diffFourierPhaseOptReal != 0) {
|
||||
for (Int_t i=0; i<fData[0].diffFourierPhaseOptReal->GetNbinsX(); i++) {
|
||||
dval = 0.0;
|
||||
for (UInt_t j=0; j<fData.size(); j++) {
|
||||
dval += GetInterpolatedValue(fData[j].diffFourierPhaseOptReal, fData[0].diffFourierPhaseOptReal->GetBinCenter(i));
|
||||
}
|
||||
fDataAvg.diffFourierPhaseOptReal->SetBinContent(i, dval/fData.size());
|
||||
}
|
||||
// set marker color, line color, maker size, marker type
|
||||
fDataAvg.diffFourierPhaseOptReal->SetMarkerColor(fData[0].dataFourierPhaseOptReal->GetMarkerColor());
|
||||
fDataAvg.diffFourierPhaseOptReal->SetLineColor(fData[0].dataFourierPhaseOptReal->GetLineColor());
|
||||
fDataAvg.diffFourierPhaseOptReal->SetMarkerSize(fData[0].dataFourierPhaseOptReal->GetMarkerSize());
|
||||
fDataAvg.diffFourierPhaseOptReal->SetMarkerStyle(fData[0].dataFourierPhaseOptReal->GetMarkerStyle());
|
||||
}
|
||||
asymmetry = (maxIm+minIm)*(val_xMin-val_xMax);
|
||||
|
||||
// go through all phases an check if there is a larger max-min value of the imaginary part
|
||||
double cp, sp;
|
||||
for (double phase=0.1; phase < 180.0; phase += 0.1) {
|
||||
cp = TMath::Cos(phase / 180.0 * TMath::Pi());
|
||||
sp = TMath::Sin(phase / 180.0 * TMath::Pi());
|
||||
first = true;
|
||||
for (Int_t i=0; i<fData[0].dataFourierIm->GetNbinsX(); i++) {
|
||||
x = fData[0].dataFourierIm->GetBinCenter(i);
|
||||
if ((x > fFourier.fRangeForPhaseCorrection[0]) && (x < fFourier.fRangeForPhaseCorrection[1])) {
|
||||
valIm = -sp * fData[0].dataFourierRe->GetBinContent(i) + cp * fData[0].dataFourierIm->GetBinContent(i);
|
||||
if (first) {
|
||||
minIm = valIm;
|
||||
maxIm = valIm;
|
||||
val_xMin = valIm;
|
||||
first = false;
|
||||
} else {
|
||||
if (valIm < minIm)
|
||||
minIm = valIm;
|
||||
if (valIm > maxIm)
|
||||
maxIm = valIm;
|
||||
val_xMax = valIm;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fabs(asymmetry) > fabs((maxIm+minIm)*(val_xMin-val_xMax))) {
|
||||
minPhase = phase;
|
||||
asymmetry = (maxIm+minIm)*(val_xMin-val_xMax);
|
||||
}
|
||||
}
|
||||
|
||||
return minPhase;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@ -4034,6 +4101,10 @@ void PMusrCanvas::CleanupFourier()
|
||||
delete fData[i].dataFourierPhase;
|
||||
fData[i].dataFourierPhase = 0;
|
||||
}
|
||||
if (fData[i].dataFourierPhaseOptReal != 0) {
|
||||
delete fData[i].dataFourierPhaseOptReal;
|
||||
fData[i].dataFourierPhaseOptReal = 0;
|
||||
}
|
||||
if (fData[i].theoryFourierRe != 0) {
|
||||
delete fData[i].theoryFourierRe;
|
||||
fData[i].theoryFourierRe = 0;
|
||||
@ -4050,6 +4121,10 @@ void PMusrCanvas::CleanupFourier()
|
||||
delete fData[i].theoryFourierPhase;
|
||||
fData[i].theoryFourierPhase = 0;
|
||||
}
|
||||
if (fData[i].theoryFourierPhaseOptReal != 0) {
|
||||
delete fData[i].theoryFourierPhaseOptReal;
|
||||
fData[i].theoryFourierPhaseOptReal = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4078,6 +4153,10 @@ void PMusrCanvas::CleanupFourierDifference()
|
||||
delete fData[i].diffFourierPhase;
|
||||
fData[i].diffFourierPhase = 0;
|
||||
}
|
||||
if (fData[i].diffFourierPhaseOptReal != 0) {
|
||||
delete fData[i].diffFourierPhaseOptReal;
|
||||
fData[i].diffFourierPhaseOptReal = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4109,6 +4188,10 @@ void PMusrCanvas::CleanupAverage()
|
||||
delete fDataAvg.dataFourierPhase;
|
||||
fDataAvg.dataFourierPhase = 0;
|
||||
}
|
||||
if (fDataAvg.dataFourierPhaseOptReal != 0) {
|
||||
delete fDataAvg.dataFourierPhaseOptReal;
|
||||
fDataAvg.dataFourierPhaseOptReal = 0;
|
||||
}
|
||||
if (fDataAvg.theory != 0) {
|
||||
delete fDataAvg.theory;
|
||||
fDataAvg.theory = 0;
|
||||
@ -4129,6 +4212,10 @@ void PMusrCanvas::CleanupAverage()
|
||||
delete fDataAvg.theoryFourierPhase;
|
||||
fDataAvg.theoryFourierPhase = 0;
|
||||
}
|
||||
if (fDataAvg.theoryFourierPhaseOptReal != 0) {
|
||||
delete fDataAvg.theoryFourierPhaseOptReal;
|
||||
fDataAvg.theoryFourierPhaseOptReal = 0;
|
||||
}
|
||||
if (fDataAvg.diff != 0) {
|
||||
delete fDataAvg.diff;
|
||||
fDataAvg.diff = 0;
|
||||
@ -4149,6 +4236,68 @@ void PMusrCanvas::CleanupAverage()
|
||||
delete fDataAvg.diffFourierPhase;
|
||||
fDataAvg.diffFourierPhase = 0;
|
||||
}
|
||||
if (fDataAvg.diffFourierPhaseOptReal != 0) {
|
||||
delete fDataAvg.diffFourierPhaseOptReal;
|
||||
fDataAvg.diffFourierPhaseOptReal = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// CalculateDiff (private)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief PMusrCanvas::CalcPhaseOptReFT
|
||||
*/
|
||||
void PMusrCanvas::CalcPhaseOptReFT()
|
||||
{
|
||||
Double_t min = fMsrHandler->GetMsrFourierList()->fRangeForPhaseCorrection[0];
|
||||
Double_t max = fMsrHandler->GetMsrFourierList()->fRangeForPhaseCorrection[1];
|
||||
|
||||
if ((min == -1.0) && (max == -1.0)) {
|
||||
if ((fFourier.fPlotRange[0] != -1) && (fFourier.fPlotRange[1] != -1)) {
|
||||
min = fFourier.fPlotRange[0];
|
||||
max = fFourier.fPlotRange[1];
|
||||
} else {
|
||||
min = fData[0].dataFourierRe->GetBinLowEdge(1);
|
||||
max = fData[0].dataFourierRe->GetBinLowEdge(fData[0].dataFourierRe->GetNbinsX())+fData[0].dataFourierRe->GetBinWidth(1);
|
||||
}
|
||||
}
|
||||
|
||||
PDoubleVector phaseParam;
|
||||
Char_t hName[1024];
|
||||
Double_t ph, re;
|
||||
|
||||
for (UInt_t i=0; i<fData.size(); i++) {
|
||||
// handle Fourier data part
|
||||
fData[i].dataFourierPhaseOptReal = PFourier::GetPhaseOptRealFourier(fData[i].dataFourierRe, fData[i].dataFourierIm,
|
||||
phaseParam, 1.0, min, max);
|
||||
// set marker and line color
|
||||
fData[i].dataFourierPhaseOptReal->SetMarkerColor(fData[i].data->GetMarkerColor());
|
||||
fData[i].dataFourierPhaseOptReal->SetLineColor(fData[i].data->GetLineColor());
|
||||
// set marker size
|
||||
fData[i].dataFourierPhaseOptReal->SetMarkerSize(1);
|
||||
// set marker type
|
||||
fData[i].dataFourierPhaseOptReal->SetMarkerStyle(fData[i].data->GetMarkerStyle());
|
||||
|
||||
// handle Fourier theory part
|
||||
// clone theory Re FT
|
||||
strcpy(hName, fData[i].theoryFourierPhase->GetName());
|
||||
strcat(hName, "_Opt_Real");
|
||||
fData[i].theoryFourierPhaseOptReal = (TH1F*) fData[i].theoryFourierRe->Clone(hName);
|
||||
|
||||
// rotate the theory according to the optimized phase parameters
|
||||
// first find minBin for min of the phase correction
|
||||
Int_t minBin = fData[i].theoryFourierPhaseOptReal->GetXaxis()->FindFixBin(min);
|
||||
Int_t maxBin = fData[i].theoryFourierPhaseOptReal->GetXaxis()->FindFixBin(max);
|
||||
|
||||
for (Int_t j=1; j<fData[i].theoryFourierPhaseOptReal->GetNbinsX(); j++) {
|
||||
ph = phaseParam[0] + phaseParam[1] * (Double_t)(j-minBin+1) / (Double_t)(maxBin-minBin);
|
||||
re = fData[i].theoryFourierRe->GetBinContent(j) * cos(ph) - fData[i].theoryFourierIm->GetBinContent(j) * sin(ph);
|
||||
fData[i].theoryFourierPhaseOptReal->SetBinContent(j, re);
|
||||
}
|
||||
// set line colors for the theory
|
||||
fData[i].theoryFourierPhaseOptReal->SetLineColor(fData[i].theory->GetLineColor());
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@ -5384,6 +5533,83 @@ void PMusrCanvas::PlotFourier(Bool_t unzoom)
|
||||
}
|
||||
|
||||
break;
|
||||
case PV_FOURIER_PHASE_OPT_REAL:
|
||||
// set x-range
|
||||
if ((fFourier.fPlotRange[0] != -1) && (fFourier.fPlotRange[1] != -1)) {
|
||||
xmin = fFourier.fPlotRange[0];
|
||||
xmax = fFourier.fPlotRange[1];
|
||||
} else {
|
||||
xmin = fData[0].dataFourierPhaseOptReal->GetBinLowEdge(1);
|
||||
xmax = fData[0].dataFourierPhaseOptReal->GetBinLowEdge(fData[0].dataFourierPhaseOptReal->GetNbinsX())+fData[0].dataFourierPhaseOptReal->GetBinWidth(1);
|
||||
}
|
||||
|
||||
// set y-range
|
||||
// first find minimum/maximum of all histos
|
||||
ymin = GetMinimum(fData[0].dataFourierPhaseOptReal);
|
||||
ymax = GetMaximum(fData[0].dataFourierPhaseOptReal);
|
||||
binContent = GetMinimum(fData[0].theoryFourierPhaseOptReal);
|
||||
if (binContent < ymin)
|
||||
ymin = binContent;
|
||||
binContent = GetMaximum(fData[0].theoryFourierPhaseOptReal);
|
||||
if (binContent > ymax)
|
||||
ymax = binContent;
|
||||
for (UInt_t i=1; i<fData.size(); i++) {
|
||||
binContent = GetMinimum(fData[i].dataFourierPhaseOptReal);
|
||||
if (binContent < ymin)
|
||||
ymin = binContent;
|
||||
binContent = GetMaximum(fData[i].dataFourierPhaseOptReal);
|
||||
if (binContent > ymax)
|
||||
ymax = binContent;
|
||||
binContent = GetMinimum(fData[i].theoryFourierPhaseOptReal);
|
||||
if (binContent < ymin)
|
||||
ymin = binContent;
|
||||
binContent = GetMaximum(fData[i].theoryFourierPhaseOptReal);
|
||||
if (binContent > ymax)
|
||||
ymax = binContent;
|
||||
}
|
||||
|
||||
// delete old fHistoFrame if present
|
||||
if (fHistoFrame) {
|
||||
delete fHistoFrame;
|
||||
fHistoFrame = 0;
|
||||
}
|
||||
|
||||
fHistoFrame = fDataTheoryPad->DrawFrame(xmin, 1.05*ymin, xmax, 1.05*ymax);
|
||||
|
||||
// find the maximal number of points present in the histograms and increase the default number of points of fHistoFrame (1000) to the needed one
|
||||
noOfPoints = 1000;
|
||||
for (UInt_t i=0; i<fData.size(); i++) {
|
||||
if (fData[i].dataFourierPhaseOptReal->GetNbinsX() > (Int_t)noOfPoints)
|
||||
noOfPoints = fData[i].dataFourierPhaseOptReal->GetNbinsX();
|
||||
}
|
||||
noOfPoints *= 2; // make sure that there are enough points
|
||||
fHistoFrame->SetBins(noOfPoints, xmin, xmax);
|
||||
|
||||
for (UInt_t i=0; i<fData.size(); i++) {
|
||||
fData[i].dataFourierPhaseOptReal->GetXaxis()->SetRangeUser(xmin, xmax);
|
||||
fData[i].dataFourierPhaseOptReal->GetYaxis()->SetRangeUser(1.05*ymin, 1.05*ymax);
|
||||
fData[i].theoryFourierPhaseOptReal->GetXaxis()->SetRangeUser(xmin, xmax);
|
||||
fData[i].theoryFourierPhaseOptReal->GetYaxis()->SetRangeUser(1.05*ymin, 1.05*ymax);
|
||||
}
|
||||
|
||||
// set x-axis title
|
||||
fHistoFrame->GetXaxis()->SetTitle(xAxisTitle.Data());
|
||||
|
||||
// set y-axis title
|
||||
fHistoFrame->GetYaxis()->SetTitleOffset(1.3);
|
||||
fHistoFrame->GetYaxis()->SetTitle("Phase Opt. Real Fourier");
|
||||
|
||||
// plot data
|
||||
for (UInt_t i=0; i<fData.size(); i++) {
|
||||
fData[i].dataFourierPhaseOptReal->Draw("psame");
|
||||
}
|
||||
|
||||
// plot theories
|
||||
for (UInt_t i=0; i<fData.size(); i++) {
|
||||
fData[i].theoryFourierPhaseOptReal->Draw("same");
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -5723,6 +5949,58 @@ void PMusrCanvas::PlotFourierDifference(Bool_t unzoom)
|
||||
|
||||
PlotFourierPhaseValue();
|
||||
|
||||
break;
|
||||
case PV_FOURIER_PHASE_OPT_REAL:
|
||||
// set x-range
|
||||
if ((fFourier.fPlotRange[0] != -1) && (fFourier.fPlotRange[1] != -1)) {
|
||||
xmin = fFourier.fPlotRange[0];
|
||||
xmax = fFourier.fPlotRange[1];
|
||||
} else {
|
||||
xmin = fData[0].diffFourierPhaseOptReal->GetBinLowEdge(1);
|
||||
xmax = fData[0].diffFourierPhaseOptReal->GetBinLowEdge(fData[0].diffFourierPhaseOptReal->GetNbinsX())+fData[0].diffFourierPhaseOptReal->GetBinWidth(1);
|
||||
}
|
||||
|
||||
// set y-range
|
||||
// first find minimum/maximum of all histos
|
||||
ymin = GetMinimum(fData[0].diffFourierPhaseOptReal);
|
||||
ymax = GetMaximum(fData[0].diffFourierPhaseOptReal);
|
||||
for (UInt_t i=1; i<fData.size(); i++) {
|
||||
binContent = GetMinimum(fData[i].diffFourierPhaseOptReal);
|
||||
if (binContent < ymin)
|
||||
ymin = binContent;
|
||||
binContent = GetMaximum(fData[i].diffFourierPhaseOptReal);
|
||||
if (binContent > ymax)
|
||||
ymax = binContent;
|
||||
}
|
||||
|
||||
// delete old fHistoFrame if present
|
||||
if (fHistoFrame) {
|
||||
delete fHistoFrame;
|
||||
fHistoFrame = 0;
|
||||
}
|
||||
|
||||
fHistoFrame = fDataTheoryPad->DrawFrame(xmin, 1.05*ymin, xmax, 1.05*ymax);
|
||||
|
||||
// set ranges for phase opt. real Fourier difference
|
||||
for (UInt_t i=0; i<fData.size(); i++) {
|
||||
fData[i].diffFourierPhaseOptReal->GetXaxis()->SetRangeUser(xmin, xmax);
|
||||
fData[i].diffFourierPhaseOptReal->GetYaxis()->SetRangeUser(1.05*ymin, 1.05*ymax);
|
||||
}
|
||||
|
||||
// set x-axis title
|
||||
fHistoFrame->GetXaxis()->SetTitle(xAxisTitle.Data());
|
||||
|
||||
// set y-axis title
|
||||
fHistoFrame->GetYaxis()->SetTitleOffset(1.3);
|
||||
if (fData[0].diffFourierTag == 1)
|
||||
fHistoFrame->GetYaxis()->SetTitle("Real Fourier (d-f: data-theory)");
|
||||
else
|
||||
fHistoFrame->GetYaxis()->SetTitle("Real Fourier (f-d: [(F data)-(F theory)]");
|
||||
|
||||
// plot data
|
||||
for (UInt_t i=0; i<fData.size(); i++) {
|
||||
fData[i].diffFourierPhaseOptReal->Draw("plsame");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -5852,6 +6130,9 @@ void PMusrCanvas::PlotAverage(Bool_t unzoom)
|
||||
case PV_FOURIER_PHASE:
|
||||
yAxisTitle = "<Phase Fourier>";
|
||||
break;
|
||||
case PV_FOURIER_PHASE_OPT_REAL:
|
||||
yAxisTitle = "<Phase Opt. Real Fourier>";
|
||||
break;
|
||||
default:
|
||||
yAxisTitle = "??";
|
||||
break;
|
||||
@ -5971,6 +6252,14 @@ void PMusrCanvas::PlotAverage(Bool_t unzoom)
|
||||
fDataAvg.diffFourierPhase->Draw("psame");
|
||||
}
|
||||
break;
|
||||
case PV_FOURIER_PHASE_OPT_REAL:
|
||||
if (!fDifferenceView) { // averaged Fourier Phase Opt Real view
|
||||
fDataAvg.dataFourierPhaseOptReal->Draw("psame");
|
||||
fDataAvg.theoryFourierPhaseOptReal->Draw("same");
|
||||
} else { // averaged diff Fourier Phase view
|
||||
fDataAvg.diffFourierPhaseOptReal->Draw("psame");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -356,7 +356,7 @@ Double_t PRunListCollection::GetSingleRunChisqExpected(const std::vector<Double_
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@ -572,6 +572,97 @@ Double_t PRunListCollection::GetNonMusrMaximumLikelihood(const std::vector<Doubl
|
||||
return mlh;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// GetSingleHistoMaximumLikelihoodExpected (public)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Calculates expected mlh of the single histogram with run block index idx of a msr-file.
|
||||
*
|
||||
* <b>return:</b>
|
||||
* - expected mlh of for a single histogram
|
||||
*
|
||||
* \param par fit parameter vector
|
||||
* \param idx run block index
|
||||
*/
|
||||
Double_t PRunListCollection::GetSingleHistoMaximumLikelihoodExpected(const std::vector<Double_t>& par, const UInt_t idx) const
|
||||
{
|
||||
Double_t expected_mlh = 0.0;
|
||||
|
||||
if (idx > fMsrInfo->GetMsrRunList()->size()) {
|
||||
cerr << ">> PRunListCollection::GetSingleHistoMaximumLikelihoodExpected() **ERROR** idx=" << idx << " is out of range [0.." << fMsrInfo->GetMsrRunList()->size() << "[" << endl << endl;
|
||||
return expected_mlh;
|
||||
}
|
||||
|
||||
Int_t type = fMsrInfo->GetMsrRunList()->at(idx).GetFitType();
|
||||
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++;
|
||||
}
|
||||
|
||||
// return the mlh of the single run
|
||||
switch (type) {
|
||||
case PRUN_SINGLE_HISTO:
|
||||
expected_mlh = fRunSingleHistoList[subIdx]->CalcMaxLikelihoodExpected(par);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return expected_mlh;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// GetSingleRunMaximumLikelihood (public)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Calculates mlh of a single run-block entry of the msr-file.
|
||||
*
|
||||
* <b>return:</b>
|
||||
* - mlh of single run-block entry with index idx
|
||||
*
|
||||
* \param par fit parameter vector
|
||||
* \param idx run block index
|
||||
*/
|
||||
Double_t PRunListCollection::GetSingleRunMaximumLikelihood(const std::vector<Double_t>& par, const UInt_t idx) const
|
||||
{
|
||||
Double_t mlh = 0.0;
|
||||
|
||||
if (idx > fMsrInfo->GetMsrRunList()->size()) {
|
||||
cerr << ">> PRunListCollection::GetSingleRunMaximumLikelihood() **ERROR** idx=" << idx << " is out of range [0.." << fMsrInfo->GetMsrRunList()->size() << "[" << endl << endl;
|
||||
return mlh;
|
||||
}
|
||||
|
||||
Int_t subIdx = 0;
|
||||
Int_t type = fMsrInfo->GetMsrRunList()->at(idx).GetFitType();
|
||||
if (type == -1) { // i.e. not found in the RUN block, try the GLOBAL block
|
||||
type = fMsrInfo->GetMsrGlobal()->GetFitType();
|
||||
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 mlh of the single run
|
||||
switch (type) {
|
||||
case PRUN_SINGLE_HISTO:
|
||||
mlh = fRunSingleHistoList[subIdx]->CalcMaxLikelihood(par);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return mlh;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// GetNoOfBinsFitted (public)
|
||||
//--------------------------------------------------------------------------
|
||||
|
@ -393,6 +393,103 @@ Double_t PRunSingleHisto::CalcMaxLikelihood(const std::vector<Double_t>& par)
|
||||
return 2.0*mllh;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// CalcMaxLikelihoodExpected (public)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Calculate expected log maximum-likelihood.
|
||||
*
|
||||
* <b>return:</b>
|
||||
* - log maximum-likelihood value
|
||||
*
|
||||
* \param par parameter vector iterated by minuit2
|
||||
*/
|
||||
Double_t PRunSingleHisto::CalcMaxLikelihoodExpected(const std::vector<Double_t>& par)
|
||||
{
|
||||
Double_t mllh = 0.0; // maximum log likelihood assuming poisson distribution for the single bin
|
||||
|
||||
Double_t N0;
|
||||
|
||||
// check if norm is a parameter or a function
|
||||
if (fRunInfo->GetNormParamNo() < MSR_PARAM_FUN_OFFSET) { // norm is a parameter
|
||||
N0 = par[fRunInfo->GetNormParamNo()-1];
|
||||
} else { // norm is a function
|
||||
// get function number
|
||||
UInt_t funNo = fRunInfo->GetNormParamNo()-MSR_PARAM_FUN_OFFSET;
|
||||
// evaluate function
|
||||
N0 = fMsrInfo->EvalFunc(funNo, *fRunInfo->GetMap(), par);
|
||||
}
|
||||
|
||||
// get tau
|
||||
Double_t tau;
|
||||
if (fRunInfo->GetLifetimeParamNo() != -1)
|
||||
tau = par[fRunInfo->GetLifetimeParamNo()-1];
|
||||
else
|
||||
tau = PMUON_LIFETIME;
|
||||
|
||||
// get background
|
||||
Double_t bkg;
|
||||
if (fRunInfo->GetBkgFitParamNo() == -1) { // bkg not fitted
|
||||
if (fRunInfo->GetBkgFix(0) == PMUSR_UNDEFINED) { // no fixed background given (background interval)
|
||||
bkg = fBackground;
|
||||
} else { // fixed bkg given
|
||||
bkg = fRunInfo->GetBkgFix(0);
|
||||
}
|
||||
} else { // bkg fitted
|
||||
bkg = par[fRunInfo->GetBkgFitParamNo()-1];
|
||||
}
|
||||
|
||||
// calculate functions
|
||||
for (Int_t i=0; i<fMsrInfo->GetNoOfFuncs(); i++) {
|
||||
Int_t funcNo = fMsrInfo->GetFuncNo(i);
|
||||
fFuncValues[i] = fMsrInfo->EvalFunc(funcNo, *fRunInfo->GetMap(), par);
|
||||
}
|
||||
|
||||
// calculate maximum log likelihood
|
||||
Double_t theo;
|
||||
Double_t data;
|
||||
Double_t time(1.0);
|
||||
Int_t i;
|
||||
|
||||
// norm is needed since there is no simple scaling like in chisq case to get the correct Max.Log.Likelihood value when normlizing N(t) to 1/ns
|
||||
Double_t normalizer = 1.0;
|
||||
|
||||
if (fScaleN0AndBkg)
|
||||
normalizer = fPacking * (fTimeResolution * 1.0e3);
|
||||
|
||||
// Calculate the theory function once to ensure one function evaluation for the current set of parameters.
|
||||
// This is needed for the LF and user functions where some non-thread-save calculations only need to be calculated once
|
||||
// for a given set of parameters---which should be done outside of the parallelized loop.
|
||||
// For all other functions it means a tiny and acceptable overhead.
|
||||
time = fTheory->Func(time, par, fFuncValues);
|
||||
|
||||
#ifdef HAVE_GOMP
|
||||
Int_t chunk = (fEndTimeBin - fStartTimeBin)/omp_get_num_procs();
|
||||
if (chunk < 10)
|
||||
chunk = 10;
|
||||
#pragma omp parallel for default(shared) private(i,time,theo,data) schedule(dynamic,chunk) reduction(-:mllh)
|
||||
#endif
|
||||
for (i=fStartTimeBin; i<fEndTimeBin; ++i) {
|
||||
time = fData.GetDataTimeStart() + (Double_t)i*fData.GetDataTimeStep();
|
||||
// calculate theory for the given parameter set
|
||||
theo = N0*TMath::Exp(-time/tau)*(1.0+fTheory->Func(time, par, fFuncValues))+bkg;
|
||||
theo *= normalizer;
|
||||
|
||||
data = normalizer*fData.GetValue()->at(i);
|
||||
|
||||
if (theo <= 0.0) {
|
||||
cerr << ">> PRunSingleHisto::CalcMaxLikelihood: **WARNING** NEGATIVE theory!!" << endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (data > 1.0e-9) { // is this correct?? needs to be checked. See G-test
|
||||
mllh += data*log(data/theo);
|
||||
}
|
||||
}
|
||||
|
||||
return 2.0*mllh;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// CalcTheory (public)
|
||||
//--------------------------------------------------------------------------
|
||||
@ -1571,7 +1668,6 @@ void PRunSingleHisto::EstimateN0()
|
||||
Double_t tau = PMUON_LIFETIME;
|
||||
|
||||
UInt_t t0 = (UInt_t)round(fT0s[0]);
|
||||
Double_t alpha = fMsrInfo->GetAlphaEstimateN0();
|
||||
Double_t dval = 0.0;
|
||||
Double_t nom = 0.0;
|
||||
Double_t denom = 0.0;
|
||||
@ -1580,14 +1676,12 @@ void PRunSingleHisto::EstimateN0()
|
||||
// calc nominator
|
||||
for (UInt_t i=t0; i<fForward.size(); i++) {
|
||||
xx = exp(-dt*(Double_t)(i-t0)/tau);
|
||||
xx += alpha;
|
||||
nom += xx;
|
||||
}
|
||||
|
||||
// calc denominator
|
||||
for (UInt_t i=t0; i<fForward.size(); i++) {
|
||||
xx = exp(-dt*(Double_t)(i-t0)/tau);
|
||||
xx += alpha;
|
||||
dval = fForward[i];
|
||||
if (dval > 0)
|
||||
denom += xx*xx/dval;
|
||||
|
@ -179,9 +179,8 @@ void PStartupHandler::OnStartDocument()
|
||||
fFourierDefaults.fPlotRange[1] = -1.0;
|
||||
fFourierDefaults.fPhaseIncrement = 1.0;
|
||||
|
||||
fStartupOptions.writeExpectedChisq = false;
|
||||
fStartupOptions.estimateN0 = true;
|
||||
fStartupOptions.alphaEstimateN0 = 0.0;
|
||||
fStartupOptions.writeExpectedChisq = false; // NOT defined in the XML, but initialized for later use!!
|
||||
fStartupOptions.estimateN0 = false; // NOT defined in the XML, but initialized for later use!!
|
||||
fStartupOptions.useDKS = false;
|
||||
}
|
||||
|
||||
@ -211,12 +210,6 @@ void PStartupHandler::OnStartElement(const Char_t *str, const TList *attributes)
|
||||
{
|
||||
if (!strcmp(str, "data_path")) {
|
||||
fKey = eDataPath;
|
||||
} else if (!strcmp(str, "write_per_run_block_chisq")) {
|
||||
fKey = eWritePerRunBlockChisq;
|
||||
} else if (!strcmp(str, "estimate_n0")) {
|
||||
fKey = eEstimateN0;
|
||||
} else if (!strcmp(str, "alpha_estimate_n0")) {
|
||||
fKey = eAlphaEstimateN0;
|
||||
} else if (!strcmp(str, "use_dks")) {
|
||||
fKey = eUseDKS;
|
||||
} else if (!strcmp(str, "marker")) {
|
||||
@ -273,21 +266,6 @@ void PStartupHandler::OnCharacters(const Char_t *str)
|
||||
// add str to the path list
|
||||
fDataPathList.push_back(str);
|
||||
break;
|
||||
case eWritePerRunBlockChisq:
|
||||
tstr = TString(str);
|
||||
if (tstr.BeginsWith("y") || tstr.BeginsWith("Y"))
|
||||
fStartupOptions.writeExpectedChisq = true;
|
||||
break;
|
||||
case eEstimateN0:
|
||||
tstr = TString(str);
|
||||
if (tstr.BeginsWith("n") || tstr.BeginsWith("N"))
|
||||
fStartupOptions.estimateN0 = false;
|
||||
break;
|
||||
case eAlphaEstimateN0:
|
||||
tstr = TString(str);
|
||||
if (tstr.IsFloat())
|
||||
fStartupOptions.alphaEstimateN0 = tstr.Atof();
|
||||
break;
|
||||
case eUseDKS:
|
||||
tstr = TString(str);
|
||||
if (tstr.BeginsWith("y") || tstr.BeginsWith("Y"))
|
||||
|
@ -31,12 +31,16 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <unistd.h>
|
||||
#include <cerrno>
|
||||
#include <cctype>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <cassert>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -46,6 +50,7 @@ using namespace std;
|
||||
#include <TFile.h>
|
||||
|
||||
#include "git-revision.h"
|
||||
#include "PStartupHandler.h"
|
||||
#include "TMusrRunHeader.h"
|
||||
#include "TLemRunHeader.h"
|
||||
#include "MuSR_td_PSI_bin.h"
|
||||
@ -64,16 +69,29 @@ using namespace std;
|
||||
*/
|
||||
void dump_header_syntax()
|
||||
{
|
||||
cout << endl << "usage: dump_header <fileName> [--file_format <fileFormat>] | --help | --version";
|
||||
cout << endl << " Dumps the header information of a given muSR data file onto the standard output.";
|
||||
cout << endl << " If no <fileFormat> is given, it will try to fiddle out what <fileFormat> it might be.";
|
||||
cout << endl << "usage: dump_header [-rn <runNo> | -fn <fileName>] [-ff, --fileFormat <fileFormat>]";
|
||||
cout << endl << " [-y, --year <year>] [-s, --summary] [--psi-bulk <opt>] |";
|
||||
cout << endl << " --help | --version";
|
||||
cout << endl;
|
||||
cout << endl << " <fileName>: muSR data file name.";
|
||||
cout << endl << " --file_format <fileFormat>: where <fileFormat> can be:";
|
||||
cout << endl << " Dumps the header information of a given muSR data file onto the standard output.";
|
||||
cout << endl << " If no <fileFormat> info is povided, it will try to guess what <fileFormat> it might be.";
|
||||
cout << endl << " For <runNo> guessing of the file format is not possible. The default assumption here is 'MusrRoot'.";
|
||||
cout << endl;
|
||||
cout << endl << " -rn, --runNo <runNo> : run number of the header to be dumped.";
|
||||
cout << endl << " -fn, --fileName <fileName> : muSR data file name.";
|
||||
cout << endl << " -ff, --fileFormat <fileFormat> : where <fileFormat> can be:";
|
||||
cout << endl << " MusrRoot, NeXus, ROOT (old LEM), PSI-BIN, PSI-MDU, MUD, WKM";
|
||||
cout << endl << " NeXus is only supported if enabled.";
|
||||
cout << endl << " --help, -h : will show this help";
|
||||
cout << endl << " --version, -v : will show the current version.";
|
||||
cout << endl << " -y, --year <year> : <year> has to be 4 digit, e.g. 2005, if provided it is used to";
|
||||
cout << endl << " generate the file name for the given <runNo>, otherwise the current";
|
||||
cout << endl << " year is used. If a file name is given, this option has no effect.";
|
||||
cout << endl << " -s, --summary : this option is used for LE-uSR data sets only. It will, additionally";
|
||||
cout << endl << " to the header information, print the summary file content.";
|
||||
cout << endl << " --psi-bulk <opt> : where <opt> consists of two items: (i) pta or tdc, ";
|
||||
cout << endl << " (ii) gps | ltf | dolly | gpd | hifi. This is needed in combination with";
|
||||
cout << endl << " the file formats PSI-BIN and PSI-MDU.";
|
||||
cout << endl << " -h, --help : will show this help";
|
||||
cout << endl << " -v, --version : will show the current version.";
|
||||
cout << endl << endl;
|
||||
}
|
||||
|
||||
@ -81,7 +99,7 @@ void dump_header_syntax()
|
||||
/**
|
||||
*
|
||||
*/
|
||||
int dump_header_root(const string fileName, const string fileFormat)
|
||||
int dump_header_root(const string fileName, const string fileFormat, const bool summary)
|
||||
{
|
||||
TFile f(fileName.c_str());
|
||||
if (f.IsZombie()) {
|
||||
@ -178,6 +196,27 @@ int dump_header_root(const string fileName, const string fileFormat)
|
||||
delete header;
|
||||
}
|
||||
|
||||
// summary as well?
|
||||
if (summary && (fileType == DH_MUSR_ROOT)) {
|
||||
TObjArray *runSum=0;
|
||||
runSum = (TObjArray*)folder->FindObject("RunSummary");
|
||||
if (!runSum) { // something is wrong!!
|
||||
cerr << endl << "**ERROR** Couldn't obtain RunSummary " << fileName << endl;
|
||||
f.Close();
|
||||
return 1;
|
||||
}
|
||||
cout << "++++++++++++++++++++" << endl;
|
||||
cout << " Run Summary" << endl;
|
||||
cout << "++++++++++++++++++++" << endl;
|
||||
TObjString *tstr;
|
||||
TString str;
|
||||
for (Int_t i=0; i<runSum->GetEntries(); i++) {
|
||||
tstr = (TObjString*)runSum->At(i);
|
||||
str = tstr->String();
|
||||
cout << str;
|
||||
}
|
||||
}
|
||||
|
||||
f.Close();
|
||||
|
||||
return 0;
|
||||
@ -562,7 +601,145 @@ int dump_header_wkm(const string fileName, const string fileFormat)
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
/**
|
||||
*
|
||||
* @brief is_number
|
||||
* @param s
|
||||
* @return
|
||||
*/
|
||||
bool dump_is_number(const char *s)
|
||||
{
|
||||
int i=0;
|
||||
|
||||
if (s == 0) // make sure it is not a null pointer
|
||||
return false;
|
||||
|
||||
while (isdigit(s[i]))
|
||||
i++;
|
||||
|
||||
if (s[i] == '\0')
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief dump_current_year
|
||||
* @return
|
||||
*/
|
||||
int dump_current_year()
|
||||
{
|
||||
time_t rawtime;
|
||||
struct tm * timeinfo;
|
||||
char buffer[32];
|
||||
|
||||
time (&rawtime);
|
||||
timeinfo = localtime(&rawtime);
|
||||
strftime(buffer, 32, "%Y", timeinfo);
|
||||
|
||||
return atoi(buffer);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief dump_create_fln
|
||||
* @param runNo
|
||||
* @param year
|
||||
* @param fileFormat
|
||||
* @return
|
||||
*/
|
||||
string dump_create_fln(string runNo, string year, string fileFormat, bool pta, string instrument)
|
||||
{
|
||||
string result = "??";
|
||||
int yearShort=0;
|
||||
int iRunNo=0;
|
||||
|
||||
if (fileFormat.empty())
|
||||
fileFormat = "MusrRoot";
|
||||
|
||||
// make sure that a 'legal' file format has been found
|
||||
if (!boost::iequals(fileFormat, "MusrRoot") &&
|
||||
!boost::iequals(fileFormat, "NeXus") &&
|
||||
!boost::iequals(fileFormat, "ROOT") &&
|
||||
!boost::iequals(fileFormat, "PSI-BIN") &&
|
||||
!boost::iequals(fileFormat, "PSI-MDU") &&
|
||||
!boost::iequals(fileFormat, "MDU") &&
|
||||
!boost::iequals(fileFormat, "WKM")) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// if year is an empty string get the current year
|
||||
int yy=-1;
|
||||
stringstream ss;
|
||||
if (year.empty()) {
|
||||
yy = dump_current_year();
|
||||
ss << yy;
|
||||
year = ss.str();
|
||||
}
|
||||
yy = atoi(year.c_str());
|
||||
if (yy > 2000)
|
||||
yearShort = yy - 2000;
|
||||
else
|
||||
yearShort = yy - 1900;
|
||||
|
||||
iRunNo = atoi(runNo.c_str());
|
||||
|
||||
char fln[64];
|
||||
char ptatdc[8];
|
||||
if (pta)
|
||||
strcpy(ptatdc, "pta");
|
||||
else
|
||||
strcpy(ptatdc, "tdc");
|
||||
if (boost::iequals(fileFormat, "MusrRoot") || boost::iequals(fileFormat, "ROOT")) {
|
||||
snprintf(fln, sizeof(fln), "lem%02d_his_%04d.root", yearShort, iRunNo);
|
||||
} else if (boost::iequals(fileFormat, "NeXus")) {
|
||||
snprintf(fln, sizeof(fln), "%s.nxs", runNo.c_str());
|
||||
} else if (boost::iequals(fileFormat, "PSI-BIN")) {
|
||||
snprintf(fln, sizeof(fln), "deltat_%s_%s_%04d.bin", ptatdc, instrument.c_str(), iRunNo);
|
||||
} else if (boost::iequals(fileFormat, "PSI-MDU")) {
|
||||
snprintf(fln, sizeof(fln), "%s_%s_%s_%05d.mdu", ptatdc, instrument.c_str(), year.c_str(), iRunNo);
|
||||
} else if (boost::iequals(fileFormat, "MUD")) {
|
||||
snprintf(fln, sizeof(fln), "%06d.msr", iRunNo);
|
||||
} else if (boost::iequals(fileFormat, "WKM")) {
|
||||
|
||||
}
|
||||
result = fln;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief dump_file_exists
|
||||
* @param pathName
|
||||
* @return
|
||||
*/
|
||||
bool dump_file_exists(const string pathName)
|
||||
{
|
||||
bool exists = true;
|
||||
|
||||
int res = access(pathName.c_str(), R_OK);
|
||||
if (res < 0) {
|
||||
if (errno == ENOENT) {
|
||||
// file does not exist
|
||||
exists = false;
|
||||
} else if (errno == EACCES) {
|
||||
// file exists but is not readable
|
||||
exists = false;
|
||||
} else {
|
||||
// FAIL
|
||||
exists = false;
|
||||
}
|
||||
}
|
||||
|
||||
return exists;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief main
|
||||
* @param argc
|
||||
* @param argv
|
||||
* @return
|
||||
*/
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@ -571,9 +748,14 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
string runNo("");
|
||||
string fileName("");
|
||||
string fileFormat("");
|
||||
int count=0;
|
||||
string year("");
|
||||
bool pta(false);
|
||||
string instrument("");
|
||||
bool summary(false);
|
||||
|
||||
for (int i=1; i<argc; i++) {
|
||||
if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h")) {
|
||||
dump_header_syntax();
|
||||
@ -585,9 +767,40 @@ int main(int argc, char *argv[])
|
||||
cout << endl << "dump_header: git-rev: " << GIT_REVISION << endl << endl;
|
||||
#endif
|
||||
return 0;
|
||||
} else if (!strcmp(argv[i], "--file_format")) {
|
||||
} else if (!strcmp(argv[i], "-rn") || !strcmp(argv[i], "--runNo")) {
|
||||
if (i+1 >= argc) {
|
||||
cout << endl << "**ERROR** found '--file_format' without <fileFormat>!" << endl;
|
||||
cerr << endl << "**ERROR** found -rn, --runNo without <runNo>!" << endl;
|
||||
dump_header_syntax();
|
||||
return 1;
|
||||
}
|
||||
// make sure there is only one 'legal' run number
|
||||
int count = 1;
|
||||
while (dump_is_number(argv[i+count]) && (i+count < argc))
|
||||
count++;
|
||||
// make sure there is one and only one run number given
|
||||
if (count == 1) {
|
||||
cerr << endl << "**ERROR** found -rn, --runNo without <runNo>, or the provided <runNo> ('" << argv[i+1] << "') is not a number!" << endl;
|
||||
dump_header_syntax();
|
||||
return 1;
|
||||
}
|
||||
if (count > 2) {
|
||||
cerr << endl << "**ERROR** found -rn, --runNo with more than one <runNo>! This is not yet supported." << endl;
|
||||
dump_header_syntax();
|
||||
return 1;
|
||||
}
|
||||
runNo = argv[i+1];
|
||||
i++;
|
||||
} else if (!strcmp(argv[i], "-fn") || !strcmp(argv[i], "--fileName")) {
|
||||
if (i+1 >= argc) {
|
||||
cerr << endl << "**ERROR** found -fn, --fileName without <fileName>!" << endl;
|
||||
dump_header_syntax();
|
||||
return 1;
|
||||
}
|
||||
fileName = argv[i+1];
|
||||
i++;
|
||||
} else if (!strcmp(argv[i], "--fileFormat") || !strcmp(argv[i], "-ff")) {
|
||||
if (i+1 >= argc) {
|
||||
cerr << endl << "**ERROR** found -ff, --fileFormat without <fileFormat>!" << endl;
|
||||
dump_header_syntax();
|
||||
return 1;
|
||||
}
|
||||
@ -595,27 +808,169 @@ int main(int argc, char *argv[])
|
||||
if (!boost::iequals(ff, "MusrRoot") && !boost::iequals(ff, "NeXus") && !boost::iequals(ff, "ROOT") &&
|
||||
!boost::iequals(ff, "PSI-BIN") && !boost::iequals(ff, "PSI-MDU") && !boost::iequals(ff, "MUD") &&
|
||||
!boost::iequals(ff, "WKM")) { // none of the listed found
|
||||
cout << endl << "**ERROR** found unsupported muSR file data format: " << argv[i+1] << endl;
|
||||
cerr << endl << "**ERROR** found unsupported muSR file data format: " << argv[i+1] << endl;
|
||||
dump_header_syntax();
|
||||
return 1;
|
||||
}
|
||||
fileFormat = argv[i+1];
|
||||
i++;
|
||||
} else if (!strcmp(argv[i], "-y") || !strcmp(argv[i], "--year")) {
|
||||
if (i+1 >= argc) {
|
||||
cerr << endl << "**ERROR** found -y, --year without <year>!" << endl;
|
||||
dump_header_syntax();
|
||||
return 1;
|
||||
}
|
||||
if (!dump_is_number(argv[i+1])) {
|
||||
cerr << endl << "**ERROR** found -y, --year with sensless <year> '" << argv[i+1] << "'!" << endl;
|
||||
dump_header_syntax();
|
||||
return 1;
|
||||
}
|
||||
int yy = strtod(argv[i+1], (char**)0);
|
||||
if ((yy < 1950) || (yy > dump_current_year())) {
|
||||
cerr << endl << "**ERROR** found -y, --year with <year> '" << yy << "'!";
|
||||
cerr << endl << " Well, cannot handle files in the pre-muSR time nor in the future." << endl;
|
||||
dump_header_syntax();
|
||||
return 1;
|
||||
}
|
||||
year = argv[i+1];
|
||||
i++;
|
||||
} else if (!strcmp(argv[i], "-s") || !strcmp(argv[i], "--summary")) {
|
||||
summary = true;
|
||||
} else if (!strcmp(argv[i], "--psi-bulk")) {
|
||||
if (i+2 >= argc) {
|
||||
cerr << endl << "**ERROR** found --psi-bulk with insufficient input!" << endl;
|
||||
dump_header_syntax();
|
||||
return 1;
|
||||
}
|
||||
if (!strcmp(argv[i+1], "pta"))
|
||||
pta = true;
|
||||
else if (!strcmp(argv[i+1], "tdc"))
|
||||
pta = false;
|
||||
else {
|
||||
cerr << endl << "**ERROR** found --psi-bulk with 1st argument '" << argv[i+1] << "'! Allowed is 'pta' or 'tdc'." << endl;
|
||||
dump_header_syntax();
|
||||
return 1;
|
||||
}
|
||||
if (strcmp(argv[i+2], "gps") && strcmp(argv[i+2], "ltf") && strcmp(argv[i+2], "dolly") &&
|
||||
strcmp(argv[i+2], "gpd") && strcmp(argv[i+2], "hifi")) {
|
||||
cerr << endl << "**ERROR** found --psi-bulk with 2nd argument '" << argv[i+1] << "'! This is an unkown instrument." << endl;
|
||||
dump_header_syntax();
|
||||
return 1;
|
||||
}
|
||||
instrument = argv[i+2];
|
||||
i += 2;
|
||||
} else {
|
||||
count++;
|
||||
fileName = argv[i];
|
||||
cerr << endl << "**ERROR** found unkown option '" << argv[i] << "'." << endl;
|
||||
dump_header_syntax();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// check if more then one file name was given
|
||||
if (count != 1) {
|
||||
cout << endl << "**ERROR** (only) a single file name is needed!" << endl;
|
||||
dump_header_syntax();
|
||||
// if year is not provided, take the current one
|
||||
if (year.empty()) {
|
||||
stringstream ss;
|
||||
ss << dump_current_year();
|
||||
year = ss.str();
|
||||
}
|
||||
|
||||
if ((runNo.length() != 0) && (fileName.length() != 0)) {
|
||||
cerr << endl << "**ERROR** currently only either runNo or fileName can be handled, not both simultanously." << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// invoke the startup handler in order to get the default search paths to the data files
|
||||
// read startup file
|
||||
char startup_path_name[128];
|
||||
TSAXParser *saxParser = new TSAXParser();
|
||||
PStartupHandler *startupHandler = new PStartupHandler();
|
||||
if (!startupHandler->StartupFileFound()) {
|
||||
cerr << endl << ">> musrfit **WARNING** couldn't find " << startupHandler->GetStartupFilePath().Data();
|
||||
cerr << endl;
|
||||
// clean up
|
||||
if (saxParser) {
|
||||
delete saxParser;
|
||||
saxParser = 0;
|
||||
}
|
||||
if (startupHandler) {
|
||||
delete startupHandler;
|
||||
startupHandler = 0;
|
||||
}
|
||||
} else {
|
||||
strcpy(startup_path_name, startupHandler->GetStartupFilePath().Data());
|
||||
saxParser->ConnectToHandler("PStartupHandler", startupHandler);
|
||||
//status = saxParser->ParseFile(startup_path_name);
|
||||
// parsing the file as above seems to lead to problems in certain environments;
|
||||
// use the parseXmlFile function instead (see PStartupHandler.cpp for the definition)
|
||||
int status = parseXmlFile(saxParser, startup_path_name);
|
||||
// check for parse errors
|
||||
if (status) { // error
|
||||
cerr << endl << ">> musrfit **WARNING** Reading/parsing musrfit_startup.xml failed.";
|
||||
cerr << endl;
|
||||
// clean up
|
||||
if (saxParser) {
|
||||
delete saxParser;
|
||||
saxParser = 0;
|
||||
}
|
||||
if (startupHandler) {
|
||||
delete startupHandler;
|
||||
startupHandler = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// runNo given, hence try to create the necessary file name based on the provided information
|
||||
if (runNo != "") {
|
||||
string str = dump_create_fln(runNo, year, fileFormat, pta, instrument);
|
||||
if (str == "??") {
|
||||
cerr << endl << "**ERROR** couldn't get a proper file name." << endl;
|
||||
return 1;
|
||||
}
|
||||
fileName = str;
|
||||
}
|
||||
|
||||
bool found_fln = false;
|
||||
// 1st check if the file name is found in the current directory
|
||||
string pathFln("");
|
||||
pathFln = "./" + fileName;
|
||||
if (dump_file_exists(pathFln))
|
||||
found_fln = true;
|
||||
|
||||
// 2nd check if file name is found in any default search paths if not already found in the current directory
|
||||
if (!found_fln) {
|
||||
PStringVector pathList = startupHandler->GetDataPathList();
|
||||
for (unsigned int i=0; i<pathList.size(); i++) {
|
||||
if (boost::iequals(fileFormat, "MusrRoot") || boost::iequals(fileFormat, "ROOT") ||
|
||||
boost::iequals(fileFormat, "WKM")) {
|
||||
pathFln = pathList[i] + "/" + year + "/" + fileName;
|
||||
} else {
|
||||
if (pta)
|
||||
pathFln = pathList[i] + "/d" + year + "/pta/" + fileName;
|
||||
else
|
||||
pathFln = pathList[i] + "/d" + year + "/tdc/" + fileName;
|
||||
}
|
||||
if (dump_file_exists(pathFln)) {
|
||||
found_fln = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found_fln) {
|
||||
cerr << "**ERROR** couldn't find any appropriate file." << endl;
|
||||
// cleanup
|
||||
if (saxParser) {
|
||||
delete saxParser;
|
||||
saxParser = 0;
|
||||
}
|
||||
if (startupHandler) {
|
||||
delete startupHandler;
|
||||
startupHandler = 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
// if file format is not given explicitly try to guess it based on the file name extension
|
||||
if (fileFormat == "") {
|
||||
if ((fileFormat == "") && (fileName != "")) {
|
||||
string fln(fileName);
|
||||
boost::to_lower(fln);
|
||||
if (fln.find(".root") != string::npos)
|
||||
@ -624,6 +979,8 @@ int main(int argc, char *argv[])
|
||||
fileFormat = "NeXus";
|
||||
else if (fln.find(".bin") != string::npos)
|
||||
fileFormat = "PSI-BIN";
|
||||
else if (fln.find(".mdu") != string::npos)
|
||||
fileFormat = "PSI-MDU";
|
||||
else if (fln.find(".msr") != string::npos)
|
||||
fileFormat = "MUD";
|
||||
else if ((fln.find(".nemu") != string::npos) || (fln.find(".wkm") != string::npos))
|
||||
@ -640,19 +997,29 @@ int main(int argc, char *argv[])
|
||||
boost::to_lower(fileFormat);
|
||||
|
||||
if (boost::iequals(fileFormat, "MusrRoot") || boost::iequals(fileFormat, "ROOT")) {
|
||||
dump_header_root(fileName, fileFormat);
|
||||
dump_header_root(pathFln, fileFormat, summary);
|
||||
} else if (boost::iequals(fileFormat, "NeXus")) {
|
||||
#ifdef PNEXUS_ENABLED
|
||||
dump_header_nexus(fileName);
|
||||
dump_header_nexus(pathFln);
|
||||
#else
|
||||
cout << endl << "Sorry, NeXus is not enabled, hence I cannot help you." << endl;
|
||||
#endif
|
||||
} else if (boost::iequals(fileFormat, "PSI-BIN") || boost::iequals(fileFormat, "PSI-MDU")) {
|
||||
dump_header_psi_bin(fileName, fileFormat);
|
||||
dump_header_psi_bin(pathFln, fileFormat);
|
||||
} else if (boost::iequals(fileFormat, "MUD")) {
|
||||
dump_header_mud(fileName, fileFormat);
|
||||
dump_header_mud(pathFln, fileFormat);
|
||||
} else if (boost::iequals(fileFormat, "WKM")) {
|
||||
dump_header_wkm(fileName, fileFormat);
|
||||
dump_header_wkm(pathFln, fileFormat);
|
||||
}
|
||||
|
||||
// cleanup
|
||||
if (saxParser) {
|
||||
delete saxParser;
|
||||
saxParser = 0;
|
||||
}
|
||||
if (startupHandler) {
|
||||
delete startupHandler;
|
||||
startupHandler = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
38
src/external/MuSRFitGUI/MSR.pm
vendored
38
src/external/MuSRFitGUI/MSR.pm
vendored
@ -446,7 +446,7 @@ $logxy";
|
||||
if ($All{"FPLOT"} eq $EMPTY) {$All{"FPLOT"}="POWER";}
|
||||
if ($All{"FPHASE"} eq $EMPTY) {$All{"FPHASE"}="8.5";}
|
||||
my $FrqRange = "#range ".$All{"FRQMIN"}." ".$All{"FRQMAX"};
|
||||
if ($All{"FRQMAX"} ne $EMPTY && $All{"FRQMIN"} ne $EMPTY) {
|
||||
if ($All{"FRQMAX"} ne $EMPTY && $All{"FRQMIN"} ne $EMPTY && $All{"FRQMAX"} ne $All{"FRQMIN"}) {
|
||||
$FrqRange = "range ".$All{"FRQMIN"}." ".$All{"FRQMAX"};
|
||||
}
|
||||
|
||||
@ -1780,20 +1780,40 @@ sub RUNFileNameAuto {
|
||||
$RUNFILE = "$DATADIR/d$YEAR/tdc/$RUN_File_Name";
|
||||
}
|
||||
elsif ( $BeamLine eq "GPS" ) {
|
||||
$RUN_File_Name = "deltat_tdc_gps_" . $RUNtmp;
|
||||
$RUNFILE = "$DATADIR/d$YEAR/tdc/$RUN_File_Name";
|
||||
if ($YEAR >= 2008) {
|
||||
$RUN_File_Name = "deltat_tdc_gps_" . $RUNtmp;
|
||||
$RUNFILE = "$DATADIR/d$YEAR/tdc/$RUN_File_Name";
|
||||
} else {
|
||||
$RUN_File_Name = "deltat_pta_gps_" . $RUNtmp;
|
||||
$RUNFILE = "$DATADIR/d$YEAR/$RUN_File_Name";
|
||||
}
|
||||
}
|
||||
elsif ( $BeamLine eq "LTF" ) {
|
||||
$RUN_File_Name = "deltat_tdc_ltf_" . $RUNtmp;
|
||||
$RUNFILE = "$DATADIR/d$YEAR/tdc/$RUN_File_Name";
|
||||
if ($YEAR >= 2009) {
|
||||
$RUN_File_Name = "deltat_tdc_ltf_" . $RUNtmp;
|
||||
$RUNFILE = "$DATADIR/d$YEAR/tdc/$RUN_File_Name";
|
||||
} else {
|
||||
$RUN_File_Name = "deltat_pta_ltf_" . $RUNtmp;
|
||||
$RUNFILE = "$DATADIR/d$YEAR/$RUN_File_Name";
|
||||
}
|
||||
}
|
||||
elsif ( $BeamLine eq "Dolly" ) {
|
||||
$RUN_File_Name = "deltat_tdc_dolly_" . $RUNtmp;
|
||||
$RUNFILE = "$DATADIR/d$YEAR/tdc/$RUN_File_Name";
|
||||
if ($YEAR >= 2008) {
|
||||
$RUN_File_Name = "deltat_tdc_dolly_" . $RUNtmp;
|
||||
$RUNFILE = "$DATADIR/d$YEAR/tdc/$RUN_File_Name";
|
||||
} else {
|
||||
$RUN_File_Name = "deltat_pta_dolly_" . $RUNtmp;
|
||||
$RUNFILE = "$DATADIR/d$YEAR/$RUN_File_Name";
|
||||
}
|
||||
}
|
||||
elsif ( $BeamLine eq "GPD" ) {
|
||||
$RUN_File_Name = "deltat_tdc_gpd_" . $RUNtmp;
|
||||
$RUNFILE = "$DATADIR/d$YEAR/tdc/$RUN_File_Name";
|
||||
if ($YEAR >= 2008) {
|
||||
$RUN_File_Name = "deltat_tdc_gpd_" . $RUNtmp;
|
||||
$RUNFILE = "$DATADIR/d$YEAR/tdc/$RUN_File_Name";
|
||||
} else {
|
||||
$RUN_File_Name = "deltat_pta_gpd_" . $RUNtmp;
|
||||
$RUNFILE = "$DATADIR/d$YEAR/$RUN_File_Name";
|
||||
}
|
||||
}
|
||||
elsif ( $BeamLine eq "HAL" ) {
|
||||
$RUNtmp=sprintf("%05d",$RUNtmp);
|
||||
|
@ -35,6 +35,8 @@
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DKS
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
#include "fftw3.h"
|
||||
#else
|
||||
#include <complex>
|
||||
@ -42,6 +44,8 @@ using namespace std;
|
||||
#include "DKSBase.h"
|
||||
#endif
|
||||
|
||||
#include "Minuit2/FCNBase.h"
|
||||
|
||||
#include "PMusr.h"
|
||||
|
||||
#define F_APODIZATION_NONE 1
|
||||
@ -49,6 +53,52 @@ using namespace std;
|
||||
#define F_APODIZATION_MEDIUM 3
|
||||
#define F_APODIZATION_STRONG 4
|
||||
|
||||
/**
|
||||
* Re Fourier phase correction
|
||||
*/
|
||||
class PFTPhaseCorrection : public ROOT::Minuit2::FCNBase
|
||||
{
|
||||
public:
|
||||
PFTPhaseCorrection(const Int_t minBin=-1, const Int_t maxBin=-1);
|
||||
PFTPhaseCorrection(vector<Double_t> &reFT, vector<Double_t> &imFT, const Int_t minBin=-1, const Int_t maxBin=-1);
|
||||
virtual ~PFTPhaseCorrection() {}
|
||||
|
||||
virtual Bool_t IsValid() { return fValid; }
|
||||
virtual void Minimize();
|
||||
|
||||
virtual void SetGamma(const Double_t gamma) { fGamma = gamma; }
|
||||
virtual void SetPh(const Double_t c0, const Double_t c1) { fPh_c0 = c0; fPh_c1 = c1; CalcPhasedFT(); CalcRealPhFTDerivative(); }
|
||||
|
||||
virtual Double_t GetGamma() { return fGamma; }
|
||||
virtual Double_t GetPhaseCorrectionParam(UInt_t idx);
|
||||
virtual Double_t GetMinimum();
|
||||
|
||||
private:
|
||||
Bool_t fValid;
|
||||
|
||||
vector<Double_t> fReal; /// original real Fourier data set
|
||||
vector<Double_t> fImag; /// original imag Fourier data set
|
||||
mutable vector<Double_t> fRealPh; /// phased real Fourier data set
|
||||
mutable vector<Double_t> fImagPh; /// phased imag Fourier data set
|
||||
mutable vector<Double_t> fRealPhD; /// 1st derivative of fRealPh
|
||||
|
||||
Double_t fMinBin; /// minimum bin from Fourier range to be used for the phase correction estimate
|
||||
Double_t fMaxBin; /// maximum bin from Fourier range to be used for the phase correction estimate
|
||||
mutable Double_t fPh_c0; /// constant part of the phase dispersion used for the phase correction
|
||||
mutable Double_t fPh_c1; /// linear part of the phase dispersion used for the phase correction
|
||||
Double_t fGamma; /// gamma parameter to balance between entropy and penalty
|
||||
Double_t fMin; /// keeps the minimum of the entropy/penalty minimization
|
||||
|
||||
virtual void Init();
|
||||
virtual void CalcPhasedFT() const;
|
||||
virtual void CalcRealPhFTDerivative() const;
|
||||
virtual Double_t Penalty() const;
|
||||
virtual Double_t Entropy() const;
|
||||
|
||||
virtual Double_t Up() const { return 1.0; }
|
||||
virtual Double_t operator()(const vector<Double_t>&) const;
|
||||
};
|
||||
|
||||
/**
|
||||
* muSR Fourier class.
|
||||
*/
|
||||
@ -70,11 +120,13 @@ class PFourier
|
||||
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);
|
||||
|
||||
static TH1F* GetPhaseOptRealFourier(const TH1F *re, const TH1F *im, vector<Double_t> &phase,
|
||||
const Double_t scale = 1.0, const Double_t min = -1.0, const Double_t max = -1.0);
|
||||
|
||||
virtual Bool_t IsValid() { return fValid; }
|
||||
virtual Bool_t IsUseFFTW() { return fUseFFTW; }
|
||||
|
||||
|
@ -71,7 +71,7 @@ typedef struct {
|
||||
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
|
||||
vector<Double_t> optPhase; ///< optimal phase which maximizes the real Fourier
|
||||
} PFourierCanvasDataSet;
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
@ -159,6 +159,7 @@ class PFourierCanvas : public TObject, public TQObject
|
||||
virtual void InitFourierCanvas(const Char_t* title, Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh);
|
||||
virtual void CleanupAverage();
|
||||
virtual void HandleAverage();
|
||||
virtual void CalcPhaseOptReal();
|
||||
|
||||
virtual void PlotFourier();
|
||||
virtual void PlotFourierPhaseValue();
|
||||
|
@ -109,7 +109,6 @@ class PMsrHandler
|
||||
|
||||
virtual void GetGroupingString(Int_t runNo, TString detector, TString &groupingStr);
|
||||
virtual Bool_t EstimateN0();
|
||||
virtual Double_t GetAlphaEstimateN0();
|
||||
|
||||
virtual std::string GetDKSTheoryString();
|
||||
virtual UInt_t GetDKSTag();
|
||||
|
@ -822,13 +822,12 @@ typedef struct {
|
||||
|
||||
//-------------------------------------------------------------
|
||||
/**
|
||||
* <p>Holds the informations for the any2many converter program
|
||||
* <p>Holds information given at startup
|
||||
*/
|
||||
typedef struct {
|
||||
Bool_t writeExpectedChisq; ///< if set to true, expected chisq per block will be written
|
||||
Bool_t estimateN0; ///< if set to true, for single histogram fits N0 will be estimated
|
||||
Double_t alphaEstimateN0; ///< relates the Bkg to N0, i.e. Bkg = alpha*N0
|
||||
Bool_t useDKS; ///< if set to true, use DKS if present and "sensible"
|
||||
Bool_t writeExpectedChisq; ///< if set to true, expected chisq and chisq per block will be written (from command line)
|
||||
Bool_t estimateN0; ///< if set to true, for single histogram fits N0 will be estimated (from command line)
|
||||
Bool_t useDKS; ///< if set to true, use DKS if present and "sensible" (from xml)
|
||||
} PStartupOptions;
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
@ -55,12 +55,13 @@
|
||||
#define XTHEO 0.75
|
||||
|
||||
// Current Plot Views
|
||||
#define PV_DATA 1
|
||||
#define PV_FOURIER_REAL 2
|
||||
#define PV_FOURIER_IMAG 3
|
||||
#define PV_FOURIER_REAL_AND_IMAG 4
|
||||
#define PV_FOURIER_PWR 5
|
||||
#define PV_FOURIER_PHASE 6
|
||||
#define PV_DATA 1
|
||||
#define PV_FOURIER_REAL 2
|
||||
#define PV_FOURIER_IMAG 3
|
||||
#define PV_FOURIER_REAL_AND_IMAG 4
|
||||
#define PV_FOURIER_PWR 5
|
||||
#define PV_FOURIER_PHASE 6
|
||||
#define PV_FOURIER_PHASE_OPT_REAL 7
|
||||
|
||||
// Canvas menu id's
|
||||
#define P_MENU_ID_DATA 10001
|
||||
@ -71,13 +72,14 @@
|
||||
|
||||
#define P_MENU_PLOT_OFFSET 1000
|
||||
|
||||
#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
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
/**
|
||||
@ -122,16 +124,19 @@ typedef struct {
|
||||
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 optimized real part spectrum Fourier transform of the data histogram
|
||||
TH1F *theory; ///< theory histogram belonging to the data histogram
|
||||
TH1F *theoryFourierRe; ///< real part of the Fourier transform of the theory histogram
|
||||
TH1F *theoryFourierIm; ///< imaginary part of the Fourier transform of the theory histogram
|
||||
TH1F *theoryFourierPwr; ///< power spectrum of the Fourier transform of the theory histogram
|
||||
TH1F *theoryFourierPhase; ///< phase spectrum of the Fourier transform of the theory histogram
|
||||
TH1F *theoryFourierPhaseOptReal; ///< phase optimized real part spectrum Fourier transform of the theory histogram
|
||||
TH1F *diff; ///< difference histogram, i.e. data-theory
|
||||
TH1F *diffFourierRe; ///< real part of the Fourier transform of the diff histogram
|
||||
TH1F *diffFourierIm; ///< imaginary part of the Fourier transform of the diff histogram
|
||||
TH1F *diffFourierPwr; ///< power spectrum of the Fourier transform of the diff histogram
|
||||
TH1F *diffFourierPhase; ///< phase spectrum of the Fourier transform of the diff histogram
|
||||
TH1F *diffFourierPhaseOptReal; ///< phase optimized real part spectrum Fourier transform of the diff histogram
|
||||
PMusrCanvasPlotRange *dataRange; ///< keep the msr-file plot data range
|
||||
UInt_t diffFourierTag; ///< 0=not relevant, 1=d-f (Fourier of difference time spectra), 2=f-d (difference of Fourier spectra)
|
||||
} PMusrCanvasDataSet;
|
||||
@ -201,12 +206,12 @@ class PMusrCanvas : public TObject, public TQObject
|
||||
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,
|
||||
const Bool_t fourier=false, const Bool_t useDKS=false);
|
||||
const Bool_t fourier=false, const Bool_t avg=false, const Bool_t useDKS=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 Bool_t fourier=false, const Bool_t useDKS=false);
|
||||
const Bool_t fourier=false, const Bool_t avg=false, const Bool_t useDKS=false);
|
||||
virtual ~PMusrCanvas();
|
||||
|
||||
virtual Bool_t IsValid() { return fValid; }
|
||||
@ -231,6 +236,7 @@ class PMusrCanvas : public TObject, public TQObject
|
||||
|
||||
private:
|
||||
Bool_t fStartWithFourier; ///< flag if true, the Fourier transform will be presented bypassing the time domain representation
|
||||
Bool_t fStartWithAvg; ///< flag if true, the averaged data/Fourier will be presented
|
||||
Bool_t fUseDKS; ///< flag if true, use DKS if it is enabled
|
||||
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
|
||||
@ -303,12 +309,12 @@ class PMusrCanvas : public TObject, public TQObject
|
||||
virtual void HandleDifferenceFourier();
|
||||
virtual void HandleFourierDifference();
|
||||
virtual void HandleAverage();
|
||||
virtual Double_t FindOptimalFourierPhase();
|
||||
virtual void CleanupDifference();
|
||||
virtual void CleanupFourier();
|
||||
virtual void CleanupFourierDifference();
|
||||
virtual void CleanupAverage();
|
||||
|
||||
virtual void CalcPhaseOptReFT();
|
||||
virtual Double_t CalculateDiff(const Double_t x, const Double_t y, TH1F *theo);
|
||||
virtual Double_t CalculateDiff(const Double_t x, const Double_t y, TGraphErrors *theo);
|
||||
virtual Int_t FindBin(const Double_t x, TGraphErrors *graph);
|
||||
|
@ -95,6 +95,9 @@ class PRunListCollection
|
||||
virtual Double_t GetMuMinusMaximumLikelihood(const std::vector<Double_t>& par) const;
|
||||
virtual Double_t GetNonMusrMaximumLikelihood(const std::vector<Double_t>& par) const;
|
||||
|
||||
virtual Double_t GetSingleHistoMaximumLikelihoodExpected(const std::vector<Double_t>& par, const UInt_t idx) const;
|
||||
virtual Double_t GetSingleRunMaximumLikelihood(const std::vector<Double_t>& par, const UInt_t idx) const;
|
||||
|
||||
virtual UInt_t GetNoOfBinsFitted(const UInt_t idx) const;
|
||||
virtual UInt_t GetTotalNoOfBinsFitted() const;
|
||||
|
||||
|
@ -45,6 +45,7 @@ class PRunSingleHisto : public PRunBase
|
||||
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 Double_t CalcMaxLikelihoodExpected(const std::vector<Double_t>& par);
|
||||
virtual void CalcTheory();
|
||||
|
||||
virtual UInt_t GetNoOfFitBins();
|
||||
|
@ -79,11 +79,10 @@ class PStartupHandler : public TObject, public TQObject
|
||||
virtual const PIntVector GetMarkerList() const { return fMarkerList; } ///< returns the marker list
|
||||
virtual const PIntVector GetColorList() const { return fColorList; } ///< returns the color list
|
||||
|
||||
virtual void SetStartupOptions(const PStartupOptions opt) { fStartupOptions = opt; }
|
||||
|
||||
private:
|
||||
enum EKeyWords {eEmpty, eComment, eDataPath, eOptions, eWritePerRunBlockChisq, eEstimateN0, eAlphaEstimateN0, eUseDKS,
|
||||
eFourierSettings, eUnits, eFourierPower, eApodization, ePlot, ePhase, ePhaseIncrement,
|
||||
enum EKeyWords {eEmpty, eComment, eDataPath, eOptions, eUseDKS,
|
||||
eFourierSettings, eUnits, eFourierPower,
|
||||
eApodization, ePlot, ePhase, ePhaseIncrement,
|
||||
eRootSettings, eMarkerList, eMarker,
|
||||
eColorList, eColor};
|
||||
EKeyWords fKey; ///< xml filter key
|
||||
|
@ -1042,7 +1042,6 @@ Int_t main(Int_t argc, Char_t *argv[])
|
||||
PStartupOptions startup_options;
|
||||
startup_options.writeExpectedChisq = false;
|
||||
startup_options.estimateN0 = true;
|
||||
startup_options.alphaEstimateN0 = 0.0;
|
||||
TSAXParser *saxParser = new TSAXParser();
|
||||
PStartupHandler *startupHandler = new PStartupHandler();
|
||||
if (!startupHandler->StartupFileFound()) {
|
||||
@ -1079,7 +1078,6 @@ Int_t main(Int_t argc, Char_t *argv[])
|
||||
}
|
||||
}
|
||||
}
|
||||
startupHandler->SetStartupOptions(startup_options);
|
||||
|
||||
// filter out the use_dks flag
|
||||
if (startupParam.useDKS == MFT_UNDEF) {
|
||||
@ -1096,7 +1094,7 @@ Int_t main(Int_t argc, Char_t *argv[])
|
||||
vector<PMsrHandler*> msrHandler;
|
||||
msrHandler.resize(startupParam.msrFln.size());
|
||||
for (UInt_t i=0; i<startupParam.msrFln.size(); i++) {
|
||||
msrHandler[i] = new PMsrHandler(startupParam.msrFln[i].Data(), startupHandler->GetStartupOptions(), true);
|
||||
msrHandler[i] = new PMsrHandler(startupParam.msrFln[i].Data(), &startup_options, true);
|
||||
status = msrHandler[i]->ReadMsrFile();
|
||||
if (status != PMUSR_SUCCESS) {
|
||||
switch (status) {
|
||||
|
@ -87,6 +87,8 @@ bool PAdminXMLParser::startElement( const QString&, const QString&,
|
||||
fKeyWord = eTitleFromDataFile;
|
||||
} else if (qName == "musrview_show_fourier") {
|
||||
fKeyWord = eMusrviewShowFourier;
|
||||
} else if (qName == "musrview_show_avg") {
|
||||
fKeyWord = eMusrviewShowAvg;
|
||||
} else if (qName == "enable_musrt0") {
|
||||
fKeyWord = eEnableMusrT0;
|
||||
} else if (qName == "keep_minuit2_output") {
|
||||
@ -251,6 +253,13 @@ bool PAdminXMLParser::characters(const QString& str)
|
||||
flag = false;
|
||||
fAdmin->setMusrviewShowFourierFlag(flag);
|
||||
break;
|
||||
case eMusrviewShowAvg:
|
||||
if (str == "y")
|
||||
flag = true;
|
||||
else
|
||||
flag = false;
|
||||
fAdmin->setMusrviewShowAvgFlag(flag);
|
||||
break;
|
||||
case eEnableMusrT0:
|
||||
if (str == "y")
|
||||
flag = true;
|
||||
@ -614,6 +623,7 @@ PAdmin::PAdmin() : QObject()
|
||||
fFileFormat = QString("");
|
||||
|
||||
fMusrviewShowFourier = false;
|
||||
fMusrviewShowAvg = false;
|
||||
|
||||
fTitleFromDataFile = false;
|
||||
fEnableMusrT0 = false;
|
||||
@ -837,6 +847,12 @@ int PAdmin::savePrefs(QString pref_fln)
|
||||
else
|
||||
data[i] = " <musrview_show_fourier>n</musrview_show_fourier>";
|
||||
}
|
||||
if (data[i].contains("<musrview_show_avg>") && data[i].contains("</musrview_show_avg>")) {
|
||||
if (fMusrviewShowAvg)
|
||||
data[i] = " <musrview_show_avg>y</musrview_show_avg>";
|
||||
else
|
||||
data[i] = " <musrview_show_avg>n</musrview_show_avg>";
|
||||
}
|
||||
if (data[i].contains("<enable_musrt0>") && data[i].contains("</enable_musrt0>")) {
|
||||
if (fEnableMusrT0)
|
||||
data[i] = " <enable_musrt0>y</enable_musrt0>";
|
||||
|
@ -69,7 +69,8 @@ class PAdminXMLParser : public QXmlDefaultHandler
|
||||
|
||||
private:
|
||||
enum EAdminKeyWords {eEmpty, eTimeout, eKeepMinuit2Output, eDumpAscii, eDumpRoot,
|
||||
eTitleFromDataFile, eChisqPreRunBlock, eEstimateN0, eMusrviewShowFourier, eEnableMusrT0,
|
||||
eTitleFromDataFile, eChisqPreRunBlock, eEstimateN0,
|
||||
eMusrviewShowFourier, eMusrviewShowAvg, eEnableMusrT0,
|
||||
eFontName, eFontSize, eExecPath, eDefaultSavePath,
|
||||
eRecentFile, eBeamline, eInstitute, eFileFormat, eLifetimeCorrection, eMsrDefaultFilePath,
|
||||
eTheoFuncPixmapPath, eFunc, eFuncName, eFuncComment, eFuncLabel,
|
||||
@ -119,6 +120,7 @@ class PAdmin : public QObject
|
||||
QString getDefaultSavePath() { return fDefaultSavePath; }
|
||||
bool getTitleFromDataFileFlag() { return fTitleFromDataFile; }
|
||||
bool getMusrviewShowFourierFlag() { return fMusrviewShowFourier; }
|
||||
bool getMusrviewShowAvgFlag() { return fMusrviewShowAvg; }
|
||||
bool getEnableMusrT0Flag() { return fEnableMusrT0; }
|
||||
bool getKeepMinuit2OutputFlag() { return fKeepMinuit2Output; }
|
||||
bool getDumpAsciiFlag() { return fDumpAscii; }
|
||||
@ -142,6 +144,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 setMusrviewShowAvgFlag(const bool flag) { fMusrviewShowAvg = flag; }
|
||||
void setEnableMusrT0Flag(const bool flag) { fEnableMusrT0 = flag; }
|
||||
void setKeepMinuit2OutputFlag(const bool flag) { fKeepMinuit2Output = flag; }
|
||||
void setDumpAsciiFlag(const bool flag) { fDumpAscii = flag; }
|
||||
@ -185,6 +188,7 @@ class PAdmin : public QObject
|
||||
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 fMusrviewShowAvg; ///< flag indicating if musrview should show at startup averaged (=true) or original (=false) data/Fourier.
|
||||
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).
|
||||
|
@ -62,6 +62,7 @@ PPrefsDialog::PPrefsDialog(PAdmin *admin) : fAdmin(admin)
|
||||
fPerRunBlockChisq_checkBox->setChecked(fAdmin->getChisqPerRunBlockFlag());
|
||||
fEstimateN0_checkBox->setChecked(fAdmin->getEstimateN0Flag());
|
||||
fFourier_checkBox->setChecked(fAdmin->getMusrviewShowFourierFlag());
|
||||
fAvg_checkBox->setChecked(fAdmin->getMusrviewShowAvgFlag());
|
||||
|
||||
fTimeout_lineEdit->setText(QString("%1").arg(fAdmin->getTimeout()));
|
||||
fTimeout_lineEdit->setValidator(new QIntValidator(fTimeout_lineEdit));
|
||||
|
@ -47,6 +47,7 @@ class PPrefsDialog : public QDialog, private Ui::PPrefsDialog
|
||||
PPrefsDialog(PAdmin *admin);
|
||||
|
||||
bool getMusrviewShowFourierFlag() { return fFourier_checkBox->isChecked(); }
|
||||
bool getMusrviewShowAvgFlag() { return fAvg_checkBox->isChecked(); }
|
||||
bool getKeepMinuit2OutputFlag() { return fKeepMn2Output_checkBox->isChecked(); }
|
||||
bool getTitleFromDataFileFlag() { return fTitleFromData_checkBox->isChecked(); }
|
||||
bool getEnableMusrT0Flag() { return fEnableMusrT0_checkBox->isChecked(); }
|
||||
|
@ -1699,6 +1699,12 @@ void PTextEdit::musrCalcChisq()
|
||||
if ( !currentEditor() )
|
||||
return;
|
||||
|
||||
int result = 0;
|
||||
if (fAdmin->getEstimateN0Flag())
|
||||
result = QMessageBox::question(this, "Estimate N0 active",
|
||||
"Do you wish a chisq/mlh evaluation with an automatic N0 estimate?",
|
||||
QMessageBox::Yes, QMessageBox::No);
|
||||
|
||||
QString tabLabel = fTabWidget->tabText(fTabWidget->currentIndex());
|
||||
if (tabLabel == "noname") {
|
||||
QMessageBox::critical(this, "**ERROR**", "For a fit a real msr-file is needed.");
|
||||
@ -1716,8 +1722,8 @@ void PTextEdit::musrCalcChisq()
|
||||
cmd.append(str);
|
||||
cmd.append(QFileInfo(*fFilenames.find( currentEditor())).fileName() );
|
||||
cmd.append("--chisq-only");
|
||||
cmd.append("--estimateN0");
|
||||
cmd.append("no");
|
||||
if (fAdmin->getEstimateN0Flag() && (result == QMessageBox::Yes))
|
||||
cmd.append("--estimateN0");
|
||||
PFitOutputHandler fitOutputHandler(QFileInfo(*fFilenames.find( currentEditor() )).absolutePath(), cmd);
|
||||
fitOutputHandler.setModal(true);
|
||||
fitOutputHandler.exec();
|
||||
@ -1770,19 +1776,11 @@ void PTextEdit::musrFit()
|
||||
// check estimate N0 flag
|
||||
if (fAdmin->getEstimateN0Flag()) {
|
||||
cmd.append("--estimateN0");
|
||||
cmd.append("yes");
|
||||
} else {
|
||||
cmd.append("--estimateN0");
|
||||
cmd.append("no");
|
||||
}
|
||||
|
||||
// check per-run-block-chisq flag
|
||||
if (fAdmin->getChisqPerRunBlockFlag()) {
|
||||
cmd.append("--per-run-block-chisq");
|
||||
cmd.append("yes");
|
||||
} else {
|
||||
cmd.append("--per-run-block-chisq");
|
||||
cmd.append("no");
|
||||
}
|
||||
|
||||
// add timeout
|
||||
@ -2203,6 +2201,8 @@ void PTextEdit::musrView()
|
||||
cmd += str + "\" --timeout " + numStr;
|
||||
if (fAdmin->getMusrviewShowFourierFlag())
|
||||
cmd += " -f ";
|
||||
if (fAdmin->getMusrviewShowAvgFlag())
|
||||
cmd += " -a ";
|
||||
cmd += " &";
|
||||
|
||||
int status=system(cmd.toLatin1());
|
||||
|
@ -33,7 +33,7 @@
|
||||
<item>
|
||||
<widget class="QTabWidget" name="fTabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="fGeneral_tab">
|
||||
<attribute name="title">
|
||||
@ -175,6 +175,19 @@
|
||||
<string>start with Fourier</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="fAvg_checkBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>40</y>
|
||||
<width>261</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>start with averaged data/Fourier</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="fMusrt0_tab">
|
||||
<attribute name="title">
|
||||
|
@ -15,6 +15,7 @@
|
||||
<chisq_per_run_block>n</chisq_per_run_block>
|
||||
<estimate_n0>y</estimate_n0>
|
||||
<musrview_show_fourier>n</musrview_show_fourier>
|
||||
<musrview_show_avg>n</musrview_show_avg>
|
||||
<enable_musrt0>y</enable_musrt0>
|
||||
</general>
|
||||
<recent_files>
|
||||
|
@ -37,6 +37,8 @@ using namespace std;
|
||||
#include <QTextStream>
|
||||
#include <QVector>
|
||||
|
||||
#include <QProcessEnvironment>
|
||||
|
||||
#include "PAdmin.h"
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@ -87,6 +89,8 @@ bool PAdminXMLParser::startElement( const QString&, const QString&,
|
||||
fKeyWord = eTitleFromDataFile;
|
||||
} else if (qName == "musrview_show_fourier") {
|
||||
fKeyWord = eMusrviewShowFourier;
|
||||
} else if (qName == "musrview_show_avg") {
|
||||
fKeyWord = eMusrviewShowAvg;
|
||||
} else if (qName == "enable_musrt0") {
|
||||
fKeyWord = eEnableMusrT0;
|
||||
} else if (qName == "keep_minuit2_output") {
|
||||
@ -234,7 +238,7 @@ bool PAdminXMLParser::characters(const QString& str)
|
||||
case eExecPath:
|
||||
fAdmin->setExecPath(QString(str.toLatin1()).trimmed());
|
||||
break;
|
||||
case eDefaultSavePath:
|
||||
case eDefaultSavePath:
|
||||
fAdmin->setDefaultSavePath(QString(str.toLatin1()).trimmed());
|
||||
break;
|
||||
case eTitleFromDataFile:
|
||||
@ -251,6 +255,13 @@ bool PAdminXMLParser::characters(const QString& str)
|
||||
flag = false;
|
||||
fAdmin->setMusrviewShowFourierFlag(flag);
|
||||
break;
|
||||
case eMusrviewShowAvg:
|
||||
if (str == "y")
|
||||
flag = true;
|
||||
else
|
||||
flag = false;
|
||||
fAdmin->setMusrviewShowAvgFlag(flag);
|
||||
break;
|
||||
case eEnableMusrT0:
|
||||
if (str == "y")
|
||||
flag = true;
|
||||
@ -477,7 +488,7 @@ bool PAdminXMLParser::endDocument()
|
||||
str = expandPath(fAdmin->getDefaultSavePath());
|
||||
if (!str.isEmpty())
|
||||
fAdmin->setDefaultSavePath(str);
|
||||
}
|
||||
}
|
||||
|
||||
if (fAdmin->getMsrDefaultFilePath().indexOf('$') >= 0) {
|
||||
str = expandPath(fAdmin->getMsrDefaultFilePath());
|
||||
@ -567,13 +578,21 @@ QString PAdminXMLParser::expandPath(const QString &str)
|
||||
QString msg;
|
||||
QString newStr="";
|
||||
|
||||
QProcessEnvironment procEnv = QProcessEnvironment::systemEnvironment();
|
||||
|
||||
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 (!procEnv.contains(token)) {
|
||||
msg = QString("Couldn't find '%1'. Some things might not work properly").arg(token);
|
||||
QMessageBox::warning(0, "**WARNING**", msg, QMessageBox::Ok, QMessageBox::NoButton);
|
||||
newStr = "";
|
||||
break;
|
||||
}
|
||||
path = procEnv.value(token, "");
|
||||
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);
|
||||
@ -614,6 +633,7 @@ PAdmin::PAdmin() : QObject()
|
||||
fFileFormat = QString("");
|
||||
|
||||
fMusrviewShowFourier = false;
|
||||
fMusrviewShowAvg = false;
|
||||
|
||||
fTitleFromDataFile = false;
|
||||
fEnableMusrT0 = false;
|
||||
@ -646,17 +666,18 @@ PAdmin::PAdmin() : QObject()
|
||||
QString path = QString("./");
|
||||
QString fln = QString("musredit_startup.xml");
|
||||
QString pathFln = path + fln;
|
||||
QProcessEnvironment procEnv = QProcessEnvironment::systemEnvironment();
|
||||
if (!QFile::exists(pathFln)) {
|
||||
// 2nd: check $HOME/.musrfit/musredit/musredit_startup.xml
|
||||
path = std::getenv("HOME");
|
||||
path = procEnv.value("HOME", "");
|
||||
pathFln = path + "/.musrfit/musredit/" + fln;
|
||||
if (!QFile::exists(pathFln)) {
|
||||
// 3rd: check $MUSRFITPATH/musredit_startup.xml
|
||||
path = std::getenv("MUSRFITPATH");
|
||||
path = procEnv.value("MUSRFITPATH", "");
|
||||
pathFln = path + "/" + fln;
|
||||
if (!QFile::exists(pathFln)) {
|
||||
// 4th: check $ROOTSYS/bin/musredit_startup.xml
|
||||
path = std::getenv("ROOTSYS");
|
||||
path = procEnv.value("ROOTSYS", "");
|
||||
pathFln = path + "/bin/" + fln;
|
||||
}
|
||||
}
|
||||
@ -837,12 +858,24 @@ int PAdmin::savePrefs(QString pref_fln)
|
||||
else
|
||||
data[i] = " <musrview_show_fourier>n</musrview_show_fourier>";
|
||||
}
|
||||
if (data[i].contains("<musrview_show_avg>") && data[i].contains("</musrview_show_avg>")) {
|
||||
if (fMusrviewShowAvg)
|
||||
data[i] = " <musrview_show_avg>y</musrview_show_avg>";
|
||||
else
|
||||
data[i] = " <musrview_show_avg>n</musrview_show_avg>";
|
||||
}
|
||||
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>";
|
||||
}
|
||||
if (data[i].contains("<font_name>") && data[i].contains("</font_name>")) {
|
||||
data[i] = QString(" <font_name>%1</font_name>").arg(fFontName);
|
||||
}
|
||||
if (data[i].contains("<font_size>") && data[i].contains("</font_size>")) {
|
||||
data[i] = QString(" <font_size>%1</font_size>").arg(fFontSize);
|
||||
}
|
||||
}
|
||||
|
||||
// write prefs
|
||||
|
@ -69,7 +69,8 @@ class PAdminXMLParser : public QXmlDefaultHandler
|
||||
|
||||
private:
|
||||
enum EAdminKeyWords {eEmpty, eTimeout, eKeepMinuit2Output, eDumpAscii, eDumpRoot,
|
||||
eTitleFromDataFile, eChisqPreRunBlock, eEstimateN0, eMusrviewShowFourier, eEnableMusrT0,
|
||||
eTitleFromDataFile, eChisqPreRunBlock, eEstimateN0,
|
||||
eMusrviewShowFourier, eMusrviewShowAvg, eEnableMusrT0,
|
||||
eFontName, eFontSize, eExecPath, eDefaultSavePath,
|
||||
eRecentFile, eBeamline, eInstitute, eFileFormat, eLifetimeCorrection, eMsrDefaultFilePath,
|
||||
eTheoFuncPixmapPath, eFunc, eFuncName, eFuncComment, eFuncLabel,
|
||||
@ -119,6 +120,7 @@ class PAdmin : public QObject
|
||||
QString getDefaultSavePath() { return fDefaultSavePath; }
|
||||
bool getTitleFromDataFileFlag() { return fTitleFromDataFile; }
|
||||
bool getMusrviewShowFourierFlag() { return fMusrviewShowFourier; }
|
||||
bool getMusrviewShowAvgFlag() { return fMusrviewShowAvg; }
|
||||
bool getEnableMusrT0Flag() { return fEnableMusrT0; }
|
||||
bool getKeepMinuit2OutputFlag() { return fKeepMinuit2Output; }
|
||||
bool getDumpAsciiFlag() { return fDumpAscii; }
|
||||
@ -142,6 +144,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 setMusrviewShowAvgFlag(const bool flag) { fMusrviewShowAvg = flag; }
|
||||
void setEnableMusrT0Flag(const bool flag) { fEnableMusrT0 = flag; }
|
||||
void setKeepMinuit2OutputFlag(const bool flag) { fKeepMinuit2Output = flag; }
|
||||
void setDumpAsciiFlag(const bool flag) { fDumpAscii = flag; }
|
||||
@ -185,6 +188,7 @@ class PAdmin : public QObject
|
||||
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 fMusrviewShowAvg; ///< flag indicating if musrview should show at startup averaged (=true) or original (=false) data/Fourier.
|
||||
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).
|
||||
|
@ -62,6 +62,10 @@ PFitOutputHandler::PFitOutputHandler(QString workingDirectory, QVector<QString>
|
||||
// QProcess related code
|
||||
fProc = new QProcess( this );
|
||||
|
||||
// make sure that the system environment variables are properly set
|
||||
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||
env.insert("LD_LIBRARY_PATH", env.value("ROOTSYS") + "/lib:" + env.value("LD_LIBRARY_PATH"));
|
||||
fProc->setProcessEnvironment(env);
|
||||
fProc->setWorkingDirectory(workingDirectory);
|
||||
|
||||
// Set up the command and arguments.
|
||||
|
@ -62,6 +62,7 @@ PPrefsDialog::PPrefsDialog(PAdmin *admin) : fAdmin(admin)
|
||||
fPerRunBlockChisq_checkBox->setChecked(fAdmin->getChisqPerRunBlockFlag());
|
||||
fEstimateN0_checkBox->setChecked(fAdmin->getEstimateN0Flag());
|
||||
fFourier_checkBox->setChecked(fAdmin->getMusrviewShowFourierFlag());
|
||||
fAvg_checkBox->setChecked(fAdmin->getMusrviewShowAvgFlag());
|
||||
|
||||
fTimeout_lineEdit->setText(QString("%1").arg(fAdmin->getTimeout()));
|
||||
fTimeout_lineEdit->setValidator(new QIntValidator(fTimeout_lineEdit));
|
||||
|
@ -47,6 +47,7 @@ class PPrefsDialog : public QDialog, private Ui::PPrefsDialog
|
||||
PPrefsDialog(PAdmin *admin);
|
||||
|
||||
bool getMusrviewShowFourierFlag() { return fFourier_checkBox->isChecked(); }
|
||||
bool getMusrviewShowAvgFlag() { return fAvg_checkBox->isChecked(); }
|
||||
bool getKeepMinuit2OutputFlag() { return fKeepMn2Output_checkBox->isChecked(); }
|
||||
bool getTitleFromDataFileFlag() { return fTitleFromData_checkBox->isChecked(); }
|
||||
bool getEnableMusrT0Flag() { return fEnableMusrT0_checkBox->isChecked(); }
|
||||
|
@ -848,6 +848,13 @@ void PTextEdit::fileOpen()
|
||||
|
||||
++it;
|
||||
}
|
||||
|
||||
// in case there is a 1st empty tab "noname", remove it
|
||||
if (fTabWidget->tabText(0) == "noname") { // has to be the first, otherwise do nothing
|
||||
fFileSystemWatcher->removePath("noname");
|
||||
|
||||
delete fTabWidget->widget(0);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -879,6 +886,13 @@ void PTextEdit::fileOpenRecent()
|
||||
else
|
||||
fileReload();
|
||||
}
|
||||
|
||||
// in case there is a 1st empty tab "noname", remove it
|
||||
if (fTabWidget->tabText(0) == "noname") { // has to be the first, otherwise do nothing
|
||||
fFileSystemWatcher->removePath("noname");
|
||||
|
||||
delete fTabWidget->widget(0);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -1699,6 +1713,11 @@ void PTextEdit::musrCalcChisq()
|
||||
if ( !currentEditor() )
|
||||
return;
|
||||
|
||||
int result = 0;
|
||||
if (fAdmin->getEstimateN0Flag())
|
||||
result = QMessageBox::question(this, "Estimate N0 active",
|
||||
"Do you wish a chisq/mlh evaluation with an automatic N0 estimate?");
|
||||
|
||||
QString tabLabel = fTabWidget->tabText(fTabWidget->currentIndex());
|
||||
if (tabLabel == "noname") {
|
||||
QMessageBox::critical(this, "**ERROR**", "For a fit a real msr-file is needed.");
|
||||
@ -1716,8 +1735,8 @@ void PTextEdit::musrCalcChisq()
|
||||
cmd.append(str);
|
||||
cmd.append(QFileInfo(*fFilenames.find( currentEditor())).fileName() );
|
||||
cmd.append("--chisq-only");
|
||||
cmd.append("--estimateN0");
|
||||
cmd.append("no");
|
||||
if (fAdmin->getEstimateN0Flag() && (result == QMessageBox::Yes))
|
||||
cmd.append("--estimateN0");
|
||||
PFitOutputHandler fitOutputHandler(QFileInfo(*fFilenames.find( currentEditor() )).absolutePath(), cmd);
|
||||
fitOutputHandler.setModal(true);
|
||||
fitOutputHandler.exec();
|
||||
@ -1770,19 +1789,11 @@ void PTextEdit::musrFit()
|
||||
// check estimate N0 flag
|
||||
if (fAdmin->getEstimateN0Flag()) {
|
||||
cmd.append("--estimateN0");
|
||||
cmd.append("yes");
|
||||
} else {
|
||||
cmd.append("--estimateN0");
|
||||
cmd.append("no");
|
||||
}
|
||||
|
||||
// check per-run-block-chisq flag
|
||||
if (fAdmin->getChisqPerRunBlockFlag()) {
|
||||
cmd.append("--per-run-block-chisq");
|
||||
cmd.append("yes");
|
||||
} else {
|
||||
cmd.append("--per-run-block-chisq");
|
||||
cmd.append("no");
|
||||
}
|
||||
|
||||
// add timeout
|
||||
@ -2205,9 +2216,26 @@ void PTextEdit::musrView()
|
||||
if (fAdmin->getMusrviewShowFourierFlag())
|
||||
arg << "-f";
|
||||
|
||||
QProcess proc(this);
|
||||
if (!proc.startDetached(cmd, arg, workDir)) {
|
||||
QMessageBox::critical(this, "ERROR", "**ERROR** musrview process couldn't be launched properly, sorry.");
|
||||
// start with averaged data/Fourier?
|
||||
if (fAdmin->getMusrviewShowAvgFlag())
|
||||
arg << "-a";
|
||||
|
||||
QProcess *proc = new QProcess(this);
|
||||
|
||||
// make sure that the system environment variables are properly set
|
||||
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||
env.insert("LD_LIBRARY_PATH", env.value("ROOTSYS") + "/lib:" + env.value("LD_LIBRARY_PATH"));
|
||||
proc->setProcessEnvironment(env);
|
||||
proc->setWorkingDirectory(workDir);
|
||||
proc->start(cmd, arg);
|
||||
if (!proc->waitForStarted()) {
|
||||
// error handling
|
||||
QString msg(tr("Could not execute the output command: ")+cmd[0]);
|
||||
QMessageBox::critical( 0,
|
||||
tr("Fatal error"),
|
||||
msg,
|
||||
tr("Quit") );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2246,9 +2274,22 @@ void PTextEdit::musrT0()
|
||||
str.setNum(fAdmin->getTimeout());
|
||||
arg << "--timeout" << str;
|
||||
|
||||
QProcess proc(this);
|
||||
if (!proc.startDetached(cmd, arg, workDir)) {
|
||||
QMessageBox::critical(this, "ERROR", "**ERROR** musrt0 process couldn't be launched properly, sorry.");
|
||||
QProcess *proc = new QProcess(this);
|
||||
|
||||
// make sure that the system environment variables are properly set
|
||||
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||
env.insert("LD_LIBRARY_PATH", env.value("ROOTSYS") + "/lib:" + env.value("LD_LIBRARY_PATH"));
|
||||
proc->setProcessEnvironment(env);
|
||||
proc->setWorkingDirectory(workDir);
|
||||
proc->start(cmd, arg);
|
||||
if (!proc->waitForStarted()) {
|
||||
// error handling
|
||||
QString msg(tr("Could not execute the output command: ")+cmd[0]);
|
||||
QMessageBox::critical( 0,
|
||||
tr("Fatal error"),
|
||||
msg,
|
||||
tr("Quit") );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2269,11 +2310,23 @@ void PTextEdit::musrFT()
|
||||
|
||||
if (dlg->exec() == QDialog::Accepted) {
|
||||
fMusrFTPrevCmd = dlg->getMusrFTOptions();
|
||||
QProcess proc(this);
|
||||
proc.setStandardOutputFile("musrFT.log");
|
||||
proc.setStandardErrorFile("musrFT.log");
|
||||
QProcess *proc = new QProcess(this);
|
||||
proc->setStandardOutputFile("musrFT.log");
|
||||
proc->setStandardErrorFile("musrFT.log");
|
||||
QString cmd = fAdmin->getExecPath() + "/musrFT";
|
||||
proc.startDetached(cmd, fMusrFTPrevCmd);
|
||||
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||
env.insert("LD_LIBRARY_PATH", env.value("ROOTSYS") + "/lib:" + env.value("LD_LIBRARY_PATH"));
|
||||
proc->setProcessEnvironment(env);
|
||||
proc->start(cmd, fMusrFTPrevCmd);
|
||||
if (!proc->waitForStarted()) {
|
||||
// error handling
|
||||
QString msg(tr("Could not execute the output command: ")+cmd[0]);
|
||||
QMessageBox::critical( 0,
|
||||
tr("Fatal error"),
|
||||
msg,
|
||||
tr("Quit") );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
delete dlg;
|
||||
@ -2295,6 +2348,7 @@ void PTextEdit::musrPrefs()
|
||||
|
||||
if (dlg->exec() == QDialog::Accepted) {
|
||||
fAdmin->setMusrviewShowFourierFlag(dlg->getMusrviewShowFourierFlag());
|
||||
fAdmin->setMusrviewShowAvgFlag(dlg->getMusrviewShowAvgFlag());
|
||||
fAdmin->setKeepMinuit2OutputFlag(dlg->getKeepMinuit2OutputFlag());
|
||||
fAdmin->setTitleFromDataFileFlag(dlg->getTitleFromDataFileFlag());
|
||||
fAdmin->setEnableMusrT0Flag(dlg->getEnableMusrT0Flag());
|
||||
|
@ -17,7 +17,7 @@
|
||||
<string>Preferences</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../musredit.qrc">
|
||||
<iconset>
|
||||
<normaloff>:/images/musrfit.xpm</normaloff>:/images/musrfit.xpm</iconset>
|
||||
</property>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
@ -175,6 +175,19 @@
|
||||
<string>start with Fourier</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="fAvg_checkBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>40</y>
|
||||
<width>231</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>start with averaged data/Fourier</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="fMusrt0_tab">
|
||||
<attribute name="title">
|
||||
|
@ -15,6 +15,7 @@
|
||||
<chisq_per_run_block>n</chisq_per_run_block>
|
||||
<estimate_n0>y</estimate_n0>
|
||||
<musrview_show_fourier>n</musrview_show_fourier>
|
||||
<musrview_show_avg>n</musrview_show_avg>
|
||||
<enable_musrt0>y</enable_musrt0>
|
||||
</general>
|
||||
<recent_files>
|
||||
|
@ -106,9 +106,8 @@ void musrfit_syntax()
|
||||
cout << endl << " -t, --title-from-data-file: will replace the <msr-file> run title by the";
|
||||
cout << endl << " run title of the FIRST run of the <msr-file> run block, if a run title";
|
||||
cout << endl << " is present in the data file.";
|
||||
cout << endl << " -e, --estimateN0: estimate N0 for single histogram fits flag. <flag> can have the values 'yes' or 'no'.";
|
||||
cout << endl << " -e, --estimateN0: estimate N0 for single histogram fits.";
|
||||
cout << endl << " -p, --per-run-block-chisq: will write per run block chisq to the msr-file.";
|
||||
cout << endl << " <flag> can have the values 'yes' or 'no'.";
|
||||
cout << endl << " --dump <type> is writing a data file with the fit data and the theory";
|
||||
cout << endl << " <type> can be 'ascii', 'root'";
|
||||
cout << endl << " --timeout <timeout_tag>: overwrites to predefined timeout of " << timeout << " (sec).";
|
||||
@ -527,8 +526,7 @@ int main(int argc, char *argv[])
|
||||
bool timeout_enabled = true;
|
||||
PStartupOptions startup_options;
|
||||
startup_options.writeExpectedChisq = false;
|
||||
startup_options.estimateN0 = true;
|
||||
startup_options.alphaEstimateN0 = 0.0;
|
||||
startup_options.estimateN0 = false;
|
||||
|
||||
TString dump("");
|
||||
char filename[1024];
|
||||
@ -579,39 +577,9 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
}
|
||||
} else if (!strcmp(argv[i], "-e") || !strcmp(argv[i], "--estimateN0")) {
|
||||
if (i<argc-1) {
|
||||
if (!strcmp(argv[i+1], "yes")) {
|
||||
startup_options.estimateN0 = true;
|
||||
} else if (!strcmp(argv[i+1], "no")) {
|
||||
startup_options.estimateN0 = false;
|
||||
} else {
|
||||
cerr << endl << "musrfit: **ERROR** option --estimateN0 <flag> with unsupported <flag> = " << argv[i+1] << endl;
|
||||
show_syntax = true;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
} else {
|
||||
cerr << endl << "musrfit: **ERROR** found option --estimateN0 without <flag>" << endl;
|
||||
show_syntax = true;
|
||||
break;
|
||||
}
|
||||
startup_options.estimateN0 = true;
|
||||
} else if (!strcmp(argv[i], "-p") || !strcmp(argv[i], "--per-run-block-chisq")) {
|
||||
if (i<argc-1) {
|
||||
if (!strcmp(argv[i+1], "yes")) {
|
||||
startup_options.writeExpectedChisq = true;
|
||||
} else if (!strcmp(argv[i+1], "no")) {
|
||||
startup_options.writeExpectedChisq = false;
|
||||
} else {
|
||||
cerr << endl << "musrfit: **ERROR** option --per-run-block-chisq <flag> with unsupported <flag> = " << argv[i+1] << endl;
|
||||
show_syntax = true;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
} else {
|
||||
cerr << endl << "musrfit: **ERROR** found option --per-run-block-chisq without <flag>" << endl;
|
||||
show_syntax = true;
|
||||
break;
|
||||
}
|
||||
startup_options.writeExpectedChisq = true;
|
||||
} else if (!strcmp(argv[i], "--timeout")) {
|
||||
if (i<argc-1) {
|
||||
TString str(argv[i+1]);
|
||||
@ -697,13 +665,11 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
}
|
||||
if (startupHandler)
|
||||
startupHandler->SetStartupOptions(startup_options);
|
||||
|
||||
// read msr-file
|
||||
PMsrHandler *msrHandler = 0;
|
||||
if (startupHandler)
|
||||
msrHandler = new PMsrHandler(filename, startupHandler->GetStartupOptions());
|
||||
msrHandler = new PMsrHandler(filename, &startup_options);
|
||||
else
|
||||
msrHandler = new PMsrHandler(filename);
|
||||
status = msrHandler->ReadMsrFile();
|
||||
|
@ -15,9 +15,6 @@
|
||||
<data_path>/afs/psi.ch/project/bulkmusr/data/hifi</data_path>
|
||||
<data_path>/afs/psi.ch/project/bulkmusr/data/lem</data_path>
|
||||
<options>
|
||||
<write_per_run_block_chisq>n</write_per_run_block_chisq>
|
||||
<estimate_n0>yes</estimate_n0>
|
||||
<alpha_estimate_n0>0.0</alpha_estimate_n0>
|
||||
<use_dks>yes</use_dks>
|
||||
</options>
|
||||
<fourier_settings>
|
||||
|
@ -63,6 +63,7 @@ void musrview_syntax()
|
||||
cout << endl << " --help : display this help and exit.";
|
||||
cout << endl << " --version : output version information and exit.";
|
||||
cout << endl << " -f, --fourier: will directly present the Fourier transform of the <msr-file>.";
|
||||
cout << endl << " -a, --avg: will directly present the averaged data/Fourier of the <msr-file>.";
|
||||
cout << endl << " --<graphic-format-extension>: ";
|
||||
cout << endl << " will produce a graphics-output-file without starting a root session.";
|
||||
cout << endl << " the name is based on the <msr-file>, e.g. 3310.msr -> 3310_0.png";
|
||||
@ -102,6 +103,7 @@ int main(int argc, char *argv[])
|
||||
bool success = true;
|
||||
char fileName[128];
|
||||
bool fourier = false;
|
||||
bool avg = false;
|
||||
bool graphicsOutput = false;
|
||||
bool asciiOutput = false;
|
||||
char graphicsExtension[128];
|
||||
@ -135,6 +137,8 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
} else if (!strcmp(argv[i], "-f") || !strcmp(argv[i], "--fourier")) {
|
||||
fourier = true;
|
||||
} else if (!strcmp(argv[i], "-a") || !strcmp(argv[i], "--avg")) {
|
||||
avg = true;
|
||||
} else if (!strcmp(argv[i], "--eps") || !strcmp(argv[i], "--pdf") || !strcmp(argv[i], "--gif") ||
|
||||
!strcmp(argv[i], "--jpg") || !strcmp(argv[i], "--png") || !strcmp(argv[i], "--svg") ||
|
||||
!strcmp(argv[i], "--xpm") || !strcmp(argv[i], "--root")) {
|
||||
@ -308,12 +312,12 @@ int main(int argc, char *argv[])
|
||||
startupHandler->GetMarkerList(),
|
||||
startupHandler->GetColorList(),
|
||||
graphicsOutput||asciiOutput,
|
||||
fourier, startupHandler->GetStartupOptions()->useDKS);
|
||||
fourier, avg, startupHandler->GetStartupOptions()->useDKS);
|
||||
else
|
||||
musrCanvas = new PMusrCanvas(i, msrHandler->GetMsrTitle()->Data(),
|
||||
10+i*100, 10+i*100, 800, 600,
|
||||
graphicsOutput||asciiOutput,
|
||||
fourier, startupHandler->GetStartupOptions()->useDKS);
|
||||
fourier, avg, startupHandler->GetStartupOptions()->useDKS);
|
||||
|
||||
if (!musrCanvas->IsValid()) {
|
||||
cerr << endl << ">> musrview **SEVERE ERROR** Couldn't invoke all necessary objects, will quit.";
|
||||
|
Reference in New Issue
Block a user