some more steps toward musrview

This commit is contained in:
nemu 2008-04-04 14:29:56 +00:00
parent 0652495a3f
commit f4f6fcb058
13 changed files with 385 additions and 172 deletions

View File

@ -37,8 +37,7 @@ CXX = g++
CXXFLAGS = -g -Wall -fPIC CXXFLAGS = -g -Wall -fPIC
PMUSRPATH = ./include PMUSRPATH = ./include
MNPATH = $(ROOTSYS)/include MNPATH = $(ROOTSYS)/include
GSLPATH = /usr/include/gsl INCLUDES = -I $(PMUSRPATH) -I $(MNPATH)
INCLUDES = -I $(PMUSRPATH) -I $(MNPATH) -I $(GSLPATH)
LD = g++ LD = g++
LDFLAGS = -g LDFLAGS = -g
endif endif
@ -64,8 +63,8 @@ GLIBS = $(ROOTGLIBS) -lXMLParser
PSILIBS = -lTLemRunHeader -lPMusr PSILIBS = -lTLemRunHeader -lPMusr
# Minuit2 lib # Minuit2 lib
MNLIB = -L$(ROOTSYS)/lib -lMinuit2 MNLIB = -L$(ROOTSYS)/lib -lMinuit2
# GSL lib # MathMore lib
GSLLIB = -lgslcblas -lgsl MMLIB = -L$(ROOTSYS)/lib -lMathMore
EXEC = musrfit EXEC = musrfit
@ -81,7 +80,7 @@ all: $(EXEC)
$(EXEC): $(OBJS) $(EXEC): $(OBJS)
@echo "---> Building $(EXEC) ..." @echo "---> Building $(EXEC) ..."
/bin/rm -f $(SHLIB) /bin/rm -f $(SHLIB)
$(LD) $(OBJS) -o $(EXEC) $(GLIBS) $(PSILIBS) $(MNLIB) $(GSLLIB) $(LD) $(OBJS) -o $(EXEC) $(GLIBS) $(PSILIBS) $(MNLIB) $(MMLIB)
@echo "done" @echo "done"
# clean up: remove all object file (and core files) # clean up: remove all object file (and core files)

View File

@ -37,8 +37,8 @@ CXX = g++
CXXFLAGS = -g -Wall -fPIC CXXFLAGS = -g -Wall -fPIC
PMUSRPATH = ./include PMUSRPATH = ./include
MNPATH = $(ROOTSYS)/include MNPATH = $(ROOTSYS)/include
GSLPATH = /usr/include/gsl #GSLPATH = /usr/include/gsl
INCLUDES = -I $(PMUSRPATH) -I $(MNPATH) -I $(GSLPATH) INCLUDES = -I $(PMUSRPATH) -I $(MNPATH)
LD = g++ LD = g++
LDFLAGS = -g LDFLAGS = -g
endif endif
@ -64,8 +64,8 @@ GLIBS = $(ROOTGLIBS) -lXMLParser
PSILIBS = -lTLemRunHeader -lPMusr PSILIBS = -lTLemRunHeader -lPMusr
# Minuit2 lib # Minuit2 lib
MNLIB = -L$(ROOTSYS)/lib -lMinuit2 MNLIB = -L$(ROOTSYS)/lib -lMinuit2
# GSL lib # MathMore lib
GSLLIB = -lgslcblas -lgsl MMLIB = -L$(ROOTSYS)/lib -lMathMore
EXEC = musrview EXEC = musrview
@ -81,7 +81,7 @@ all: $(EXEC)
$(EXEC): $(OBJS) $(EXEC): $(OBJS)
@echo "---> Building $(EXEC) ..." @echo "---> Building $(EXEC) ..."
/bin/rm -f $(SHLIB) /bin/rm -f $(SHLIB)
$(LD) $(OBJS) -o $(EXEC) $(GLIBS) $(PSILIBS) $(MNLIB) $(GSLLIB) $(LD) $(OBJS) -o $(EXEC) $(GLIBS) $(PSILIBS) $(MNLIB) $(MMLIB)
@echo "done" @echo "done"
# clean up: remove all object file (and core files) # clean up: remove all object file (and core files)

View File

@ -40,7 +40,7 @@ endif
# -- Linux # -- Linux
ifeq ($(OS),LINUX) ifeq ($(OS),LINUX)
CXX = g++ CXX = g++
CXXFLAGS = -g -Wall -fPIC CXXFLAGS = -g -Wall -Wno-trigraphs -fPIC
PMUSRPATH = ../include PMUSRPATH = ../include
MNPATH = $(ROOTSYS)/include MNPATH = $(ROOTSYS)/include
GSLPATH = /usr/include/gsl GSLPATH = /usr/include/gsl
@ -53,7 +53,7 @@ endif
# -- Darwin # -- Darwin
ifeq ($(OS),DARWIN) ifeq ($(OS),DARWIN)
CXX = g++ CXX = g++
CXXFLAGS = -g -Wall -fPIC CXXFLAGS = -g -Wall -Wno-trigraphs -fPIC
INCLUDES = -I../include INCLUDES = -I../include
LD = g++ LD = g++
LDFLAGS = -g LDFLAGS = -g
@ -123,7 +123,7 @@ PStartupHandlerDict.cpp: ../include/PStartupHandler.h
PMusrCanvasDict.cpp: ../include/PMusrCanvas.h PMusrCanvasDict.cpp: ../include/PMusrCanvas.h
@echo "Generating dictionary $@..." @echo "Generating dictionary $@..."
rootcint -f $@ -c -p $^ rootcint -v -f $@ -c -p $^
install: all install: all
@echo "Installing shared lib: libPMusr.so ( you must be root ;-) )" @echo "Installing shared lib: libPMusr.so ( you must be root ;-) )"

