Re: Problem with ntuple/variable bin widths..

From: John Richardson (jrich@mh1.lbl.gov)
Date: Mon Jun 14 1999 - 06:10:55 MEST


Hi Rene,
thanks for your prompt response!

Please find an attatched script to illustrate my finding 
(for_rene.C).
This puts 16 values of 'a' into an ntuple then projects 'a'
first into a variable binned histo (twalk1) then into an equal
binned histo (twalk2).
The bin boundaries for twalk1 are calculated as the mid points
between the data values.

The root version I am using is  2.21/08 (Solaris).

By the way, a quick question about ntuple plotting...
If I want to histogram one parameter from an ntuple (a)
and use another (b) as the weight, how do I do this?
In paw I used to just put the name of the 'weight
variable' in the logic string defining the cuts
e.g. n/proj 200 100.a b.and.c<100

I've tried to do this kind of thing:

ntuple1->Project("twalk2","a","(b)&&(c<100.0)","")

without success.

Thanks,
John


On Sun, 13 Jun 1999, Rene Brun wrote:

> Hi John,
> This should work.
> Can you tell me what is the version of root ?
> Could you send me a small file with a 5 lines long macro showing the
> problem?
> 
> Rene Brun
> 
> 
> On Sun, 13 Jun 1999, John Richardson wrote:
> 
> > 
> > Has anyone attempted to project ntuple data into a histogram
> > with non-equal bin widths?
> > 
> > I find that using
> > 
> > ntuple->Draw("a>>histid","","");
> > or
> > ntuple->Project("histid","a","","");
> > 
> > work just fine so long as the TH1F called histid has equal bins.
> > If histid has been set up with variable binning however, the
> > bin assignment of the data seems to be corrupt.
> > Perhaps there is something special I need to do for this
> > case. Can anyone comment?
> > 
> > John Richardson.
> > 
> 
> 




{
gROOT->Reset();
TNtuple *ntuple1 = new TNtuple("ntuple1","","a:b");

Float_t outer_values[16];
Float_t bin_edges[17];

Int_t ii;
Int_t nouter;

outer_values[0] = 2590.0;
outer_values[1] = 2666.0;
outer_values[2] = 2781.0;
outer_values[3] = 2933.0;
outer_values[4] = 3124.0;
outer_values[5] = 3352.0;
outer_values[6] = 3619.0;
outer_values[7] = 3924.0;
outer_values[8] = 4267.0;
outer_values[9] = 4648.0;
outer_values[10] = 5181.0;
outer_values[11] = 6324.0;
outer_values[12] = 7848.0;
outer_values[13] = 10134.0;
outer_values[14] = 14706.0;
outer_values[15] = 24963.0;

/* Calculate the bin boundaries */
 bin_edges[0] = outer_values[0]-(outer_values[1]-outer_values[0])/2.0;
 for (ii=0; ii<16; ii++)
 {
  bin_edges[ii+1] = 2.0*outer_values[ii]-bin_edges[ii];
 }

 for (ii=0; ii<16; ii++)
   {
           ntuple1->Fill(outer_values[ii],0.0);
   }

/* Variable bin histo */
TH1F *twalk1 = new TH1F("twalk1","Timewalk1", 16, bin_edges);

/* Equal bin histo */
TH1F *twalk2 = new TH1F("twalk2","Timewalk2", 100, 0.0, 30000.0);

ntuple1->Draw("a>>twalk1","","");
ntuple1->Draw("a>>twalk2","","");

}



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:34 MET