some even more flexible startup handler scheme

This commit is contained in:
nemu 2008-04-08 11:35:36 +00:00
parent 5d363ce953
commit 676043cb81
7 changed files with 121 additions and 60 deletions

View File

@ -46,9 +46,7 @@ short term:
* at the moment that startup handler is looked for in the directory where musrfit/musrview * at the moment that startup handler is looked for in the directory where musrfit/musrview
is executed, this is stupid. Define a place where to look for it. is executed, this is stupid. Define a place where to look for it.
**DONE** 08-04-08
* check concept to get bin data for musrview on single histo (fBinData in PRunBase).
If it is ok, implement it for the others.
* do I need to cleanup AddText() objects from TPaveText etc myself? **CHECK** * do I need to cleanup AddText() objects from TPaveText etc myself? **CHECK**

View File

@ -57,6 +57,19 @@ PMusrCanvas::PMusrCanvas()
fKeyboardHandlerText = 0; fKeyboardHandlerText = 0;
} }
//--------------------------------------------------------------------------
// Constructor
//--------------------------------------------------------------------------
/**
*
*/
PMusrCanvas::PMusrCanvas(const int number, const char* title,
Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh) :
fPlotNumber(number)
{
InitMusrCanvas(title, wtopx, wtopy, ww, wh);
}
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// Constructor // Constructor
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
@ -67,6 +80,59 @@ 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,
const PIntVector markerList, const PIntVector colorList) : const PIntVector markerList, const PIntVector colorList) :
fPlotNumber(number), fMarkerList(markerList), fColorList(colorList) fPlotNumber(number), fMarkerList(markerList), fColorList(colorList)
{
InitMusrCanvas(title, wtopx, wtopy, ww, wh);
}
//--------------------------------------------------------------------------
// Destructor
//--------------------------------------------------------------------------
/**
*
*/
PMusrCanvas::~PMusrCanvas()
{
cout << "~PMusrCanvas() called" << endl;
// cleanup
if (fKeyboardHandlerText) {
delete fKeyboardHandlerText;
fKeyboardHandlerText = 0;
}
if (fTitlePad) {
delete fTitlePad;
fTitlePad = 0;
}
if (fDataTheoryPad) {
delete fDataTheoryPad;
fDataTheoryPad = 0;
}
if (fParameterTheoryPad) {
delete fParameterTheoryPad;
fParameterTheoryPad = 0;
}
if (fInfoPad) {
delete fInfoPad;
fInfoPad = 0;
}
if (fMainCanvas) {
delete fMainCanvas;
fMainCanvas = 0;
}
}
//--------------------------------------------------------------------------
// InitMusrCanvas
//--------------------------------------------------------------------------
/**
* <p>
*
* \param title
* \param wtopx
* \param wtopy
* \param ww
* \param wh
*/
void PMusrCanvas::InitMusrCanvas(const char* title, Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh)
{ {
fValid = false; fValid = false;
@ -158,43 +224,6 @@ cout << canvasName.Data() << " = " << fMainCanvas << endl;
// cout << "fParameterTheoryPad " << fParameterTheoryPad << endl; // cout << "fParameterTheoryPad " << fParameterTheoryPad << endl;
// cout << "fInfoPad " << fInfoPad << endl; // cout << "fInfoPad " << fInfoPad << endl;
// cout << "fKeyboardHandlerText " << fKeyboardHandlerText << endl; // cout << "fKeyboardHandlerText " << fKeyboardHandlerText << endl;
}
//--------------------------------------------------------------------------
// Destructor
//--------------------------------------------------------------------------
/**
*
*/
PMusrCanvas::~PMusrCanvas()
{
cout << "~PMusrCanvas() called" << endl;
// cleanup
if (fKeyboardHandlerText) {
delete fKeyboardHandlerText;
fKeyboardHandlerText = 0;
}
if (fTitlePad) {
delete fTitlePad;
fTitlePad = 0;
}
if (fDataTheoryPad) {
delete fDataTheoryPad;
fDataTheoryPad = 0;
}
if (fParameterTheoryPad) {
delete fParameterTheoryPad;
fParameterTheoryPad = 0;
}
if (fInfoPad) {
delete fInfoPad;
fInfoPad = 0;
}
if (fMainCanvas) {
delete fMainCanvas;
fMainCanvas = 0;
}
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------

View File

@ -52,11 +52,28 @@ using namespace std;
* <p> * <p>
* *
*/ */
PRunDataHandler::PRunDataHandler(PMsrHandler *msrInfo, const PStringVector dataPath) : fDataPath(dataPath) PRunDataHandler::PRunDataHandler(PMsrHandler *msrInfo) : fMsrInfo(msrInfo)
{ {
// cout << endl << "in PRunDataHandler::PRunDataHandler()"; // cout << endl << "in PRunDataHandler::PRunDataHandler()";
fMsrInfo = msrInfo; // read files
if (!ReadFile()) // couldn't read file
fAllDataAvailable = false;
else
fAllDataAvailable = true;
}
//--------------------------------------------------------------------------
// Constructor
//--------------------------------------------------------------------------
/**
* <p>
*
*/
PRunDataHandler::PRunDataHandler(PMsrHandler *msrInfo, const PStringVector dataPath) :
fMsrInfo(msrInfo), fDataPath(dataPath)
{
// cout << endl << "in PRunDataHandler::PRunDataHandler()";
// read files // read files
if (!ReadFile()) // couldn't read file if (!ReadFile()) // couldn't read file

View File

@ -87,6 +87,8 @@ class PMusrCanvas : public TObject, public TQObject
{ {
public: public:
PMusrCanvas(); PMusrCanvas();
PMusrCanvas(const int number, const char* title,
Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh);
PMusrCanvas(const int number, const char* title, 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,
const PIntVector markerList, const PIntVector colorList); const PIntVector markerList, const PIntVector colorList);
@ -128,6 +130,7 @@ class PMusrCanvas : public TObject, public TQObject
PIntVector fMarkerList; PIntVector fMarkerList;
PIntVector fColorList; PIntVector fColorList;
virtual void InitMusrCanvas(const char* title, Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh);
virtual void InitDataSet(PMusrCanvasDataSet &dataSet); virtual void InitDataSet(PMusrCanvasDataSet &dataSet);
virtual void CleanupDataSet(PMusrCanvasDataSet &dataSet); virtual void CleanupDataSet(PMusrCanvasDataSet &dataSet);
virtual void HandleSingleHistoDataSet(unsigned int runNo, PRunData *data); virtual void HandleSingleHistoDataSet(unsigned int runNo, PRunData *data);

View File

@ -43,6 +43,7 @@ using namespace std;
class PRunDataHandler class PRunDataHandler
{ {
public: public:
PRunDataHandler(PMsrHandler *msrInfo);
PRunDataHandler(PMsrHandler *msrInfo, const PStringVector dataPath); PRunDataHandler(PMsrHandler *msrInfo, const PStringVector dataPath);
virtual ~PRunDataHandler(); virtual ~PRunDataHandler();

View File

@ -527,7 +527,7 @@ int main(int argc, char *argv[])
status = saxParser->ParseFile(startup_path_name); status = saxParser->ParseFile(startup_path_name);
// check for parse errors // check for parse errors
if (status) { // error if (status) { // error
cout << endl << "**ERROR** reading/parsing musrfit_startup.xml. Fix it."; cout << endl << "**WARNING** reading/parsing musrfit_startup.xml.";
cout << endl; cout << endl;
// clean up // clean up
if (saxParser) { if (saxParser) {
@ -538,7 +538,6 @@ int main(int argc, char *argv[])
delete startupHandler; delete startupHandler;
startupHandler = 0; startupHandler = 0;
} }
return PMUSR_WRONG_STARTUP_SYNTAX;
} }
// read msr-file // read msr-file
@ -547,12 +546,12 @@ int main(int argc, char *argv[])
if (status != PMUSR_SUCCESS) { if (status != PMUSR_SUCCESS) {
switch (status) { switch (status) {
case PMUSR_MSR_FILE_NOT_FOUND: case PMUSR_MSR_FILE_NOT_FOUND:
cout << endl << "couldn't find " << argv[1] << endl << endl; cout << endl << "**ERROR** couldn't find " << argv[1] << endl << endl;
break; break;
case PMUSR_MSR_SYNTAX_ERROR: case PMUSR_MSR_SYNTAX_ERROR:
cout << endl << "syntax error in file " << argv[1] << ", full stop here." << endl << endl; cout << endl << "**SYNTAX ERROR** in file " << argv[1] << ", full stop here." << endl << endl;
default: default:
cout << endl << "unkown error when trying to read the msr-file" << endl << endl; cout << endl << "**UNKOWN ERROR** when trying to read the msr-file" << endl << endl;
break; break;
} }
return status; return status;
@ -562,10 +561,15 @@ int main(int argc, char *argv[])
musrfit_debug_info(msrHandler); musrfit_debug_info(msrHandler);
// read all the necessary runs (raw data) // read all the necessary runs (raw data)
PRunDataHandler *dataHandler = new PRunDataHandler(msrHandler, startupHandler->GetDataPathList()); PRunDataHandler *dataHandler;
if (startupHandler)
dataHandler = new PRunDataHandler(msrHandler, startupHandler->GetDataPathList());
else
dataHandler = new PRunDataHandler(msrHandler);
bool success = dataHandler->IsAllDataAvailable(); bool success = dataHandler->IsAllDataAvailable();
if (!success) { if (!success) {
cout << endl << "Couldn't read all data files, will quit ..." << endl; cout << endl << "**ERROR** Couldn't read all data files, will quit ..." << endl;
} }
// generate the necessary fit histogramms for the fit // generate the necessary fit histogramms for the fit
@ -576,7 +580,7 @@ int main(int argc, char *argv[])
for (unsigned int i=0; i < msrHandler->GetMsrRunList()->size(); i++) { for (unsigned int i=0; i < msrHandler->GetMsrRunList()->size(); i++) {
success = runListCollection->Add(i, kFit); success = runListCollection->Add(i, kFit);
if (!success) { if (!success) {
cout << endl << "Couldn't handle run no " << i << " "; cout << endl << "**ERROR** Couldn't handle run no " << i << " ";
cout << (*msrHandler->GetMsrRunList())[i].fRunName.Data(); cout << (*msrHandler->GetMsrRunList())[i].fRunName.Data();
break; break;
} }
@ -598,13 +602,13 @@ int main(int argc, char *argv[])
if (status != PMUSR_SUCCESS) { if (status != PMUSR_SUCCESS) {
switch (status) { switch (status) {
case PMUSR_MSR_LOG_FILE_WRITE_ERROR: case PMUSR_MSR_LOG_FILE_WRITE_ERROR:
cout << endl << "couldn't write mlog-file" << endl << endl; cout << endl << "**ERROR** couldn't write mlog-file" << endl << endl;
break; break;
case PMUSR_TOKENIZE_ERROR: case PMUSR_TOKENIZE_ERROR:
cout << endl << "couldn't generate mlog-file name" << endl << endl; cout << endl << "**ERROR** couldn't generate mlog-file name" << endl << endl;
break; break;
default: default:
cout << endl << "unkown error when trying to write the mlog-file" << endl << endl; cout << endl << "**UNKOWN ERROR** when trying to write the mlog-file" << endl << endl;
break; break;
} }
} }

View File

@ -117,7 +117,7 @@ int main(int argc, char *argv[])
status = saxParser->ParseFile(startup_path_name); status = saxParser->ParseFile(startup_path_name);
// check for parse errors // check for parse errors
if (status) { // error if (status) { // error
cout << endl << "**ERROR** reading/parsing musrfit_startup.xml. Fix it."; cout << endl << "**WARNING** reading/parsing musrfit_startup.xml.";
cout << endl; cout << endl;
// clean up // clean up
if (saxParser) { if (saxParser) {
@ -128,7 +128,6 @@ int main(int argc, char *argv[])
delete startupHandler; delete startupHandler;
startupHandler = 0; startupHandler = 0;
} }
return PMUSR_WRONG_STARTUP_SYNTAX;
} }
// read msr-file // read msr-file
@ -149,7 +148,12 @@ int main(int argc, char *argv[])
} }
// read all the necessary runs (raw data) // read all the necessary runs (raw data)
PRunDataHandler *dataHandler = new PRunDataHandler(msrHandler, startupHandler->GetDataPathList()); PRunDataHandler *dataHandler;
if (startupHandler)
dataHandler = new PRunDataHandler(msrHandler, startupHandler->GetDataPathList());
else
dataHandler = new PRunDataHandler(msrHandler);
success = dataHandler->IsAllDataAvailable(); success = dataHandler->IsAllDataAvailable();
if (!success) { if (!success) {
cout << endl << "**ERROR** Couldn't read all data files, will quit ..." << endl; cout << endl << "**ERROR** Couldn't read all data files, will quit ..." << endl;
@ -180,10 +184,15 @@ int main(int argc, char *argv[])
bool ok = true; bool ok = true;
for (unsigned int i=0; i<msrHandler->GetMsrPlotList()->size(); i++) { for (unsigned int i=0; i<msrHandler->GetMsrPlotList()->size(); i++) {
musrCanvas = new PMusrCanvas(i, msrHandler->GetMsrTitle()->Data(), if (startupHandler)
10+i*100, 10+i*100, 800, 600, musrCanvas = new PMusrCanvas(i, msrHandler->GetMsrTitle()->Data(),
startupHandler->GetMarkerList(), 10+i*100, 10+i*100, 800, 600,
startupHandler->GetColorList()); startupHandler->GetMarkerList(),
startupHandler->GetColorList());
else
musrCanvas = new PMusrCanvas(i, msrHandler->GetMsrTitle()->Data(),
10+i*100, 10+i*100, 800, 600);
if (!musrCanvas->IsValid()) { if (!musrCanvas->IsValid()) {
cout << endl << "**SEVERE ERROR** Couldn't invoke all necessary objects, will quit."; cout << endl << "**SEVERE ERROR** Couldn't invoke all necessary objects, will quit.";
cout << endl; cout << endl;