diff --git a/src/classes/Makefile.PMusr b/src/classes/Makefile.PMusr index 30a54bbc..66d8b34d 100644 --- a/src/classes/Makefile.PMusr +++ b/src/classes/Makefile.PMusr @@ -76,23 +76,24 @@ MNLIB = -L$(ROOTSYS)/lib -lMinuit2 GSLLIB = -lgslcblas -lgsl -# some definitions: headers, sources, objects,... +# some definitions: headers (used to generate *Dict* stuff), sources, objects,... HEADERS = -HEADERS += PStartupHandler.h -HEADERS += PMsrHandler.h -HEADERS += PRunDataHandler.h -HEADERS += PFunctionHandler.h -HEADERS += PFunctionGrammar.h -HEADERS += PFunction.h -HEADERS += PRunBase.h -HEADERS += PRunSingleHisto.h -HEADERS += PRunAsymmetry.h -HEADERS += PRunRRF.h -HEADERS += PRunNonMusr.h -HEADERS += PRunListCollection.h -HEADERS += PTheory.h -HEADERS += PFitterFcn.h -HEADERS += PFitter.h +# HEADERS += PStartupHandler.h +# HEADERS += PMsrHandler.h +# HEADERS += PRunDataHandler.h +# HEADERS += PFunctionHandler.h +# HEADERS += PFunctionGrammar.h +# HEADERS += PFunction.h +# HEADERS += PRunBase.h +# HEADERS += PRunSingleHisto.h +# HEADERS += PRunAsymmetry.h +# HEADERS += PRunRRF.h +# HEADERS += PRunNonMusr.h +# HEADERS += PRunListCollection.h +# HEADERS += PTheory.h +# HEADERS += PFitterFcn.h +# HEADERS += PFitter.h +HEADERS += ../include/PMusrCanvas.h OBJS = OBJS += PStartupHandler.o @@ -109,6 +110,10 @@ OBJS += PRunListCollection.o OBJS += PTheory.o OBJS += PFitterFcn.o OBJS += PFitter.o +OBJS += PMusrCanvas.o PMusrCanvasDict.o + +DICT = +DICT += PMusrCanvasDict.cpp SHLIB = libPMusr.so @@ -133,6 +138,10 @@ clean:; @rm -f $(OBJS) *Dict* core* $(OBJS): %.o: %.cpp $(CXX) $(INCLUDES) $(CXXFLAGS) -c $< +$(DICT): $(HEADERS) + @echo "Generating dictionary files" + rootcint -f $@ -c $^ + install: all @echo "Installing shared lib: libPMusr.so ( you must be root ;-) )" ifeq ($(OS),LINUX) diff --git a/src/classes/PMusrCanvas.cpp b/src/classes/PMusrCanvas.cpp new file mode 100644 index 00000000..f3f62bb5 --- /dev/null +++ b/src/classes/PMusrCanvas.cpp @@ -0,0 +1,259 @@ +/*************************************************************************** + + PMusrCanvas.cpp + + Author: Andreas Suter + e-mail: andreas.suter@psi.ch + + $Id$ + +***************************************************************************/ + +/*************************************************************************** + * Copyright (C) 2007 by Andreas Suter * + * andreas.suter@psi.ch * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include +using namespace std; + +#include + +#include "PMusrCanvas.h" + +ClassImpQ(PMusrCanvas) + +//-------------------------------------------------------------------------- +// Constructor +//-------------------------------------------------------------------------- +/** + * + */ +PMusrCanvas::PMusrCanvas() +{ + fValid = false; + + fMainCanvas = 0; + fTitlePad = 0; + fDataTheoryPad = 0; + fParameterTheoryPad = 0; + fInfoPad = 0; + fKeyboardHandlerText = 0; +} + +//-------------------------------------------------------------------------- +// Constructor +//-------------------------------------------------------------------------- +/** + * + */ +PMusrCanvas::PMusrCanvas(const char* title, Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh) +{ + fValid = false; + + fMainCanvas = 0; + fTitlePad = 0; + fDataTheoryPad = 0; + fParameterTheoryPad = 0; + fInfoPad = 0; + fKeyboardHandlerText = 0; + + // invoke canvas + fMainCanvas = new TCanvas("fMainCanvas", title, wtopx, wtopy, ww, wh); +cout << "fMainCanvas = " << fMainCanvas << endl; + if (fMainCanvas == 0) { + cout << endl << "PMusrCanvas::PMusrCanvas: **PANIC ERROR**: Couldn't invoke fMainCanvas"; + cout << endl; + return; + } + + // divide the canvas into 4 pads + // title pad + fTitlePad = new TPaveText(0.0, YTITLE, 1.0, 1.0, "NDC"); + if (fTitlePad == 0) { + cout << endl << "PMusrCanvas::PMusrCanvas: **PANIC ERROR**: Couldn't invoke fTitlePad"; + cout << endl; + return; + } + fTitlePad->SetFillColor(TColor::GetColor(255,255,255)); + fTitlePad->SetTextAlign(12); // middle, left + fTitlePad->AddText("This is a title, this is a title, this is a title, this is a title, ..."); + fTitlePad->Draw(); + + // data/theory pad + fDataTheoryPad = new TPad("dataTheoryPad", "dataTheoryPad", 0.0, YINFO, XTHEO-0.02, YTITLE); + fDataTheoryPad = new TPad("dataTheoryPad", "dataTheoryPad", 0.0, YINFO, XTHEO, YTITLE); + if (fDataTheoryPad == 0) { + cout << endl << "PMusrCanvas::PMusrCanvas: **PANIC ERROR**: Couldn't invoke fDataTheoryPad"; + cout << endl; + return; + } + fDataTheoryPad->SetFillColor(TColor::GetColor(255,255,255)); + fDataTheoryPad->Draw(); + + // parameter/theory pad + fParameterTheoryPad = new TPaveText(XTHEO, 0.1, 1.0, YTITLE, "NDC"); + if (fParameterTheoryPad == 0) { + cout << endl << "PMusrCanvas::PMusrCanvas: **PANIC ERROR**: Couldn't invoke fParameterTheoryPad"; + cout << endl; + return; + } + fParameterTheoryPad->SetFillColor(TColor::GetColor(255,255,255)); + fParameterTheoryPad->SetTextAlign(13); // top, left + fParameterTheoryPad->SetTextFont(102); // courier bold, scalable so that greek parameters will be plotted properly + fParameterTheoryPad->AddText("parameter/theory pad ..."); + fParameterTheoryPad->AddText("1 alphaLR 0.9157 0.01075"); + fParameterTheoryPad->AddText("2 alphaTB 0.8777 0.007409"); + fParameterTheoryPad->AddText("3 asyS 0.1555 0.004631"); + fParameterTheoryPad->AddText("4 lambdaS 0.06726 0.01466"); + fParameterTheoryPad->AddText("5 field 7.444 0.1995"); + fParameterTheoryPad->AddText("6 phaseLR 18.3 4.1"); + fParameterTheoryPad->AddText("7 phaseTB -83.1 2.1"); + fParameterTheoryPad->AddText(" "); + fParameterTheoryPad->AddText("asymmetry 3"); + fParameterTheoryPad->AddText("simplExpo 4 (#lambda)"); + fParameterTheoryPad->AddText("TFieldCos map1 fun1 (#phi #nu)"); + fParameterTheoryPad->AddText(" "); + fParameterTheoryPad->AddText("fun1 = par5 * 0.01355"); + fParameterTheoryPad->Draw(); + + // info pad + fInfoPad = new TPaveText(0.0, 0.0, 1.0, YINFO, "NDC"); + if (fInfoPad == 0) { + cout << endl << "PMusrCanvas::PMusrCanvas: **PANIC ERROR**: Couldn't invoke fInfoPad"; + cout << endl; + return; + } + fInfoPad->SetFillColor(TColor::GetColor(255,255,255)); + 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 + fDataTheoryPad->cd(); + fKeyboardHandlerText = new TPaveText(0.1, 0.1, 0.3, 0.2, "rb"); + if (fKeyboardHandlerText == 0) { + cout << endl << "PMusrCanvas::PMusrCanvas: **PANIC ERROR**: Couldn't invoke fKeyboardHandlerText"; + cout << endl; + return; + } + fKeyboardHandlerText->AddText("none"); + fKeyboardHandlerText->Draw(); + fDataTheoryPad->Modified(); + + fValid = true; + + fMainCanvas->cd(); + fMainCanvas->Show(); + 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; + +} + +//-------------------------------------------------------------------------- +// Destructor +//-------------------------------------------------------------------------- +/** + * + */ +PMusrCanvas::~PMusrCanvas() +{ + // 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; + } +} + +//-------------------------------------------------------------------------- +// Done (SIGNAL) +//-------------------------------------------------------------------------- +/** + *

