Discussion:
[ROOT] TH1D from TH2D's
Alberto Pulvirenti
2009-02-23 12:07:25 UTC
Permalink
Dear all,

I am doing an analysis job where I create the same 1D histogram for
several bins of a reference variable. I was wandering if it is possible
to do this with a TH2D, instead, but I should have the possibility to
take a single "row" of such TH2D to retrieve the corresponding TH1D with
only the entries in that row, because I think that this is less memory
demanding, and it could allow to have a very large number of bins in
both dimensions of the histogram, which would be of great advantage to me.

Is this possible in an automatic way?

Hope that the question is clear.

Thanks, cheers

Alberto
Mario Kadastik
2009-02-23 12:29:15 UTC
Permalink
Post by Alberto Pulvirenti
I am doing an analysis job where I create the same 1D histogram for
several bins of a reference variable. I was wandering if it is
possible to do this with a TH2D, instead, but I should have the
possibility to take a single "row" of such TH2D to retrieve the
corresponding TH1D with only the entries in that row, because I
think that this is less memory demanding, and it could allow to have
a very large number of bins in both dimensions of the histogram,
which would be of great advantage to me.
Is this possible in an automatic way?
http://root.cern.ch/root/html522/TH2.html

Look at the functions ProjectionX and ProjectionY. You can select just
one single bin as the start and stop and the resulting histogram
should be a 1D histogram of the other axis of that particular bin. I
have used this for exactly the purpose you plan to use it (to store N
TH1D histograms inside one TH2D histogram).

Mario
Philippe Canal
2009-02-23 14:49:14 UTC
Permalink
Hi Alberto,

It sounds like you need to store your data in a TTree and extract the
histogram on demand.

Cheers,
Philippe.
Post by Alberto Pulvirenti
Dear all,
I am doing an analysis job where I create the same 1D histogram for
several bins of a reference variable. I was wandering if it is
possible to do this with a TH2D, instead, but I should have the
possibility to take a single "row" of such TH2D to retrieve the
corresponding TH1D with only the entries in that row, because I think
that this is less memory demanding, and it could allow to have a very
large number of bins in both dimensions of the histogram, which would
be of great advantage to me.
Is this possible in an automatic way?
Hope that the question is clear.
Thanks, cheers
Alberto
Alberto Pulvirenti
2009-02-23 15:54:45 UTC
Permalink
Hi, this would be very nice, but unfortunately I think I will not be
allowed to do this, due to some restrictions, so I must rely on TH2D's.
The suggestion from Mario, using ProjectionX/Y is OK for my purposes.
If I will be allowed to use TTrees, this will be the best solution, anyway.

Thanks, best regards.

Alberto
Post by Philippe Canal
Hi Alberto,
It sounds like you need to store your data in a TTree and extract the
histogram on demand.
Cheers,
Philippe.
Post by Alberto Pulvirenti
Dear all,
I am doing an analysis job where I create the same 1D histogram for
several bins of a reference variable. I was wandering if it is
possible to do this with a TH2D, instead, but I should have the
possibility to take a single "row" of such TH2D to retrieve the
corresponding TH1D with only the entries in that row, because I think
that this is less memory demanding, and it could allow to have a very
large number of bins in both dimensions of the histogram, which would
be of great advantage to me.
Is this possible in an automatic way?
Hope that the question is clear.
Thanks, cheers
Alberto
Continue reading on narkive:
Loading...