Hello ROOTers,
I am trying to fit several histograms simultaneously, and originally used code directly adapted from the example at http://root.cern.ch/root/html/tutorials/fit/combinedFit.C.html.
Now I need to use quite a few more histograms and functions, and I’d really like to avoid passing each function by hand. I’ve tried to adapt the code so that I pass the GlobalChi2 struct a container of pointers to ROOT::Math::IMultiGenFunction objects instead of passing each ROOT::Math::IMultiGenFunction explicitly, but I’m running into problems.
In the orignal code, objects of type ROOT::Fit::Chi2Function were created in the main body of the function and passed by reference to a struct calling for ROOT::Math::IMultiGenFunction objects. But when I pass by reference a container of ROOT::Fit::Chi2Function * to a struct expecting a container of ROOT::Math::IMultiGenFunction *, I get an error:
[quote]error: no matching function for call to ‘GlobalChi2::GlobalChi2(std::vector<ROOT::Fit::Chi2Function*, std::allocatorROOT::Fit::Chi2Function* >&)’
/afs/crc.nd.edu/user/a/arobert4/neutwall.git/3He26Mg_analysis/fit/combinedFit_vec.C:37: note: candidates are: GlobalChi2::GlobalChi2(std::vector<ROOT::Math::IMultiGenFunction*, std::allocatorROOT::Math::IMultiGenFunction* >&)[/quote]
I’m not sure how to fix this. Making containers of the objects themselves fails because ROOT::Fit::Chi2Function doesn’t have an assignment operator. As far as I can tell, I need to make a container of pointers.
My understanding is that these two different types are necessary - the ROOT::Fit::Chi2Function can accept data and a function, while the ROOT::Math::IMultiGenFunction allows me to define the () operator, necessary for the fitter.
I’ve also explored fixing this by passing the fitter a vector of structs, where each struct takes a function. But I’m really not sure how to make this work with the call to the ROOT::Fit::Fitter; I can’t seem to match the function call the original code is making with anything in the documentation.
The version of ROOT I’m using is 5.30, running on linux with x86_64 architecture.
Many thanks for your time!
combinedFit_vec_simple.C (2.76 KB)