Hello,
I’m using RooFit in ROOT 5.28.
I’m trying to built one unique dataset from two similar ones. The two initial datasets are generated from RooGaussian and then I apply two different weights to each of those datasets (i.e. 1.0 and 0.5).
Then I create an empty dataset. I fill this one with the two initial ones using the append method. However, and here is my problem, the weights seems to disappear during this operation:
(here is the code that I’m using)
...
RooRealVar x("x","x",-10,10);
RooRealVar m1("m1","m1",3,2,4);
RooRealVar s1("s1","s1",2,0.5,3);
RooGaussian gauss1("gauss1","gauss1",x,m1,s1);
RooDataSet *d1 = gauss1.generate(x,10000);
RooRealVar m2("m2","m2",-2,2,4);
RooRealVar s2("s2","s2",2,0.5,3);
RooGaussian gauss2("gauss2","gauss2",x,m2,s2);
RooDataSet *d2 = gauss2.generate(x,10000);
RooFormulaVar wFunc("w","event weight","(0.5)",x) ;
RooRealVar* w = (RooRealVar*) d2->addColumn(wFunc) ;
RooDataSet *d3_a = new RooDataSet(d2->GetName(),d2->GetTitle(),d2,*d2->get(),0,w->GetName()) ;
RooFormulaVar wFunc("w","event weight","(1)",x) ;
RooRealVar* w = (RooRealVar*) d1->addColumn(wFunc) ;
RooDataSet *d3_b = new RooDataSet(d1->GetName(),d1->GetTitle(),d1,*d1->get(),0,w->GetName()) ;
RooDataSet *d5 = new RooDataSet("d5","d5",x);
d5->append(*d3_a);
d5->append(*d3_b);
d3_a->Print("v");
d3_b->Print("v");
d5->Print("v");
...
The PrintOut gives me:
DataStore gauss2Data (Generated From gauss2)
Contains 10000 entries
Observables:
1) x = -3.24245 L(-10 - 10) "x"
Dataset variable "w" is interpreted as the event weight
DataStore gauss1Data (Generated From gauss1)
Contains 10000 entries
Observables:
1) x = 3.37908 L(-10 - 10) "x"
Dataset variable "w" is interpreted as the event weight
DataStore d5 (d5)
Contains 20000 entries
Observables:
1) x = 3.37908 L(-10 - 10) "x"
Moreover, when I try to plot separatly the initial weighted datasets, the weights normalization is good, it only disappears when I use dataset d5.
Does someone know what I’m not during right and what should be the proper way to use the append method while handling weighted datasets ?
Thank you,
Simon