This is helpful...but imagine this variation: What if MyCodeA and
MyCodeB have the same set of histograms, with the same names -- in fact, all
that is different between MyCodeA and MyCodeB is that they are based on files
that have ntuples with the same structure, but different content. This is not
a crazy situation, I think; I have two data samples, I make the same set of
plots out of them, and I want to compare. But once I run do b.Loop(), all the
histograms made in a.Loop() get replaced (because they have the same names),
and I'm lost again.
In PAW, one could have two histograms with the same number, as long as
they were in different subdirectories, e.g. //LUN1 and //LUN2. Am I allowed
to do the same sort of thing now?
Or better still -- why should I have to have MyCodeA and MyCodeB if
they only differ by the name of the file that they are opening? Is there some
variant of the MakeClass output that I can use which would allow me to easily
change the name of the file that provides the ntuple?
Thanks for your help -- I really expect to understand all of this
someday. Best wishes.
Ken
On Wed, 27 Feb 2002, Rene Brun wrote:
> Hi Ken,
>
> Very easy.
> Assuming MyCodeA a;
> a.fChain->GetDirectory()->ls()
>
> To get one histogram from the corresponding directory, do, eg:
> TH1F *h = (TH1F*)a.fChain->GetDirectory()->Get(hist_name);
>
> Rene Brun
>
> On Wed, 27 Feb 2002, Ken Bloom wrote:
>
> > Dear ROOT,
> >
> > I have two different ROOT ntuples, in two different files. I use the
> > MakeClass method to give me a skeleton of code that allows me to create and
> > fill histograms based on the contents of the two ntuples, and I can use these
> > classes like so:
> >
> > .L MyCodeA.C
> > MyCodeA a;
> > a.Loop();
> > .L MyCodeB.C
> > MyCodeB b;
> > b.Loop();
> >
> > By doing this, TFile objects are being created inside a and b, but I never get
> > to see those.
> >
> > Now, I would like to compare the histograms made by a to those made by
> > b. At this point, I believe I'm in a directory that belongs to b, so I can
> > see the histograms made by b, but seeing the ones made by a is harder. I know
> > that I can see a list of those histograms via something like:
> >
> > TFile* f1 =
> > (TFile*)gROOT->GetListOfFiles()->FindObject("/path/name/of/file");
> > f1.Print();
> >
> > but I seem to have trouble then grabbing the histograms in said list.
> >
> > So how can I get to use both sets of histograms simultaneously? And
> > is there a way to do this without going through gROOT? I feel like I did
> > things like this in PAW, and that it was much easier! Thanks, best wishes.
> >
> > Ken
> >
> > ------------------------------------------------------------------------------
> > Ken Bloom, Karma Adjuster Department of Physics
> > 734-763-2329 / 734-936-1817 (fax) University of Michigan
> > kenbloom@umich.edu http://www.umich.edu/~kenbloom
> >
> >
>
------------------------------------------------------------------------------
Ken Bloom, Karma Adjuster Department of Physics
734-763-2329 / 734-936-1817 (fax) University of Michigan
kenbloom@umich.edu http://www.umich.edu/~kenbloom
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:43 MET