From f4f6fcb058ba24efe7d403168b1efb851637be87 Mon Sep 17 00:00:00 2001 From: nemu Date: Fri, 4 Apr 2008 14:29:56 +0000 Subject: [PATCH] some more steps toward musrview --- src/Makefile.musrfit | 9 +- src/Makefile.musrview | 10 +- src/classes/Makefile.PMusr | 6 +- src/classes/PMsrHandler.cpp | 74 ++++++++-- src/classes/PMusrCanvas.cpp | 218 +++++++++++++++++------------ src/classes/PRunListCollection.cpp | 106 +++++++++++--- src/classes/PTheory.cpp | 9 +- src/include/PMusr.h | 1 + src/include/PMusrCanvas.h | 36 +++-- src/include/PRunBase.h | 4 +- src/include/PRunListCollection.h | 10 +- src/include/PTheory.h | 10 +- src/musrview.cpp | 64 ++++++--- 13 files changed, 385 insertions(+), 172 deletions(-) diff --git a/src/Makefile.musrfit b/src/Makefile.musrfit index 33492a91..fe562799 100644 --- a/src/Makefile.musrfit +++ b/src/Makefile.musrfit @@ -37,8 +37,7 @@ CXX = g++ CXXFLAGS = -g -Wall -fPIC PMUSRPATH = ./include MNPATH = $(ROOTSYS)/include -GSLPATH = /usr/include/gsl -INCLUDES = -I $(PMUSRPATH) -I $(MNPATH) -I $(GSLPATH) +INCLUDES = -I $(PMUSRPATH) -I $(MNPATH) LD = g++ LDFLAGS = -g endif @@ -64,8 +63,8 @@ GLIBS = $(ROOTGLIBS) -lXMLParser PSILIBS = -lTLemRunHeader -lPMusr # Minuit2 lib MNLIB = -L$(ROOTSYS)/lib -lMinuit2 -# GSL lib -GSLLIB = -lgslcblas -lgsl +# MathMore lib +MMLIB = -L$(ROOTSYS)/lib -lMathMore EXEC = musrfit @@ -81,7 +80,7 @@ all: $(EXEC) $(EXEC): $(OBJS) @echo "---> Building $(EXEC) ..." /bin/rm -f $(SHLIB) - $(LD) $(OBJS) -o $(EXEC) $(GLIBS) $(PSILIBS) $(MNLIB) $(GSLLIB) + $(LD) $(OBJS) -o $(EXEC) $(GLIBS) $(PSILIBS) $(MNLIB) $(MMLIB) @echo "done" # clean up: remove all object file (and core files) diff --git a/src/Makefile.musrview b/src/Makefile.musrview index a60e91dc..fcd9f171 100644 --- a/src/Makefile.musrview +++ b/src/Makefile.musrview @@ -37,8 +37,8 @@ CXX = g++ CXXFLAGS = -g -Wall -fPIC PMUSRPATH = ./include MNPATH = $(ROOTSYS)/include -GSLPATH = /usr/include/gsl -INCLUDES = -I $(PMUSRPATH) -I $(MNPATH) -I $(GSLPATH) +#GSLPATH = /usr/include/gsl +INCLUDES = -I $(PMUSRPATH) -I $(MNPATH) LD = g++ LDFLAGS = -g endif @@ -64,8 +64,8 @@ GLIBS = $(ROOTGLIBS) -lXMLParser PSILIBS = -lTLemRunHeader -lPMusr # Minuit2 lib MNLIB = -L$(ROOTSYS)/lib -lMinuit2 -# GSL lib -GSLLIB = -lgslcblas -lgsl +# MathMore lib +MMLIB = -L$(ROOTSYS)/lib -lMathMore EXEC = musrview @@ -81,7 +81,7 @@ all: $(EXEC) $(EXEC): $(OBJS) @echo "---> Building $(EXEC) ..." /bin/rm -f $(SHLIB) - $(LD) $(OBJS) -o $(EXEC) $(GLIBS) $(PSILIBS) $(MNLIB) $(GSLLIB) + $(LD) $(OBJS) -o $(EXEC) $(GLIBS) $(PSILIBS) $(MNLIB) $(MMLIB) @echo "done" # clean up: remove all object file (and core files) diff --git a/src/classes/Makefile.PMusr b/src/classes/Makefile.PMusr index 36def6e5..599792cf 100644 --- a/src/classes/Makefile.PMusr +++ b/src/classes/Makefile.PMusr @@ -40,7 +40,7 @@ endif # -- Linux ifeq ($(OS),LINUX) CXX = g++ -CXXFLAGS = -g -Wall -fPIC +CXXFLAGS = -g -Wall -Wno-trigraphs -fPIC PMUSRPATH = ../include MNPATH = $(ROOTSYS)/include GSLPATH = /usr/include/gsl @@ -53,7 +53,7 @@ endif # -- Darwin ifeq ($(OS),DARWIN) CXX = g++ -CXXFLAGS = -g -Wall -fPIC +CXXFLAGS = -g -Wall -Wno-trigraphs -fPIC INCLUDES = -I../include LD = g++ LDFLAGS = -g @@ -123,7 +123,7 @@ PStartupHandlerDict.cpp: ../include/PStartupHandler.h PMusrCanvasDict.cpp: ../include/PMusrCanvas.h @echo "Generating dictionary $@..." - rootcint -f $@ -c -p $^ + rootcint -v -f $@ -c -p $^ install: all @echo "Installing shared lib: libPMusr.so ( you must be root ;-) )" diff --git a/src/classes/PMsrHandler.cpp b/src/classes/PMsrHandler.cpp index d5655858..fb1bf86f 100644 --- a/src/classes/PMsrHandler.cpp +++ b/src/classes/PMsrHandler.cpp @@ -608,18 +608,18 @@ int PMsrHandler::WriteMsrLogFile() // create the new statistics block PMsrLineStructure line; if (fStatistic.fChisq) { // chi^2 - line.fLine = " chi2 = "; + line.fLine = " chisq = "; line.fLine += fStatistic.fMin; line.fLine += ", NDF = "; line.fLine += fStatistic.fNdf; - line.fLine += ", chi2r = chi2/NDF = "; + line.fLine += ", chisq/NDF = "; line.fLine += fStatistic.fMin / fStatistic.fNdf; } else { line.fLine = " maxLH = "; line.fLine += fStatistic.fMin; line.fLine += ", NDF = "; line.fLine += fStatistic.fNdf; - line.fLine += ", maxLHr = maxLH/NDF = "; + line.fLine += ", maxLH/NDF = "; line.fLine += fStatistic.fMin / fStatistic.fNdf; } fStatistic.fStatLines.push_back(line); @@ -1818,18 +1818,76 @@ bool PMsrHandler::HandlePlotEntry(PMsrLines &lines) */ bool PMsrHandler::HandleStatisticEntry(PMsrLines &lines) { - PMsrLines::iterator iter; - if (lines.empty()) { cout << endl << "WARNING: There is no STATISTIC block! Do you really want this?"; cout << endl; + return false; } - for (iter = lines.begin(); iter != lines.end(); ++iter) { - if (!iter->fLine.BeginsWith("STATISTIC")) - fStatistic.fStatLines.push_back(*iter); + char str[128]; + char date[128]; + char time[128]; + int status; + double dval; + unsigned int ival; + for (unsigned int i=0; iAddText(" 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 fDataTheoryPad->cd(); @@ -152,13 +151,13 @@ cout << "fMainCanvas = " << fMainCanvas << endl; fMainCanvas->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", "PMusrCanvas", this, "HandleCmdKey(Int_t,Int_t,Int_t,TObject*)"); -cout << "this " << this << endl; -cout << "fMainCanvas " << fMainCanvas << endl; -cout << "fTitlePad " << fTitlePad << endl; -cout << "fDataTheoryPad " << fDataTheoryPad << endl; -cout << "fParameterTheoryPad " << fParameterTheoryPad << endl; -cout << "fInfoPad " << fInfoPad << endl; -cout << "fKeyboardHandlerText " << fKeyboardHandlerText << endl; +// cout << "this " << this << endl; +// cout << "fMainCanvas " << fMainCanvas << endl; +// cout << "fTitlePad " << fTitlePad << endl; +// cout << "fDataTheoryPad " << fDataTheoryPad << endl; +// cout << "fParameterTheoryPad " << fParameterTheoryPad << endl; +// cout << "fInfoPad " << fInfoPad << endl; +// cout << "fKeyboardHandlerText " << fKeyboardHandlerText << endl; } @@ -170,6 +169,7 @@ cout << "fKeyboardHandlerText " << fKeyboardHandlerText << endl; */ PMusrCanvas::~PMusrCanvas() { +cout << "~PMusrCanvas() called" << endl; // cleanup if (fKeyboardHandlerText) { delete fKeyboardHandlerText; @@ -221,11 +221,11 @@ void PMusrCanvas::HandleCmdKey(Int_t event, Int_t x, Int_t y, TObject *selected) if (event != kKeyPress) return; - cout << ">this " << this << endl; - cout << ">fMainCanvas " << fMainCanvas << endl; - cout << ">selected " << selected << endl; - - cout << "px: " << (char)fMainCanvas->GetEventX() << endl; +// cout << ">this " << this << endl; +// cout << ">fMainCanvas " << fMainCanvas << endl; +// cout << ">selected " << selected << endl; +// +// cout << "px: " << (char)fMainCanvas->GetEventX() << endl; TString str((Char_t)x); if (x == 'q') { @@ -244,45 +244,6 @@ void PMusrCanvas::HandleCmdKey(Int_t event, Int_t x, Int_t y, TObject *selected) } } -//-------------------------------------------------------------------------- -// SetParameterList -//-------------------------------------------------------------------------- -/** - *

