'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
Processing /mnt/build/workspace/root-makedoc-v610/rootspi/rdoc/src/v6-10-00-patches/tutorials/roofit/rf401_importttreethx.C...
#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.