Plot two root file in one frame

Hi Olivier
I run your script by three root file and it work.
But when I run it for three other .root file It doesn’t work and the output error attached.
I attached three new file too.
All of files generate by same methods.
I get confused.
can you help me?

error.txt (6.8 KB)

cT90.root (19.4 KB)
cT93.root (21.8 KB)
cT97.root (19.7 KB)

void MergePlot() {
   TFile* fr1 = TFile::Open("cT90.root");
   TCanvas* c1;
   fr1->GetObject("cT90;1", c1);
   TGraph *g1 = (TGraph*)c1->GetListOfPrimitives()->FindObject("Graph");
   g1->SetLineColor(kGreen);

   TFile* fr2 = TFile::Open("cT93.root");
   TCanvas* c2;
   fr2->GetObject("cT93;1", c2);
   TGraph *g2 = (TGraph*)c2->GetListOfPrimitives()->FindObject("Graph");
   g2->SetLineColor(kBlue);

   TFile* fr3 = TFile::Open("cT97.root");
   TCanvas* c3;
   fr3->GetObject("cT97;1", c3);
   TGraph *g3 = (TGraph*)c3->GetListOfPrimitives()->FindObject("Graph");


   auto C = new TCanvas();
   C->SetLogx();
   C->SetLogy();

   auto m = new TMultiGraph();
   m->Add(g1);
   m->Add(g2);
   m->Add(g3);
   m->Draw("AL");

   C->RedrawAxis();
}

thanks.

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