diff --git a/README b/README index ceff445b..fd52af9c 100644 --- a/README +++ b/README @@ -1,33 +1,32 @@ -# musrfit - muSR data analysis package # - -### Contents ### - -This is a data analysis package to analyze time differential muSR data. -Currently it allows the following things: - -* setting up most commonly used fitting functions for muSR -* fitting data, including global fits -* showing the fit results and the residuals -* showing the Fourier transform of the data -* extracting easily the fitting parameters to be used in other programs (gnuplot, qtiplot/origin, ...) -* allows to generate fitting input files for follow-up runs -* allows to generate global fitting input files based on a single run template -* allows to implement more sophisticated user functions - (e.g. GL vortex lattice, Meissner screening including low-energy muon stopping profiles) - -### Currently supported platforms: ### - -* Linux -* Mac OS X -* Windows - not really, only for the very brave ones - -### Documentation #### - -For a more exhaustive user documentation see: - - http://lmu.web.psi.ch/musrfit/user/MUSR/WebHome.html - -### Contact ### - - - +# musrfit - muSR data analysis package # + +### Contents ### + +This is a data analysis package to analyze time differential muSR and beta-NMR data. +Currently it allows the following things: + +* setting up most commonly used fitting functions for muSR and beta-NMR +* fitting data, including global fits +* showing the fit results and the residuals +* showing the Fourier transform of the data +* extracting easily the fitting parameters to be used in other programs (gnuplot, qtiplot/origin, ...) +* allows to generate fitting input files for follow-up runs +* allows to generate global fitting input files based on a single run template +* allows to implement more sophisticated user functions + (e.g. GL vortex lattice, Meissner screening including low-energy muon stopping profiles) + +### Currently supported platforms: ### + +* Linux +* Mac OS X +* Windows - not really, only for the very brave ones + +### Documentation #### + +For a more exhaustive user documentation see: + + http://lmu.web.psi.ch/musrfit/user/MUSR/WebHome.html + +### Contact ### + + \ No newline at end of file diff --git a/src/classes/PMusrCanvas.cpp b/src/classes/PMusrCanvas.cpp index 17e34378..9762e17b 100644 --- a/src/classes/PMusrCanvas.cpp +++ b/src/classes/PMusrCanvas.cpp @@ -1361,6 +1361,922 @@ void PMusrCanvas::SaveGraphicsAndQuit(Char_t *fileName, Char_t *graphicsFormat) Done(0); } +//-------------------------------------------------------------------------- +// SaveDataAscii +//-------------------------------------------------------------------------- +/** + *

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; iGetNbinsX(); 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; iGetNbinsX(); 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; iGetNbinsX(); 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; iGetNbinsX(); 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; jGetNbinsX(); 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; iGetNbinsX(); 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; iGetNbinsX(); 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; iGetNbinsX(); 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; jGetNbinsX(); 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; iGetNbinsX(); 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; jGetNbinsX(); 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; iGetNbinsX(); 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; jGetNbinsX(); 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; iGetNbinsX(); 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; jGetNbinsX(); 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; jGetNbinsX(); 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; jGetNbinsX(); 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; iGetNbinsX(); 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; jGetNbinsX(); 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; iGetNbinsX(); 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; jGetNbinsX(); 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; iGetN(); 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; iGetN(); 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; jGetN(); 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; iGetEntries()-1; i++) { + ostr = dynamic_cast(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 0) + fout << dumpVector[j].dataErr[i] << ", "; + } else { + if (dumpVector[j].dataErr.size() > 0) + fout << ", , , "; + else + fout << ", , "; + } + } + // write last difference entry + if (i 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 maxTheoryLength) + maxLength = maxDataLength; + else + maxLength = maxTheoryLength; + + // write data and theory + for (UInt_t i=0; i 0) + fout << dumpVector[j].dataErr[i] << ", "; + } else { + if (dumpVector[j].dataErr.size() > 0) + fout << " , , , "; + else + fout << " , , "; + } + } + // write theory + for (UInt_t j=0; j> Data windows saved in ascii format ..." << endl; + // if (asciiOutput) { + // if (fPlotNumber == static_cast(fMsrHandler->GetMsrPlotList()->size()) - 1) + // Done(0); + // } +} + //-------------------------------------------------------------------------- // CreateStyle (private) //-------------------------------------------------------------------------- @@ -2079,7 +2995,7 @@ void PMusrCanvas::HandleDataSet(UInt_t plotNo, UInt_t runNo, PRunData *data) (Int_t)((fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin[runNo] - data->GetTheoryTimeStart())/data->GetTheoryTimeStep()) * data->GetTheoryTimeStep() - data->GetTheoryTimeStep()/2.0; // closesd start value compatible with the user given end = start + size * data->GetTheoryTimeStep(); // closesd end value compatible with the user given - } +} // invoke histo theoHisto = new TH1F(name, name, size, start, end); @@ -4156,7 +5072,6 @@ void PMusrCanvas::PlotFourier(Bool_t unzoom) // plot fourier data Double_t xmin, xmax, ymin, ymax, binContent; UInt_t noOfPoints = 1000; - switch (fCurrentPlotView) { case PV_FOURIER_REAL: // set x-range @@ -5273,917 +6188,6 @@ void PMusrCanvas::DecrementFourierPhase() } } -//-------------------------------------------------------------------------- -// SaveDataAscii (private) -//-------------------------------------------------------------------------- -/** - *

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; iGetNbinsX(); 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; iGetNbinsX(); 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; iGetNbinsX(); 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; iGetNbinsX(); 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; jGetNbinsX(); 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; iGetNbinsX(); 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; iGetNbinsX(); 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; iGetNbinsX(); 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; jGetNbinsX(); 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; iGetNbinsX(); 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; jGetNbinsX(); 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; iGetNbinsX(); 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; jGetNbinsX(); 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; iGetNbinsX(); 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; jGetNbinsX(); 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; jGetNbinsX(); 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; jGetNbinsX(); 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; iGetNbinsX(); 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; jGetNbinsX(); 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; iGetNbinsX(); 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; jGetNbinsX(); 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; iGetN(); 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; iGetN(); 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; jGetN(); 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; iGetEntries()-1; i++) { - ostr = dynamic_cast(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 0) - fout << dumpVector[j].dataErr[i] << ", "; - } else { - if (dumpVector[j].dataErr.size() > 0) - fout << ", , , "; - else - fout << ", , "; - } - } - // write last difference entry - if (i 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 maxTheoryLength) - maxLength = maxDataLength; - else - maxLength = maxTheoryLength; - - // write data and theory - for (UInt_t i=0; i 0) - fout << dumpVector[j].dataErr[i] << ", "; - } else { - if (dumpVector[j].dataErr.size() > 0) - fout << " , , , "; - else - fout << " , , "; - } - } - // write theory - for (UInt_t j=0; j> Data windows saved in ascii format ..." << endl; -} //-------------------------------------------------------------------------- // IsScaleN0AndBkg (private) diff --git a/src/external/libBNMR/045674.msr b/src/external/libBNMR/045674.msr new file mode 100644 index 00000000..df6bc823 Binary files /dev/null and b/src/external/libBNMR/045674.msr differ diff --git a/src/external/libBNMR/ExpRlx-MUD.msr b/src/external/libBNMR/ExpRlx-MUD.msr new file mode 100644 index 00000000..ccbf0bb4 --- /dev/null +++ b/src/external/libBNMR/ExpRlx-MUD.msr @@ -0,0 +1,73 @@ + +# Run Numbers: 1111 +############################################################### +FITPARAMETER +############################################################### +# No Name Value Err Min Max + 1 Alphap 1.11662 0.00020 none + 2 Asyp 0 0.00038 none + 3 T 1e6 0 none + 4 Rlx 0.969e6 0.020 none + 5 Pos 1 0 none + 6 Neg -1 0 none + +############################################################### +THEORY +############################################################### +asymmetry fun1 +userFcn libBNMR.so ExpRlx 3 4 + +############################################################### +FUNCTIONS +############################################################### +fun1 = map1 * map2 + +############################################################### +RUN 045674 BNMR TRIUMF MUD (name beamline institute data-file-format) +fittype 2 (asymmetry fit) +alpha 1 +forward 3 +backward 4 +data 11 799 11 799 +background 800 900 800 900 # estimated bkg: 416.9700 / 465.7600 +t0 0.0 0.0 +map 2 5 0 0 0 0 0 0 0 0 +fit 5e5 8e6 +packing 5 + +RUN 045674 BNMR TRIUMF MUD (name beamline institute data-file-format) +fittype 2 (asymmetry fit) +alpha 1 +forward 5 +backward 6 +data 11 799 11 799 +background 800 900 800 900 # estimated bkg: 430.9200 / 479.4500 +t0 0.0 0.0 +map 2 6 0 0 0 0 0 0 0 0 +fit 5e5 8e6 +packing 5 + + +############################################################### +COMMANDS +MINIMIZE +HESSE +SAVE + +############################################################### +PLOT 2 (asymmetry plot) +runs 1 2 +use_fit_ranges + + +############################################################### +FOURIER +units MHz # units either 'Gauss', 'MHz', or 'Mc/s' +fourier_power 12 +apodization STRONG # NONE, WEAK, MEDIUM, STRONG +plot POWER # REAL, IMAG, REAL_AND_IMAG, POWER, PHASE +phase 8 +#range FRQMIN FRQMAX +############################################################### +STATISTIC --- 2014-11-14 16:37:41 + chisq = 372.2, NDF = 295, chisq/NDF = 1.261744 diff --git a/src/include/PMusrCanvas.h b/src/include/PMusrCanvas.h index eaf0b5ac..7b44260e 100644 --- a/src/include/PMusrCanvas.h +++ b/src/include/PMusrCanvas.h @@ -229,6 +229,7 @@ class PMusrCanvas : public TObject, public TQObject virtual void LastCanvasClosed(); // SLOT virtual void SaveGraphicsAndQuit(Char_t *fileName, Char_t *graphicsFormat); + virtual void SaveDataAscii(); private: Int_t fTimeout; ///< timeout after which the Done signal should be emited. If timeout <= 0, no timeout is taking place @@ -329,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); diff --git a/src/musrview.cpp b/src/musrview.cpp index e9cb2558..6e035945 100644 --- a/src/musrview.cpp +++ b/src/musrview.cpp @@ -67,6 +67,8 @@ void musrview_syntax() cout << endl << " eps, pdf, gif, jpg, png, svg, xpm, root"; cout << endl << " example: musrview 3310.msr --png, will produce a files 3310_X.png"; cout << endl << " where 'X' stands for the plot number (starting form 0)"; + cout << endl << " --ascii: "; + cout << endl << " will produce an ascii dump of the data and fit as plotted."; cout << endl << " --timeout : given in seconds after which musrview terminates."; cout << endl << " If <= 0, no timeout will take place. Default is 0."; cout << endl; @@ -100,6 +102,7 @@ int main(int argc, char *argv[]) bool success = true; char fileName[128]; bool graphicsOutput = false; + bool asciiOutput = false; char graphicsExtension[128]; int timeout = 0; @@ -135,6 +138,8 @@ int main(int argc, char *argv[]) graphicsOutput = true; strcpy(graphicsExtension, argv[i]+2); + } else if (!strcmp(argv[i], "--ascii")) { + asciiOutput = true; } else if (!strcmp(argv[i], "--timeout")) { if (i+1 < argc) { TString str(argv[i+1]); @@ -280,7 +285,7 @@ int main(int argc, char *argv[]) if (success) { // generate Root application needed for PMusrCanvas - if (graphicsOutput) { + if (graphicsOutput || asciiOutput) { argv[argc] = (char*)malloc(16*sizeof(char)); strcpy(argv[argc], "-b"); argc++; @@ -299,10 +304,10 @@ int main(int argc, char *argv[]) startupHandler->GetFourierDefaults(), startupHandler->GetMarkerList(), startupHandler->GetColorList(), - graphicsOutput); + graphicsOutput||asciiOutput); else musrCanvas = new PMusrCanvas(i, msrHandler->GetMsrTitle()->Data(), - 10+i*100, 10+i*100, 800, 600, graphicsOutput); + 10+i*100, 10+i*100, 800, 600, graphicsOutput||asciiOutput); if (!musrCanvas->IsValid()) { cerr << endl << ">> musrview **SEVERE ERROR** Couldn't invoke all necessary objects, will quit."; @@ -334,6 +339,12 @@ int main(int argc, char *argv[]) musrCanvas->SaveGraphicsAndQuit(fileName, graphicsExtension); } + if (asciiOutput) { + // save data in batch mode + musrCanvas->SaveDataAscii(); + musrCanvas->Done(0); + } + // keep musrCanvas objects canvasVector.push_back(musrCanvas); }