Saving Multiple TGraphAsymmErrors to Separate TCanvas


ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Hello,

I currently have a vector of TGraphAsymmErrors (around 150 graphs), which are my efficiency graphs. I am trying to save all these graphs as separate TCanvas, so I would like 150 TCanvas files. I tried creating a for loop to save it, however, it is giving me segmentation fault errors.

for (int graph = 0; graph < Graphs.size(); graph++){
			
			TCanvas *canvas = new TCanvas((const char*)(StringLabels[graph]),(const char*)(StringLabels[graph]),1);
			TGraphAsymmErrors *efficiency; 
			efficiency = Graphs[graph];
			canvas->SaveAs((const char*)("efficiency_" + StringLabels[graph]+".root"));
			canvas->Close();
			canvas->Clear();
			canvas->Update();

		}

The reason why I was doing this is because when I open these graphs in the TBrowser, it did not save my Draw Options. I wanted to draw a graph without the connecting lines, so I had efficiency->Draw(“AP”), however, when I opened in the TBrowser, the lines connected the dots.
Does anyone have a solution to this? I am using C++ with ROOT version 5.34/10.

Thank you,
ppajarillo

It seems to me that you want to set the default drawing option for your graphs. I don’t think it is possible but @couet may know better.

I can offer a “brutal fix”, however.
When you open the TBrowser, you will see the “Draw Option:” field (up on the left side). If you type AP there then, when you click on any of your graphs, they will be drawn with “AP”.

If you really want to save them in different canvases then you would need to specify how the “Graphs” and “StringLabels” are defined.

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