TVirtualFitter with two histograms

Hello,
I am doing two fits inside a member function of a class and am calling TVirtualFitter so I can access the error matrix later:

TVirtualFitter fitter_zdR;
TVirtualFitter fitter_zdPhi;

void Line::Fit() throw(int){
zdR->Fit(FitFunc_zdR, “Q”);
fitter_zdR=TVirtualFitter::GetFitter();
zdPhi->Fit(FitFunc_zdPhi, “Q”);
fitter_zdPhi=TVirtualFitter::GetFitter();
}

however when examining the fitter_zdR and fitter_zdPhi I see it is pointing to the same object.

How can I do this so I end up with two distinct objects?

I have tried doing this by declaring in the header TFitter* fitter_zdR and doing (in the cpp)

fitter_zdR=new TFitter(3);
fitter_zdR->(TFitter*)TVirtualFitter::GetFitter();

but root complains that it doesn’t recognise the constructor:

undefined reference to `TFitter::TFitter(int)’
(isn’t this a valid constructor?)

I have also tried
fitter_zdR=(TFitter*)TVirtualFitter::GetFitter();
but this again leads to the two fitters pointing to the same object.

Note: I have to declare fitter_zdR and fitter_zdPhi in the header file so I can access them later in another function.

Cheers,
Ellie

you have to add libMinuit to the list of your library when linking.

Lorenzo