added y-range option to usr_fit_ranges in the PLOT block (MUSR-144)

This commit is contained in:
nemu 2010-10-21 05:03:28 +00:00
parent 5cd4283d30
commit 38161c9d42
3 changed files with 61 additions and 4 deletions

View File

@ -6,6 +6,7 @@
musrfit 0.7.0 - changes since 0.6.0
===================================
NEW added y-range option to usr_fit_ranges in the PLOT block (MUSR-144).
NEW added FIT_RANGE RESET | start end | s1 e1 s2 e2 .. sN eN command to the COMMAND block
NEW added FIX/RELEASE/RESTORE minuit2 command to the COMMAND block
NEW implemented more checks on the integrity of the msr-file

View File

@ -1672,7 +1672,10 @@ Int_t PMsrHandler::WriteMsrFile(const Char_t *filename, map<UInt_t, TString> *co
// use_fit_ranges
if (fPlots[i].fUseFitRanges) {
fout << "use_fit_ranges" << endl;
if (!fPlots[i].fYmin.empty() && !fPlots[i].fYmax.empty())
fout << "use_fit_ranges " << fPlots[i].fYmin[0] << " " << fPlots[i].fYmax[0] << endl;
else
fout << "use_fit_ranges" << endl;
}
// view_packing
@ -3444,6 +3447,43 @@ Bool_t PMsrHandler::HandlePlotEntry(PMsrLines &lines)
}
} else if (iter1->fLine.Contains("use_fit_ranges", TString::kIgnoreCase)) {
param.fUseFitRanges = true;
// check if y-ranges are given
tokens = iter1->fLine.Tokenize(" \t");
if (!tokens) {
cerr << endl << ">> PMsrHandler::HandlePlotEntry: **SEVERE ERROR** Couldn't tokenize PLOT in line " << iter1->fLineNo;
cerr << endl << endl;
return false;
}
if (tokens->GetEntries() == 3) { // i.e. use_fit_ranges ymin ymax
// handle y_min
ostr = dynamic_cast<TObjString*>(tokens->At(1));
str = ostr->GetString();
if (str.IsFloat())
param.fYmin.push_back((Double_t)str.Atof());
else
error = true;
// handle y_max
ostr = dynamic_cast<TObjString*>(tokens->At(2));
str = ostr->GetString();
if (str.IsFloat())
param.fYmax.push_back((Double_t)str.Atof());
else
error = true;
} else {
cerr << endl << ">> PMsrHandler::HandlePlotEntry: **WARNING** use_fit_ranges with undefined additional parameters in line " << iter1->fLineNo;
cerr << endl << ">> Will ignore this PLOT block command line, sorry.";
cerr << endl << ">> Proper syntax: use_fit_ranges [ymin ymax]";
cerr << endl << ">> Found: '" << iter1->fLine.Data() << "'" << endl;
}
// clean up
if (tokens) {
delete tokens;
tokens = 0;
}
} else if (iter1->fLine.Contains("logx", TString::kIgnoreCase)) {
param.fLogX = true;
} else if (iter1->fLine.Contains("logy", TString::kIgnoreCase)) {
@ -3670,7 +3710,7 @@ Bool_t PMsrHandler::HandlePlotEntry(PMsrLines &lines)
cerr << endl << "[range tmin tmax [ymin ymax]]";
cerr << endl << "[sub_ranges tmin1 tmax1 tmin2 tmax2 ... tminN tmaxN [ymin ymax]";
cerr << endl << "[logx | logy]";
cerr << endl << "[use_fit_ranges]";
cerr << endl << "[use_fit_ranges [ymin ymax]]";
cerr << endl << "[view_packing n]";
cerr << endl;
cerr << endl << "where <plot_type> is: 0=single histo asym,";

View File

@ -1721,7 +1721,7 @@ void PMusrCanvas::HandleDataSet(UInt_t plotNo, UInt_t runNo, PRunData *data)
}
}
// check if 'use_fit_range' plotting is whished
// check if 'use_fit_ranges' plotting is whished
if (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fUseFitRanges) {
start = fMsrHandler->GetMsrRunList()->at(runNo).GetFitRange(0); // needed to estimate size
end = fMsrHandler->GetMsrRunList()->at(runNo).GetFitRange(1); // needed to estimate size
@ -1749,7 +1749,16 @@ void PMusrCanvas::HandleDataSet(UInt_t plotNo, UInt_t runNo, PRunData *data)
fXmin = start;
fXmax = end;
}
if (!fYRangePresent) {
// check if y-range is given as well
if (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fYmin.size() != 0) {
ymin = fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fYmin[0];
ymax = fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fYmax[0];
dataSet.dataRange->SetYRange(ymin, ymax);
// keep range information
fYRangePresent = true;
fYmin = ymin;
fYmax = ymax;
} else {
fYRangePresent = true;
fYmin = -0.4;
fYmax = 0.4;
@ -2025,6 +2034,13 @@ void PMusrCanvas::HandleNonMusrDataSet(UInt_t plotNo, UInt_t runNo, PRunData *da
xmin = fMsrHandler->GetMsrRunList()->at(runNo).GetFitRange(0); // needed to estimate size
xmax = fMsrHandler->GetMsrRunList()->at(runNo).GetFitRange(1); // needed to estimate size
dataSet.dataRange->SetXRange(xmin, xmax);
// check if y-range is given as well
if (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fYmin.size() != 0) {
ymin = fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fYmin[0];
ymax = fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fYmax[0];
dataSet.dataRange->SetYRange(ymin, ymax);
}
}
// check if 'sub_ranges' plotting is whished