Re: [ROOT] Add Histograms

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Aug 09 2002 - 22:59:07 MEST


Hi Mat,

You have two options

-option 1
t1->Draw("APHOE>>h1");
t1->Draw("BPHOE>>+h1"); // add to existing h1

-option 2
t1->Draw("APHOE>>h1");
t1->Draw("BPHOE>>h2");
TH1F *h1 = (TH1F*)gDirectory->Get("h1");
TH1F *h2 = (TH1F*)gDirectory->Get("h2");
h1->Add(h2);

see doc of TTree::Draw, eg at:

http://root.cern.ch/root/htmldoc/src/TTree.cxx.html#TTree:Draw

Rene Brun

On Fri, 9 Aug 2002, matthew dunseth wood wrote:

> I am trying to add two histograms that I generated with TTree::Draw.  The
> commands I typed are as follows:
> 
> TFile f("atlfast.root");
> TTree *t1 = (TTree*)f.Get("Atlfast/50");
> 
> t1->Draw("APHOE>>h1");
> t1->Draw("BPHOE>>h2");
> 
> h1->Add(h2);
> 
> When I attempt to add the histograms I get the following:
> 
> Error: Symbol h2 is not defined in current scope 
> FILE:/tmp/filewYtM0M_cint LINE:1
> *** Interpreter error recovered ***
> 
> Why is h2 not defined in current scope?  For that matter what is the
> current scope?  My knowledge of C++ is quite rudimentary so excuse me if
> the answer to this is obvious.
> 
> Matthew Wood
> 
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:04 MET