Roofit: addTH1 crashing

For some reason my script crashes when using addTH1, but seems to happen only during clean up (when I quit out of root):

//  TH1F *pi0pi0combohisto = new TH1F("ccbarhisto", "ccbarhisto", numbins, d0MassLo, d0MassHi);
  TH1* pi0pi0combohisto = d0Mass.createHistogram("d0MassCombo", d0MassLo, d0MassHi ,numbins) ;
  dxPi0Pi0_d0FitCombo->fillHistogram(pi0pi0combohisto, d0Mass) ;

  TCanvas *signalPlot = new TCanvas("signalPlot", "signalPlot");
  RooPlot *pSig = d0Mass.frame();
  pSig -> Draw();

I have tried two different methods to create the histogram (shown above). Can anyone see what’s going on, or do you have a snippet of code which adds a TH1F to a rooplot?


Hi James,

It seems that your TH1 gets deleted twice somehow. In general, a RooPlot takes ownership of everything that is added to it, so any attempt to delete the TH1 yourself afterwards could result in such a crash.

I can however not reproduce the crash by typing in an example very similar to yours and then immediately quitting the root session.

Can you send me a completely self-contained example?