It is now possible to export the averaged data/Fourier

This commit is contained in:
2016-02-23 13:22:41 +01:00
parent 352ac5db21
commit fe48da74a1
3 changed files with 274 additions and 487 deletions

View File

@ -4,7 +4,7 @@
changes since 0.17.0 changes since 0.17.0
=================================== ===================================
NEW 2016-02-23 It is now possible to export the averaged data/Fourier
changes since 0.16.0 changes since 0.16.0
=================================== ===================================

View File

@ -1516,7 +1516,6 @@ void PMusrCanvas::ExportData(const Char_t *fileName)
Int_t xmaxBin; Int_t xmaxBin;
Double_t xmin; Double_t xmin;
Double_t xmax; Double_t xmax;
Double_t time, freq;
Double_t xval, yval; Double_t xval, yval;
switch (fPlotType) { switch (fPlotType) {
@ -1533,30 +1532,13 @@ void PMusrCanvas::ExportData(const Char_t *fileName)
xmax = fHistoFrame->GetXaxis()->GetBinCenter(xmaxBin); xmax = fHistoFrame->GetXaxis()->GetBinCenter(xmaxBin);
// fill ascii dump data // fill ascii dump data
if (fAveragedView) {
GetExportDataSet(fDataAvg.diff, xmin, xmax, dumpVector);
} else { // go through all the histogramms
for (UInt_t i=0; i<fData.size(); i++) { // go through all the histogramms for (UInt_t i=0; i<fData.size(); i++) { // go through all the histogramms
// clean up dump GetExportDataSet(fData[i].diff, xmin, xmax, dumpVector);
dump.dataX.clear();
dump.data.clear();
dump.dataErr.clear();
dump.theoryX.clear();
dump.theory.clear();
// go through all difference data bins
for (Int_t j=1; j<fData[i].diff->GetNbinsX(); j++) {
// get time
time = fData[i].diff->GetBinCenter(j);
// check if time is in the current range
if ((time >= xmin) && (time <= xmax)) {
dump.dataX.push_back(time);
dump.data.push_back(fData[i].diff->GetBinContent(j));
dump.dataErr.push_back(fData[i].diff->GetBinError(j));
} }
} }
// if anything found keep it
if (dump.dataX.size() > 0)
dumpVector.push_back(dump);
}
break; break;
case PV_FOURIER_REAL: case PV_FOURIER_REAL:
// get current x-range // get current x-range
@ -1566,29 +1548,13 @@ void PMusrCanvas::ExportData(const Char_t *fileName)
xmax = fData[0].diffFourierRe->GetXaxis()->GetBinCenter(xmaxBin); xmax = fData[0].diffFourierRe->GetXaxis()->GetBinCenter(xmaxBin);
// fill ascii dump data // fill ascii dump data
if (fAveragedView) {
GetExportDataSet(fDataAvg.diffFourierRe, xmin, xmax, dumpVector, false);
} else { // go through all the histogramms
for (UInt_t i=0; i<fData.size(); i++) { // go through all the histogramms for (UInt_t i=0; i<fData.size(); i++) { // go through all the histogramms
// clean up dump GetExportDataSet(fData[i].diffFourierRe, xmin, xmax, dumpVector, false);
dump.dataX.clear();
dump.data.clear();
dump.dataErr.clear();
dump.theoryX.clear();
dump.theory.clear();
// go through all data bins
for (Int_t j=1; j<fData[i].diffFourierRe->GetNbinsX(); j++) {
// get frequency
freq = fData[i].diffFourierRe->GetBinCenter(j);
// check if time is in the current range
if ((freq >= xmin) && (freq <= xmax)) {
dump.dataX.push_back(freq);
dump.data.push_back(fData[i].diffFourierRe->GetBinContent(j));
} }
} }
// if anything found keep it
if (dump.dataX.size() > 0)
dumpVector.push_back(dump);
}
break; break;
case PV_FOURIER_IMAG: case PV_FOURIER_IMAG:
// get current x-range // get current x-range
@ -1598,29 +1564,13 @@ void PMusrCanvas::ExportData(const Char_t *fileName)
xmax = fData[0].diffFourierIm->GetXaxis()->GetBinCenter(xmaxBin); xmax = fData[0].diffFourierIm->GetXaxis()->GetBinCenter(xmaxBin);
// fill ascii dump data // fill ascii dump data
if (fAveragedView) {
GetExportDataSet(fDataAvg.diffFourierIm, xmin, xmax, dumpVector, false);
} else { // go through all the histogramms
for (UInt_t i=0; i<fData.size(); i++) { // go through all the histogramms for (UInt_t i=0; i<fData.size(); i++) { // go through all the histogramms
// clean up dump GetExportDataSet(fData[i].diffFourierIm, xmin, xmax, dumpVector, false);
dump.dataX.clear();
dump.data.clear();
dump.dataErr.clear();
dump.theoryX.clear();
dump.theory.clear();
// go through all data bins
for (Int_t j=1; j<fData[i].diffFourierIm->GetNbinsX(); j++) {
// get frequency
freq = fData[i].diffFourierIm->GetBinCenter(j);
// check if time is in the current range
if ((freq >= xmin) && (freq <= xmax)) {
dump.dataX.push_back(freq);
dump.data.push_back(fData[i].diffFourierIm->GetBinContent(j));
} }
} }
// if anything found keep it
if (dump.dataX.size() > 0)
dumpVector.push_back(dump);
}
break; break;
case PV_FOURIER_REAL_AND_IMAG: case PV_FOURIER_REAL_AND_IMAG:
// get current x-range // get current x-range
@ -1630,38 +1580,15 @@ void PMusrCanvas::ExportData(const Char_t *fileName)
xmax = fData[0].diffFourierRe->GetXaxis()->GetBinCenter(xmaxBin); xmax = fData[0].diffFourierRe->GetXaxis()->GetBinCenter(xmaxBin);
// fill ascii dump data // fill ascii dump data
if (fAveragedView) {
GetExportDataSet(fDataAvg.diffFourierRe, xmin, xmax, dumpVector, false);
GetExportDataSet(fDataAvg.diffFourierIm, xmin, xmax, dumpVector, false);
} else { // go through all the histogramms
for (UInt_t i=0; i<fData.size(); i++) { // go through all the histogramms for (UInt_t i=0; i<fData.size(); i++) { // go through all the histogramms
// clean up dump GetExportDataSet(fData[i].diffFourierRe, xmin, xmax, dumpVector, false);
dump.dataX.clear(); GetExportDataSet(fData[i].diffFourierIm, xmin, xmax, dumpVector, false);
dump.data.clear();
dump.dataErr.clear();
dump.theoryX.clear();
dump.theory.clear();
// go through all data bins
for (Int_t j=1; j<fData[i].diffFourierRe->GetNbinsX(); j++) {
// get frequency
freq = fData[i].diffFourierRe->GetBinCenter(j);
// check if time is in the current range
if ((freq >= xmin) && (freq <= xmax)) {
dump.dataX.push_back(freq);
dump.data.push_back(fData[i].diffFourierRe->GetBinContent(j));
} }
} }
for (Int_t j=1; j<fData[i].diffFourierIm->GetNbinsX(); j++) {
// get frequency
freq = fData[i].diffFourierIm->GetBinCenter(j);
// check if time is in the current range
if ((freq >= xmin) && (freq <= xmax)) {
dump.dataX.push_back(freq);
dump.data.push_back(fData[i].diffFourierIm->GetBinContent(j));
}
}
// if anything found keep it
if (dump.dataX.size() > 0)
dumpVector.push_back(dump);
}
break; break;
case PV_FOURIER_PWR: case PV_FOURIER_PWR:
// get current x-range // get current x-range
@ -1671,29 +1598,13 @@ void PMusrCanvas::ExportData(const Char_t *fileName)
xmax = fData[0].diffFourierPwr->GetXaxis()->GetBinCenter(xmaxBin); xmax = fData[0].diffFourierPwr->GetXaxis()->GetBinCenter(xmaxBin);
// fill ascii dump data // fill ascii dump data
for (UInt_t i=0; i<fData.size(); i++) { // go through all the histogramms if (fAveragedView) {
// clean up dump GetExportDataSet(fDataAvg.diffFourierPwr, xmin, xmax, dumpVector, false);
dump.dataX.clear(); } else { // go through all the histogramms
dump.data.clear(); for (UInt_t i=0; i<fData.size(); i++) {
dump.dataErr.clear(); GetExportDataSet(fData[i].diffFourierPwr, xmin, xmax, dumpVector, false);
dump.theoryX.clear();
dump.theory.clear();
// go through all data bins
for (Int_t j=1; j<fData[i].diffFourierPwr->GetNbinsX(); j++) {
// get frequency
freq = fData[i].diffFourierPwr->GetBinCenter(j);
// check if time is in the current range
if ((freq >= xmin) && (freq <= xmax)) {
dump.dataX.push_back(freq);
dump.data.push_back(fData[i].diffFourierPwr->GetBinContent(j));
} }
} }
// if anything found keep it
if (dump.dataX.size() > 0)
dumpVector.push_back(dump);
}
break; break;
case PV_FOURIER_PHASE: case PV_FOURIER_PHASE:
// get current x-range // get current x-range
@ -1703,29 +1614,13 @@ void PMusrCanvas::ExportData(const Char_t *fileName)
xmax = fData[0].diffFourierPhase->GetXaxis()->GetBinCenter(xmaxBin); xmax = fData[0].diffFourierPhase->GetXaxis()->GetBinCenter(xmaxBin);
// fill ascii dump data // fill ascii dump data
for (UInt_t i=0; i<fData.size(); i++) { // go through all the histogramms if (fAveragedView) {
// clean up dump GetExportDataSet(fDataAvg.diffFourierPhase, xmin, xmax, dumpVector, false);
dump.dataX.clear(); } else { // go through all the histogramms
dump.data.clear(); for (UInt_t i=0; i<fData.size(); i++) {
dump.dataErr.clear(); GetExportDataSet(fData[i].diffFourierPhase, xmin, xmax, dumpVector, false);
dump.theoryX.clear();
dump.theory.clear();
// go through all data bins
for (Int_t j=1; j<fData[i].diffFourierPhase->GetNbinsX(); j++) {
// get frequency
freq = fData[i].diffFourierPhase->GetBinCenter(j);
// check if time is in the current range
if ((freq >= xmin) && (freq <= xmax)) {
dump.dataX.push_back(freq);
dump.data.push_back(fData[i].diffFourierPhase->GetBinContent(j));
} }
} }
// if anything found keep it
if (dump.dataX.size() > 0)
dumpVector.push_back(dump);
}
break; break;
default: default:
break; break;
@ -1740,42 +1635,16 @@ void PMusrCanvas::ExportData(const Char_t *fileName)
xmax = fHistoFrame->GetXaxis()->GetBinCenter(xmaxBin); xmax = fHistoFrame->GetXaxis()->GetBinCenter(xmaxBin);
// fill ascii dump data // fill ascii dump data
for (UInt_t i=0; i<fData.size(); i++) { // go through all the histogramms if (fAveragedView) {
// clean up dump GetExportDataSet(fDataAvg.data, xmin, xmax, dumpVector);
dump.dataX.clear(); GetExportDataSet(fDataAvg.theory, xmin, xmax, dumpVector, false);
dump.data.clear(); } else { // go through all the histogramms
dump.dataErr.clear(); for (UInt_t i=0; i<fData.size(); i++) {
dump.theoryX.clear(); GetExportDataSet(fData[i].data, xmin, xmax, dumpVector);
dump.theory.clear(); GetExportDataSet(fData[i].theory, xmin, xmax, dumpVector, false);
// go through all data bins
for (Int_t j=1; j<fData[i].data->GetNbinsX(); j++) {
// get time
time = fData[i].data->GetBinCenter(j);
// check if time is in the current range
if ((time >= xmin) && (time <= xmax)) {
dump.dataX.push_back(time);
dump.data.push_back(fData[i].data->GetBinContent(j));
dump.dataErr.push_back(fData[i].data->GetBinError(j));
} }
} }
// go through all theory bins
for (Int_t j=1; j<fData[i].theory->GetNbinsX(); j++) {
// get time
time = fData[i].theory->GetBinCenter(j);
// check if time is in the current range
if ((time >= xmin) && (time <= xmax)) {
dump.theoryX.push_back(time);
dump.theory.push_back(fData[i].theory->GetBinContent(j));
}
}
// if anything found keep it
if (dump.dataX.size() > 0)
dumpVector.push_back(dump);
}
break; break;
case PV_FOURIER_REAL: case PV_FOURIER_REAL:
// get current x-range // get current x-range
@ -1785,40 +1654,15 @@ void PMusrCanvas::ExportData(const Char_t *fileName)
xmax = fData[0].dataFourierRe->GetXaxis()->GetBinCenter(xmaxBin); xmax = fData[0].dataFourierRe->GetXaxis()->GetBinCenter(xmaxBin);
// fill ascii dump data // fill ascii dump data
for (UInt_t i=0; i<fData.size(); i++) { // go through all the histogramms if (fAveragedView) {
// clean up dump GetExportDataSet(fDataAvg.dataFourierRe, xmin, xmax, dumpVector, false);
dump.dataX.clear(); GetExportDataSet(fDataAvg.theoryFourierRe, xmin, xmax, dumpVector, false);
dump.data.clear(); } else { // go through all the histogramms
dump.dataErr.clear(); for (UInt_t i=0; i<fData.size(); i++) {
dump.theoryX.clear(); GetExportDataSet(fData[i].dataFourierRe, xmin, xmax, dumpVector, false);
dump.theory.clear(); GetExportDataSet(fData[i].theoryFourierRe, xmin, xmax, dumpVector, false);
// go through all data bins
for (Int_t j=1; j<fData[i].dataFourierRe->GetNbinsX(); j++) {
// get frequency
freq = fData[i].dataFourierRe->GetBinCenter(j);
// check if time is in the current range
if ((freq >= xmin) && (freq <= xmax)) {
dump.dataX.push_back(freq);
dump.data.push_back(fData[i].dataFourierRe->GetBinContent(j));
} }
} }
// go through all theory bins
for (Int_t j=1; j<fData[i].theoryFourierRe->GetNbinsX(); j++) {
// get frequency
freq = fData[i].theoryFourierRe->GetBinCenter(j);
// check if time is in the current range
if ((freq >= xmin) && (freq <= xmax)) {
dump.theoryX.push_back(freq);
dump.theory.push_back(fData[i].theoryFourierRe->GetBinContent(j));
}
}
// if anything found keep it
if (dump.dataX.size() > 0)
dumpVector.push_back(dump);
}
break; break;
case PV_FOURIER_IMAG: case PV_FOURIER_IMAG:
// get current x-range // get current x-range
@ -1828,40 +1672,15 @@ void PMusrCanvas::ExportData(const Char_t *fileName)
xmax = fData[0].dataFourierIm->GetXaxis()->GetBinCenter(xmaxBin); xmax = fData[0].dataFourierIm->GetXaxis()->GetBinCenter(xmaxBin);
// fill ascii dump data // fill ascii dump data
for (UInt_t i=0; i<fData.size(); i++) { // go through all the histogramms if (fAveragedView) {
// clean up dump GetExportDataSet(fDataAvg.dataFourierIm, xmin, xmax, dumpVector, false);
dump.dataX.clear(); GetExportDataSet(fDataAvg.theoryFourierIm, xmin, xmax, dumpVector, false);
dump.data.clear(); } else { // go through all the histogramms
dump.dataErr.clear(); for (UInt_t i=0; i<fData.size(); i++) {
dump.theoryX.clear(); GetExportDataSet(fData[i].dataFourierIm, xmin, xmax, dumpVector, false);
dump.theory.clear(); GetExportDataSet(fData[i].theoryFourierIm, xmin, xmax, dumpVector, false);
// go through all data bins
for (Int_t j=1; j<fData[i].dataFourierIm->GetNbinsX(); j++) {
// get frequency
freq = fData[i].dataFourierIm->GetBinCenter(j);
// check if time is in the current range
if ((freq >= xmin) && (freq <= xmax)) {
dump.dataX.push_back(freq);
dump.data.push_back(fData[i].dataFourierIm->GetBinContent(j));
} }
} }
// go through all theory bins
for (Int_t j=1; j<fData[i].theoryFourierIm->GetNbinsX(); j++) {
// get frequency
freq = fData[i].theoryFourierIm->GetBinCenter(j);
// check if time is in the current range
if ((freq >= xmin) && (freq <= xmax)) {
dump.theoryX.push_back(freq);
dump.theory.push_back(fData[i].theoryFourierIm->GetBinContent(j));
}
}
// if anything found keep it
if (dump.dataX.size() > 0)
dumpVector.push_back(dump);
}
break; break;
case PV_FOURIER_REAL_AND_IMAG: case PV_FOURIER_REAL_AND_IMAG:
// get current x-range // get current x-range
@ -1870,81 +1689,19 @@ void PMusrCanvas::ExportData(const Char_t *fileName)
xmin = fData[0].dataFourierRe->GetXaxis()->GetBinCenter(xminBin); xmin = fData[0].dataFourierRe->GetXaxis()->GetBinCenter(xminBin);
xmax = fData[0].dataFourierRe->GetXaxis()->GetBinCenter(xmaxBin); xmax = fData[0].dataFourierRe->GetXaxis()->GetBinCenter(xmaxBin);
// fill ascii dump data if (fAveragedView) {
for (UInt_t i=0; i<fData.size(); i++) { // go through all the histogramms GetExportDataSet(fDataAvg.dataFourierRe, xmin, xmax, dumpVector, false);
//----------------------------- GetExportDataSet(fDataAvg.theoryFourierRe, xmin, xmax, dumpVector, false);
// Re GetExportDataSet(fDataAvg.dataFourierIm, xmin, xmax, dumpVector, false);
//----------------------------- GetExportDataSet(fDataAvg.theoryFourierIm, xmin, xmax, dumpVector, false);
// clean up dump } else { // go through all the histogramms
dump.dataX.clear(); for (UInt_t i=0; i<fData.size(); i++) {
dump.data.clear(); GetExportDataSet(fData[i].dataFourierRe, xmin, xmax, dumpVector, false);
dump.dataErr.clear(); GetExportDataSet(fData[i].theoryFourierRe, xmin, xmax, dumpVector, false);
dump.theoryX.clear(); GetExportDataSet(fData[i].dataFourierIm, xmin, xmax, dumpVector, false);
dump.theory.clear(); GetExportDataSet(fData[i].theoryFourierIm, xmin, xmax, dumpVector, false);
// go through all data bins
for (Int_t j=1; j<fData[i].dataFourierRe->GetNbinsX(); j++) {
// get frequency
freq = fData[i].dataFourierRe->GetBinCenter(j);
// check if time is in the current range
if ((freq >= xmin) && (freq <= xmax)) {
dump.dataX.push_back(freq);
dump.data.push_back(fData[i].dataFourierRe->GetBinContent(j));
} }
} }
// go through all theory bins
for (Int_t j=1; j<fData[i].theoryFourierRe->GetNbinsX(); j++) {
// get frequency
freq = fData[i].theoryFourierRe->GetBinCenter(j);
// check if time is in the current range
if ((freq >= xmin) && (freq <= xmax)) {
dump.theoryX.push_back(freq);
dump.theory.push_back(fData[i].theoryFourierRe->GetBinContent(j));
}
}
// if anything found keep it
if (dump.dataX.size() > 0)
dumpVector.push_back(dump);
//-----------------------------
// Im
//-----------------------------
// clean up dump
dump.dataX.clear();
dump.data.clear();
dump.dataErr.clear();
dump.theoryX.clear();
dump.theory.clear();
// go through all data bins
for (Int_t j=1; j<fData[i].dataFourierIm->GetNbinsX(); j++) {
// get frequency
freq = fData[i].dataFourierIm->GetBinCenter(j);
// check if time is in the current range
if ((freq >= xmin) && (freq <= xmax)) {
dump.dataX.push_back(freq);
dump.data.push_back(fData[i].dataFourierIm->GetBinContent(j));
}
}
// go through all theory bins
for (Int_t j=1; j<fData[i].theoryFourierIm->GetNbinsX(); j++) {
// get frequency
freq = fData[i].theoryFourierIm->GetBinCenter(j);
// check if time is in the current range
if ((freq >= xmin) && (freq <= xmax)) {
dump.theoryX.push_back(freq);
dump.theory.push_back(fData[i].theoryFourierIm->GetBinContent(j));
}
}
// if anything found keep it
if (dump.dataX.size() > 0)
dumpVector.push_back(dump);
}
break; break;
case PV_FOURIER_PWR: case PV_FOURIER_PWR:
// get current x-range // get current x-range
@ -1954,40 +1711,15 @@ void PMusrCanvas::ExportData(const Char_t *fileName)
xmax = fData[0].dataFourierPwr->GetXaxis()->GetBinCenter(xmaxBin); xmax = fData[0].dataFourierPwr->GetXaxis()->GetBinCenter(xmaxBin);
// fill ascii dump data // fill ascii dump data
for (UInt_t i=0; i<fData.size(); i++) { // go through all the histogramms if (fAveragedView) {
// clean up dump GetExportDataSet(fDataAvg.dataFourierPwr, xmin, xmax, dumpVector, false);
dump.dataX.clear(); GetExportDataSet(fDataAvg.theoryFourierPwr, xmin, xmax, dumpVector, false);
dump.data.clear(); } else { // go through all the histogramms
dump.dataErr.clear(); for (UInt_t i=0; i<fData.size(); i++) {
dump.theoryX.clear(); GetExportDataSet(fData[i].dataFourierPwr, xmin, xmax, dumpVector, false);
dump.theory.clear(); GetExportDataSet(fData[i].theoryFourierPwr, xmin, xmax, dumpVector, false);
// go through all data bins
for (Int_t j=1; j<fData[i].dataFourierPwr->GetNbinsX(); j++) {
// get frequency
freq = fData[i].dataFourierPwr->GetBinCenter(j);
// check if time is in the current range
if ((freq >= xmin) && (freq <= xmax)) {
dump.dataX.push_back(freq);
dump.data.push_back(fData[i].dataFourierPwr->GetBinContent(j));
} }
} }
// go through all theory bins
for (Int_t j=1; j<fData[i].theoryFourierPwr->GetNbinsX(); j++) {
// get frequency
freq = fData[i].theoryFourierPwr->GetBinCenter(j);
// check if time is in the current range
if ((freq >= xmin) && (freq <= xmax)) {
dump.theoryX.push_back(freq);
dump.theory.push_back(fData[i].theoryFourierPwr->GetBinContent(j));
}
}
// if anything found keep it
if (dump.dataX.size() > 0)
dumpVector.push_back(dump);
}
break; break;
case PV_FOURIER_PHASE: case PV_FOURIER_PHASE:
// get current x-range // get current x-range
@ -1997,40 +1729,15 @@ void PMusrCanvas::ExportData(const Char_t *fileName)
xmax = fData[0].dataFourierPhase->GetXaxis()->GetBinCenter(xmaxBin); xmax = fData[0].dataFourierPhase->GetXaxis()->GetBinCenter(xmaxBin);
// fill ascii dump data // fill ascii dump data
for (UInt_t i=0; i<fData.size(); i++) { // go through all the histogramms if (fAveragedView) {
// clean up dump GetExportDataSet(fDataAvg.dataFourierPhase, xmin, xmax, dumpVector, false);
dump.dataX.clear(); GetExportDataSet(fDataAvg.theoryFourierPhase, xmin, xmax, dumpVector, false);
dump.data.clear(); } else { // go through all the histogramms
dump.dataErr.clear(); for (UInt_t i=0; i<fData.size(); i++) {
dump.theoryX.clear(); GetExportDataSet(fData[i].dataFourierPhase, xmin, xmax, dumpVector, false);
dump.theory.clear(); GetExportDataSet(fData[i].theoryFourierPhase, xmin, xmax, dumpVector, false);
// go through all data bins
for (Int_t j=1; j<fData[i].dataFourierPhase->GetNbinsX(); j++) {
// get frequency
freq = fData[i].dataFourierPhase->GetBinCenter(j);
// check if time is in the current range
if ((freq >= xmin) && (freq <= xmax)) {
dump.dataX.push_back(freq);
dump.data.push_back(fData[i].dataFourierPhase->GetBinContent(j));
} }
} }
// go through all theory bins
for (Int_t j=1; j<fData[i].theoryFourierPhase->GetNbinsX(); j++) {
// get frequency
freq = fData[i].theoryFourierPhase->GetBinCenter(j);
// check if time is in the current range
if ((freq >= xmin) && (freq <= xmax)) {
dump.theoryX.push_back(freq);
dump.theory.push_back(fData[i].theoryFourierPhase->GetBinContent(j));
}
}
// if anything found keep it
if (dump.dataX.size() > 0)
dumpVector.push_back(dump);
}
break; break;
default: default:
break; break;
@ -2053,8 +1760,6 @@ void PMusrCanvas::ExportData(const Char_t *fileName)
dump.dataX.clear(); dump.dataX.clear();
dump.data.clear(); dump.data.clear();
dump.dataErr.clear(); dump.dataErr.clear();
dump.theoryX.clear();
dump.theory.clear();
// go through all data bins // go through all data bins
for (Int_t j=0; j<fNonMusrData[i].diff->GetN(); j++) { for (Int_t j=0; j<fNonMusrData[i].diff->GetN(); j++) {
@ -2102,8 +1807,6 @@ void PMusrCanvas::ExportData(const Char_t *fileName)
dump.dataX.clear(); dump.dataX.clear();
dump.data.clear(); dump.data.clear();
dump.dataErr.clear(); dump.dataErr.clear();
dump.theoryX.clear();
dump.theory.clear();
// go through all data bins // go through all data bins
for (Int_t j=0; j<fNonMusrData[i].data->GetN(); j++) { for (Int_t j=0; j<fNonMusrData[i].data->GetN(); j++) {
@ -2123,8 +1826,8 @@ void PMusrCanvas::ExportData(const Char_t *fileName)
fNonMusrData[i].theory->GetPoint(j,xval,yval); fNonMusrData[i].theory->GetPoint(j,xval,yval);
// check if time is in the current range // check if time is in the current range
if ((xval >= xmin) && (xval <= xmax)) { if ((xval >= xmin) && (xval <= xmax)) {
dump.theoryX.push_back(xval); dump.dataX.push_back(xval);
dump.theory.push_back(yval); dump.data.push_back(yval);
} }
} }
@ -2164,43 +1867,57 @@ void PMusrCanvas::ExportData(const Char_t *fileName)
} }
// find out what is the longest data/theory vector // find out what is the longest data/theory vector
UInt_t maxDataLength = 0; UInt_t maxLength = 0;
UInt_t maxTheoryLength = 0;
for (UInt_t i=0; i<dumpVector.size(); i++) { for (UInt_t i=0; i<dumpVector.size(); i++) {
if (maxDataLength < dumpVector[i].dataX.size()) if (maxLength < dumpVector[i].dataX.size())
maxDataLength = dumpVector[i].dataX.size(); maxLength = dumpVector[i].dataX.size();
if (maxTheoryLength < dumpVector[i].theoryX.size())
maxTheoryLength = dumpVector[i].theoryX.size();
} }
// write data to file // write data to file
UInt_t maxLength = 0;
if (fDifferenceView) { // difference view if (fDifferenceView) { // difference view
// write header // write header
switch (fCurrentPlotView) { switch (fCurrentPlotView) {
case PV_DATA: case PV_DATA:
if (fAveragedView) {
fout << "% from averaged view" << endl;
fout << "% x, diff, errDiff" << endl;
} else {
fout << "% "; fout << "% ";
for (UInt_t i=0; i<dumpVector.size()-1; i++) { for (UInt_t i=0; i<dumpVector.size()-1; i++) {
fout << "x" << i << " , diff" << i << ", errDiff" << i << ", "; fout << "x" << i << " , diff" << i << ", errDiff" << i << ", ";
} }
fout << "x" << dumpVector.size()-1 << " , diff" << dumpVector.size()-1 << ", errDiff" << dumpVector.size()-1 << endl; fout << "x" << dumpVector.size()-1 << " , diff" << dumpVector.size()-1 << ", errDiff" << dumpVector.size()-1 << endl;
}
break; break;
case PV_FOURIER_REAL: case PV_FOURIER_REAL:
if (fAveragedView) {
fout << "% from averaged view" << endl;
fout << "% x, F_diffRe" << endl;
} else {
fout << "% "; fout << "% ";
for (UInt_t i=0; i<dumpVector.size()-1; i++) { for (UInt_t i=0; i<dumpVector.size()-1; i++) {
fout << "freq" << i << ", F_diffRe" << i << ", "; fout << "freq" << i << ", F_diffRe" << i << ", ";
} }
fout << "freq" << dumpVector.size()-1 << ", F_diffRe" << dumpVector.size()-1 << endl; fout << "freq" << dumpVector.size()-1 << ", F_diffRe" << dumpVector.size()-1 << endl;
}
break; break;
case PV_FOURIER_IMAG: case PV_FOURIER_IMAG:
if (fAveragedView) {
fout << "% from averaged view" << endl;
fout << "% x, F_diffIm" << endl;
} else {
fout << "% "; fout << "% ";
for (UInt_t i=0; i<dumpVector.size()-1; i++) { for (UInt_t i=0; i<dumpVector.size()-1; i++) {
fout << "freq" << i << ", F_diffIm" << i << ", "; fout << "freq" << i << ", F_diffIm" << i << ", ";
} }
fout << "freq" << dumpVector.size()-1 << ", F_diffIm" << dumpVector.size()-1 << endl; fout << "freq" << dumpVector.size()-1 << ", F_diffIm" << dumpVector.size()-1 << endl;
}
break; break;
case PV_FOURIER_REAL_AND_IMAG: case PV_FOURIER_REAL_AND_IMAG:
if (fAveragedView) {
fout << "% from averaged view" << endl;
fout << "% x, F_diffRe, F_diffIm" << endl;
} else {
fout << "% "; fout << "% ";
for (UInt_t i=0; i<dumpVector.size()/2; i++) { for (UInt_t i=0; i<dumpVector.size()/2; i++) {
fout << "freq" << i << ", F_diffRe" << i << ", "; fout << "freq" << i << ", F_diffRe" << i << ", ";
@ -2209,27 +1926,36 @@ void PMusrCanvas::ExportData(const Char_t *fileName)
fout << "freq" << i << ", F_diffIm" << i << ", "; fout << "freq" << i << ", F_diffIm" << i << ", ";
} }
fout << "freq" << dumpVector.size()/2-1 << ", F_diffIm" << dumpVector.size()/2-1 << endl; fout << "freq" << dumpVector.size()/2-1 << ", F_diffIm" << dumpVector.size()/2-1 << endl;
}
break; break;
case PV_FOURIER_PWR: case PV_FOURIER_PWR:
if (fAveragedView) {
fout << "% from averaged view" << endl;
fout << "% x, F_diffPwr" << endl;
} else {
fout << "% "; fout << "% ";
for (UInt_t i=0; i<dumpVector.size()-1; i++) { for (UInt_t i=0; i<dumpVector.size()-1; i++) {
fout << "freq" << i << ", F_diffPwr" << i << ", "; fout << "freq" << i << ", F_diffPwr" << i << ", ";
} }
fout << "freq" << dumpVector.size()-1 << ", F_diffPwr" << dumpVector.size()-1 << endl; fout << "freq" << dumpVector.size()-1 << ", F_diffPwr" << dumpVector.size()-1 << endl;
}
break; break;
case PV_FOURIER_PHASE: case PV_FOURIER_PHASE:
if (fAveragedView) {
fout << "% from averaged view" << endl;
fout << "% x, F_diffPhase" << endl;
} else {
fout << "% "; fout << "% ";
for (UInt_t i=0; i<dumpVector.size()-1; i++) { for (UInt_t i=0; i<dumpVector.size()-1; i++) {
fout << "freq" << i << ", F_diffPhase" << i << ", "; fout << "freq" << i << ", F_diffPhase" << i << ", ";
} }
fout << "freq" << dumpVector.size()-1 << ", F_diffPhase" << dumpVector.size()-1 << endl; fout << "freq" << dumpVector.size()-1 << ", F_diffPhase" << dumpVector.size()-1 << endl;
}
break; break;
default: default:
break; break;
} }
maxLength = maxDataLength;
// write difference data // write difference data
for (UInt_t i=0; i<maxLength; i++) { for (UInt_t i=0; i<maxLength; i++) {
// write difference data // write difference data
@ -2264,84 +1990,119 @@ void PMusrCanvas::ExportData(const Char_t *fileName)
// write header // write header
switch (fCurrentPlotView) { switch (fCurrentPlotView) {
case PV_DATA: case PV_DATA:
if (fAveragedView) {
fout << "% from averaged view" << endl;
fout << "% xData, data, errData, xTheory, theory" << endl;
} else {
fout << "% "; fout << "% ";
for (UInt_t i=0; i<dumpVector.size(); i++) { for (UInt_t i=0; i<dumpVector.size(); i++) {
fout << "xData" << i << " , data" << i << ", errData" << i << ", "; if (i % 2 == 0)
fout << "xData" << i/2 << " , data" << i/2 << ", errData" << i/2 << ", ";
else
if (i == dumpVector.size()-1)
fout << "xTheory" << (i-1)/2 << " , theory" << (i-1)/2 << endl;
else
fout << "xTheory" << (i-1)/2 << " , theory" << (i-1)/2 << ", ";
} }
for (UInt_t i=0; i<dumpVector.size()-1; i++) {
fout << "xTheory" << i << " , theory" << i << ", ";
} }
fout << "xTheory" << dumpVector.size()-1 << " , theory" << dumpVector.size()-1 << endl;
break; break;
case PV_FOURIER_REAL: case PV_FOURIER_REAL:
if (fAveragedView) {
fout << "% from averaged view" << endl;
fout << "% freq, F_Re, freqTheo, F_theoRe" << endl;
} else {
fout << "% "; fout << "% ";
for (UInt_t i=0; i<dumpVector.size(); i++) { for (UInt_t i=0; i<dumpVector.size(); i++) {
fout << "freq" << i << ", F_Re" << i << ", "; if (i % 2 == 0)
fout << "freq" << i/2 << ", F_Re" << i/2 << ", ";
else
if (i == dumpVector.size()-1)
fout << "freqTheo" << (i-1)/2 << ", F_theoRe" << (i-1)/2 << endl;
else
fout << "freqTheo" << (i-1)/2 << ", F_theoRe" << (i-1)/2 << ", ";
} }
for (UInt_t i=0; i<dumpVector.size()-1; i++) {
fout << "freqTheo" << i << ", F_theo" << i << ", ";
} }
fout << "freqTheo" << dumpVector.size()-1 << ", F_theo" << dumpVector.size()-1 << endl;
break; break;
case PV_FOURIER_IMAG: case PV_FOURIER_IMAG:
if (fAveragedView) {
fout << "% from averaged view" << endl;
fout << "% freq, F_Im, freqTheo, F_theoIm" << endl;
} else {
fout << "% "; fout << "% ";
for (UInt_t i=0; i<dumpVector.size(); i++) { for (UInt_t i=0; i<dumpVector.size(); i++) {
fout << "freq" << i << ", F_Im" << i << ", "; if (i % 2 == 0)
fout << "freq" << i/2 << ", F_Im" << i/2 << ", ";
else
if (i == dumpVector.size()-1)
fout << "freqTheo" << (i-1)/2 << ", F_theoIm" << (i-1)/2 << endl;
else
fout << "freqTheo" << (i-1)/2 << ", F_theoIm" << (i-1)/2 << ", ";
} }
for (UInt_t i=0; i<dumpVector.size()-1; i++) {
fout << "freqTheo" << i << ", F_theo" << i << ", ";
} }
fout << "freqTheo" << dumpVector.size()-1 << ", F_theo" << dumpVector.size()-1 << endl;
break; break;
case PV_FOURIER_REAL_AND_IMAG: case PV_FOURIER_REAL_AND_IMAG:
if (fAveragedView) {
fout << "% from averaged view" << endl;
fout << "% freq, F_Re, freqTheo, F_theoRe, freq, F_Im, freqTheo, F_theoIm" << endl;
} else {
fout << "% "; fout << "% ";
for (UInt_t i=0; i<dumpVector.size()/2; i++) { for (UInt_t i=0; i<dumpVector.size(); i++) {
fout << "freq" << i << ", F_Re" << i << ", "; if (i % 4 == 0)
fout << "freq" << i/4 << ", F_Re" << i/4 << ", ";
else if (i % 4 == 1)
fout << "freqTheo" << (i-1)/4 << ", F_theoRe" << (i-1)/4 << ", ";
else if (i % 4 == 2)
fout << "freq" << (i-2)/4 << ", F_Im" << (i-2)/4 << ", ";
else
if (i == dumpVector.size()-1)
fout << "freqTheo" << (i-3)/4 << ", F_theoIm" << (i-3)/4 << endl;
else
fout << "freqTheo" << (i-3)/4 << ", F_theoIm" << (i-3)/4 << ", ";
} }
for (UInt_t i=0; i<dumpVector.size()/2; i++) {
fout << "freq" << i << ", F_Im" << i << ", ";
} }
for (UInt_t i=0; i<dumpVector.size()/2; i++) {
fout << "freqTheo" << i << ", F_theoRe" << i << ", ";
}
for (UInt_t i=0; i<(dumpVector.size()-1)/2; i++) {
fout << "freqTheo" << i << ", F_theoIm" << i << ", ";
}
fout << "freqTheo" << (dumpVector.size()-1)/2 << ", F_theoIm" << (dumpVector.size()-1)/2 << endl;
break; break;
case PV_FOURIER_PWR: case PV_FOURIER_PWR:
if (fAveragedView) {
fout << "% from averaged view" << endl;
fout << "% freq, F_Pwr, freqTheo, F_theoPwr" << endl;
} else {
fout << "% "; fout << "% ";
for (UInt_t i=0; i<dumpVector.size(); i++) { for (UInt_t i=0; i<dumpVector.size(); i++) {
fout << "freq" << i << ", F_Pwr" << i << ", "; if (i % 2 == 0)
fout << "freq" << i/2 << ", F_Pwr" << i/2 << ", ";
else
if (i == dumpVector.size()-1)
fout << "freqTheo" << (i-1)/2 << ", F_theoPwr" << (i-1)/2 << endl;
else
fout << "freqTheo" << (i-1)/2 << ", F_theoPwr" << (i-1)/2 << ", ";
} }
for (UInt_t i=0; i<dumpVector.size()-1; i++) {
fout << "freqTheo" << i << ", F_theo" << i << ", ";
} }
fout << "freqTheo" << dumpVector.size()-1 << ", F_theo" << dumpVector.size()-1 << endl;
break; break;
case PV_FOURIER_PHASE: case PV_FOURIER_PHASE:
if (fAveragedView) {
fout << "% from averaged view" << endl;
fout << "% freq, F_Phase, freqTheo, F_theoPhase" << endl;
} else {
fout << "% "; fout << "% ";
for (UInt_t i=0; i<dumpVector.size(); i++) { for (UInt_t i=0; i<dumpVector.size(); i++) {
fout << "freq" << i << ", F_Phase" << i << ", "; if (i % 2 == 0)
fout << "freq" << i/2 << ", F_Phase" << i/2 << ", ";
else
if (i == dumpVector.size()-1)
fout << "freqTheo" << (i-1)/2 << ", F_theoPhase" << (i-1)/2 << endl;
else
fout << "freqTheo" << (i-1)/2 << ", F_theoPhase" << (i-1)/2 << ", ";
} }
for (UInt_t i=0; i<dumpVector.size()-1; i++) {
fout << "freqTheo" << i << ", F_theo" << i << ", ";
} }
fout << "freqTheo" << dumpVector.size()-1 << ", F_theo" << dumpVector.size()-1 << endl;
break; break;
default: default:
break; break;
} }
if (maxDataLength > maxTheoryLength)
maxLength = maxDataLength;
else
maxLength = maxTheoryLength;
// write data and theory // write data and theory
for (UInt_t i=0; i<maxLength; i++) { for (UInt_t i=0; i<maxLength; i++) {
// write data // write data/theory
for (UInt_t j=0; j<dumpVector.size(); j++) { for (UInt_t j=0; j<dumpVector.size()-1; j++) {
if (i<dumpVector[j].dataX.size()) { if (i<dumpVector[j].dataX.size()) {
fout << dumpVector[j].dataX[i] << ", "; fout << dumpVector[j].dataX[i] << ", ";
fout << dumpVector[j].data[i] << ", "; fout << dumpVector[j].data[i] << ", ";
@ -2354,19 +2115,10 @@ void PMusrCanvas::ExportData(const Char_t *fileName)
fout << " , , "; fout << " , , ";
} }
} }
// write theory // write last data/theory entry
for (UInt_t j=0; j<dumpVector.size()-1; j++) { if (i<dumpVector[dumpVector.size()-1].dataX.size()) {
if (i<dumpVector[j].theoryX.size()) { fout << dumpVector[dumpVector.size()-1].dataX[i] << ", ";
fout << dumpVector[j].theoryX[i] << ", "; fout << dumpVector[dumpVector.size()-1].data[i];
fout << dumpVector[j].theory[i] << ", ";
} else {
fout << " , , ";
}
}
// write last theory entry
if (i<dumpVector[dumpVector.size()-1].theoryX.size()) {
fout << dumpVector[dumpVector.size()-1].theoryX[i] << ", ";
fout << dumpVector[dumpVector.size()-1].theory[i];
} else { } else {
fout << " , "; fout << " , ";
} }
@ -2382,8 +2134,6 @@ void PMusrCanvas::ExportData(const Char_t *fileName)
dumpVector[i].dataX.clear(); dumpVector[i].dataX.clear();
dumpVector[i].data.clear(); dumpVector[i].data.clear();
dumpVector[i].dataErr.clear(); dumpVector[i].dataErr.clear();
dumpVector[i].theoryX.clear();
dumpVector[i].theory.clear();
} }
dumpVector.clear(); dumpVector.clear();
@ -2394,6 +2144,42 @@ void PMusrCanvas::ExportData(const Char_t *fileName)
// } // }
} }
//--------------------------------------------------------------------------
// GetExportDataSet (private)
//--------------------------------------------------------------------------
/**
* <p> extract data for export.
*
* \param data
* \param xmin
* \param xmax
* \param dumpData
* \param hasError
*/
void PMusrCanvas::GetExportDataSet(const TH1F *data, const Double_t xmin, const Double_t xmax,
PMusrCanvasAsciiDumpVector &dumpData, const Bool_t hasError)
{
PMusrCanvasAsciiDump dump;
Double_t x=0.0;
// go through all difference data bins
for (Int_t j=1; j<data->GetNbinsX(); j++) {
// get time/freq
x = data->GetBinCenter(j);
// check if x is in the current range
if ((x >= xmin) && (x <= xmax)) {
dump.dataX.push_back(x);
dump.data.push_back(data->GetBinContent(j));
if (hasError)
dump.dataErr.push_back(data->GetBinError(j));
}
}
// if anything found keep it
if (dump.dataX.size() > 0)
dumpData.push_back(dump);
}
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// CreateStyle (private) // CreateStyle (private)
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------

View File

@ -181,8 +181,6 @@ typedef struct {
PDoubleVector dataX; ///< x-axis data set PDoubleVector dataX; ///< x-axis data set
PDoubleVector data; ///< y-axis data set PDoubleVector data; ///< y-axis data set
PDoubleVector dataErr; ///< error of the y-axis data set PDoubleVector dataErr; ///< error of the y-axis data set
PDoubleVector theoryX; ///< x-axis theory set
PDoubleVector theory; ///< y-axis theory set
} PMusrCanvasAsciiDump; } PMusrCanvasAsciiDump;
//------------------------------------------------------------------------ //------------------------------------------------------------------------
@ -333,6 +331,9 @@ class PMusrCanvas : public TObject, public TQObject
virtual Double_t GetInterpolatedValue(TH1F* histo, Double_t xVal); virtual Double_t GetInterpolatedValue(TH1F* histo, Double_t xVal);
virtual void GetExportDataSet(const TH1F *data, const Double_t xmin, const Double_t xmax,
PMusrCanvasAsciiDumpVector &dumpData, const Bool_t hasError=true);
ClassDef(PMusrCanvas, 1) ClassDef(PMusrCanvas, 1)
}; };