> Error in <TApplication::TApplication>: only one instance of TApplication allowed In your code: > gROOT->ProcessLine(".L py.C"); > TApplication *app = new TApplication("app", &argc, argv); The creation of TApplication you be done as early as possible and definitively before calling gROOT->ProcessLine: int main (int argc, char** argv) { TApplication *app = new TApplication("app", &argc, argv); gROOT->ProcessLine(".L py.C"); Since 'h' is being defined in your compiled code, ProjectionXY does not have automatic access to it. You could use a compiled version of ProjectionXY (doing .L py.C++ and make sure that h, h1_px and h2_py are defined as extern references inside py.C) or you need to declare h, h1_px and h2_py to the interpreter using something similar to: gROOT->ProcessLine(".L define.C"); with define.C // start define.C #include <TH1.h> #include <TH2.h> extern TH2F *h; extern TH1D *h1_px, *h1_py; // end of define.C Cheers, Philippe. -----Original Message----- From: owner-roottalk@pcroot.cern.ch [mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Harufumi Tsuchiya Sent: Tuesday, December 04, 2001 2:13 AM To: brun@pcbrun.cern.ch Cc: roottalk@pcroot.cern.ch Subject: Re: [ROOT] My procedure using TExec is wrong ? Thank you so much for your quick reply. Using your attached programs in previous mail, I modified one of the programs (pym.C) like bottom of this mail (mod_pym.C) for compiling via g++. I certainly could do what I want to do. But, I got new error message. Error in <TApplication::TApplication>: only one instance of TApplication allowed What is the meaning ? And also I have one more question. In fact, ProjectionXY is defiend in my origianl main program and h , other histograms(h1_px, h1_py) and pad are also defined in the top of the main program like below. This procedure is wrong ? In such a case that I want to do, Must I separate ProjectionXY in atnoter file in order to use gROOT->ProcessLine() ? TH2F *h; TH1F *h1_px, *h1_py; TPad *pad[4]; int main ( int argc, char** argv ) { : : } void ProjectionXY() { : : } Thank you, Harufumi Tsuchiya ------------------------- mod_pym.C ------------------------- #include <TROOT.h> #include <TH1.h> #include <TH2.h> #include <TExec.h> #include <TCanvas.h> #include <TFile.h> #include <TApplication.h> TH2F *h; TH1D *h1_px, *h1_py; int main (int argc, char** argv) { gROOT->ProcessLine(".L py.C"); TApplication *app = new TApplication("app", &argc, argv); TExec *ex_proj = new TExec("ex_proj", "ProjectionXY()"); TFile f("hsimple.root"); h = (TH2F*)gDirectory->Get("hpxpy"); h->GetListOfFunctions()->Add(ex_proj); h1_px = 0; h1_py = 0; TCanvas c1("c1"); c1.Divide(2,2); c1.cd(1); h->Draw("colz"); app->Run(); }
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:11 MET