]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HBTAN/AliHBTFunction.cxx
Bug correction - Fortan sources where not commpiled
[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}
976183fd 223/******************************************************************/
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
1b446896 292/******************************************************************/
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);
19b27ae5 332 fNumerator->Fill(x,y);
1b446896 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);
19b27ae5 343 fDenominator->Fill(x,y);
1b446896 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
ba95ae3f 390/******************************************************************/
391/******************************************************************/
392/******************************************************************/
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();
8e0e9b48 411 fNBinsToScale = 30;
ba95ae3f 412 }
413
414AliHBTTwoPairFctn1D::
415AliHBTTwoPairFctn1D(const Char_t* name, const Char_t* title,
416 Int_t nbins, Double_t maxval, Double_t minval)
417 :AliHBTTwoPairFctn(name,title)
418 {
419 TString numstr = fName + " Numerator"; //title and name of the
420 //numerator histogram
421 TString denstr = fName + " Denominator";//title and name of the
422 //denominator histogram
423
424 fNumerator = new TH1D(numstr.Data(),numstr.Data(),
425 nbins,minval,maxval);
426
427 fDenominator = new TH1D(denstr.Data(),denstr.Data(),
428 nbins,minval,maxval);
429
430 fNumerator->Sumw2();
431 fDenominator->Sumw2();
8e0e9b48 432 fNBinsToScale = 30;
ba95ae3f 433 }
434
435
436/******************************************************************/
437AliHBTTwoPairFctn1D::~AliHBTTwoPairFctn1D()
438{
439 delete fNumerator;
440 delete fDenominator;
441}
442void AliHBTTwoPairFctn1D::
443ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
444{
445 partpair = CheckPair(partpair);
446 trackpair = CheckPair(trackpair);
447 if( partpair && trackpair)
448 {
449 Double_t x = GetValue(trackpair,partpair);
450 fNumerator->Fill(x);
451 }
452}
453/******************************************************************/
454
4e871a8a 455void AliHBTTwoPairFctn1D::ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
ba95ae3f 456{
457 partpair = CheckPair(partpair);
458 trackpair = CheckPair(trackpair);
459 if( partpair && trackpair)
460 {
461 Double_t x = GetValue(trackpair,partpair);
462 fDenominator->Fill(x);
463 }
464
465}
4e871a8a 466/******************************************************************/
467Double_t AliHBTTwoPairFctn1D::Scale()
468{
469 if (gDebug>0) cout<<"Enetered Scale()"<<endl;
470 if(!fNumerator)
471 {
472 Error("Scale","No numerator");
473 return 0.0;
474 }
475 if(!fDenominator)
476 {
477 Error("Scale","No denominator");
478 return 0.0;
479 }
480
481 if(fNBinsToScale < 1)
482 {
483 return 0.0;
484 Error("Scale","Number of bins for scaling is smaller thnan 1");
485 }
486 Int_t nbins = fNumerator->GetNbinsX();
487 if (fNBinsToScale > nbins)
488 {
489 Error("Scale","Number of bins for scaling is bigger thnan number of bins in histograms");
490 return 0.0;
491 }
492 if (gDebug>0) cout<<"No errors detected"<<endl;
493
494 Double_t ratio;
495 Double_t sum = 0;
496 Int_t N = 0;
497
498 Int_t offset = nbins - fNBinsToScale - 1;
499 Int_t i;
500 for ( i = offset; i< nbins; i++)
501 {
502 if ( fNumerator->GetBinContent(i) > 0.0 )
503 {
504 ratio = fDenominator->GetBinContent(i)/fNumerator->GetBinContent(i);
505 sum += ratio;
506 N++;
507 }
508 }
509
510 if(gDebug > 0) cout<<"sum="<<sum<<" fNBinsToScale="<<fNBinsToScale<<" N="<<N<<endl;
511
512 if (N == 0) return 0.0;
513 Double_t ret = sum/((Double_t)N);
514
515 if(gDebug > 0) cout<<"Scale() returning "<<ret<<endl;
516 return ret;
517}
ba95ae3f 518
1b446896 519/******************************************************************/
520/******************************************************************/
521/******************************************************************/
27b3fe5d 522ClassImp( AliHBTTwoPairFctn2D)
1b446896 523
524
27b3fe5d 525AliHBTTwoPairFctn2D::
526AliHBTTwoPairFctn2D(Int_t nXbins, Double_t maxXval, Double_t minXval ,
1b446896 527 Int_t nYbins, Double_t maxYval, Double_t minYval)
528
529{
530 TString numstr = fName + " Numerator"; //title and name of the
531 //numerator histogram
532 TString denstr = fName + " Denominator";//title and name of the
533 //denominator histogram
534
535 fNumerator = new TH2D(numstr.Data(),numstr.Data(),
536 nXbins,minXval,maxXval,
537 nYbins,minYval,maxYval);
538
539 fDenominator = new TH2D(denstr.Data(),denstr.Data(),
540 nXbins,minXval,maxXval,
541 nYbins,minYval,maxYval);
542
543 fNumerator->Sumw2();
544 fDenominator->Sumw2();
545
546}
27b3fe5d 547AliHBTTwoPairFctn2D::~AliHBTTwoPairFctn2D()
1b446896 548{
549 delete fNumerator;
550 delete fDenominator;
551}
27b3fe5d 552void AliHBTTwoPairFctn2D::
1b446896 553ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
554{
555 partpair = CheckPair(partpair);
556 trackpair = CheckPair(trackpair);
557 if( partpair && trackpair)
558 {
559 Double_t x,y;
560 GetValues(trackpair,partpair,x,y);
19b27ae5 561 fNumerator->Fill(x,y);
1b446896 562 }
563}
564
27b3fe5d 565void AliHBTTwoPairFctn2D::
1b446896 566ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
567{
568 partpair = CheckPair(partpair);
569 trackpair = CheckPair(trackpair);
570 if( partpair && trackpair)
571 {
572 Double_t x,y;
573 GetValues(trackpair,partpair,x,y);
19b27ae5 574 fDenominator->Fill(x,y);
1b446896 575 }
576
577}
578
ba95ae3f 579/******************************************************************/
580/******************************************************************/
581/******************************************************************/
582ClassImp(AliHBTTwoPairFctn3D)
583
584void AliHBTTwoPairFctn3D::
585ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
586{
587 partpair = CheckPair(partpair);
588 trackpair = CheckPair(trackpair);
589 if( partpair && trackpair)
590 {
591 Double_t x,y,z;
592 GetValues(trackpair,partpair,x,y,z);
19b27ae5 593 fNumerator->Fill(x,y,z);
ba95ae3f 594 }
595}
596
597void AliHBTTwoPairFctn3D::
598ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
599{
600 partpair = CheckPair(partpair);
601 trackpair = CheckPair(trackpair);
602 if( partpair && trackpair)
603 {
604 Double_t x,y,z;
605 GetValues(trackpair,partpair,x,y,z);
19b27ae5 606 fDenominator->Fill(x,y,z);
ba95ae3f 607 }
608
609}
610