26 using namespace RooFit;
 
   28 TH1 *makeTH1(
const char *name, Double_t mean, Double_t sigma);
 
   31 void rf401_importttreethx()
 
   37    TH1 *hh_1 = makeTH1(
"hh1", 0, 3);
 
   38    TH1 *hh_2 = makeTH1(
"hh2", -3, 1);
 
   39    TH1 *hh_3 = makeTH1(
"hh3", +3, 4);
 
   42    RooRealVar x(
"x", 
"x", -10, 10);
 
   45    RooCategory c(
"c", 
"c");
 
   46    c.defineType(
"SampleA");
 
   47    c.defineType(
"SampleB");
 
   48    c.defineType(
"SampleC");
 
   51    RooDataHist *dh = 
new RooDataHist(
"dh", 
"dh", x, Index(c), Import(
"SampleA", *hh_1), Import(
"SampleB", *hh_2),
 
   52                                      Import(
"SampleC", *hh_3));
 
   56    map<string, TH1 *> hmap;
 
   57    hmap[
"SampleA"] = hh_1;
 
   58    hmap[
"SampleB"] = hh_2;
 
   59    hmap[
"SampleC"] = hh_3;
 
   60    RooDataHist *dh2 = 
new RooDataHist(
"dh", 
"dh", x, c, hmap);
 
   66    TTree *tree = makeTTree();
 
   69    RooRealVar y(
"y", 
"y", -10, 10);
 
   70    RooRealVar z(
"z", 
"z", -10, 10);
 
   73    RooDataSet ds(
"ds", 
"ds", RooArgSet(x, y), Import(*tree));
 
   77    RooDataSet ds2(
"ds2", 
"ds2", RooArgSet(x, y, z), Import(*tree), Cut(
"y+z<0"));
 
   84    RooRealVar i(
"i", 
"i", 0, 5);
 
   85    RooDataSet ds3(
"ds3", 
"ds3", RooArgSet(i, x), Import(*tree));
 
   89    RooCategory icat(
"i", 
"i");
 
   90    icat.defineType(
"State0", 0);
 
   91    icat.defineType(
"State1", 1);
 
   95    RooDataSet ds4(
"ds4", 
"ds4", RooArgSet(icat, x), Import(*tree));
 
  102    RooDataSet *dsA = (RooDataSet *)ds2.reduce(RooArgSet(x, y), 
"z<-5");
 
  103    RooDataSet *dsB = (RooDataSet *)ds2.reduce(RooArgSet(x, y), 
"abs(z)<5");
 
  104    RooDataSet *dsC = (RooDataSet *)ds2.reduce(RooArgSet(x, y), 
"z>5");
 
  107    RooDataSet *dsABC = 
new RooDataSet(
"dsABC", 
"dsABC", RooArgSet(x, y), Index(c), Import(
"SampleA", *dsA),
 
  108                                       Import(
"SampleB", *dsB), Import(
"SampleC", *dsC));
 
  113 TH1 *makeTH1(
const char *name, Double_t mean, Double_t sigma)
 
  117    TH1D *hh = 
new TH1D(name, name, 100, -10, 10);
 
  118    for (
int i = 0; i < 1000; i++) {
 
  119       hh->Fill(gRandom->Gaus(mean, sigma));
 
  128    TTree *tree = 
new TTree(
"tree", 
"tree");
 
  129    Double_t *px = 
new Double_t;
 
  130    Double_t *py = 
new Double_t;
 
  131    Double_t *pz = 
new Double_t;
 
  132    Int_t *pi = 
new Int_t;
 
  133    tree->Branch(
"x", px, 
"x/D");
 
  134    tree->Branch(
"y", py, 
"y/D");
 
  135    tree->Branch(
"z", pz, 
"z/D");
 
  136    tree->Branch(
"i", pi, 
"i/I");
 
  137    for (
int i = 0; i < 100; i++) {
 
  138       *px = gRandom->Gaus(0, 3);
 
  139       *py = gRandom->Uniform() * 30 - 15;
 
  140       *pz = gRandom->Gaus(0, 5);