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;

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

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

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";
	cout << "setGraph done\n";



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);
titleText = "x_{a}x_{b}G^{#pm} - " + parton;
TPaveLabel *Title = new TPaveLabel(0.1,0.94,0.90,0.98,titleText.c_str());


//g->GetYaxis()->SetTitle("Scale (GeV)");


fname = fname + "-" + parton;



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

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


delete canv;


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.