--------------470D4B377BFD
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
I am using 2 PAW ntuples h2root-ed. I want to overplot variables from
each file, normalized by entries. I can now sort out (see attachment) how
to normalize them when I have explicitly defined the histograms.
I am curious to know if I can also do it in the 'interactive' mode,
using the h10 TTree object, viz:
TFile f("file1.root");
TFile g("file2.root");
f.cd();
h10.Draw("momentum");
g.cd();
h10.Draw("momentum","","same");
Can I get pointers to these two histograms so I can normalize them
as per Rene's solution (in the attachment)?
Thanks,
Richard
-- Richard Dubois SLD, Stanford Linear Accelerator Center Richard@slac.stanford.edu http://www.slac.stanford.edu/~richard/ 415-926-3824 415-926-2923 (FAX)--------------470D4B377BFD Content-Type: message/rfc822 Content-Transfer-Encoding: 7bit Content-Disposition: inline
Received: from SERV04.SLAC.STANFORD.EDU (SERV04.SLAC.Stanford.EDU [134.79.16.134]) by mailbox.SLAC.Stanford.EDU (8.8.5/8.6.11) with SMTP id JAA20800 for <RICHARD@MAILBOX.SLAC.Stanford.EDU>; Tue, 1 Jul 1997 09:04:17 -0700 (PDT) Received: from DIRECTORY-DAEMON by SERV04.SLAC.STANFORD.EDU (PMDF V5.1-7 #16063) id <01IKPTJ774OW001DLU@SERV04.SLAC.STANFORD.EDU> for RICHARD@MAILBOX.SLAC.Stanford.EDU; Tue, 1 Jul 1997 09:04:17 -0700 (PDT) Received: from listbox2.cern.ch ("port 4894"@[137.138.24.200]) by SERV04.SLAC.STANFORD.EDU (PMDF V5.1-7 #16063) with ESMTP id <01IKPTJ5AJ70001FQ2@SERV04.SLAC.STANFORD.EDU> for richard@SLAC.Stanford.EDU; Tue, 01 Jul 1997 09:04:16 -0700 (PDT) Received: from hpbrun (hpbrun.cern.ch [128.141.201.206]) by listbox2.cern.ch (8.8.5/8.8.5) with SMTP id SAA06254 for <richard@SLAC.Stanford.EDU>; Tue, 01 Jul 1997 18:04:13 +0200 (MET DST) Date: Tue, 01 Jul 1997 18:00:12 +0200 From: Rene Brun <Rene.Brun@cern.ch> Subject: Re: root question Sender: brun@listbox2.cern.ch To: richard@SLAC.Stanford.EDU Message-id: <33B9298C.6401@mail.cern.ch> Organization: CERN. European Lab. for Particle Physics X-Envelope-to: RICHARD@MAILBOX.SLAC.Stanford.EDU MIME-version: 1.0 X-Mailer: Mozilla 2.02 (X11; I; HP-UX B.10.20 9000/755) Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit References: <33B926D0.530F@slac.stanford.edu> X-Authentication-warning: listbox2.cern.ch: Host hpbrun.cern.ch [128.141.201.206] claimed to be hpbrun
Richard Dubois wrote: > > Hi Rene, > > In a quick search I didn't find an address to send root questions... > > I want to do an overlay of two plots, normalized by the number of > entries for each. I haven't been able to figure out how to do the > normalization. How do I do it? >
Hi Richard, We have two lists roottalk and rootdev. To suscribe see http://root.cern.ch roottalk is a general discussion list (we have about 300 people now) rootdev is the Root developers. Send mail to rootdev@hpsalo.cern.ch for bug reports (if any). Now the answer to your question. Suppose you have a Root file containing two histograms h1 and h2 You can do: Root > float norm1 = 1/h1.GetEntries() Root > float norm2 = 1/h2.GetEntries() Root > TH1F hnorm1 = norm1*(*h1) Root > TH1F hnorm2 = norm2*(*h2) Root > hnorm1.Draw(); Root > hnorm2.Draw("same")
Note that if h1 and h2 are two TH1F objects (not pointers) created with TH1F h1(...) TH2F h2(..) you should replace the statement above TH1F hnorm1 = norm1*(*h1) by TH1F hnorm1 = norm1*h1 (*h1) dereferences the pointer (normal C++).
Rene
--------------470D4B377BFD--