introduced multigraph to handle overlapping ranges correctly. Still some problems with axis labels

This commit is contained in:
nemu
2009-02-18 08:02:33 +00:00
parent 84718ab60c
commit 2954242867
2 changed files with 66 additions and 21 deletions

View File

@ -70,6 +70,9 @@ PMusrCanvas::PMusrCanvas()
fParameterTheoryPad = 0; fParameterTheoryPad = 0;
fInfoPad = 0; fInfoPad = 0;
fMultiGraphData = 0;
fMultiGraphDiff = 0;
InitFourier(); InitFourier();
fCurrentFourierPhase = fFourier.fPhaseIncrement; fCurrentFourierPhase = fFourier.fPhaseIncrement;
@ -86,6 +89,9 @@ PMusrCanvas::PMusrCanvas(const int number, const char* title,
Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh) : Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh) :
fPlotNumber(number) fPlotNumber(number)
{ {
fMultiGraphData = 0;
fMultiGraphDiff = 0;
InitFourier(); InitFourier();
CreateStyle(); CreateStyle();
InitMusrCanvas(title, wtopx, wtopy, ww, wh); InitMusrCanvas(title, wtopx, wtopy, ww, wh);
@ -107,6 +113,9 @@ PMusrCanvas::PMusrCanvas(const int number, const char* title,
fPlotNumber(number), fFourier(fourierDefault), fPlotNumber(number), fFourier(fourierDefault),
fMarkerList(markerList), fColorList(colorList) fMarkerList(markerList), fColorList(colorList)
{ {
fMultiGraphData = 0;
fMultiGraphDiff = 0;
CreateStyle(); CreateStyle();
InitMusrCanvas(title, wtopx, wtopy, ww, wh); InitMusrCanvas(title, wtopx, wtopy, ww, wh);
@ -156,9 +165,19 @@ cout << "~PMusrCanvas() called. fMainCanvas name=" << fMainCanvas->GetName() <<
CleanupDataSet(fData[i]); CleanupDataSet(fData[i]);
fData.clear(); fData.clear();
} }
if (fMultiGraphData) {
delete fMultiGraphData;
fMultiGraphData = 0;
}
if (fMultiGraphDiff) {
delete fMultiGraphDiff;
fMultiGraphDiff = 0;
}
if (fNonMusrData.size() > 0) { if (fNonMusrData.size() > 0) {
/*
for (unsigned int i=0; i<fNonMusrData.size(); i++) for (unsigned int i=0; i<fNonMusrData.size(); i++)
CleanupDataSet(fNonMusrData[i]); CleanupDataSet(fNonMusrData[i]);
*/
fNonMusrData.clear(); fNonMusrData.clear();
} }
if (fCurrentFourierPhaseText) { if (fCurrentFourierPhaseText) {
@ -1456,6 +1475,7 @@ void PMusrCanvas::HandleDifference()
// set marker and line color // set marker and line color
diffHisto->SetMarkerColor(fNonMusrData[i].data->GetMarkerColor()); diffHisto->SetMarkerColor(fNonMusrData[i].data->GetMarkerColor());
diffHisto->SetLineColor(fNonMusrData[i].data->GetLineColor());
// set marker size // set marker size
diffHisto->SetMarkerSize(fNonMusrData[i].data->GetMarkerSize()); diffHisto->SetMarkerSize(fNonMusrData[i].data->GetMarkerSize());
// set marker type // set marker type
@ -2112,29 +2132,41 @@ void PMusrCanvas::PlotData()
TString yAxisTitle = fRunList->GetYAxisTitle(runs[runNo].fRunName); TString yAxisTitle = fRunList->GetYAxisTitle(runs[runNo].fRunName);
if (fNonMusrData.size() > 0) { if (fNonMusrData.size() > 0) {
fNonMusrData[0].data->Draw("ap"); // check if fMultiGraphData needs to be created, and if yes add all data and theory
if (!fMultiGraphData) {
fMultiGraphData = new TMultiGraph();
assert(fMultiGraphData != 0);
// add all data to fMultiGraphData
for (unsigned int i=0; i<fNonMusrData.size(); i++) {
fMultiGraphData->Add(fNonMusrData[i].data, "p");
}
// add all the theory to fMultiGraphData
for (unsigned int i=0; i<fNonMusrData.size(); i++) {
fMultiGraphData->Add(fNonMusrData[i].theory, "l");
}
}
fMultiGraphData->Draw("a");
// set x-range // set x-range
Double_t xmin = fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin; Double_t xmin = fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin;
Double_t xmax = fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmax; Double_t xmax = fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmax;
fNonMusrData[0].data->GetXaxis()->SetRangeUser(xmin, xmax); fMultiGraphData->GetXaxis()->SetRangeUser(xmin, xmax);
// check if it is necessary to set the y-axis range // check if it is necessary to set the y-axis range
Double_t ymin = fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fYmin; Double_t ymin = fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fYmin;
Double_t ymax = fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fYmax; Double_t ymax = fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fYmax;
if ((ymin != -999.0) && (ymax != -999.0)) { if ((ymin != -999.0) && (ymax != -999.0)) {
fNonMusrData[0].data->GetYaxis()->SetRangeUser(ymin, ymax); fMultiGraphData->GetYaxis()->SetRangeUser(ymin, ymax);
} else {
fMultiGraphData->GetYaxis()->UnZoom();
} }
// set x-axis label // set x-axis label
fNonMusrData[0].data->GetXaxis()->SetTitle(xAxisTitle.Data()); fMultiGraphData->GetXaxis()->SetTitle(xAxisTitle.Data());
// set y-axis label // set y-axis label
fNonMusrData[0].data->GetYaxis()->SetTitle(yAxisTitle.Data()); fMultiGraphData->GetYaxis()->SetTitle(yAxisTitle.Data());
// plot all remaining data
for (unsigned int i=1; i<fNonMusrData.size(); i++) { fMultiGraphData->Draw("a");
fNonMusrData[i].data->Draw("psame");
}
// plot all the theory
for (unsigned int i=0; i<fNonMusrData.size(); i++) {
fNonMusrData[i].theory->Draw("csame");
}
} }
} }
@ -2175,15 +2207,25 @@ void PMusrCanvas::PlotDifference()
unsigned int runNo = (unsigned int)plotInfo.fRuns[0].Re()-1; unsigned int runNo = (unsigned int)plotInfo.fRuns[0].Re()-1;
TString xAxisTitle = fRunList->GetXAxisTitle(runs[runNo].fRunName); TString xAxisTitle = fRunList->GetXAxisTitle(runs[runNo].fRunName);
fNonMusrData[0].diff->Draw("ap"); // if fMultiGraphDiff is not present create it and add the diff data
// set x-axis label if (!fMultiGraphDiff) {
fNonMusrData[0].diff->GetXaxis()->SetTitle(xAxisTitle.Data()); fMultiGraphDiff = new TMultiGraph();
// set y-axis label assert(fMultiGraphDiff != 0);
fNonMusrData[0].diff->GetYaxis()->SetTitle("data-theory");
// plot all remaining diff data // add all diff data to fMultiGraphDiff
for (unsigned int i=1; i<fNonMusrData.size(); i++) { for (unsigned int i=0; i<fNonMusrData.size(); i++) {
fNonMusrData[i].diff->Draw("psame"); fMultiGraphDiff->Add(fNonMusrData[i].diff, "p");
}
} }
fMultiGraphDiff->Draw("a");
// set x-axis label
fMultiGraphDiff->GetXaxis()->SetTitle(xAxisTitle.Data());
// set y-axis label
fMultiGraphDiff->GetYaxis()->SetTitle("data-theory");
fMultiGraphDiff->Draw("a");
} }
fDataTheoryPad->Update(); fDataTheoryPad->Update();

View File

@ -43,6 +43,7 @@
#include <TPad.h> #include <TPad.h>
#include <TH1F.h> #include <TH1F.h>
#include <TGraphErrors.h> #include <TGraphErrors.h>
#include <TMultiGraph.h>
#include <TLatex.h> #include <TLatex.h>
#include "PMusr.h" #include "PMusr.h"
@ -204,6 +205,8 @@ class PMusrCanvas : public TObject, public TQObject
PMusrCanvasDataList fData; PMusrCanvasDataList fData;
PMusrCanvasNonMusrDataList fNonMusrData; PMusrCanvasNonMusrDataList fNonMusrData;
TMultiGraph *fMultiGraphData;
TMultiGraph *fMultiGraphDiff;
PMsrFourierStructure fFourier; PMsrFourierStructure fFourier;
PIntVector fMarkerList; PIntVector fMarkerList;