Re: Filling a histogram with weight from other histogram

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Wed, 13 Jun 2012 14:30:33 +0200


Hi Benjamin,

a simple suggestion :

    TH1 *hpt = (TH1*)eff->Clone("hpt"); //making sure that hpt and eff have the same binning

    nt->Draw("pt>>hpt");                        //refill hpt with pt and 
weigth=1

    hpt->Multiply(eff);

Rene

On 13/06/2012 13:57, Benjamin Bannier wrote:
> Hi Axel,
>
> thank you for taking the time to answer.
>
> I now make sure the histogram is know when I fill the histogram, but get
> a different error when filling the histogram with the nice and simple
> TTree::Draw:
>
> $ nt->Draw("pt", "eff->GetBinContent(eff->FindBin(pt))")
> Error in<TTreeFormula::Compile>: Bad numerical expression : "eff.GetBinContent(eff.FindFixBin(pt))"
>
> I tried casting that expression to some numeric types, but it didn't help.
>
> I would really like to use some automatic drawing function instead of iterating
> over the tree by hand. Is there a way to make this work?
>
>
> Cheers,
>
> Benjamin
>
Received on Wed Jun 13 2012 - 14:31:25 CEST

This archive was generated by hypermail 2.2.0 : Wed Jun 13 2012 - 17:50:01 CEST