]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HBTAN/AliHBTFunction.cxx
To remove a warning from compiler (file not terminated by EOL)
[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();
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
4e871a8a 453void AliHBTTwoPairFctn1D::ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
ba95ae3f 454{
455 partpair = CheckPair(partpair);
456 trackpair = CheckPair(trackpair);
457 if( partpair && trackpair)
458 {
459 Double_t x = GetValue(trackpair,partpair);
460 fDenominator->Fill(x);
461 }
462
463}
4e871a8a 464/******************************************************************/
465Double_t AliHBTTwoPairFctn1D::Scale()
466{
467 if (gDebug>0) cout<<"Enetered Scale()"<<endl;
468 if(!fNumerator)
469 {
470 Error("Scale","No numerator");
471 return 0.0;
472 }
473 if(!fDenominator)
474 {
475 Error("Scale","No denominator");
476 return 0.0;
477 }
478
479 if(fNBinsToScale < 1)
480 {
481 return 0.0;
482 Error("Scale","Number of bins for scaling is smaller thnan 1");
483 }
484 Int_t nbins = fNumerator->GetNbinsX();
485 if (fNBinsToScale > nbins)
486 {
487 Error("Scale","Number of bins for scaling is bigger thnan number of bins in histograms");
488 return 0.0;
489 }
490 if (gDebug>0) cout<<"No errors detected"<<endl;
491
492 Double_t ratio;
493 Double_t sum = 0;
494 Int_t N = 0;
495
496 Int_t offset = nbins - fNBinsToScale - 1;
497 Int_t i;
498 for ( i = offset; i< nbins; i++)
499 {
500 if ( fNumerator->GetBinContent(i) > 0.0 )
501 {
502 ratio = fDenominator->GetBinContent(i)/fNumerator->GetBinContent(i);
503 sum += ratio;
504 N++;
505 }
506 }
507
508 if(gDebug > 0) cout<<"sum="<<sum<<" fNBinsToScale="<<fNBinsToScale<<" N="<<N<<endl;
509
510 if (N == 0) return 0.0;
511 Double_t ret = sum/((Double_t)N);
512
513 if(gDebug > 0) cout<<"Scale() returning "<<ret<<endl;
514 return ret;
515}
ba95ae3f 516
1b446896 517/******************************************************************/
518/******************************************************************/
519/******************************************************************/
27b3fe5d 520ClassImp( AliHBTTwoPairFctn2D)
1b446896 521
522
27b3fe5d 523AliHBTTwoPairFctn2D::
524AliHBTTwoPairFctn2D(Int_t nXbins, Double_t maxXval, Double_t minXval ,
1b446896 525 Int_t nYbins, Double_t maxYval, Double_t minYval)
526
527{
528 TString numstr = fName + " Numerator"; //title and name of the
529 //numerator histogram
530 TString denstr = fName + " Denominator";//title and name of the
531 //denominator histogram
532
533 fNumerator = new TH2D(numstr.Data(),numstr.Data(),
534 nXbins,minXval,maxXval,
535 nYbins,minYval,maxYval);
536
537 fDenominator = new TH2D(denstr.Data(),denstr.Data(),
538 nXbins,minXval,maxXval,
539 nYbins,minYval,maxYval);
540
541 fNumerator->Sumw2();
542 fDenominator->Sumw2();
543
544}
27b3fe5d 545AliHBTTwoPairFctn2D::~AliHBTTwoPairFctn2D()
1b446896 546{
547 delete fNumerator;
548 delete fDenominator;
549}
27b3fe5d 550void AliHBTTwoPairFctn2D::
1b446896 551ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
552{
553 partpair = CheckPair(partpair);
554 trackpair = CheckPair(trackpair);
555 if( partpair && trackpair)
556 {
557 Double_t x,y;
558 GetValues(trackpair,partpair,x,y);
19b27ae5 559 fNumerator->Fill(x,y);
1b446896 560 }
561}
562
27b3fe5d 563void AliHBTTwoPairFctn2D::
1b446896 564ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
565{
566 partpair = CheckPair(partpair);
567 trackpair = CheckPair(trackpair);
568 if( partpair && trackpair)
569 {
570 Double_t x,y;
571 GetValues(trackpair,partpair,x,y);
19b27ae5 572 fDenominator->Fill(x,y);
1b446896 573 }
574
575}
576
ba95ae3f 577/******************************************************************/
578/******************************************************************/
579/******************************************************************/
580ClassImp(AliHBTTwoPairFctn3D)
581
582void AliHBTTwoPairFctn3D::
583ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
584{
585 partpair = CheckPair(partpair);
586 trackpair = CheckPair(trackpair);
587 if( partpair && trackpair)
588 {
589 Double_t x,y,z;
590 GetValues(trackpair,partpair,x,y,z);
19b27ae5 591 fNumerator->Fill(x,y,z);
ba95ae3f 592 }
593}
594
595void AliHBTTwoPairFctn3D::
596ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
597{
598 partpair = CheckPair(partpair);
599 trackpair = CheckPair(trackpair);
600 if( partpair && trackpair)
601 {
602 Double_t x,y,z;
603 GetValues(trackpair,partpair,x,y,z);
19b27ae5 604 fDenominator->Fill(x,y,z);
ba95ae3f 605 }
606
607}
608