de77f93acd1a746b0a067181fb79053a78b41d40
[u/mrichter/AliRoot.git] / HBTAN / AliHBTWeightasCorrFctn.cxx
1 #include "AliHBTWeightasCorrFctn.h"
2 #include <TH1.h>
3 #include <Riostream.h>
4
5 ///////////////////////////////////////////////////////
6 //                                                   //
7 // AliHBTWeightasCorrFctn.h                             //
8 //                                                   //
9 // Class for calculating 3D Weightas correlation        //
10 // functions                                         //
11 //                                                   //
12 ///////////////////////////////////////////////////////
13
14 ClassImp(AliHBTWeightasCorrFctn)
15
16      AliHBTWeightasCorrFctn::AliHBTWeightasCorrFctn(const char* name, const char* title):
17  AliHBTTwoPairFctn1D(name,title),
18
19      fNum(0x0),
20      fDen(0x0),
21      fRat(0x0)
22
23 {
24 //ctor
25 }
26      
27 /******************************************************************/
28 AliHBTWeightasCorrFctn::AliHBTWeightasCorrFctn(const char* name, const char* title, Int_t nbins, Float_t maxXval, Float_t minXval):
29  AliHBTTwoPairFctn1D(name,title,nbins,maxXval,minXval),
30
31
32      fNum(new TObjArray()),
33      fDen(new TObjArray()),
34      fRat(new TObjArray())
35 {
36      SetParams(nbins,maxXval, minXval);
37 }
38
39 /******************************************************************/
40 AliHBTWeightasCorrFctn::AliHBTWeightasCorrFctn(const AliHBTWeightasCorrFctn& in):
41  AliHBTTwoPairFctn1D(in),
42
43
44
45      fNum((in.fNum)?(TObjArray*)in.fNum->Clone():0x0),
46      fDen((in.fDen)?(TObjArray*)in.fDen->Clone():0x0),
47      fRat((in.fRat)?(TObjArray*)in.fRat->Clone():0x0)
48  {
49 //ctor
50 }
51
52 /******************************************************************/
53
54 AliHBTWeightasCorrFctn::~AliHBTWeightasCorrFctn()
55 {
56  //dtor
57
58      delete fNum;
59      delete fDen;
60      delete fRat;
61      
62 }
63
64 /******************************************************************/
65 void AliHBTWeightasCorrFctn::Write()
66 {
67 //out    
68      Int_t i;
69 //     Int_t n=GetNumberOfIntervals();
70      Double_t scale;
71
72      for(i=0;i<fNumberOfIntervals;i++){
73           TH1D *num = ((TH1D*)fNum->At(i));
74           TH1D *den = ((TH1D*)fDen->At(i));
75           TH1D &rat = *((TH1D*)fRat->At(i));
76           scale = Scale(num,den);
77           Info("Write():","Scale in interval %d = %lf",i,scale);
78           rat.Divide(num,den,scale);
79           
80           
81           num->Write();
82           den->Write();
83           rat.Write();
84      }
85
86 }
87
88 //-------------------------------------
89 void AliHBTWeightasCorrFctn::ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
90 {
91     //Fills the numerator using pair from the same event
92      trackpair = CheckPair(trackpair);
93      if(partpair == 0x0) return;
94      if(trackpair == 0x0) return;
95      
96      Double_t weight = 1.0;
97
98      int n = fNumberOfIntervals;
99      Double_t rplane=0.;   //reaction plane angle - 2 B determined
100      Double_t phi=(trackpair->Particle1()->Phi()+trackpair->Particle2()->Phi())/2.-rplane; //deltaphi bo nie mam nic innego pod reka
101
102      phi=phi*360/(2*TMath::Pi());
103      Double_t q=GetValue(trackpair, partpair);
104      Int_t ntv;
105      ntv =  (int)(phi*n/(360.));
106      
107      TH1D *num = ((TH1D*)fNum->At(ntv));
108      
109         
110      if ( trackpair && partpair)
111      {
112           if ( ( trackpair->Particle1()->GetPdgCode() == partpair->Particle1()->GetPdgCode()) &&
113                ( trackpair->Particle2()->GetPdgCode() == partpair->Particle2()->GetPdgCode())    )
114           {
115                weight=partpair->GetWeight();
116 //             Info("ProcessSameEvent","weight=%lf",weight);
117           }
118           num->Fill(q,weight);
119      }
120 }
121
122 /****************************************************************/
123 void AliHBTWeightasCorrFctn::Init()
124 {
125      BuildHistos();
126 }
127 /****************************************************************/
128
129
130 void AliHBTWeightasCorrFctn::ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
131 {
132      
133      Double_t rplane=0.;   //reaction plane angle - 2 B determined
134      Double_t phi=(trackpair->Particle1()->Phi()+trackpair->Particle2()->Phi())/2.-rplane; //deltaphi bo nie mam nic innego pod reka
135      phi=phi*360/(2*TMath::Pi());
136      Double_t qout=GetValue(trackpair, partpair);
137
138      int n = fNumberOfIntervals;
139      
140      Int_t ntv;
141      ntv =  (int)(phi*n/(360.));
142
143      TH1D &den = *((TH1D*)fDen->At(ntv));
144      if ( trackpair && partpair)
145      {
146           den.Fill(qout);
147      }
148 }
149
150
151 /******************************************************************/
152
153
154 void AliHBTWeightasCorrFctn::SetParams(Int_t nbins, Float_t maxXval, Float_t minXval){
155      fnbins=nbins;
156      fmaxXval= maxXval;
157      fminXval=minXval;
158 }
159 TH1* AliHBTWeightasCorrFctn::GetResult()
160 {
161        
162      TH1D *den = ((TH1D*)fDen->UncheckedAt(1));
163      return den;
164  }
165
166
167
168
169 ClassImp(AliHBTQOutWeightasCorrFctn)
170      
171      AliHBTQOutWeightasCorrFctn::AliHBTQOutWeightasCorrFctn(const char* name, const char* title, Int_t nbins, Float_t maxXval, Float_t minXval):
172 AliHBTWeightasCorrFctn(name,title,nbins,maxXval,minXval)
173
174 {
175 //ct0r
176 }
177
178 void AliHBTQOutWeightasCorrFctn::BuildHistos()
179 {
180     
181      Int_t i;
182      int n=GetNumberOfIntervals();
183
184      int nbins=Getnbins();
185
186      double max = GetmaxXval();
187      double min = GetminXval();
188      char buff[10];
189      
190
191      
192      TH1D *Num;
193      TH1D *Den;
194      TH1D *Rat;
195      
196      TString nameNum = "NumOut";
197      TString nameDen = "DenOut";
198      TString nameRat = "RatOut";
199      
200      for(i=0;i<n;i++){
201           
202           sprintf(buff,"%d",i);
203
204           nameNum +=TString(buff);
205
206           nameDen +=TString(buff);
207           nameRat +=TString(buff);
208           
209           
210           Num = new TH1D(nameNum.Data(),nameNum.Data(),nbins,min,max);
211           Den = new TH1D(nameDen.Data(),nameDen.Data(),nbins,min,max);
212           Rat = new TH1D(nameRat.Data(),nameRat.Data(),nbins,min,max);
213           
214           Num->Sumw2();
215           Den->Sumw2();
216           Rat->Sumw2();
217           
218           Num->Reset();
219           Den->Reset();
220           Rat->Reset();
221           
222           fNum->Add(Num);
223           fDen->Add(Den);
224           fRat->Add(Rat);
225           
226           nameNum = TString("NumOut");
227           nameDen = TString("DenOut");
228           nameRat = TString("RatOut");
229           
230      }
231
232      
233  }
234
235 ClassImp(AliHBTQSideWeightasCorrFctn)
236      
237      AliHBTQSideWeightasCorrFctn::AliHBTQSideWeightasCorrFctn(const char* name, const char* title, Int_t nbins, Float_t maxXval, Float_t minXval):
238 AliHBTWeightasCorrFctn(name,title,nbins,maxXval,minXval)
239
240 {
241 //ct0r
242 }
243
244 void AliHBTQSideWeightasCorrFctn::BuildHistos()
245 {
246     
247      Int_t i;
248      int n=GetNumberOfIntervals();
249      int nbins=Getnbins();
250
251      double max = GetmaxXval();
252      double min = GetminXval();
253      char buff[10];
254      
255
256      
257      TH1D *Num;
258      TH1D *Den;
259      TH1D *Rat;
260      
261      TString nameNum = "NumSide";
262      TString nameDen = "DenSide";
263      TString nameRat = "RatSide";
264      
265      for(i=0;i<n;i++){
266           
267           sprintf(buff,"%d",i);
268
269           nameNum +=TString(buff);
270
271           nameDen +=TString(buff);
272           nameRat +=TString(buff);
273           
274           
275           Num = new TH1D(nameNum.Data(),nameNum.Data(),nbins,min,max);
276           Den = new TH1D(nameDen.Data(),nameDen.Data(),nbins,min,max);
277           Rat = new TH1D(nameRat.Data(),nameRat.Data(),nbins,min,max);
278           
279           Num->Sumw2();
280           Den->Sumw2();
281           Rat->Sumw2();
282           
283           Num->Reset();
284           Den->Reset();
285           Rat->Reset();
286           
287           fNum->Add(Num);
288           fDen->Add(Den);
289           fRat->Add(Rat);
290           
291           nameNum = TString("NumSide");
292           nameDen = TString("DenSide");
293           nameRat = TString("RatSide");
294           
295      }
296
297      
298  }
299
300 ClassImp(AliHBTQLongWeightasCorrFctn)
301      
302      AliHBTQLongWeightasCorrFctn::AliHBTQLongWeightasCorrFctn(const char* name, const char* title, Int_t nbins, Float_t maxXval, Float_t minXval):
303 AliHBTWeightasCorrFctn(name,title,nbins,maxXval,minXval)
304
305 {
306 //ct0r
307 }
308
309 void AliHBTQLongWeightasCorrFctn::BuildHistos()
310 {
311     
312      Int_t i;
313      int n=GetNumberOfIntervals();
314      int nbins=Getnbins();
315
316      double max = GetmaxXval();
317      double min = GetminXval();
318      char buff[10];
319      
320
321      
322      TH1D *Num;
323      TH1D *Den;
324      TH1D *Rat;
325      
326      TString nameNum = "NumLong";
327      TString nameDen = "DenLong";
328      TString nameRat = "RatLong";
329      
330      for(i=0;i<n;i++){
331           
332           sprintf(buff,"%d",i);
333
334           nameNum +=TString(buff);
335
336           nameDen +=TString(buff);
337           nameRat +=TString(buff);
338           
339           
340           Num = new TH1D(nameNum.Data(),nameNum.Data(),nbins,min,max);
341           Den = new TH1D(nameDen.Data(),nameDen.Data(),nbins,min,max);
342           Rat = new TH1D(nameRat.Data(),nameRat.Data(),nbins,min,max);
343           
344           Num->Sumw2();
345           Den->Sumw2();
346           Rat->Sumw2();
347           
348           Num->Reset();
349           Den->Reset();
350           Rat->Reset();
351           
352           fNum->Add(Num);
353           fDen->Add(Den);
354           fRat->Add(Rat);
355           
356           nameNum = TString("NumLong");
357           nameDen = TString("DenLong");
358           nameRat = TString("RatLong");
359           
360      }
361
362      
363  }