From 91c66651aa46f46a27ddd7caed4477d9313ea3d8 Mon Sep 17 00:00:00 2001 From: nemu Date: Wed, 11 Aug 2010 13:12:31 +0000 Subject: [PATCH] fix of a time window frame bug reported in MUSR-138 --- src/classes/PFourier.cpp | 6 +++++- src/classes/PMusrCanvas.cpp | 33 ++++++++++++++++++++++++++++----- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/classes/PFourier.cpp b/src/classes/PFourier.cpp index d4677768..c36aac2f 100644 --- a/src/classes/PFourier.cpp +++ b/src/classes/PFourier.cpp @@ -371,7 +371,11 @@ void PFourier::PrepareFFTwInputData(UInt_t apodizationTag) } // 2nd fill fIn - UInt_t start = (UInt_t)(fStartTime/fTimeResolution) + t0bin; + Int_t val = static_cast(fStartTime/fTimeResolution) + t0bin; + UInt_t start = 0; + if (val >= 0) { + start = static_cast(static_cast(fStartTime/fTimeResolution) + t0bin); + } for (UInt_t i=0; iGetBinContent(i+start); fIn[i][1] = 0.0; diff --git a/src/classes/PMusrCanvas.cpp b/src/classes/PMusrCanvas.cpp index 3888cb6c..bae2304b 100644 --- a/src/classes/PMusrCanvas.cpp +++ b/src/classes/PMusrCanvas.cpp @@ -2015,11 +2015,14 @@ void PMusrCanvas::HandleDifferenceFourier() // check if difference has been already calcualted, if not do it if (fData[0].diff == 0) HandleDifference(); + + // get time from the current fHistoFrame Int_t bin; - bin = fData[0].diff->GetXaxis()->GetFirst(); - double startTime = fData[0].diff->GetBinCenter(bin); - bin = fData[0].diff->GetXaxis()->GetLast(); - double endTime = fData[0].diff->GetBinCenter(bin); + bin = fHistoFrame->GetXaxis()->GetFirst(); + double startTime = fHistoFrame->GetBinCenter(bin); + bin = fHistoFrame->GetXaxis()->GetLast(); + double endTime = fHistoFrame->GetBinCenter(bin); + for (UInt_t i=0; iDrawFrame(dataXmin, dataYmin, dataXmax, dataYmax); fHistoFrame->GetXaxis()->SetRangeUser(fXmin, fXmax); @@ -2699,16 +2708,30 @@ void PMusrCanvas::PlotDifference() return; if (fPlotType != MSR_PLOT_NON_MUSR) { + // keep the current x-axis range from the data view + Double_t xmin, xmax; + xmin = fHistoFrame->GetXaxis()->GetBinCenter(fHistoFrame->GetXaxis()->GetFirst()); + xmax = fHistoFrame->GetXaxis()->GetBinCenter(fHistoFrame->GetXaxis()->GetLast()); + + // delete old fHistoFrame if present + if (fHistoFrame) { + delete fHistoFrame; + fHistoFrame = 0; + } + fHistoFrame = fDataTheoryPad->DrawFrame(fXmin, fYmin, fXmax, fYmax); // set x-axis label fHistoFrame->GetXaxis()->SetTitle("time (#mus)"); // set y-axis label fHistoFrame->GetYaxis()->SetTitle("data-theory"); - // plot all remaining diff data + // plot all diff data for (UInt_t i=0; iDraw("pesame"); } + // set the axis frame to the values of the data frame + fHistoFrame->GetXaxis()->SetRangeUser(xmin, xmax); + // check if RRF and if yes show a label if ((fRRFText != 0) && (fRRFLatexText != 0)) { fRRFLatexText->DrawLatex(0.1, 0.92, fRRFText->Data());