Hi,
My code aims to import my weighted txt and fit;
There are three columns in my txt, these are Variables u, phi and weight separately.
The test_weight.txt file is located here:
result1e4.txt (976.6 KB)
My code is:
#include <RooRealVar.h>
#include <RooCategory.h>
#include <RooDataSet.h>
#include <RooTruthModel.h>
#include <RooBCPGenDecay.h>
#include <RooPlot.h>
#include <RooGlobalFunc.h>
#include <RooSimultaneous.h>
#include <RooSimPdfBuilder.h>
#include <RooArgSet.h>
#include <TString.h>
#include <TCanvas.h>
using namespace RooFit;
void roofit_xeyeU()
{
RooRealVar u("u", "u", 0, 2.2794);
RooRealVar phi("phi", "phi", 0, 2*TMath::Pi());
cout << "FOR DEBUG:phi is equal :"<< phi <<endl;
RooRealVar w("w", "w", -1, 1);
RooRealVar kappa("kappa","kappa",2.2794,2.27,2.29);
RooGenericPdf model("model","model"," 1/(kappa*kappa*pow((1+u),3))*(kappa*(1+pow((1+u),2))-4*u/kappa*(1+u)*(kappa-u))",RooArgSet(u,kappa));
//read my file
RooArgList obs("obs");
obs.add(u);
obs.add(phi);
obs.add(w);
TString file = "result1e4.txt";
RooDataSet* testDS = RooDataSet::read(file.Data(),obs);
RooDataSet data("data","data",obs,Import(*testDS),WeightVar("w"));
model.fitTo(data,Minos(true), Strategy(1),Save(true),Verbose(false));
TH1 *h = data.createHistogram("h",u,Binning(100),YVar(phi,Binning(100)));
RooPlot *uframe = u.frame(Title("Unbinned data@Entries = 1E8"));
data.plotOn(uframe);
model.plotOn(uframe);
model.paramOn(uframe,Layout(0.6,0.93,0.7));
data.statOn(uframe,Layout(0.6,0.93,0.9));
TCanvas *c1 = new TCanvas("dataimport", "dataimport", 1000, 800);
c1->Divide(1,2);
c1->cd(1);
gPad->SetLeftMargin(0.15);
uframe->GetYaxis()->SetTitleOffset(2);
uframe->Draw();
c1->cd(2);
h->Draw("lego2");
}
But it happens:
Processing roofit_xeyeU.cxx…
RooFit v3.60 – Developed by Wouter Verkerke and David Kirkby
Copyright © 2000-2013 NIKHEF, University of California & Stanford University
All rights reserved, please read http://roofit.sourceforge.net/license.txt
IncrementalExecutor::executeFunction: symbol ‘_ZlsRSoRK9RooAbsArg’ unresolved while linking [cling interface function]!
You are probably missing the definition of operator<<(std::ostream&, RooAbsArg const&)
Maybe you need to load the corresponding shared library?
**Am I importing the unweighted data incorrectly? **
And my ROOT is 6.20/02
Best Regards,
hurricane