How to see the TCanvas of a TDirectoryFile

Hi experts,

I have a root file with a TDirectoryFile ,and it contains many TCanvas. When I use TBrowser a to look the pictures, I can only look at most 10 pictures, then there will be a collapse . And I can’t look other pictures. What should I do ,now I can only reopen the root file and select other pictures. Could you please give me some advice?

Screenshot 2023-08-21 at 18.45.25

Screenshot 2023-08-21 at 18.45.33

Hi,

Can you provide your ROOT file to be able reproduce problem?

Regards,
Sergey

outFile_FF.root (2.6 MB)

OK! This is my file.

Hi,

I can reproduce problem wih “classical” TBrowser.
When closing TCanvas - it make seg violation.
It is question to @bellenot.

Which ROOT version you are using?
Can you try to use web-based TBrowser.
Something like:

root --web=chrome ~/Downloads/outFile_FF.root -e 'new TBrowser' 

With current master and 6.28 version I see no such problem in web-based browser

Regards,
Sergey

Hi,

I’m using 6.26 version, by running this command ,I still can’t look many pictures.

Screenshot 2023-08-21 at 19.23.01

Yes, you are right.
After opening 9 first TCanvas I see same problem also in web-based RBrowser.

Are these canvases produce by yourself or by RooFit?

https://gitlab.cern.ch/ATLAS-EGamma/Software/ElectronID/TagAndProbe/-/blob/FudgeFactors/analysis_packs/ElectronLikelihoodID/python/getFudgeFactors.py#L191-257

Can you open this link?
we will create canvas and then draw the picture

  0 def writePlotToFile(root_file, ff):
  1     """
  2     For each data/MC/Conv PDF, plot all of these in a single graph, to be used
  3     to check that the conv PDF matches the data PDF.
  4     """
  5     # plot options
  6     dataHistMarkerSize = 1.3
  7     mcHistLineColor = ROOT.kBlue
  8     convPDFLineColor = ROOT.kRed
  9     ATLASLabelType = "Internal"
 10     sqrtEnergy = "#sqrt{{s}} = 13 TeV"
 11     processType = "#font[42]{Z #rightarrow ee}" if ff.low_et_edge >= 15.0 else \
 12         "#font[42]{J#psi #rightarrow ee}"
 13 
 14 
 15     if root_file.GetDirectory(ff.variable):
 16         root_file.cd(ff.variable)
 17     else:
 18         root_file.mkdir(ff.variable)
 19         root_file.cd(ff.variable)
 20 
 21     canvas = ROOT.TCanvas(ff.dataPdf.GetName())
 22 
 23     xframe = ff.observable.frame()
 24 
 25     ff.rooVarData.plotOn(xframe, ROOT.RooFit.Name("DataHist"),
 26         ROOT.RooFit.MarkerSize(dataHistMarkerSize))
 27 
 28     ff.rooVarMC.plotOn(xframe, ROOT.RooFit.Name("MCHist"),
 29         ROOT.RooFit.LineColor(mcHistLineColor))
 30 
 31     ff.convPDF.plotOn(xframe, ROOT.RooFit.Name("ConvPDF"),
 32         ROOT.RooFit.LineColor(convPDFLineColor))
 33 
 34     # Drawing options for canvas
 35     xframe.Draw()
 36     xframe.SetTitle(" ")
 37     xframe.SetMaximum(xframe.GetMaximum()*1.43)
 38     xframe.SetXTitle(ff.variable)
 39 
 40     energyLabel = ROOT.TLatex(0.2, 0.82, sqrtEnergy)
 41     energyLabel.SetNDC()
 42     energyLabel.Draw()
 43 
 44     etLabel = ROOT.TLatex(0.2, 0.76, str(ff.low_et_edge) + " #leq E_{T} #leq " +
 45         str(et_binning[et_binning.index(ff.low_et_edge) + 1]) + " GeV")
 46 
 47     etLabel.SetNDC()
 48     etLabel.Draw()
 49 
 50     etaLabel = ROOT.TLatex(0.2, 0.7, str(ff.low_abseta_edge) + " #leq |#eta| #leq " +
 51         str(abseta_binning[abseta_binning.index(ff.low_abseta_edge) + 1]))
 52 
 53     etaLabel.SetNDC()
 54     etaLabel.Draw()
 55 
 56     legend = ROOT.TLegend(0.5, 0.67, 0.9, 0.92, "", "brNDC")
 57     legend.SetBorderSize(0)
 58     legend.SetFillColor(0)
 59     legend.SetFillStyle(0)
 60     legend.AddEntry("DataHist", processType+" Data", "P")
 61     legend.AddEntry("MCHist", processType + " MC", "F")
 62     legend.AddEntry("ConvPDF", processType + " MC Corrected", "L")
 63     legend.Draw()
 64 
 65 
 66     canvas.Write()