View File

@ -608,18 +608,18 @@ int PMsrHandler::WriteMsrLogFile()
// create the new statistics block // create the new statistics block
PMsrLineStructure line; PMsrLineStructure line;
if (fStatistic.fChisq) { // chi^2 if (fStatistic.fChisq) { // chi^2
line.fLine = " chi2 = "; line.fLine = " chisq = ";
line.fLine += fStatistic.fMin; line.fLine += fStatistic.fMin;
line.fLine += ", NDF = "; line.fLine += ", NDF = ";
line.fLine += fStatistic.fNdf; line.fLine += fStatistic.fNdf;
line.fLine += ", chi2r = chi2/NDF = "; line.fLine += ", chisq/NDF = ";
line.fLine += fStatistic.fMin / fStatistic.fNdf; line.fLine += fStatistic.fMin / fStatistic.fNdf;
} else { } else {
line.fLine = " maxLH = "; line.fLine = " maxLH = ";
line.fLine += fStatistic.fMin; line.fLine += fStatistic.fMin;
line.fLine += ", NDF = "; line.fLine += ", NDF = ";
line.fLine += fStatistic.fNdf; line.fLine += fStatistic.fNdf;
line.fLine += ", maxLHr = maxLH/NDF = "; line.fLine += ", maxLH/NDF = ";
line.fLine += fStatistic.fMin / fStatistic.fNdf; line.fLine += fStatistic.fMin / fStatistic.fNdf;
} }
fStatistic.fStatLines.push_back(line); fStatistic.fStatLines.push_back(line);
@ -1818,17 +1818,75 @@ bool PMsrHandler::HandlePlotEntry(PMsrLines &lines)
*/ */
bool PMsrHandler::HandleStatisticEntry(PMsrLines &lines) bool PMsrHandler::HandleStatisticEntry(PMsrLines &lines)
{ {
PMsrLines::iterator iter;
if (lines.empty()) { if (lines.empty()) {
cout << endl << "WARNING: There is no STATISTIC block! Do you really want this?"; cout << endl << "WARNING: There is no STATISTIC block! Do you really want this?";
cout << endl; cout << endl;
return false;
} }
for (iter = lines.begin(); iter != lines.end(); ++iter) { char str[128];
if (!iter->fLine.BeginsWith("STATISTIC")) char date[128];
fStatistic.fStatLines.push_back(*iter); char time[128];
int status;
double dval;
unsigned int ival;
for (unsigned int i=0; i<lines.size(); i++) {
// filter date and chisq etc from strings
// extract date and time
if (lines[i].fLine.Contains("STATISTIC")) {
status = sscanf(lines[i].fLine.Data(), "STATISTIC --- %s%s", date, time);
if (status == 2) {
fStatistic.fDate = TString(date)+TString(", ")+TString(time);
} else {
fStatistic.fDate = TString("????-??-??, ??:??:??");
} }
}
// extract chisq
if (lines[i].fLine.Contains("chisq =")) {
fStatistic.fChisq = true;
strncpy(str, lines[i].fLine.Data(), sizeof(str));
status = sscanf(str+lines[i].fLine.Index("chisq = ")+8, "%lf", &dval);
if (status == 1) {
fStatistic.fMin = dval;
} else {
fStatistic.fMin = -1.0;
}
}
// extract maxLH
if (lines[i].fLine.Contains("maxLH =")) {
fStatistic.fChisq = true;
strncpy(str, lines[i].fLine.Data(), sizeof(str));
status = sscanf(str+lines[i].fLine.Index("maxLH = ")+8, "%lf", &dval);
if (status == 1) {
fStatistic.fMin = dval;
} else {
fStatistic.fMin = -1.0;
}
}
// extract NDF
if (lines[i].fLine.Contains(", NDF =")) {
fStatistic.fChisq = true;
strncpy(str, lines[i].fLine.Data(), sizeof(str));
status = sscanf(str+lines[i].fLine.Index(", NDF = ")+8, "%u", &ival);
if (status == 1) {
fStatistic.fNdf = ival;
} else {
fStatistic.fNdf = 0;
}
}
// keep string
fStatistic.fStatLines.push_back(lines[i]);
}
// cout << endl << "Statistic:";
// cout << endl << " Date & Time: " << fStatistic.fDate.Data();
// if (fStatistic.fChisq) { // chisq
// cout << endl << " chisq = " << fStatistic.fMin;
// cout << endl << " NDF = " << fStatistic.fNdf;
// } else { // maximum likelihood
// cout << endl << " maxLH = " << fStatistic.fMin;
// cout << endl << " NDF = " << fStatistic.fNdf;
// }
return true; return true;
} }

View File

