From 38161c9d427d4e87687d5decdb5ee96f9492b679 Mon Sep 17 00:00:00 2001 From: nemu Date: Thu, 21 Oct 2010 05:03:28 +0000 Subject: [PATCH] added y-range option to usr_fit_ranges in the PLOT block (MUSR-144) --- ChangeLog | 1 + src/classes/PMsrHandler.cpp | 44 +++++++++++++++++++++++++++++++++++-- src/classes/PMusrCanvas.cpp | 20 +++++++++++++++-- 3 files changed, 61 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 19000fd5..b31a9eef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/src/classes/PMsrHandler.cpp b/src/classes/PMsrHandler.cpp index 05fd4e3d..605577f6 100644 --- a/src/classes/PMsrHandler.cpp +++ b/src/classes/PMsrHandler.cpp @@ -1672,7 +1672,10 @@ Int_t PMsrHandler::WriteMsrFile(const Char_t *filename, map *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(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(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 is: 0=single histo asym,"; diff --git a/src/classes/PMusrCanvas.cpp b/src/classes/PMusrCanvas.cpp index 860bd290..be297072 100644 --- a/src/classes/PMusrCanvas.cpp +++ b/src/classes/PMusrCanvas.cpp @@ -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