This seems a simple problem but I can’t find a solution.
I have a RooAbsPdf and I need to get the value at the maximum.
(Not the coordinates of the maximum but the value of the pdf at the maximum).
For the 1D case I solved it by:
- plotting the function in a RooPlot
- Getting the curve
- getting the maximum of the curve
- use asTF()
- use the GetMaximumX method of TF1
- use getVal() to get the pdf value at the maximum found.
But now I need to do it in many dimensions. Possibly an arbitrary N dimensions.
The two methods above do not seems generalisable to N dim (maybe not even 2). Any idea?
In case of 2 or 3 dimensions you can use the RooAbsReal::asTF method to transform to a TF2 or TF3 and then use the TF2(3)::GetMaximum.
Otherwise you can use directly the ROOT::Math::Minimizer interface to find the minimum of the function built from the negate of a RooAbsPdf.
You can use RooAbsReal::bindVars or RooAbsReal::iGenFunction to build a functor from the RooAbsPdf that you can then set as input to the ROOT::Math::Minimizer class.
Also you could use the RooMinimizer class. In that case you should build a RooAbsReal from the negate of your RooAbsPdf and pass this object as input to the RooMinimizer