@ -47,6 +47,7 @@ ClassImpQ(PMusrCanvas)
PMusrCanvas::PMusrCanvas() PMusrCanvas::PMusrCanvas()
{ {
fValid = false; fValid = false;
fPlotNumber = -1;
fMainCanvas = 0; fMainCanvas = 0;
fTitlePad = 0; fTitlePad = 0;
@ -62,9 +63,10 @@ PMusrCanvas::PMusrCanvas()
/** /**
* *
*/ */
PMusrCanvas::PMusrCanvas(const char* title, Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh, PMusrCanvas::PMusrCanvas(const int number, const char* title,
Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh,
const PIntVector markerList, const PIntVector colorList) : const PIntVector markerList, const PIntVector colorList) :
fMarkerList(markerList), fColorList(colorList) fPlotNumber(number), fMarkerList(markerList), fColorList(colorList)
{ {
fValid = false; fValid = false;
@ -76,10 +78,12 @@ PMusrCanvas::PMusrCanvas(const char* title, Int_t wtopx, Int_t wtopy, Int_t ww,
fKeyboardHandlerText = 0; fKeyboardHandlerText = 0;
// invoke canvas // invoke canvas
fMainCanvas = new TCanvas("fMainCanvas", title, wtopx, wtopy, ww, wh); TString canvasName = TString("fMainCanvas");
cout << "fMainCanvas = " << fMainCanvas << endl; canvasName += fPlotNumber;
fMainCanvas = new TCanvas(canvasName.Data(), title, wtopx, wtopy, ww, wh);
cout << canvasName.Data() << " = " << fMainCanvas << endl;
if (fMainCanvas == 0) { if (fMainCanvas == 0) {
cout << endl << "PMusrCanvas::PMusrCanvas: **PANIC ERROR**: Couldn't invoke fMainCanvas"; cout << endl << "PMusrCanvas::PMusrCanvas: **PANIC ERROR**: Couldn't invoke " << canvasName.Data();
cout << endl; cout << endl;
return; return;
} }
@ -119,7 +123,7 @@ cout << "fMainCanvas = " << fMainCanvas << endl;
fParameterTheoryPad->SetTextFont(102); // courier bold, scalable so that greek parameters will be plotted properly fParameterTheoryPad->SetTextFont(102); // courier bold, scalable so that greek parameters will be plotted properly
// info pad // info pad
fInfoPad = new TPaveText(0.0, 0.0, 1.0, YINFO, "NDC"); fInfoPad = new TLegend(0.0, 0.0, 1.0, YINFO, "NDC");
if (fInfoPad == 0) { if (fInfoPad == 0) {
cout << endl << "PMusrCanvas::PMusrCanvas: **PANIC ERROR**: Couldn't invoke fInfoPad"; cout << endl << "PMusrCanvas::PMusrCanvas: **PANIC ERROR**: Couldn't invoke fInfoPad";
cout << endl; cout << endl;
@ -127,11 +131,6 @@ cout << "fMainCanvas = " << fMainCanvas << endl;
} }
fInfoPad->SetFillColor(TColor::GetColor(255,255,255)); fInfoPad->SetFillColor(TColor::GetColor(255,255,255));
fInfoPad->SetTextAlign(12); // middle, left fInfoPad->SetTextAlign(12); // middle, left
fInfoPad->AddText("musrfit info pad ...");
fInfoPad->AddText(" this is the 1st info line ...");
fInfoPad->AddText(" this is the 2nd info line ...");
fInfoPad->AddText(" this is the 2nd info line ...");
fInfoPad->Draw();
// fKeyboardHandlerText Pad init // fKeyboardHandlerText Pad init
fDataTheoryPad->cd(); fDataTheoryPad->cd();
@ -152,13 +151,13 @@ cout << "fMainCanvas = " << fMainCanvas << endl;
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*)");
cout << "this " << this << endl; // cout << "this " << this << endl;
cout << "fMainCanvas " << fMainCanvas << endl; // cout << "fMainCanvas " << fMainCanvas << endl;
cout << "fTitlePad " << fTitlePad << endl; // cout << "fTitlePad " << fTitlePad << endl;
cout << "fDataTheoryPad " << fDataTheoryPad << endl; // cout << "fDataTheoryPad " << fDataTheoryPad << 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;
} }
@ -170,6 +169,7 @@ cout << "fKeyboardHandlerText " << fKeyboardHandlerText << endl;
*/ */
PMusrCanvas::~PMusrCanvas() PMusrCanvas::~PMusrCanvas()
{ {
cout << "~PMusrCanvas() called" << endl;
// cleanup // cleanup
if (fKeyboardHandlerText) { if (fKeyboardHandlerText) {
delete fKeyboardHandlerText; delete fKeyboardHandlerText;
@ -221,11 +221,11 @@ void PMusrCanvas::HandleCmdKey(Int_t event, Int_t x, Int_t y, TObject *selected)
if (event != kKeyPress) if (event != kKeyPress)
return; return;
cout << ">this " << this << endl; // cout << ">this " << this << endl;
cout << ">fMainCanvas " << fMainCanvas << endl; // cout << ">fMainCanvas " << fMainCanvas << endl;
cout << ">selected " << selected << endl; // cout << ">selected " << selected << endl;
//
cout << "px: " << (char)fMainCanvas->GetEventX() << endl; // cout << "px: " << (char)fMainCanvas->GetEventX() << endl;
TString str((Char_t)x); TString str((Char_t)x);
if (x == 'q') { if (x == 'q') {
@ -244,45 +244,6 @@ void PMusrCanvas::HandleCmdKey(Int_t event, Int_t x, Int_t y, TObject *selected)
} }
} }
//--------------------------------------------------------------------------
// 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 // UpdateParamTheoryPad
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
@ -291,6 +252,9 @@ void PMusrCanvas::SetFunctionList(PMsrLines &functionList)
*/ */
void PMusrCanvas::UpdateParamTheoryPad() void PMusrCanvas::UpdateParamTheoryPad()
{ {
if (!fValid)
return;
TString str; TString str;
char cnum[128]; char cnum[128];
int maxLength = 0; int maxLength = 0;
@ -298,52 +262,54 @@ void PMusrCanvas::UpdateParamTheoryPad()
int idx; int idx;
// add parameters ------------------------------------------------------------ // add parameters ------------------------------------------------------------
PMsrParamList param = *fMsrHandler->GetMsrParamList();
// get maximal parameter name string length // get maximal parameter name string length
for (unsigned int i=0; i<fParamList.size(); i++) { for (unsigned int i=0; i<param.size(); i++) {
if (fParamList[i].fName.Length() > maxLength) if (param[i].fName.Length() > maxLength)
maxLength = fParamList[i].fName.Length(); maxLength = param[i].fName.Length();
} }
maxLength += 2; maxLength += 2;
// add parameters to the pad // add parameters to the pad
for (unsigned int i=0; i<fParamList.size(); i++) { for (unsigned int i=0; i<param.size(); i++) {
str = ""; str = "";
// parameter no // parameter no
str += fParamList[i].fNo; str += param[i].fNo;
if (fParamList[i].fNo<10) if (param[i].fNo<10)
str += " "; str += " ";
else else
str += " "; str += " ";
// parameter name // parameter name
str += fParamList[i].fName; str += param[i].fName;
for (int j=0; j<maxLength-fParamList[i].fName.Length(); j++) // fill spaces for (int j=0; j<maxLength-param[i].fName.Length(); j++) // fill spaces
str += " "; str += " ";
// parameter value // parameter value
if (round(fParamList[i].fValue)-fParamList[i].fValue==0) if (round(param[i].fValue)-param[i].fValue==0)
sprintf(cnum, "%.1lf", fParamList[i].fValue); sprintf(cnum, "%.1lf", param[i].fValue);
else else
sprintf(cnum, "%.6lf", fParamList[i].fValue); sprintf(cnum, "%.6lf", param[i].fValue);
str += cnum; str += cnum;
for (int j=0; j<9-(int)strlen(cnum); j++) // fill spaces for (int j=0; j<9-(int)strlen(cnum); j++) // fill spaces
str += " "; str += " ";
str += " "; // to make sure that at least 1 space is placed str += " "; // to make sure that at least 1 space is placed
// parameter error // parameter error
if (fParamList[i].fPosErrorPresent) { // minos was used if (param[i].fPosErrorPresent) { // minos was used
if (round(fParamList[i].fStep)-fParamList[i].fStep==0) if (round(param[i].fStep)-param[i].fStep==0)
sprintf(cnum, "%.1lf", fParamList[i].fStep); sprintf(cnum, "%.1lf", param[i].fStep);
else else
sprintf(cnum, "%.6lf", fParamList[i].fStep); sprintf(cnum, "%.6lf", param[i].fStep);
str += cnum; str += cnum;
str += "/"; str += "/";
if (round(fParamList[i].fPosError)-fParamList[i].fPosError==0) if (round(param[i].fPosError)-param[i].fPosError==0)
sprintf(cnum, "%.1lf", fParamList[i].fPosError); sprintf(cnum, "%.1lf", param[i].fPosError);
else else
sprintf(cnum, "%.6lf", fParamList[i].fPosError); sprintf(cnum, "%.6lf", param[i].fPosError);
str += cnum; str += cnum;
} else { // minos was not used } else { // minos was not used
if (round(fParamList[i].fStep)-fParamList[i].fStep==0) if (round(param[i].fStep)-param[i].fStep==0)
sprintf(cnum, "%.1lf", fParamList[i].fStep); sprintf(cnum, "%.1lf", param[i].fStep);
else else
sprintf(cnum, "%.6lf", fParamList[i].fStep); sprintf(cnum, "%.6lf", param[i].fStep);
str += cnum; str += cnum;
} }
ypos = 0.925-i*0.025; ypos = 0.925-i*0.025;
@ -352,9 +318,10 @@ void PMusrCanvas::UpdateParamTheoryPad()
// add theory ------------------------------------------------------------ // add theory ------------------------------------------------------------
ypos -= 0.025; ypos -= 0.025;
for (unsigned int i=1; i<fTheoryList.size(); i++) { PMsrLines theory = *fMsrHandler->GetMsrTheory();
for (unsigned int i=1; i<theory.size(); i++) {
// remove comment if present // remove comment if present
str = fTheoryList[i].fLine; str = theory[i].fLine;
idx = str.Index("("); idx = str.Index("(");
if (idx > 0) { // comment present if (idx > 0) { // comment present
str.Resize(idx-1); str.Resize(idx-1);
@ -366,9 +333,10 @@ void PMusrCanvas::UpdateParamTheoryPad()
// add functions -------------------------------------------------------- // add functions --------------------------------------------------------
ypos -= 0.025; ypos -= 0.025;
for (unsigned int i=1; i<fFunctionList.size(); i++) { PMsrLines functions = *fMsrHandler->GetMsrFunctions();
for (unsigned int i=1; i<functions.size(); i++) {
ypos -= 0.025; ypos -= 0.025;
fParameterTheoryPad->AddText(0.03, ypos, fFunctionList[i].fLine.Data()); fParameterTheoryPad->AddText(0.03, ypos, functions[i].fLine.Data());
} }
fParameterTheoryPad->Draw(); fParameterTheoryPad->Draw();
@ -376,6 +344,44 @@ void PMusrCanvas::UpdateParamTheoryPad()
fMainCanvas->Update(); fMainCanvas->Update();
} }
//--------------------------------------------------------------------------
// UpdateDataTheoryPad
//--------------------------------------------------------------------------
/**
* <p>
*/
void PMusrCanvas::UpdateDataTheoryPad()
{
// some checks first
unsigned int runNo;
PMsrPlotStructure plotInfo = fMsrHandler->GetMsrPlotList()->at(fPlotNumber);
PMsrRunList runs = *fMsrHandler->GetMsrRunList();
for (unsigned int i=0; i<plotInfo.fRuns.size(); i++) {
// first check that plot number is smaller than the maximal number of runs
if ((int)plotInfo.fRuns[i].Re() > (int)runs.size()) {
fValid = false;
cout << endl << "PMusrCanvas::UpdateDataTheoryPad: **ERROR** run plot number " << (int)plotInfo.fRuns[i].Re() << " is larger than the number of runs " << runs.size();
cout << endl;
return;
}
// check that the plottype and the fittype do correspond
runNo = (unsigned int)plotInfo.fRuns[i].Re()-1;
cout << endl << ">> runNo = " << runNo;
cout << endl;
if (plotInfo.fPlotType != runs[runNo].fFitType) {
fValid = false;
cout << endl << "PMusrCanvas::UpdateDataTheoryPad: **ERROR** plottype = " << plotInfo.fPlotType << ", fittype = " << runs[runNo].fFitType << ", however they have to correspond!";
cout << endl;
return;
}
}
for (unsigned int i=0; i<plotInfo.fRuns.size(); i++) {
// get run data and create a histogram
// get theory object and calculate a theory histogram
}
}
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// UpdateInfoPad // UpdateInfoPad
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
@ -384,7 +390,43 @@ void PMusrCanvas::UpdateParamTheoryPad()
*/ */
void PMusrCanvas::UpdateInfoPad() void PMusrCanvas::UpdateInfoPad()
{ {
// get fit data if (!fValid)
return;
PMsrStatisticStructure statistic = *fMsrHandler->GetMsrStatistic();
TString tstr, tsubstr;
tstr = "musrfit: ";
// get fit date
tstr += statistic.fDate;
tstr += TString(", ");
// get chisq if not a max likelihood fit // get chisq if not a max likelihood fit
if (statistic.fChisq) { // chisq
tstr += TString("chisq = ");
} else { // max. likelihood
tstr += TString("maxLH = ");
}
tstr += statistic.fMin;
tstr += TString(" , NDF = ");
tstr += statistic.fNdf;
if (statistic.fChisq) { // chisq
tstr += TString(" , chisq/NDF = ");
} else { // max. likelihood
tstr += TString(" , maxLH/NDF = ");
}
if (statistic.fNdf != 0) {
tstr += statistic.fMin/statistic.fNdf;
} else {
tstr += TString("undefined");
}
fInfoPad->SetHeader(tstr);
// get run plot info // get run plot info
fInfoPad->Draw();
fMainCanvas->cd();
fMainCanvas->Update();
} }

View File

@ -40,7 +40,7 @@
* <p> * <p>
* *
* \param msrInfo pointer to the msr info structure * \param msrInfo pointer to the msr info structure
* \param runNo number of the run of the msr-file * \param data
*/ */
PRunListCollection::PRunListCollection(PMsrHandler *msrInfo, PRunDataHandler *data) PRunListCollection::PRunListCollection(PMsrHandler *msrInfo, PRunDataHandler *data)
{ {
@ -292,16 +292,34 @@ unsigned int PRunListCollection::GetTotalNoOfBinsFitted()
* <p> * <p>
* *
* \param index * \param index
* \param tag kIndex -> data at index, kRunNo -> data of given run no
*/ */
PRunData* PRunListCollection::GetSingleHisto(unsigned int index) PRunData* PRunListCollection::GetSingleHisto(unsigned int index, EDataSwitch tag)
{ {
PRunData *data = 0;
switch (tag) {
case kIndex:
if ((index < 0) || (index > fRunSingleHistoList.size())) { if ((index < 0) || (index > fRunSingleHistoList.size())) {
cout << endl << "PRunListCollection::GetSingleHisto: index = " << index << " out of bounds"; cout << endl << "PRunListCollection::GetSingleHisto: index = " << index << " out of bounds";
return 0; return 0;
} }
fRunSingleHistoList[index]->CalcTheory(); fRunSingleHistoList[index]->CalcTheory();
PRunData *data = fRunSingleHistoList[index]->GetData(); data = fRunSingleHistoList[index]->GetData();
break;
case kRunNo:
for (unsigned int i=0; i<fRunSingleHistoList.size(); i++) {
if (fRunSingleHistoList[i]->GetRunNo() == index) {
data = fRunSingleHistoList[i]->GetData();
break;
}
}
break;
default: // error
return 0;
break;
}
return data; return data;
} }
@ -313,16 +331,34 @@ PRunData* PRunListCollection::GetSingleHisto(unsigned int index)
* <p> * <p>
* *
* \param index * \param index
* \param tag kIndex -> data at index, kRunNo -> data of given run no
*/ */
PRunData* PRunListCollection::GetAsymmetry(unsigned int index) PRunData* PRunListCollection::GetAsymmetry(unsigned int index, EDataSwitch tag)
{ {
PRunData *data = 0;
switch (tag) {
case kIndex:
if ((index < 0) || (index > fRunAsymmetryList.size())) { if ((index < 0) || (index > fRunAsymmetryList.size())) {
cout << endl << "PRunListCollection::GetAsymmetry: index = " << index << " out of bounds"; cout << endl << "PRunListCollection::GetAsymmetry: index = " << index << " out of bounds";
return 0; return 0;
} }
fRunAsymmetryList[index]->CalcTheory(); fRunAsymmetryList[index]->CalcTheory();
PRunData *data = fRunAsymmetryList[index]->GetData(); data = fRunAsymmetryList[index]->GetData();
break;
case kRunNo:
for (unsigned int i=0; i<fRunAsymmetryList.size(); i++) {
if (fRunAsymmetryList[i]->GetRunNo() == index) {
data = fRunAsymmetryList[i]->GetData();
break;
}
}
break;
default: // error
return 0;
break;
}
return data; return data;
} }
@ -334,13 +370,25 @@ PRunData* PRunListCollection::GetAsymmetry(unsigned int index)
* <p> * <p>
* *
* \param index * \param index
* \param tag kIndex -> data at index, kRunNo -> data of given run no
*/ */
PRunData* PRunListCollection::GetRRF(unsigned int index) PRunData* PRunListCollection::GetRRF(unsigned int index, EDataSwitch tag)
{ {
PRunData *data = 0;
switch (tag) {
case kIndex:
if ((index < 0) || (index > fRunRRFList.size())) { if ((index < 0) || (index > fRunRRFList.size())) {
cout << endl << "PRunListCollection::GetRRF: index = " << index << " out of bounds"; cout << endl << "PRunListCollection::GetRRF: index = " << index << " out of bounds";
return 0; return 0;
} }
break;
case kRunNo:
break;
default: // error
return 0;
break;
}
return 0; return 0;
} }
@ -352,13 +400,25 @@ PRunData* PRunListCollection::GetRRF(unsigned int index)
* <p> * <p>
* *
* \param index * \param index
* \param tag kIndex -> data at index, kRunNo -> data of given run no
*/ */
PRunData* PRunListCollection::GetNonMusr(unsigned int index) PRunData* PRunListCollection::GetNonMusr(unsigned int index, EDataSwitch tag)
{ {
PRunData *data = 0;
switch (tag) {
case kIndex:
if ((index < 0) || (index > fRunNonMusrList.size())) { if ((index < 0) || (index > fRunNonMusrList.size())) {
cout << endl << "PRunListCollection::GetNonMusr: index = " << index << " out of bounds"; cout << endl << "PRunListCollection::GetNonMusr: index = " << index << " out of bounds";
return 0; return 0;
} }
break;
case kRunNo:
break;
default: // error
return 0;
break;
}
return 0; return 0;
} }

View File

@ -39,6 +39,8 @@ using namespace std;
#include <TObjArray.h> #include <TObjArray.h>
#include <TMath.h> #include <TMath.h>
#include <Math/SpecFuncMathMore.h>
#include "PMsrHandler.h" #include "PMsrHandler.h"
#include "PTheory.h" #include "PTheory.h"
@ -1074,9 +1076,12 @@ double PTheory::SkewedGauss(register double t, const vector<double>& paramValues
else if (val[2] == val[3]) // sigma+ == sigma- -> Gaussian else if (val[2] == val[3]) // sigma+ == sigma- -> Gaussian
skg = TMath::Cos(phase+freq*t) * gp; skg = TMath::Cos(phase+freq*t) * gp;
else else
// skg = TMath::Cos(phase+freq*t) * (wm*gm + wp*gp) +
// TMath::Sin(phase+freq*t) * (wm*gm*2.0*zm/SQRT_PI*gsl_sf_hyperg_1F1(0.5,1.5,zm*zm) -
// wp*gp*2.0*zp/SQRT_PI*gsl_sf_hyperg_1F1(0.5,1.5,zp*zp));
skg = TMath::Cos(phase+freq*t) * (wm*gm + wp*gp) + skg = TMath::Cos(phase+freq*t) * (wm*gm + wp*gp) +
TMath::Sin(phase+freq*t) * (wm*gm*2.0*zm/SQRT_PI*gsl_sf_hyperg_1F1(0.5,1.5,zm*zm) - TMath::Sin(phase+freq*t) * (wm*gm*2.0*zm/SQRT_PI*ROOT::Math::conf_hyperg(0.5,1.5,zm*zm) -
wp*gp*2.0*zp/SQRT_PI*gsl_sf_hyperg_1F1(0.5,1.5,zp*zp)); wp*gp*2.0*zp/SQRT_PI*ROOT::Math::conf_hyperg(0.5,1.5,zp*zp));
return skg; return skg;
} }

View File

@ -251,6 +251,7 @@ typedef vector<PMsrPlotStructure> PMsrPlotList;
*/ */
typedef struct { typedef struct {
PMsrLines fStatLines; PMsrLines fStatLines;
TString fDate; ///< string holding fitting date and time
bool fChisq; ///< flag telling if min = chi2 or min = max.likelyhood bool fChisq; ///< flag telling if min = chi2 or min = max.likelyhood
double fMin; ///< chi2 or max. likelyhood double fMin; ///< chi2 or max. likelyhood
unsigned int fNdf; ///< number of degrees of freedom unsigned int fNdf; ///< number of degrees of freedom

View File

@ -36,9 +36,15 @@
#include <TQObject.h> #include <TQObject.h>
#include <TCanvas.h> #include <TCanvas.h>
#include <TPaveText.h> #include <TPaveText.h>
#include <TLegend.h>
#include <TPad.h> #include <TPad.h>
#include <TH1F.h>
#include "PMusr.h" #include "PMusr.h"
#ifndef __MAKECINT__
#include "PMsrHandler.h"
#include "PRunListCollection.h"
#endif
#define YINFO 0.1 #define YINFO 0.1
#define YTITLE 0.95 #define YTITLE 0.95
@ -46,23 +52,27 @@
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
/** /**
* <p> * <p>The preprocessor tag __MAKECINT__ is used to hide away from rootcint
* the overly complex spirit header files.
*/ */
class PMusrCanvas : public TObject, public TQObject 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 int number, const char* title,
Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh,
const PIntVector markerList, const PIntVector colorList); const PIntVector markerList, const PIntVector colorList);
virtual ~PMusrCanvas(); virtual ~PMusrCanvas();
virtual Bool_t IsValid() { return fValid; } virtual Bool_t IsValid() { return fValid; }
virtual void SetParameterList(PMsrParamList &paramList); #ifndef __MAKECINT__
virtual void SetTheoryList(PMsrLines &theoryList); virtual void SetMsrHandler(PMsrHandler *msrHandler) { fMsrHandler = msrHandler; }
virtual void SetFunctionList(PMsrLines &functionList); virtual void SetRunListCollection(PRunListCollection *runList) { fRunList = runList; }
#endif
virtual void UpdateParamTheoryPad(); virtual void UpdateParamTheoryPad();
virtual void UpdateDataTheoryPad();
virtual void UpdateInfoPad(); virtual void UpdateInfoPad();
virtual void Done(Int_t status=0); // *SIGNAL* virtual void Done(Int_t status=0); // *SIGNAL*
@ -70,18 +80,22 @@ class PMusrCanvas : public TObject, public TQObject
private: private:
Bool_t fValid; Bool_t fValid;
Int_t fPlotNumber;
TCanvas *fMainCanvas; TCanvas *fMainCanvas;
TPaveText *fTitlePad; TPaveText *fTitlePad;
TPad *fDataTheoryPad; TPad *fDataTheoryPad;
TPaveText *fParameterTheoryPad; TPaveText *fParameterTheoryPad;
TPaveText *fInfoPad; TLegend *fInfoPad;
TPaveText *fKeyboardHandlerText; TPaveText *fKeyboardHandlerText;
PMsrParamList fParamList; #ifndef __MAKECINT__
PMsrLines fTheoryList; PMsrHandler *fMsrHandler;
PMsrLines fFunctionList; PRunListCollection *fRunList;
#endif
vector<TH1F*> fData;
PIntVector fMarkerList; PIntVector fMarkerList;
PIntVector fColorList; PIntVector fColorList;

View File

@ -41,7 +41,6 @@ using namespace std;
#include "PMsrHandler.h" #include "PMsrHandler.h"
#include "PRunDataHandler.h" #include "PRunDataHandler.h"
#include "PTheory.h" #include "PTheory.h"
//#include "PFunctions.h"
//------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------
/** /**
@ -70,6 +69,7 @@ class PRunBase
virtual void CalcTheory() = 0; // pure virtual, i.e. needs to be implemented by the deriving class!! virtual void CalcTheory() = 0; // pure virtual, i.e. needs to be implemented by the deriving class!!
virtual unsigned int GetRunNo() { return fRunNo; }
virtual PRunData* GetData() { return &fData; } virtual PRunData* GetData() { return &fData; }
virtual void CleanUp(); virtual void CleanUp();
virtual bool IsValid() { return fValid; } virtual bool IsValid() { return fValid; }
@ -77,7 +77,7 @@ class PRunBase
protected: protected:
bool fValid; bool fValid;
int fRunNo; ///< number of the run within the msr file unsigned int fRunNo; ///< number of the run within the msr file
PMsrHandler *fMsrInfo; ///< msr-file handler PMsrHandler *fMsrInfo; ///< msr-file handler
PMsrRunStructure *fRunInfo; ///< run info used to filter out needed infos for the run PMsrRunStructure *fRunInfo; ///< run info used to filter out needed infos for the run
PRunDataHandler *fRawData; ///< holds the raw run data PRunDataHandler *fRawData; ///< holds the raw run data

View File

@ -49,6 +49,8 @@ class PRunListCollection
PRunListCollection(PMsrHandler *msrInfo, PRunDataHandler *data); PRunListCollection(PMsrHandler *msrInfo, PRunDataHandler *data);
virtual ~PRunListCollection(); virtual ~PRunListCollection();
enum EDataSwitch { kIndex, kRunNo };
virtual bool Add(int runNo); virtual bool Add(int runNo);
virtual double GetSingleHistoChisq(const std::vector<double>& par); virtual double GetSingleHistoChisq(const std::vector<double>& par);
@ -68,10 +70,10 @@ class PRunListCollection
virtual unsigned int GetNoOfRRF() { return fRunRRFList.size(); } virtual unsigned int GetNoOfRRF() { return fRunRRFList.size(); }
virtual unsigned int GetNoOfNonMusr() { return fRunNonMusrList.size(); } virtual unsigned int GetNoOfNonMusr() { return fRunNonMusrList.size(); }
virtual PRunData* GetSingleHisto(unsigned int index); virtual PRunData* GetSingleHisto(unsigned int index, EDataSwitch tag=kIndex);
virtual PRunData* GetAsymmetry(unsigned int index); virtual PRunData* GetAsymmetry(unsigned int index, EDataSwitch tag=kIndex);
virtual PRunData* GetRRF(unsigned int index); virtual PRunData* GetRRF(unsigned int index, EDataSwitch tag=kIndex);
virtual PRunData* GetNonMusr(unsigned int index); virtual PRunData* GetNonMusr(unsigned int index, EDataSwitch tag=kIndex);
private: private:
PMsrHandler *fMsrInfo; ///< keeps all msr file info PMsrHandler *fMsrInfo; ///< keeps all msr file info

View File

@ -39,11 +39,11 @@
#include "PMsrHandler.h" #include "PMsrHandler.h"
#include <gsl_sf_hyperg.h> // #include <gsl_sf_hyperg.h>
//
extern "C" { // extern "C" {
double gsl_sf_hyperg_1F1(double a, double b, double x); // double gsl_sf_hyperg_1F1(double a, double b, double x);
} // }
// -------------------------------------------------------- // --------------------------------------------------------
// function handling tags // function handling tags

View File

@ -157,28 +157,60 @@ 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, vector<PMusrCanvas*> canvasVector;
startupHandler->GetMarkerList(), startupHandler->GetColorList()); PMusrCanvas *musrCanvas;
bool ok = true;
for (unsigned int i=0; i<msrHandler->GetMsrPlotList()->size(); i++) {
musrCanvas = new PMusrCanvas(i, msrHandler->GetMsrTitle()->Data(),
10+i*100, 10+i*100, 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;
return -1; ok = false;
break;
} }
musrCanvas->SetParameterList(*msrHandler->GetMsrParamList()); // ugly but rootcint cannot handle the spirit-parser framework
musrCanvas->SetTheoryList(*msrHandler->GetMsrTheory()); // musrCanvas->SetParamInfo(*msrHandler->GetMsrParamList());
musrCanvas->SetFunctionList(*msrHandler->GetMsrFunctions()); // musrCanvas->SetTheoryInfo(*msrHandler->GetMsrTheory());
// musrCanvas->SetFunctionsInfo(*msrHandler->GetMsrFunctions());
// musrCanvas->SetRunsInfo(*msrHandler->GetMsrRunList());
// musrCanvas->SetPlotInfo(msrHandler->GetMsrPlotList()->at(i));
// musrCanvas->SetStatisticsInfo(*msrHandler->GetMsrStatistic());
musrCanvas->SetMsrHandler(msrHandler);
musrCanvas->SetRunListCollection(runListCollection);
musrCanvas->UpdateParamTheoryPad(); musrCanvas->UpdateParamTheoryPad();
musrCanvas->UpdateDataTheoryPad();
musrCanvas->UpdateInfoPad();
if (!musrCanvas->IsValid()) { // something went wrong
ok = false;
break;
}
musrCanvas->Connect("Done(Int_t)", "TApplication", &app, "Terminate(Int_t)"); musrCanvas->Connect("Done(Int_t)", "TApplication", &app, "Terminate(Int_t)");
app.Run(); // keep musrCanvas objects
canvasVector.push_back(musrCanvas);
}
// check that everything is ok
if (ok)
app.Run(true); // true needed that Run will return after quit so that cleanup works
// clean up // clean up
if (musrCanvas) { cout << endl << "clean up canvas vector ...";
delete musrCanvas; for (unsigned int i=0; i<canvasVector.size(); i++) {
musrCanvas = 0; canvasVector[i]->~PMusrCanvas();
} }
canvasVector.empty();
} }
cout << endl;
// clean up // clean up
if (saxParser) { if (saxParser) {