Remove redundant and optimize code for saving data to ascii in batch mode.
This commit is contained in:
parent
55fb9df820
commit
acb5a1af09
@ -1362,13 +1362,12 @@ void PMusrCanvas::SaveGraphicsAndQuit(Char_t *fileName, Char_t *graphicsFormat)
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// SaveDataAsciiAndQuit
|
||||
// SaveDataAscii
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Saves the currently seen data (data, difference, Fourier spectra, ...) in ascii column format.
|
||||
* This function is used to dump the ascii output in batch mode.
|
||||
*/
|
||||
void PMusrCanvas::SaveDataAsciiAndQuit()
|
||||
void PMusrCanvas::SaveDataAscii()
|
||||
{
|
||||
// collect relevant data
|
||||
PMusrCanvasAsciiDump dump;
|
||||
@ -2043,7 +2042,7 @@ void PMusrCanvas::SaveDataAsciiAndQuit()
|
||||
// open output data-file
|
||||
fout.open(fln.Data(), iostream::out);
|
||||
if (!fout.is_open()) {
|
||||
cerr << endl << ">> PMusrCanvas::SaveDataAsciiAndQuit: **ERROR** couldn't open file " << fln.Data() << " for writing." << endl;
|
||||
cerr << endl << ">> PMusrCanvas::SaveDataAscii: **ERROR** couldn't open file " << fln.Data() << " for writing." << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2272,9 +2271,10 @@ void PMusrCanvas::SaveDataAsciiAndQuit()
|
||||
dumpVector.clear();
|
||||
|
||||
cout << endl << ">> Data windows saved in ascii format ..." << endl;
|
||||
|
||||
if (fPlotNumber == static_cast<Int_t>(fMsrHandler->GetMsrPlotList()->size()) - 1)
|
||||
Done(0);
|
||||
// if (asciiOutput) {
|
||||
// if (fPlotNumber == static_cast<Int_t>(fMsrHandler->GetMsrPlotList()->size()) - 1)
|
||||
// Done(0);
|
||||
// }
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@ -6188,917 +6188,6 @@ void PMusrCanvas::DecrementFourierPhase()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// SaveDataAscii (private)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Saves the currently seen data (data, difference, Fourier spectra, ...) in ascii column format.
|
||||
*/
|
||||
void PMusrCanvas::SaveDataAscii()
|
||||
{
|
||||
// collect relevant data
|
||||
PMusrCanvasAsciiDump dump;
|
||||
PMusrCanvasAsciiDumpVector dumpVector;
|
||||
|
||||
Int_t xminBin;
|
||||
Int_t xmaxBin;
|
||||
Double_t xmin;
|
||||
Double_t xmax;
|
||||
Double_t time, freq;
|
||||
Double_t xval, yval;
|
||||
|
||||
switch (fPlotType) {
|
||||
case MSR_PLOT_SINGLE_HISTO:
|
||||
case MSR_PLOT_ASYM:
|
||||
case MSR_PLOT_MU_MINUS:
|
||||
if (fDifferenceView) { // difference view plot
|
||||
switch (fCurrentPlotView) {
|
||||
case PV_DATA:
|
||||
// get current x-range
|
||||
xminBin = fHistoFrame->GetXaxis()->GetFirst(); // first bin of the zoomed range
|
||||
xmaxBin = fHistoFrame->GetXaxis()->GetLast(); // last bin of the zoomed range
|
||||
xmin = fHistoFrame->GetXaxis()->GetBinCenter(xminBin);
|
||||
xmax = fHistoFrame->GetXaxis()->GetBinCenter(xmaxBin);
|
||||
|
||||
// fill ascii dump data
|
||||
for (UInt_t i=0; i<fData.size(); i++) { // go through all the histogramms
|
||||
// clean up dump
|
||||
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;
|
||||
case PV_FOURIER_REAL:
|
||||
// get current x-range
|
||||
xminBin = fData[0].diffFourierRe->GetXaxis()->GetFirst(); // first bin of the zoomed range
|
||||
xmaxBin = fData[0].diffFourierRe->GetXaxis()->GetLast(); // last bin of the zoomed range
|
||||
xmin = fData[0].diffFourierRe->GetXaxis()->GetBinCenter(xminBin);
|
||||
xmax = fData[0].diffFourierRe->GetXaxis()->GetBinCenter(xmaxBin);
|
||||
|
||||
// fill ascii dump data
|
||||
for (UInt_t i=0; i<fData.size(); i++) { // go through all the histogramms
|
||||
// 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].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;
|
||||
case PV_FOURIER_IMAG:
|
||||
// get current x-range
|
||||
xminBin = fData[0].diffFourierIm->GetXaxis()->GetFirst(); // first bin of the zoomed range
|
||||
xmaxBin = fData[0].diffFourierIm->GetXaxis()->GetLast(); // last bin of the zoomed range
|
||||
xmin = fData[0].diffFourierIm->GetXaxis()->GetBinCenter(xminBin);
|
||||
xmax = fData[0].diffFourierIm->GetXaxis()->GetBinCenter(xmaxBin);
|
||||
|
||||
// fill ascii dump data
|
||||
for (UInt_t i=0; i<fData.size(); i++) { // go through all the histogramms
|
||||
// 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].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;
|
||||
case PV_FOURIER_REAL_AND_IMAG:
|
||||
// get current x-range
|
||||
xminBin = fData[0].diffFourierRe->GetXaxis()->GetFirst(); // first bin of the zoomed range
|
||||
xmaxBin = fData[0].diffFourierRe->GetXaxis()->GetLast(); // last bin of the zoomed range
|
||||
xmin = fData[0].diffFourierRe->GetXaxis()->GetBinCenter(xminBin);
|
||||
xmax = fData[0].diffFourierRe->GetXaxis()->GetBinCenter(xmaxBin);
|
||||
|
||||
// fill ascii dump data
|
||||
for (UInt_t i=0; i<fData.size(); i++) { // go through all the histogramms
|
||||
// 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].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;
|
||||
case PV_FOURIER_PWR:
|
||||
// get current x-range
|
||||
xminBin = fData[0].diffFourierPwr->GetXaxis()->GetFirst(); // first bin of the zoomed range
|
||||
xmaxBin = fData[0].diffFourierPwr->GetXaxis()->GetLast(); // last bin of the zoomed range
|
||||
xmin = fData[0].diffFourierPwr->GetXaxis()->GetBinCenter(xminBin);
|
||||
xmax = fData[0].diffFourierPwr->GetXaxis()->GetBinCenter(xmaxBin);
|
||||
|
||||
// fill ascii dump data
|
||||
for (UInt_t i=0; i<fData.size(); i++) { // go through all the histogramms
|
||||
// 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].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;
|
||||
case PV_FOURIER_PHASE:
|
||||
// get current x-range
|
||||
xminBin = fData[0].diffFourierPhase->GetXaxis()->GetFirst(); // first bin of the zoomed range
|
||||
xmaxBin = fData[0].diffFourierPhase->GetXaxis()->GetLast(); // last bin of the zoomed range
|
||||
xmin = fData[0].diffFourierPhase->GetXaxis()->GetBinCenter(xminBin);
|
||||
xmax = fData[0].diffFourierPhase->GetXaxis()->GetBinCenter(xmaxBin);
|
||||
|
||||
// fill ascii dump data
|
||||
for (UInt_t i=0; i<fData.size(); i++) { // go through all the histogramms
|
||||
// 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].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;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else { // not a difference view plot
|
||||
switch (fCurrentPlotView) {
|
||||
case PV_DATA:
|
||||
// get current x-range
|
||||
xminBin = fHistoFrame->GetXaxis()->GetFirst(); // first bin of the zoomed range
|
||||
xmaxBin = fHistoFrame->GetXaxis()->GetLast(); // last bin of the zoomed range
|
||||
xmin = fHistoFrame->GetXaxis()->GetBinCenter(xminBin);
|
||||
xmax = fHistoFrame->GetXaxis()->GetBinCenter(xmaxBin);
|
||||
|
||||
// fill ascii dump data
|
||||
for (UInt_t i=0; i<fData.size(); i++) { // go through all the histogramms
|
||||
// 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].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;
|
||||
case PV_FOURIER_REAL:
|
||||
// get current x-range
|
||||
xminBin = fData[0].dataFourierRe->GetXaxis()->GetFirst(); // first bin of the zoomed range
|
||||
xmaxBin = fData[0].dataFourierRe->GetXaxis()->GetLast(); // last bin of the zoomed range
|
||||
xmin = fData[0].dataFourierRe->GetXaxis()->GetBinCenter(xminBin);
|
||||
xmax = fData[0].dataFourierRe->GetXaxis()->GetBinCenter(xmaxBin);
|
||||
|
||||
// fill ascii dump data
|
||||
for (UInt_t i=0; i<fData.size(); i++) { // go through all the histogramms
|
||||
// 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].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;
|
||||
case PV_FOURIER_IMAG:
|
||||
// get current x-range
|
||||
xminBin = fData[0].dataFourierIm->GetXaxis()->GetFirst(); // first bin of the zoomed range
|
||||
xmaxBin = fData[0].dataFourierIm->GetXaxis()->GetLast(); // last bin of the zoomed range
|
||||
xmin = fData[0].dataFourierIm->GetXaxis()->GetBinCenter(xminBin);
|
||||
xmax = fData[0].dataFourierIm->GetXaxis()->GetBinCenter(xmaxBin);
|
||||
|
||||
// fill ascii dump data
|
||||
for (UInt_t i=0; i<fData.size(); i++) { // go through all the histogramms
|
||||
// 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;
|
||||
case PV_FOURIER_REAL_AND_IMAG:
|
||||
// get current x-range
|
||||
xminBin = fData[0].dataFourierRe->GetXaxis()->GetFirst(); // first bin of the zoomed range
|
||||
xmaxBin = fData[0].dataFourierRe->GetXaxis()->GetLast(); // last bin of the zoomed range
|
||||
xmin = fData[0].dataFourierRe->GetXaxis()->GetBinCenter(xminBin);
|
||||
xmax = fData[0].dataFourierRe->GetXaxis()->GetBinCenter(xmaxBin);
|
||||
|
||||
// fill ascii dump data
|
||||
for (UInt_t i=0; i<fData.size(); i++) { // go through all the histogramms
|
||||
//-----------------------------
|
||||
// Re
|
||||
//-----------------------------
|
||||
// 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].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;
|
||||
case PV_FOURIER_PWR:
|
||||
// get current x-range
|
||||
xminBin = fData[0].dataFourierPwr->GetXaxis()->GetFirst(); // first bin of the zoomed range
|
||||
xmaxBin = fData[0].dataFourierPwr->GetXaxis()->GetLast(); // last bin of the zoomed range
|
||||
xmin = fData[0].dataFourierPwr->GetXaxis()->GetBinCenter(xminBin);
|
||||
xmax = fData[0].dataFourierPwr->GetXaxis()->GetBinCenter(xmaxBin);
|
||||
|
||||
// fill ascii dump data
|
||||
for (UInt_t i=0; i<fData.size(); i++) { // go through all the histogramms
|
||||
// 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].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;
|
||||
case PV_FOURIER_PHASE:
|
||||
// get current x-range
|
||||
xminBin = fData[0].dataFourierPhase->GetXaxis()->GetFirst(); // first bin of the zoomed range
|
||||
xmaxBin = fData[0].dataFourierPhase->GetXaxis()->GetLast(); // last bin of the zoomed range
|
||||
xmin = fData[0].dataFourierPhase->GetXaxis()->GetBinCenter(xminBin);
|
||||
xmax = fData[0].dataFourierPhase->GetXaxis()->GetBinCenter(xmaxBin);
|
||||
|
||||
// fill ascii dump data
|
||||
for (UInt_t i=0; i<fData.size(); i++) { // go through all the histogramms
|
||||
// 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].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;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MSR_PLOT_NON_MUSR:
|
||||
if (fDifferenceView) { // difference view plot
|
||||
switch (fCurrentPlotView) {
|
||||
case PV_DATA:
|
||||
// get current x-range
|
||||
xminBin = fMultiGraphData->GetXaxis()->GetFirst(); // first bin of the zoomed range
|
||||
xmaxBin = fMultiGraphData->GetXaxis()->GetLast(); // last bin of the zoomed range
|
||||
xmin = fMultiGraphData->GetXaxis()->GetBinCenter(xminBin);
|
||||
xmax = fMultiGraphData->GetXaxis()->GetBinCenter(xmaxBin);
|
||||
|
||||
// fill ascii dump data
|
||||
for (UInt_t i=0; i<fNonMusrData.size(); i++) { // go through all the histogramms
|
||||
// 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=0; j<fNonMusrData[i].diff->GetN(); j++) {
|
||||
// get x and y value
|
||||
fNonMusrData[i].diff->GetPoint(j,xval,yval);
|
||||
// check if time is in the current range
|
||||
if ((xval >= xmin) && (xval <= xmax)) {
|
||||
dump.dataX.push_back(xval);
|
||||
dump.data.push_back(yval);
|
||||
dump.dataErr.push_back(fNonMusrData[i].diff->GetErrorY(j));
|
||||
}
|
||||
}
|
||||
|
||||
// if anything found keep it
|
||||
if (dump.dataX.size() > 0)
|
||||
dumpVector.push_back(dump);
|
||||
}
|
||||
|
||||
break;
|
||||
case PV_FOURIER_REAL:
|
||||
break;
|
||||
case PV_FOURIER_IMAG:
|
||||
break;
|
||||
case PV_FOURIER_REAL_AND_IMAG:
|
||||
break;
|
||||
case PV_FOURIER_PWR:
|
||||
break;
|
||||
case PV_FOURIER_PHASE:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else { // not a difference view plot
|
||||
switch (fCurrentPlotView) {
|
||||
case PV_DATA:
|
||||
// get current x-range
|
||||
xminBin = fMultiGraphData->GetXaxis()->GetFirst(); // first bin of the zoomed range
|
||||
xmaxBin = fMultiGraphData->GetXaxis()->GetLast(); // last bin of the zoomed range
|
||||
xmin = fMultiGraphData->GetXaxis()->GetBinCenter(xminBin);
|
||||
xmax = fMultiGraphData->GetXaxis()->GetBinCenter(xmaxBin);
|
||||
|
||||
// fill ascii dump data
|
||||
for (UInt_t i=0; i<fNonMusrData.size(); i++) { // go through all the histogramms
|
||||
// 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=0; j<fNonMusrData[i].data->GetN(); j++) {
|
||||
// get x and y value
|
||||
fNonMusrData[i].data->GetPoint(j,xval,yval);
|
||||
// check if time is in the current range
|
||||
if ((xval >= xmin) && (xval <= xmax)) {
|
||||
dump.dataX.push_back(xval);
|
||||
dump.data.push_back(yval);
|
||||
dump.dataErr.push_back(fNonMusrData[i].data->GetErrorY(j));
|
||||
}
|
||||
}
|
||||
|
||||
// go through all theory bins
|
||||
for (Int_t j=0; j<fNonMusrData[i].theory->GetN(); j++) {
|
||||
// get x and y value
|
||||
fNonMusrData[i].theory->GetPoint(j,xval,yval);
|
||||
// check if time is in the current range
|
||||
if ((xval >= xmin) && (xval <= xmax)) {
|
||||
dump.theoryX.push_back(xval);
|
||||
dump.theory.push_back(yval);
|
||||
}
|
||||
}
|
||||
|
||||
// if anything found keep it
|
||||
if (dump.dataX.size() > 0)
|
||||
dumpVector.push_back(dump);
|
||||
}
|
||||
|
||||
break;
|
||||
case PV_FOURIER_REAL:
|
||||
break;
|
||||
case PV_FOURIER_IMAG:
|
||||
break;
|
||||
case PV_FOURIER_REAL_AND_IMAG:
|
||||
break;
|
||||
case PV_FOURIER_PWR:
|
||||
break;
|
||||
case PV_FOURIER_PHASE:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// generate output filename
|
||||
|
||||
// in order to handle names with "." correctly this slightly odd data-filename generation
|
||||
TObjArray *tokens = fMsrHandler->GetFileName().Tokenize(".");
|
||||
TObjString *ostr;
|
||||
TString str;
|
||||
TString fln = TString("");
|
||||
for (Int_t i=0; i<tokens->GetEntries()-1; i++) {
|
||||
ostr = dynamic_cast<TObjString*>(tokens->At(i));
|
||||
fln += ostr->GetString() + TString(".");
|
||||
}
|
||||
if (!fDifferenceView) {
|
||||
fln += "data.ascii";
|
||||
} else {
|
||||
fln += "diff.ascii";
|
||||
}
|
||||
|
||||
if (tokens) {
|
||||
delete tokens;
|
||||
tokens = 0;
|
||||
}
|
||||
|
||||
// open file
|
||||
ofstream fout;
|
||||
|
||||
// open output data-file
|
||||
fout.open(fln.Data(), iostream::out);
|
||||
if (!fout.is_open()) {
|
||||
cerr << endl << ">> PMusrCanvas::SaveDataAscii: **ERROR** couldn't open file " << fln.Data() << " for writing." << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
// find out what is the longest data/theory vector
|
||||
UInt_t maxDataLength = 0;
|
||||
UInt_t maxTheoryLength = 0;
|
||||
for (UInt_t i=0; i<dumpVector.size(); i++) {
|
||||
if (maxDataLength < dumpVector[i].dataX.size())
|
||||
maxDataLength = dumpVector[i].dataX.size();
|
||||
if (maxTheoryLength < dumpVector[i].theoryX.size())
|
||||
maxTheoryLength = dumpVector[i].theoryX.size();
|
||||
}
|
||||
|
||||
// write data to file
|
||||
UInt_t maxLength = 0;
|
||||
|
||||
if (fDifferenceView) { // difference view
|
||||
// write header
|
||||
switch (fCurrentPlotView) {
|
||||
case PV_DATA:
|
||||
fout << "% ";
|
||||
for (UInt_t i=0; i<dumpVector.size()-1; i++) {
|
||||
fout << "x" << i << " , diff" << i << ", errDiff" << i << ", ";
|
||||
}
|
||||
fout << "x" << dumpVector.size()-1 << " , diff" << dumpVector.size()-1 << ", errDiff" << dumpVector.size()-1 << endl;
|
||||
break;
|
||||
case PV_FOURIER_REAL:
|
||||
fout << "% ";
|
||||
for (UInt_t i=0; i<dumpVector.size()-1; i++) {
|
||||
fout << "freq" << i << ", F_diffRe" << i << ", ";
|
||||
}
|
||||
fout << "freq" << dumpVector.size()-1 << ", F_diffRe" << dumpVector.size()-1 << endl;
|
||||
break;
|
||||
case PV_FOURIER_IMAG:
|
||||
fout << "% ";
|
||||
for (UInt_t i=0; i<dumpVector.size()-1; i++) {
|
||||
fout << "freq" << i << ", F_diffIm" << i << ", ";
|
||||
}
|
||||
fout << "freq" << dumpVector.size()-1 << ", F_diffIm" << dumpVector.size()-1 << endl;
|
||||
break;
|
||||
case PV_FOURIER_REAL_AND_IMAG:
|
||||
fout << "% ";
|
||||
for (UInt_t i=0; i<dumpVector.size()/2; i++) {
|
||||
fout << "freq" << i << ", F_diffRe" << i << ", ";
|
||||
}
|
||||
for (UInt_t i=0; i<dumpVector.size()/2-1; i++) {
|
||||
fout << "freq" << i << ", F_diffIm" << i << ", ";
|
||||
}
|
||||
fout << "freq" << dumpVector.size()/2-1 << ", F_diffIm" << dumpVector.size()/2-1 << endl;
|
||||
break;
|
||||
case PV_FOURIER_PWR:
|
||||
fout << "% ";
|
||||
for (UInt_t i=0; i<dumpVector.size()-1; i++) {
|
||||
fout << "freq" << i << ", F_diffPwr" << i << ", ";
|
||||
}
|
||||
fout << "freq" << dumpVector.size()-1 << ", F_diffPwr" << dumpVector.size()-1 << endl;
|
||||
break;
|
||||
case PV_FOURIER_PHASE:
|
||||
fout << "% ";
|
||||
for (UInt_t i=0; i<dumpVector.size()-1; i++) {
|
||||
fout << "freq" << i << ", F_diffPhase" << i << ", ";
|
||||
}
|
||||
fout << "freq" << dumpVector.size()-1 << ", F_diffPhase" << dumpVector.size()-1 << endl;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
maxLength = maxDataLength;
|
||||
|
||||
// write difference data
|
||||
for (UInt_t i=0; i<maxLength; i++) {
|
||||
// write difference data
|
||||
for (UInt_t j=0; j<dumpVector.size()-1; j++) {
|
||||
if (i<dumpVector[j].dataX.size()) {
|
||||
fout << dumpVector[j].dataX[i] << ", ";
|
||||
fout << dumpVector[j].data[i] << ", ";
|
||||
if (dumpVector[j].dataErr.size() > 0)
|
||||
fout << dumpVector[j].dataErr[i] << ", ";
|
||||
} else {
|
||||
if (dumpVector[j].dataErr.size() > 0)
|
||||
fout << ", , , ";
|
||||
else
|
||||
fout << ", , ";
|
||||
}
|
||||
}
|
||||
// write last difference entry
|
||||
if (i<dumpVector[dumpVector.size()-1].dataX.size()) {
|
||||
fout << dumpVector[dumpVector.size()-1].dataX[i] << ", ";
|
||||
fout << dumpVector[dumpVector.size()-1].data[i] << ", ";
|
||||
if (dumpVector[dumpVector.size()-1].dataErr.size() > 0)
|
||||
fout << dumpVector[dumpVector.size()-1].dataErr[i];
|
||||
} else {
|
||||
if (dumpVector[dumpVector.size()-1].dataErr.size() > 0)
|
||||
fout << ", , ";
|
||||
else
|
||||
fout << ", ";
|
||||
}
|
||||
fout << endl;
|
||||
}
|
||||
} else { // no difference view
|
||||
// write header
|
||||
switch (fCurrentPlotView) {
|
||||
case PV_DATA:
|
||||
fout << "% ";
|
||||
for (UInt_t i=0; i<dumpVector.size(); i++) {
|
||||
fout << "xData" << i << " , data" << i << ", errData" << i << ", ";
|
||||
}
|
||||
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;
|
||||
case PV_FOURIER_REAL:
|
||||
fout << "% ";
|
||||
for (UInt_t i=0; i<dumpVector.size(); i++) {
|
||||
fout << "freq" << i << ", F_Re" << i << ", ";
|
||||
}
|
||||
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;
|
||||
case PV_FOURIER_IMAG:
|
||||
fout << "% ";
|
||||
for (UInt_t i=0; i<dumpVector.size(); i++) {
|
||||
fout << "freq" << i << ", F_Im" << i << ", ";
|
||||
}
|
||||
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;
|
||||
case PV_FOURIER_REAL_AND_IMAG:
|
||||
fout << "% ";
|
||||
for (UInt_t i=0; i<dumpVector.size()/2; i++) {
|
||||
fout << "freq" << i << ", F_Re" << i << ", ";
|
||||
}
|
||||
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;
|
||||
case PV_FOURIER_PWR:
|
||||
fout << "% ";
|
||||
for (UInt_t i=0; i<dumpVector.size(); i++) {
|
||||
fout << "freq" << i << ", F_Pwr" << i << ", ";
|
||||
}
|
||||
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;
|
||||
case PV_FOURIER_PHASE:
|
||||
fout << "% ";
|
||||
for (UInt_t i=0; i<dumpVector.size(); i++) {
|
||||
fout << "freq" << i << ", F_Phase" << i << ", ";
|
||||
}
|
||||
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;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (maxDataLength > maxTheoryLength)
|
||||
maxLength = maxDataLength;
|
||||
else
|
||||
maxLength = maxTheoryLength;
|
||||
|
||||
// write data and theory
|
||||
for (UInt_t i=0; i<maxLength; i++) {
|
||||
// write data
|
||||
for (UInt_t j=0; j<dumpVector.size(); j++) {
|
||||
if (i<dumpVector[j].dataX.size()) {
|
||||
fout << dumpVector[j].dataX[i] << ", ";
|
||||
fout << dumpVector[j].data[i] << ", ";
|
||||
if (dumpVector[j].dataErr.size() > 0)
|
||||
fout << dumpVector[j].dataErr[i] << ", ";
|
||||
} else {
|
||||
if (dumpVector[j].dataErr.size() > 0)
|
||||
fout << " , , , ";
|
||||
else
|
||||
fout << " , , ";
|
||||
}
|
||||
}
|
||||
// write theory
|
||||
for (UInt_t j=0; j<dumpVector.size()-1; j++) {
|
||||
if (i<dumpVector[j].theoryX.size()) {
|
||||
fout << dumpVector[j].theoryX[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 {
|
||||
fout << " , ";
|
||||
}
|
||||
fout << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// close file
|
||||
fout.close();
|
||||
|
||||
// clean up
|
||||
for (UInt_t i=0; i<dumpVector.size(); i++) {
|
||||
dumpVector[i].dataX.clear();
|
||||
dumpVector[i].data.clear();
|
||||
dumpVector[i].dataErr.clear();
|
||||
dumpVector[i].theoryX.clear();
|
||||
dumpVector[i].theory.clear();
|
||||
}
|
||||
dumpVector.clear();
|
||||
|
||||
cout << endl << ">> Data windows saved in ascii format ..." << endl;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// IsScaleN0AndBkg (private)
|
||||
|
@ -229,7 +229,7 @@ class PMusrCanvas : public TObject, public TQObject
|
||||
virtual void LastCanvasClosed(); // SLOT
|
||||
|
||||
virtual void SaveGraphicsAndQuit(Char_t *fileName, Char_t *graphicsFormat);
|
||||
virtual void SaveDataAsciiAndQuit();
|
||||
virtual void SaveDataAscii();
|
||||
|
||||
private:
|
||||
Int_t fTimeout; ///< timeout after which the Done signal should be emited. If timeout <= 0, no timeout is taking place
|
||||
@ -330,8 +330,6 @@ class PMusrCanvas : public TObject, public TQObject
|
||||
virtual void IncrementFourierPhase();
|
||||
virtual void DecrementFourierPhase();
|
||||
|
||||
virtual void SaveDataAscii();
|
||||
|
||||
virtual Bool_t IsScaleN0AndBkg();
|
||||
virtual UInt_t GetNeededAccuracy(PMsrParamStructure param);
|
||||
|
||||
|
@ -340,7 +340,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
if (asciiOutput) {
|
||||
musrCanvas->SaveDataAsciiAndQuit();
|
||||
// save data in batch mode
|
||||
musrCanvas->SaveDataAscii();
|
||||
musrCanvas->Done(0);
|
||||
}
|
||||
|
||||
// keep musrCanvas objects
|
||||
|
Loading…
x
Reference in New Issue
Block a user