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