some improvements for non-musr type handling

This commit is contained in:
nemu 2009-05-04 11:52:34 +00:00
parent 86bc9a28ac
commit 2012c537e8
6 changed files with 101 additions and 47 deletions

View File

@ -70,6 +70,7 @@ PMusrCanvas::PMusrCanvas()
fParameterPad = 0;
fTheoryPad = 0;
fInfoPad = 0;
fMultiGraphLegend = 0;
fMultiGraphData = 0;
fMultiGraphDiff = 0;
@ -143,6 +144,28 @@ PMusrCanvas::~PMusrCanvas()
delete fTitlePad;
fTitlePad = 0;
}
if (fData.size() > 0) {
for (unsigned int i=0; i<fData.size(); i++)
CleanupDataSet(fData[i]);
fData.clear();
}
if (fNonMusrData.size() > 0) {
for (unsigned int i=0; i<fNonMusrData.size(); i++)
CleanupDataSet(fNonMusrData[i]);
fNonMusrData.clear();
}
if (fMultiGraphData) {
delete fMultiGraphData;
fMultiGraphData = 0;
}
if (fMultiGraphDiff) {
delete fMultiGraphDiff;
fMultiGraphDiff = 0;
}
if (fCurrentFourierPhaseText) {
delete fCurrentFourierPhaseText;
fCurrentFourierPhaseText = 0;
}
if (fDataTheoryPad) {
delete fDataTheoryPad;
fDataTheoryPad = 0;
@ -162,32 +185,15 @@ PMusrCanvas::~PMusrCanvas()
delete fInfoPad;
fInfoPad = 0;
}
if (fMultiGraphLegend) {
fMultiGraphLegend->Clear();
delete fMultiGraphLegend;
fMultiGraphLegend = 0;
}
if (fMainCanvas) {
delete fMainCanvas;
fMainCanvas = 0;
}
if (fData.size() > 0) {
for (unsigned int i=0; i<fData.size(); i++)
CleanupDataSet(fData[i]);
fData.clear();
}
if (fMultiGraphData) {
delete fMultiGraphData;
fMultiGraphData = 0;
}
if (fMultiGraphDiff) {
delete fMultiGraphDiff;
fMultiGraphDiff = 0;
}
if (fNonMusrData.size() > 0) {
for (unsigned int i=0; i<fNonMusrData.size(); i++)
CleanupDataSet(fNonMusrData[i]);
fNonMusrData.clear();
}
if (fCurrentFourierPhaseText) {
delete fCurrentFourierPhaseText;
fCurrentFourierPhaseText = 0;
}
}
//--------------------------------------------------------------------------
@ -1013,6 +1019,7 @@ void PMusrCanvas::InitMusrCanvas(const char* title, Int_t wtopx, Int_t wtopy, In
fParameterPad = 0;
fTheoryPad = 0;
fInfoPad = 0;
fMultiGraphLegend = 0;
// invoke canvas
TString canvasName = TString("fMainCanvas");
@ -2265,12 +2272,36 @@ void PMusrCanvas::PlotData()
} else {
fMultiGraphData->GetYaxis()->UnZoom();
}
// set x-axis label
fMultiGraphData->GetXaxis()->SetTitle(xAxisTitle.Data());
// set y-axis label
fMultiGraphData->GetYaxis()->SetTitle(yAxisTitle.Data());
// set x-, y-axis label only if there is just one data set
if (fNonMusrData.size() == 1) {
// set x-axis label
fMultiGraphData->GetXaxis()->SetTitle(xAxisTitle.Data());
// set y-axis label
fMultiGraphData->GetYaxis()->SetTitle(yAxisTitle.Data());
} else { // more than one data set present, hence add a legend
if (fMultiGraphLegend) {
delete fMultiGraphLegend;
}
fMultiGraphLegend = new TLegend(0.8, 0.8, 1.0, 1.0);
assert(fMultiGraphLegend != 0);
PStringVector legendLabel;
for (unsigned int i=0; i<plotInfo.fRuns.size(); i++) {
runNo = (unsigned int)plotInfo.fRuns[i].Re()-1;
xAxisTitle = fRunList->GetXAxisTitle(runs[runNo].fRunName[0], runNo);
yAxisTitle = fRunList->GetYAxisTitle(runs[runNo].fRunName[0], runNo);
legendLabel.push_back(xAxisTitle + " vs. " + yAxisTitle);
}
for (unsigned int i=0; i<fNonMusrData.size(); i++) {
fMultiGraphLegend->AddEntry(fNonMusrData[i].data, legendLabel[i].Data(), "p");
}
legendLabel.clear();
}
fMultiGraphData->Draw("a");
if (fMultiGraphLegend)
fMultiGraphLegend->Draw();
}
}

View File