+ * + */ +void PMusrCanvas::Done(Int_t status) +{ + Emit("Done(Int_t)", status); +} + +//-------------------------------------------------------------------------- +// HandleCmdKey (SLOT) +//-------------------------------------------------------------------------- +/** + *

+ * + */ +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; + + TString str((Char_t)x); + if (x == 'q') { + Done(0); + } else { + if (fKeyboardHandlerText) { + fDataTheoryPad->cd(); + delete fKeyboardHandlerText; + fKeyboardHandlerText = 0; + fKeyboardHandlerText = new TPaveText(0.1, 0.1, 0.3, 0.2, "rb"); + fKeyboardHandlerText->AddText(str.Data()); + fKeyboardHandlerText->Draw(); + fMainCanvas->cd(); + } + fMainCanvas->Update(); + } +} diff --git a/src/classes/PRunAsymmetry.cpp b/src/classes/PRunAsymmetry.cpp index 6e9c6302..21ba1a04 100644 --- a/src/classes/PRunAsymmetry.cpp +++ b/src/classes/PRunAsymmetry.cpp @@ -371,7 +371,7 @@ bool PRunAsymmetry::PrepareData() // first get start data, end data, and t0 unsigned int start[2] = {fRunInfo->fDataRange[0], fRunInfo->fDataRange[2]}; unsigned int end[2] = {fRunInfo->fDataRange[1], fRunInfo->fDataRange[3]}; - unsigned int t0[2] = {fT0s[0], fT0s[1]}; + double t0[2] = {fT0s[0], fT0s[1]}; // check if start, end, and t0 make any sense // 1st check if start and end are in proper order for (unsigned int i=0; i<2; i++) { diff --git a/src/classes/PRunSingleHisto.cpp b/src/classes/PRunSingleHisto.cpp index 0ef56970..1a1ea820 100644 --- a/src/classes/PRunSingleHisto.cpp +++ b/src/classes/PRunSingleHisto.cpp @@ -333,7 +333,7 @@ bool PRunSingleHisto::PrepareData() // first get start data, end data, and t0 unsigned int start = fRunInfo->fDataRange[0]; unsigned int end = fRunInfo->fDataRange[1]; - unsigned int t0 = fT0s[0]; + double t0 = fT0s[0]; // check if start, end, and t0 make any sense // 1st check if start and end are in proper order if (end < start) { // need to swap them