Re: TF3::GetHistogram() seg violation

From: Olivier Couet <Olivier.Couet_at_cern.ch>
Date: Wed, 30 Mar 2011 11:39:02 +0000


Hi,

The TF3 constructor had a wrong number of parameter. GetHistogram works after a Draw()

Try:

    TF3* test_f3=new TF3("test_f3",test,0,10,0,10,0,10,2);

    test_f3->SetParameters(1,2);
    test_f3->SetNpx(nPoints);
    test_f3->SetNpy(nPoints);
    test_f3->SetNpz(nPoints);
    

    cout<<"Test function3 test = "<<test_f3->Eval(5,5,5)<<endl;     

    test_f3->Draw();
    TH3F* test3_hist=(TH3F*)test_f3->GetHistogram();

On 3/30/11 12:11 PM, "Serhiy Senyukov" <Serhiy.Senyukov_at_cern.ch> wrote:

>#include <TF2.h>
>#include <TF3.h>
>#include <TH2.h>
>#include <TH3.h>
>
>Double_t test(Double_t *x, Double_t *par)
>{
> return 100;
>}
>
>void bugtest(Int_t nPoints=5){
> TF2* test_f2=new TF2("test_f2",test,0,10,0,10,2);
> test_f2->SetParameters(1,2);
> test_f2->SetNpx(nPoints);
> test_f2->SetNpy(nPoints);
>
> TF3* test_f3=new TF3("test_f3",test,0,10,0,10,2);
> test_f3->SetParameters(1,2);
> test_f3->SetNpx(nPoints);
> test_f3->SetNpy(nPoints);
> test_f3->SetNpz(nPoints);
>
> cout<<"Test function2 test = "<<test_f2->Eval(5,5)<<endl;
> cout<<"Test function3 test = "<<test_f3->Eval(5,5,5)<<endl;
>
> TH2F* test2_hist=(TH2F*)test_f2->GetHistogram();
> TH3F* test3_hist=(TH3F*)test_f3->GetHistogram();
>}
Received on Wed Mar 30 2011 - 13:39:07 CEST

This archive was generated by hypermail 2.2.0 : Wed Mar 30 2011 - 17:50:01 CEST