Bug correction
[u/mrichter/AliRoot.git] / HBTAN / AliHBTPIDPurityFctns.cxx
CommitLineData
becde6ce 1#include "AliHBTPIDPurityFctns.h"
2//_______________________________________________________________________________
3/////////////////////////////////////////////////////////////////////////////////
4//
5// class AliHBTMonPhiResolutionVsPtFctn;
6// class AliHBTMonThetaResolutionVsPtFctn;
7//
8// file: AliHBTPIDPurityFctns.cxx AliHBTPIDPurityFctns.h
9//
10// Caution: On 2D plots on X axis in simulated values
11// That is contrary to two-particle resolutions where it is reconstructed one
12//
13// added by Piotr.Skowronski@cern.ch
14//
15//
16//////////////////////////////////////////////////////////////////////////////////
17
18
19/******************************************************************/
20/******************************************************************/
21
22ClassImp(AliHBTMonPIDPurityVsPtFctn)
23
24AliHBTMonPIDPurityVsPtFctn::AliHBTMonPIDPurityVsPtFctn(Int_t nbins, Double_t maxXval, Double_t minXval):
25 AliHBTMonTwoParticleFctn1D(nbins,maxXval,minXval),
81b40753 26 fGood(0x0),
27 fAll(0x0)
becde6ce 28{
29 //ctor
30 Rename("pidpurityvspt","PIDPurityVsPt");
31
32}
33/******************************************************************/
34
35AliHBTMonPIDPurityVsPtFctn::~AliHBTMonPIDPurityVsPtFctn()
36{
37 //dtor
38 delete fGood;
81b40753 39 delete fAll;
becde6ce 40}
41/******************************************************************/
42void AliHBTMonPIDPurityVsPtFctn::Write()
43{
44 AliHBTMonitorFunction::Write();
45 fGood->Write();
81b40753 46 fAll->Write();
becde6ce 47}
48/******************************************************************/
49
50void AliHBTMonPIDPurityVsPtFctn::Init()
51{
52//Initializes fuction
53 if (AliHBTParticle::GetDebug()>0) Info("Init","%s",GetName());
54
55 if (fResult == 0x0)
56 {
57 Warning("Init","Function has NULL result histogram!");
58 return;
59 }
60
61 if (fGood == 0x0)
62 {
63 TString numstr = fName + " Good"; //title and name of the
64 //result histogram
65 TAxis* xax = fResult->GetXaxis();
66 fGood = new TH1D(numstr,numstr,xax->GetNbins(),xax->GetXmin(),xax->GetXmax());
67 }
68
81b40753 69 if (fAll == 0x0)
70 {
71 TString numstr = fName + " All"; //title and name of the
72 //result histogram
73 TAxis* xax = fResult->GetXaxis();
74 fAll = new TH1D(numstr,numstr,xax->GetNbins(),xax->GetXmin(),xax->GetXmax());
75 }
76
becde6ce 77 fResult->Reset();
78 fResult->SetDirectory(0x0);
81b40753 79 fResult->Sumw2();
becde6ce 80 fGood->Reset();
81 fGood->SetDirectory(0x0);
81b40753 82 fGood->Sumw2();
83 fAll->Reset();
84 fAll->SetDirectory(0x0);
85 fAll->Sumw2();
becde6ce 86
87 if (AliHBTParticle::GetDebug()>0) Info("Init","%s Done.",GetName());
88}
89
90/******************************************************************/
91
92void AliHBTMonPIDPurityVsPtFctn::Rename(const Char_t * name)
93{
94 //Rename fuctions and all histograms belonging to it
95 SetName(name);
96 SetTitle(name);
97
98 if (fResult)
99 {
100 TString numstr = fName + " Result"; //title and name of the result histogram
101 fResult->SetName(numstr);
102 fResult->SetTitle(numstr);
103 }
104 if (fGood)
105 {
106 TString numstr = fName + " Good";
107 fGood->SetName(numstr);
108 fGood->SetTitle(numstr);
109 }
81b40753 110
111 if (fAll)
112 {
113 TString numstr = fName + " All";
114 fAll->SetName(numstr);
115 fAll->SetTitle(numstr);
116 }
becde6ce 117}
118/******************************************************************/
119
120void AliHBTMonPIDPurityVsPtFctn::Rename(const Char_t * name, const Char_t * title)
121{
122 //renames and retitle the function and histograms
123
124 SetName(name);
125 SetTitle(title);
126
127 if (fResult)
128 {
129 TString numstrn = fName + " Result"; //name of the result histogram
130 TString numstrt = fTitle + " Result"; //title of the result histogram
131 fResult->SetName(numstrn);
132 fResult->SetTitle(numstrt);
133 }
134 if (fGood)
135 {
136 TString numstrn = fName + " Good"; //name of the Good histogram
137 TString numstrt = fTitle + " Good"; //title of the Good histogram
138 fGood->SetName(numstrn);
139 fGood->SetTitle(numstrt);
140 }
141
81b40753 142 if (fAll)
143 {
144 TString numstrn = fName + " All"; //name of the All histogram
145 TString numstrt = fTitle + " All"; //title of the All histogram
146 fAll->SetName(numstrn);
147 fAll->SetTitle(numstrt);
148 }
149
becde6ce 150}
151/******************************************************************/
152
153TH1* AliHBTMonPIDPurityVsPtFctn::GetResult()
154{
155 //Returns the result of the fuction
156 //that is histogram with effciency and contamination
157
81b40753 158 fResult->Divide(fGood,fAll);
becde6ce 159 return fResult;
160}
161/******************************************************************/
162
163void AliHBTMonPIDPurityVsPtFctn::Process(AliHBTParticle * track,AliHBTParticle * part)
164{
165 //process the particle/track
166 Double_t pt = part->Pt();
81b40753 167 fAll->Fill(pt);
becde6ce 168 if (track->GetPdgCode() == part->GetPdgCode())
169 {
170 fGood->Fill(pt);
171 }
172// else
173// {
174// Info("Process","Catched pid impurity ...");
175// }
176}
177
178/******************************************************************/
179/******************************************************************/
180/******************************************************************/
181
182ClassImp(AliHBTMonPIDContaminationVsPtFctn)
183
184AliHBTMonPIDContaminationVsPtFctn::AliHBTMonPIDContaminationVsPtFctn(Int_t nbins, Double_t maxXval, Double_t minXval):
185 AliHBTMonTwoParticleFctn1D(nbins,maxXval,minXval),
81b40753 186 fWrong(0x0),
187 fAll(0x0)
becde6ce 188{
189 //ctor
190 Rename("pidcontaminationvspt","PIDContaminationVsPt");
191}
192/******************************************************************/
193
194AliHBTMonPIDContaminationVsPtFctn::~AliHBTMonPIDContaminationVsPtFctn()
195{
196 //dtor
197 delete fWrong;
81b40753 198 delete fAll;
becde6ce 199}
200/******************************************************************/
201
202void AliHBTMonPIDContaminationVsPtFctn::Write()
203{
204 //Writes the function results
205 AliHBTMonitorFunction::Write();
206 fWrong->Write();
81b40753 207 fAll->Write();
becde6ce 208}
209/******************************************************************/
210
211void AliHBTMonPIDContaminationVsPtFctn::Init()
212{
213//Initializes fuction
214 if (AliHBTParticle::GetDebug()>0) Info("Init","%s",GetName());
215
216 if (fResult == 0x0)
217 {
218 Warning("Init","Function has NULL result histogram!");
219 return;
220 }
221
222 if (fWrong == 0x0)
223 {
224 TString numstr = fName + " Wrong"; //title and name of the
225 //result histogram
226 TAxis* xax = fResult->GetXaxis();
227 fWrong = new TH1D(numstr,numstr,xax->GetNbins(),xax->GetXmin(),xax->GetXmax());
228 }
229
81b40753 230 if (fAll == 0x0)
231 {
232 TString numstr = fName + " All"; //title and name of the
233 //result histogram
234 TAxis* xax = fResult->GetXaxis();
235 fAll = new TH1D(numstr,numstr,xax->GetNbins(),xax->GetXmin(),xax->GetXmax());
236 }
becde6ce 237 fResult->Reset();
238 fResult->SetDirectory(0x0);
81b40753 239 fResult->Sumw2();
becde6ce 240 fWrong->Reset();
241 fWrong->SetDirectory(0x0);
81b40753 242 fWrong->Sumw2();
243 fAll->Reset();
244 fAll->SetDirectory(0x0);
245 fAll->Sumw2();
246
becde6ce 247 if (AliHBTParticle::GetDebug()>0) Info("Init","%s Done.",GetName());
248}
249
250/******************************************************************/
251
252void AliHBTMonPIDContaminationVsPtFctn::Rename(const Char_t * name)
253{
254 //Rename fuctions and all histograms belonging to it
255 SetName(name);
256 SetTitle(name);
257
258 if (fResult)
259 {
260 TString numstr = fName + " Result"; //title and name of the result histogram
261 fResult->SetName(numstr);
262 fResult->SetTitle(numstr);
263 }
264 if (fWrong)
265 {
266 TString numstr = fName + " Wrong";
267 fWrong->SetName(numstr);
268 fWrong->SetTitle(numstr);
269 }
81b40753 270
271 if (fAll)
272 {
273 TString numstrn = fName + " All"; //name of the All histogram
274 TString numstrt = fTitle + " All"; //title of the All histogram
275 fAll->SetName(numstrn);
276 fAll->SetTitle(numstrt);
277 }
becde6ce 278}
279/******************************************************************/
280
281void AliHBTMonPIDContaminationVsPtFctn::Rename(const Char_t * name, const Char_t * title)
282{
283 //renames and retitle the function and histograms
284
285 SetName(name);
286 SetTitle(title);
287
288 if (fResult)
289 {
290 TString numstrn = fName + " Result"; //name of the result histogram
291 TString numstrt = fTitle + " Result"; //title of the result histogram
292 fResult->SetName(numstrn);
293 fResult->SetTitle(numstrt);
294 }
295 if (fWrong)
296 {
297 TString numstrn = fName + " Wrong"; //name of the Wrong histogram
298 TString numstrt = fTitle + " Wrong"; //title of the Wrong histogram
299 fWrong->SetName(numstrn);
300 fWrong->SetTitle(numstrt);
301 }
81b40753 302
303 if (fAll)
304 {
305 TString numstr = fName + " All";
306 fAll->SetName(numstr);
307 fAll->SetTitle(numstr);
308 }
309
becde6ce 310}
311/******************************************************************/
312
313TH1* AliHBTMonPIDContaminationVsPtFctn::GetResult()
314{
315 //Returns the result of the fuction
316 //that is histogram with effciency and contamination
317
81b40753 318 fResult->Divide(fWrong,fAll);
becde6ce 319 return fResult;
320}
321/******************************************************************/
322
323void AliHBTMonPIDContaminationVsPtFctn::Process(AliHBTParticle * track, AliHBTParticle * part)
324{
325 //process the particle/track
326 Double_t pt = part->Pt();
81b40753 327 fAll->Fill(pt);
becde6ce 328
329 if (track->GetPdgCode() != part->GetPdgCode())
330 {
331// Info("Process","Catched contamination");
332// track->Print();part->Print();
333 fWrong->Fill(pt);
334 }
335}
336
337/******************************************************************/
338ClassImp(AliHBTPairPIDProbVsQInvFctn)
339
340AliHBTPairPIDProbVsQInvFctn::AliHBTPairPIDProbVsQInvFctn(Int_t nbins, Double_t maxXval, Double_t minXval):
341 AliHBTOnePairFctn1D(nbins,maxXval,minXval)
342{
343 fWriteNumAndDen = kTRUE;//change default behaviour
344 Rename("qinvpidpur","Q_{inv} Function");
345}
346/******************************************************************/
347
348TH1* AliHBTPairPIDProbVsQInvFctn::GetResult()
349{
350 //returns the scaled ratio
351 delete fRatio;
352 fRatio = GetRatio(Scale());
353 return fRatio;
354}
355/******************************************************************/
356
357void AliHBTPairPIDProbVsQInvFctn::ProcessSameEventParticles(AliHBTPair* pair)
358{
359 //Fills the numerator using pair from the same event
360 pair = CheckPair(pair);
361 if(pair) fNumerator->Fill(pair->GetQInv(),pair->GetPIDProb());
362}
363/******************************************************************/
364
365void AliHBTPairPIDProbVsQInvFctn::ProcessDiffEventParticles(AliHBTPair* pair)
366 {
367 //Fills the denumerator using mixed pairs
368 pair = CheckPair(pair);
369 if(pair) fDenominator->Fill(pair->GetQInv(),pair->GetPIDProb());
370 }
371
372
373ClassImp(AliHBTPairPIDProbVsQOutSQideQLongFctn)
374
375AliHBTPairPIDProbVsQOutSQideQLongFctn::AliHBTPairPIDProbVsQOutSQideQLongFctn(Int_t nXbins, Double_t maxXval, Double_t minXval,
376 Int_t nYbins, Double_t maxYval, Double_t minYval,
377 Int_t nZbins, Double_t maxZval, Double_t minZval):
378 AliHBTOnePairFctn3D(nXbins,maxXval,minXval,nYbins,maxYval,minYval,nZbins,maxZval,minZval)
379{
380 //ctor
381 fWriteNumAndDen = kTRUE;//change default behaviour
382 Rename("qoslpidpur","Pair PID Probablilty .vs. Q_{out}-Q_{side}-Q_{long} Fctn");
383}
384/*************************************************************/
385
386void AliHBTPairPIDProbVsQOutSQideQLongFctn::ProcessSameEventParticles(AliHBTPair* pair)
387{
388//Fills numerator
389 pair = CheckPair(pair);
390 if (pair == 0x0) return;
391 Double_t weight = pair->GetPIDProb();
392 Double_t out = TMath::Abs(pair->GetQOutCMSLC());
393 Double_t side = TMath::Abs(pair->GetQSideCMSLC());
394 Double_t lon = TMath::Abs(pair->GetQLongCMSLC());
395 fNumerator->Fill(out,side,lon,weight);
396}
397/*************************************************************/
398
399void AliHBTPairPIDProbVsQOutSQideQLongFctn::ProcessDiffEventParticles(AliHBTPair* pair)
400{
401//Fills numerator
402 pair = CheckPair(pair);
403 if (pair == 0x0) return;
404 Double_t weight = pair->GetPIDProb();
405 Double_t out = TMath::Abs(pair->GetQOutCMSLC());
406 Double_t side = TMath::Abs(pair->GetQSideCMSLC());
407 Double_t lon = TMath::Abs(pair->GetQLongCMSLC());
408 fDenominator->Fill(out,side,lon,weight);
409}
410/*************************************************************/
411
412TH1* AliHBTPairPIDProbVsQOutSQideQLongFctn::GetResult()
413{
414 //returns the scaled ratio
415 delete fRatio;
416 fRatio = GetRatio(Scale());
417 return fRatio;
418}