I have 4 root files (2 root files are generated from .C macro 1.root & 2.root which have x and y-axis value ) and the other two are histogram root files(geant1.rrot and geant2.root). The second part is causing some problems and without this program is doing very well. How should it be modified
{
TFile *f1 = TFile::Open("1.root");
c1->Draw();
Graph->GetYaxis()->SetRangeUser(1,10000);
Graph->GetXaxis()->SetRangeUser(4,10);
c1->SetLogy();
Graph->SetMarkerStyle(23);
////////////////////////////2nd part/////////////////////////////////
TFile *f5 = TFile::Open("2.root");
TCanvas *c1->Draw();
c1->Draw("same");
Graph->SetMarkerStyle(25);
//////////////////////////////////////////////////////////////////
TFile *f2 = TFile::Open("geant1.root");
TCanvas *c2 = (TCanvas*)f2->Get("h16");
h16->Draw("hist same");
h16->SetName("a");
a->SetLineStyle(7);
a->SetMarkerStyle(26);
a->SetLineColor(12);
a->SetLineWidth(2);
TFile *f3 = TFile::Open("geant2.root");
TCanvas *c3 = (TCanvas*)f3->Get("h16");
h16->Draw("hist same");
h16->SetName("b");
b->SetLineStyle(10);
b->SetMarkerStyle(29);
b->SetLineColor(4);
b->SetLineWidth(2);
leg = new TLegend(0.51,0.69,0.9,0.9);
leg->SetHeader("result");
leg->AddEntry(a,"a","l");
leg->AddEntry(b, "b","l");
leg->AddEntry(Graph,"ref1","p");
leg->AddEntry(Graph,"ref2","p");
leg->SetFillColor(10);
leg->Draw();
}
_ROOT Version:_6.14
Platform: Ubuntu
Compiler: Not Provided
couet
January 9, 2020, 2:17pm
2
Option “SAME” does not exist for canvases.
c1->Draw("same")
has no meaning
couet
January 9, 2020, 2:18pm
3
Can you provide the data files ?
These are the macro files from which first root two files are generated-
1.C (248 Bytes)
2.C (247 Bytes)
Root files created from these two macro files:
1.root (8.1 KB)
2.root (8.1 KB)
Root file from Geant4:
geant1.root (47.3 KB) geant2.root (47.5 KB)
A_Kumar
January 10, 2020, 10:45am
5
Hey @couet ,
Did you get/know the answer how to perform ?
Axel
January 11, 2020, 12:16pm
6
Olivier will reply next week, he is unavailable yesterday and this weekend.
Axel
couet
January 13, 2020, 1:24pm
7
void kumar()
{
TFile *f1 = TFile::Open("1.root");
TCanvas *c = (TCanvas *)f1->Get("c1");
TGraphErrors *g1 = (TGraphErrors *)c->GetListOfPrimitives()->FindObject("Graph");
c->Close();
g1->GetYaxis()->SetRangeUser(1,10000);
g1->GetXaxis()->SetRangeUser(4,10);
g1->SetMarkerStyle(23);
g1->Draw("AP");
gPad->SetLogy();
TFile *f2 = TFile::Open("2.root");
c = (TCanvas *)f2->Get("c1");
TGraphErrors *g2 = (TGraphErrors *)c->GetListOfPrimitives()->FindObject("Graph");
c->Close();
g2->SetMarkerStyle(23);
g2->Draw("P");
g2->SetMarkerStyle(25);
TFile *f3 = TFile::Open("geant1.root");
TH1D* h1 = (TH1D*)f3->Get("h16");
h1->Draw("hist same");
h1->SetLineStyle(7);
h1->SetMarkerStyle(26);
h1->SetLineColor(12);
h1->SetLineWidth(2);
TFile *f4 = TFile::Open("geant2.root");
TH1D* h2 = (TH1D*)f4->Get("h16");
h2->Draw("hist same");
h2->SetName("b");
h2->SetLineStyle(10);
h2->SetMarkerStyle(29);
h2->SetLineColor(4);
h2->SetLineWidth(2);
auto leg = new TLegend(0.51,0.69,0.9,0.9);
leg->SetHeader("result");
leg->AddEntry(h1,"a","l");
leg->AddEntry(h2, "b","l");
leg->AddEntry(g1,"ref1","p");
leg->AddEntry(g2,"ref2","p");
leg->SetFillColor(10);
leg->Draw();
}
A_Kumar
January 14, 2020, 11:42am
9
Hi @couet
I do not want 5.5, 6.5, 7.5 & 8.5 on x-axis (no decimal values). I tried with TGaxis::SetMaxDigits but no change observed.
couet
January 14, 2020, 12:05pm
10
g1->GetXaxis()->SetNdivisions(509);