Thanks for your help Wouter.
I’m sorry but it’s still not working for me. I’ve parred down my code to the shortest runnable code. Could you glance at my code and see if anything jumps out at you:
void fitd0Mass(double d0Massmin, double d0Massmax,
double delMassmin, double delMassmax,
double gamma1PCmsmin, double gamma1PCmsmax,
double gamma2PCmsmin, double gamma2PCmsmax,
double dStarPCmsmin, double dStarPCmsmax,
double pi0Vetomin, double pi0Vetomax,
TString customVarText = "", double customVarmin = 0, double customVarmax = 0
){
gSystem->Load("libRooFit.so");
//get weights values
double wCCBar;
ccbar->SetBranchAddress("weight", &wCCBar);
ccbar->GetEntry();
RooRealVar ccbarweight("ccbarweight", "ccbarweight", wCCBar);
double wUds;
uds->SetBranchAddress("weight", &wUds);
uds->GetEntry();
RooRealVar udsweight("udsweight", "udsweight", wUds);
ccbarweight.Print();
udsweight.Print();
int nbins = 40;
//Observables
RooRealVar delMass("delMass", "delMass", delMassmin, delMassmax);
RooRealVar d0Mass("d0Mass" , "d0Mass" , d0Massmin, d0Massmax);
d0Mass.setBins(nbins);
//cut vars
RooRealVar gamma1PCms("gamma1PCms", "gamma1PCms", gamma1PCmsmin, gamma1PCmsmax);
RooRealVar gamma2PCms("gamma2PCms", "gamma2PCms", gamma2PCmsmin, gamma2PCmsmax);
RooRealVar dStarPCms("dStarPCms", "dStarPCms", dStarPCmsmin, dStarPCmsmax);
RooRealVar pi0background("pi0background", "pi0background", pi0vetomin, pi0vetomax);
cout << "d0Mass: " << d0Massmin << " to " << d0Massmax << endl;
cout << "delMass: " << delMassmin << " to " << delMassmax << endl;
cout << "gamma1PCms: " << gamma1PCmsmin << " to " << gamma1PCmsmax << endl;
cout << "gamma2PCms: " << gamma2PCmsmin << " to " << gamma2PCmsmax << endl;
cout << "dStarPCms: " << dStarPCmsmin << " to " << dStarPCmsmax << endl;
cout << "pi0background: " << pi0vetomin << " to " << pi0vetomax << endl;
//var set
using namespace RooFit;
RooArgSet ntupleVarSet(d0Mass, gamma1PCms, gamma2PCms, dStarPCms, pi0background, delMass);
RooDataSet *backgroundset = new RooDataSet("datad0_back", "background dataset with d0mass ", ntupleVarSet);
RooDataSet ccbarset = RooDataSet("ccbar_set", "ccbar dataset", ccbar, ntupleVarSet);
RooDataSet udsset = RooDataSet("uds_set", "uds dataset", uds, ntupleVarSet);
RooPlot* tempFrame=d0Mass.frame();
TCanvas* tempcanvas = new TCanvas("beforeuds", "beforeuds"); // make new canvas
udsset.plotOn(tempFrame);
tempFrame->Draw(); // Put our plot on the canvas.
RooPlot* temp1Frame=d0Mass.frame();
TCanvas* temp1canvas = new TCanvas("beforeccbar", "beforeccbar"); // make new canvas
ccbarset.plotOn(temp1Frame);
temp1Frame->Draw(); // Put our plot on the canvas.
//weighting
ccbarset.addColumn(ccbarweight);
ccbarset.setWeightVar(ccbarweight);
udsset.addColumn(udsweight);
udsset.setWeightVar(udsweight);
RooPlot* temp2Frame=d0Mass.frame();
TCanvas* temp2canvas = new TCanvas("afteruds", "afteruds"); // make new canvas
udsset.plotOn(temp2Frame);
temp2Frame->Draw(); // Put our plot on the canvas.
RooPlot* temp4Frame=d0Mass.frame();
TCanvas* temp4canvas = new TCanvas("afterccbar", "afterccbar"); // make new canvas
ccbarset.plotOn(temp4Frame);
temp4Frame->Draw(); // Put our plot on the canvas.
ntupleVarSet.Print("v");
ccbarset.append(udsset);
RooPlot* temp3Frame=d0Mass.frame();
TCanvas* temp3canvas = new TCanvas("aftertotal", "aftertotal"); // make new canvas
ccbarset.plotOn(temp3Frame);
temp3Frame->Draw(); // Put our plot on the canvas.
}
I print out 5 plots for a test. I have the two datasets before scaling:
ccbar:
http://www.slac.stanford.edu/~jmorris/beforeccbar.gif
http://www.slac.stanford.edu/~jmorris/beforeuds.gif
With the scalings that my code prints out:
RooRealVar::ccbarweight[ ] = 0.598669
RooRealVar::udsweight[ ] = 0.967881
I have the plots after the scaling:
http://www.slac.stanford.edu/~jmorris/afterccbar.gif
http://www.slac.stanford.edu/~jmorris/afteruds.gif
Looking at the first bin we see that the scaling is looking correctly:
ccbar:570.59 =~ 34
uds: 270.96 =~ 26
So everything seems to be working fine. But when I append uds to ccbar I don’t get the answer I expect (34+26) = 60
http://www.slac.stanford.edu/~jmorris/aftertotal.gif
As you can see, I’m getting 50 for the first bin.
Is my syntax wrong somewhere? I feel like I’ve tried everything.
Thanks,
James
[/code]