resolved merge conflicts with master

This commit is contained in:
2016-12-23 14:16:22 +01:00
54 changed files with 2297 additions and 829 deletions

View File

@@ -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;

View File

@@ -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;
}
}
}

View File

@@ -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;
}
}
}

View File

@@ -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;

View File

@@ -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);

View File

@@ -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)
//--------------------------------------------------------------------------

View File

@@ -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;
}

View File

@@ -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)
//--------------------------------------------------------------------------

View File

@@ -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;

View File

@@ -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"))