There are two graphs saved within .root files.
I am able to upload the graphs and individually open them. However, I haven’t been able to figure out how to superimpose them. Here’s what I have so far:
When I do this, all I get is the graph of gr2. Oddly enough, when I replace TGraphErrors with TGraph or even TH1D, I still get the graph. It’s also strange to me that when I try creating a canvas for the two graphs, the canvas loads separately, leaving me with an empty canvas and the gr2 graph.
Changing colors and marker style hasn’t helped either. Any suggestions?
TCanvas *c2 = new TCanvas("Candidates by Pt Range","Candidates by Pt Range",10,10,700,500);
TFile *MyFile = new TFile("fig/myfig_data_pt.root","RECREATE");
Double_t x[5]={0.75,1.25,1.75,2.50,4.00};
Double_t ex[5]={0,0,0,0,0};
//normalize
/* Magnitude=sqrt(y[0]*y[0]+y[1]*y[1]+y[2]*y[2]+y[3]*y[3]+y[4]*y[4]);
for (n=0; n<5; n++) {
y[n] /= Magnitude; ey[n] /= Magnitude;}
*/
gr = new TGraphErrors(5,x,y,ex,ey);
gr->GetXaxis()->SetTitle(“Mean Pt Value”);
gr->SetLineColor(kRed);
gr->SetMarkerColor(kRed);
gr->SetMarkerStyle(24);
gr->Draw(“AP”);
c2->Update();
c2->Write(“MassPlot”);
y[5] and ey[5] were defined within the program. When I run the program, linux just responds, “Processing test.cxx” (test.cxx is the program’s name). Is this what you were asking for?
TFile *MyFile = new TFile("fig/myfig_data_pt.root","RECREATE");
gr = new TGraphErrors(5,x,y,ex,ey);
gr->GetXaxis()->SetTitle("Mean Pt Value");
gr->SetLineColor(kRed);
gr->SetMarkerColor(kRed);
gr->SetMarkerStyle(24);
gr->Draw("AP");
c2->Update();
gr->Write("MassPlot");
In the reading program do: