Is there a clever way how to integrate a TH2 histogram, when the integration range on y axis depends on x? Let’s say I have a line y=k*x+q (k and q are known doubles) and I want to integrate only above this line.
If no clever way exists, which way is the fastest? Bin-by-bin, via projections, …?
One could make a clone of the histogram and then play with this “clone”.
For example, one could manually loop over all “clone’s” bins and set the unwanted ones to 0.
One could also write a simple TF1 which would return 1 above the line and 0 below it and use the TH1::Multiply method to modify “clone’s” bins’ contents.
Then one could simply calculate the integral of the “clone”.
Another (very) easy way could be to create an appropriate TCutG and apply it while using TH2::ProjectionX or TH2::ProjectionY.
Then one could simply calculate the integral of the created “projection” histogram.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.