]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGPP/pid/doeffKa.C
Escape special characters for latex (Diego)
[u/mrichter/AliRoot.git] / PWGPP / pid / doeffKa.C
CommitLineData
7484404e 1#include"TF1.h"
2#include"TH1D.h"
3#include"TH2F.h"
4#include"TMath.h"
5#include"TSystem.h"
6#include"TCanvas.h"
7#include"TFile.h"
8#include"TGraphErrors.h"
9#include"AliPIDperfContainer.h"
10
11int LoadLib();
12void doeffKa(Int_t pos=1,Float_t prob=0.1,Float_t etaminkp=-0.8,Float_t etamaxkp=0.8);
13TH2F *GetHistoKap(Float_t pt=1,Float_t ptM=1.1,Float_t pMinkp=0,Float_t pMinkn=0.,Float_t etaminkp=-0.8,Float_t etamaxkp=0.8);
14TH2F *GetHistoKan(Float_t pt=1,Float_t ptM=1.1,Float_t pMinkn=0,Float_t pMinkp=0.,Float_t etaminkp=-0.8,Float_t etamaxkp=0.8);
15void fit(TH1D *h,Float_t *a=NULL,char *opt="",char *opt2="",Float_t pt=1.5);
16void AddHisto(TH2F *h1,TH2F *h2,Float_t w);
17
a8ad4709 18TObject* fContPid1;
19TObject* fContPid2;
20const Int_t nBinPid = 14; // pt,eta, ptPip, ptPin, PPip, PPin, TOF3sigmaPip, TOF3sigmaPin, isPhiTrue, nsigmaPip, nsigmaPin
21// 0.985 < mass < 1.045 (60) and 0 < centrality < 100 (10)
22Int_t binPid[nBinPid] = {1/*ptPhi*/,8/*EtaPi*/,20/*pt+*/,20/*pt-*/,5/*P+*/,1/*P-*/,2/*TOFmatch+*/,2/*TOFmatch-*/,2/*istrue*/,4/*Nsigma+*/,4/*Nsigma-*/,1/*DeltaPhi+*/,1/*DeltaPhi-*/,1/*Psi*/};
23Float_t xmin[nBinPid] = {1,-0.8,0.3,0.3,0,0,-0.5,-0.5,-0.5,0,0,-TMath::Pi(),-TMath::Pi(),-TMath::Pi()/2};
24Float_t xmax[nBinPid] = {5,0.8,4.3,4.3,1,1,1.5,1.5,1.5,7.5,7.5,TMath::Pi(),TMath::Pi(),TMath::Pi()/2};
25
26TF1 *fsign;
27TF1 *fall;
28TF1 *fback;
29
30Int_t ifunc=0;
31
32Float_t fitmin = 0.99;
33Float_t fitmax = 1.045;
34
08b5b548 35Int_t cmin = 1;// min 1
6490e37e 36Int_t cmax = 8;// max 10
a8ad4709 37
6490e37e 38Float_t weightS = -1.;
a8ad4709 39
bf2e05d5 40Int_t rebinsize = 1;
a8ad4709 41
42Int_t parplotted = 2;
43
44Bool_t isMC = kFALSE; // don't change this (is set automatically)
45Bool_t selectTrue = kTRUE; // put it to true to remove background (only for MC)
46Bool_t keepTrue = kFALSE; // put it to false to fit only background (only for MC)
47
48Bool_t kGoodMatch = kFALSE; // to check good matching
49
50Bool_t kSigma2vs3 = kFALSE; // to check good matching
51
52Bool_t require5sigma = kFALSE; // don't touch this flag
53
54Bool_t bayesVsigma = kFALSE; // only to do checks
55
56Bool_t kTOFmatch = kFALSE; // for combined PID requires TOF matching
57
08b5b548 58Bool_t kOverAll = kFALSE;
e34b28fe 59Bool_t kOverAllTOFmatch = kFALSE;
08b5b548 60Bool_t kOverAll2Sigma = kFALSE;
167b8b0a 61Bool_t kPid2Sigma = kFALSE;
62Bool_t kPid3Sigma = kFALSE;
08b5b548 63
64TH2F *hmatched;
65TH2F *htracked;
a8ad4709 66
67Bool_t kLoaded=kFALSE;
7484404e 68int LoadLib(){
6490e37e 69 weightS = -1.;
a8ad4709 70
bf2e05d5 71 require5sigma = kFALSE;
72
a8ad4709 73 if(! kLoaded){
74 gSystem->Load("libVMC.so");
75 gSystem->Load("libPhysics.so");
76 gSystem->Load("libTree.so");
77 gSystem->Load("libMinuit.so");
78 gSystem->Load("libSTEERBase.so");
79 gSystem->Load("libANALYSIS.so");
80 gSystem->Load("libAOD.so");
81 gSystem->Load("libESD.so");
82 gSystem->Load("libANALYSIS.so");
83 gSystem->Load("libANALYSISalice.so");
84 gSystem->Load("libCORRFW.so");
85 gSystem->Load("libNetx.so");
86 gSystem->Load("libPWGPPpid.so");
87
88 TFile *f = new TFile("AnalysisResults.root");
a8ad4709 89 TList *l = (TList *) f->Get("contPhiBayes1");
08b5b548 90 TList *l2 = (TList *) f->Get("contPhiBayes2");
7484404e 91
92 if(!(l && l2)) return 0;
93
08b5b548 94 fContPid1 = (AliPIDperfContainer *) l->FindObject("contPID");
95 fContPid2 = (AliPIDperfContainer *) l->FindObject("contPID2");
96 hmatched = (TH2F *) l2->FindObject("hMatchKa");
97 htracked = (TH2F *) l2->FindObject("hTrackingKa");
a8ad4709 98 }
99 kLoaded = kTRUE;
100
101 // check if MC
476e3d92
FN
102 Float_t x[] = {xmin[0]+0.001,xmin[1]+0.001,xmin[2]+0.001,xmin[3]+0.001,xmin[4]+0.001,xmin[5]+0.001,xmin[6]+0.001,xmin[7]+0.001,1/*trueMC*/,xmin[9],xmin[10],xmin[11],xmin[12],xmin[13]};
103 Float_t x2[] = {xmax[0],xmax[1],xmax[2],xmax[3],xmax[4],xmax[5],xmax[6],xmax[7],xmax[8],xmax[9],xmax[10],xmax[11],xmax[12],xmax[13]};
a8ad4709 104
7484404e 105 AliPIDperfContainer *tmp = (AliPIDperfContainer *) fContPid1;
a8ad4709 106 TH1D *h = tmp->GetQA(0, x, x2)->ProjectionX("checkMC");
107
108 if(h->GetEntries()) isMC = kTRUE;
109 else isMC=kFALSE;
110
111 if(!isMC){
112 selectTrue = kFALSE;
113 keepTrue = kTRUE;
114 }
115 else{
116 printf("MC truth found!!!!!!\nIt is MC!!!!!!");
117 }
118
119 fsign = new TF1("fsign","[0]*TMath::Voigt(x-[1],[3],[2])*(x>0.987)*(x > 1.005 && x < 1.035 || [4])",fitmin,fitmax);
120 fback = new TF1("fback","([0]*sqrt(x-0.987) + [1]*(x-0.987) + [2]*sqrt(x-0.987)*(x-0.987) +[3]*(x-0.987)*(x-0.987)+[4]*(x-0.987)*(x-0.987)*sqrt(x-0.987))*(x>0.987)",fitmin,fitmax);
121 fall = new TF1("fall","([0]*TMath::Voigt(x-[1],[3],[2])*(x > 1.005 && x < 1.035 || [9]) + [4]*sqrt(x-0.987) + [5]*(x-0.987) + [6]*sqrt(x-0.987)*(x-0.987) +[7]*(x-0.987)*(x-0.987)+[8]*(x-0.987)*(x-0.987)*sqrt(x-0.987))*(x>0.987)",0.987,1.05);
122
123 if(isMC){
124 fsign->SetParameter(4,0);
125 fall->FixParameter(9,0);
126 }
127 else{
128 fsign->SetParameter(4,1);
129 fall->FixParameter(9,1);
130 }
131
132 fsign->SetLineColor(2);
133 fback->SetLineColor(4);
134
135 if(kSigma2vs3){
136 kGoodMatch=kFALSE;
137 kOverAll = 0;
138 }
139
140 if(bayesVsigma){
141 kOverAll = 0;
142 kGoodMatch=kFALSE;
143 kSigma2vs3=kFALSE;
144 kTOFmatch=kTRUE;
6490e37e 145 weightS = -0.7;
a8ad4709 146 }
e34b28fe 147 if(kOverAll){
6490e37e 148 weightS = -0.7;
e34b28fe 149 }
7484404e 150
151 return 1;
a8ad4709 152}
153
7484404e 154void doeffKa(Int_t pos,Float_t prob,Float_t etaminkp,Float_t etamaxkp){
a8ad4709 155 LoadLib();
08b5b548 156 TH1D *hm = hmatched->ProjectionX("matchingKaEff",cmin,cmax);
157 TH1D *ht = htracked->ProjectionX("tracking",cmin,cmax);
158
159 hm->GetYaxis()->SetTitle("TOF matching eff.");
160 hm->SetTitle("Using probability as weights");
161
162 hm->Sumw2();
163 ht->Sumw2();
164
165 hm->Divide(hm,ht,1,1,"B");
a8ad4709 166
08b5b548 167
a8ad4709 168 Int_t nptbin = binPid[2];
169 Float_t minptbin = xmin[2];
170 Float_t maxptbin = xmax[2];
171
172 if(pos == 0){
173 nptbin = binPid[3];
174 minptbin = xmin[3];
175 maxptbin = xmax[3];
176 }
177
167b8b0a 178 if(prob > 0.1999|| kPid3Sigma ||kPid2Sigma){
a8ad4709 179 kGoodMatch = kFALSE;
180 kSigma2vs3 = kFALSE;
80d8d480 181// if(! kOverAll) require5sigma = kTRUE;
6490e37e 182 if(!isMC && !kOverAll) weightS = -0.95;
a8ad4709 183 }
184
7484404e 185 TCanvas *c1 = new TCanvas();
186 c1->Divide((nptbin+1)/2,2);
187 TH2F *hh,*hh2;
188 TH1D *h;
a8ad4709 189 char name[100];
190 Float_t b[50][3];
191
192 Double_t xx[50],yy[50];
193 Double_t exx[50],eyy[50];
194
195 for(Int_t i=0;i < nptbin;i++){
7484404e 196 c1->cd(i+1);//->SetLogy();
a8ad4709 197 Float_t ptmin = minptbin+(maxptbin-minptbin)/nptbin*(i);
198 Float_t ptmax = minptbin+(maxptbin-minptbin)/nptbin*(i+1);
199
200 xx[i] = (ptmin+ptmax)/2;
201 exx[i] = (-ptmin+ptmax)/2;
202
203 Float_t pp=0.1;
204 if(prob < 0.2) pp = 0.;
205 if(pos) hh=GetHistoKap(ptmin,ptmax,pp,0.0,etaminkp,etamaxkp);
206 else hh=GetHistoKan(ptmin,ptmax,pp,0.0);
207 sprintf(name,"TOF matched: %f < p_{T} < %f GeV/#it{c}",ptmin,ptmax);
208 hh->SetTitle(name);
209 sprintf(name,"hNoPid%i",i);
210
211 pp=prob;
212 if(prob < 0.2) pp = 0.1;
213 if(pos) hh2=GetHistoKap(ptmin,ptmax,pp,0.0,etaminkp,etamaxkp);
214 else hh2=GetHistoKan(ptmin,ptmax,pp,0.0);
215 AddHisto(hh,hh2,weightS);
216
217 h = hh->ProjectionX(name,cmin,cmax);
218 h->RebinX(rebinsize);
219 h->Draw("ERR");
220 h->SetMarkerStyle(24);
221 b[i][0]=-1;
222 Int_t ntrial = 0;
223 Float_t chi2 = 10000;
08b5b548 224 while(ntrial < 3 && (chi2 > 20 + 1000*selectTrue)){
a8ad4709 225 fit(h,b[i],"WW","",xx[i]);
226 c1->Update();
227// getchar();
228 fit(h,b[i],"","",xx[i]);
229 ntrial++;
230 chi2 = b[i][2];
231 printf("chi2 = %f\n",chi2);
232 c1->Update();
233// getchar();
234
235 }
236
237 yy[i] = fall->GetParameter(parplotted);
238 eyy[i] = fall->GetParError(parplotted);
239 }
240
241 TGraphErrors *gpar = new TGraphErrors(nptbin,xx,yy,exx,eyy);
7484404e 242 c1->cd(8);
08b5b548 243// gpar->Draw("AP");
a8ad4709 244 gpar->SetMarkerStyle(20);
245
246 TCanvas *c2 = new TCanvas();
247 c2->Divide((nptbin+1)/2,2);
248 Float_t b2[50][3];
249
250 for(Int_t i=0;i < nptbin;i++){
251 c2->cd(i+1);
252 Float_t ptmin = minptbin+(maxptbin-minptbin)/nptbin*(i);
253 Float_t ptmax = minptbin+(maxptbin-minptbin)/nptbin*(i+1);
254
255 Float_t pp=prob;
256 if(prob < 0.2) pp = 0.1;
257 if(pos) hh=GetHistoKap(ptmin,ptmax,pp,0.0,etaminkp,etamaxkp);
258 else hh=GetHistoKan(ptmin,ptmax,pp,0.0);
259 sprintf(name,"P_{TOF} > 0.8: %f < p_{T} < %f GeV/#it{c}",ptmin,ptmax);
260 hh->SetTitle(name);
261 sprintf(name,"hPid60_%i",i);
262 h = hh->ProjectionX(name,cmin,cmax);
263 h->RebinX(rebinsize);
264 h->Draw("ERR");
265 h->SetMarkerStyle(24);
266 b2[i][0]=-1;
267 Int_t ntrial = 0;
268 Float_t chi2 = 10000;
08b5b548 269 while(ntrial < 3 && (chi2 > 20 + 1000*selectTrue)){
a8ad4709 270 fit(h,b2[i],"WW","");
271 fit(h,b2[i],"","");
272 ntrial++;
273 chi2 = b2[i][2];
274 printf("chi2 = %f\n",chi2);
275 }
276 yy[i] = fall->GetParameter(parplotted);
277 eyy[i] = fall->GetParError(parplotted);
278
279 }
280
281 TGraphErrors *gpar2 = new TGraphErrors(nptbin,xx,yy,exx,eyy);
282 c2->cd(8);
08b5b548 283// gpar2->Draw("AP");
a8ad4709 284 gpar2->SetMarkerStyle(20);
285
286 Double_t xpt[50],expt[50],eff[50],efferr[50];
287 for(Int_t i=0;i<nptbin;i++){
288 printf("%f +/- %f - %f +/- %f\n",b[i][0],b[i][1],b2[i][0],b2[i][1]);
289
290 Float_t ptmin = minptbin+(maxptbin-minptbin)/nptbin*(i);
291 Float_t ptmax = minptbin+(maxptbin-minptbin)/nptbin*(i+1);
292
293 xpt[i] = (ptmin+ptmax)/2;
294 expt[i] = (-ptmin+ptmax)/2;
295 eff[i] = b2[i][0]/(b[i][0]-b2[i][0]*weightS);
296
297 b[i][0] = b[i][0]-b2[i][0]*weightS;
298
7ae044be 299 if(b[i][0] < 0.5) b[i][0] = 0.5;
300 if(b2[i][0] < 0.5) b2[i][0] = 0.5;
301
476e3d92
FN
302
303 efferr[i] = TMath::Abs(b[i][1]*b[i][1]/b[i][0]/b[i][0] + b2[i][1]*b2[i][1]/b2[i][0]/b2[i][0])*(b2[i][0]+b2[i][1])*(1+weightS*(b2[i][0]-b2[i][1])/b[i][0])/b[i][0];//*(1-eff[i]);//der2*der2*(b[i][1]*b[i][1] - b2[i][1]*b2[i][1]));
304 efferr[i] = TMath::Sqrt(efferr[i]);
a8ad4709 305
306 if(TMath::Abs(efferr[i]) > 1)efferr[i]=1;
307 }
308 new TCanvas();
309 TGraphErrors *geff = new TGraphErrors(nptbin,xpt,eff,expt,efferr);
310 geff->Draw("AP");
311
312 char flag[100];
7484404e 313 flag[0] = '\0';
a8ad4709 314
315 if(isMC){
316 if(selectTrue) sprintf(flag,"true");
317 else if(!keepTrue) sprintf(flag,"back");
318 }
319
320 char flag2[100];
7484404e 321 flag2[0] = '\0';
a8ad4709 322
08b5b548 323 Bool_t kWriteME = kFALSE;
324
a8ad4709 325 char etarange[100];
326 sprintf(etarange,"_%.1f-%.1f_",etaminkp,etamaxkp);
327
328 if(kGoodMatch)
329 sprintf(flag2,"GM");
330
331 if(bayesVsigma)
332 sprintf(flag2,"BayesVsSigma");
333
334 if(kSigma2vs3)
335 sprintf(flag2,"Sigma2vs3");
336
337 if(kOverAll)
338 sprintf(flag2,"OverAll");
e34b28fe 339 if(kOverAllTOFmatch)
340 sprintf(flag2,"OverAllTOF");
341 if(kOverAll2Sigma)
342 sprintf(flag2,"OverAll2sigma");
a8ad4709 343
167b8b0a 344 if(kPid3Sigma)
345 sprintf(flag2,"pid3sigma");
346 if(kPid2Sigma)
347 sprintf(flag2,"pid2sigma");
348
a8ad4709 349 if(pos){
350 if(prob >=0.2) sprintf(name,"kaonPos%sP%iEff%i_%i%s%s.root",etarange,Int_t(prob*100),(cmin-1)*10,cmax*10,flag,flag2);
08b5b548 351 else{
352 sprintf(name,"kaonPos%sMatchEff%i_%i%s%s.root",etarange,(cmin-1)*10,cmax*10,flag,flag2);
6490e37e 353 if(!(kOverAll || bayesVsigma || kGoodMatch || kSigma2vs3)) kWriteME = kTRUE;
08b5b548 354 }
a8ad4709 355 }
356 else{
357 if(prob >=0.2) sprintf(name,"kaonNeg%sP%iEff%i_%i%s%s.root",etarange,Int_t(prob*100),(cmin-1)*10,cmax*10,flag,flag2);
358 else sprintf(name,"kaonNeg%sMatchEff%i_%i%s%s.root",etarange,(cmin-1)*10,cmax*10,flag,flag2);
359 }
360
08b5b548 361 geff->SetTitle("K efficiency (from #phi);p_{T} (GeV/#it{c};efficiency");
a8ad4709 362 TFile *fout = new TFile(name,"RECREATE");
363 geff->Write();
08b5b548 364 if(kWriteME) hm->Write();
a8ad4709 365 fout->Close();
366
08b5b548 367 if(kWriteME) hm->Draw("SAME");
a8ad4709 368}
369
7484404e 370TH2F *GetHistoKap(Float_t pt,Float_t ptM,Float_t pMinkp,Float_t pMinkn,Float_t etaminkp,Float_t etamaxkp){
a8ad4709 371
167b8b0a 372 Float_t x[] = {xmin[0]+0.001,etaminkp+0.001,pt+0.001,xmin[3]+0.001,pMinkp+0.001,pMinkn+0.001,(pMinkp>0.09 || kPid3Sigma||kPid2Sigma)+0.001,kTOFmatch+0.001,selectTrue,xmin[9],xmin[10],xmin[11],xmin[12],xmin[13]};
a8ad4709 373 Float_t x2[] = {xmax[0],etamaxkp-0.001,ptM-0.001,xmax[3],xmax[4],xmax[5],xmax[6],xmax[7],keepTrue,xmax[9],xmax[10],xmax[11],xmax[12],xmax[13]};
374
e34b28fe 375 if(kOverAll){
376 x[6] = 0.0001;
6490e37e 377 x2[9] = 5.9;
378 if(pMinkp > 0.19) x2[9] = 4.9;
e34b28fe 379 }
380
381 if(kOverAllTOFmatch && pMinkp > 0.19){
382 x[6] = 1.0001;
6490e37e 383 x2[9] = 4.9;
e34b28fe 384 }
385
386 if(kOverAll2Sigma && pMinkp > 0.09){
387 x2[9] = 2;
388 x[6] = 1.0001;
389 }
390
a8ad4709 391 if(kGoodMatch){
392 x[6] = 1.0001;
393 if(pMinkp > 0)
394 x2[9] = 4.9;
395
396 }
397
398 if(kTOFmatch){
399 x[6] = 1.0001;
400 }
401
402 if(kSigma2vs3){
403 x[6] = 1.0001;
404 x2[9] = 3;
405 if(pMinkp > 0)
406 x2[9] = 2;
407 }
408
409 if(bayesVsigma){
410 if(pMinkp > 0){
411 x[4] = 0.2001;
412 x2[9] = 5;
413 }
414 else{
415 x2[9] = 3;
416 }
417
418
419 }
420
421 if(require5sigma) x2[9] = 4.9;
167b8b0a 422 if(kPid3Sigma && pMinkp>0.09) x2[9] = 2.9;
423 if(kPid2Sigma && pMinkp>0.09) x2[9] = 1.9;
a8ad4709 424
7484404e 425 AliPIDperfContainer *tmp = (AliPIDperfContainer *) fContPid1;
a8ad4709 426
427 TH2F *h = tmp->GetQA(0, x, x2);
428
429 h->GetXaxis()->SetTitle("M_{#phi} (GeV/#it{c}^{2})");
430 h->GetYaxis()->SetTitle("centrality [%]");
431
432 return h;
433}
434
7484404e 435TH2F *GetHistoKan(Float_t pt,Float_t ptM,Float_t pMinkn,Float_t pMinkp,Float_t etaminkp,Float_t etamaxkp){
a8ad4709 436
167b8b0a 437 Float_t x[] = {xmin[0]+0.001,etaminkp+0.001,xmin[2]+0.001,pt+0.001,pMinkp+0.001,pMinkn+0.001,kTOFmatch+0.001,(pMinkn>0.09 || kPid3Sigma||kPid2Sigma)+0.001,selectTrue,xmin[9],xmin[10],xmin[11],xmin[12],xmin[13]};
a8ad4709 438 Float_t x2[] = {xmax[0],etamaxkp-0.001,xmax[2],ptM-0.001,xmax[4],xmax[5],xmax[6],xmax[7],keepTrue,xmax[9],xmax[10],xmax[11],xmax[12],xmax[13]};
439
e34b28fe 440 if(kOverAll){
441 x[7] = 0.0001;
6490e37e 442 x2[10] = 5.9;
443 if(pMinkn > 0.19) x2[10] = 4.9;
e34b28fe 444 }
445
446 if(kOverAllTOFmatch && pMinkn > 0.19){
447 x[7] = 1.0001;
6490e37e 448 x2[10] = 4.9;
e34b28fe 449 }
450
451 if(kOverAll2Sigma && pMinkn > 0.09){
452 x2[10] = 2;
453 x[7] = 1.0001;
454 }
455
a8ad4709 456 if(kGoodMatch){
457 x[7] = 1.0001;
458 if(pMinkn > 0)
459 x2[10] = 4.9;
460
461 }
462
463 if(kTOFmatch){
464 x[7] = 1.0001;
465 }
466
467 if(kSigma2vs3){
468 x[7] = 1.0001;
469 x2[10] = 3;
470 if(pMinkn > 0)
471 x2[10] = 2;
472 }
473
474 if(bayesVsigma){
475 if(pMinkn > 0){
476 x[5] = 0.2001;
477 x2[10] = 5;
478 }
479 else{
480 x2[10] = 3;
481 }
482 }
483
484 if(require5sigma) x2[10] = 4.9;
167b8b0a 485 if(kPid3Sigma && pMinkn>0.09) x2[10] = 2.9;
486 if(kPid2Sigma && pMinkn>0.09) x2[10] = 1.9;
a8ad4709 487
7484404e 488 AliPIDperfContainer *tmp = (AliPIDperfContainer *) fContPid2;
a8ad4709 489
490 TH2F *h = tmp->GetQA(0, x, x2);
491
492 h->GetXaxis()->SetTitle("M_{#phi} (GeV/#it{c}^{2})");
493 h->GetYaxis()->SetTitle("centrality [%]");
494
495 return h;
496}
497
498
7484404e 499void fit(TH1D *h,Float_t *a,char *opt,char *opt2,Float_t pt){
a8ad4709 500 if(h->GetEntries() < 1){
501 if(a){
502 a[0]=0.01;
503 a[1]=1;
504 }
505 return;
506 }
507
508
509 fall->SetParameter(0,100);
510 fall->SetParameter(0,1.01898 + 2.4e-04*pt);
511 fall->SetParameter(2,0.0044);
512 fall->SetParameter(3,0.0015);
513
514 fall->SetParLimits(0,-100,100000);
515 fall->SetParLimits(1,1.01898 + 2.4e-04*pt-1e-03,1.01898 + 2.4e-04*pt+1e-03);
516 fall->SetParLimits(2,0.0005,0.006);
517 fall->SetParLimits(3,0.001,0.0017);
518
519 fall->FixParameter(1,1.01884 + 2.9891e-04*pt);
520 fall->FixParameter(2,0.0044);
521 fall->FixParameter(3,7.57574e-04 + 3.85408e-04*pt);
522
523 fall->ReleaseParameter(4);
524 fall->ReleaseParameter(5);
525 fall->ReleaseParameter(6);
526 fall->ReleaseParameter(7);
527 fall->ReleaseParameter(8);
528
529
530 if(!kGoodMatch && !kSigma2vs3){
531 if(pt > 1.5){
532 fall->FixParameter(7,0);
533 fall->FixParameter(8,0);
534 }
535 if(pt > 1.7){
536 fall->FixParameter(6,0);
537 }
538 }
539
540 if(selectTrue){
541 fall->FixParameter(4,0);
542 fall->FixParameter(5,0);
543 fall->FixParameter(6,0);
544 fall->FixParameter(7,0);
545 fall->FixParameter(8,0);
546 }
547
548 char name[100];
549 TF1 *ftmp=fall;
550
551 TF1 *ftmp2=new TF1(*fsign);
552 sprintf(name,"fsign%i",ifunc);
553 ftmp2->SetName(name);
554
555 TF1 *ftmp3=new TF1(*fback);
556 sprintf(name,"ftmp3%i",ifunc);
557 ftmp3->SetName(name);
558
559 ifunc++;
560
561 h->Fit(ftmp,opt,opt2,fitmin,fitmax);
562 h->Draw("ERR");
563
564 ftmp2->SetParameter(0,ftmp->GetParameter(0));
565 ftmp2->SetParameter(1,ftmp->GetParameter(1));
566 ftmp2->SetParameter(2,ftmp->GetParameter(2));
567 ftmp2->SetParameter(3,ftmp->GetParameter(3));
568 ftmp2->Draw("SAME");
569 ftmp3->SetParameter(0,ftmp->GetParameter(4));
570 ftmp3->SetParameter(1,ftmp->GetParameter(5));
571 ftmp3->SetParameter(2,ftmp->GetParameter(6));
572 ftmp3->SetParameter(3,ftmp->GetParameter(7));
573 ftmp3->SetParameter(4,ftmp->GetParameter(8));
574 ftmp3->Draw("SAME");
575
576 Float_t mean = ftmp->GetParameter(1);
577 Float_t sigma = 0.0044;//TMath::Abs(ftmp->GetParameter(2));
578
579 Float_t signI = ftmp2->Integral(mean-10*sigma,mean+10*sigma)/h->GetBinWidth(1);
7ae044be 580 if(signI < 0.1) signI = 0.1;
476e3d92 581
a8ad4709 582 Float_t backI = ftmp3->Integral(mean-3*sigma,mean+3*sigma)/h->GetBinWidth(1);
476e3d92 583 if(backI < 1) backI = 1;
a8ad4709 584
476e3d92
FN
585 Float_t errI = TMath::Abs(ftmp->GetParError(0)*ftmp->GetParError(0)/(0.001+ftmp->GetParameter(0))/(0.001+ftmp->GetParameter(0)));
586 errI = TMath::Sqrt(errI);
a8ad4709 587
588 printf("signal(5 sigma) = %f +/- %f(fit) +/- %f(stat)\n",signI,errI*signI,TMath::Sqrt(signI));
589 printf("backgr(3sigma) = %f\n",backI);
590 printf("significance(3 sigma) = %f\n",signI/sqrt(signI+backI));
591
592 if(a){
593 a[0]=signI;
594 a[1]=signI*errI*signI*errI + signI;
595 a[1] = TMath::Sqrt(a[1]);
596 if(ftmp->GetNDF()) a[2] = ftmp->GetChisquare()/ftmp->GetNDF();
597
598
599 if(selectTrue){
6490e37e 600 a[0] = h->GetEntries();
a8ad4709 601 a[1] = TMath::Sqrt(a[0]);
602 }
603 }
604}
605
7484404e 606void AddHisto(TH2F *h1,TH2F *h2,Float_t w){
a8ad4709 607 Int_t nbinx = h1->GetNbinsX();
608 Int_t nbiny = h1->GetNbinsY();
609
610 for(Int_t i=1;i<=nbinx;i++){
611 for(Int_t j=1;j<=nbiny;j++){
7484404e 612 Double_t val = h1->GetBinContent(i,j) + h2->GetBinContent(i,j)*w;
a8ad4709 613 Float_t err = TMath::Min(TMath::Sqrt(val),val);
614 h1->SetBinContent(i,j,val);
615 h1->SetBinError(i,j,err);
616 }
617 }
618}