12#include "TDirectory.h"
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);
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);
49 TString m_name = hist_name +
"_1";
50 TH1D* hm = (TH1D*)gDirectory->Get(m_name)->Clone(
"hm");
53 B2DEBUG(199,
"Number of entries: " << hm->GetEntries());
54 TH1D* hlast = (TH1D*)hm->Clone(
"hlast");
56 hlast->SetName(m_name);
57 for (
int i = 1; i < h2->GetNbinsX(); ++i) {
61 TH1D* h1d = h2->ProjectionY(
"h1d", i, i);
63 sum = h1d->GetEntries();
64 if (sum < minHitCut)
continue;
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",
"");
71 mean = g1->GetParameter(1);
72 err = g1->GetParError(1);
74 double sg2 = g1->GetParameter(2);
75 h1d->Fit(
"g1",
"Q0",
"", mean - 1.1 * sg2, mean + 1.1 * sg2);
76 mean = g1->GetParameter(1);
79 hlast->SetBinContent(i, mean);
80 hlast->SetBinError(i, err);
Class to do the slice fit.
static TH1D * doSliceFitY(TH2D *h2, int minHitCut=0)
Do the slice fit for the 2d histogram.
Abstract base class for different kinds of events.