RooPlot disappears from memory

Hello,

Within a class I am creating a plot, using the code

            self.c_rect_eff = ROOT.TCanvas("c_rect_eff", "Fits", 40,40,800,600)
            self.c_rect_eff.Divide(2,1)
            self.c_rect_eff.cd(1)
            
            self.f_rect_eff = self.m_var.frame() # This is the part that does not work
            
            self.uncut_data_rect_eff.plotOn(self.f_rect_eff)
            self.uncut_results["model"].pdf("model").plotOn(self.f_rect_eff)
            self.f_rect_eff.Draw()

            self.c_rect_eff.cd(2)
            
            self.f_rect_eff2 = self.m_var.frame() # This is the part tht does not work
            
            self.cut_data_rect_eff.plotOn(self.f_rect_eff2)
            self.cut_results["model"].pdf("model").plotOn(self.f_rect_eff2)
            self.f_rect_eff2.Draw()

            self.c_rect_eff.Update()
            self.all_frame.append(self.f_rect_eff)
            self.c_rect_eff.Print("Test.pdf")

ie. everything is saved to the class instance calling the function containing this code.

The plots save fine to the .pdf file, but vanish from the screen because the RooPlots somehow get deleted by the memory managements.

That is, when I call .f_rect_eff I get “None” returned.

Why is that?
Thanks in advance!

Hi,

it’s a bit hard to say given the snippet. Can you share an example showing the behaviour?

Cheers,
D