Dear all,
I have been attempting to migrate some code to TVirtualFitter that was built using TFitterMinuit, and am having little success. The original code is[code]class MinLogLike: public ROOT::Minuit2::FCNBase{
private:
vector costhetax_posi;
vector costhetay_posi;
vector costhetaz_posi;
vector costhetax_nega;
vector costhetay_nega;
vector costhetaz_nega;
public:
MinLogLike(vector cosx_posi,vector cosy_posi,vector cosz_posi,vector cosx_nega,vector cosy_nega,vector cosz_nega){
costhetax_posi=cosx_posi;
costhetay_posi=cosy_posi;
costhetaz_posi=cosz_posi;
costhetax_nega=cosx_nega;
costhetay_nega=cosy_nega;
costhetaz_nega=cosz_nega;
}
double operator() (const std::vector &x) const {
double sposi = 0.0, snega = 0.0;
for (Int_t i=0; i<costhetax_posi.size(); i++) {
sposi+=-TMath::Log((1.0+x[0]*costhetax_posi[i]+x[1]*costhetaz_posi[i]+x[2]*costhetay_posi[i]));
}
for (Int_t i=0; i<costhetax_nega.size(); i++) {
snega+=-TMath::Log((1.0-x[0]*costhetax_nega[i]-x[1]*costhetaz_nega[i]+x[2]*costhetay_nega[i]));
}
return sposi+snega;
}
double Up() const { return 0.5; }
};[/code]
and the class used later as TFitterMinuit* pMinuit = new TFitterMinuit();
MinLogLike minloglike(cosx_posi,cosy_posi,cosz_posi,cosx_nega,cosy_nega,cosz_nega);
pMinuit->SetMinuitFCN(&minloglike);
Trying to update this code has proven quite troublesome for me. There appears to be two places where I am struggling. The first place is in the class definition and the second place is calling the class. My original idea in updating this code was to just update the class definitions and function call/options. Currently, here is my updated code:
[code]#include āTVirtualFitter.hā
#include āTMinuit.hā
#include āMath/Minimizer.hā
//#include "TFitterMinuit.h"
using namespace std;
class MinLogLike: public ROOT::Math::Minimizer{
private:
vector costhetax_posi;
vector costhetay_posi;
vector costhetaz_posi;
vector costhetax_nega;
vector costhetay_nega;
vector costhetaz_nega;
public:
MinLogLike(vector cosx_posi,vector cosy_posi,vector cosz_posi,vector cosx_nega,vector cosy_nega,vector cosz_nega){
costhetax_posi=cosx_posi;
costhetay_posi=cosy_posi;
costhetaz_posi=cosz_posi;
costhetax_nega=cosx_nega;
costhetay_nega=cosy_nega;
costhetaz_nega=cosz_nega;
}
double operator() (const std::vector &x) const {
double sposi = 0.0, snega = 0.0;
for (Int_t i=0; i<costhetax_posi.size(); i++) {
sposi+=-TMath::Log((1.0+x[0]*costhetax_posi[i]+x[1]*costhetaz_posi[i]+x[2]*costhetay_posi[i]));
}
for (Int_t i=0; i<costhetax_nega.size(); i++) {
snega+=-TMath::Log((1.0-x[0]*costhetax_nega[i]-x[1]*costhetaz_nega[i]+x[2]*costhetay_nega[i]));
}
return sposi+snega;
}
double Up() const { return 0.5; }
};[/code]
and [code] TVirtualFitter *pMinuit = TVirtualFitter::Fitter(0, 6);//Fitter with up to 6 params
MinLogLike minloglike(cosx_posi,cosy_posi,cosz_posi,cosx_nega,cosy_nega,cosz_nega);
pMinuit->SetFCN(&minloglike);[/code]
When I attempt to run the macro, I receive the following errors:
[quote]/Users/Colin/Desktop/final_skim/Observables/2d/unprimed/root6/hist_2d_fit.C:172:16: error:
variable type āMinLogLikeā is an abstract class
MinLogLike minloglike(cosx_posi,cosy_posi,cosz_posi,cosx_nega,cosy_nā¦
^
/opt/local/root-6.06.02/include/Math/Minimizer.h:128:17: note: unimplemented
pure virtual method āSetFunctionā in 'MinLogLikeā
virtual void SetFunction(const ROOT::Math::IMultiGenFunction & func) = 0;
^
/opt/local/root-6.06.02/include/Math/Minimizer.h:161:17: note: unimplemented
pure virtual method āSetVariableā in 'MinLogLikeā
virtual bool SetVariable(unsigned int ivar, const std::string & nameā¦
^
/opt/local/root-6.06.02/include/Math/Minimizer.h:253:18: note: unimplemented
pure virtual method āMinimizeā in 'MinLogLikeā
virtual bool Minimize() = 0;
^
/opt/local/root-6.06.02/include/Math/Minimizer.h:256:19: note: unimplemented
pure virtual method āMinValueā in 'MinLogLikeā
virtual double MinValue() const = 0;
^
/opt/local/root-6.06.02/include/Math/Minimizer.h:259:28: note: unimplemented
pure virtual method āXā in 'MinLogLikeā
virtual const double * X() const = 0;
^
/opt/local/root-6.06.02/include/Math/Minimizer.h:275:25: note: unimplemented
pure virtual method āNDimā in 'MinLogLikeā
virtual unsigned int NDim() const = 0;[/quote]
Iāve tried some different class definitions and calls, but all result in an error. I havenāt been able to find anything in the forums that directly deal with an issue like this. Can anyone provide any help on this migration to TVirtualFitter from TFitterMinuit?