1 |
|
|
2 |
|
|
3 |
|
|
4 |
< |
void fitSlices(TH2* hCorr, TF1* func = 0){ |
4 |
> |
void fitSlices(TH2* hCorr, TF1* func = 0, bool variableBins = 0){ |
5 |
|
|
6 |
|
bool useFit = func != 0; |
7 |
|
|
8 |
|
int nBins = hCorr->GetNbinsX(); |
9 |
|
|
10 |
< |
TH1D* hMean = new TH1D(Form("%s_1",hCorr->GetName()),"",nBins,hCorr->GetXaxis()->GetXmin(),hCorr->GetXaxis()->GetXmax()); |
11 |
< |
TH1D* hSigma = new TH1D(Form("%s_2",hCorr->GetName()),"",nBins,hCorr->GetXaxis()->GetXmin(),hCorr->GetXaxis()->GetXmax()); |
10 |
> |
TH1D* hMean; |
11 |
> |
TH1D* hSigma; |
12 |
> |
|
13 |
> |
if(variableBins){ |
14 |
> |
hMean = new TH1D(Form("%s_1",hCorr->GetName()),"",hCorr->GetNbinsX(),hCorr->GetXaxis()->GetXbins()->GetArray()); |
15 |
> |
hSigma = new TH1D(Form("%s_2",hCorr->GetName()),"",hCorr->GetNbinsX(),hCorr->GetXaxis()->GetXbins()->GetArray()); |
16 |
> |
}else{ |
17 |
> |
hMean = new TH1D(Form("%s_1",hCorr->GetName()),"",nBins,hCorr->GetXaxis()->GetXmin(),hCorr->GetXaxis()->GetXmax()); |
18 |
> |
hSigma = new TH1D(Form("%s_2",hCorr->GetName()),"",nBins,hCorr->GetXaxis()->GetXmin(),hCorr->GetXaxis()->GetXmax()); |
19 |
> |
} |
20 |
|
|
21 |
|
for(int i = 1; i < nBins+1; ++i){ |
22 |
|
int bin = nBins - i; |
23 |
|
TH1D* h = hCorr->ProjectionY(Form("%s_bin%d",hCorr->GetName(),bin),i,i); |
24 |
|
|
25 |
< |
|
25 |
> |
if(h->GetEntries() < 5) continue; |
26 |
|
if(useFit){ |
27 |
|
|
28 |
|
func->SetParameter(0,h->GetMaximum()); |
36 |
|
hSigma->SetBinContent(i,func->GetParameter(2)); |
37 |
|
hSigma->SetBinError(i,func->GetParError(2)); |
38 |
|
}else{ |
39 |
+ |
|
40 |
|
hMean->SetBinContent(i,h->GetMean()); |
41 |
|
hMean->SetBinError(i,h->GetMeanError()); |
42 |
|
hSigma->SetBinContent(i,h->GetRMS()); |
43 |
|
hSigma->SetBinError(i,h->GetRMSError()); |
44 |
+ |
|
45 |
|
} |
46 |
|
|
47 |
|
} |