Thanks I didn't think about this trick On Mon, 18 Mar 2002, Rene Brun wrote: > Hi Reinhardt, > > Modify your code as indicated below. > > Rene Brun > > Reinhardt Chamonal wrote: > > > > Hi the experts, > > > > First that's going be a very very basic question. I had a look at > > various examples around but I am stuck and frustrated. (I am started at > > Root) > > What I would like to do is a little simple script to take a number and > > then > > plot the histogram corresponding to this number > > Here is what I do: > > > > #include <iostream.h> > > > > int show(Int_t nb) { > > gROOT->Reset(); > > c1 = new TCanvas("mapmt","MAPMTs",10,40,800,600); > > TFile *f = new TFile("r99.root"); //<================ > //use new, otherwise when closing the file, hist will be destroyed > > //TFile *f = new TFILE("r99.root"); > > gPad->SetLogy(); > > TH1F *boundary = new TH1F("boundary","Channel Signal",500,-0.5,250.5); > TString cut = "pdid==0 && pixid=="; > cut += nb; > > h10->Draw("norm>>+boundary","cut); > > c1->Update(); > > //return 0; > > > > } > > > > so calling show(2) should draw the histogram cooresponding to pixid=2 > > when calling > > h10->Draw("norm>>+boundary","pdid==0 && pixid==nb"); > > where I put my variable nb. It obviously doesn't like it certainly because > > of the "". What is the correct declaration in this case ? > > Can anybody indicate me an example where this is used ? > > > > Also as running my script without nb, (with the number instead) works but > > the histogram shows up and then disappears... :( > > I read something about the heap.. (as my histogram boudary with my > > personnal boundaries is declared as new). Is it the case ? What can I do > > to let it stay ? > > > > Cheers. > > > > ------------------------------------------------------------ > > Reinhardt CHAMONAL The University of Edinburgh > > Dept. of Physics & Astronomy > > email: chamonal@ph.ed.ac.uk King's Buildings, JCMB, 5301 > > Mayfield Road > > phone: +44-131-650 5307 Edinburgh, EH9 3JZ > > > > web: http://www.ph.ed.ac.uk/~chamonal/ > > http://www.reuh.fr.st > > ------------------------------------------------------------ >
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:46 MET