From d0f520a1f48d2ae8343d02157871ad96a9b70992 Mon Sep 17 00:00:00 2001 From: nemu Date: Tue, 12 Jul 2011 07:17:38 +0000 Subject: [PATCH] a musrview exception error when starting with t0's very much off to the positive side in the msr-file (MUSR-199) --- ChangeLog | 1 + src/classes/PMusrCanvas.cpp | 99 ++++++++++++++++++++++++++++++++++--- 2 files changed, 94 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3ed3adb1..6e2cce01 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,7 @@ NEW the chi^2 calculation in single-histogram and asymmetry fits is parallelized if musrfit is built using a compiler supporting OpenMP (e.g. GCC >= 4.2) Using --disable-omp this feature can be disabled on the configure level. NEW any2many: force the user to define the exact NeXus ouput format (HDF4,HDF5,XML) +FIXED a musrview exception error when starting with t0's very much off to the positive side in the msr-file (MUSR-199) FIXED a linking problem when only shared libraries are built on Cygwin FIXED the problem that in certain environments XML files could not be parsed (MUSR-122) FIXED crash of musrview in case the XML startup file is present but cannot be parsed correctly diff --git a/src/classes/PMusrCanvas.cpp b/src/classes/PMusrCanvas.cpp index 7852947a..6574c3b3 100644 --- a/src/classes/PMusrCanvas.cpp +++ b/src/classes/PMusrCanvas.cpp @@ -1825,14 +1825,56 @@ void PMusrCanvas::HandleDataSet(UInt_t plotNo, UInt_t runNo, PRunData *data) // check if 'use_fit_range' plotting is whished if (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fUseFitRanges) { - startBin = (UInt_t)((fMsrHandler->GetMsrRunList()->at(runNo).GetFitRange(0) - data->GetDataTimeStart())/data->GetDataTimeStep()); - endBin = (UInt_t)((fMsrHandler->GetMsrRunList()->at(runNo).GetFitRange(1) - data->GetDataTimeStart())/data->GetDataTimeStep()); + Double_t dval = (fMsrHandler->GetMsrRunList()->at(runNo).GetFitRange(0) - data->GetDataTimeStart())/data->GetDataTimeStep(); + if (dval < 0.0) { // make sure that startBin >= 0 + startBin = 0; + cerr << endl << "PMusrCanvas::HandleDataSet() **WARNING** found startBin data < 0 for 'use_fit_range', will set it to 0" << endl << endl; + } else if (dval >= (Double_t)data->GetValue()->size()) { // make sure that startBin <= length of data vector + cerr << endl << ">> PMusrCanvas::HandleDataSet() **WARNING** found startBin data=" << (UInt_t)dval << " >= data vector size=" << data->GetValue()->size() << " for 'use_fit_range',"; + cerr << endl << ">> will set it to data vector size" << endl << endl; + startBin = data->GetValue()->size(); + } else { + startBin = (UInt_t)dval; + } + + dval = (fMsrHandler->GetMsrRunList()->at(runNo).GetFitRange(1) - data->GetDataTimeStart())/data->GetDataTimeStep(); + if (dval < 0.0) { // make sure that endBin >= 0 + endBin = 0; + cerr << endl << "PMusrCanvas::HandleDataSet() **WARNING** found endBin data < 0 for 'use_fit_range', will set it to 0" << endl << endl; + } else if (dval >= (Double_t)data->GetValue()->size()) { // make sure that endBin <= length of data vector + cerr << endl << ">> PMusrCanvas::HandleDataSet() **WARNING** found endBin data=" << (UInt_t)dval << " >= data vector size=" << data->GetValue()->size() << " for 'use_fit_range',"; + cerr << endl << ">> will set it to data vector size" << endl << endl; + endBin = data->GetValue()->size(); + } else { + endBin = (UInt_t)dval; + } } // check if 'sub_ranges' plotting is whished if (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin.size() > 1) { - startBin = (UInt_t)((fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin[runNo] - data->GetDataTimeStart())/data->GetDataTimeStep()); - endBin = (UInt_t)((fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmax[runNo] - data->GetDataTimeStart())/data->GetDataTimeStep()); + Double_t dval = (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin[runNo] - data->GetDataTimeStart())/data->GetDataTimeStep(); + if (dval < 0.0) { // make sure that startBin >= 0 + startBin = 0; + cerr << endl << "PMusrCanvas::HandleDataSet() **WARNING** found startBin data < 0 for 'sub_ranges', will set it to 0" << endl << endl; + } else if (dval >= (Double_t)data->GetValue()->size()) { // make sure that startBin <= length of data vector + cerr << endl << ">> PMusrCanvas::HandleDataSet() **WARNING** found startBin data=" << (UInt_t)dval << " >= data vector size=" << data->GetValue()->size() << " for 'sub_ranges',"; + cerr << endl << ">> will set it to data vector size" << endl << endl; + startBin = data->GetValue()->size(); + } else { + startBin = (UInt_t)dval; + } + + dval = (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmax[runNo] - data->GetDataTimeStart())/data->GetDataTimeStep(); + if (dval < 0.0) { // make sure that endBin >= 0 + endBin = 0; + cerr << endl << "PMusrCanvas::HandleDataSet() **WARNING** found endBin data < 0 for 'sub_ranges', will set it to 0" << endl << endl; + } else if (dval >= (Double_t)data->GetValue()->size()) { // make sure that endtBin <= length of data vector + cerr << endl << ">> PMusrCanvas::HandleDataSet() **WARNING** found endBin data=" << (UInt_t)dval << " >= data vector size=" << data->GetValue()->size() << " for 'sub_ranges',"; + cerr << endl << ">> will set it to data vector size" << endl << endl; + endBin = data->GetValue()->size(); + } else { + endBin = (UInt_t)dval; + } } for (UInt_t i=startBin; iGetMsrPlotList()->at(fPlotNumber).fUseFitRanges) { - startBin = (UInt_t)((fMsrHandler->GetMsrRunList()->at(runNo).GetFitRange(0) - data->GetDataTimeStart())/data->GetTheoryTimeStep()); - endBin = (UInt_t)((fMsrHandler->GetMsrRunList()->at(runNo).GetFitRange(1) - data->GetDataTimeStart())/data->GetTheoryTimeStep()); + Double_t dval = (fMsrHandler->GetMsrRunList()->at(runNo).GetFitRange(0) - data->GetDataTimeStart())/data->GetTheoryTimeStep(); + if (dval < 0.0) { // make sure that startBin >= 0 + startBin = 0; + cerr << endl << "PMusrCanvas::HandleDataSet() **WARNING** found startBin theory < 0 for 'use_fit_range', will set it to 0" << endl << endl; + } else if (dval >= (Double_t)data->GetTheory()->size()) { // make sure that startBin <= length of theory vector + cerr << endl << ">> PMusrCanvas::HandleDataSet() **WARNING** found startBin theory=" << (UInt_t)dval << " >= theory vector size=" << data->GetTheory()->size() << " for 'use_fit_range',"; + cerr << endl << ">> will set it to theory vector size" << endl << endl; + startBin = data->GetTheory()->size(); + } else { + startBin = (UInt_t)dval; + } + + dval = (fMsrHandler->GetMsrRunList()->at(runNo).GetFitRange(1) - data->GetDataTimeStart())/data->GetTheoryTimeStep(); + if (dval < 0.0) { // make sure that endBin >= 0 + endBin = 0; + cerr << endl << "PMusrCanvas::HandleDataSet() **WARNING** found endBin theory < 0 for 'use_fit_range', will set it to 0" << endl << endl; + } else if (dval >= (Double_t)data->GetTheory()->size()) { // make sure that endBin <= length of theory vector + cerr << endl << ">> PMusrCanvas::HandleDataSet() **WARNING** found endBin theory=" << (UInt_t)dval << " >= theory vector size=" << data->GetTheory()->size() << " for 'use_fit_range',"; + cerr << endl << ">> will set it to theory vector size" << endl << endl; + endBin = data->GetTheory()->size(); + } else { + endBin = (UInt_t)dval; + } } // check if 'sub_ranges' plotting is whished if (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin.size() > 1) { startBin = (UInt_t)((fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin[runNo] -data->GetDataTimeStart())/data->GetTheoryTimeStep()); endBin = (UInt_t)((fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmax[runNo] -data->GetDataTimeStart())/data->GetTheoryTimeStep()); + + Double_t dval = (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin[runNo] -data->GetDataTimeStart())/data->GetTheoryTimeStep(); + if (dval < 0.0) { // make sure that startBin >= 0 + startBin = 0; + cerr << endl << "PMusrCanvas::HandleDataSet() **WARNING** found startBin theory < 0 for 'sub_ranges', will set it to 0" << endl << endl; + } else if (dval >= (Double_t)data->GetTheory()->size()) { // make sure that startBin <= length of theory vector + cerr << endl << ">> PMusrCanvas::HandleDataSet() **WARNING** found startBin theory=" << (UInt_t)dval << " >= theory vector size=" << data->GetTheory()->size() << " for 'sub_ranges',"; + cerr << endl << ">> will set it to theory vector size" << endl << endl; + startBin = data->GetTheory()->size(); + } else { + startBin = (UInt_t)dval; + } + + dval = (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmax[runNo] -data->GetDataTimeStart())/data->GetTheoryTimeStep(); + if (dval < 0.0) { // make sure that endBin >= 0 + endBin = 0; + cerr << endl << "PMusrCanvas::HandleDataSet() **WARNING** found endBin theory < 0 for 'sub_ranges', will set it to 0" << endl << endl; + } else if (dval >= (Double_t)data->GetTheory()->size()) { // make sure that endtBin <= length of theory vector + cerr << endl << ">> PMusrCanvas::HandleDataSet() **WARNING** found endBin theory=" << (UInt_t)dval << " >= theory vector size=" << data->GetTheory()->size() << " for 'sub_ranges',"; + cerr << endl << ">> will set it to theory vector size" << endl << endl; + endBin = data->GetTheory()->size(); + } else { + endBin = (UInt_t)dval; + } } for (UInt_t i=startBin; i