Hi,
I have two data sets and I need to subtract them using some different weights. The first problem I found is that the weights have no effect and I do not know what is missing in my script. I do a test by plotting the un-weighted and weighed data set, but they are the same.
Thanks!
This is the code:
TFile *file1 = TFile::Open("../rootfiles/ch2.root");
TTree *tree1 = (TTree*)file1->Get("h509");
TFile *file2 = File::Open("../rootfiles/carbon.root");
TTree *tree2 = (TTree*)file2->Get("h509");
// Declare observable
RooRealVar excEnergy_ch2("excEnergy","excEnergy",0,25);
RooRealVar excEnergy_carbon("excEnergy","excEnergy",0,25);
//weight for the ch2
double w_ch2 = 1./(0.0397*2759456);
RooRealVar ch2Weight("ch2Weight", "ch2Weight",w_ch2);
RooDataSet dh_ch2("dh_ch2","dh_ch2",RooArgSet(excEnergy_ch2),Import(*tree1));
RooDataSet dh_ch2_weighted("dh_ch2_weighted","dh_ch2_weighted",RooArgSet(excEnergy_ch2),Import(*tree1),WeightVar("ch2Weight"));
// Make plot to see if the weight works
RooPlot* frame_ch2 = excEnergy_ch2.frame(Title("data set ch2"));
dh_ch2.plotOn(frame_ch2,DataError(RooAbsData::SumW2));
dh_ch2_weighted.plotOn(frame_ch2,DataError(RooAbsData::SumW2),LineColor(kMagenta),MarkerColor(kMagenta));
frame_ch2->Draw();