fixed some 'uninitialized' stuff. Add canvas graphic dump feature, and fixed crash described in MUSR-53
This commit is contained in:
parent
addc2f5b91
commit
ea0800b4fe
@ -132,7 +132,7 @@ PMusrCanvas::PMusrCanvas(const int number, const char* title,
|
|||||||
*/
|
*/
|
||||||
PMusrCanvas::~PMusrCanvas()
|
PMusrCanvas::~PMusrCanvas()
|
||||||
{
|
{
|
||||||
cout << "~PMusrCanvas() called. fMainCanvas name=" << fMainCanvas->GetName() << endl;
|
//cout << "~PMusrCanvas() called. fMainCanvas name=" << fMainCanvas->GetName() << endl;
|
||||||
// cleanup
|
// cleanup
|
||||||
if (fStyle) {
|
if (fStyle) {
|
||||||
delete fStyle;
|
delete fStyle;
|
||||||
@ -180,10 +180,8 @@ cout << "~PMusrCanvas() called. fMainCanvas name=" << fMainCanvas->GetName() <<
|
|||||||
fMultiGraphDiff = 0;
|
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) {
|
||||||
@ -247,8 +245,8 @@ void PMusrCanvas::UpdateParamTheoryPad()
|
|||||||
TString str;
|
TString str;
|
||||||
char cnum[128];
|
char cnum[128];
|
||||||
int maxLength = 0;
|
int maxLength = 0;
|
||||||
Double_t ypos, yoffset;
|
Double_t ypos = 0.0, yoffset = 0.0;
|
||||||
int idx;
|
int idx = -1;
|
||||||
|
|
||||||
// add parameters ------------------------------------------------------------
|
// add parameters ------------------------------------------------------------
|
||||||
PMsrParamList param = *fMsrHandler->GetMsrParamList();
|
PMsrParamList param = *fMsrHandler->GetMsrParamList();
|
||||||
@ -344,6 +342,7 @@ void PMusrCanvas::UpdateParamTheoryPad()
|
|||||||
fTheoryPad->AddText(0.03, ypos, functions[i].fLine.Data());
|
fTheoryPad->AddText(0.03, ypos, functions[i].fLine.Data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fParameterPad->Draw();
|
fParameterPad->Draw();
|
||||||
fTheoryPad->Draw();
|
fTheoryPad->Draw();
|
||||||
fMainCanvas->cd();
|
fMainCanvas->cd();
|
||||||
@ -900,6 +899,52 @@ void PMusrCanvas::LastCanvasClosed()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------
|
||||||
|
// SaveGraphicsAndQuit
|
||||||
|
//--------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* \param graphicsFormat One of the supported graphics formats.
|
||||||
|
*/
|
||||||
|
void PMusrCanvas::SaveGraphicsAndQuit(char *fileName, char *graphicsFormat)
|
||||||
|
{
|
||||||
|
cout << endl << ">> SaveGraphicsAndQuit: will dump the canvas into a graphics output file (" << graphicsFormat << ") ..."<< endl;
|
||||||
|
|
||||||
|
TString str(fileName);
|
||||||
|
Int_t idx = -1;
|
||||||
|
Int_t size = 0;
|
||||||
|
char ext[32];
|
||||||
|
|
||||||
|
if (str.Contains(".msr")) {
|
||||||
|
idx = str.Index(".msr");
|
||||||
|
size = 4;
|
||||||
|
}
|
||||||
|
if (str.Contains(".mlog")) {
|
||||||
|
idx = str.Index(".mlog");
|
||||||
|
size = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (idx == -1) {
|
||||||
|
cout << endl << "PMusrCanvas::SaveGraphicsAndQuit **ERROR**: fileName (" << fileName << ") is invalid." << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf(ext, "_%d", fPlotNumber);
|
||||||
|
str.Replace(idx, size, ext, strlen(ext));
|
||||||
|
idx += strlen(ext);
|
||||||
|
size = strlen(ext);
|
||||||
|
sprintf(ext, ".%s", graphicsFormat);
|
||||||
|
str.Replace(idx, size, ext, strlen(ext));
|
||||||
|
|
||||||
|
cout << endl << ">> SaveGraphicsAndQuit: " << str.Data() << endl;
|
||||||
|
|
||||||
|
fMainCanvas->SaveAs(str.Data());
|
||||||
|
|
||||||
|
if (fPlotNumber == static_cast<int>(fMsrHandler->GetMsrPlotList()->size()) - 1)
|
||||||
|
Done(0);
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
// CreateStyle (private)
|
// CreateStyle (private)
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
@ -908,7 +953,9 @@ void PMusrCanvas::LastCanvasClosed()
|
|||||||
*/
|
*/
|
||||||
void PMusrCanvas::CreateStyle()
|
void PMusrCanvas::CreateStyle()
|
||||||
{
|
{
|
||||||
fStyle = new TStyle("musrStyle", "musrStyle");
|
TString musrStyle("musrStyle");
|
||||||
|
musrStyle += fPlotNumber;
|
||||||
|
fStyle = new TStyle(musrStyle, musrStyle);
|
||||||
fStyle->SetOptStat(0); // no statistics options
|
fStyle->SetOptStat(0); // no statistics options
|
||||||
fStyle->SetOptTitle(0); // no title
|
fStyle->SetOptTitle(0); // no title
|
||||||
fStyle->cd();
|
fStyle->cd();
|
||||||
@ -1073,6 +1120,7 @@ void PMusrCanvas::InitMusrCanvas(const char* title, Int_t wtopx, Int_t wtopy, In
|
|||||||
|
|
||||||
fMainCanvas->cd();
|
fMainCanvas->cd();
|
||||||
fMainCanvas->Show();
|
fMainCanvas->Show();
|
||||||
|
|
||||||
fMainCanvas->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", "PMusrCanvas",
|
fMainCanvas->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", "PMusrCanvas",
|
||||||
this, "HandleCmdKey(Int_t,Int_t,Int_t,TObject*)");
|
this, "HandleCmdKey(Int_t,Int_t,Int_t,TObject*)");
|
||||||
|
|
||||||
@ -1308,6 +1356,8 @@ void PMusrCanvas::HandleDataSet(unsigned int plotNo, unsigned int runNo, PRunDat
|
|||||||
// create histo specific infos
|
// create histo specific infos
|
||||||
name = fMsrHandler->GetMsrRunList()->at(runNo).fRunName[0] + "_DataRunNo";
|
name = fMsrHandler->GetMsrRunList()->at(runNo).fRunName[0] + "_DataRunNo";
|
||||||
name += (int)runNo;
|
name += (int)runNo;
|
||||||
|
name += "_";
|
||||||
|
name += fPlotNumber;
|
||||||
start = data->fDataTimeStart - data->fDataTimeStep/2.0;
|
start = data->fDataTimeStart - data->fDataTimeStep/2.0;
|
||||||
end = data->fDataTimeStart + data->fValue.size()*data->fDataTimeStep + data->fDataTimeStep/2.0;
|
end = data->fDataTimeStart + data->fValue.size()*data->fDataTimeStep + data->fDataTimeStep/2.0;
|
||||||
|
|
||||||
@ -1344,6 +1394,8 @@ void PMusrCanvas::HandleDataSet(unsigned int plotNo, unsigned int runNo, PRunDat
|
|||||||
// create histo specific infos
|
// create histo specific infos
|
||||||
name = fMsrHandler->GetMsrRunList()->at(runNo).fRunName[0] + "_TheoRunNo";
|
name = fMsrHandler->GetMsrRunList()->at(runNo).fRunName[0] + "_TheoRunNo";
|
||||||
name += (int)runNo;
|
name += (int)runNo;
|
||||||
|
name += "_";
|
||||||
|
name += fPlotNumber;
|
||||||
start = data->fTheoryTimeStart - data->fTheoryTimeStep/2.0;
|
start = data->fTheoryTimeStart - data->fTheoryTimeStep/2.0;
|
||||||
end = data->fTheoryTimeStart + data->fTheory.size()*data->fTheoryTimeStep + data->fTheoryTimeStep/2.0;
|
end = data->fTheoryTimeStart + data->fTheory.size()*data->fTheoryTimeStep + data->fTheoryTimeStep/2.0;
|
||||||
|
|
||||||
@ -1833,14 +1885,14 @@ cout << endl << ">> data scale = " << scale;
|
|||||||
*/
|
*/
|
||||||
double PMusrCanvas::FindOptimalFourierPhase()
|
double PMusrCanvas::FindOptimalFourierPhase()
|
||||||
{
|
{
|
||||||
cout << endl << ">> in FindOptimalFourierPhase ... ";
|
//cout << endl << ">> in FindOptimalFourierPhase ... ";
|
||||||
|
|
||||||
// check that Fourier is really present
|
// check that Fourier is really present
|
||||||
if ((fData[0].dataFourierRe == 0) || (fData[0].dataFourierIm == 0))
|
if ((fData[0].dataFourierRe == 0) || (fData[0].dataFourierIm == 0))
|
||||||
return 0.0;
|
return 0.0;
|
||||||
|
|
||||||
double minPhase, x, valIm, val_xMin, val_xMax;
|
Double_t minPhase, x, valIm, val_xMin = 0.0, val_xMax = 0.0;
|
||||||
double minIm, maxIm, asymmetry;
|
Double_t minIm = 0.0, maxIm = 0.0, asymmetry;
|
||||||
// get min/max of the imaginary part for phase = 0.0 as a starting point
|
// get min/max of the imaginary part for phase = 0.0 as a starting point
|
||||||
minPhase = 0.0;
|
minPhase = 0.0;
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
@ -324,7 +324,7 @@ void PMusrT0::InitDataAndBkg()
|
|||||||
|
|
||||||
// add lines
|
// add lines
|
||||||
// t0 line
|
// t0 line
|
||||||
int t0Bin;
|
Int_t t0Bin = 0;
|
||||||
switch (fDetectorTag) {
|
switch (fDetectorTag) {
|
||||||
case DETECTOR_TAG_FORWARD:
|
case DETECTOR_TAG_FORWARD:
|
||||||
t0Bin = fMsrHandler->GetMsrRunList()->at(fRunNo).fT0[0 + fAddRunNo * fAddRunOffset/2];
|
t0Bin = fMsrHandler->GetMsrRunList()->at(fRunNo).fT0[0 + fAddRunNo * fAddRunOffset/2];
|
||||||
|
@ -302,8 +302,8 @@ bool PRunNonMusr::PrepareViewData()
|
|||||||
// followed: the smallest x-interval found will be used to for the fXTheory resolution
|
// followed: the smallest x-interval found will be used to for the fXTheory resolution
|
||||||
// which is 1000 function points. The function will be calculated from the smallest
|
// which is 1000 function points. The function will be calculated from the smallest
|
||||||
// xmin found up to the largest xmax found.
|
// xmin found up to the largest xmax found.
|
||||||
double xMin, xMax;
|
Double_t xMin = 0.0, xMax = 0.0;
|
||||||
double xAbsMin, xAbsMax;
|
Double_t xAbsMin = 0.0, xAbsMax = 0.0;
|
||||||
bool first = true;
|
bool first = true;
|
||||||
// cout << endl << ">> plotList->size()=" << plotList->size();
|
// cout << endl << ">> plotList->size()=" << plotList->size();
|
||||||
for (unsigned int i=0; i<plotList->size(); i++) {
|
for (unsigned int i=0; i<plotList->size(); i++) {
|
||||||
|
@ -172,6 +172,8 @@ class PMusrCanvas : public TObject, public TQObject
|
|||||||
virtual void HandleMenuPopup(Int_t id); // SLOT
|
virtual void HandleMenuPopup(Int_t id); // SLOT
|
||||||
virtual void LastCanvasClosed(); // SLOT
|
virtual void LastCanvasClosed(); // SLOT
|
||||||
|
|
||||||
|
virtual void SaveGraphicsAndQuit(char *fileName, char *graphicsFormat);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Bool_t fValid;
|
Bool_t fValid;
|
||||||
Bool_t fDifferenceView; /// tag showing that the shown data, fourier, are the difference between data and theory
|
Bool_t fDifferenceView; /// tag showing that the shown data, fourier, are the difference between data and theory
|
||||||
|
@ -58,14 +58,13 @@ void musrview_syntax()
|
|||||||
cout << endl << "usage: musrview <msr-file> [--<graphic-format-extension>] | --version | --help";
|
cout << endl << "usage: musrview <msr-file> [--<graphic-format-extension>] | --version | --help";
|
||||||
cout << endl << " <msr-file>: msr/mlog input file";
|
cout << endl << " <msr-file>: msr/mlog input file";
|
||||||
cout << endl << " 'musrview <msr-file>' will execute musrview";
|
cout << endl << " 'musrview <msr-file>' will execute musrview";
|
||||||
cout << endl << ">> ----- NOT YET IMPLEMENTED ----- << ";
|
|
||||||
cout << endl << " --<graphic-format-extension>: ";
|
cout << endl << " --<graphic-format-extension>: ";
|
||||||
cout << endl << " will produce a graphics-output-file without starting a root session.";
|
cout << endl << " will produce a graphics-output-file without starting a root session.";
|
||||||
cout << endl << " the name is based on the <msr-file>, e.g. 3310.msr -> 3310.png";
|
cout << endl << " the name is based on the <msr-file>, e.g. 3310.msr -> 3310_0.png";
|
||||||
cout << endl << " supported graphic-format-extension:";
|
cout << endl << " supported graphic-format-extension:";
|
||||||
cout << endl << " eps, pdf, gif, jpg, png, svg, xpm, root";
|
cout << endl << " eps, pdf, gif, jpg, png, svg, xpm, root";
|
||||||
cout << endl << " example: musrview 3310.msr --png, will produce a file 3310.png";
|
cout << endl << " example: musrview 3310.msr --png, will produce a files 3310_X.png";
|
||||||
cout << endl << ">> ----- NOT YET IMPLEMENTED ----- << ";
|
cout << endl << " where 'X' stands for the plot number (starting form 0)";
|
||||||
cout << endl << " 'musrview' or 'musrview --help' will show this help";
|
cout << endl << " 'musrview' or 'musrview --help' will show this help";
|
||||||
cout << endl << " 'musrview --version' will print the musrview version";
|
cout << endl << " 'musrview --version' will print the musrview version";
|
||||||
cout << endl << endl;
|
cout << endl << endl;
|
||||||
@ -79,8 +78,10 @@ int main(int argc, char *argv[])
|
|||||||
bool success = true;
|
bool success = true;
|
||||||
char fileName[128];
|
char fileName[128];
|
||||||
bool graphicsOutput = false;
|
bool graphicsOutput = false;
|
||||||
char graphicsExtension[32];
|
char graphicsExtension[128];
|
||||||
|
|
||||||
|
|
||||||
|
// check input arguments
|
||||||
switch (argc) {
|
switch (argc) {
|
||||||
case 1:
|
case 1:
|
||||||
show_syntax = true;
|
show_syntax = true;
|
||||||
@ -291,6 +292,10 @@ cout << endl;
|
|||||||
|
|
||||||
musrCanvas->Connect("Done(Int_t)", "TApplication", &app, "Terminate(Int_t)");
|
musrCanvas->Connect("Done(Int_t)", "TApplication", &app, "Terminate(Int_t)");
|
||||||
|
|
||||||
|
if (graphicsOutput) {
|
||||||
|
musrCanvas->SaveGraphicsAndQuit(fileName, graphicsExtension);
|
||||||
|
}
|
||||||
|
|
||||||
// keep musrCanvas objects
|
// keep musrCanvas objects
|
||||||
canvasVector.push_back(musrCanvas);
|
canvasVector.push_back(musrCanvas);
|
||||||
}
|
}
|
||||||
@ -300,24 +305,24 @@ cout << endl;
|
|||||||
app.Run(true); // true needed that Run will return after quit so that cleanup works
|
app.Run(true); // true needed that Run will return after quit so that cleanup works
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
cout << endl << "clean up canvas vector ...";
|
//cout << endl << "clean up canvas vector ...";
|
||||||
char canvasName[32];
|
char canvasName[32];
|
||||||
for (unsigned int i=0; i<canvasVector.size(); i++) {
|
for (unsigned int i=0; i<canvasVector.size(); i++) {
|
||||||
// check if canvas is still there before calling the destructor **TO BE DONE**
|
// check if canvas is still there before calling the destructor **TO BE DONE**
|
||||||
sprintf(canvasName, "fMainCanvas%d", i);
|
sprintf(canvasName, "fMainCanvas%d", i);
|
||||||
cout << endl << ">> canvasName=" << canvasName << ", canvasVector[" << i << "]=" << canvasVector[i];
|
//cout << endl << ">> canvasName=" << canvasName << ", canvasVector[" << i << "]=" << canvasVector[i];
|
||||||
if (gROOT->GetListOfCanvases()->FindObject(canvasName) != 0) {
|
if (gROOT->GetListOfCanvases()->FindObject(canvasName) != 0) {
|
||||||
cout << endl << ">> canvasName=" << canvasName << ", found ...";
|
//cout << endl << ">> canvasName=" << canvasName << ", found ...";
|
||||||
cout << endl;
|
//cout << endl;
|
||||||
canvasVector[i]->~PMusrCanvas();
|
canvasVector[i]->~PMusrCanvas();
|
||||||
} else {
|
} else {
|
||||||
cout << endl << ">> canvasName=" << canvasName << ", NOT found ...";
|
//cout << endl << ">> canvasName=" << canvasName << ", NOT found ...";
|
||||||
cout << endl;
|
//cout << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
canvasVector.empty();
|
canvasVector.empty();
|
||||||
}
|
}
|
||||||
cout << endl;
|
//cout << endl;
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
plotList.clear();
|
plotList.clear();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user