Bidimensional fit

Hi experts,

I would like to do a bidimensional fit but I didn’t find any kind of example so I tried in this way:

  1. I have a bidimensional histo and from this I do the ProjectionX and ProjectionY
  2. I fit separately the two projections with 2 pdf
  3. I try to combine the 2 pdf into one (RooProduct prod_pdf(“prod_pdf”,“prod_pdf”,RooArgList(pdf1,pdf2)))
  4. I keep the bidimensional histo and I want to use the “prod_pdf” to fit it but at this point it crashes and gives me this error message

*** Break *** segmentation violation

===========================================================
There was a crash (#7 0xb71ebd8d in SigHandler () from /home/patrizia/ROOT/lib/libCore.so).
This is the entire stack trace of all threads:

#0 0xb7786410 in __kernel_vsyscall ()
#1 0xb658f593 in waitpid () from /lib/tls/i686/cmov/libc.so.6
#2 0xb6532643 in ?? () from /lib/tls/i686/cmov/libc.so.6
#3 0xb6656d7d in system () from /lib/tls/i686/cmov/libpthread.so.0
#4 0xb71e7c0d in TUnixSystem::Exec () from /home/patrizia/ROOT/lib/libCore.so
#5 0xb71eee52 in TUnixSystem::StackTrace () from /home/patrizia/ROOT/lib/libCore.so
#6 0xb71ebca6 in TUnixSystem::DispatchSignals () from /home/patrizia/ROOT/lib/libCore.so
#7 0xb71ebd8d in SigHandler () from /home/patrizia/ROOT/lib/libCore.so
#8 0xb71e542d in sighandler () from /home/patrizia/ROOT/lib/libCore.so
#9
#10 0xb5f262a7 in TH1::Divide () from /home/patrizia/ROOT/lib/libHist.so
#11 0xb4f33725 in RooAbsPdf::fitTo () from /home/patrizia/ROOT/lib/libRooFitCore.so
#12 0xb4f2a6d8 in RooAbsPdf::fitTo () from /home/patrizia/ROOT/lib/libRooFitCore.so
#13 0xb519f2be in G__G__RooFitCore1_241_0_26 () from /home/patrizia/ROOT/lib/libRooFitCore.so
#14 0xb69fa7b5 in Cint::G__ExceptionWrapper () from /home/patrizia/ROOT/lib/libCint.so
#15 0xb6ab2a06 in G__execute_call () from /home/patrizia/ROOT/lib/libCint.so
#16 0xb6ab52c0 in G__call_cppfunc () from /home/patrizia/ROOT/lib/libCint.so
#17 0xb6a89f43 in G__interpret_func () from /home/patrizia/ROOT/lib/libCint.so
#18 0xb6a7671a in G__getfunction () from /home/patrizia/ROOT/lib/libCint.so
#19 0xb6b77044 in G__getstructmem () from /home/patrizia/ROOT/lib/libCint.so
#20 0xb6b6c0f3 in G__getvariable () from /home/patrizia/ROOT/lib/libCint.so
#21 0xb6a4b0af in G__getitem () from /home/patrizia/ROOT/lib/libCint.so
#22 0xb6a4fee5 in G__getexpr () from /home/patrizia/ROOT/lib/libCint.so
#23 0xb6a3b696 in G__define_var () from /home/patrizia/ROOT/lib/libCint.so
#24 0xb6ae1e4d in G__exec_statement () from /home/patrizia/ROOT/lib/libCint.so
#25 0xb6a8c38e in G__interpret_func () from /home/patrizia/ROOT/lib/libCint.so
#26 0xb6a7688f in G__getfunction () from /home/patrizia/ROOT/lib/libCint.so
#27 0xb6a4b65d in G__getitem () from /home/patrizia/ROOT/lib/libCint.so
#28 0xb6a4fee5 in G__getexpr () from /home/patrizia/ROOT/lib/libCint.so
#29 0xb6a5ce72 in G__calc_internal () from /home/patrizia/ROOT/lib/libCint.so
#30 0xb6af3567 in G__process_cmd () from /home/patrizia/ROOT/lib/libCint.so
#31 0xb71d5843 in TCint::ProcessLine () from /home/patrizia/ROOT/lib/libCore.so
#32 0xb71d541f in TCint::ProcessLineSynch () from /home/patrizia/ROOT/lib/libCore.so
#33 0xb70f4287 in TApplication::ExecuteFile () from /home/patrizia/ROOT/lib/libCore.so
#34 0xb70f487c in TApplication::ProcessFile () from /home/patrizia/ROOT/lib/libCore.so
#35 0xb70f1bbe in TApplication::ProcessLine () from /home/patrizia/ROOT/lib/libCore.so
#36 0xb67ae6c4 in TRint::Run () from /home/patrizia/ROOT/lib/libRint.so
#37 0x08048ea5 in main ()

The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug report at
root.cern.ch/bugs. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.

#10 0xb5f262a7 in TH1::Divide () from /home/patrizia/ROOT/lib/libHist.so
#11 0xb4f33725 in RooAbsPdf::fitTo () from /home/patrizia/ROOT/lib/libRooFitCore.so
#12 0xb4f2a6d8 in RooAbsPdf::fitTo () from /home/patrizia/ROOT/lib/libRooFitCore.so

Root > Function pseudo_Dalitz_fit() busy flag cleared

Any suggestion?

Thanks
pseudo_Dalitz_fit.C (7.18 KB)

Hi,
it is not clear to me what you want to do. If you want to do a simple bi-dimensional fit to a 2D histogram, don’t do the projection, but just do, for a least-square (chi2) fit

TH2 * h2 = .... // your 2-d histogram 
TF2 * f2 = new TF2("f2",............) ; // your 2D function you want to fit
h2->Fit(func);  

and for a binned likelihood fit (better if you have few entries/bins) do:

h2->Fit(func,"L");  

Ciao

Lorenzo

Let me explain my problem with Roofit:

  1. I want to do a 2D fit
  2. my bidimensional histo is mass1vsmass2
  3. I made some slices in one direction and projected them in the other and at this point i tried to do my 2D fit.
  4. I did it for the 3 separated decay modes (bidi_fit_Lca1.C,bidi_fit_Lcnr.C,bidi_fit_Lcrho.C) and i would like to put all togheter to do an extended likelihood fit to find the yield (bidi_fit.C) but it doesn’t wok.
    I put here in attachement the macro I used for the 2D fit .
    I can’t upload the ntuples because there is here enough space but if you where I can put them I’ll do it.
    I tried to do this fit but I’m no so sure it’s correct because I didn’t find any kind of example.
    In particular I would like to fit directly my 2d histo but it seems not possible so that the only way I found to do that is the way that you can see in the 3 separated macro (bidi_fit_Lca1.C,bidi_fit_Lcnr.C,bidi_fit_Lcrho.C) but doing in this way I have a disagreement between the number of entries in the 2d histo and the dataSet created ,for example, in this way

TH2* dh2 = data.createHistogram(“dh2”,mrho46_gRandom,Binning(100),YVar(mrho56_gRandom,Binning(100)))

that has a double number of entries.
I hope to have been clear

Thanks a lot
bidi_fit_Lcrho.C (14.1 KB)
bidi_fit_Lcnr.C (12.7 KB)
bidi_fit_Lca1.C (15.3 KB)
bidi_fit.C (7.99 KB)

Hi,

If you want to use RooFit (you don’t need the 1D fits done before the 2-D one). Use RooProdPdf rather than RooProduct.

Cheers,

– Gregory