Belle II Software development
SliceFit Class Reference

Class to do the slice fit. More...

#include <SliceFit.h>

Static Public Member Functions

static TH1D * doSliceFitY (TH2D *h2, int minHitCut=0)
 Do the slice fit for the 2d histogram.
 

Detailed Description

Class to do the slice fit.

Definition at line 25 of file SliceFit.h.

Member Function Documentation

◆ doSliceFitY()

static TH1D * doSliceFitY ( TH2D *  h2,
int  minHitCut = 0 
)
inlinestatic

Do the slice fit for the 2d histogram.

Definition at line 30 of file SliceFit.h.

31 {
32 gPrintViaErrorHandler = kTRUE;
33 gErrorIgnoreLevel = 3001;
34 TString hist_name = h2->GetName();
35 double ub = h2->GetYaxis()->GetXmax();
36 double lb = h2->GetYaxis()->GetXmin();
37 B2DEBUG(199, "Axis: " << lb << " " << ub);
38 if ((h2->GetEntries() / h2->GetNbinsX()) < 30) {
39 B2WARNING("Low statictic: " << h2->GetEntries() << " Hits");
40 h2->Rebin2D(2, 2, hist_name);
41 }
42
43 B2DEBUG(199, "Slice fit for histo " << hist_name);
44 B2DEBUG(199, "Number of entries: " << h2->GetEntries());
45 TF1* g1 = new TF1("g1", "gaus", lb, ub);
46 h2->FitSlicesY(0, 0, -1, minHitCut);
47
48
49 TString m_name = hist_name + "_1";
50 TH1D* hm = (TH1D*)gDirectory->Get(m_name)->Clone("hm");
51 if (!hm) return 0;
52
53 B2DEBUG(199, "Number of entries: " << hm->GetEntries());
54 TH1D* hlast = (TH1D*)hm->Clone("hlast");
55 hlast->Reset();
56 hlast->SetName(m_name);
57 for (int i = 1; i < h2->GetNbinsX(); ++i) {
58 double sum = 0;
59 double err = 0;
60 double mean = -99;
61 TH1D* h1d = h2->ProjectionY("h1d", i, i);
62 if (!h1d) continue;
63 sum = h1d->GetEntries();
64 if (sum < minHitCut) continue; //skip low data slice
65 mean = h1d->GetMean();
66 double sg = h1d->GetRMS();
67 double max = h1d->GetMaximum();
68 g1->SetParameters(max, mean, sg);
69 h1d->Fit("g1", "QNR", "");
70 // TF1 *f1=h1d->GetFunction("gaus");
71 mean = g1->GetParameter(1);
72 err = g1->GetParError(1);
73 if (sum > 50) {
74 double sg2 = g1->GetParameter(2);
75 h1d->Fit("g1", "Q0", "", mean - 1.1 * sg2, mean + 1.1 * sg2);
76 mean = g1->GetParameter(1);
77 // err=g1->GetParError(1);
78 }
79 hlast->SetBinContent(i, mean);
80 hlast->SetBinError(i, err);
81 h1d->Delete();
82 }
83 return hlast;
84 }

The documentation for this class was generated from the following file: