'DATA AND CATEGORIES' RooFit tutorial macro #401
Overview of advanced option for importing data from ROOT TTree and THx histograms Basic import options are demonstrated in rf102_dataimport.C
0.0286650657654
4.75323009491
Processing /mnt/build/workspace/root-makedoc-v614/rootspi/rdoc/src/v6-14-00-patches/tutorials/roofit/rf401_importttreethx.C...
[1mRooFit v3.60 -- Developed by Wouter Verkerke and David Kirkby[0m
Copyright (C) 2000-2013 NIKHEF, University of California & Stanford University
All rights reserved, please read http://roofit.sourceforge.net/license.txt
[#1] INFO:DataHandling -- RooDataHist::adjustBinning(dh): fit range of variable x expanded to nearest bin boundaries: [-10,10] --> [-10,10]
RooDataHist::dh[c,x] = 300 bins (2964 weights)
[#1] INFO:DataHandling -- RooDataHist::adjustBinning(dh): fit range of variable x expanded to nearest bin boundaries: [-10,10] --> [-10,10]
RooDataHist::dh[c,x] = 300 bins (2964 weights)
[#1] INFO:Eval -- RooTreeDataStore::loadValues(ds) Ignored 35 out of range events
RooDataSet::ds[x,y] = 65 entries
[#1] INFO:Eval -- RooTreeDataStore::loadValues(ds2) Ignored 36 out of range events
RooDataSet::ds2[x,y,z] = 26 entries
[#1] INFO:Eval -- RooAbsReal::attachToTree(i) TTree Int_t branch i will be converted to double precision
RooDataSet::ds3[i,x] = 100 entries
[#1] INFO:DataHandling -- RooAbsCategory::attachToTree(i) TTree branch i will be interpreted as category index
[#1] INFO:Eval -- RooTreeDataStore::loadValues(ds4) Ignored 33 out of range events
RooDataSet::ds4[i,x] = 67 entries
RooDataSet::dsABC[c,x,y] = 26 entries
#include <map>
TTree* makeTTree() ;
void rf401_importttreethx()
{
TH1* hh_1 = makeTH1(
"hh1",0,3) ;
TH1* hh_2 = makeTH1(
"hh2",-3,1) ;
TH1* hh_3 = makeTH1(
"hh3",+3,4) ;
c.defineType("SampleA") ;
c.defineType("SampleB") ;
c.defineType("SampleC") ;
map<string,TH1*> hmap ;
hmap["SampleA"] = hh_1 ;
hmap["SampleB"] = hh_2 ;
hmap["SampleC"] = hh_3 ;
TTree* tree = makeTTree() ;
ds.Print() ;
ds2.Print() ;
ds3.Print() ;
icat.defineType("State0",0) ;
icat.defineType("State1",1) ;
ds4.Print() ;
RooDataSet* dsABC =
new RooDataSet(
"dsABC",
"dsABC",
RooArgSet(x,y),
Index(c),
Import(
"SampleA",*dsA),
Import(
"SampleB",*dsB),
Import(
"SampleC",*dsC)) ;
}
{
TH1D* hh =
new TH1D(name,name,100,-10,10) ;
for (int i=0 ; i<1000 ; i++) {
hh->
Fill(gRandom->Gaus(mean,sigma)) ;
}
return hh ;
}
TTree* makeTTree()
{
TTree* tree = new TTree("tree","tree") ;
tree->Branch("x",px,"x/D") ;
tree->Branch("y",py,"y/D") ;
tree->Branch("z",pz,"z/D") ;
tree->Branch("i",pi,"i/I") ;
for (int i=0 ; i<100 ; i++) {
*px = gRandom->Gaus(0,3) ;
*py = gRandom->Uniform()*30 - 15 ;
*pz = gRandom->Gaus(0,5) ;
*pi = i % 3 ;
tree->Fill() ;
}
}
- Author
- 07/2008 - Wouter Verkerke
Definition in file rf401_importttreethx.C.