I just tried with ROOT master on Windows and all I got is the following errors:

C:\Users\bellenot\Downloads>root -l outFile_FF.root
root [0]
Attaching file outFile_FF.root as _file0...
(TFile *) 0x1b8c4919850
root [1] TBrowser b
(TBrowser &) Name: Browser Title: ROOT Object Browser
root [2] Error in <TList::Clear>: A list is accessing an object (000001B8C553B040) already deleted (list name = TList)
Error in <TList::Clear>: A list is accessing an object (000001B8C5538BB0) already deleted (list name = TList)
Error in <TList::Clear>: A list is accessing an object (000001B8C553A410) already deleted (list name = TList)
Error in <TList::Clear>: A list is accessing an object (000001B8C5538FC0) already deleted (list name = TList)
Error in <TList::Clear>: A list is accessing an object (000001B8C55397E0) already deleted (list name = TList)
Error in <TList::Clear>: A list is accessing an object (000001B8C5536310) already deleted (list name = TList)
Error in <TList::Clear>: A list is accessing an object (000001B8C1A801F0) already deleted (list name = TList)
Error in <TList::Clear>: A list is accessing an object (000001B8C55352D0) already deleted (list name = TList)

It is problem with canvas cleanup. One need to investigate it in details.

Then it’s probably for @couet

I can reproduce the problem with:

   auto f = new TFile("outFile_FF.root");
   auto dir = f->GetDirectory("fracs1");
   TCanvas *c;
   c = (TCanvas *)dir->Get("fracs1_sig_smoothed_hist_from_KDE_et20eta0.00"); 
   c->Draw();

When I quit ROOT I get:

    Error in <TList::Clear>: A list is accessing an object (0x7fdfa5b23650) already deleted (list name = TList)

Not sure why.

Hi,

Most probably reason is histogram, which appears twice in the canvas - with different draw option.
And ROOT crashed when trying to cleanup list of primitives in the pad.

I have workaround, but this is very general problem of TList class.
At least for TPad primitives I will provide PR which should avoid crash.

Regards,
Sergey

Hi,

Finally this PR from @pcanal should solve problem with proper handling and closing of such canvases. It is cleanup problem of histograms read from ROOT file.

About showing such many number of canvas in web browser - it is limitation of 10 threads, which are created by default in web server. One can increase default number of threads providing

gEnv->SetValue("WebGui.HttpThreads", 30);

Or creating .rootrc file with the entry:

WebGui.HttpThreads: 30

I will add warning message when too much web widgets are created at once.

Regards,
Sergey

Here is example macro how to show so many canvases all together inside web-based TBrowser:

{
   gEnv->SetValue("WebGui.HttpThreads", 30);

   auto f = new TFile("/home/user/files/outFile_FF.root");
   auto dir = f->GetDirectory("fracs1");

   new TBrowser;

   TIter iter(dir->GetListOfKeys());
   int cnt = 0;
   while (auto key = iter()) {
      if (++cnt < 25) {
         auto c = (TCanvas *) dir->Get(key->GetName());
         c->Draw();
      }
   }
}

All these canvases will be showed inside RBrowser and not as independent windows.

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