Errors in plotting ROOT histograms from G4 extended examples for gps

Dear all,

as also reported in

there are some problems in the extended examples with the macro root files named plotHisto.C.

In particular, I would like to plot the histograms of the gps examples in examples/extended/eventgenerator/exgps for the beam source defined in the test30.mac macro.

I tried to correct the errors reported in Root error: call to deleted constructor of 'TFile' by writing the script of the plotHisto.C macro as follow:

{
  gROOT->Reset();

  // Draw histos filled by Geant4 simulation 
  //   
  //TFile f = TFile("test02.root");

  TFile f("build/test30.root");
  TCanvas* c1 = new TCanvas("c1", "  ");

  //TDirectory* dir = (TDirectory*)f.Get("histo");

  TH1D* hist1 = (TH1D*)f.Get("h1.1");
  hist1->Draw("HIST");
/*  
  TH1D* hist2 = (TH1D*)dir->Get("h1.2");      
  hist2->Draw("HIST");
*/
  TH1D* hist3 = (TH1D*)f.Get("h1.3");
  hist3->Draw("HIST");

  TH1D* hist4 = (TH1D*)f.Get("h1.4");
  hist4->Draw("HIST");

  TH2D* hist5 = (TH2D*)f.Get("h2.1");
  hist5->Draw("HIST");
/*  
  TH2D* hist6 = (TH2D*)f.Get("h2.2");      
  hist6->Draw("HIST");
    
  TH2D* hist7 = (TH2D*)dir->Get("h2.3");      
  hist7->Draw("HIST");
*/
  TH2D* hist8 = (TH2D*)f.Get("h2.4");
  hist8->Draw("HIST");
}

Unfortunately, I still having the following error messages when I run plotHisto.C with ROOT:

I have to say that I am a beginner with ROOT but I would ask, please, if someone has some suggestions for this specific problem with the Geant4 examples.
Thanks in advance for your time.
Best regards,

Christian

Dear Christian,

Can you try the plotHisto.C macro in the basic B4a example? On my side (Mac OS) this macro works fine with root 6.24/02 and 6.24/06.

If the error persists, you can change

TFile f("build/test30.root");

in

TFile f = new TFile("build/test30.root");

and then use f-> instead of f. in the following lines.

1 Like

Thanks for your answer. I solved the problem by opening a discussion in the Geant4 forum:

https://root-forum.cern.ch/t/errors-in-root-macro-plothisto-c-extended-example-of-geant4/48709

Thanks for your time.
Best regards,

Christian