implmented some startup features

This commit is contained in:
nemu 2008-04-03 13:10:49 +00:00
parent 5fc7e14f3f
commit 0652495a3f
13 changed files with 101 additions and 24 deletions

View File

@ -118,6 +118,7 @@ bool PFitter::DoFit()
SetParameters(); SetParameters();
bool status; bool status;
bool minosUsed = false;
for (unsigned int i=0; i<fCmdList.size(); i++) { for (unsigned int i=0; i<fCmdList.size(); i++) {
switch (fCmdList[i]) { switch (fCmdList[i]) {
case PMN_INTERACTIVE: case PMN_INTERACTIVE:
@ -148,6 +149,7 @@ bool PFitter::DoFit()
break; break;
case PMN_MINOS: case PMN_MINOS:
status = ExecuteMinos(); status = ExecuteMinos();
minosUsed = true;
break; break;
case PMN_PLOT: case PMN_PLOT:
cout << endl << "**WARNING** from PFitter::DoFit() : the command PLOT is not yet implemented."; cout << endl << "**WARNING** from PFitter::DoFit() : the command PLOT is not yet implemented.";
@ -180,6 +182,13 @@ bool PFitter::DoFit()
} }
} }
// if minos was not used, there are NO valid positive errors
if (!minosUsed) {
for (unsigned int i=0; i<fParams.size(); i++) {
fRunInfo->SetMsrParamPosErrorPresent(i, false);
}
}
return true; return true;
} }

View File

@ -683,6 +683,28 @@ bool PMsrHandler::SetMsrParamStep(unsigned int i, double value)
return true; return true;
} }
//--------------------------------------------------------------------------
// SetMsrParamPosErrorPresent (public)
//--------------------------------------------------------------------------
/**
* <p>
*
* \param i
* \param value
*/
bool PMsrHandler::SetMsrParamPosErrorPresent(unsigned int i, bool value)
{
if (i > fParam.size()) {
cout << endl << "PMsrHandler::SetMsrParamPosErrorPresent(): i = " << i << " is larger than the number of parameters " << fParam.size();
cout << endl;
return false;
}
fParam[i].fPosErrorPresent = value;
return true;
}
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// SetMsrParamPosError (public) // SetMsrParamPosError (public)
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------

View File

