Re: TTree::Draw() with weights

From: Nick van Eijndhoven (Nick@phys.uu.nl)
Date: Thu Nov 12 1998 - 14:50:04 MET


Christoph Ernst wrote:
> 
> Hello,
> 
> Is there a simple way to rescale the y-axis of a TH1 when you plot it from
> TTree::Draw()?
> For example I want to draw a pt spectrum via tree->Draw("pt"). But as
> 1/pt * dN/dpt  not just as  dN/dpt.
> Also, I would like to plot histos from a Tree where each entry has a
> specific weight w (something like dw/dx). In a loop I would simply say
> h1->Fill(x_i, w_i);.
> But I cannot figure out how to do this in the nice way of TTree::Draw().
> If TTree::Draw() can't do it, what do you think is the best alternative?
> 
> Greetings
>         Christoph
> 

Hi Christoph,
The way I always do this is :

tree->Draw("pt","1.*1./pt")
-- 

                                              Cheers,

                               _/_/      _/    _/   _/_/_/_/    _/   _/
                              _/  _/    _/    _/   _/          _/  _/
                             _/    _/  _/    _/   _/          _/_/
                            _/      _/_/    _/   _/          _/  _/
                           _/        _/    _/   _/_/_/_/    _/    _/


*----------------------------------------------------------------------*
 Dr. Nick van Eijndhoven                Department of Subatomic Physics
 email : nick@phys.uu.nl                Utrecht University / NIKHEF
 tel. +31-30-2532331 (direct)           P.O. Box 80.000
 tel. +31-30-2531492 (secr.)            NL-3508 TA Utrecht
 fax. +31-30-2518689                    The Netherlands
 WWW : http://www.phys.uu.nl/~nick      Office : Ornstein lab. 172
 ----------------------------------------------------------------------
 tel. +41-22-7679751 (direct)           CERN PPE Division / ALICE exp.
 tel. +41-22-7675857 (secr.)            CH-1211 Geneva 23
 fax. +41-22-7679480                    Switzerland
 CERN beep : 13+7294                    Office : B 160 1-012
*----------------------------------------------------------------------*



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