Symbol error (and bad integral value ?)

Hello

I have two problems with a simple fit with a crystal ball. The fit seems to work but I have an incorrect value for integral: 0.849871. Maybe it’s the normalized value but i use getVal() witch return the raw value (i need this raw value for a ratio signa/background)

Threre is an other error (see below) that i don’t understand.

The file “LS.AOD.output.root” is attached

Here is the code

[code]
#ifndef CINT
#include “RooGlobalFunc.h”
#endif

#include “TFile.h”
#include “TH1.h”
#include “TF1.h”
#include “TCanvas.h”
#include “TPad.h”
#include “TStyle.h”
#include <Riostream.h>
#include <TROOT.h>
#include <TMath.h>
#include <TText.h>
#include <TPaveLabel.h>

//Roofit include

#include “RooCBShape.h”
#include “RooFit.h”
#include “RooRealVar.h”
#include “RooArgSet.h”
#include “RooProdPdf.h”
#include “RooAbsPdf.h”
#include “RooAbsData.h”
#include “RooDataSet.h”
#include “RooPlot.h”
#include “RooCmdArg.h”
#include “RooNLLVar.h”
#include “RooMinuit.h”
#include “RooDataHist.h”
#include “RooFitResult.h”
#include “RooHistPdf.h”
#include “RooGenericPdf.h”
#include “RooChi2Var.h”

using namespace RooFit;

//MuonMixingAOD.output.root
//LS.AOD.output.root

void MultipleFit(TString file = “LS.AOD.output.root”){

gROOT->Reset();

//Open the file

TFile *f = new TFile(file,“READ”);

// Get histo

TH1 t = (TH1)f->Get(“h_out1”);

//Some decorations

gStyle->SetCanvasBorderMode(0);
gStyle->SetCanvasColor(kWhite);
gStyle->SetFrameBorderMode(0);
gStyle->SetFrameFillColor(kWhite);

TCanvas *c = new TCanvas(“c”,“Fits”,1600,800);

//Variables

RooRealVar m(“m”,“invariant mass (GeV/c^{2})”,2.5,3.6);

RooDataHist *data = new RooDataHist(“data”,“data x”,m,t);

RooFitResult *res_crystal;

Float_t begin = 2.8;
Float_t end = 3.3;

//Define fit model

//Crystal ball fit

RooRealVar mean_cb(“mean_cb”,“mass”,3,2.9,3.2);
RooRealVar sigma_cb(“sigma_cb”,“width”,0.06,0,0.1);
RooRealVar alpha(“alpha”,“alpha”,1,0,2);
RooRealVar n(“n”,“n”,1,0,5);
RooCBShape *crystalball = new RooCBShape(“crystal ball”,“crystal ball PDF”,m,mean_cb,sigma_cb,alpha,n);

//Fit to data

res_crystal = crystalball->fitTo(*data,Range(begin,end),Save());

//Plot

RooPlot* mframe2 = m.frame(Title(“Crystal ball fit of J/#Psi invariant mass”));
data->plotOn(mframe2,DataError(RooAbsData::SumW2));
crystalball->plotOn(mframe2,LineColor(kRed));
mframe2->Draw();

c->Print(“fit.png”,“pngLandscape”);

// Write fit result in a LaTeX file

RooArgSet* params_crystal = crystalball->getParameters(m);

params_crystal->printLatex(OutputFile(“fit_result_crystal.tex”));

cout << "integral = " << crystalball->getVal()<< endl ;

// Chi 2 / nDOF for crystal ball

Int_t lower = t->GetXaxis()->FindFixBin(begin);
Int_t upper = t->GetXaxis()->FindFixBin(end);

RooChi2Var chi2_cb(“chi2_cb”,“chi2 of crystal ball”,*crystalball,*data);

cout << chi2_cb << endl;

Double_t val = chi2_cb.getVal();

Int_t range = upper-lower;

cout << range << endl;

Double_t new_chi2_crystal = val / (range - (res_crystal->floatParsFinal().getSize()));

} [/code]
LS.AOD.output.root (16.2 KB)

Hi,

That symbol translates to the method

operator<<(std::basic_ostream<char, std::char_traits >&, RooAbsArg const&)

(you can use ‘c++filt <mangled_name>’ to discover this), which I think is triggered by this line:
cout << chi2_cb << endl;

you can either do

cout << chi2_cb.getVal() << endl;  

or

chi2_cb.Print() ;

Wouter

Hi,

Concerning your second issue: This:

cout << "integral = " << crystalball->getVal()<< endl ;

does not return the integral but rather the normalized p.d.f. value at the current value of the observable of the p.d.f.

The integral over a normalized p.d.f. is always one by construction. If you wish to calculate the integral over a normalized p.d.f. over a sub-range, you should use createIntegral()

RooAbsReal* intRange = crystalball->createIntegral(m,m,“RangeName”) ;

where the above named range was associated with using

m.setRange("RangeName",-3,3) ; // example

Look at $ROOTSYS/tutorials/roofit/rf203_ranges.C for more details on working
with ranges

Wouter

Wouter

Thanks