]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGPP/pid/doeffKa.C
Merge branch 'feature-movesplit'
[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){
4070f709 74 gSystem->Load("libVMC");
75 gSystem->Load("libPhysics");
76 gSystem->Load("libTree");
77 gSystem->Load("libMinuit");
78 gSystem->Load("libSTEERBase");
79 gSystem->Load("libANALYSIS");
80 gSystem->Load("libAOD");
81 gSystem->Load("libESD");
82 gSystem->Load("libANALYSIS");
83 gSystem->Load("libANALYSISalice");
84 gSystem->Load("libCORRFW");
85 gSystem->Load("libNetx");
86 gSystem->Load("libPWGPPpid");
a8ad4709 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
9309a88b 217 if(xx[i] > 2.5) rebinsize = 2;
218
a8ad4709 219 h = hh->ProjectionX(name,cmin,cmax);
220 h->RebinX(rebinsize);
221 h->Draw("ERR");
222 h->SetMarkerStyle(24);
223 b[i][0]=-1;
224 Int_t ntrial = 0;
225 Float_t chi2 = 10000;
08b5b548 226 while(ntrial < 3 && (chi2 > 20 + 1000*selectTrue)){
a8ad4709 227 fit(h,b[i],"WW","",xx[i]);
228 c1->Update();
229// getchar();
230 fit(h,b[i],"","",xx[i]);
231 ntrial++;
232 chi2 = b[i][2];
233 printf("chi2 = %f\n",chi2);
234 c1->Update();
235// getchar();
236
237 }
238
239 yy[i] = fall->GetParameter(parplotted);
240 eyy[i] = fall->GetParError(parplotted);
241 }
242
243 TGraphErrors *gpar = new TGraphErrors(nptbin,xx,yy,exx,eyy);
7484404e 244 c1->cd(8);
08b5b548 245// gpar->Draw("AP");
a8ad4709 246 gpar->SetMarkerStyle(20);
247
248 TCanvas *c2 = new TCanvas();
249 c2->Divide((nptbin+1)/2,2);
250 Float_t b2[50][3];
251
252 for(Int_t i=0;i < nptbin;i++){
253 c2->cd(i+1);
254 Float_t ptmin = minptbin+(maxptbin-minptbin)/nptbin*(i);
255 Float_t ptmax = minptbin+(maxptbin-minptbin)/nptbin*(i+1);
256
257 Float_t pp=prob;
258 if(prob < 0.2) pp = 0.1;
259 if(pos) hh=GetHistoKap(ptmin,ptmax,pp,0.0,etaminkp,etamaxkp);
260 else hh=GetHistoKan(ptmin,ptmax,pp,0.0);
261 sprintf(name,"P_{TOF} > 0.8: %f < p_{T} < %f GeV/#it{c}",ptmin,ptmax);
262 hh->SetTitle(name);
263 sprintf(name,"hPid60_%i",i);
264 h = hh->ProjectionX(name,cmin,cmax);
265 h->RebinX(rebinsize);
266 h->Draw("ERR");
267 h->SetMarkerStyle(24);
268 b2[i][0]=-1;
269 Int_t ntrial = 0;
270 Float_t chi2 = 10000;
08b5b548 271 while(ntrial < 3 && (chi2 > 20 + 1000*selectTrue)){
a8ad4709 272 fit(h,b2[i],"WW","");
273 fit(h,b2[i],"","");
274 ntrial++;
275 chi2 = b2[i][2];
276 printf("chi2 = %f\n",chi2);
277 }
278 yy[i] = fall->GetParameter(parplotted);
279 eyy[i] = fall->GetParError(parplotted);
280
281 }
282
283 TGraphErrors *gpar2 = new TGraphErrors(nptbin,xx,yy,exx,eyy);
284 c2->cd(8);
08b5b548 285// gpar2->Draw("AP");
a8ad4709 286 gpar2->SetMarkerStyle(20);
287
288 Double_t xpt[50],expt[50],eff[50],efferr[50];
289 for(Int_t i=0;i<nptbin;i++){
290 printf("%f +/- %f - %f +/- %f\n",b[i][0],b[i][1],b2[i][0],b2[i][1]);
291
292 Float_t ptmin = minptbin+(maxptbin-minptbin)/nptbin*(i);
293 Float_t ptmax = minptbin+(maxptbin-minptbin)/nptbin*(i+1);
294
295 xpt[i] = (ptmin+ptmax)/2;
296 expt[i] = (-ptmin+ptmax)/2;
297 eff[i] = b2[i][0]/(b[i][0]-b2[i][0]*weightS);
298
ca4825ae 299 // b[i][0] = b[i][0]-b2[i][0]*weightS;
a8ad4709 300
ca4825ae 301 // if(b[i][0] < 0.5) b[i][0] = 0.5;
302 // if(b2[i][0] < 0.5) b2[i][0] = 0.5;
7ae044be 303
476e3d92 304
ca4825ae 305 // 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]));
306 // efferr[i] = TMath::Sqrt(efferr[i]);
307 efferr[i] = 1./(b[i][0]-b2[i][0]*weightS)/(b[i][0]-b2[i][0]*weightS)*TMath::Sqrt(b[i][0]*b[i][0]*b2[i][1]*b2[i][1] + b2[i][0]*b2[i][0]*b[i][1]*b[i][1]);
a8ad4709 308
309 if(TMath::Abs(efferr[i]) > 1)efferr[i]=1;
310 }
311 new TCanvas();
312 TGraphErrors *geff = new TGraphErrors(nptbin,xpt,eff,expt,efferr);
313 geff->Draw("AP");
314
315 char flag[100];
7484404e 316 flag[0] = '\0';
a8ad4709 317
318 if(isMC){
319 if(selectTrue) sprintf(flag,"true");
320 else if(!keepTrue) sprintf(flag,"back");
321 }
322
323 char flag2[100];
7484404e 324 flag2[0] = '\0';
a8ad4709 325
08b5b548 326 Bool_t kWriteME = kFALSE;
327
a8ad4709 328 char etarange[100];
329 sprintf(etarange,"_%.1f-%.1f_",etaminkp,etamaxkp);
330
331 if(kGoodMatch)
332 sprintf(flag2,"GM");
333
334 if(bayesVsigma)
335 sprintf(flag2,"BayesVsSigma");
336
337 if(kSigma2vs3)
338 sprintf(flag2,"Sigma2vs3");
339
340 if(kOverAll)
341 sprintf(flag2,"OverAll");
e34b28fe 342 if(kOverAllTOFmatch)
343 sprintf(flag2,"OverAllTOF");
344 if(kOverAll2Sigma)
345 sprintf(flag2,"OverAll2sigma");
a8ad4709 346
167b8b0a 347 if(kPid3Sigma)
348 sprintf(flag2,"pid3sigma");
349 if(kPid2Sigma)
350 sprintf(flag2,"pid2sigma");
351
a8ad4709 352 if(pos){
353 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 354 else{
355 sprintf(name,"kaonPos%sMatchEff%i_%i%s%s.root",etarange,(cmin-1)*10,cmax*10,flag,flag2);
6490e37e 356 if(!(kOverAll || bayesVsigma || kGoodMatch || kSigma2vs3)) kWriteME = kTRUE;
08b5b548 357 }
a8ad4709 358 }
359 else{
360 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);
361 else sprintf(name,"kaonNeg%sMatchEff%i_%i%s%s.root",etarange,(cmin-1)*10,cmax*10,flag,flag2);
362 }
363
08b5b548 364 geff->SetTitle("K efficiency (from #phi);p_{T} (GeV/#it{c};efficiency");
a8ad4709 365 TFile *fout = new TFile(name,"RECREATE");
366 geff->Write();
08b5b548 367 if(kWriteME) hm->Write();
a8ad4709 368 fout->Close();
369
08b5b548 370 if(kWriteME) hm->Draw("SAME");
a8ad4709 371}
372
7484404e 373TH2F *GetHistoKap(Float_t pt,Float_t ptM,Float_t pMinkp,Float_t pMinkn,Float_t etaminkp,Float_t etamaxkp){
a8ad4709 374
167b8b0a 375 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 376 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]};
377
e34b28fe 378 if(kOverAll){
379 x[6] = 0.0001;
6490e37e 380 x2[9] = 5.9;
381 if(pMinkp > 0.19) x2[9] = 4.9;
e34b28fe 382 }
383
384 if(kOverAllTOFmatch && pMinkp > 0.19){
385 x[6] = 1.0001;
6490e37e 386 x2[9] = 4.9;
e34b28fe 387 }
388
389 if(kOverAll2Sigma && pMinkp > 0.09){
390 x2[9] = 2;
391 x[6] = 1.0001;
392 }
393
a8ad4709 394 if(kGoodMatch){
395 x[6] = 1.0001;
396 if(pMinkp > 0)
397 x2[9] = 4.9;
398
399 }
400
401 if(kTOFmatch){
402 x[6] = 1.0001;
403 }
404
405 if(kSigma2vs3){
406 x[6] = 1.0001;
407 x2[9] = 3;
408 if(pMinkp > 0)
409 x2[9] = 2;
410 }
411
412 if(bayesVsigma){
413 if(pMinkp > 0){
414 x[4] = 0.2001;
415 x2[9] = 5;
416 }
417 else{
418 x2[9] = 3;
419 }
420
421
422 }
423
424 if(require5sigma) x2[9] = 4.9;
167b8b0a 425 if(kPid3Sigma && pMinkp>0.09) x2[9] = 2.9;
426 if(kPid2Sigma && pMinkp>0.09) x2[9] = 1.9;
a8ad4709 427
7484404e 428 AliPIDperfContainer *tmp = (AliPIDperfContainer *) fContPid1;
a8ad4709 429
430 TH2F *h = tmp->GetQA(0, x, x2);
431
432 h->GetXaxis()->SetTitle("M_{#phi} (GeV/#it{c}^{2})");
433 h->GetYaxis()->SetTitle("centrality [%]");
434
435 return h;
436}
437
7484404e 438TH2F *GetHistoKan(Float_t pt,Float_t ptM,Float_t pMinkn,Float_t pMinkp,Float_t etaminkp,Float_t etamaxkp){
a8ad4709 439
167b8b0a 440 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 441 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]};
442
e34b28fe 443 if(kOverAll){
444 x[7] = 0.0001;
6490e37e 445 x2[10] = 5.9;
446 if(pMinkn > 0.19) x2[10] = 4.9;
e34b28fe 447 }
448
449 if(kOverAllTOFmatch && pMinkn > 0.19){
450 x[7] = 1.0001;
6490e37e 451 x2[10] = 4.9;
e34b28fe 452 }
453
454 if(kOverAll2Sigma && pMinkn > 0.09){
455 x2[10] = 2;
456 x[7] = 1.0001;
457 }
458
a8ad4709 459 if(kGoodMatch){
460 x[7] = 1.0001;
461 if(pMinkn > 0)
462 x2[10] = 4.9;
463
464 }
465
466 if(kTOFmatch){
467 x[7] = 1.0001;
468 }
469
470 if(kSigma2vs3){
471 x[7] = 1.0001;
472 x2[10] = 3;
473 if(pMinkn > 0)
474 x2[10] = 2;
475 }
476
477 if(bayesVsigma){
478 if(pMinkn > 0){
479 x[5] = 0.2001;
480 x2[10] = 5;
481 }
482 else{
483 x2[10] = 3;
484 }
485 }
486
487 if(require5sigma) x2[10] = 4.9;
167b8b0a 488 if(kPid3Sigma && pMinkn>0.09) x2[10] = 2.9;
489 if(kPid2Sigma && pMinkn>0.09) x2[10] = 1.9;
a8ad4709 490
7484404e 491 AliPIDperfContainer *tmp = (AliPIDperfContainer *) fContPid2;
a8ad4709 492
493 TH2F *h = tmp->GetQA(0, x, x2);
494
495 h->GetXaxis()->SetTitle("M_{#phi} (GeV/#it{c}^{2})");
496 h->GetYaxis()->SetTitle("centrality [%]");
497
498 return h;
499}
500
501
7484404e 502void fit(TH1D *h,Float_t *a,char *opt,char *opt2,Float_t pt){
a8ad4709 503 if(h->GetEntries() < 1){
504 if(a){
505 a[0]=0.01;
506 a[1]=1;
507 }
508 return;
509 }
510
511
512 fall->SetParameter(0,100);
513 fall->SetParameter(0,1.01898 + 2.4e-04*pt);
514 fall->SetParameter(2,0.0044);
515 fall->SetParameter(3,0.0015);
516
517 fall->SetParLimits(0,-100,100000);
518 fall->SetParLimits(1,1.01898 + 2.4e-04*pt-1e-03,1.01898 + 2.4e-04*pt+1e-03);
519 fall->SetParLimits(2,0.0005,0.006);
520 fall->SetParLimits(3,0.001,0.0017);
521
522 fall->FixParameter(1,1.01884 + 2.9891e-04*pt);
523 fall->FixParameter(2,0.0044);
524 fall->FixParameter(3,7.57574e-04 + 3.85408e-04*pt);
525
526 fall->ReleaseParameter(4);
527 fall->ReleaseParameter(5);
528 fall->ReleaseParameter(6);
529 fall->ReleaseParameter(7);
530 fall->ReleaseParameter(8);
531
532
533 if(!kGoodMatch && !kSigma2vs3){
534 if(pt > 1.5){
535 fall->FixParameter(7,0);
536 fall->FixParameter(8,0);
537 }
538 if(pt > 1.7){
539 fall->FixParameter(6,0);
540 }
541 }
542
543 if(selectTrue){
544 fall->FixParameter(4,0);
545 fall->FixParameter(5,0);
546 fall->FixParameter(6,0);
547 fall->FixParameter(7,0);
548 fall->FixParameter(8,0);
549 }
550
551 char name[100];
552 TF1 *ftmp=fall;
553
554 TF1 *ftmp2=new TF1(*fsign);
555 sprintf(name,"fsign%i",ifunc);
556 ftmp2->SetName(name);
557
558 TF1 *ftmp3=new TF1(*fback);
559 sprintf(name,"ftmp3%i",ifunc);
560 ftmp3->SetName(name);
561
562 ifunc++;
563
564 h->Fit(ftmp,opt,opt2,fitmin,fitmax);
565 h->Draw("ERR");
566
567 ftmp2->SetParameter(0,ftmp->GetParameter(0));
568 ftmp2->SetParameter(1,ftmp->GetParameter(1));
569 ftmp2->SetParameter(2,ftmp->GetParameter(2));
570 ftmp2->SetParameter(3,ftmp->GetParameter(3));
571 ftmp2->Draw("SAME");
572 ftmp3->SetParameter(0,ftmp->GetParameter(4));
573 ftmp3->SetParameter(1,ftmp->GetParameter(5));
574 ftmp3->SetParameter(2,ftmp->GetParameter(6));
575 ftmp3->SetParameter(3,ftmp->GetParameter(7));
576 ftmp3->SetParameter(4,ftmp->GetParameter(8));
577 ftmp3->Draw("SAME");
578
579 Float_t mean = ftmp->GetParameter(1);
580 Float_t sigma = 0.0044;//TMath::Abs(ftmp->GetParameter(2));
581
582 Float_t signI = ftmp2->Integral(mean-10*sigma,mean+10*sigma)/h->GetBinWidth(1);
7ae044be 583 if(signI < 0.1) signI = 0.1;
476e3d92 584
a8ad4709 585 Float_t backI = ftmp3->Integral(mean-3*sigma,mean+3*sigma)/h->GetBinWidth(1);
476e3d92 586 if(backI < 1) backI = 1;
a8ad4709 587
476e3d92
FN
588 Float_t errI = TMath::Abs(ftmp->GetParError(0)*ftmp->GetParError(0)/(0.001+ftmp->GetParameter(0))/(0.001+ftmp->GetParameter(0)));
589 errI = TMath::Sqrt(errI);
a8ad4709 590
591 printf("signal(5 sigma) = %f +/- %f(fit) +/- %f(stat)\n",signI,errI*signI,TMath::Sqrt(signI));
592 printf("backgr(3sigma) = %f\n",backI);
593 printf("significance(3 sigma) = %f\n",signI/sqrt(signI+backI));
594
595 if(a){
596 a[0]=signI;
597 a[1]=signI*errI*signI*errI + signI;
598 a[1] = TMath::Sqrt(a[1]);
599 if(ftmp->GetNDF()) a[2] = ftmp->GetChisquare()/ftmp->GetNDF();
600
601
602 if(selectTrue){
6490e37e 603 a[0] = h->GetEntries();
a8ad4709 604 a[1] = TMath::Sqrt(a[0]);
605 }
606 }
607}
608
7484404e 609void AddHisto(TH2F *h1,TH2F *h2,Float_t w){
a8ad4709 610 Int_t nbinx = h1->GetNbinsX();
611 Int_t nbiny = h1->GetNbinsY();
612
613 for(Int_t i=1;i<=nbinx;i++){
614 for(Int_t j=1;j<=nbiny;j++){
7484404e 615 Double_t val = h1->GetBinContent(i,j) + h2->GetBinContent(i,j)*w;
a8ad4709 616 Float_t err = TMath::Min(TMath::Sqrt(val),val);
617 h1->SetBinContent(i,j,val);
618 h1->SetBinError(i,j,err);
619 }
620 }
621}