diff --git a/src/classes/PMsrHandler.cpp b/src/classes/PMsrHandler.cpp index 14f188ef..feeccd0a 100644 --- a/src/classes/PMsrHandler.cpp +++ b/src/classes/PMsrHandler.cpp @@ -3204,6 +3204,11 @@ Bool_t PMsrHandler::HandlePlotEntry(PMsrLines &lines) param.fLogX = false; // i.e. if not overwritten use linear x-axis param.fLogY = false; // i.e. if not overwritten use linear y-axis param.fViewPacking = -1; // i.e. if not overwritten use the packing of the run blocks + param.fRuns.clear(); + param.fTmin.clear(); + param.fTmax.clear(); + param.fYmin.clear(); + param.fYmax.clear(); param.fRRFPacking = 0; // i.e. if not overwritten it will not be a valid RRF param.fRRFFreq = 0.0; // i.e. no RRF whished param.fRRFUnit = RRF_UNIT_MHz; diff --git a/src/classes/PMusr.cpp b/src/classes/PMusr.cpp index 7c23e5af..e8eb40a7 100644 --- a/src/classes/PMusr.cpp +++ b/src/classes/PMusr.cpp @@ -1190,7 +1190,7 @@ void PMsrRunBlock::SetAddT0(Int_t ival, UInt_t addRunIdx, UInt_t histoNoIdx) // GetFitRange //-------------------------------------------------------------------------- /** - *
get fit range value at position idx + *
get fit range value at position idx. idx: 0=fit range start, 1=fit range end. * * return: * - fit range value, if idx is within proper boundaries diff --git a/src/classes/PMusrCanvas.cpp b/src/classes/PMusrCanvas.cpp index 7ed7113a..eed9d49a 100644 --- a/src/classes/PMusrCanvas.cpp +++ b/src/classes/PMusrCanvas.cpp @@ -41,6 +41,70 @@ using namespace std; #include "PMusrCanvas.h" #include "PFourier.h" +ClassImp(PMusrCanvas) + +//-------------------------------------------------------------------------- +// Constructor +//-------------------------------------------------------------------------- +/** + *
Constructor + */ +PMusrCanvasPlotRange::PMusrCanvasPlotRange() +{ + fXRangePresent = false; + fYRangePresent = false; + + fXmin = 0.0; + fXmax = 0.0; + fYmin = 0.0; + fYmax = 0.0; +} + +//-------------------------------------------------------------------------- +// SetXRange (public) +//-------------------------------------------------------------------------- +/** + *
Sets the x-range values. + * + * \param xmin minimum range value + * \param xmax maximum range value + */ +void PMusrCanvasPlotRange::SetXRange(Double_t xmin, Double_t xmax) +{ + if (xmin > xmax) { + cerr << endl << "PMusrCanvasPlotRange::SetXRange: **WARNING** xmin > xmax, will swap them." << endl; + fXmin = xmax; + fXmax = xmin; + } else { + fXmin = xmin; + fXmax = xmax; + } + fXRangePresent = true; +} + +//-------------------------------------------------------------------------- +// SetYRange (public) +//-------------------------------------------------------------------------- +/** + *
Sets the y-range values.
+ *
+ * \param ymin minimum range value
+ * \param ymax maximum range value
+ */
+void PMusrCanvasPlotRange::SetYRange(Double_t ymin, Double_t ymax)
+{
+ if (ymin > ymax) {
+ cerr << endl << "PMusrCanvasPlotRange::SetYRange: **WARNING** ymin > ymax, will swap them." << endl;
+ fYmin = ymax;
+ fYmax = ymin;
+ } else {
+ fYmin = ymin;
+ fYmax = ymax;
+ }
+ fYRangePresent = true;
+}
+
+
ClassImpQ(PMusrCanvas)
//--------------------------------------------------------------------------
@@ -84,6 +148,11 @@ PMusrCanvas::PMusrCanvas()
fRRFText = 0;
fRRFLatexText = 0;
+
+ fXmin = 0.0;
+ fXmax = 0.0;
+ fYmin = 0.0;
+ fYmax = 0.0;
}
//--------------------------------------------------------------------------
@@ -120,6 +189,11 @@ PMusrCanvas::PMusrCanvas(const Int_t number, const Char_t* title,
fRRFText = 0;
fRRFLatexText = 0;
+
+ fXmin = 0.0;
+ fXmax = 0.0;
+ fYmin = 0.0;
+ fYmax = 0.0;
}
//--------------------------------------------------------------------------
@@ -162,6 +236,11 @@ PMusrCanvas::PMusrCanvas(const Int_t number, const Char_t* title,
fRRFText = 0;
fRRFLatexText = 0;
+
+ fXmin = 0.0;
+ fXmax = 0.0;
+ fYmin = 0.0;
+ fYmax = 0.0;
}
//--------------------------------------------------------------------------
@@ -760,7 +839,7 @@ void PMusrCanvas::HandleCmdKey(Int_t event, Int_t x, Int_t y, TObject *selected)
PlotData();
} else if ((fCurrentPlotView == PV_DATA) && fDifferenceView) {
CleanupFourierDifference();
- HandleDifference();
+ HandleDifference(true);
} else if ((fCurrentPlotView != PV_DATA) && !fDifferenceView) {
HandleFourier();
} else if ((fCurrentPlotView != PV_DATA) && fDifferenceView) {
@@ -1332,6 +1411,7 @@ void PMusrCanvas::InitDataSet(PMusrCanvasDataSet &dataSet)
dataSet.diffFourierIm = 0;
dataSet.diffFourierPwr = 0;
dataSet.diffFourierPhase = 0;
+ dataSet.dataRange = 0;
}
//--------------------------------------------------------------------------
@@ -1359,6 +1439,7 @@ void PMusrCanvas::InitDataSet(PMusrCanvasNonMusrDataSet &dataSet)
dataSet.diffFourierIm = 0;
dataSet.diffFourierPwr = 0;
dataSet.diffFourierPhase = 0;
+ dataSet.dataRange = 0;
}
//--------------------------------------------------------------------------
@@ -1431,6 +1512,10 @@ void PMusrCanvas::CleanupDataSet(PMusrCanvasDataSet &dataSet)
delete dataSet.diffFourierPhase;
dataSet.diffFourierPhase = 0;
}
+ if (dataSet.dataRange) {
+ delete dataSet.dataRange;
+ dataSet.dataRange = 0;
+ }
}
//--------------------------------------------------------------------------
@@ -1503,6 +1588,10 @@ void PMusrCanvas::CleanupDataSet(PMusrCanvasNonMusrDataSet &dataSet)
delete dataSet.diffFourierPhase;
dataSet.diffFourierPhase = 0;
}
+ if (dataSet.dataRange) {
+ delete dataSet.dataRange;
+ dataSet.dataRange = 0;
+ }
}
//--------------------------------------------------------------------------
@@ -1521,13 +1610,17 @@ void PMusrCanvas::HandleDataSet(UInt_t plotNo, UInt_t runNo, PRunData *data)
TH1F *dataHisto;
TH1F *theoHisto;
- TString name;
- double start;
- double end;
+ TString name;
+ Double_t start;
+ Double_t end;
+ Double_t xmin, xmax, ymin, ymax;
Int_t size;
InitDataSet(dataSet);
+ // create plot range object for the data set
+ dataSet.dataRange = new PMusrCanvasPlotRange();
+
// dataHisto -------------------------------------------------------------
// create histo specific infos
name = *fMsrHandler->GetMsrRunList()->at(runNo).GetRunName() + "_DataRunNo";
@@ -1537,6 +1630,28 @@ void PMusrCanvas::HandleDataSet(UInt_t plotNo, UInt_t runNo, PRunData *data)
start = data->GetDataTimeStart() - data->GetDataTimeStep()/2.0;
end = start + data->GetValue()->size()*data->GetDataTimeStep();
size = data->GetValue()->size();
+ dataSet.dataRange->SetXRange(start, end); // full possible range
+ // make sure that for asymmetry the y-range is initialized reasonably
+ if (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fPlotType == MSR_PLOT_ASYM)
+ dataSet.dataRange->SetYRange(-0.4, 0.4);
+ fPlotRangeTag = PR_NONE; // keep the proper plot range tag
+
+ // check if plot range is given in the msr-file, and if yes keep the values
+ if (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin.size() != 0) {
+ // keep x-range
+ xmin = fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin[0];
+ xmax = fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmax[0];
+ 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);
+ }
+
+ // keep the proper plot range tag
+ fPlotRangeTag = PR_RANGE;
+ }
// check if 'use_fit_range' plotting is whished
if (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fUseFitRanges) {
@@ -1547,6 +1662,14 @@ void PMusrCanvas::HandleDataSet(UInt_t plotNo, UInt_t runNo, PRunData *data)
(Int_t)((fMsrHandler->GetMsrRunList()->at(runNo).GetFitRange(0) - data->GetDataTimeStart())/data->GetDataTimeStep()) * data->GetDataTimeStep() -
data->GetDataTimeStep()/2.0; // closesd start value compatible with the user given
end = start + size * data->GetDataTimeStep(); // closesd end value compatible with the user given
+ dataSet.dataRange->SetXRange(start, end);
+
+ // make sure that for asymmetry the y-range is initialized reasonably
+ if (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fPlotType == MSR_PLOT_ASYM)
+ dataSet.dataRange->SetYRange(-0.4, 0.4);
+
+ // keep the proper plot range tag
+ fPlotRangeTag = PR_FIT_RANGE;
}
// check if 'sub_ranges' plotting is whished
@@ -1558,6 +1681,17 @@ void PMusrCanvas::HandleDataSet(UInt_t plotNo, UInt_t runNo, PRunData *data)
(Int_t)((fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin[runNo] - data->GetDataTimeStart())/data->GetDataTimeStep()) * data->GetDataTimeStep() -
data->GetDataTimeStep()/2.0; // closesd start value compatible with the user given
end = start + size * data->GetDataTimeStep(); // closesd end value compatible with the user given
+ dataSet.dataRange->SetXRange(start, end);
+
+ // 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 the proper plot range tag
+ fPlotRangeTag = PR_SUB_RANGE;
}
// invoke histo
@@ -1694,6 +1828,9 @@ void PMusrCanvas::HandleNonMusrDataSet(UInt_t plotNo, UInt_t runNo, PRunData *da
InitDataSet(dataSet);
+ // create plot range object for the data set and fill it
+ dataSet.dataRange = new PMusrCanvasPlotRange();
+
// dataHisto -------------------------------------------------------------
// invoke graph
@@ -1749,6 +1886,89 @@ void PMusrCanvas::HandleNonMusrDataSet(UInt_t plotNo, UInt_t runNo, PRunData *da
dataSet.data = dataHisto;
dataSet.theory = theoHisto;
+ // check the plot range options
+ Double_t xmin=0.0, xmax=0.0, ymin=0.0, ymax=0.0, x=0.0, y=0.0;
+
+ // initialize the plot range to the maximal possible given the data. This is needed if there is no plot-range style entry present
+ dataSet.data->GetPoint(0, xmin, y); // get xmin
+ dataSet.data->GetPoint(dataSet.data->GetN()-1, xmax, y); // get xmax
+ dataSet.data->GetPoint(0, x, y); // init ymin/ymax
+ ymin = y;
+ ymax = y;
+ for (Int_t i=1; i Handles the calculation of the difference spectra (i.e. data-theory).
* It allocates the necessary objects if they are not already present. At the
* end it calls the plotting routine.
+ *
+ * \param unzoom if set to true, change ranges to the original msr-file values
*/
-void PMusrCanvas::HandleDifference()
+void PMusrCanvas::HandleDifference(Bool_t unzoom)
{
// check if it is necessary to calculate diff data
if ((fPlotType != MSR_PLOT_NON_MUSR) && (fData[0].diff == 0)) {
@@ -1802,6 +2024,9 @@ void PMusrCanvas::HandleDifference()
TString name;
// loop over all histos
for (UInt_t i=0; i
+ */
+class PMusrCanvasPlotRange : public TObject
+{
+ public:
+ PMusrCanvasPlotRange();
+ virtual ~PMusrCanvasPlotRange() {}
+
+ virtual void SetXRange(Double_t xmin, Double_t xmax);
+ virtual void SetYRange(Double_t ymin, Double_t ymax);
+
+ virtual Bool_t IsXRangePresent() { return fXRangePresent; }
+ virtual Bool_t IsYRangePresent() { return fYRangePresent; }
+
+ virtual Double_t GetXMin() { return fXmin; }
+ virtual Double_t GetXMax() { return fXmax; }
+ virtual Double_t GetYMin() { return fYmin; }
+ virtual Double_t GetYMax() { return fYmax; }
+
+ private:
+ Bool_t fXRangePresent;
+ Bool_t fYRangePresent;
+ Double_t fXmin;
+ Double_t fXmax;
+ Double_t fYmin;
+ Double_t fYmax;
+
+ ClassDef(PMusrCanvasPlotRange, 1)
+};
+
//------------------------------------------------------------------------
/**
* Structure holding all necessary histograms for a single plot block entry for
@@ -103,6 +141,7 @@ typedef struct {
TH1F *diffFourierIm; ///< imaginary part of the Fourier transform of the diff histogram
TH1F *diffFourierPwr; ///< power spectrum of the Fourier transform of the diff histogram
TH1F *diffFourierPhase; ///< phase spectrum of the Fourier transform of the diff histogram
+ PMusrCanvasPlotRange *dataRange; ///< keep the msr-file plot data range
} PMusrCanvasDataSet;
//------------------------------------------------------------------------
@@ -132,6 +171,7 @@ typedef struct {
TGraphErrors *diffFourierIm; ///< imaginary part of the Fourier transform of the diff error graph
TGraphErrors *diffFourierPwr; ///< power spectrum of the Fourier transform of the diff error graph
TGraphErrors *diffFourierPhase; ///< phase spectrum of the Fourier transform of the diff error graph
+ PMusrCanvasPlotRange *dataRange; ///< keep the msr-file plot data range
} PMusrCanvasNonMusrDataSet;
//------------------------------------------------------------------------
@@ -195,12 +235,13 @@ class PMusrCanvas : public TObject, public TQObject
virtual void SaveGraphicsAndQuit(Char_t *fileName, Char_t *graphicsFormat);
private:
- Bool_t fBatchMode; ///< musrview in ROOT batch mode
- Bool_t fValid; ///< if true, everything looks OK
- Bool_t fDifferenceView; ///< tag showing that the shown data, fourier, are the difference between data and theory
- Int_t fCurrentPlotView; ///< tag showing what the current plot view is: data, fourier, ...
- Int_t fPlotType; ///< plot type tag: -1 == undefined, MSR_PLOT_SINGLE_HISTO == single histogram, MSR_PLOT_ASYM == asymmetry, MSR_PLOT_MU_MINUS == mu minus (not yet implemented), MSR_PLOT_NON_MUSR == non-muSR
- Int_t fPlotNumber; ///< plot number
+ Bool_t fBatchMode; ///< musrview in ROOT batch mode
+ Bool_t fValid; ///< if true, everything looks OK
+ Bool_t fDifferenceView; ///< tag showing that the shown data, fourier, are the difference between data and theory
+ Int_t fCurrentPlotView; ///< tag showing what the current plot view is: data, fourier, ...
+ Int_t fPlotType; ///< plot type tag: -1 == undefined, MSR_PLOT_SINGLE_HISTO == single histogram, MSR_PLOT_ASYM == asymmetry, MSR_PLOT_MU_MINUS == mu minus (not yet implemented), MSR_PLOT_NON_MUSR == non-muSR
+ Int_t fPlotNumber; ///< plot number
+ UInt_t fPlotRangeTag; ///< plot range tag: 0=no range given, 1=range, 2=sub_ranges, 3=use_fit_ranges.
Double_t fXmin, fXmax, fYmin, fYmax; ///< data/theory frame range
@@ -252,7 +293,7 @@ class PMusrCanvas : public TObject, public TQObject
virtual void CleanupDataSet(PMusrCanvasNonMusrDataSet &dataSet);
virtual void HandleDataSet(UInt_t plotNo, UInt_t runNo, PRunData *data);
virtual void HandleNonMusrDataSet(UInt_t plotNo, UInt_t runNo, PRunData *data);
- virtual void HandleDifference();
+ virtual void HandleDifference(Bool_t unzoom=false);
virtual void HandleFourier();
virtual void HandleDifferenceFourier();
virtual void HandleFourierDifference();
diff --git a/src/include/PMusrCanvasLinkDef.h b/src/include/PMusrCanvasLinkDef.h
index 7099a9d6..90bebeeb 100644
--- a/src/include/PMusrCanvasLinkDef.h
+++ b/src/include/PMusrCanvasLinkDef.h
@@ -35,6 +35,7 @@
#pragma link off all classes;
#pragma link off all functions;
+#pragma link C++ class PMusrCanvasPlotRange+;
#pragma link C++ class PMusrCanvas+;
#endif