Hi
Bob,
I am still confused by the use of the histogram(name) method -- the root of
my original question. It looks like it returns a Histogram object that is
trapped at compile time since (as per item 3.) one cannot use the statistics
methods on Histogram directly. This seems to contradict example 1. (which
would be very useful).
"Johnson, Tony S." wrote:
1) The histogram(name)
method in EventAnalyzer returns a histogram. You can do anything with that
histogram that you would do with a histogram created using new
Histogram(name). E.g.
histogram("xyz").fill(10); double
mean = histogram("xyz").getMean(); Histogram xyz =
histogram("xyz");
to be more precise, the Histogram(name)
method does the following:
Thus it is possible to use the histogram method with a
Histogram1D, IF you create the Histogram1D manually and then subsequently use
histogram(name) to find it. In this case you would be able to cast the returned
histogram to a Histogram1D, and use the getMean()
method:
// Construtor
new
Histogram1D("Bobs1DHistogram");
// somewhere else
((Histogram1D) histogram()).getMean();
If you do not explicitly create the histogram using new
Histogram1D() then the histogram method will just create you a Histogram, and
the cast will fail (since a Histogram is not in general a
Histogram1D).
The problem here is that it is not convenient to have
to explicitly create the histograms, especially in the case where you want to
dynamically create the names for the histograms, which is why I suggested a
different way to do it in my earlier e-mail. Maybe what we should add is a way
to specify what type of Histogram you want histogram() to create, perhaps on a
folder by folder basis.
Finally, for my continuing Java education ....
4) You can rename histograms with the rename method, but you
must catch the RenameException, since some histograms may not support being
renamed. In this instance you probably don't really want to use
renaming.I've attached an
example which illustrates all of this.Tony
I wasnt expecting
people to directly call the rename method, so I made this a bit obscure (as
opposed to everything else which is crystal clear of course). The
RenameException is an internal class of NamedObject. So its full name
is:
hep.analysis.NamedObject.RenameException
so even if you have
import
hep.analysis.*;
you still need to
refer to it as NamedObject.RenameException. I think you can also do
a:
import
hep.analysis.NamedObject.*;
The reason for doing
it this way was to avoid further polluting the hep.analysis.* name space with
what I thought would be an obscure and rarely used
exception.
Tony