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();
bool status;
bool minosUsed = false;
for (unsigned int i=0; i<fCmdList.size(); i++) {
switch (fCmdList[i]) {
case PMN_INTERACTIVE:
@ -148,6 +149,7 @@ bool PFitter::DoFit()
break;
case PMN_MINOS:
status = ExecuteMinos();
minosUsed = true;
break;
case PMN_PLOT:
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;
}

View File

@ -683,6 +683,28 @@ bool PMsrHandler::SetMsrParamStep(unsigned int i, double value)
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)
//--------------------------------------------------------------------------

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;

View File

@ -52,7 +52,7 @@ using namespace std;
* <p>
*
*/
PRunDataHandler::PRunDataHandler(PMsrHandler *msrInfo)
PRunDataHandler::PRunDataHandler(PMsrHandler *msrInfo, const PStringVector dataPath) : fDataPath(dataPath)
{
// cout << endl << "in PRunDataHandler::PRunDataHandler()";
@ -63,6 +63,10 @@ PRunDataHandler::PRunDataHandler(PMsrHandler *msrInfo)
fAllDataAvailable = false;
else
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
// ** 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
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);
// WKMFULLDATAPATH has the structure: path_1:path_2:...:path_n
TObjArray *tokens = str.Tokenize(":");
TObjString *ostr;
for (int i=0; i<tokens->GetEntries(); 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
pathName = str;
break;
@ -276,7 +288,7 @@ bool PRunDataHandler::FileExistsCheck(PMsrRunStructure &runInfo)
// no proper path name found
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 << " 1. the local directory";
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:
// check that str is a valid path
// add str to the path list
fDataPathList.push_back(str);
break;
case eMarker:
// check that str is a number

View File

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

View File

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

View File

@ -52,7 +52,8 @@ class PMusrCanvas : public TObject, public TQObject
{
public:
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 Bool_t IsValid() { return fValid; }
@ -82,6 +83,9 @@ class PMusrCanvas : public TObject, public TQObject
PMsrLines fTheoryList;
PMsrLines fFunctionList;
PIntVector fMarkerList;
PIntVector fColorList;
ClassDef(PMusrCanvas, 1)
};

View File

@ -43,14 +43,15 @@ using namespace std;
class PRunDataHandler
{
public:
PRunDataHandler(PMsrHandler *msrInfo);
PRunDataHandler(PMsrHandler *msrInfo, const PStringVector dataPath);
virtual ~PRunDataHandler();
virtual bool IsAllDataAvailable() { return fAllDataAvailable; }
virtual PRawRunData* GetRunData(TString runName);
private:
PMsrHandler *fMsrInfo;
PMsrHandler *fMsrInfo;
PStringVector fDataPath;
bool fAllDataAvailable; ///< flag indicating if all data sets could be read
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 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:
enum EKeyWords {eEmpty, eComment, eDataPath,
eRootSettings, eMarkerList, eMarker,
eColorList, eColor};
EKeyWords fKey;
vector<TString> fDataPathList;
PStringVector fDataPathList;
PIntVector fMarkerList;
PIntVector fColorList;

View File

@ -33,10 +33,11 @@
#include <fstream>
using namespace std;
#include "TString.h"
#include "TFile.h"
#include "TCanvas.h"
#include "TH1.h"
#include <TSAXParser.h>
#include <TString.h>
#include <TFile.h>
#include <TCanvas.h>
#include <TH1.h>
#include "PMusr.h"
#include "PStartupHandler.h"
@ -501,7 +502,25 @@ int main(int argc, char *argv[])
}
// read startup file
TSAXParser *saxParser = new TSAXParser();
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
PMsrHandler *msrHandler = new PMsrHandler(argv[1]);
@ -524,7 +543,7 @@ int main(int argc, char *argv[])
musrfit_debug_info(msrHandler);
// read all the necessary runs (raw data)
PRunDataHandler *dataHandler = new PRunDataHandler(msrHandler);
PRunDataHandler *dataHandler = new PRunDataHandler(msrHandler, startupHandler->GetDataPathList());
bool success = dataHandler->IsAllDataAvailable();
if (!success) {
cout << endl << "Couldn't read all data files, will quit ..." << endl;

View File

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

View File

@ -132,7 +132,7 @@ int main(int argc, char *argv[])
}
// read all the necessary runs (raw data)
PRunDataHandler *dataHandler = new PRunDataHandler(msrHandler);
PRunDataHandler *dataHandler = new PRunDataHandler(msrHandler, startupHandler->GetDataPathList());
success = dataHandler->IsAllDataAvailable();
if (!success) {
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
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()) {
cout << endl << "**SEVERE ERROR** Couldn't invoke all necessary objects, will quit.";
cout << endl;