Re: [ROOT] undeclared objects

From: Frankland John (frankland@ganil.fr)
Date: Sat May 24 2003 - 16:09:45 MEST


Hello Justin

After you call tree->Draw(...) the histogram with name "htemp" is created
in memory, and in order to access it you have go and find it:

>for ( UInt_t i = 0, i < N; i ++ )
>{
>  tree->Draw( "a : b", cut1 + cut2 );
>
>  if ( 0 < tree->GetSelectedRows() )
>  {
>
TH2F *htemp = (TH2F*)gROOT->FindObject("htemp");

>    htemp->Fit( "pol1", "q", "", 0.0, range );
>  }
>}
>
>  
>
At the CINT command line you don't need to do this, as the wily
interpreter does it for you automatically, transforming the name "htemp"
that you type into a pointer called htemp, which is great as long as
you know what's going on, otherwise very confusing.

Note that if your TTree::Draw(...) creates a 1-D histogram, htemp
is a TH1F, 2-D histogram is a TH2F etc. etc. If you need to cover
all possibilities with the same statement, you could declare htemp
as a TH1* and then cast it.

Hope this helps


-- 
John D. Frankland
Beam Coordinator
GANIL
B.P. 55027
14076 CAEN Cedex 05

tel: +33 (0)231454628
fax: +33 (0)231454665



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:11 MET