Hi Oliver Here a more specific example. Try to run this macro void test(){ Float_t x[2]={2,4}; Float_t errx[2]={0.2,0.4}; Float_t y[2]={5,6}; Float_t erry[2]={0.2,0.4}; TGraphErrors *a =new TGraphErrors(2,x,y,errx,erry); a->SetName("graph"); TH1F *b =new TH1F("pp","pp",10,0,10); b->Fill(2); b->Fill(4); } You can get the histogram using FindObject and for example draw it: root [2] a=(TH1F*)gROOT->FindObject("pp") (const class TH1F*)0x8763500 root [3] a->Draw() But I'm not able to find the graph root [4] b=(TGraphErrors*)gROOT->FindObject("graph") (const class TGraphErrors*)0x0 <------------pointer to nothing! root [5] b->Draw("AP") Error: illegal pointer to class object b 0x0 117 FILE:/tmp/fileB7tW9P_cint LINE:1 *** Interpreter error recovered *** It seems that the graph 'is not in memory'(if this is the right way to say) like histograms are. I'm just trying to understand if I can recall from the command line a graph that I previously created in macro,like I do with histograms hope this time is clear Angela On Wed, 28 Feb 2001, Oliver Mang wrote: > Hi Angela, > > as you don't give an example of your code, I can only make a rough guess. > I assume your macro looks like this: > { > TGraph mygraph(...); > [...] > mygraph->Draw(); > } > In this case, the TGraph is created on the stack and exists only inside > the macro, i.e. it will disappear when the macro finishes execution. This > is normal C/C++ behaviour. > If you change your macro to > > TGraph mygraph(); > { > [...] > } > then mygraph will be a global object and 'survive' the end of macro > execution (even without being drawn). You should be able to locate it with > gROOT->FindObject() _if_ you named your TGraph with SetName() (TGraphs > have to have their names explicitly set). > > HTH, > Oliver > -- Angela Biselli homepage : http://ignatz.phys.rpi.edu/~biselli Graduate Student e-mail:biselli@angel.phys.rpi.edu Office TEL.518-276-2050
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:38 MET