Dear root experts,
I am using TH2Poly for some application related to LHC data monitoring, they are very convenient for this particular case, however I found that it is impossible to merge files containing TH2Poly using the usual “hadd” function (Error in TH2Poly::Merge: Cannot merge TH2Poly).
I don’t know if it is a bug or an expected feature, in the second case can someone try to explain me why?
I see that the TH1::Add function works perfectly so I was quite sure that also the hadd would have worked, am I mistaking something?
Dear root experts,
TH2Poly is a 2D Histogram class (TH2) allowing to define polygonal bins of arbitrary shape. A merge operation is therefore in general not defined.
About this, can we provide a specific merging at least for TH2Poly of the very same type? This would be very useful, as an example, for CMS DQM code.
Anyway I still don’t get the point, if I have TH2 in two different files and I merge the files using hadd I can merge them or at least I get an error stating that the histos have different binning, what prevent to do so also for TH2Poly I can not really understand. Maybe shall I ask for a new root feature?
if you have a specific usecase, it would be great if you could formulate a request. As usual, we’ll do our best to support experiments.
Merging TH2Poly might be tricking in the general case because bins can be of any shape and there is a high probability of bins’ overlaps. This can be treated in many different ways. But there is no obvious default making every body happy…
But if you know you can merge the two histograms safely you can get the list of bins of one histogram using GetBins. It gives you the TList of all the bins. You can then iterate on it and do an AddBin on the other histogram for the bins you want to add.
Actually, as stated in my first message, the method Add(TH1*, c) is working perfectly for TH2Poly of the same type (i.e equal shapes of bins, equal number of bins), so, in interactive mode, there is no need to loop or to Get bins. They can be used just as “normal” 2D histograms.
What I would like to have is the “hadd” function to work properly for this case, so two files with TH2Poly of the same type should be mergeable like any other .root files with simple histograms. I will make a request for a new feature or maybe have a chat in person with Danilo if he is available at cern. Thanks anyway for your clarifications.