new ctors
[u/mrichter/AliRoot.git] / HBTAN / AliHBTFunction.cxx
CommitLineData
1b446896 1#include "AliHBTFunction.h"
2/******************************************************************/
3/*
4Piotr Krzysztof Skowronski
5Piotr.Skowronski@cern.ch
6Base classes for HBT functions
7
8 function
9 / \
10 / \
11 / \
12 / \
13 / \
14 / \
15 / \
27b3fe5d 16 one pair two pair
1b446896 17 / | \ / | \
18 / | \ / | \
19 1D 2D 3D 1D 2D 3D
20
21 four particle functions are intendent to be resolution functions:
22 it is mecessary to have simulated particle pair corresponding to given
23 recontructed track pair in order to calculate function simualted value
24 and recontructed value to be further histogrammed
25
26*/
27/******************************************************************/
28/******************************************************************/
29
976183fd 30#include <iostream.h>
1b446896 31ClassImp( AliHBTFunction )
32
33AliHBTFunction::AliHBTFunction()
34{
ba95ae3f 35 fPairCut = new AliHBTEmptyPairCut(); //dummy cut
36}
37/******************************************************************/
38AliHBTFunction::AliHBTFunction(const char* name,const char* title):TNamed(name,title)
39{
40 fPairCut = new AliHBTEmptyPairCut(); //dummy cut
1b446896 41}
2674b9ff 42/******************************************************************/
43
44AliHBTFunction::~AliHBTFunction()
45 {
46 if (fPairCut) delete fPairCut;
47 }
48/******************************************************************/
1b446896 49
50void AliHBTFunction::
51Write()
52 {
53 if (GetNumerator()) GetNumerator()->Write();
54 if (GetDenominator()) GetDenominator()->Write();
55 TH1* res = GetResult();
976183fd 56 if (res) res->Write();
1b446896 57 }
58/******************************************************************/
59
60TH1* AliHBTFunction::
61GetRatio(Double_t normfactor)
62 {
2674b9ff 63 if (gDebug>0) cout<<"Mormfactor is "<<normfactor<<" for "<<fName<<endl;
976183fd 64
65 if (normfactor == 0.0)
66 {
67 Error("GetRatio","Scaling Factor is 0. Null poiner returned");
68 return 0x0;
69 }
1b446896 70 TString str = fName + " ratio";
71 TH1 *result = (TH1*)GetNumerator()->Clone(str.Data());
72
73 result->SetTitle(str.Data());
976183fd 74 //result->Sumw2();
1b446896 75
76 result->Divide(GetNumerator(),GetDenominator(),normfactor);
77
78 return result;
79
80 }
81/******************************************************************/
82void AliHBTFunction::SetPairCut(AliHBTPairCut* cut)
83{
84//Sets new Pair Cut. Old one is deleted
85//Note that it is created new object instead of simple pointer set
86//I do not want to have pointer
87//to object created somewhere else
88//because in that case I could not believe that
89//it would always exist (sb could delete it)
90//so we have always own copy
91
92 if(!cut)
93 {
94 Error("AliHBTFunction::SetPairCut","argument is NULL");
95 return;
96 }
97 delete fPairCut;
98 fPairCut = (AliHBTPairCut*)cut->Clone();
99
100}
101
102/******************************************************************/
103
104void AliHBTFunction::
105Rename(const Char_t * name)
106 {
107 //renames the function and histograms
108 SetName(name);
109 SetTitle(name);
110
111 TString numstr = fName + " Numerator"; //title and name of the
112 //numerator histogram
113 TString denstr = fName + " Denominator";//title and name of the
114 //denominator histogram
115
116 GetNumerator()->SetName(numstr.Data());
117 GetNumerator()->SetTitle(numstr.Data());
118
119 GetDenominator()->SetName(denstr.Data());
120 GetDenominator()->SetTitle(denstr.Data());
121
122 }
123
124void AliHBTFunction::
125Rename(const Char_t * name, const Char_t * title)
126 {
127 //renames and retitle the function and histograms
128
129 SetName(name);
130 SetTitle(title);
131
132 TString numstrn = fName + " Numerator"; //name of the
133 //numerator histogram
134
135 TString numstrt = fTitle + " Numerator"; //title of the
136 //numerator histogram
137
138 TString denstrn = fName + " Denominator";//name of the
139 //denominator histogram
140
141 TString denstrt = fTitle + " Denominator";//title of the
142 //denominator histogram
143
144
145 GetNumerator()->SetName(numstrn.Data());
146 GetNumerator()->SetTitle(numstrt.Data());
147
148 GetDenominator()->SetName(denstrn.Data());
149 GetDenominator()->SetTitle(denstrt.Data());
150
151
152 }
153
154/******************************************************************/
155/******************************************************************/
156/******************************************************************/
157
27b3fe5d 158ClassImp( AliHBTOnePairFctn )
1b446896 159
160/******************************************************************/
161/******************************************************************/
162/******************************************************************/
163
27b3fe5d 164ClassImp( AliHBTTwoPairFctn)
1b446896 165
166/******************************************************************/
167/******************************************************************/
168/******************************************************************/
169
27b3fe5d 170ClassImp( AliHBTOnePairFctn1D )
ba95ae3f 171AliHBTOnePairFctn1D::AliHBTOnePairFctn1D():fNBinsToScale(30)
172 {
173 fNumerator = 0x0;
174 fDenominator = 0x0;
175 }
1b446896 176
27b3fe5d 177AliHBTOnePairFctn1D::
178AliHBTOnePairFctn1D(Int_t nbins, Double_t maxXval, Double_t minXval)
1b446896 179 {
180 //Constructor of Two Part One Dimentional Function
181 // nbins: number of bins in histograms - default 100
182 // maxXval and minXval: range of histgram(s) default 0 - 0.15 (GeV)
183
184
185 TString numstr = fName + " Numerator"; //title and name of the
186 //numerator histogram
187 TString denstr = fName + " Denominator";//title and name of the
188 //denominator histogram
189
190 fNumerator = new TH1D(numstr.Data(),numstr.Data(),nbins,minXval,maxXval);
191 fDenominator = new TH1D(denstr.Data(),denstr.Data(),nbins,minXval,maxXval);
192
193 fNumerator->Sumw2();
194 fDenominator->Sumw2();
195
976183fd 196 fNBinsToScale = 30;
197
1b446896 198 }
ba95ae3f 199AliHBTOnePairFctn1D::
200AliHBTOnePairFctn1D(const Char_t *name, const Char_t *title,
201 Int_t nbins, Double_t maxXval, Double_t minXval)
202 :AliHBTOnePairFctn(name,title)
203{
204 TString numstr = fName + " Numerator"; //title and name of the
205 //numerator histogram
206 TString denstr = fName + " Denominator";//title and name of the
207 //denominator histogram
208
209 fNumerator = new TH1D(numstr.Data(),numstr.Data(),nbins,minXval,maxXval);
210 fDenominator = new TH1D(denstr.Data(),denstr.Data(),nbins,minXval,maxXval);
211
212 fNumerator->Sumw2();
213 fDenominator->Sumw2();
214
215 fNBinsToScale = 30;
216}
1b446896 217/******************************************************************/
27b3fe5d 218AliHBTOnePairFctn1D::~AliHBTOnePairFctn1D()
1b446896 219{
220 delete fNumerator;
221 delete fDenominator;
222}
223/******************************************************************/
976183fd 224
27b3fe5d 225void AliHBTOnePairFctn1D::ProcessSameEventParticles(AliHBTPair* pair)
976183fd 226{
227 //Fills the numerator
228 pair = CheckPair(pair);
229 if(pair) fNumerator->Fill(GetValue(pair));
230}
231/******************************************************************/
27b3fe5d 232void AliHBTOnePairFctn1D::ProcessDiffEventParticles(AliHBTPair* pair)
976183fd 233 {
234 //fills denumerator
235 pair = CheckPair(pair);
236 if(pair) fDenominator->Fill(GetValue(pair));
237
238 }
239/******************************************************************/
27b3fe5d 240Double_t AliHBTOnePairFctn1D::Scale()
976183fd 241{
2674b9ff 242 if (gDebug>0) cout<<"Enetered Scale()"<<endl;
976183fd 243 if(!fNumerator)
244 {
245 Error("Scale","No numerator");
246 return 0.0;
247 }
248 if(!fDenominator)
249 {
250 Error("Scale","No denominator");
251 return 0.0;
252 }
253
254 if(fNBinsToScale < 1)
255 {
256 return 0.0;
257 Error("Scale","Number of bins for scaling is smaller thnan 1");
258 }
259 Int_t nbins = fNumerator->GetNbinsX();
260 if (fNBinsToScale > nbins)
261 {
262 Error("Scale","Number of bins for scaling is bigger thnan number of bins in histograms");
263 return 0.0;
264 }
2674b9ff 265 if (gDebug>0) cout<<"No errors detected"<<endl;
976183fd 266
2674b9ff 267 Double_t ratio;
268 Double_t sum = 0;
269 Int_t N = 0;
270
976183fd 271 Int_t offset = nbins - fNBinsToScale - 1;
272 Int_t i;
273 for ( i = offset; i< nbins; i++)
274 {
2674b9ff 275 if ( fNumerator->GetBinContent(i) > 0.0 )
976183fd 276 {
2674b9ff 277 ratio = fDenominator->GetBinContent(i)/fNumerator->GetBinContent(i);
278 sum += ratio;
279 N++;
976183fd 280 }
281 }
2674b9ff 282
283 if(gDebug > 0) cout<<"sum="<<sum<<" fNBinsToScale="<<fNBinsToScale<<" N="<<N<<endl;
284
285 if (N == 0) return 0.0;
286 Double_t ret = sum/((Double_t)N);
976183fd 287
2674b9ff 288 if(gDebug > 0) cout<<"Scale() returning "<<ret<<endl;
289 return ret;
976183fd 290}
291
292/******************************************************************/
1b446896 293/******************************************************************/
294/******************************************************************/
295
27b3fe5d 296ClassImp( AliHBTOnePairFctn2D )
1b446896 297
27b3fe5d 298AliHBTOnePairFctn2D::
299AliHBTOnePairFctn2D(Int_t nXbins, Double_t maxXval, Double_t minXval ,
1b446896 300 Int_t nYbins, Double_t maxYval, Double_t minYval)
301
302{
303 TString numstr = fName + " Numerator"; //title and name of the
304 //numerator histogram
305 TString denstr = fName + " Denominator";//title and name of the
306 //denominator histogram
307
308 fNumerator = new TH2D(numstr.Data(),numstr.Data(),
309 nXbins,minXval,maxXval,
310 nYbins,minYval,maxYval);
311
312 fDenominator = new TH2D(denstr.Data(),denstr.Data(),
313 nXbins,minXval,maxXval,
314 nYbins,minYval,maxYval);
315
316 fNumerator->Sumw2();
317 fDenominator->Sumw2();
318
319}
27b3fe5d 320AliHBTOnePairFctn2D::~AliHBTOnePairFctn2D()
1b446896 321{
322 delete fNumerator;
323 delete fDenominator;
324}
27b3fe5d 325void AliHBTOnePairFctn2D::ProcessSameEventParticles(AliHBTPair* pair)
1b446896 326{
327 pair = CheckPair(pair);
328 if(pair)
329 {
330 Double_t x,y;
331 GetValues(pair,x,y);
332 fNumerator->Fill(y,x);
333 }
334}
335
27b3fe5d 336void AliHBTOnePairFctn2D::ProcessDiffEventParticles(AliHBTPair* pair)
1b446896 337{
338 pair = CheckPair(pair);
339 if(pair)
340 {
341 Double_t x,y;
342 GetValues(pair,x,y);
343 fDenominator->Fill(y,x);
344 }
345
346}
347
348
349/******************************************************************/
350/******************************************************************/
351/******************************************************************/
352
27b3fe5d 353ClassImp( AliHBTOnePairFctn3D)
1b446896 354
27b3fe5d 355AliHBTOnePairFctn3D::
356AliHBTOnePairFctn3D(Int_t nXbins, Double_t maxXval, Double_t minXval,
1b446896 357 Int_t nYbins, Double_t maxYval, Double_t minYval,
358 Int_t nZbins, Double_t maxZval, Double_t minZval)
359
360{
361 TString numstr = fName + " Numerator"; //title and name of the
362 //numerator histogram
363 TString denstr = fName + " Denominator";//title and name of the
364 //denominator histogram
365
366 fNumerator = new TH3D(numstr.Data(),numstr.Data(),
367 nXbins,minXval,maxXval,
368 nYbins,minYval,maxYval,
369 nZbins,minZval,maxZval);
370
371 fDenominator = new TH3D(denstr.Data(),denstr.Data(),
372 nXbins,minXval,maxXval,
373 nYbins,minYval,maxYval,
374 nZbins,minZval,maxZval);
375
376 fNumerator->Sumw2();
377 fDenominator->Sumw2();
378
379}
ba95ae3f 380/******************************************************************/
7836ee94 381
5a9432a9 382AliHBTOnePairFctn3D::~AliHBTOnePairFctn3D()
7836ee94 383{
384 delete fNumerator;
385 delete fDenominator;
386}
ba95ae3f 387/******************************************************************/
7836ee94 388
7836ee94 389
390/******************************************************************/
391/******************************************************************/
392/******************************************************************/
ba95ae3f 393ClassImp( AliHBTTwoPairFctn1D)
394
395AliHBTTwoPairFctn1D::
396AliHBTTwoPairFctn1D(Int_t nbins, Double_t maxval, Double_t minval)
397 {
398 TString numstr = fName + " Numerator"; //title and name of the
399 //numerator histogram
400 TString denstr = fName + " Denominator";//title and name of the
401 //denominator histogram
402
403 fNumerator = new TH1D(numstr.Data(),numstr.Data(),
404 nbins,minval,maxval);
405
406 fDenominator = new TH1D(denstr.Data(),denstr.Data(),
407 nbins,minval,maxval);
408
409 fNumerator->Sumw2();
410 fDenominator->Sumw2();
411 }
412
413AliHBTTwoPairFctn1D::
414AliHBTTwoPairFctn1D(const Char_t* name, const Char_t* title,
415 Int_t nbins, Double_t maxval, Double_t minval)
416 :AliHBTTwoPairFctn(name,title)
417 {
418 TString numstr = fName + " Numerator"; //title and name of the
419 //numerator histogram
420 TString denstr = fName + " Denominator";//title and name of the
421 //denominator histogram
422
423 fNumerator = new TH1D(numstr.Data(),numstr.Data(),
424 nbins,minval,maxval);
425
426 fDenominator = new TH1D(denstr.Data(),denstr.Data(),
427 nbins,minval,maxval);
428
429 fNumerator->Sumw2();
430 fDenominator->Sumw2();
431 }
432
433
434/******************************************************************/
435AliHBTTwoPairFctn1D::~AliHBTTwoPairFctn1D()
436{
437 delete fNumerator;
438 delete fDenominator;
439}
440void AliHBTTwoPairFctn1D::
441ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
442{
443 partpair = CheckPair(partpair);
444 trackpair = CheckPair(trackpair);
445 if( partpair && trackpair)
446 {
447 Double_t x = GetValue(trackpair,partpair);
448 fNumerator->Fill(x);
449 }
450}
451/******************************************************************/
452
453void AliHBTTwoPairFctn1D::
454ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
455{
456 partpair = CheckPair(partpair);
457 trackpair = CheckPair(trackpair);
458 if( partpair && trackpair)
459 {
460 Double_t x = GetValue(trackpair,partpair);
461 fDenominator->Fill(x);
462 }
463
464}
465
466/******************************************************************/
467/******************************************************************/
468/******************************************************************/
27b3fe5d 469ClassImp( AliHBTTwoPairFctn2D)
1b446896 470
471
27b3fe5d 472AliHBTTwoPairFctn2D::
473AliHBTTwoPairFctn2D(Int_t nXbins, Double_t maxXval, Double_t minXval ,
1b446896 474 Int_t nYbins, Double_t maxYval, Double_t minYval)
475
476{
477 TString numstr = fName + " Numerator"; //title and name of the
478 //numerator histogram
479 TString denstr = fName + " Denominator";//title and name of the
480 //denominator histogram
481
482 fNumerator = new TH2D(numstr.Data(),numstr.Data(),
483 nXbins,minXval,maxXval,
484 nYbins,minYval,maxYval);
485
486 fDenominator = new TH2D(denstr.Data(),denstr.Data(),
487 nXbins,minXval,maxXval,
488 nYbins,minYval,maxYval);
489
490 fNumerator->Sumw2();
491 fDenominator->Sumw2();
492
493}
27b3fe5d 494AliHBTTwoPairFctn2D::~AliHBTTwoPairFctn2D()
1b446896 495{
496 delete fNumerator;
497 delete fDenominator;
498}
27b3fe5d 499void AliHBTTwoPairFctn2D::
1b446896 500ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
501{
502 partpair = CheckPair(partpair);
503 trackpair = CheckPair(trackpair);
504 if( partpair && trackpair)
505 {
506 Double_t x,y;
507 GetValues(trackpair,partpair,x,y);
508 fNumerator->Fill(y,x);
509 }
510}
511
27b3fe5d 512void AliHBTTwoPairFctn2D::
1b446896 513ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
514{
515 partpair = CheckPair(partpair);
516 trackpair = CheckPair(trackpair);
517 if( partpair && trackpair)
518 {
519 Double_t x,y;
520 GetValues(trackpair,partpair,x,y);
521 fDenominator->Fill(y,x);
522 }
523
524}
525
ba95ae3f 526/******************************************************************/
527/******************************************************************/
528/******************************************************************/
529ClassImp(AliHBTTwoPairFctn3D)
530
531void AliHBTTwoPairFctn3D::
532ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
533{
534 partpair = CheckPair(partpair);
535 trackpair = CheckPair(trackpair);
536 if( partpair && trackpair)
537 {
538 Double_t x,y,z;
539 GetValues(trackpair,partpair,x,y,z);
540 fNumerator->Fill(z,y,x);
541 }
542}
543
544void AliHBTTwoPairFctn3D::
545ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
546{
547 partpair = CheckPair(partpair);
548 trackpair = CheckPair(trackpair);
549 if( partpair && trackpair)
550 {
551 Double_t x,y,z;
552 GetValues(trackpair,partpair,x,y,z);
553 fDenominator->Fill(z,y,x);
554 }
555
556}
557