added some first features

This commit is contained in:
nemu 2008-04-02 07:24:32 +00:00
parent 1de245df8b
commit 62fd115a76
3 changed files with 224 additions and 30 deletions

View File

@ -92,12 +92,11 @@ cout << "fMainCanvas = " << fMainCanvas << endl;
}
fTitlePad->SetFillColor(TColor::GetColor(255,255,255));
fTitlePad->SetTextAlign(12); // middle, left
fTitlePad->AddText("This is a title, this is a title, this is a title, this is a title, ...");
fTitlePad->AddText(title);
fTitlePad->Draw();
// data/theory pad
fDataTheoryPad = new TPad("dataTheoryPad", "dataTheoryPad", 0.0, YINFO, XTHEO-0.02, YTITLE);
fDataTheoryPad = new TPad("dataTheoryPad", "dataTheoryPad", 0.0, YINFO, XTHEO, YTITLE);
fDataTheoryPad = new TPad("dataTheoryPad", "dataTheoryPad", 0.0, YINFO, XTHEO, YTITLE);
if (fDataTheoryPad == 0) {
cout << endl << "PMusrCanvas::PMusrCanvas: **PANIC ERROR**: Couldn't invoke fDataTheoryPad";
cout << endl;
@ -116,21 +115,6 @@ cout << "fMainCanvas = " << fMainCanvas << endl;
fParameterTheoryPad->SetFillColor(TColor::GetColor(255,255,255));
fParameterTheoryPad->SetTextAlign(13); // top, left
fParameterTheoryPad->SetTextFont(102); // courier bold, scalable so that greek parameters will be plotted properly
fParameterTheoryPad->AddText("parameter/theory pad ...");
fParameterTheoryPad->AddText("1 alphaLR 0.9157 0.01075");
fParameterTheoryPad->AddText("2 alphaTB 0.8777 0.007409");
fParameterTheoryPad->AddText("3 asyS 0.1555 0.004631");
fParameterTheoryPad->AddText("4 lambdaS 0.06726 0.01466");
fParameterTheoryPad->AddText("5 field 7.444 0.1995");
fParameterTheoryPad->AddText("6 phaseLR 18.3 4.1");
fParameterTheoryPad->AddText("7 phaseTB -83.1 2.1");
fParameterTheoryPad->AddText(" ");
fParameterTheoryPad->AddText("asymmetry 3");
fParameterTheoryPad->AddText("simplExpo 4 (#lambda)");
fParameterTheoryPad->AddText("TFieldCos map1 fun1 (#phi #nu)");
fParameterTheoryPad->AddText(" ");
fParameterTheoryPad->AddText("fun1 = par5 * 0.01355");
fParameterTheoryPad->Draw();
// info pad
fInfoPad = new TPaveText(0.0, 0.0, 1.0, YINFO, "NDC");
@ -257,3 +241,128 @@ void PMusrCanvas::HandleCmdKey(Int_t event, Int_t x, Int_t y, TObject *selected)
fMainCanvas->Update();
}
}
//--------------------------------------------------------------------------
// SetParameterList
//--------------------------------------------------------------------------
/**
* <p>
*
* \param paramList
*/
void PMusrCanvas::SetParameterList(PMsrParamList &paramList)
{
fParamList = paramList;
}
//--------------------------------------------------------------------------
// SetTheoryList
//--------------------------------------------------------------------------
/**
* <p>
*
* \param theoryList
*/
void PMusrCanvas::SetTheoryList(PMsrLines &theoryList)
{
fTheoryList = theoryList;
}
//--------------------------------------------------------------------------
// SetFunctionList
//--------------------------------------------------------------------------
/**
* <p>
*
* \param functionList
*/
void PMusrCanvas::SetFunctionList(PMsrLines &functionList)
{
fFunctionList = functionList;
}
//--------------------------------------------------------------------------
// UpdateParamTheoryPad
//--------------------------------------------------------------------------
/**
* <p>
*/
void PMusrCanvas::UpdateParamTheoryPad()
{
TString str;
char cnum[128];
int maxLength = 0;
Double_t ypos;
int idx;
// add parameters ------------------------------------------------------------
// get maximal parameter name string length
for (unsigned int i=0; i<fParamList.size(); i++) {
if (fParamList[i].fName.Length() > maxLength)
maxLength = fParamList[i].fName.Length();
}
maxLength += 2;
// add parameters to the pad
for (unsigned int i=0; i<fParamList.size(); i++) {
str = "";
// parameter no
str += fParamList[i].fNo;
if (fParamList[i].fNo<10)
str += " ";
else
str += " ";
// parameter name
str += fParamList[i].fName;
for (int j=0; j<maxLength-fParamList[i].fName.Length(); j++) // fill spaces
str += " ";
// parameter value
if (round(fParamList[i].fValue)-fParamList[i].fValue==0)
sprintf(cnum, "%.1lf", fParamList[i].fValue);
else
sprintf(cnum, "%.6lf", fParamList[i].fValue);
str += cnum;
for (int j=0; j<9-(int)strlen(cnum); j++) // fill spaces
str += " ";
str += " "; // to make sure that at least 1 space is placed
// parameter error
if (fParamList[i].fPosErrorPresent) { // minos was used
if (round(fParamList[i].fStep)-fParamList[i].fStep==0)
sprintf(cnum, "%.1lf", fParamList[i].fStep);
else
sprintf(cnum, "%.6lf", fParamList[i].fStep);
str += cnum;
str += "/";
if (round(fParamList[i].fPosError)-fParamList[i].fPosError==0)
sprintf(cnum, "%.1lf", fParamList[i].fPosError);
else
sprintf(cnum, "%.6lf", fParamList[i].fPosError);
str += cnum;
} else { // minos was not used
if (round(fParamList[i].fStep)-fParamList[i].fStep==0)
sprintf(cnum, "%.1lf", fParamList[i].fStep);
else
sprintf(cnum, "%.6lf", fParamList[i].fStep);
str += cnum;
}
ypos = 0.925-i*0.025;
fParameterTheoryPad->AddText(0.03, ypos, str.Data());
}
// add theory ------------------------------------------------------------
ypos -= 0.025;
for (unsigned int i=1; i<fTheoryList.size(); i++) {
// remove comment if present
str = fTheoryList[i].fLine;
idx = str.Index("(");
if (idx > 0) { // comment present
str.Resize(idx-1);
str.Resize(str.Strip().Length());
}
ypos -= 0.025;
fParameterTheoryPad->AddText(0.03, ypos, str.Data());
}
fParameterTheoryPad->Draw();
fMainCanvas->cd();
fMainCanvas->Update();
}

