Hi ROOTalkers,
I wanted to use RooFit to do maximum likelihood
fits of my histograms and tree variables but have
problems reading in my root file. I have checked
Roofit documentation, but the examples offered there
are too simple for my application.
-
I am using root-5.22.00 version.
-
First, I have a ROOT problem declaring the
pointer to a histogram in *.root file and
drawing that histogram. I can start ROOT
interactively, start TBrowser and click on
histogram and see that it is OK.But, in my macro, the following does not work:
TFile f = new TFile(“run84101.root”);
TH1F h1 = (TH1F) f->Get(“h1THRESHOLD_10”);
TCanvas c=new TCanvas(“PEN Maximum Likelihood Analysis”,“PEN Maximum Likelihood Analysis”,200,10,700,600);
h1->Draw();
c->Update();Reported error is:
Error: illegal pointer to class object h1 0x0 406 h_maxPEN.C:53:
*** Interpreter error recovered ***
My histogram "h1THRESHOLD_10" is in folder /histos/Check, so I tried
variations:
TFile input("/home/ef2p/pen08/maxlike/run84101.root");
input.cd("/histos/Check");
TH1F *h1 = (TH1F*) f->Get("h1THRESHOLD_10");
but that produces the same "illegal pointer error". So, I am
stuck without sucessful input and cannot use RooFit.
- Second I try to read in a TTree that is in the same file run84101.root.
I succeed in plotting two Tree variables with:
TFile f(“run84101.root”) ;
t1=(TTree ) gROOT->FindObject(“usertree”) ;
TCanvas c=new TCanvas(“PEN Maximum Likelihood Analysis”,“PEN Maximum Likelihood Analysis”,200,10,700,600);
c->Divide(1,2) ;
c->cd(1) ;
t1->Draw(“digi.t_pion”) ;
c->cd(2) ;
t1->Draw(“asum.csi_sum”) ;
c->Update();
But, the variables are in sub-sub-branches, so when I try to assocuate them with
RooDataSet, that fails:
RooRealVar asum.csi_sum(“asum.csi_sum”,“asum.csi_sum”,0,100) ;
RooRealVar digi.t_pion(“digi.t_pion”,“digi.t_pion”,200,640) ;
RooDataSet pen_emodel(“pen_emodel”,“pen_emodel”,RooArgSet(asum.csi_sum,digi.t_pion),Import(t1)) ;
RooPlot frame1=asum.csi_sum.frame(Title(“1L Energy”)) ;
pen_emodel.plotOn(frame1) ;
with error mesasages:
Error: Symbol asum is not defined in current scope t_maxPEN.C:55:
Error: Failed to evaluate asum.csi_sum
Error: Symbol digi is not defined in current scope t_maxPEN.C:55:
Error: Failed to evaluate digi.t_pion
*** Interpreter error recovered ***
Does that mean that I have to redefine/rewrite my Tree and that
Roofit cannot understand sub-branches or my syntax is wrong?
Cheers, Emil
f1.ps (10.3 KB)
f2.ps (8.89 KB)
run84101.root (797 KB)