TH2::FitSlicesY()

the script that gives me this output is in the message below.
Apparently, the cint does not produce the hpxpy_[0-2]:

root [0]
Processing fitslicesy.C…
Error: Symbol hpxpy_0 is not defined in current scope fitslicesy.C:46:
Error: Failed to evaluate hpxpy_0->Draw()
*** Interpreter error recovered ***
root [1]

void fitslicesy() {
//
// To see the output of this macro, click begin_html <a href="gif/fitslicesy.gif" >here</a> end_html
//    This macro illustrates how to use the TH1::FitSlicesY function
//    It uses the TH2F histogram generated in macro hsimple.C
//    It invokes FitSlicesY and draw the fitted "mean" and "sigma"
//    in 2 sepate pads.
//    This macro shows also how to annotate a picture, change
//    some pad parameters.
//Author: Rene Brun
//changes:I.Rubinsky

// Change some default parameters in the current style
   gStyle->SetLabelSize(0.06,"x");
   gStyle->SetLabelSize(0.06,"y");
   gStyle->SetFrameFillColor(38);
   gStyle->SetTitleW(0.6);
   gStyle->SetTitleH(0.1);

// Connect the input file and get the 2-d histogram in memory
   TH2D *hpxpy = new TH2D("","",100,-5.,5.,100,-5.,5.);

// Create a canvas and divide it
   TCanvas *c1 = new TCanvas("c1","c1",700,500);
   c1->SetFillColor(42);
   c1->Divide(2,1);
   c1->cd(1);
   TPad *left = (TPad*)gPad;
   left->Divide(1,2);

// Draw 2-d original histogram
   left->cd(1);
   gPad->SetTopMargin(0.12);
   gPad->SetFillColor(33);
   hpxpy->Draw();
   hpxpy->GetXaxis()->SetLabelSize(0.06);
   hpxpy->GetYaxis()->SetLabelSize(0.06);
   hpxpy->SetMarkerColor(kYellow);

// Fit slices projected along Y fron bins in X [7,32]
   hpxpy->FitSlicesY(0,0,0,20);

// Show fitted "mean" for each slice
   left->cd(2);
   gPad->SetFillColor(33);
   hpxpy_0->Draw();
   c1->cd(2);
   TPad *right = (TPad*)gPad;
   right->Divide(1,2);
   right->cd(1);
   gPad->SetTopMargin(0.12);
   gPad->SetLeftMargin(0.15);
   gPad->SetFillColor(33);
   hpxpy_1->Draw();

// Show fitted "sigma" for each slice
   right->cd(2);
   gPad->SetTopMargin(0.12);
   gPad->SetLeftMargin(0.15);
   gPad->SetFillColor(33);
   hpxpy_2->SetMinimum(0.8);
   hpxpy_2->Draw();

//attributes
   hpxpy_0->SetLineColor(kYellow);
   hpxpy_1->SetLineColor(kYellow);
   hpxpy_2->SetLineColor(kYellow);
   hpxpy_0->SetMarkerColor(kRed);
   hpxpy_1->SetMarkerColor(kRed);
   hpxpy_2->SetMarkerColor(kRed);
   hpxpy_0->SetMarkerStyle(21);
   hpxpy_1->SetMarkerStyle(21);
   hpxpy_2->SetMarkerStyle(21);
   hpxpy_0->SetMarkerSize(0.6);
   hpxpy_1->SetMarkerSize(0.6);
   hpxpy_2->SetMarkerSize(0.6);
}

root version 5.14[/code]

Igor,

In your example hpxpy is empty, so there is nothing to fit.

Rene

Dear Rene,
it is not required to be non empty for the FitSlices to work? is it?
do you think if I have at least one entry in the histo it would work?
I will have a try. post it here shortly.
Igor

[quote=“brun”]Igor,

In your example hpxpy is empty, so there is nothing to fit.

Rene[/quote]

Dear Rene

the problem is in my oversimplification of a toy experiment:

it’s in this line here:

// Connect the input file and get the 2-d histogram in memory
   TH2D *hpxpy = new TH2D("","",100,-5.,5.,100,-5.,5.); 

the name of the histogram can not be empty !
the contents of the histogram can be.

[quote=“brun”]Igor,

In your example hpxpy is empty, so there is nothing to fit.

Rene[/quote]