Hi Rene,
I did not hear back from you. So let me give you an example (should have
done that immediately). I modified in the tutorial examples the one
that fits the slices. Instead of reading in the hpxpy from a file,
I create it locally. You can see that I either fill it through
hpxpy->Fill(px,py,1.0) or hpxpy->Fill(px,py,1.0e-5). I have reduced
"cut" to -100 so it does not kick in.
In the first case things work fine but in the second one all slices are
skipped because "Int_t(nrentries) == 0".
{
//
// 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.
//
gROOT->Reset();
// 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
// TFile *hsimple = new TFile("hsimple.root");
// TH2F *hpxpy = (TH2F*)hsimple->Get("hpxpy");
TH2F *hpxpy = new TH2F("hpxpy","py vs px",40,-4,4,40,-4,4);
gRandom->SetSeed();
Float_t px, py, pz;
for (Int_t i = 0; i < 25000; i++) {
gRandom->Rannor(px,py);
pz = px*px + py*py;
Float_t random = gRandom->Rndm(1);
//hpxpy->Fill(px,py,1.0);
hpxpy->Fill(px,py,1.0e-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);
hpxpy->FitSlicesY(0,0,0,-100);
// 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);
}
> Date: Thu, 18 May 2000 07:36:44 +0000
> From: Rene Brun <Rene.Brun@cern.ch>
> MIME-Version: 1.0
> To: Eddy Offermann <eddy@rentec.com>
> CC: roottalk@pcroot.cern.ch
> Subject: Re: [ROOT] FitSlicesX/Y
> Content-Transfer-Encoding: 7bit
>
> Hi Eddy,
> Could you clarify your problem ? TH1::FitSlicesX/Y has a parameter "cut"
> to reject slices with a number of entries (not the sum of weights) less than
> cut.
>
> Rene Brun
>
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:25 MET