Chi2 minimization to match MC to data


I have binned distributions of both MC and data, and I want to scale the MC distribution
to best fit the data distribution. I’m new to RooFit, and it wasn’t obvious to me how to
adapt the chi2fit tutorial to my use case. The TH1::Chi2Test method seemed to be much
closer to what I want, except for the minimization. Would I simply define a function that
calls the TH1::Chi2Test method with a scaling parameter and pass that user function to
the minimization routine directly? Or is there a better way?

Thanks for any help!