- * - * \param paramList - */ -void PMusrCanvas::SetParameterList(PMsrParamList ¶mList) -{ - fParamList = paramList; -} - -//-------------------------------------------------------------------------- -// SetTheoryList -//-------------------------------------------------------------------------- -/** - *

- * - * \param theoryList - */ -void PMusrCanvas::SetTheoryList(PMsrLines &theoryList) -{ - fTheoryList = theoryList; -} - -//-------------------------------------------------------------------------- -// SetFunctionList -//-------------------------------------------------------------------------- -/** - *

- * - * \param functionList - */ -void PMusrCanvas::SetFunctionList(PMsrLines &functionList) -{ - fFunctionList = functionList; -} - //-------------------------------------------------------------------------- // UpdateParamTheoryPad //-------------------------------------------------------------------------- @@ -291,6 +252,9 @@ void PMusrCanvas::SetFunctionList(PMsrLines &functionList) */ void PMusrCanvas::UpdateParamTheoryPad() { + if (!fValid) + return; + TString str; char cnum[128]; int maxLength = 0; @@ -298,52 +262,54 @@ void PMusrCanvas::UpdateParamTheoryPad() int idx; // add parameters ------------------------------------------------------------ + PMsrParamList param = *fMsrHandler->GetMsrParamList(); + // get maximal parameter name string length - for (unsigned int i=0; i maxLength) - maxLength = fParamList[i].fName.Length(); + for (unsigned int i=0; i maxLength) + maxLength = param[i].fName.Length(); } maxLength += 2; // add parameters to the pad - for (unsigned int i=0; iGetMsrTheory(); + for (unsigned int i=1; i 0) { // comment present str.Resize(idx-1); @@ -366,9 +333,10 @@ void PMusrCanvas::UpdateParamTheoryPad() // add functions -------------------------------------------------------- ypos -= 0.025; - for (unsigned int i=1; iGetMsrFunctions(); + for (unsigned int i=1; iAddText(0.03, ypos, fFunctionList[i].fLine.Data()); + fParameterTheoryPad->AddText(0.03, ypos, functions[i].fLine.Data()); } fParameterTheoryPad->Draw(); @@ -376,6 +344,44 @@ void PMusrCanvas::UpdateParamTheoryPad() fMainCanvas->Update(); } +//-------------------------------------------------------------------------- +// UpdateDataTheoryPad +//-------------------------------------------------------------------------- +/** + *

