Segmentation violation when RooDataHist

Hi,everyone.
I’m trying to use RooFit to fit a ROOT file “Bs2JpsiPhiData” to get the mass. However, I was troubled with segmentation violation when I called RooDataHist, and the fitting code is the following:
root [0] #include “RooRealVar.h”

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

root [1] #include “RooGaussian.h”
root [2] #include “TH1.h”
root [3] #include “RooDataHist.h”
root [4] #include “RooAbsPdf.h”
root [5] #include “RooPlot.h”
root [6] using namespace RooFit;
root [7] RooRealVar x(“x”,“x”,-10,10);
root [8] RooRealVar mean(“mean”,“Mean of Gaussian”,0,-10,10);
root [9] RooRealVar sigma(“sigma”,“Width of Gaussian”,3,-10,10);
root [10] RooGaussian gauss(“gauss”,“gauss(x,mean,sigma)”,x,mean,sigma);
root [11] TH1* hh = (TH1*) gDirectory->Get(“Bs2JpsiPhiData”);
root [12] RooDataHist data(“data”,“dataset with x”,x,hh);

*** Break *** segmentation violation

===========================================================
There was a crash.
This is the entire stack trace of all threads:

#0 0x00007f55c4be241b in waitpid () from /lib64/libc.so.6
#1 0x00007f55c4b5e7ef in do_system () from /lib64/libc.so.6
#2 0x00007f55c5203e28 in TUnixSystem::StackTrace() () from /usr/lib64/root/libCore.so.6.16
#3 0x00007f55c5206a54 in TUnixSystem::DispatchSignals(ESignals) () from /usr/lib64/root/libCore.so.6.16
#4
#5 0x00007f55b8ce7829 in RooDataHist::RooDataHist(char const*, char const*, RooArgList const&, TH1 const*, double) () from /usr/lib64/root/libRooFitCore.so.6.16.00
#6 0x00007f55b8ff3095 in ?? ()
#7 0x0000000000000000 in ?? ()

The lines below might hint at the cause of the crash.
You may get help by asking at the ROOT forum http://root.cern.ch/forum
Only if you are really convinced it is a bug in ROOT then please submit a
report at http://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.

#5 0x00007f55b8ce7829 in RooDataHist::RooDataHist(char const*, char const*, RooArgList const&, TH1 const*, double) () from /usr/lib64/root/libRooFitCore.so.6.16.00
#6 0x00007f55b8ff3095 in ?? ()
#7 0x0000000000000000 in ?? ()

My platform is Fedora 29, and I build ROOT by using dnf install root and dnf install root-* python{2,3}-root . Is there something wrong with my code or ROOT?
Please help, thanks a lot.
LQS

@StephanH, can you take a look please here?

Thanks,
Oksana.

I suggest to write the single lines into a macro. You can execute the macro using
.x macroName.cxx
or even compile and execute using
.x macroName.cxx+g

That might make our life a bit easier (and you could send it around) if we cannot solve it immediately.

Right now, however, I would be that hh is a nullptr, because the histogram is maybe called differently. If you write a macro, would you just check the hh pointer immediately after you read it from the file?

Stephan, thank you! Please neglect the message I send you. I find that hh is null and a non-null argument is nedded . Could you show me how can I get a non
-null argument from the ROOT file “Bs2JpsiPhiData.root” in the RooFit workstation? Please help! Thank you!!!
LQS

If you want more info on how to write macros, see here:
https://root.cern.ch/root/htmldoc/guides/primer/ROOTPrimer.html#root-macros

See here on how to open a file, list it’s contents and retrieve an object:
https://root.cern.ch/root/htmldoc/guides/primer/ROOTPrimer.html#file-io-and-parallel-analysis

When you succeed to retrieve the histogram, you should be able to create the RooDataSet.

1 Like

Stephan, thank you very much ! You are so kind to help me solve such simple and stupid problem!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.