[ROOT] RE: Filling histo in subroutines

From: Philippe Canal (pcanal@fnal.gov)
Date: Fri Oct 17 2003 - 19:46:01 MEST


Hi Elena,

The point is that in 
	t->Draw("p2.pt>>g");
'g' does NOT refer to the name of the pointer but to the name of the object (i.e. the result of g->GetName()).
The following might work:
	t->Draw(Form("p2.pt>>%s",g->GetName());
Of course this assumes that the histogram is in the current ROOT directory.

Cheers,
Philippe.

-----Original Message-----
From: owner-about-root@listserv.fnal.gov
[mailto:owner-about-root@listserv.fnal.gov]On Behalf Of Elena Vataga
Sent: Friday, October 17, 2003 12:38 PM
To: Rene Brun
Cc: ABOUT-ROOT@listserv.fnal.gov; roottalk@pcroot.cern.ch
Subject: Re: Filling histo in subroutines


Hello, Rene,

Thank you for fast reply.

No, they are not named g..
I am calling this function in a loop,
so the name is always different.
I tryied to add:
g->SetName(g->GetName());
(does it make sence?)
it does not help...

regards,
        Elena

On Fri, 17 Oct 2003, Rene Brun wrote:

> Hi Elena,
>
> It looks like your histograms TH1F *f and *g are not named "f" and "g".
> When doing t->Draw("p2.pt>>g"), ROOT will fill an histogram named "g".
> If no histogram named "g" exists, one will be automatically created.
>
>
> Rene Brun
>
>  On
> Fri, 17 Oct 2003, Elena Vataga wrote:
>
> > Hello, rooters!
> >
> >
> > Could you, please, give me an advise on the following:
> >
> > I created function inside my root macro which essentialy
> > do the following:
> >
> > void make_histo(TChain *t ,  TH1F* g, TH1F* b, TCut CUT ) {
> >   t->Draw("p2.pt>>g");
> >   t->Draw("p2.pt>>b",CUT);
> >   g->Sumw2();
> >   b->Sumw2();
> > }
> >
> > Histogram I am getting on return are empty.
> > I cannot simply make:
> >
> >  t->Draw("p2.pt>>htemp");
> >  TH1F *g = (TH1F*)htemp->Clone("g")
> > because I am using non-equidistant binning and need to pass
> > booked histo into subroutine.
> >
> > Any idea how to make it work?
> >
> >         Thank you in advance,
> >                         Elena
> >
>



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