Updated to the new way AOD stores particles
[u/mrichter/AliRoot.git] / HBTAN / AliHBTWeightNonId3DCorrFctn.cxx
1 #include "AliHBTWeightNonId3DCorrFctn.h"
2 #include <TH1.h>
3 #include <Riostream.h>
4
5 ///////////////////////////////////////////////////////
6 //                                                   //
7 // AliHBTWeightNonId3DCorrFctn.h                     //
8 //                                                   //
9 // Class for calculating 3D non-id correlation       //
10 // functions using methods of weights                //
11 //                                                   //
12 ///////////////////////////////////////////////////////
13
14 ClassImp(AliHBTWeightNonId3DCorrFctn)
15
16 AliHBTWeightNonId3DCorrFctn::AliHBTWeightNonId3DCorrFctn(const char* name, const char* title):
17  AliHBTTwoPairFctn1D(name,title),
18  fWeightNumOutP(0x0),
19  fWeightDenOutP(0x0),
20  fWeightRatOutP(0x0),
21  fWeightNumOutN(0x0),
22  fWeightDenOutN(0x0),
23  fWeightRatOutN(0x0),
24  fWeightRatOut(0x0),
25  fWeightRatOutNOverP(0x0),
26  fWeightNumSideP(0x0),
27  fWeightDenSideP(0x0),
28  fWeightRatSideP(0x0),
29  fWeightNumSideN(0x0),
30  fWeightDenSideN(0x0),
31  fWeightRatSideN(0x0),
32  fWeightRatSide(0x0),
33  fWeightRatSideNOverP(0x0),
34  fWeightNumLongP(0x0),
35  fWeightDenLongP(0x0),
36  fWeightRatLongP(0x0),
37  fWeightNumLongN(0x0),
38  fWeightDenLongN(0x0),
39  fWeightRatLongN(0x0),
40  fWeightRatLong(0x0),
41  fWeightRatLongNOverP(0x0)
42 {
43 //ctor
44 }
45 /******************************************************************/
46 AliHBTWeightNonId3DCorrFctn::AliHBTWeightNonId3DCorrFctn(const char* name, const char* title, 
47                                                          Int_t nbinsX, Float_t maxXval, Float_t minXval):   
48  AliHBTTwoPairFctn1D(name,title,nbinsX,maxXval,minXval),
49  fWeightNumOutP(0x0),
50  fWeightDenOutP(0x0),
51  fWeightRatOutP(0x0),
52  fWeightNumOutN(0x0),
53  fWeightDenOutN(0x0),
54  fWeightRatOutN(0x0),
55  fWeightRatOut(0x0),
56  fWeightRatOutNOverP(0x0),
57  fWeightNumSideP(0x0),
58  fWeightDenSideP(0x0),
59  fWeightRatSideP(0x0),
60  fWeightNumSideN(0x0),
61  fWeightDenSideN(0x0),
62  fWeightRatSideN(0x0),
63  fWeightRatSide(0x0),
64  fWeightRatSideNOverP(0x0),
65  fWeightNumLongP(0x0),
66  fWeightDenLongP(0x0),
67  fWeightRatLongP(0x0),
68  fWeightNumLongN(0x0),
69  fWeightDenLongN(0x0),
70  fWeightRatLongN(0x0),
71  fWeightRatLong(0x0),
72  fWeightRatLongNOverP(0x0)
73 {
74 //ctor
75 }
76
77 /******************************************************************/
78 AliHBTWeightNonId3DCorrFctn::AliHBTWeightNonId3DCorrFctn(const AliHBTWeightNonId3DCorrFctn& in):
79  AliHBTTwoPairFctn1D(in),
80  fWeightNumOutP(0x0),
81  fWeightDenOutP(0x0),
82  fWeightRatOutP(0x0),
83  fWeightNumOutN(0x0),
84  fWeightDenOutN(0x0),
85  fWeightRatOutN(0x0),
86  fWeightRatOut(0x0),
87  fWeightRatOutNOverP(0x0),
88  fWeightNumSideP(0x0),
89  fWeightDenSideP(0x0),
90  fWeightRatSideP(0x0),
91  fWeightNumSideN(0x0),
92  fWeightDenSideN(0x0),
93  fWeightRatSideN(0x0),
94  fWeightRatSide(0x0),
95  fWeightRatSideNOverP(0x0),
96  fWeightNumLongP(0x0),
97  fWeightDenLongP(0x0),
98  fWeightRatLongP(0x0),
99  fWeightNumLongN(0x0),
100  fWeightDenLongN(0x0),
101  fWeightRatLongN(0x0),
102  fWeightRatLong(0x0),
103  fWeightRatLongNOverP(0x0)
104 {
105 //ctor
106 }
107
108 /******************************************************************/
109
110 AliHBTWeightNonId3DCorrFctn::~AliHBTWeightNonId3DCorrFctn()
111 {
112  //dtor
113  delete fWeightNumOutP;
114  delete fWeightDenOutP;
115  delete fWeightRatOutP;
116  delete fWeightNumOutN;
117  delete fWeightDenOutN;
118  delete fWeightRatOutN;
119  delete fWeightRatOut;
120  delete fWeightRatOutNOverP;
121  delete fWeightNumSideP;
122  delete fWeightDenSideP;
123  delete fWeightRatSideP;
124  delete fWeightNumSideN;
125  delete fWeightDenSideN;
126  delete fWeightRatSideN;
127  delete fWeightRatSide;
128  delete fWeightRatSideNOverP;
129  delete fWeightNumLongP;
130  delete fWeightDenLongP;
131  delete fWeightRatLongP;
132  delete fWeightNumLongN;
133  delete fWeightDenLongN;
134  delete fWeightRatLongN;
135  delete fWeightRatLong;
136  delete fWeightRatLongNOverP;
137  
138 }
139
140 //-------------------------------------
141 void AliHBTWeightNonId3DCorrFctn::ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
142 {
143     //Fills the numerator using pair from the same event
144     partpair = CheckPair(partpair);
145     trackpair = CheckPair(trackpair);
146     if(partpair == 0x0) return;
147     if(trackpair == 0x0) return;
148  
149     double tKStar = TMath::Abs(trackpair->GetKStar());
150     double tKStarOut = trackpair->GetKStarOut();
151     double tKStarSide = trackpair->GetKStarSide();
152     double tKStarLong = trackpair->GetKStarLong();
153
154     Double_t weight = 1.0;
155     
156   if ( trackpair && partpair)
157   {
158     if ( ( trackpair->Particle1()->GetPdgCode() == partpair->Particle1()->GetPdgCode()) &&
159          ( trackpair->Particle2()->GetPdgCode() == partpair->Particle2()->GetPdgCode())    )
160     {
161         weight=partpair->GetWeight();
162     }
163     
164     if(tKStarOut>0.)
165     {
166         fWeightNumOutP->Fill(tKStar,weight);
167     }
168     else
169     {
170         fWeightNumOutN->Fill(tKStar,weight);
171     }
172
173     if(tKStarSide>0.)
174     {
175         fWeightNumSideP->Fill(tKStar,weight);
176     }
177     else
178     {
179         fWeightNumSideN->Fill(tKStar,weight);
180     }
181
182     if(tKStarLong>0.)
183     {
184         fWeightNumLongP->Fill(tKStar,weight);
185     }
186     else
187     {
188         fWeightNumLongN->Fill(tKStar,weight);
189     }
190   }
191   
192 }
193
194 /****************************************************************/
195
196
197 void AliHBTWeightNonId3DCorrFctn::ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
198 {
199
200   trackpair = CheckPair(trackpair);
201   partpair  = CheckPair(partpair);
202
203   double tKStar = TMath::Abs(partpair->GetKStar());
204   double tKStarOut = trackpair->GetKStarOut();
205   double tKStarSide = trackpair->GetKStarSide();
206   double tKStarLong = trackpair->GetKStarLong();
207
208   if ( trackpair && partpair)
209   {
210     if(tKStarOut>0.)
211     {
212         fWeightDenOutP->Fill(tKStar);
213     }
214     else
215     {
216         fWeightDenOutN->Fill(tKStar);
217     }
218
219     if(tKStarSide>0.)
220     {
221         fWeightDenSideP->Fill(tKStar);
222     }
223     else
224     {
225         fWeightDenSideN->Fill(tKStar);
226     }
227
228     if(tKStarLong>0.)
229     {
230         fWeightDenLongP->Fill(tKStar);
231     }
232     else
233     {
234         fWeightDenLongN->Fill(tKStar);
235     }
236   }
237   
238 }
239
240
241 /****************************************************************/
242 void AliHBTWeightNonId3DCorrFctn::Init()
243 {
244     AliHBTTwoPairFctn1D::Init();
245  fWeightNumOutP->Reset();
246  fWeightDenOutP->Reset();
247  fWeightRatOutP->Reset();
248  fWeightNumOutN->Reset();
249  fWeightDenOutN->Reset();
250  fWeightRatOutN->Reset();
251  fWeightRatOut->Reset();
252  fWeightRatOutNOverP->Reset();
253
254  fWeightNumSideP->Reset();
255  fWeightDenSideP->Reset();
256  fWeightRatSideP->Reset();
257  fWeightNumSideN->Reset();
258  fWeightDenSideN->Reset();
259  fWeightRatSideN->Reset();
260  fWeightRatSide->Reset();
261  fWeightRatSideNOverP->Reset();
262
263  fWeightNumLongP->Reset();
264  fWeightDenLongP->Reset();
265  fWeightRatLongP->Reset();
266  fWeightNumLongN->Reset();
267  fWeightDenLongN->Reset();
268  fWeightRatLongN->Reset();
269  fWeightRatLong->Reset();
270  fWeightRatLongNOverP->Reset();
271 }
272 /******************************************************************/
273
274 void AliHBTWeightNonId3DCorrFctn::BuildHistos(Int_t nbins, Float_t max, Float_t min)
275 {
276     
277     AliHBTFunction1D::BuildHistos(nbins,max,min);
278     
279     TString nameNumOutP = "WeightNumOutP";
280     TString nameDenOutP = "WeightDenOutP";
281     TString nameRatOutP = "WeightRatOutP";
282     TString nameNumOutN = "WeightNumOutN";
283     TString nameDenOutN = "WeightDenOutN";
284     TString nameRatOutN = "WeightRatOutN";
285     TString nameRatOut =  "WeightRatOut";
286     TString nameRatOutNOverP = "WeightRatOutNOverP";
287     TString nameNumSideP = "WeightNumSideP";
288     TString nameDenSideP = "WeightDenSideP";
289     TString nameRatSideP = "WeightRatSideP";
290     TString nameNumSideN = "WeightNumSideN";
291     TString nameDenSideN = "WeightDenSideN";
292     TString nameRatSideN = "WeightRatSideN";
293     TString nameRatSide = "WeightRatSide";
294     TString nameRatSideNOverP = "WeightRatSideNOverP";
295     TString nameNumLongP = "WeightNumLongP";
296     TString nameDenLongP = "WeightDenLongP";
297     TString nameRatLongP = "WeightRatLongP";
298     TString nameNumLongN = "WeightNumLongN";
299     TString nameDenLongN = "WeightDenLongN";
300     TString nameRatLongN = "WeightRatLongN";
301     TString nameRatLong = "WeightRatLong";
302     TString nameRatLongNOverP = "WeightRatLongNOverP";
303
304     fWeightNumOutP = new TH1D(nameNumOutP.Data(),nameNumOutP.Data(),nbins,min,max);
305     fWeightDenOutP = new TH1D(nameDenOutP.Data(),nameDenOutP.Data(),nbins,min,max);
306     fWeightRatOutP = new TH1D(nameRatOutP.Data(),nameRatOutP.Data(),nbins,min,max);
307
308     fWeightNumOutN = new TH1D(nameNumOutN.Data(),nameNumOutN.Data(),nbins,min,max);
309     fWeightDenOutN = new TH1D(nameDenOutN.Data(),nameDenOutN.Data(),nbins,min,max);
310     fWeightRatOutN = new TH1D(nameRatOutN.Data(),nameRatOutN.Data(),nbins,min,max);
311
312     fWeightRatOut = new TH1D(nameRatOut.Data(),nameRatOut.Data(),nbins,min,max);
313     fWeightRatOutNOverP = new TH1D(nameRatOutNOverP.Data(),nameRatOutNOverP.Data(),nbins,min,max);
314
315     fWeightNumSideP = new TH1D(nameNumSideP.Data(),nameNumSideP.Data(),nbins,min,max);
316     fWeightDenSideP = new TH1D(nameDenSideP.Data(),nameDenSideP.Data(),nbins,min,max);
317     fWeightRatSideP = new TH1D(nameRatSideP.Data(),nameRatSideP.Data(),nbins,min,max);
318
319     fWeightNumSideN = new TH1D(nameNumSideN.Data(),nameNumSideN.Data(),nbins,min,max);
320     fWeightDenSideN = new TH1D(nameDenSideN.Data(),nameDenSideN.Data(),nbins,min,max);
321     fWeightRatSideN = new TH1D(nameRatSideN.Data(),nameRatSideN.Data(),nbins,min,max);
322
323     fWeightRatSide = new TH1D(nameRatSide.Data(),nameRatSide.Data(),nbins,min,max);
324     fWeightRatSideNOverP = new TH1D(nameRatSideNOverP.Data(),nameRatSideNOverP.Data(),nbins,min,max);
325
326     fWeightNumLongP = new TH1D(nameNumLongP.Data(),nameNumLongP.Data(),nbins,min,max);
327     fWeightDenLongP = new TH1D(nameDenLongP.Data(),nameDenLongP.Data(),nbins,min,max);
328     fWeightRatLongP = new TH1D(nameRatLongP.Data(),nameRatLongP.Data(),nbins,min,max);
329
330     fWeightNumLongN = new TH1D(nameNumLongN.Data(),nameNumLongN.Data(),nbins,min,max);
331     fWeightDenLongN = new TH1D(nameDenLongN.Data(),nameDenLongN.Data(),nbins,min,max);
332     fWeightRatLongN = new TH1D(nameRatLongN.Data(),nameRatLongN.Data(),nbins,min,max);
333
334     fWeightRatLong = new TH1D(nameRatLong.Data(),nameRatLong.Data(),nbins,min,max);
335     fWeightRatLongNOverP = new TH1D(nameRatLongNOverP.Data(),nameRatLongNOverP.Data(),nbins,min,max);
336
337
338     fWeightNumOutP->Sumw2();
339     fWeightDenOutP->Sumw2();
340     fWeightRatOutP->Sumw2();
341     fWeightNumOutN->Sumw2();
342     fWeightDenOutN->Sumw2();
343     fWeightRatOutN->Sumw2();
344     fWeightRatOut->Sumw2();
345     fWeightRatOutNOverP->Sumw2();
346     fWeightNumSideP->Sumw2();
347     fWeightDenSideP->Sumw2();
348     fWeightRatSideP->Sumw2();
349     fWeightNumSideN->Sumw2();
350     fWeightDenSideN->Sumw2();
351     fWeightRatSideN->Sumw2();
352     fWeightRatSide->Sumw2();
353     fWeightRatSideNOverP->Sumw2();
354     fWeightNumLongP->Sumw2();
355     fWeightDenLongP->Sumw2();
356     fWeightRatLongP->Sumw2();
357     fWeightNumLongN->Sumw2();
358     fWeightDenLongN->Sumw2();
359     fWeightRatLongN->Sumw2();
360     fWeightRatLong->Sumw2();
361     fWeightRatLongNOverP->Sumw2();
362 }
363
364 /******************************************************************/
365
366 TH1* AliHBTWeightNonId3DCorrFctn::GetResult()
367 {
368     return fWeightRatOutN;
369 }
370
371 /******************************************************************/
372
373 void AliHBTWeightNonId3DCorrFctn::WriteFunction()
374 {
375
376  Double_t outPscale = Scale(fWeightNumOutP,fWeightDenOutP);
377  cout<<"WoutPscale = "<<outPscale<<endl;
378  fWeightRatOutP->Divide(fWeightNumOutP,fWeightDenOutP,outPscale);
379
380  Double_t outNscale = Scale(fWeightNumOutN,fWeightDenOutN);
381  cout<<"WoutNscale = "<<outNscale<<endl;
382  fWeightRatOutN->Divide(fWeightNumOutN,fWeightDenOutN,outNscale);
383
384  fWeightRatOutNOverP->Divide(fWeightRatOutN,fWeightRatOutP);
385
386
387  Double_t sidePscale = Scale(fWeightNumSideP,fWeightDenSideP);
388  fWeightRatSideP->Divide(fWeightNumSideP,fWeightDenSideP,sidePscale);
389
390  Double_t sideNscale = Scale(fWeightNumSideN,fWeightDenSideN);
391  fWeightRatSideN->Divide(fWeightNumSideN,fWeightDenSideN,sideNscale);
392
393  fWeightRatSideNOverP->Divide(fWeightRatSideN,fWeightRatSideP);
394
395
396  Double_t longPscale = Scale(fWeightNumLongP,fWeightDenLongP);
397  fWeightRatLongP->Divide(fWeightNumLongP,fWeightDenLongP,longPscale);
398
399  Double_t longNscale = Scale(fWeightNumLongN,fWeightDenLongN);
400  fWeightRatLongN->Divide(fWeightNumLongN,fWeightDenLongN,longNscale);
401
402  fWeightRatLongNOverP->Divide(fWeightRatLongN,fWeightRatLongP);
403
404  fWeightNumOutP->Write();
405  fWeightDenOutP->Write();
406  fWeightRatOutP->Write();
407  fWeightNumOutN->Write();
408  fWeightDenOutN->Write();
409  fWeightRatOutN->Write();
410  fWeightRatOut->Write();
411  fWeightRatOutNOverP->Write();
412
413  fWeightNumSideP->Write();
414  fWeightDenSideP->Write();
415  fWeightRatSideP->Write();
416  fWeightNumSideN->Write();
417  fWeightDenSideN->Write();
418  fWeightRatSideN->Write();
419  fWeightRatSide->Write();
420  fWeightRatSideNOverP->Write();
421
422  fWeightNumLongP->Write();
423  fWeightDenLongP->Write();
424  fWeightRatLongP->Write();
425  fWeightNumLongN->Write();
426  fWeightDenLongN->Write();
427  fWeightRatLongN->Write();
428  fWeightRatLong->Write();
429  fWeightRatLongNOverP->Write();
430
431 }
432