CINT can be made more strict regarding the usage of a
non pointer as a pointer.
At the root prompt type #pragma security level3
Then you get something like this....
root [0] #pragma security level3
root [1] TH1F h1 = new TH1F("blat", "quat", 20, 4.5, 6);
cint: Security mode 0xffff:0x1000 Casting protected FILE:/tmp/22397baa
LINE:1
*** Interpreter error recovered ***
I think the cint documentation says more about what the security
flag does..
- Mark
-----Original Message-----
From: owner-roottalk@hpsalo.CERN.CH [mailto:owner-roottalk@hpsalo.CERN.CH]
On Behalf Of Stephen Bailey
Sent: Wednesday, August 19, 1998 9:57 AM
To: Rene Brun
Cc: roottalk@hpsalo.CERN.CH
Subject: Re: proj ntuple into predefined histogram
On Wed, 19 Aug 1998, Rene Brun wrote:
> Stephen Bailey wrote:
> >
> > Hi.
> >
> > I'm trying to project an ntuple into a histogram which I
> > defined so that I can control the number of bins used.
> > e.g.
> >
> > TH1F h1 = new TH1F("blat", "quat", 20, 4.5, 6);
> > ntuple->Draw("m>>+h1", "(4.5<m)&&(m<6.0)");
> > h1->Draw();
> >
> > I also tryed m>>h1, but the ntuple->Draw command always
> > picks its own choice for number of bins and h1 always
> > seems to remain empty. If I don't predefine h1 then it
> > gets created and properly filled but I don't have control
> > over the number of bins.
> >
> > Is there a way to do this easily (i.e. without looping
> > trough the ntuple and filling the histogram event by event)?
>
> Replace:
> TH1F h1 = new TH1F(..
> by
> TH1F *h1 = new TH1F(..
>
> The TTree::Draw function (in the form "m>>+h1") fills an histogram
> with the name "h1". In your case h1 is the name of the pointer,
> not the name of the histogram ("blat").
> It is a good practice to have the pointer_name = histogram_name.
> Your program will work with:
> TH1F *h1 = new TH1F("blat", "quat", 20, 4.5, 6);
> ntuple->Draw("m>>+blat", "(4.5<m)&&(m<6.0)");
> h1->Draw();
> or
> TH1F *blat = new TH1F("blat", "quat", 20, 4.5, 6);
> ntuple->Draw("m>>+blat", "(4.5<m)&&(m<6.0)");
> blat->Draw();
>
> Rene Brun
The difference in the example is whether the histogram_name ==
variable_name. If they are *not* equal, CINT apparently lets me
get away with the sloppy usage of a non-pointer as a pointer,
whereas it didn't work if the histogram and its variable had the
same name. But if I correctly type them as pointers as you suggest,
then both cases work. Thanks for the help.
Stephen