Hi ROOTers, The following piece of code tries to: * Create one canvas, and a pad inside. * Draw a graph, update the canvas and save it. * Clear the pad. * Draw another graph, update the canvas and save it. * etc. * clear the screen and free memory The problem is that when I call pCanv->Update() for the first time, ROOT begins to do it while the script goes on running, so calling several times pCanv->SaveAs(...) before finishing the first update of the Canvas. Thus some of the files contain an empty canvas, while others have a semi-drawn one. It seems like updating the canvas uses a thread independent from the one that runs the script... is it right? Does anybody know how to make ROOT update completely the Canvas before executing the next line of code? Thanks in advance, Alberto THE CODE: // // Create Canvas and Pad // TCanvas *pCanv = new TCanvas("pCanv", "" ,200, 100, 1100, 800); TPad *pPad = new TPad("pPad", "", 0.03, 0.03, 0.97, 0.97); pCanv->SetFillColor(10); pCanv->SetGrid(); // // Draw fpScatter // TH1F *GraphFrame = pPad->DrawFrame(fpCentral->GetPlotLimXMin(), fpCentral->GetPlotLimYMin(), fpCentral->GetPlotLimXMax(), fpCentral->GetPlotLimYMax(), fHistTitle.Data()); GraphFrame->GetXaxis()->SetTitle("#phi_{b} (rad/512)"); GraphFrame->GetXaxis()->CenterTitle(); GraphFrame->GetYaxis()->SetTitle("#Delta#phi (rad/4096)"); GraphFrame->GetYaxis()->CenterTitle(); fpScatter->SetMarkerStyle(1); fpScatter->SetMarkerSize(0.35); fpScatter->SetMarkerColor(4); fpScatter->Draw("P"); pCanv->Update(); pCanv->SaveAs( (const Char_t*) ( TString("Sc") + fFileName + TString(".ps") ) ); pPad->Clear(); // // Draw fpHist // fpHistPt->SetStats(kFALSE); fpHistPt->GetXaxis()->SetTitle("p_{t} (GeV/c)"); fpHistPt->GetXaxis()->CenterTitle(); fpHistPt->GetYaxis()->SetTitle("Number of hits"); fpHistPt->GetYaxis()->CenterTitle(); fpHistPt->Draw(); pCanv->Update(); pCanv->SaveAs( (const Char_t*) ( TString("hPt") + fFileName + TString(".ps") ) ); pPad->Clear(); ... more like this ... // // Clear screen // delete pPad; delete pCanv; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Alberto Garcia Raboso CERN / EP CH-1211 Geneva 23, Switzerland Office 40-2B-19 (+41 22 76 71626) E-Mail: Alberto.Garcia.Raboso@cern.ch ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Well, farewell, my hobbits! You should come safe to your own homes now, and I shall not be kept awake for fear of your peril. We will send word when we may, and some of us may yet meet at times; but I fear that we shall not all be gathered together ever again. The return of the King. J.R.R. Tolkien ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:10 MET