Hi John, I do not see any problem with your macro. You construct a variable bin size histogram and you fill it with one entry per bin. You see a flat distribution with all values=1. Concerning your question about weights: See URL: http://root.cern.ch/root/html/TTree.html#TTree:Draw You can read: selection is an expression with a combination of the columns. In a selection all the C++ operators are authorized. The value corresponding to the selection expression is used as a weight to fill the histogram. If the expression includes only boolean operations, the result is 0 or 1. If the result is 0, the histogram is not filled. In general, the expression may be of the form: value*(boolean expression) if boolean expression is true, the histogram is filled with a weight = value. Examples: selection1 = "x<y && sqrt(z)>3.2" selection2 = "(x+y)*(sqrt(z)>3.2" selection1 returns a weigth = 0 or 1 selection2 returns a weight = x+y if sqrt(z)>3.2 returns a weight = 0 otherwise. Note that in 2.21/08, the selection cannot be just one variable. ntuple.Draw("x","y") will not produce the distribution of x with the weigth y. You have to type: ntuple.Draw("x',"1*y") This problem is already fixed in the dev version 2.22. Rene Brun John Richardson wrote: > > 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