Problem of dependence

Hi everyone,

I’m new using Roofit.
I want to use data from an ascii file, plot them and fit them with RooFit.
B and C are variables depending on E.

here is the code :

RooRealVar E("E","E",0,2000);
RooRealVar B("B","B",-1,0);
RooRealVar C("C","C",0,1);
RooDataSet* impData=RooDataSet::read("data.dat", RooArgList(E,B,C));
RooRealVar* energie=(impData->get())->find(E.GetName());
RooRealVar* coefB=(impData->get())->find(B.GetName());
RooPlot* eframe=energie->frame();
coefB->PlotOn(eframe);
eframe->Draw();

running the macro I have these messages :

ERROR:Plotting–RooRealVar::b:plotOn: WARNING: variable is not an explicite dependent : E

ERROR:Plotting–RooRealVar::b:CreatePlotProjection: “E” is not a dependent and will be ignored

and data are not plotted.

How can I indicate that B is dependent on E?
I have not found anything about that in the user’s guide.

thanks

Hi JR,

I’m somewhat confused as to what you are trying to accomplish.

One can plot the distribution of B,C,E in data using

RooPlot* frame = X.frame() ; // where X is B,C or E
impData->plotOn(frame) ;

However since these are variables that occur in dataset all three
observables, so I don’t know what you mean that B depends on E.

Can you describe the plot you aim to make?

Wouter

Hi Wouter,

What I want to do is loading data from an ASCII file, plotting them and fitting them. First column is energy E, and B and C are dependant on E.

So I want to plot B function of E and C function of E.

Hi,

Do you mean that you want a 2D plot of B vs E?

Here you can do e.g.

TH2* hh = impData->createHistogram(“B,E”) ;
hh->Draw(“box”) ;

Or did you mean something else?

Wouter

that’s what I mean effectively.

I’ll try that, thanks!

Ok it draws the correct histogramm :smiley:

In order to fit my data with an external function (a polynom for exemple), as written in the manual, I tried this :

RooDataHist data("data","dataset with E",E,Import(*hh));
RooPlot* frame = E.frame();
data.plotOn(frame);
frame->Draw();

RooDataHist needs a TH1* whereas hh is a TH2*.
By the way it drew me something, but E (which is between 0 and 2000) is drawn rebinned between 0 and 1217 (or something like that).

How can I do that properly?

Hi,

Since TH2 inherits from TH1 you can provide a TH2 whereever a TH1 is requested. However if you want a 2D binned dataset to be created you should specify 2 observables in the constructor e.g.

RooDataHist data(“data”,“dataset with E vs F”,RooArgList(E,F),Import(*hh));

Concerning the binning and ranges: The RooDataHist import operation will only import the range of the histogram that fits in the defined range of the RooRealVars E,F. E.g. if you define RooRealVar E to have a range from (0-1000) and your TH2 has a range of (0-2000) it will only import the bins in the range (0-1000). This is probably what happens in your case.

Wouter