TH3F for storing 2D matrix with 2 infos per pixel

Hi,

I have a question about the use of TH3F: I would need a 2D matrix of pixels, where for each pixel I have two values (e.g. energy and time, both double). So I want to fill a TH3F with (row, col, time, energy), then find the clusters in the 2D matrix (row-col), and be able to extract the time and energy about each pixel in the clusters. Once I extract the clusters I write all the info in a TTree.

So far I worked with only one info per pixel (e.g. energy), so a TH2F was perfect for doing the job. I have never worked with the TH3 class so I’d like to naively ask if I can use it in the same way to store the 2 infos per pixel.

Thanks!


ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


@couet, perhaps you can help here please?

I am not really sure how to extend what you do with a TH2F to TH3F. Let me guess:
You will create a TH3F with only 2 bins along the Z axis, so you will have two “layers” along Z ? the bin content of the 1st layer will time and the 2nd energy ?

I don’t really know how to do it, I just wondered if it’s somehow possible… If I do as you suggest, then how do I fill the TH3F so that it has 2 “z” layers? I mean if for the TH2F I now do
histo->Fill(Col, Row, energy),
I cannot simply move to
histo->Fill(Col, Row, energy, time)
cause then the energy will be considered the “z” value and the “time” as the actual content of the (x,y,z) bin…

Imagine that the Z axis has 2 bins from (for instance 0 to 2.) That would be:

histo->Fill(Col, Row, .0.5, time); // first layer filled with time
histo->Fill(Col, Row, .1.5, energy); // second layer filled with energy

But that’s not really practical if you want to produce a color for time and an other one for energy… Why not having 2 TH2F … ? one for time and one for energy ?

The thing is that I want to use the Row-Col matrix to find the clusters and once I’ve found a cluster I want to be able to extract the energy and time info for each pixel in the cluster at once… that’s all I need, then I will write this info into another file. So I think the method you proposed should work, I will try it… Thanks!

You mean the one based on a single TH3F or the one based on two TH2F ?

On a single one with two layers, no?

Yes I explained you how you could do if you want to have a TH3F but as I said it might be difficult to handle it when you will want to plot it. At the end what you have with these two layers is two TH2F stored in a TH3F … If at some point to need to have the TH2F (for any reason) why not having them right from the beginning ? I do not see the advantage of having a TH3F in your case.

But then I would have to run the same clustering algorithm twice? :thinking:

Ok up to you … if you think it is better with a single TH3 just try …

@couet Yepp with the TH3F and the 2 layers it works a charm exactly as I needed it. Thanks! :partying_face:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.