1 |
|
2 |
|
3 |
|
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;
|
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 |
if(h->GetEntries() < 5) continue;
|
26 |
if(useFit){
|
27 |
|
28 |
func->SetParameter(0,h->GetMaximum());
|
29 |
func->SetParameter(1,h->GetMean());
|
30 |
func->SetParameter(2,h->GetRMS());
|
31 |
|
32 |
h->Fit(func);
|
33 |
|
34 |
hMean->SetBinContent(i,func->GetParameter(1));
|
35 |
hMean->SetBinError(i,func->GetParError(1));
|
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 |
}
|
48 |
}
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|