Re: Filling a histogram with weight from other histogram

From: Axel Naumann <Axel.Naumann_at_cern.ch>
Date: Wed, 13 Jun 2012 13:37:58 +0200


Hi Benjamin,

CINT gives you a shortcut to "eff" without declaring it. But that currently only works for non-arguments. I.e. either do Int_t bin = eff->FindFixBin(pt);
eff->GetBinContent(bin);

or even better

TH1* eff = 0;
myFile->GetObject("eff", eff);
eff->getBinContent(eff->FindFixBin(pt))

of shorter but without type check

TH1* eff = (TH1F*)myFile->Get("eff");
eff->getBinContent(eff->FindFixBin(pt))

Cheers, Axel.

On 06/13/2012 01:01 PM, Benjamin Bannier wrote:
> Hi,
>
> I would like to fill a histogram from a TNtuple and get the fill
> weight from another histogram, depending on a variable from the
> ntuple.
>
> I tried
>
> nt->Draw("pt", "eff->GetBinContent(eff->FindBin(pt))")
>
> where `nt` is a `TNtuple` and `eff` a `TH1` in the variable pt.
>
> However at the cint prompt already getting the weight fails:
>
> root [18] eff (class TH1F*)0x9533f60)] root [19]
> eff->GetBinContent(eff->FindBin(0.2)) Error: Symbol eff is not
> defined in current scope (tmpfile):1: Error: Failed to evaluate
> eff->FindBin(0.2) *** Interpreter error recovered ***
>
> What is the correct way to do this?
>
>
> Cheers,
>
> Benjamin
>

Received on Wed Jun 13 2012 - 13:38:01 CEST

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