RE: [ROOT] Fill histograms problem using TString

From: Philippe Canal (pcanal@fnal.gov)
Date: Thu May 20 2004 - 20:42:22 MEST


Hi Martin,

In order to refer to the leaf in a ntuple as a string for histogram filling purpose you should use TTree::Draw (or TTreeFormula for advanced users).

The histogram class as no clue what so ever of the content of your TTree and can not make any correlation.

Cheers,
Philippe.

-----Original Message-----
From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Martin Simard
Sent: Wednesday, May 19, 2004 11:46 PM
To: Rene Brun
Cc: roottalk@pcroot.cern.ch
Subject: Re: [ROOT] Fill histograms problem using TString


Hi Rene,

Thanks for the answer, but I want to use the TString like a
leaf in a ntuple. For example,

h1.Fill(track_number);  // for example track_number is 1 or 2

TString s="track_number";
h2.Fill(s,1); // do not fill the integer value of track_number

h1 gives 2 colonnes with values 1 or 2 and
h2 give histograms with a colonne named track_number

How can I do this properly to get h2 = h1 ?
And is it possible...

Thanks
Martin


On Sat, 15 May 2004, Rene Brun wrote:

> Hi Martin,
>
> On Fri, 14 May 2004, Martin Simard wrote:
>
> >
> > Hello,
> >
> > I want to fill histograms using TString like this.
> >
> > HistoName->Fill(Variable);
> >
> > Do Variable can be a TString??
>
> Yes, you can, but must specify the weight argument
>
> TString s="Martin"
> h.Fill(s,1);
>
> See an example in $ROOTSYS/tutorials/hlabels1.C
> Don't forget to:
>   h.SetBit(TH1::kCanRebin); //before filling
>   h.LabelsDeflate(); // before drawing
>
> These two calls are automatically generated when projecting a
> Tree string variable to a histogram.
>
> Rene Brun
>
> >
> >
> > I know there is a way to use a TString by Project like this.
> >
> > ntuple->Project(HistoName, Variable, weight(cut));
> >
> > For this case, How can I use this in a Loop over all entries?
> >
> >
> > Thanks
> > Martin
> >
>
>



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:08 MET