The difficulty I’m having is in knowing how to treat roo variables similarly or differently from standard c++ ones. As objects they could all be deleted and reinstanced everytime, but is this needed?
The following code seems to loose context and other necessary info to compile and I’m unable to discern what to change.
The code below is a paired down version, which attempts to get the roo part working first. I’ve already got the gui working.
The main goal is to get my roovars initialized and scoping properly.
Thanks,
Dave
[code]// rooInit.C
#include <TGClient.h>
#include <TGFrame.h>
#include “TMath.h”
#include “TCanvas.h”
#include “TF1.h”
#include “RooRealVar.h”
#include “RooGaussian.h”
#include <RQ_OBJECT.h>
class MyMainFrame {
RQ_OBJECT(“MyMainFrame”)
private:
TGMainFrame *fMain;
TGCompositeFrame *cframe2;
// — Observables —
UInt_t xsig;
UInt_t xmean;
UInt_t rmin;
UInt_t rmx;
// — Observables —
RooRealVar sigmes();
RooRealVar qdcmes();
RooRealVar x();
RooRealVar mean();
RooRealVar sigma();
public:
MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h);
virtual ~MyMainFrame();
void MyVars(UInt_t xmean, UInt_t xsig, UInt_t rmin, UInt_t rmx);
void MyGauss(UInt_t xmean, UInt_t xsig, UInt_t rmin, UInt_t rmx);
ClassDef(MyMainFrame, 0)
};
MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h)
{
// Create a main frame
fMain = new TGMainFrame(p, w, h, kFitWidth | kFitHeight); // p,w,h connected?
cframe2 = new TGCompositeFrame(fMain,50,50, kVerticalFrame | kLHintsLeft); // ineffective
// Create buttons and inputs with calls to MyGauss();
fMain->AddFrame(cframe2, new TGLayoutHints(kLHintsExpandX, 20, 20, 5, 5));
fMain->SetWindowName(“rooInit”);
TGDimension size = fMain->GetDefaultSize();
fMain->Resize(size);
fMain->MapSubwindows();
fMain->Resize(fMain->GetDefaultSize());
fMain->MapWindow();
}
MyMainFrame::~MyMainFrame()
{
// Clean up all widgets, frames and layouthints that were used
fMain->Cleanup();
delete fMain;
}
void MyMainFrame::MyGauss(UInt_t xmean,UInt_t xsig,UInt_t rmin,UInt_t rmx)
{
// — Observables —
x.setRange(rmin,rmx);
mean.setVal(xmean);
sigma.setVal(xsig);
RooGaussian gauss(“gauss”,“gauss(x,mean,sigma)”,x,mean,sigma);
RooDataSet *data = gauss.generate(x,10000); // deletes every time
xframe=x.frame();
data->plotOn(xframe);
xframe->Draw();
delete data;
delete gauss;
}
void rooInit(){
// Test fit of a single Gaussian
gSystem->Load(“libRooFit”);
using namespace RooFit;
RooTrace::active(1);
// Popup the GUI
new MyMainFrame(gClient->GetRoot(),300,300);
MyMainFrame::MyGauss(2000,50,100,4000);
}[/code]