+ */ +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 (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; iGetMsrStatistic(); + TString tstr, tsubstr; + + tstr = "musrfit: "; + + // get fit date + tstr += statistic.fDate; + tstr += TString(", "); + // 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 + + fInfoPad->Draw(); + fMainCanvas->cd(); + fMainCanvas->Update(); } diff --git a/src/classes/PRunListCollection.cpp b/src/classes/PRunListCollection.cpp index fdc99923..e299427a 100644 --- a/src/classes/PRunListCollection.cpp +++ b/src/classes/PRunListCollection.cpp @@ -40,7 +40,7 @@ *

* * \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) { @@ -292,16 +292,34 @@ unsigned int PRunListCollection::GetTotalNoOfBinsFitted() *

* * \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) { - if ((index < 0) || (index > fRunSingleHistoList.size())) { - cout << endl << "PRunListCollection::GetSingleHisto: index = " << index << " out of bounds"; - return 0; - } + PRunData *data = 0; - fRunSingleHistoList[index]->CalcTheory(); - PRunData *data = fRunSingleHistoList[index]->GetData(); + switch (tag) { + case kIndex: + if ((index < 0) || (index > fRunSingleHistoList.size())) { + cout << endl << "PRunListCollection::GetSingleHisto: index = " << index << " out of bounds"; + return 0; + } + + fRunSingleHistoList[index]->CalcTheory(); + data = fRunSingleHistoList[index]->GetData(); + break; + case kRunNo: + for (unsigned int i=0; iGetRunNo() == index) { + data = fRunSingleHistoList[i]->GetData(); + break; + } + } + break; + default: // error + return 0; + break; + } return data; } @@ -313,16 +331,34 @@ PRunData* PRunListCollection::GetSingleHisto(unsigned int 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) { - if ((index < 0) || (index > fRunAsymmetryList.size())) { - cout << endl << "PRunListCollection::GetAsymmetry: index = " << index << " out of bounds"; - return 0; - } + PRunData *data = 0; - fRunAsymmetryList[index]->CalcTheory(); - PRunData *data = fRunAsymmetryList[index]->GetData(); + switch (tag) { + case kIndex: + if ((index < 0) || (index > fRunAsymmetryList.size())) { + cout << endl << "PRunListCollection::GetAsymmetry: index = " << index << " out of bounds"; + return 0; + } + + fRunAsymmetryList[index]->CalcTheory(); + data = fRunAsymmetryList[index]->GetData(); + break; + case kRunNo: + for (unsigned int i=0; iGetRunNo() == index) { + data = fRunAsymmetryList[i]->GetData(); + break; + } + } + break; + default: // error + return 0; + break; + } return data; } @@ -334,12 +370,24 @@ PRunData* PRunListCollection::GetAsymmetry(unsigned int 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) { - if ((index < 0) || (index > fRunRRFList.size())) { - cout << endl << "PRunListCollection::GetRRF: index = " << index << " out of bounds"; - return 0; + PRunData *data = 0; + + switch (tag) { + case kIndex: + if ((index < 0) || (index > fRunRRFList.size())) { + cout << endl << "PRunListCollection::GetRRF: index = " << index << " out of bounds"; + return 0; + } + break; + case kRunNo: + break; + default: // error + return 0; + break; } return 0; @@ -352,12 +400,24 @@ PRunData* PRunListCollection::GetRRF(unsigned int 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) { - if ((index < 0) || (index > fRunNonMusrList.size())) { - cout << endl << "PRunListCollection::GetNonMusr: index = " << index << " out of bounds"; - return 0; + PRunData *data = 0; + + switch (tag) { + case kIndex: + if ((index < 0) || (index > fRunNonMusrList.size())) { + cout << endl << "PRunListCollection::GetNonMusr: index = " << index << " out of bounds"; + return 0; + } + break; + case kRunNo: + break; + default: // error + return 0; + break; } return 0; diff --git a/src/classes/PTheory.cpp b/src/classes/PTheory.cpp index 3251e8ca..88ee94d3 100644 --- a/src/classes/PTheory.cpp +++ b/src/classes/PTheory.cpp @@ -39,6 +39,8 @@ using namespace std; #include #include +#include + #include "PMsrHandler.h" #include "PTheory.h" @@ -1074,9 +1076,12 @@ double PTheory::SkewedGauss(register double t, const vector& paramValues else if (val[2] == val[3]) // sigma+ == sigma- -> Gaussian skg = TMath::Cos(phase+freq*t) * gp; 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) + - 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)); + 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*ROOT::Math::conf_hyperg(0.5,1.5,zp*zp)); return skg; } diff --git a/src/include/PMusr.h b/src/include/PMusr.h index 91ae6ccd..50e9eed6 100644 --- a/src/include/PMusr.h +++ b/src/include/PMusr.h @@ -251,6 +251,7 @@ typedef vector PMsrPlotList; */ typedef struct { PMsrLines fStatLines; + TString fDate; ///< string holding fitting date and time bool fChisq; ///< flag telling if min = chi2 or min = max.likelyhood double fMin; ///< chi2 or max. likelyhood unsigned int fNdf; ///< number of degrees of freedom diff --git a/src/include/PMusrCanvas.h b/src/include/PMusrCanvas.h index d3f236db..df887c90 100644 --- a/src/include/PMusrCanvas.h +++ b/src/include/PMusrCanvas.h @@ -36,9 +36,15 @@ #include #include #include +#include #include +#include #include "PMusr.h" +#ifndef __MAKECINT__ +#include "PMsrHandler.h" +#include "PRunListCollection.h" +#endif #define YINFO 0.1 #define YTITLE 0.95 @@ -46,23 +52,27 @@ //-------------------------------------------------------------------------- /** - *

+ *

The preprocessor tag __MAKECINT__ is used to hide away from rootcint + * the overly complex spirit header files. */ 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 int number, 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; } - virtual void SetParameterList(PMsrParamList ¶mList); - virtual void SetTheoryList(PMsrLines &theoryList); - virtual void SetFunctionList(PMsrLines &functionList); +#ifndef __MAKECINT__ + virtual void SetMsrHandler(PMsrHandler *msrHandler) { fMsrHandler = msrHandler; } + virtual void SetRunListCollection(PRunListCollection *runList) { fRunList = runList; } +#endif virtual void UpdateParamTheoryPad(); + virtual void UpdateDataTheoryPad(); virtual void UpdateInfoPad(); virtual void Done(Int_t status=0); // *SIGNAL* @@ -70,21 +80,25 @@ class PMusrCanvas : public TObject, public TQObject private: Bool_t fValid; + Int_t fPlotNumber; TCanvas *fMainCanvas; TPaveText *fTitlePad; TPad *fDataTheoryPad; TPaveText *fParameterTheoryPad; - TPaveText *fInfoPad; + TLegend *fInfoPad; TPaveText *fKeyboardHandlerText; - PMsrParamList fParamList; - PMsrLines fTheoryList; - PMsrLines fFunctionList; +#ifndef __MAKECINT__ + PMsrHandler *fMsrHandler; + PRunListCollection *fRunList; +#endif - PIntVector fMarkerList; - PIntVector fColorList; + vector fData; + + PIntVector fMarkerList; + PIntVector fColorList; ClassDef(PMusrCanvas, 1) }; diff --git a/src/include/PRunBase.h b/src/include/PRunBase.h index c8f1837d..d192e854 100644 --- a/src/include/PRunBase.h +++ b/src/include/PRunBase.h @@ -41,7 +41,6 @@ using namespace std; #include "PMsrHandler.h" #include "PRunDataHandler.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 unsigned int GetRunNo() { return fRunNo; } virtual PRunData* GetData() { return &fData; } virtual void CleanUp(); virtual bool IsValid() { return fValid; } @@ -77,7 +77,7 @@ class PRunBase protected: 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 PMsrRunStructure *fRunInfo; ///< run info used to filter out needed infos for the run PRunDataHandler *fRawData; ///< holds the raw run data diff --git a/src/include/PRunListCollection.h b/src/include/PRunListCollection.h index d6ff5c2d..e6177357 100644 --- a/src/include/PRunListCollection.h +++ b/src/include/PRunListCollection.h @@ -49,6 +49,8 @@ class PRunListCollection PRunListCollection(PMsrHandler *msrInfo, PRunDataHandler *data); virtual ~PRunListCollection(); + enum EDataSwitch { kIndex, kRunNo }; + virtual bool Add(int runNo); virtual double GetSingleHistoChisq(const std::vector& par); @@ -68,10 +70,10 @@ class PRunListCollection virtual unsigned int GetNoOfRRF() { return fRunRRFList.size(); } virtual unsigned int GetNoOfNonMusr() { return fRunNonMusrList.size(); } - virtual PRunData* GetSingleHisto(unsigned int index); - virtual PRunData* GetAsymmetry(unsigned int index); - virtual PRunData* GetRRF(unsigned int index); - virtual PRunData* GetNonMusr(unsigned int index); + virtual PRunData* GetSingleHisto(unsigned int index, EDataSwitch tag=kIndex); + virtual PRunData* GetAsymmetry(unsigned int index, EDataSwitch tag=kIndex); + virtual PRunData* GetRRF(unsigned int index, EDataSwitch tag=kIndex); + virtual PRunData* GetNonMusr(unsigned int index, EDataSwitch tag=kIndex); private: PMsrHandler *fMsrInfo; ///< keeps all msr file info diff --git a/src/include/PTheory.h b/src/include/PTheory.h index e408b4f1..70bc8d52 100644 --- a/src/include/PTheory.h +++ b/src/include/PTheory.h @@ -39,11 +39,11 @@ #include "PMsrHandler.h" -#include - -extern "C" { - double gsl_sf_hyperg_1F1(double a, double b, double x); -} +// #include +// +// extern "C" { +// double gsl_sf_hyperg_1F1(double a, double b, double x); +// } // -------------------------------------------------------- // function handling tags diff --git a/src/musrview.cpp b/src/musrview.cpp index 7c690cc6..c22c73f2 100644 --- a/src/musrview.cpp +++ b/src/musrview.cpp @@ -157,28 +157,60 @@ 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, - startupHandler->GetMarkerList(), startupHandler->GetColorList()); - if (!musrCanvas->IsValid()) { - cout << endl << "**SEVERE ERROR** Couldn't invoke all necessary objects, will quit."; - cout << endl; - return -1; + vector canvasVector; + PMusrCanvas *musrCanvas; + + bool ok = true; + for (unsigned int i=0; iGetMsrPlotList()->size(); i++) { + + musrCanvas = new PMusrCanvas(i, msrHandler->GetMsrTitle()->Data(), + 10+i*100, 10+i*100, 800, 600, + startupHandler->GetMarkerList(), + startupHandler->GetColorList()); + if (!musrCanvas->IsValid()) { + cout << endl << "**SEVERE ERROR** Couldn't invoke all necessary objects, will quit."; + cout << endl; + ok = false; + break; + } + // ugly but rootcint cannot handle the spirit-parser framework +// musrCanvas->SetParamInfo(*msrHandler->GetMsrParamList()); +// 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->UpdateDataTheoryPad(); + musrCanvas->UpdateInfoPad(); + + if (!musrCanvas->IsValid()) { // something went wrong + ok = false; + break; + } + + musrCanvas->Connect("Done(Int_t)", "TApplication", &app, "Terminate(Int_t)"); + + // keep musrCanvas objects + canvasVector.push_back(musrCanvas); } - 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(); + // check that everything is ok + if (ok) + app.Run(true); // true needed that Run will return after quit so that cleanup works // clean up - if (musrCanvas) { - delete musrCanvas; - musrCanvas = 0; +cout << endl << "clean up canvas vector ..."; + for (unsigned int i=0; i~PMusrCanvas(); } + canvasVector.empty(); } +cout << endl; // clean up if (saxParser) {