TGraph2D issue also

Hi, I saw the TGraph2D problem just a few posts below mine, but it doesn’t resolve the issue that I am having. I was wondering if anyone could point out a solution…

I have a multi-part script (still relatively new at C++, so it is just scripting with functions, essentially) to perform my calculations and make plots. The rest of it works fine, but the series of functions involved in the creation of my TGraph2D plot aren’t working.

The first function is the one that sets up the TGraph2D. I have commented some lines out because I tried it two ways - with the SetPoint method, and with a new TGraph2D populated by an int, and three arrays of doubles.

[code]void printG(string fname)

{
int q, np = 101101, i;

double xxG[np], yi[np], M[np], xa, xb, y, miny, maxy, z;
style_Theory myStyle;
myStyle.SetStyle();

for ( q=0; q<=5; q++ ) {
	if (q == 2) {
		q=3;
	}

	/*TGraph2D *gxxG = new TGraph2D();*/		
	i=0;

NOTE: The embedded “for” loops below are not displaying correctly in this post, and I am not sure why. This aspect of the code does work correctly, and the only important part is the inclusion of the SetPoint(i,y,scale,z) that is commented out. Not visible is a set of 3 arrays of doubles, yi[np], M[np] and xxG[np], which are all correctly populated through the “for” loops.

	for ( double scale=1000; scale<=10000; scale+=90 ) {
		maxy = log(14000.0/scale);
		miny = -maxy;

		for ( y = miny; y<maxy>SetPoint(i,y,scale,z);*/

			i = i + 1;
		}
	}
	cout << "finished calc\n";
	TGraph2D *gxxG = new TGraph2D(np,yi,M,xxG);

	cout << "graph made\n";
	setGraphG2D(q,gxxG,fname);
	cout << "setGraph done\n";

}

}
[/code]

The next function creates the canvas and draws the graph. Some of the lines are commented out because they didn’t work for some odd reason. I will explain at the end.

[code]void setGraphG2D( int p, TGraph2D *g, std::string fname )
{
std::string parton, titleText;

parton = getText(p,0);
TCanvas *cCanv = new TCanvas("cCanv","G Factor Parameter Scan",10,10,800,900);
TPad *cPad = new TPad("cPad","",0.03,0.03,0.98,0.92,10);
cPad->Draw();
titleText = "x_{a}x_{b}G^{#pm} - " + parton;
TPaveLabel *Title = new TPaveLabel(0.1,0.94,0.90,0.98,titleText.c_str());
Title->Draw();
cPad->cd();

//g->GetXaxis()->SetLabelSize(0.03);
//g->GetYaxis()->SetLabelSize(0.03);
//g->GetZaxis()->SetLabelSize(0.03);

//g->GetXaxis()->SetTitle("y");
//g->GetYaxis()->SetTitle("Scale (GeV)");
//g->GetZaxis()->SetTitle("xxG^{#pm}");

gStyle->SetPalette(1);
g->Draw("surf1");

fname = fname + "-" + parton;

saveGraph(cCanv,fname);

}[/code]

This last one just writes the graph to a file and clears things.

[code]void saveGraph( TCanvas *canv, std::string fname )
{
fname = fname + “.eps”;

canv->Update();

canv->SaveAs(fname.c_str());
canv->Clear();
delete canv;

}[/code]

Now, the issue I am having… First of all, when I include the lines that I have commented out in the second function (g->GetXaxis, etc…), the program hangs right at that spot. (I have tested it with cout comments)

Secondly, when I remove them, the script will hang at the canv->Update() in the last function. When I comment that out, it writes the file, and goes to start the second one and then gives me a major error (I think a segmentation fault, or some such - I can’t remember exactly, and my attempts to recreate it are being foiled by a different function I currently have unfinished, so the script won’t compile at the moment).

Can anyone see anything glaringly wrong with what I have done? I split up the features into multiple functions, because I plan on using the other functions for use with other, future features.

Much thanks to those who can read through the long post.

Can you please send some example we can run (to see the problem). Put it in the forum as an attached file, not as inline code (like you did).
Thanks in advance.