[ROOT] Using a declared variable in a root command line

From: Reinhardt Chamonal (chamonal@ph.ed.ac.uk)
Date: Mon Mar 18 2002 - 13:17:22 MET


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("r99.root"); 
  //TFile *f = new TFILE("r99.root");
  gPad->SetLogy();
  TH1F *boundary = new TH1F("boundary","Channel Signal",500,-0.5,250.5);
  h10->Draw("norm>>+boundary","pdid==0 && pixid==nb");
  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