@ -935,7 +935,7 @@ bool PRunDataHandler::ReadAsciiFile()
// open file
ifstream f;
// open dump-file
// open data-file
f.open(fRunPathName.Data(), ifstream::in);
if (!f.is_open()) {
cout << endl << "PRunDataHandler::ReadAsciiFile **ERROR** Couldn't open data file (" << fRunPathName.Data() << ") for reading, sorry ...";
@ -946,8 +946,7 @@ bool PRunDataHandler::ReadAsciiFile()
PRawRunData runData;
// init some stuff
runData.fDataNonMusr.fXIndex = 0;
runData.fDataNonMusr.fYIndex = 1;
runData.fDataNonMusr.fFromAscii = true;
runData.fDataNonMusr.fLabels.push_back("??"); // x default label
runData.fDataNonMusr.fLabels.push_back("??"); // y default label
@ -1253,8 +1252,7 @@ bool PRunDataHandler::ReadDBFile()
PRawRunData runData;
runData.fDataNonMusr.fXIndex = -1;
runData.fDataNonMusr.fYIndex = -1;
runData.fDataNonMusr.fFromAscii = false;
int lineNo = 0;
int idx;

View File

@ -489,14 +489,27 @@ const char* PRunListCollection::GetSetup(TString &runName)
*/
const char* PRunListCollection::GetXAxisTitle(TString &runName, const unsigned int idx)
{
//cout << endl << ">> PRunListCollection::GetXAxisTitle: runName = " << runName.Data() << ", idx = " << idx;
//cout << endl << ">> PRunListCollection::GetXAxisTitle: fRunNonMusrList.size() = " << fRunNonMusrList.size();
//cout << endl;
PRawRunData *runData = fData->GetRunData(runName);
int index = fRunNonMusrList[idx]->GetXIndex();
const char *result = 0;
// cout << endl << ">>PRunListCollection::GetXAxisTitle, x-index = " << index;
// cout << endl;
if (runData->fDataNonMusr.fFromAscii) {
result = runData->fDataNonMusr.fLabels[0].Data();
} else {
for (unsigned int i=0; i<fRunNonMusrList.size(); i++) {
if (fRunNonMusrList[i]->GetRunNo() == idx) {
int index = fRunNonMusrList[i]->GetXIndex();
result = runData->fDataNonMusr.fLabels[index].Data();
break;
}
}
}
return runData->fDataNonMusr.fLabels[index].Data();
return result;
}
//--------------------------------------------------------------------------
@ -510,13 +523,25 @@ const char* PRunListCollection::GetXAxisTitle(TString &runName, const unsigned i
*/
const char* PRunListCollection::GetYAxisTitle(TString &runName, const unsigned int idx)
{
//cout << endl << ">> PRunListCollection::GetYAxisTitle: runName = " << runName.Data() << ", idx = " << idx;
//cout << endl;
PRawRunData *runData = fData->GetRunData(runName);
int index = fRunNonMusrList[idx]->GetYIndex();
const char *result = 0;
// cout << endl << ">>PRunListCollection::GetYAxisTitle, y-index = " << index;
// cout << endl;
if (runData->fDataNonMusr.fFromAscii) {
result = runData->fDataNonMusr.fLabels[1].Data();
} else {
for (unsigned int i=0; i<fRunNonMusrList.size(); i++) {
if (fRunNonMusrList[i]->GetRunNo() == idx) {
int index = fRunNonMusrList[i]->GetYIndex();
result = runData->fDataNonMusr.fLabels[index].Data();
break;
}
}
}
return runData->fDataNonMusr.fLabels[index].Data();
return result;
}

View File

@ -155,7 +155,7 @@ bool PRunNonMusr::PrepareData()
{
bool success = true;
cout << endl << "in PRunNonMusr::PrepareData(): will feed fFitData";
//cout << endl << "in PRunNonMusr::PrepareData(): will feed fFitData";
if (fRunInfo->fRunName.size() > 1) { // ADDRUN present which is not supported for NonMusr
cout << endl << ">> PRunNonMusr::PrepareData(): **WARNING** ADDRUN NOT SUPPORTED FOR THIS FIT TYPE, WILL IGNORE IT." << endl;
@ -374,10 +374,10 @@ unsigned int PRunNonMusr::GetXIndex()
unsigned int index = 0;
bool found = false;
//cout << endl << ">> PRunNonMusr::GetXIndex: fRawRunData->fDataNonMusr.fXIndex = " << fRawRunData->fDataNonMusr.fXIndex;
if (fRawRunData->fDataNonMusr.fXIndex >= 0) { // ascii-file format
//cout << endl << ">> PRunNonMusr::GetXIndex: fRawRunData->fDataNonMusr.fFromAscii = " << fRawRunData->fDataNonMusr.fFromAscii;
if (fRawRunData->fDataNonMusr.fFromAscii) { // ascii-file format
//cout << endl << ">> PRunNonMusr::GetXIndex: ascii-file format";
index = fRawRunData->fDataNonMusr.fXIndex;
index = 0;
found = true;
} else { // db-file format
//cout << endl << ">> PRunNonMusr::GetXIndex: db-file format";
@ -421,8 +421,8 @@ unsigned int PRunNonMusr::GetYIndex()
bool found = false;
// cout << endl << ">> PRunNonMusr::GetYIndex:";
if (fRawRunData->fDataNonMusr.fYIndex >= 0) { // ascii-file format
index = fRawRunData->fDataNonMusr.fYIndex;
if (fRawRunData->fDataNonMusr.fFromAscii) { // ascii-file format
index = 1;
found = true;
} else { // db-file format
if (fRunInfo->fXYDataIndex[1] > 0) { // xy-data already indices

View File

@ -166,8 +166,7 @@ typedef struct {
* <p>
*/
typedef struct {
int fXIndex; ///< index for the x-data vector
int fYIndex; ///< index for the y-data vector
bool fFromAscii; ///< if true: data file was an ascii input file, otherwise it is a db input file
PStringVector fLabels; ///< vector of all labels (used for x-, y-axis title in view)
PStringVector fDataTags; ///< vector of all data tags
vector<PDoubleVector> fData; ///< vector of all data

View File

@ -200,6 +200,7 @@ class PMusrCanvas : public TObject, public TQObject
TPaveText *fParameterPad;
TPaveText *fTheoryPad;
TLegend *fInfoPad;
TLegend *fMultiGraphLegend;
#ifndef __MAKECINT__
PMsrHandler *fMsrHandler;