View File

@ -38,6 +38,8 @@
#include <TPaveText.h>
#include <TPad.h>
#include "PMusr.h"
#define YINFO 0.1
#define YTITLE 0.95
#define XTHEO 0.75
@ -55,6 +57,12 @@ class PMusrCanvas : public TObject, public TQObject
virtual Bool_t IsValid() { return fValid; }
virtual void SetParameterList(PMsrParamList &paramList);
virtual void SetTheoryList(PMsrLines &theoryList);
virtual void SetFunctionList(PMsrLines &functionList);
virtual void UpdateParamTheoryPad();
virtual void Done(Int_t status=0); // *SIGNAL*
virtual void HandleCmdKey(Int_t event, Int_t x, Int_t y, TObject *selected); // SLOT
@ -69,6 +77,10 @@ class PMusrCanvas : public TObject, public TQObject
TPaveText *fKeyboardHandlerText;
PMsrParamList fParamList;
PMsrLines fTheoryList;
PMsrLines fFunctionList;
ClassDef(PMusrCanvas, 1)
};

View File

@ -35,8 +35,13 @@ using namespace std;
#include <TApplication.h>
#include "PMusr.h"
#include "PStartupHandler.h"
#include "PMsrHandler.h"
#include "PRunDataHandler.h"
#include "PRunListCollection.h"
#include "PMusrCanvas.h"
//--------------------------------------------------------------------------
/**
* <p>
@ -56,6 +61,7 @@ void musrview_syntax()
int main(int argc, char *argv[])
{
bool show_syntax = false;
int status;
switch (argc) {
case 1:
@ -71,7 +77,7 @@ int main(int argc, char *argv[])
} else {
// check if filename has extension msr
if (!strstr(argv[1], ".msr")) {
cout << endl << "ERROR: " << argv[1] << " is not a msr-file!" << endl;
cout << endl << "**ERROR** " << argv[1] << " is not a msr-file!" << endl;
show_syntax = true;
}
}
@ -85,23 +91,90 @@ int main(int argc, char *argv[])
return PMUSR_WRONG_STARTUP_SYNTAX;
}
TApplication app("App", &argc, argv);
// read startup file
PStartupHandler *startupHandler = new PStartupHandler();
PMusrCanvas *musrCanvas = new PMusrCanvas("musr canvas dummy", 10, 10, 800, 600);
if (!musrCanvas->IsValid()) {
cout << endl << "**SEVERE ERROR** Couldn't invoke all necessary objects, will quit.";
cout << endl;
return -1;
// read msr-file
PMsrHandler *msrHandler = new PMsrHandler(argv[1]);
status = msrHandler->ReadMsrFile();
if (status != PMUSR_SUCCESS) {
switch (status) {
case PMUSR_MSR_FILE_NOT_FOUND:
cout << endl << "**ERROR** couldn't find '" << argv[1] << "'" << endl << endl;
break;
case PMUSR_MSR_SYNTAX_ERROR:
cout << endl << "**SYNTAX ERROR** in file " << argv[1] << ", full stop here." << endl << endl;
default:
cout << endl << "**UNKNOWN ERROR** when trying to read the msr-file" << endl << endl;
break;
}
return status;
}
musrCanvas->Connect("Done(Int_t)", "TApplication", &app, "Terminate(Int_t)");
// read all the necessary runs (raw data)
PRunDataHandler *dataHandler = new PRunDataHandler(msrHandler);
bool success = dataHandler->IsAllDataAvailable();
if (!success) {
cout << endl << "**ERROR** Couldn't read all data files, will quit ..." << endl;
}
app.Run();
// generate the necessary fit histogramms for the view
PRunListCollection *runListCollection = 0;
if (success) {
// feed all the necessary histogramms for the view
runListCollection = new PRunListCollection(msrHandler, dataHandler);
for (unsigned int i=0; i < msrHandler->GetMsrRunList()->size(); i++) {
success = runListCollection->Add(i);
if (!success) {
cout << endl << "**ERROR** Couldn't handle run no " << i << " ";
cout << (*msrHandler->GetMsrRunList())[i].fRunName.Data();
break;
}
}
}
if (success) {
// generate Root application needed for PMusrCanvas
TApplication app("App", &argc, argv);
PMusrCanvas *musrCanvas = new PMusrCanvas(msrHandler->GetMsrTitle()->Data(), 10, 10, 800, 600);
if (!musrCanvas->IsValid()) {
cout << endl << "**SEVERE ERROR** Couldn't invoke all necessary objects, will quit.";
cout << endl;
return -1;
}
musrCanvas->SetParameterList(*msrHandler->GetMsrParamList());
musrCanvas->SetTheoryList(*msrHandler->GetMsrTheory());
musrCanvas->SetFunctionList(*msrHandler->GetMsrFunctions());
musrCanvas->UpdateParamTheoryPad();
musrCanvas->Connect("Done(Int_t)", "TApplication", &app, "Terminate(Int_t)");
app.Run();
// clean up
if (musrCanvas) {
delete musrCanvas;
musrCanvas = 0;
}
}
// clean up
if (musrCanvas) {
delete musrCanvas;
musrCanvas = 0;
if (startupHandler) {
delete startupHandler;
startupHandler = 0;
}
if (msrHandler) {
delete msrHandler;
msrHandler = 0;
}
if (dataHandler) {
delete dataHandler;
dataHandler = 0;
}
if (runListCollection) {
delete runListCollection;
runListCollection = 0;
}
return 0;