@ -62,7 +62,9 @@ PMusrCanvas::PMusrCanvas()
/** /**
* *
*/ */
PMusrCanvas::PMusrCanvas(const char* title, Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh) PMusrCanvas::PMusrCanvas(const char* title, Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh,
const PIntVector markerList, const PIntVector colorList) :
fMarkerList(markerList), fColorList(colorList)
{ {
fValid = false; fValid = false;

View File

@ -52,7 +52,7 @@ using namespace std;
* <p> * <p>
* *
*/ */
PRunDataHandler::PRunDataHandler(PMsrHandler *msrInfo) PRunDataHandler::PRunDataHandler(PMsrHandler *msrInfo, const PStringVector dataPath) : fDataPath(dataPath)
{ {
// cout << endl << "in PRunDataHandler::PRunDataHandler()"; // cout << endl << "in PRunDataHandler::PRunDataHandler()";
@ -63,6 +63,10 @@ PRunDataHandler::PRunDataHandler(PMsrHandler *msrInfo)
fAllDataAvailable = false; fAllDataAvailable = false;
else else
fAllDataAvailable = true; fAllDataAvailable = true;
/*for (unsigned int i=0; i<fDataPath.size(); i++)
cout << endl << i << ": " << fDataPath[i].Data();
cout << endl;*/
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
@ -236,18 +240,26 @@ bool PRunDataHandler::FileExistsCheck(PMsrRunStructure &runInfo)
} }
// check if the file is found in the directory given in the startup file // check if the file is found in the directory given in the startup file
// ** STILL MISSING ** if (pathName.CompareTo("???") == 0) { // not found in local directory search
for (unsigned int i=0; i<fDataPath.size(); i++) {
str = fDataPath[i] + TString("/") + runInfo.fRunName + TString(".") + ext;
if (gSystem->AccessPathName(str.Data())!=true) { // found
pathName = str;
break;
}
}
}
// check if the file is found in the directories given by WKMFULLDATAPATH // check if the file is found in the directories given by WKMFULLDATAPATH
const char *wkmpath = gSystem->Getenv("WKMFULLDATAPATH"); const char *wkmpath = gSystem->Getenv("WKMFULLDATAPATH");
if (pathName.CompareTo("???") == 0) { // not found in local directory search if (pathName.CompareTo("???") == 0) { // not found in local directory and xml path
str = TString(wkmpath); str = TString(wkmpath);
// WKMFULLDATAPATH has the structure: path_1:path_2:...:path_n // WKMFULLDATAPATH has the structure: path_1:path_2:...:path_n
TObjArray *tokens = str.Tokenize(":"); TObjArray *tokens = str.Tokenize(":");
TObjString *ostr; TObjString *ostr;
for (int i=0; i<tokens->GetEntries(); i++) { for (int i=0; i<tokens->GetEntries(); i++) {
ostr = dynamic_cast<TObjString*>(tokens->At(i)); ostr = dynamic_cast<TObjString*>(tokens->At(i));
str = ostr->GetString() + "/" + runInfo.fRunName + TString(".") + ext; str = ostr->GetString() + TString("/") + runInfo.fRunName + TString(".") + ext;
if (gSystem->AccessPathName(str.Data())!=true) { // found if (gSystem->AccessPathName(str.Data())!=true) { // found
pathName = str; pathName = str;
break; break;
@ -276,7 +288,7 @@ bool PRunDataHandler::FileExistsCheck(PMsrRunStructure &runInfo)
// no proper path name found // no proper path name found
if (pathName.CompareTo("???") == 0) { if (pathName.CompareTo("???") == 0) {
cout << endl << "ERROR: Couldn't find '" << runInfo.fRunName << "' in any standard path."; cout << endl << "**ERROR** Couldn't find '" << runInfo.fRunName << "' in any standard path.";
cout << endl << " standard search pathes are:"; cout << endl << " standard search pathes are:";
cout << endl << " 1. the local directory"; cout << endl << " 1. the local directory";
cout << endl << " 2. the data directory given in the startup XML file"; cout << endl << " 2. the data directory given in the startup XML file";

View File

@ -154,6 +154,7 @@ void PStartupHandler::OnCharacters(const char *str)
case eDataPath: case eDataPath:
// check that str is a valid path // check that str is a valid path
// add str to the path list // add str to the path list
fDataPathList.push_back(str);
break; break;
case eMarker: case eMarker:
// check that str is a number // check that str is a number

View File

@ -32,11 +32,6 @@
#ifndef _PMSRHANDLER_H_ #ifndef _PMSRHANDLER_H_
#define _PMSRHANDLER_H_ #define _PMSRHANDLER_H_
/*
#include <vector>
using namespace std;
*/
#include <TString.h> #include <TString.h>
#include <TComplex.h> #include <TComplex.h>
@ -72,6 +67,7 @@ class PMsrHandler
virtual bool SetMsrParamValue(unsigned int i, double value); virtual bool SetMsrParamValue(unsigned int i, double value);
virtual bool SetMsrParamStep(unsigned int i, double value); virtual bool SetMsrParamStep(unsigned int i, double value);
virtual bool SetMsrParamPosErrorPresent(unsigned int i, bool value);
virtual bool SetMsrParamPosError(unsigned int i, double value); virtual bool SetMsrParamPosError(unsigned int i, double value);
virtual void SetMsrStatisticMin(double min) { fStatistic.fMin = min; } virtual void SetMsrStatisticMin(double min) { fStatistic.fMin = min; }

View File

@ -110,6 +110,12 @@ typedef vector<double> PDoubleVector;
*/ */
typedef vector<TComplex> PComplexVector; typedef vector<TComplex> PComplexVector;
//-------------------------------------------------------------
/**
* <p> typedef to make to code more readable.
*/
typedef vector<TString> PStringVector;
//------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------
/** /**
* <p>Predominantly used in PRunBase. * <p>Predominantly used in PRunBase.

View File

@ -52,7 +52,8 @@ class PMusrCanvas : public TObject, public TQObject
{ {
public: public:
PMusrCanvas(); PMusrCanvas();
PMusrCanvas(const char* title, Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh); PMusrCanvas(const char* title, Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh,
const PIntVector markerList, const PIntVector colorList);
virtual ~PMusrCanvas(); virtual ~PMusrCanvas();
virtual Bool_t IsValid() { return fValid; } virtual Bool_t IsValid() { return fValid; }
@ -82,6 +83,9 @@ class PMusrCanvas : public TObject, public TQObject
PMsrLines fTheoryList; PMsrLines fTheoryList;
PMsrLines fFunctionList; PMsrLines fFunctionList;
PIntVector fMarkerList;
PIntVector fColorList;
ClassDef(PMusrCanvas, 1) ClassDef(PMusrCanvas, 1)
}; };

View File

@ -43,7 +43,7 @@ using namespace std;
class PRunDataHandler class PRunDataHandler
{ {
public: public:
PRunDataHandler(PMsrHandler *msrInfo); PRunDataHandler(PMsrHandler *msrInfo, const PStringVector dataPath);
virtual ~PRunDataHandler(); virtual ~PRunDataHandler();
virtual bool IsAllDataAvailable() { return fAllDataAvailable; } virtual bool IsAllDataAvailable() { return fAllDataAvailable; }
@ -51,6 +51,7 @@ class PRunDataHandler
private: private:
PMsrHandler *fMsrInfo; PMsrHandler *fMsrInfo;
PStringVector fDataPath;
bool fAllDataAvailable; ///< flag indicating if all data sets could be read bool fAllDataAvailable; ///< flag indicating if all data sets could be read
TString fRunName; ///< current run name TString fRunName; ///< current run name

View File

@ -56,13 +56,17 @@ class PStartupHandler : public TObject, public TQObject
virtual void OnFatalError(const char*); // SLOT virtual void OnFatalError(const char*); // SLOT
virtual void OnCdataBlock(const char*, Int_t); // SLOT virtual void OnCdataBlock(const char*, Int_t); // SLOT
virtual const PStringVector GetDataPathList() const { return fDataPathList; }
virtual const PIntVector GetMarkerList() const { return fMarkerList; }
virtual const PIntVector GetColorList() const { return fColorList; }
private: private:
enum EKeyWords {eEmpty, eComment, eDataPath, enum EKeyWords {eEmpty, eComment, eDataPath,
eRootSettings, eMarkerList, eMarker, eRootSettings, eMarkerList, eMarker,
eColorList, eColor}; eColorList, eColor};
EKeyWords fKey; EKeyWords fKey;
vector<TString> fDataPathList; PStringVector fDataPathList;
PIntVector fMarkerList; PIntVector fMarkerList;
PIntVector fColorList; PIntVector fColorList;

View File

@ -33,10 +33,11 @@
#include <fstream> #include <fstream>
using namespace std; using namespace std;
#include "TString.h" #include <TSAXParser.h>
#include "TFile.h" #include <TString.h>
#include "TCanvas.h" #include <TFile.h>
#include "TH1.h" #include <TCanvas.h>
#include <TH1.h>
#include "PMusr.h" #include "PMusr.h"
#include "PStartupHandler.h" #include "PStartupHandler.h"
@ -501,7 +502,25 @@ int main(int argc, char *argv[])
} }
// read startup file // read startup file
TSAXParser *saxParser = new TSAXParser();
PStartupHandler *startupHandler = new PStartupHandler(); PStartupHandler *startupHandler = new PStartupHandler();
saxParser->ConnectToHandler("PStartupHandler", startupHandler);
status = saxParser->ParseFile("musrfit_startup.xml");
// check for parse errors
if (status) { // error
cout << endl << "**ERROR** reading/parsing musrfit_startup.xml. Fix it.";
cout << endl;
// clean up
if (saxParser) {
delete saxParser;
saxParser = 0;
}
if (startupHandler) {
delete startupHandler;
startupHandler = 0;
}
return PMUSR_WRONG_STARTUP_SYNTAX;
}
// read msr-file // read msr-file
PMsrHandler *msrHandler = new PMsrHandler(argv[1]); PMsrHandler *msrHandler = new PMsrHandler(argv[1]);
@ -524,7 +543,7 @@ 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); PRunDataHandler *dataHandler = new PRunDataHandler(msrHandler, startupHandler->GetDataPathList());
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 << "Couldn't read all data files, will quit ..." << endl;

View File

@ -4,8 +4,8 @@
$Id$ $Id$
Defines default settings for the musrfit package Defines default settings for the musrfit package
</comment> </comment>
<data_path name="/mnt/data/nemu/his"/> <data_path>/mnt/data/nemu/his</data_path>
<data_path name="/mnt/data/nemu/wkm"/> <data_path>/mnt/data/nemu/wkm</data_path>
<root_settings> <root_settings>
<marker_list> <marker_list>
<!-- Root marker numbers --> <!-- Root marker numbers -->

View File

@ -132,7 +132,7 @@ 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); PRunDataHandler *dataHandler = new PRunDataHandler(msrHandler, startupHandler->GetDataPathList());
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;
@ -157,7 +157,8 @@ int main(int argc, char *argv[])
// generate Root application needed for PMusrCanvas // generate Root application needed for PMusrCanvas
TApplication app("App", &argc, argv); TApplication app("App", &argc, argv);
PMusrCanvas *musrCanvas = new PMusrCanvas(msrHandler->GetMsrTitle()->Data(), 10, 10, 800, 600); PMusrCanvas *musrCanvas = new PMusrCanvas(msrHandler->GetMsrTitle()->Data(), 10, 10, 800, 600,
startupHandler->GetMarkerList(), startupHandler->GetColorList());
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;