Nothing happens

Hi folks

I have a quick question in this your field. I am using the following code that I got from the ROOT web page “several graphs with errors in the same pad”.

root.cern.ch/cgi-bin/print_hit_b … #first_hit

On the web, the code is a postcript. I tested and it works. Then I wanted to use the same structure in c++ (see code below) and when I run my program it happens that there is no graph! Do I have to draw the canvas at the end, or should I call any other function???

I’ve included in the headers the following files THF2.h, TGraphErrors.h, TCanvas.h

void plotSamePad(Double_t infoRun[NRUNS][4], Double_t dataRun[NCHANN][NRUNS]){

Int_t n1,n2;
Int_t det1,det2;
Double_t x1[NRUNS], x2[NRUNS], y1[NRUNS], y2[NRUNS];

//next two vars stores a value between 0 and 47
det1=getDetector();
det2=findPair(det1);
TCanvas *c1 = new TCanvas(“c1”,“gerrors2”,200,10,700,500);
c1->SetFillColor(42);
c1->SetGrid();
c1->Update();

// create a 2-d histogram to define the range
TH2F *hr = new TH2F(“hr”,“Several graphs in the same pad”,2,-0.4,1.2,2,0,12);
hr->SetXTitle(“X title”);
hr->SetYTitle(“Y title”);
hr->Draw();
c1->GetFrame()->SetFillColor(21);
c1->GetFrame()->SetBorderSize(12);

// create first graph
//getPoints() just adds “n1” points to the x1,y1
//arrays {return the number of points added}
n1=getPoints(det1,x1,y1,infoRun,dataRun);
TGraphErrors *gr1 = new TGraphErrors(n1,x1,y1);
gr1->SetMarkerColor(kBlue);
gr1->SetMarkerStyle(21);
gr1->Draw(“LP”);

// create second graph
//similar process
n2=getPoints(det2,x2,y2,infoRun,dataRun);
TGraphErrors *gr2 = new TGraphErrors(n2,x2,y2);
gr2->SetMarkerColor(kRed);
gr2->SetMarkerStyle(20);
gr2->Draw(“LP”);

printf(“end of plot function”);
}

My guess is that I am not setting my THF2 object in the correct way. Something I should mention is that
the array x[] stores distances between -20 and 20 and y[] array stores values between -25 and 25.

I appreciate your help,

thxs,

Now that I’ve playing with the parameters of TGraphErrors() and THF2() I released I am wrong. Even Though the parameters in the code that I attached in the last post are not big enough to plot the data, my main problem is that I dont get the Canvas to pop up on my screen.

grrrrrr,

good night,