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