1 |
buchmann |
1.1 |
#include <iostream>
|
2 |
|
|
#include <sstream>
|
3 |
|
|
#include <iomanip>
|
4 |
|
|
#include <TFile.h>
|
5 |
|
|
#include <TTree.h>
|
6 |
|
|
#include <TH1.h>
|
7 |
|
|
#include <TF1.h>
|
8 |
|
|
#include <TMath.h>
|
9 |
|
|
#include <TCanvas.h>
|
10 |
|
|
#include <vector>
|
11 |
|
|
#include <TROOT.h>
|
12 |
|
|
#include <TLine.h>
|
13 |
|
|
#include <TLegend.h>
|
14 |
|
|
#include <TLatex.h>
|
15 |
|
|
#include <TRandom.h>
|
16 |
|
|
#ifndef GeneralToolBoxLoaded
|
17 |
|
|
#include "GeneralToolBox.C"
|
18 |
|
|
#endif
|
19 |
|
|
#ifndef Verbosity
|
20 |
|
|
#define Verbosity 0
|
21 |
|
|
#endif
|
22 |
|
|
|
23 |
|
|
using namespace std;
|
24 |
|
|
|
25 |
|
|
Double_t LogParabola(Double_t *x,Double_t *par)
|
26 |
|
|
{
|
27 |
|
|
return par[0]*TMath::Exp(-par[1]*(x[0]-par[2])*(x[0]-par[2])); // we're adding a "logarithmic parabola" :-)
|
28 |
|
|
//note: the abs() around the first parameter ensures that, when fitting, no negative values are chosen.
|
29 |
|
|
}
|
30 |
|
|
|
31 |
buchmann |
1.2 |
Double_t LogParabolaP(Double_t *x,Double_t *par)
|
32 |
|
|
{
|
33 |
|
|
float fitval = par[0]*TMath::Exp(-par[1]*(x[0]-par[2])*(x[0]-par[2])); // we're adding a "logarithmic parabola" :-)
|
34 |
|
|
fitval+= statErrorP(fitval);
|
35 |
|
|
return fitval;
|
36 |
|
|
}
|
37 |
|
|
|
38 |
|
|
Double_t LogParabolaN(Double_t *x,Double_t *par)
|
39 |
|
|
{
|
40 |
|
|
float fitval = par[0]*TMath::Exp(-par[1]*(x[0]-par[2])*(x[0]-par[2])); // we're adding a "logarithmic parabola" :-)
|
41 |
|
|
fitval-= statErrorN(fitval);
|
42 |
|
|
return fitval;
|
43 |
|
|
}
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
|
47 |
buchmann |
1.1 |
bool doreject=false;
|
48 |
|
|
float low_reject=-10;
|
49 |
|
|
float hi_reject=10;
|
50 |
|
|
|
51 |
|
|
bool dofixed=true;
|
52 |
|
|
|
53 |
|
|
|
54 |
|
|
bool addparabola=true;
|
55 |
|
|
float parabola_height=0;
|
56 |
|
|
float parabola_inclination=0;
|
57 |
|
|
float parabola_pointzero=0;
|
58 |
|
|
|
59 |
|
|
float find_KM_peak(TH1F *all, TH1F *ttbar, float minfit, float maxfit, bool is_data, float &error,float &Sigma);
|
60 |
|
|
float find_Gauss_peak(TH1F *all, TH1F *ttbar, float minfit, float maxfit, bool is_data, float &error,float &Sigma,int numsig);
|
61 |
|
|
|
62 |
buchmann |
1.8 |
Double_t CrystalBallPlusLogParabola(double *x, double *par)
|
63 |
|
|
{
|
64 |
|
|
//parameters:
|
65 |
|
|
//N: the way we scale the function
|
66 |
|
|
//alpha (where the function changes)
|
67 |
|
|
//n: exponent of the power expression in the left area
|
68 |
|
|
//xbar: peak of the gaussian part (RHS)
|
69 |
|
|
//sigma: width of the gaussian part (RHS)
|
70 |
|
|
float N=par[0];
|
71 |
|
|
float alpha=par[3]; //verified (orig: 1)
|
72 |
|
|
float n=par[4]; // verified (orig: 2)
|
73 |
|
|
float xbar=par[1]; //verified (orig: 3)
|
74 |
|
|
float sigma=par[2]; //verified (orig: 4)
|
75 |
|
|
float altX=-x[0];
|
76 |
|
|
float result=-999;
|
77 |
|
|
if(((altX-xbar)/sigma>-alpha)){
|
78 |
|
|
result=N*TMath::Exp(-(altX-xbar)*(altX-xbar)/(2*sigma*sigma));
|
79 |
|
|
}
|
80 |
|
|
else
|
81 |
|
|
{
|
82 |
|
|
//if we are outside the central (Gaussian) area things become more difficult ...
|
83 |
|
|
float A=TMath::Power(n/TMath::Abs(alpha),n)*TMath::Exp(-alpha*alpha/2);
|
84 |
|
|
float B=n/TMath::Abs(alpha) - TMath::Abs(alpha);
|
85 |
|
|
if((altX-xbar)/sigma<=-alpha) result=N*A*TMath::Power((B-((altX-xbar)/sigma)),-n);
|
86 |
|
|
if((altX-xbar)/sigma>=alpha) result=N*A*TMath::Power((B+((altX-xbar)/sigma)),-n);
|
87 |
|
|
}
|
88 |
|
|
|
89 |
|
|
result+=par[5]*TMath::Exp(-par[6]*(x[0]-par[7])*(x[0]-par[7])); // we're adding a "logarithmic parabola" :-)
|
90 |
|
|
if(par[5]<0) return -999; // there can be no negative ttbar contribution, so just return a value which is going to be a horrible fit.
|
91 |
|
|
if(par[6]<0) return -999; // the parabola needs to close (i.e. tend to negative values for large |jzb|, not to large positive values)
|
92 |
|
|
|
93 |
|
|
return result;
|
94 |
|
|
}
|
95 |
|
|
|
96 |
|
|
Double_t CrystalBallPlusLogParabolaP(double *x, double *par)
|
97 |
|
|
{
|
98 |
buchmann |
1.10 |
float parameter_bkp=par[5];
|
99 |
|
|
par[5]=0;
|
100 |
|
|
float zjetsresult=CrystalBallPlusLogParabola(x,par);
|
101 |
|
|
par[5]=parameter_bkp;
|
102 |
|
|
parameter_bkp=par[0];
|
103 |
|
|
par[0]=0;
|
104 |
|
|
float ttbarresult=CrystalBallPlusLogParabola(x,par);
|
105 |
|
|
par[0]=parameter_bkp;
|
106 |
|
|
return zjetsresult+ttbarresult+TMath::Sqrt(zjetsresult+(1.0/3.0)*ttbarresult);
|
107 |
buchmann |
1.8 |
}
|
108 |
|
|
|
109 |
|
|
Double_t CrystalBallPlusLogParabolaN(double *x, double *par)
|
110 |
|
|
{
|
111 |
buchmann |
1.10 |
float parameter_bkp=par[5];
|
112 |
|
|
par[5]=0;
|
113 |
|
|
float zjetsresult=CrystalBallPlusLogParabola(x,par);
|
114 |
|
|
par[5]=parameter_bkp;
|
115 |
|
|
parameter_bkp=par[0];
|
116 |
|
|
par[0]=0;
|
117 |
|
|
float ttbarresult=CrystalBallPlusLogParabola(x,par);
|
118 |
|
|
par[0]=parameter_bkp;
|
119 |
|
|
return zjetsresult+ttbarresult-TMath::Sqrt(zjetsresult+(1.0/3.0)*ttbarresult);
|
120 |
buchmann |
1.8 |
}
|
121 |
buchmann |
1.1 |
|
122 |
|
|
Double_t KrystalMallLogPar(double *x, double *par)
|
123 |
|
|
{
|
124 |
|
|
//parameters:
|
125 |
|
|
//N: the way we scale the function
|
126 |
|
|
//alpha (where the function changes)
|
127 |
|
|
//n: exponent of the power expression in the left area
|
128 |
|
|
//xbar: peak of the gaussian part (RHS)
|
129 |
|
|
//sigma: width of the gaussian part (RHS)
|
130 |
|
|
float N=par[0];
|
131 |
|
|
float alpha=par[1];
|
132 |
|
|
float n=par[2];
|
133 |
|
|
float xbar=par[3];
|
134 |
|
|
float sigma=par[4];
|
135 |
|
|
float altX=x[0];
|
136 |
|
|
float result=-999;
|
137 |
|
|
if(doreject&&x[0]>low_reject&&x[0]<hi_reject)
|
138 |
|
|
{
|
139 |
|
|
TF1::RejectPoint();
|
140 |
|
|
return 0;
|
141 |
|
|
}
|
142 |
|
|
if(((altX-xbar)/sigma>-alpha)&&((altX-xbar)/sigma<alpha)){
|
143 |
|
|
result=N*TMath::Exp(-(altX-xbar)*(altX-xbar)/(2*sigma*sigma));
|
144 |
|
|
}
|
145 |
|
|
else
|
146 |
|
|
{
|
147 |
|
|
//if we are outside the central (Gaussian) area things become more difficult ...
|
148 |
|
|
float A=TMath::Power(n/TMath::Abs(alpha),n)*TMath::Exp(-alpha*alpha/2);
|
149 |
|
|
float B=n/TMath::Abs(alpha) - TMath::Abs(alpha);
|
150 |
|
|
if((altX-xbar)/sigma<=-alpha) result=N*A*TMath::Power((B-((altX-xbar)/sigma)),-n);
|
151 |
|
|
if((altX-xbar)/sigma>=alpha) result=N*A*TMath::Power((B+((altX-xbar)/sigma)),-n);
|
152 |
|
|
}
|
153 |
|
|
|
154 |
|
|
if(addparabola) {
|
155 |
|
|
if(dofixed) {
|
156 |
|
|
result+=parabola_height*TMath::Exp(-parabola_inclination*(x[0]-parabola_pointzero)*(x[0]-parabola_pointzero)); // we're adding a "logarithmic parabola" :-)
|
157 |
|
|
}
|
158 |
|
|
else {
|
159 |
|
|
result+=par[5]*TMath::Exp(-par[6]*(x[0]-par[7])*(x[0]-par[7])); // we're adding a "logarithmic parabola" :-)
|
160 |
|
|
if(par[5]<0) return -999; // there can be no negative ttbar contribution, so just return a value which is going to be a horrible fit.
|
161 |
|
|
if(par[6]<0) return -999; // the parabola needs to close (i.e. tend to negative values for large |jzb|, not to large positive values)
|
162 |
|
|
}
|
163 |
|
|
}
|
164 |
|
|
return result;
|
165 |
|
|
}
|
166 |
|
|
|
167 |
|
|
|
168 |
|
|
void do_ttbar_fit(TH1F *ttbar,TF1 *logpar, TF1 *KM)
|
169 |
|
|
{
|
170 |
|
|
logpar->SetParameters(10,2,3);
|
171 |
|
|
ttbar->Fit(logpar,"NQ");
|
172 |
|
|
ttbar->Fit(logpar,"NQ");
|
173 |
|
|
ttbar->Fit(logpar,"NQ");
|
174 |
|
|
ttbar->Fit(logpar,"NQ");
|
175 |
|
|
ttbar->SetStats(0);
|
176 |
|
|
parabola_height=logpar->GetParameter(0);
|
177 |
|
|
parabola_inclination=logpar->GetParameter(1);
|
178 |
|
|
parabola_pointzero=logpar->GetParameter(2);
|
179 |
|
|
}
|
180 |
|
|
|
181 |
|
|
void draw_complete_fit(TH1F *all, TH1F *ttbar, float minfit, float maxfit, bool is_data, TF1 *KM)
|
182 |
|
|
{
|
183 |
|
|
TCanvas *fitsummary;
|
184 |
|
|
if(is_data) {
|
185 |
|
|
fitsummary= new TCanvas("fitsummary","Fit Summary",1000,500);
|
186 |
|
|
fitsummary->Divide(2,1);
|
187 |
|
|
}
|
188 |
|
|
else {
|
189 |
|
|
fitsummary= new TCanvas("fitsummary","Fit Summary",1200,400);
|
190 |
|
|
fitsummary->Divide(3,1);
|
191 |
|
|
}
|
192 |
|
|
TF1 *logpar = new TF1("logpar",LogParabola,minfit,maxfit,3);
|
193 |
|
|
|
194 |
|
|
logpar->SetParameters(KM->GetParameter(5),KM->GetParameter(6),KM->GetParameter(7));
|
195 |
|
|
logpar->SetLineColor(kOrange);
|
196 |
|
|
logpar->SetLineStyle(2);
|
197 |
|
|
if(!is_data)
|
198 |
|
|
{
|
199 |
|
|
ttbar->GetXaxis()->SetTitle("JZB (GeV/c)");
|
200 |
|
|
ttbar->GetYaxis()->SetTitle("events");
|
201 |
|
|
ttbar->GetXaxis()->CenterTitle();
|
202 |
|
|
ttbar->GetYaxis()->CenterTitle();
|
203 |
|
|
ttbar->SetLineColor(kRed);
|
204 |
|
|
fitsummary->cd(1);
|
205 |
|
|
ttbar->Draw();
|
206 |
|
|
fitsummary->cd(1);
|
207 |
|
|
logpar->Draw("same");
|
208 |
|
|
TLegend *leg = new TLegend(0.3,0.25,0.65,0.4);
|
209 |
|
|
leg->AddEntry(ttbar,"t#bar{t} (mc)","l");
|
210 |
|
|
leg->AddEntry(logpar,"Fit with Log. Parabola","l");
|
211 |
|
|
leg->SetLineColor(kWhite);
|
212 |
|
|
leg->SetFillColor(kWhite);
|
213 |
|
|
leg->Draw();
|
214 |
|
|
TText *title1=write_title("t#bar{t} Distribution and Fit");
|
215 |
|
|
title1->Draw();
|
216 |
|
|
}
|
217 |
|
|
fitsummary->cd(2-int(is_data));
|
218 |
|
|
fitsummary->cd(2-int(is_data))->SetLogy(1);
|
219 |
|
|
all->GetYaxis()->SetTitle("events");
|
220 |
|
|
all->GetYaxis()->CenterTitle();
|
221 |
|
|
all->Draw();
|
222 |
|
|
ttbar->SetLineColor(kRed);
|
223 |
|
|
if(!is_data) ttbar->Draw("same");
|
224 |
|
|
KM->SetLineWidth(1);
|
225 |
|
|
KM->Draw("same");
|
226 |
|
|
logpar->SetLineWidth(1);
|
227 |
|
|
logpar->Draw("same");
|
228 |
|
|
if(!is_data)ttbar->Draw("same");
|
229 |
|
|
TLegend *leg2 = new TLegend(0.65,0.65,0.89,0.89);
|
230 |
|
|
if(is_data) leg2->AddEntry(all,"Data","l");
|
231 |
|
|
else leg2->AddEntry(all,"Stacked MC","l");
|
232 |
|
|
leg2->AddEntry(KM,"Fitted KM Function","l");
|
233 |
|
|
if(!is_data) leg2->AddEntry(ttbar,"t#bar{t} MC","l");
|
234 |
|
|
leg2->AddEntry(logpar,"t#bar{t} (Fit)","l");
|
235 |
|
|
leg2->SetFillColor(kWhite);
|
236 |
|
|
leg2->SetLineColor(kWhite);
|
237 |
|
|
leg2->Draw();
|
238 |
|
|
TText *title2=write_title("Distribution and Fits (log.)");
|
239 |
|
|
title2->Draw();
|
240 |
|
|
fitsummary->cd(3-is_data);
|
241 |
|
|
all->Draw();
|
242 |
|
|
KM->Draw("same");
|
243 |
|
|
float peaklocation=KM->GetParameter(3);
|
244 |
|
|
TLine *muline = new TLine(peaklocation,0,peaklocation,all->GetMaximum());
|
245 |
|
|
muline->SetLineColor(kBlue);
|
246 |
|
|
muline->SetLineStyle(2);
|
247 |
|
|
muline->Draw();
|
248 |
buchmann |
1.9 |
TLegend *leg = new TLegend(0.75,0.75,0.89,0.89);
|
249 |
buchmann |
1.1 |
if(is_data) leg2->AddEntry(all,"Data","l");
|
250 |
|
|
else leg->AddEntry(all,"Stacked MC","l");
|
251 |
|
|
leg->AddEntry(KM,"Fitted KM Function","l");
|
252 |
|
|
stringstream mulinelabel;
|
253 |
|
|
mulinelabel<<"Peak position at #mu="<<peaklocation;
|
254 |
|
|
leg->AddEntry(muline,mulinelabel.str().c_str(),"l");
|
255 |
|
|
leg->SetLineColor(kWhite);
|
256 |
|
|
leg->SetFillColor(kWhite);
|
257 |
|
|
leg->Draw();
|
258 |
|
|
mulinelabel<<"+/-"<<TMath::Abs(KM->GetParError(3));
|
259 |
|
|
TText *title3=write_title("Distribution and Fits");
|
260 |
|
|
title3->Draw();
|
261 |
|
|
TText *titlel=write_title_low(mulinelabel.str().c_str());
|
262 |
|
|
titlel->Draw();
|
263 |
|
|
|
264 |
|
|
stringstream printtop;
|
265 |
|
|
printtop << "#mu="<<std::setprecision(3)<<KM->GetParameter(3)<<"+/-"<<std::setprecision(3)<<KM->GetParError(3);
|
266 |
|
|
TLatex *toptext = new TLatex(0,all->GetMaximum()*1.3,printtop.str().c_str());
|
267 |
|
|
toptext->SetTextAlign(22);
|
268 |
|
|
// toptext->Draw();
|
269 |
|
|
|
270 |
|
|
doreject=false;
|
271 |
|
|
TF1 *wholefitfunc=(TF1*)KM->Clone();
|
272 |
|
|
doreject=true;
|
273 |
|
|
wholefitfunc->SetLineColor(kRed);
|
274 |
|
|
wholefitfunc->SetLineStyle(2);
|
275 |
|
|
wholefitfunc->Draw("same");
|
276 |
|
|
|
277 |
|
|
fitsummary->cd(2-is_data);
|
278 |
|
|
wholefitfunc->Draw("same");
|
279 |
|
|
|
280 |
|
|
if(is_data) CompleteSave(fitsummary, "fit/Fit_Summary_Data");
|
281 |
|
|
else CompleteSave(fitsummary,"fit/Fit_Summary_MC");
|
282 |
|
|
|
283 |
|
|
}
|
284 |
|
|
|
285 |
|
|
float Kostas_algorithm(TH1F *hist, float &error, float &sigma, TF1* fitFunc, float lowlimit, float highlimit,bool is_data)
|
286 |
|
|
{
|
287 |
|
|
float mean = hist->GetBinCenter( hist->GetMaximumBin());
|
288 |
|
|
float rms = hist->GetRMS();
|
289 |
|
|
mean = hist->GetBinCenter( hist->GetMaximumBin());
|
290 |
|
|
|
291 |
|
|
fitFunc->SetParameter(1,mean);
|
292 |
|
|
|
293 |
|
|
hist->Fit(fitFunc,"QLL0","",mean-10,mean+10);
|
294 |
|
|
|
295 |
|
|
mean=fitFunc->GetParameter(1);
|
296 |
|
|
rms=fitFunc->GetParameter(2);
|
297 |
|
|
error=fitFunc->GetParError(1);
|
298 |
|
|
|
299 |
|
|
bool printOut = false; // print the peak estimate in the i-th iteration
|
300 |
|
|
|
301 |
|
|
// --- perform iterations
|
302 |
|
|
int numIterations=5;
|
303 |
|
|
|
304 |
buchmann |
1.6 |
if(printOut) dout << " ( ";
|
305 |
buchmann |
1.1 |
for(int i=1;i<numIterations+1;i++) //--- modify the number of iterations until peak is stable
|
306 |
|
|
{
|
307 |
|
|
hist->Fit(fitFunc,"QLLN","same",mean - lowlimit*rms, mean + highlimit*rms); // fit -2 +1 sigma from previous iteration
|
308 |
|
|
mean=fitFunc->GetParameter(1);
|
309 |
|
|
fitFunc->SetRange(mean - lowlimit*rms, mean + highlimit*rms);
|
310 |
buchmann |
1.6 |
if(printOut) dout << mean << ",";
|
311 |
buchmann |
1.1 |
}
|
312 |
buchmann |
1.6 |
if(printOut) dout << " ) ";
|
313 |
|
|
if(printOut) dout << endl;
|
314 |
buchmann |
1.1 |
mean=fitFunc->GetParameter(1);
|
315 |
|
|
sigma=fitFunc->GetParameter(2);
|
316 |
|
|
error=1.0*fitFunc->GetParError(1);
|
317 |
|
|
|
318 |
|
|
// below this point we're merely doing cosmetics :-)
|
319 |
buchmann |
1.4 |
TCanvas *peakfitcanvas = new TCanvas("peakfitcanvas","Fitting Canvas");
|
320 |
|
|
peakfitcanvas->cd();
|
321 |
|
|
|
322 |
buchmann |
1.1 |
hist->SetMinimum(0);
|
323 |
|
|
if(is_data) hist->Draw("e1");
|
324 |
|
|
else hist->Draw("histo");
|
325 |
|
|
fitFunc->SetLineColor(kBlue);
|
326 |
|
|
fitFunc->SetLineWidth(1);
|
327 |
|
|
fitFunc->Draw("same");
|
328 |
|
|
hist->SetStats(0);
|
329 |
|
|
TLegend *leg;
|
330 |
|
|
if(is_data) {
|
331 |
|
|
leg= make_legend("Fit (Data)");
|
332 |
|
|
leg->AddEntry(hist,"Data","p");
|
333 |
|
|
}
|
334 |
|
|
else {
|
335 |
|
|
leg= make_legend("Fit (MC)");
|
336 |
|
|
leg->AddEntry(hist,"MC","l");
|
337 |
|
|
}
|
338 |
buchmann |
1.4 |
|
339 |
buchmann |
1.1 |
leg->AddEntry(fitFunc,"Fit","l");
|
340 |
buchmann |
1.9 |
leg->SetX1(0.7);
|
341 |
|
|
leg->SetY1(0.7);
|
342 |
buchmann |
1.1 |
leg->Draw();
|
343 |
|
|
|
344 |
|
|
TText *ftitle=write_text(0.20,0.86,"Fit results:");
|
345 |
|
|
ftitle->SetTextSize(0.03);
|
346 |
|
|
ftitle->SetTextAlign(11);
|
347 |
|
|
stringstream fitresult;
|
348 |
|
|
fitresult << "#mu=" << std::setprecision(4) << mean << "+/-" << std::setprecision(4) << error;
|
349 |
|
|
// TText *title1=write_text(0.20,0.96,fitresult.str().c_str());
|
350 |
|
|
TText *title1=write_text(0.20,0.82,fitresult.str().c_str());
|
351 |
|
|
title1->SetTextSize(0.03);
|
352 |
|
|
title1->SetTextAlign(11);
|
353 |
|
|
stringstream sigmainfo;
|
354 |
|
|
sigmainfo << "#sigma=" << std::setprecision(4) << fitFunc->GetParameter(2) << "+/-" << std::setprecision(4) << fitFunc->GetParError(2);
|
355 |
|
|
// TText *sigmatext=write_text(0.80,0.96,sigmainfo.str().c_str());
|
356 |
|
|
TText *sigmatext=write_text(0.20,0.78,sigmainfo.str().c_str());
|
357 |
|
|
sigmatext->SetTextSize(0.03);
|
358 |
|
|
sigmatext->SetTextAlign(11);
|
359 |
|
|
|
360 |
buchmann |
1.5 |
// TText* toptitle;
|
361 |
|
|
// if(is_data) toptitle = write_title("Fit Result (data)");
|
362 |
|
|
// else toptitle = write_title("Fit Result (MC)");
|
363 |
|
|
// toptitle->Draw();
|
364 |
buchmann |
1.1 |
ftitle->Draw();
|
365 |
|
|
title1->Draw();
|
366 |
|
|
sigmatext->Draw();
|
367 |
buchmann |
1.8 |
if(!is_data) {
|
368 |
|
|
CompleteSave(peakfitcanvas,"fit/Fit_Summary_MC");
|
369 |
|
|
PlottingSetup::JZBPeakPositionMC=mean;
|
370 |
|
|
PlottingSetup::JZBPeakWidthMC=fitFunc->GetParameter(2);
|
371 |
|
|
} else {
|
372 |
|
|
CompleteSave(peakfitcanvas,"fit/Fit_Summary_Data");
|
373 |
|
|
PlottingSetup::JZBPeakPositionData=mean;
|
374 |
|
|
PlottingSetup::JZBPeakWidthData=fitFunc->GetParameter(2);
|
375 |
|
|
}
|
376 |
buchmann |
1.4 |
delete peakfitcanvas;
|
377 |
buchmann |
1.1 |
|
378 |
|
|
return mean;
|
379 |
|
|
}
|
380 |
|
|
|
381 |
|
|
|
382 |
|
|
|
383 |
|
|
float find_peak(TH1F *all, TH1F *ttbar, float minfit, float maxfit, bool is_data, float &error,float &Sigma, int method)
|
384 |
|
|
{
|
385 |
buchmann |
1.4 |
float peak_position=0;
|
386 |
buchmann |
1.1 |
if(method==0||method>1) {
|
387 |
|
|
//looking at a gaus request
|
388 |
|
|
int numsig=1;
|
389 |
|
|
if(method>1) numsig=method;
|
390 |
|
|
peak_position=find_Gauss_peak(all,ttbar,minfit,maxfit,is_data,error,Sigma,numsig);
|
391 |
|
|
}
|
392 |
|
|
if(method==1) {
|
393 |
|
|
//looking at a KM request
|
394 |
|
|
peak_position=find_KM_peak(all,ttbar,minfit,maxfit,is_data,error,Sigma);
|
395 |
|
|
}
|
396 |
|
|
if(method==-99) { // KOSTAS!!
|
397 |
|
|
TF1 *f1 = new TF1("f1","gaus",-40,40);
|
398 |
|
|
peak_position=Kostas_algorithm(all,error,Sigma,f1,2.5,2.5,is_data);
|
399 |
|
|
}
|
400 |
|
|
return peak_position;
|
401 |
|
|
}
|
402 |
|
|
|
403 |
|
|
|
404 |
|
|
float get_Gaussian_peak(TH1F *hist, float &error, float &sigma, TF1* fitFunc, float lowlimit, float highlimit,bool is_data,int numsig)
|
405 |
|
|
{
|
406 |
|
|
TCanvas *fitcanvas = new TCanvas("fitcanvas","fitcanvas");
|
407 |
|
|
float mean = hist->GetBinCenter( hist->GetMaximumBin());
|
408 |
|
|
float rms = hist->GetRMS();
|
409 |
|
|
|
410 |
|
|
mean = hist->GetBinCenter( hist->GetMaximumBin());
|
411 |
|
|
|
412 |
|
|
fitFunc->SetParameter(1,mean);
|
413 |
|
|
|
414 |
|
|
hist->Fit(fitFunc,"QLL0","",mean-10,mean+10);
|
415 |
|
|
|
416 |
|
|
mean=fitFunc->GetParameter(1);
|
417 |
|
|
rms=fitFunc->GetParameter(2);
|
418 |
|
|
error=fitFunc->GetParError(1);
|
419 |
|
|
|
420 |
|
|
bool printOut = false; // print the peak estimate in the i-th iteration
|
421 |
|
|
|
422 |
|
|
// --- perform iterations
|
423 |
|
|
int numIterations=5;
|
424 |
|
|
|
425 |
buchmann |
1.6 |
if(printOut) dout << " ( ";
|
426 |
buchmann |
1.1 |
for(int i=1;i<numIterations+1;i++) //--- modify the number of iterations until peak is stable
|
427 |
|
|
{
|
428 |
|
|
hist->Fit(fitFunc,"QLLN","same",mean - numsig*rms, mean + numsig*rms); // fit -2 +1 sigma from previous iteration
|
429 |
|
|
mean=fitFunc->GetParameter(1);
|
430 |
|
|
fitFunc->SetRange(mean - numsig*rms, mean + numsig*rms);
|
431 |
buchmann |
1.6 |
if(printOut) dout << mean << ",";
|
432 |
buchmann |
1.1 |
}
|
433 |
buchmann |
1.6 |
if(printOut) dout << " ) ";
|
434 |
|
|
if(printOut) dout << endl;
|
435 |
buchmann |
1.1 |
mean=fitFunc->GetParameter(1);
|
436 |
|
|
sigma=fitFunc->GetParameter(2);
|
437 |
|
|
error=1.0*fitFunc->GetParError(1);
|
438 |
|
|
fitcanvas->cd();
|
439 |
|
|
hist->SetMinimum(0);
|
440 |
|
|
if(is_data) hist->Draw("e1");
|
441 |
|
|
else hist->Draw("histo");
|
442 |
|
|
fitFunc->SetLineColor(kBlue);
|
443 |
|
|
fitFunc->SetLineWidth(1);
|
444 |
|
|
fitFunc->Draw("same");
|
445 |
|
|
hist->SetStats(0);
|
446 |
|
|
TLegend *leg;
|
447 |
|
|
if(is_data) {
|
448 |
|
|
leg= make_legend("Fit (Data)");
|
449 |
|
|
leg->AddEntry(hist,"Data","p");
|
450 |
|
|
}
|
451 |
|
|
else {
|
452 |
|
|
leg= make_legend("Fit (MC)");
|
453 |
|
|
leg->AddEntry(hist,"MC","l");
|
454 |
|
|
}
|
455 |
|
|
|
456 |
|
|
leg->AddEntry(fitFunc,"Fit","l");
|
457 |
|
|
leg->Draw();
|
458 |
|
|
|
459 |
|
|
TText *ftitle=write_text(0.20,0.86,"Fit results:");
|
460 |
|
|
ftitle->SetTextSize(0.03);
|
461 |
|
|
ftitle->SetTextAlign(11);
|
462 |
|
|
stringstream fitresult;
|
463 |
|
|
fitresult << "#mu=" << std::setprecision(4) << mean << "+/-" << std::setprecision(4) << error;
|
464 |
|
|
// TText *title1=write_text(0.20,0.96,fitresult.str().c_str());
|
465 |
|
|
TText *title1=write_text(0.20,0.82,fitresult.str().c_str());
|
466 |
|
|
title1->SetTextSize(0.03);
|
467 |
|
|
title1->SetTextAlign(11);
|
468 |
|
|
stringstream sigmainfo;
|
469 |
|
|
sigmainfo << "#sigma=" << std::setprecision(4) << fitFunc->GetParameter(2) << "+/-" << std::setprecision(4) << fitFunc->GetParError(2);
|
470 |
|
|
// TText *sigmatext=write_text(0.80,0.96,sigmainfo.str().c_str());
|
471 |
|
|
TText *sigmatext=write_text(0.20,0.78,sigmainfo.str().c_str());
|
472 |
|
|
sigmatext->SetTextSize(0.03);
|
473 |
|
|
sigmatext->SetTextAlign(11);
|
474 |
|
|
|
475 |
buchmann |
1.7 |
// TText* toptitle;
|
476 |
|
|
// if(is_data) toptitle = write_title("Fit Result (data)");
|
477 |
|
|
// else toptitle = write_title("Fit Result (MC)");
|
478 |
|
|
// toptitle->Draw();
|
479 |
buchmann |
1.1 |
ftitle->Draw();
|
480 |
|
|
title1->Draw();
|
481 |
|
|
sigmatext->Draw();
|
482 |
|
|
if(!is_data) CompleteSave(fitcanvas,"fit/Fit_Summary_MC");
|
483 |
|
|
if(is_data) CompleteSave(fitcanvas,"fit/Fit_Summary_Data");
|
484 |
|
|
|
485 |
|
|
|
486 |
buchmann |
1.6 |
// dout << "[" << fitFunc->GetParameter(1) << " , " << fitFunc->GetParError(1) << "]" << endl;
|
487 |
buchmann |
1.1 |
return mean;
|
488 |
|
|
}
|
489 |
|
|
|
490 |
|
|
|
491 |
|
|
float find_Gauss_peak(TH1F *all, TH1F *ttbar, float minfit, float maxfit, bool is_data, float &error,float &Sigma,int numsig)
|
492 |
|
|
{
|
493 |
|
|
TF1 *fitfunc = new TF1("fitfunc","gaus",minfit,maxfit);
|
494 |
|
|
float peakpos = get_Gaussian_peak(all,error,Sigma,fitfunc, minfit, maxfit,is_data,numsig);
|
495 |
|
|
return peakpos;
|
496 |
|
|
}
|
497 |
|
|
|
498 |
|
|
float find_KM_peak(TH1F *all, TH1F *ttbar, float minfit, float maxfit, bool is_data, float &error,float &Sigma)
|
499 |
|
|
{
|
500 |
|
|
all->SetLineColor(kBlue);
|
501 |
|
|
all->SetStats(0);
|
502 |
|
|
all->SetTitle("");
|
503 |
|
|
all->GetXaxis()->SetTitle("JZB (GeV/c)");
|
504 |
|
|
all->GetYaxis()->SetTitle("events");
|
505 |
|
|
all->GetXaxis()->CenterTitle();
|
506 |
|
|
all->GetYaxis()->CenterTitle();
|
507 |
|
|
TF1 *fitfunc = new TF1("fitfunc",KrystalMallLogPar,0.8*minfit,0.8*maxfit,8);
|
508 |
|
|
if(!is_data)
|
509 |
|
|
{
|
510 |
|
|
TF1 *logpar = new TF1("logpar",LogParabola,minfit,maxfit,3);
|
511 |
|
|
do_ttbar_fit(ttbar,logpar,fitfunc);
|
512 |
|
|
fitfunc->SetParameters(1000,2,2.5,-1.6,4,logpar->GetParameter(0),logpar->GetParameter(1),logpar->GetParameter(2));
|
513 |
|
|
parabola_height=logpar->GetParameter(0);
|
514 |
|
|
parabola_inclination=logpar->GetParameter(1);
|
515 |
|
|
parabola_pointzero=logpar->GetParameter(2);
|
516 |
|
|
dofixed=true;//ttbar is known so we can fix the parameters and don't need to use them for fitting!
|
517 |
|
|
}
|
518 |
|
|
else
|
519 |
|
|
{
|
520 |
|
|
fitfunc->SetParameters(1000,2,2.5,-1.6,4,5.45039,0.000324593,12.3528);
|
521 |
|
|
dofixed=false;
|
522 |
|
|
}
|
523 |
|
|
|
524 |
|
|
vector<float> chi2values;
|
525 |
|
|
addparabola=true;
|
526 |
|
|
for (int ifit=0;ifit<100;ifit++)
|
527 |
|
|
{
|
528 |
|
|
all->Fit(fitfunc,"NQ");
|
529 |
|
|
chi2values.push_back(fitfunc->GetChisquare());
|
530 |
|
|
if(ifit>5&&chi2values[ifit-2]==chi2values[ifit]) break;
|
531 |
|
|
}
|
532 |
|
|
/*
|
533 |
|
|
The parameters represent the following quantities:
|
534 |
|
|
float N=par[0];
|
535 |
|
|
float alpha=par[1];
|
536 |
|
|
float n=par[2];
|
537 |
|
|
float xbar=par[3];
|
538 |
|
|
float sigma=par[4];
|
539 |
|
|
*/
|
540 |
|
|
//we are clearing an area of two sigma to the left and to the right of the center of the function for the "real fit".
|
541 |
|
|
low_reject=-2*fitfunc->GetParameter(4)+fitfunc->GetParameter(3);
|
542 |
|
|
hi_reject=fitfunc->GetParameter(3)+2*fitfunc->GetParameter(4);
|
543 |
|
|
if(low_reject>-15) low_reject=-10;
|
544 |
|
|
if(hi_reject<15) hi_reject=10;
|
545 |
|
|
doreject=true;//activating the rejection :-)
|
546 |
|
|
|
547 |
|
|
for (int ifit=0;ifit<100;ifit++)
|
548 |
|
|
{
|
549 |
|
|
all->Fit(fitfunc,"NQ");
|
550 |
|
|
chi2values.push_back(fitfunc->GetChisquare());
|
551 |
|
|
if(ifit>5&&chi2values[ifit-2]==chi2values[ifit]) break;
|
552 |
|
|
}
|
553 |
|
|
|
554 |
|
|
draw_complete_fit(all,ttbar,minfit,maxfit,is_data,fitfunc);
|
555 |
|
|
doreject=true;
|
556 |
|
|
error=fitfunc->GetParError(3);
|
557 |
|
|
Sigma=fitfunc->GetParameter(4);//sigma
|
558 |
|
|
|
559 |
|
|
return fitfunc->GetParameter(3);
|
560 |
|
|
}
|
561 |
|
|
|
562 |
|
|
Double_t InvCrystalBall(Double_t *x,Double_t *par)
|
563 |
|
|
{
|
564 |
|
|
Double_t arg1=0,arg2=0,A=0,B=0;
|
565 |
|
|
Double_t f1=0;
|
566 |
|
|
Double_t f2=0;
|
567 |
|
|
Double_t lim=0;
|
568 |
|
|
Double_t fitval=0;
|
569 |
|
|
Double_t N=0;
|
570 |
|
|
Double_t n=par[4];
|
571 |
|
|
|
572 |
|
|
Double_t invX = -x[0];
|
573 |
|
|
|
574 |
|
|
if (par[2] != 0)
|
575 |
|
|
arg1 = (invX-par[1])/par[2];
|
576 |
|
|
|
577 |
|
|
arg2 = ( -pow( TMath::Abs(par[3]) , 2 ) ) / 2 ;
|
578 |
|
|
|
579 |
|
|
if (par[3] != 0)
|
580 |
|
|
A = pow( ( n / TMath::Abs( par[3] ) ) , n) * TMath::Exp(arg2);
|
581 |
|
|
|
582 |
|
|
if (par[3] != 0)
|
583 |
|
|
B = n / TMath::Abs(par[3]) - TMath::Abs(par[3]);
|
584 |
|
|
|
585 |
|
|
f1 = TMath::Exp(-0.5*arg1*arg1);
|
586 |
|
|
if (par[2] != 0)
|
587 |
|
|
f2 = A * pow( ( B - (invX - par[1])/par[2] ) , -n );
|
588 |
|
|
|
589 |
|
|
if (par[2] != 0)
|
590 |
|
|
lim = ( par[1] - invX ) / par[2] ;
|
591 |
|
|
|
592 |
|
|
N = par[0];
|
593 |
|
|
|
594 |
|
|
|
595 |
|
|
|
596 |
|
|
if(lim < par[3])
|
597 |
|
|
fitval = N * f1;
|
598 |
|
|
if(lim >= par[3])
|
599 |
|
|
fitval = N * f2;
|
600 |
|
|
|
601 |
|
|
return fitval;
|
602 |
|
|
}
|
603 |
|
|
|
604 |
buchmann |
1.3 |
|
605 |
|
|
Double_t DoubleInvCrystalBall(Double_t *x,Double_t *par)
|
606 |
|
|
{
|
607 |
|
|
Double_t arg1=0,arg2=0,A=0,B=0;
|
608 |
|
|
Double_t f1=0;
|
609 |
|
|
Double_t f2=0;
|
610 |
|
|
Double_t lim=0;
|
611 |
|
|
Double_t fitval=0;
|
612 |
|
|
Double_t N=0;
|
613 |
|
|
Double_t n=par[4];
|
614 |
|
|
|
615 |
|
|
Double_t Sarg1=0,Sarg2=0,SA=0,SB=0;
|
616 |
|
|
Double_t Sf1=0;
|
617 |
|
|
Double_t Sf2=0;
|
618 |
|
|
Double_t Slim=0;
|
619 |
|
|
Double_t Sfitval=0;
|
620 |
|
|
Double_t SN=0;
|
621 |
|
|
Double_t Sn=par[9];
|
622 |
|
|
|
623 |
|
|
Double_t invX = -x[0];
|
624 |
|
|
|
625 |
|
|
if (par[2] != 0) arg1 = (invX-par[1])/par[2];
|
626 |
|
|
|
627 |
|
|
if (par[7] != 0) Sarg1 = (invX-par[6])/par[7];
|
628 |
|
|
|
629 |
|
|
arg2 = ( -pow( TMath::Abs(par[3]) , 2 ) ) / 2 ;
|
630 |
|
|
Sarg2 = ( -pow( TMath::Abs(par[8]) , 2 ) ) / 2 ;
|
631 |
|
|
|
632 |
|
|
if (par[3] != 0) A = pow( ( n / TMath::Abs( par[3] ) ) , n) * TMath::Exp(arg2);
|
633 |
|
|
if (par[8] != 0) SA = pow( ( Sn / TMath::Abs( par[8] ) ) , Sn) * TMath::Exp(Sarg2);
|
634 |
|
|
|
635 |
|
|
if (par[3] != 0) B = n / TMath::Abs(par[3]) - TMath::Abs(par[3]);
|
636 |
|
|
if (par[8] != 0) SB = Sn / TMath::Abs(par[8]) - TMath::Abs(par[8]);
|
637 |
|
|
|
638 |
|
|
f1 = TMath::Exp(-0.5*arg1*arg1);
|
639 |
|
|
Sf1 = TMath::Exp(-0.5*Sarg1*Sarg1);
|
640 |
|
|
|
641 |
|
|
if (par[2] != 0) f2 = A * pow( ( B - (invX - par[1])/par[2] ) , -n );
|
642 |
|
|
if (par[7] != 0) Sf2 = SA * pow( ( SB - (invX - par[6])/par[7] ) , -Sn );
|
643 |
|
|
|
644 |
|
|
if (par[2] != 0) lim = ( par[1] - invX ) / par[2] ;
|
645 |
|
|
if (par[7] != 0) Slim = ( par[6] - invX ) / par[7] ;
|
646 |
|
|
|
647 |
|
|
N = par[0];
|
648 |
|
|
SN = par[5];
|
649 |
|
|
|
650 |
|
|
|
651 |
|
|
|
652 |
|
|
if(lim < par[3]) fitval = N * f1;
|
653 |
|
|
if(lim >= par[3]) fitval = N * f2;
|
654 |
|
|
|
655 |
|
|
if(Slim < par[8]) Sfitval = SN * Sf1;
|
656 |
|
|
if(Slim >= par[8]) Sfitval = SN * Sf2;
|
657 |
|
|
|
658 |
|
|
return fitval+Sfitval;
|
659 |
|
|
}
|
660 |
|
|
|
661 |
buchmann |
1.4 |
Double_t DoubleInvCrystalBallP(Double_t *x,Double_t *par)
|
662 |
|
|
{
|
663 |
|
|
Double_t arg1=0,arg2=0,A=0,B=0;
|
664 |
|
|
Double_t f1=0;
|
665 |
|
|
Double_t f2=0;
|
666 |
|
|
Double_t lim=0;
|
667 |
|
|
Double_t fitval=0;
|
668 |
|
|
Double_t N=0;
|
669 |
|
|
Double_t n=par[4];
|
670 |
|
|
|
671 |
|
|
Double_t Sarg1=0,Sarg2=0,SA=0,SB=0;
|
672 |
|
|
Double_t Sf1=0;
|
673 |
|
|
Double_t Sf2=0;
|
674 |
|
|
Double_t Slim=0;
|
675 |
|
|
Double_t Sfitval=0;
|
676 |
|
|
Double_t SN=0;
|
677 |
|
|
Double_t Sn=par[9];
|
678 |
|
|
|
679 |
|
|
Double_t invX = -x[0];
|
680 |
|
|
|
681 |
|
|
if (par[2] != 0) arg1 = (invX-par[1])/par[2];
|
682 |
|
|
|
683 |
|
|
if (par[7] != 0) Sarg1 = (invX-par[6])/par[7];
|
684 |
|
|
|
685 |
|
|
arg2 = ( -pow( TMath::Abs(par[3]) , 2 ) ) / 2 ;
|
686 |
|
|
Sarg2 = ( -pow( TMath::Abs(par[8]) , 2 ) ) / 2 ;
|
687 |
|
|
|
688 |
|
|
if (par[3] != 0) A = pow( ( n / TMath::Abs( par[3] ) ) , n) * TMath::Exp(arg2);
|
689 |
|
|
if (par[8] != 0) SA = pow( ( Sn / TMath::Abs( par[8] ) ) , Sn) * TMath::Exp(Sarg2);
|
690 |
|
|
|
691 |
|
|
if (par[3] != 0) B = n / TMath::Abs(par[3]) - TMath::Abs(par[3]);
|
692 |
|
|
if (par[8] != 0) SB = Sn / TMath::Abs(par[8]) - TMath::Abs(par[8]);
|
693 |
|
|
|
694 |
|
|
f1 = TMath::Exp(-0.5*arg1*arg1);
|
695 |
|
|
Sf1 = TMath::Exp(-0.5*Sarg1*Sarg1);
|
696 |
|
|
|
697 |
|
|
if (par[2] != 0) f2 = A * pow( ( B - (invX - par[1])/par[2] ) , -n );
|
698 |
|
|
if (par[7] != 0) Sf2 = SA * pow( ( SB - (invX - par[6])/par[7] ) , -Sn );
|
699 |
|
|
|
700 |
|
|
if (par[2] != 0) lim = ( par[1] - invX ) / par[2] ;
|
701 |
|
|
if (par[7] != 0) Slim = ( par[6] - invX ) / par[7] ;
|
702 |
|
|
|
703 |
|
|
N = par[0];
|
704 |
|
|
SN = par[5];
|
705 |
|
|
|
706 |
|
|
|
707 |
|
|
|
708 |
|
|
if(lim < par[3]) fitval = N * f1;
|
709 |
|
|
if(lim >= par[3]) fitval = N * f2;
|
710 |
|
|
|
711 |
|
|
if(Slim < par[8]) Sfitval = SN * Sf1;
|
712 |
|
|
if(Slim >= par[8]) Sfitval = SN * Sf2;
|
713 |
|
|
|
714 |
|
|
fitval+=Sfitval;
|
715 |
|
|
fitval+=statErrorP(fitval);
|
716 |
|
|
|
717 |
|
|
return fitval;
|
718 |
|
|
}
|
719 |
|
|
|
720 |
|
|
Double_t DoubleInvCrystalBallN(Double_t *x,Double_t *par)
|
721 |
|
|
{
|
722 |
|
|
Double_t arg1=0,arg2=0,A=0,B=0;
|
723 |
|
|
Double_t f1=0;
|
724 |
|
|
Double_t f2=0;
|
725 |
|
|
Double_t lim=0;
|
726 |
|
|
Double_t fitval=0;
|
727 |
|
|
Double_t N=0;
|
728 |
|
|
Double_t n=par[4];
|
729 |
|
|
|
730 |
|
|
Double_t Sarg1=0,Sarg2=0,SA=0,SB=0;
|
731 |
|
|
Double_t Sf1=0;
|
732 |
|
|
Double_t Sf2=0;
|
733 |
|
|
Double_t Slim=0;
|
734 |
|
|
Double_t Sfitval=0;
|
735 |
|
|
Double_t SN=0;
|
736 |
|
|
Double_t Sn=par[9];
|
737 |
|
|
|
738 |
|
|
Double_t invX = -x[0];
|
739 |
|
|
|
740 |
|
|
if (par[2] != 0) arg1 = (invX-par[1])/par[2];
|
741 |
|
|
|
742 |
|
|
if (par[7] != 0) Sarg1 = (invX-par[6])/par[7];
|
743 |
|
|
|
744 |
|
|
arg2 = ( -pow( TMath::Abs(par[3]) , 2 ) ) / 2 ;
|
745 |
|
|
Sarg2 = ( -pow( TMath::Abs(par[8]) , 2 ) ) / 2 ;
|
746 |
|
|
|
747 |
|
|
if (par[3] != 0) A = pow( ( n / TMath::Abs( par[3] ) ) , n) * TMath::Exp(arg2);
|
748 |
|
|
if (par[8] != 0) SA = pow( ( Sn / TMath::Abs( par[8] ) ) , Sn) * TMath::Exp(Sarg2);
|
749 |
|
|
|
750 |
|
|
if (par[3] != 0) B = n / TMath::Abs(par[3]) - TMath::Abs(par[3]);
|
751 |
|
|
if (par[8] != 0) SB = Sn / TMath::Abs(par[8]) - TMath::Abs(par[8]);
|
752 |
|
|
|
753 |
|
|
f1 = TMath::Exp(-0.5*arg1*arg1);
|
754 |
|
|
Sf1 = TMath::Exp(-0.5*Sarg1*Sarg1);
|
755 |
|
|
|
756 |
|
|
if (par[2] != 0) f2 = A * pow( ( B - (invX - par[1])/par[2] ) , -n );
|
757 |
|
|
if (par[7] != 0) Sf2 = SA * pow( ( SB - (invX - par[6])/par[7] ) , -Sn );
|
758 |
|
|
|
759 |
|
|
if (par[2] != 0) lim = ( par[1] - invX ) / par[2] ;
|
760 |
|
|
if (par[7] != 0) Slim = ( par[6] - invX ) / par[7] ;
|
761 |
|
|
|
762 |
|
|
N = par[0];
|
763 |
|
|
SN = par[5];
|
764 |
|
|
|
765 |
|
|
|
766 |
|
|
|
767 |
|
|
if(lim < par[3]) fitval = N * f1;
|
768 |
|
|
if(lim >= par[3]) fitval = N * f2;
|
769 |
|
|
|
770 |
|
|
if(Slim < par[8]) Sfitval = SN * Sf1;
|
771 |
|
|
if(Slim >= par[8]) Sfitval = SN * Sf2;
|
772 |
|
|
|
773 |
|
|
fitval+=Sfitval;
|
774 |
|
|
fitval-=statErrorN(fitval);
|
775 |
|
|
|
776 |
|
|
return fitval;
|
777 |
|
|
}
|
778 |
buchmann |
1.3 |
|
779 |
buchmann |
1.1 |
Double_t InvCrystalBallP(Double_t *x,Double_t *par)
|
780 |
|
|
{
|
781 |
|
|
Double_t arg1=0,arg2=0,A=0,B=0;
|
782 |
|
|
Double_t f1=0;
|
783 |
|
|
Double_t f2=0;
|
784 |
|
|
Double_t lim=0;
|
785 |
|
|
Double_t fitval=0;
|
786 |
|
|
Double_t N=0;
|
787 |
|
|
Double_t n=par[4];
|
788 |
|
|
|
789 |
|
|
Double_t invX = -x[0];
|
790 |
|
|
|
791 |
|
|
if (par[2] != 0)
|
792 |
|
|
arg1 = (invX-par[1])/par[2];
|
793 |
|
|
|
794 |
|
|
arg2 = ( -pow( TMath::Abs(par[3]) , 2 ) ) / 2 ;
|
795 |
|
|
|
796 |
|
|
if (par[3] != 0)
|
797 |
|
|
A = pow( ( n / TMath::Abs( par[3] ) ) , n) * TMath::Exp(arg2);
|
798 |
|
|
|
799 |
|
|
if (par[3] != 0)
|
800 |
|
|
B = n / TMath::Abs(par[3]) - TMath::Abs(par[3]);
|
801 |
|
|
|
802 |
|
|
f1 = TMath::Exp(-0.5*arg1*arg1);
|
803 |
|
|
if (par[2] != 0)
|
804 |
|
|
f2 = A * pow( ( B - (invX - par[1])/par[2] ) , -n );
|
805 |
|
|
|
806 |
|
|
if (par[2] != 0)
|
807 |
|
|
lim = ( par[1] - invX ) / par[2] ;
|
808 |
|
|
|
809 |
|
|
N = par[0];
|
810 |
|
|
|
811 |
|
|
|
812 |
|
|
|
813 |
|
|
if(lim < par[3])
|
814 |
|
|
fitval = N * f1;
|
815 |
|
|
if(lim >= par[3])
|
816 |
|
|
fitval = N * f2;
|
817 |
|
|
|
818 |
|
|
fitval+= statErrorP(fitval);
|
819 |
|
|
return fitval;
|
820 |
|
|
}
|
821 |
|
|
|
822 |
|
|
Double_t InvCrystalBallN(Double_t *x,Double_t *par)
|
823 |
|
|
{
|
824 |
|
|
Double_t arg1=0,arg2=0,A=0,B=0;
|
825 |
|
|
Double_t f1=0;
|
826 |
|
|
Double_t f2=0;
|
827 |
|
|
Double_t lim=0;
|
828 |
|
|
Double_t fitval=0;
|
829 |
|
|
Double_t N=0;
|
830 |
|
|
Double_t n=par[4];
|
831 |
|
|
|
832 |
|
|
Double_t invX = -x[0];
|
833 |
|
|
|
834 |
|
|
if (par[2] != 0)
|
835 |
|
|
arg1 = (invX-par[1])/par[2];
|
836 |
|
|
|
837 |
|
|
arg2 = ( -pow( TMath::Abs(par[3]) , 2 ) ) / 2 ;
|
838 |
|
|
|
839 |
|
|
if (par[3] != 0)
|
840 |
|
|
A = pow( ( n / TMath::Abs( par[3] ) ) , n) * TMath::Exp(arg2);
|
841 |
|
|
|
842 |
|
|
if (par[3] != 0)
|
843 |
|
|
B = n / TMath::Abs(par[3]) - TMath::Abs(par[3]);
|
844 |
|
|
|
845 |
|
|
f1 = TMath::Exp(-0.5*arg1*arg1);
|
846 |
|
|
if (par[2] != 0)
|
847 |
|
|
f2 = A * pow( ( B - (invX - par[1])/par[2] ) , -n );
|
848 |
|
|
|
849 |
|
|
if (par[2] != 0)
|
850 |
|
|
lim = ( par[1] - invX ) / par[2] ;
|
851 |
|
|
|
852 |
|
|
N = par[0];
|
853 |
|
|
|
854 |
|
|
|
855 |
|
|
|
856 |
|
|
if(lim < par[3])
|
857 |
|
|
fitval = N * f1;
|
858 |
|
|
if(lim >= par[3])
|
859 |
|
|
fitval = N * f2;
|
860 |
|
|
|
861 |
|
|
fitval-= statErrorN(fitval);
|
862 |
|
|
return fitval;
|
863 |
|
|
}
|
864 |
|
|
|
865 |
|
|
|