]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HBTAN/AliHBTFunction.cxx
Proper initialization in constructors
[u/mrichter/AliRoot.git] / HBTAN / AliHBTFunction.cxx
CommitLineData
1b446896 1#include "AliHBTFunction.h"
6e8d850a 2
3/* $Id: */
4
5//--------------------------------------------------------------------
26f1270c 6//AliHBTFunction
7//Author: Piotr Krzysztof Skowronski
8//Piotr.Skowronski@cern.ch
6e8d850a 9//Base classes for HBT functions
10/*
2c33acf3 11 OnePairFctn Function TwoPairFctn
26f1270c 12 | \ \ / | \ /|\
13 | \ \ / | \ / | \
14 | \ \ 1D 2D 3D / | \
15 | \ \ / \ |\ | \________________/__ | \
16 | \ \/ \ | \__|_____________ / \| \
17 | \ \ \_|____|__ \ / | \
18 | \ / \___ | | \ \/ |\ \
19 | / \ | | \ /\ | \ \
20 | / \ \| | \ / \ | \ \
21 | / \ /\ | \ / \ | \ |
22 | / \ / \ | \ / \ | \ |
6e8d850a 23 | / \ / \ | \ / \ | \ |
26f1270c 24 | / \/ \ | \/ \ | \ |
25 OnePair1D OnePair2D OnePair3D TwoPair1D TwoPair2D TwoPair3D
26
27
1b446896 28 four particle functions are intendent to be resolution functions:
29 it is mecessary to have simulated particle pair corresponding to given
30 recontructed track pair in order to calculate function simualted value
2c33acf3 31 and recontructed value, to be further histogrammed
1b446896 32*/
6e8d850a 33//---------------------------------------------------------------------
26f1270c 34
2dc7203b 35#include <TH2.h>
36#include <TH3.h>
37
1b446896 38/******************************************************************/
39/******************************************************************/
40
41ClassImp( AliHBTFunction )
42
201fedb7 43AliHBTFunction::AliHBTFunction():
44 fPairCut(new AliHBTEmptyPairCut()) //dummy cut
1b446896 45{
2c33acf3 46//Default constructor
ba95ae3f 47}
48/******************************************************************/
201fedb7 49AliHBTFunction::AliHBTFunction(const char* name,const char* title):
50 TNamed(name,title),
51 fPairCut(new AliHBTEmptyPairCut()) //dummy cut
ba95ae3f 52{
201fedb7 53//Constructor
1b446896 54}
2674b9ff 55/******************************************************************/
56
57AliHBTFunction::~AliHBTFunction()
2c33acf3 58{
59//destructor
8928fd0d 60 delete fPairCut;
2c33acf3 61}
2674b9ff 62/******************************************************************/
1b446896 63
c41732dc 64void AliHBTFunction::WriteFunction()
2c33acf3 65{
66//writes result of the function to file
1b446896 67 if (GetNumerator()) GetNumerator()->Write();
68 if (GetDenominator()) GetDenominator()->Write();
69 TH1* res = GetResult();
976183fd 70 if (res) res->Write();
2c33acf3 71}
1b446896 72/******************************************************************/
73
266c51ca 74TH1* AliHBTFunction::GetRatio(Double_t normfactor)
1b446896 75 {
2c33acf3 76 //returns ratio of numerator and denominator
77 //
266c51ca 78 if (gDebug>0) Info("GetRatio","Norm. Factor is %f for %s",normfactor,GetName());
976183fd 79
80 if (normfactor == 0.0)
81 {
82 Error("GetRatio","Scaling Factor is 0. Null poiner returned");
83 return 0x0;
84 }
1b446896 85 TString str = fName + " ratio";
86 TH1 *result = (TH1*)GetNumerator()->Clone(str.Data());
87
88 result->SetTitle(str.Data());
1b446896 89
90 result->Divide(GetNumerator(),GetDenominator(),normfactor);
91
92 return result;
93
94 }
95/******************************************************************/
96void AliHBTFunction::SetPairCut(AliHBTPairCut* cut)
97{
98//Sets new Pair Cut. Old one is deleted
99//Note that it is created new object instead of simple pointer set
100//I do not want to have pointer
101//to object created somewhere else
102//because in that case I could not believe that
103//it would always exist (sb could delete it)
104//so we have always own copy
105
106 if(!cut)
107 {
108 Error("AliHBTFunction::SetPairCut","argument is NULL");
109 return;
110 }
111 delete fPairCut;
112 fPairCut = (AliHBTPairCut*)cut->Clone();
113
114}
115
116/******************************************************************/
117
8928fd0d 118void AliHBTFunction::Rename(const Char_t * name)
1b446896 119 {
120 //renames the function and histograms
121 SetName(name);
122 SetTitle(name);
123
124 TString numstr = fName + " Numerator"; //title and name of the
125 //numerator histogram
126 TString denstr = fName + " Denominator";//title and name of the
127 //denominator histogram
128
129 GetNumerator()->SetName(numstr.Data());
130 GetNumerator()->SetTitle(numstr.Data());
131
132 GetDenominator()->SetName(denstr.Data());
133 GetDenominator()->SetTitle(denstr.Data());
134
135 }
136
8928fd0d 137void AliHBTFunction::Rename(const Char_t * name, const Char_t * title)
1b446896 138 {
139 //renames and retitle the function and histograms
140
141 SetName(name);
142 SetTitle(title);
143
144 TString numstrn = fName + " Numerator"; //name of the
145 //numerator histogram
146
147 TString numstrt = fTitle + " Numerator"; //title of the
148 //numerator histogram
149
150 TString denstrn = fName + " Denominator";//name of the
151 //denominator histogram
152
153 TString denstrt = fTitle + " Denominator";//title of the
154 //denominator histogram
155
156
157 GetNumerator()->SetName(numstrn.Data());
158 GetNumerator()->SetTitle(numstrt.Data());
159
160 GetDenominator()->SetName(denstrn.Data());
161 GetDenominator()->SetTitle(denstrt.Data());
162
163
164 }
26f1270c 165/******************************************************************/
166
c41732dc 167void AliHBTFunction::InitFunction()
26f1270c 168{
169//Iniotializes fctn.: Resets histograms
170//In case histograms are not created in ctor, builds with default parameters
171 if ( !(GetNumerator()&&GetDenominator()) ) BuildHistos();
172 GetNumerator()->Reset();
173 GetDenominator()->Reset();
174}
1b446896 175
176/******************************************************************/
177/******************************************************************/
178/******************************************************************/
179
27b3fe5d 180ClassImp( AliHBTOnePairFctn )
1b446896 181
182/******************************************************************/
183/******************************************************************/
184/******************************************************************/
185
27b3fe5d 186ClassImp( AliHBTTwoPairFctn)
1b446896 187
188/******************************************************************/
189/******************************************************************/
190/******************************************************************/
191
26f1270c 192ClassImp( AliHBTFunction1D )
1b446896 193
26f1270c 194const Int_t AliHBTFunction1D::fgkDefaultNBins = 100;
195const Float_t AliHBTFunction1D::fgkDefaultMin = 0.0;
196const Float_t AliHBTFunction1D::fgkDefaultMax = 0.15;
197const UInt_t AliHBTFunction1D::fgkDefaultNBinsToScale = 30;
198
199
200AliHBTFunction1D::AliHBTFunction1D():
201 fNumerator(0x0),
202 fDenominator(0x0),
203 fNBinsToScale(fgkDefaultNBinsToScale)
2c33acf3 204{//default constructor
26f1270c 205}
206/******************************************************************/
207
208AliHBTFunction1D::AliHBTFunction1D(Int_t nbins, Float_t maxXval, Float_t minXval):
209 fNumerator(0x0),
210 fDenominator(0x0),
211 fNBinsToScale(fgkDefaultNBinsToScale)
212{
1b446896 213 //Constructor of Two Part One Dimentional Function
214 // nbins: number of bins in histograms - default 100
215 // maxXval and minXval: range of histgram(s) default 0 - 0.15 (GeV)
26f1270c 216 BuildHistos(nbins,maxXval,minXval);
217}
218/******************************************************************/
219AliHBTFunction1D::AliHBTFunction1D(const Char_t *name, const Char_t *title):
220 AliHBTFunction(name,title),
221 fNumerator(0x0),
222 fDenominator(0x0),
223 fNBinsToScale(fgkDefaultNBinsToScale)
2c33acf3 224{//constructor
ba95ae3f 225}
1b446896 226/******************************************************************/
26f1270c 227AliHBTFunction1D::AliHBTFunction1D(const Char_t *name, const Char_t *title,
228 Int_t nbins, Float_t maxXval, Float_t minXval):
229 AliHBTFunction(name,title),
230 fNumerator(0x0),
231 fDenominator(0x0),
232 fNBinsToScale(fgkDefaultNBinsToScale)
233{
2c33acf3 234//constructor
235 BuildHistos(nbins,maxXval,minXval);
26f1270c 236}
237/******************************************************************/
238
239AliHBTFunction1D::~AliHBTFunction1D()
1b446896 240{
2c33acf3 241//destructor
1b446896 242 delete fNumerator;
243 delete fDenominator;
244}
26f1270c 245/******************************************************************/
246void AliHBTFunction1D::BuildHistos()
247{
2c33acf3 248//builds histograms with default settings
26f1270c 249 BuildHistos(fgkDefaultNBins,fgkDefaultMax,fgkDefaultMin);
250}
251
976183fd 252/******************************************************************/
253
26f1270c 254void AliHBTFunction1D::BuildHistos(Int_t nbins, Float_t max, Float_t min)
976183fd 255{
2c33acf3 256//builds numarator and denominator hitograms
26f1270c 257 TString numstr = fName + " Numerator"; //title and name of the
258 //numerator histogram
259 TString denstr = fName + " Denominator";//title and name of the
260 //denominator histogram
261 fNumerator = new TH1D(numstr.Data(),numstr.Data(),nbins,min,max);
262 fDenominator = new TH1D(denstr.Data(),denstr.Data(),nbins,min,max);
263
264 fNumerator->Sumw2();
265 fDenominator->Sumw2();
976183fd 266}
267/******************************************************************/
976183fd 268
26f1270c 269Double_t AliHBTFunction1D::Scale()
270{
271 //Calculates the factor that should be used to scale
272 //quatience of fNumerator and fDenominator to 1 at tail
273 return Scale(fNumerator,fDenominator);
274}
976183fd 275/******************************************************************/
26f1270c 276
277Double_t AliHBTFunction1D::Scale(TH1D* num,TH1D* den)
976183fd 278{
26f1270c 279 //Calculates the factor that should be used to scale
280 //quatience of num and den to 1 at tail
281
266c51ca 282 if (gDebug>0) Info("Scale","Enetered Scale()");
26f1270c 283 if(!num)
976183fd 284 {
285 Error("Scale","No numerator");
286 return 0.0;
287 }
26f1270c 288 if(!den)
976183fd 289 {
290 Error("Scale","No denominator");
291 return 0.0;
292 }
293
294 if(fNBinsToScale < 1)
295 {
296 return 0.0;
297 Error("Scale","Number of bins for scaling is smaller thnan 1");
298 }
26f1270c 299 UInt_t nbins = num->GetNbinsX();
976183fd 300 if (fNBinsToScale > nbins)
301 {
302 Error("Scale","Number of bins for scaling is bigger thnan number of bins in histograms");
303 return 0.0;
304 }
266c51ca 305 if (gDebug>0) Info("Scale","No errors detected");
976183fd 306
2674b9ff 307 Double_t ratio;
308 Double_t sum = 0;
2dc7203b 309 Int_t n = 0;
2674b9ff 310
976183fd 311 Int_t offset = nbins - fNBinsToScale - 1;
2c33acf3 312
313 for (UInt_t i = offset; i< nbins; i++)
976183fd 314 {
26f1270c 315 if ( num->GetBinContent(i) > 0.0 )
976183fd 316 {
26f1270c 317 ratio = den->GetBinContent(i)/num->GetBinContent(i);
2674b9ff 318 sum += ratio;
2dc7203b 319 n++;
976183fd 320 }
321 }
2674b9ff 322
2dc7203b 323 if(gDebug > 0) Info("Scale","sum=%f fNBinsToScale=%d n=%d",sum,fNBinsToScale,n);
2674b9ff 324
2dc7203b 325 if (n == 0) return 0.0;
326 Double_t ret = sum/((Double_t)n);
976183fd 327
266c51ca 328 if(gDebug > 0) Info("Scale","returning %f",ret);
2674b9ff 329 return ret;
976183fd 330}
331
1b446896 332/******************************************************************/
333/******************************************************************/
334/******************************************************************/
335
26f1270c 336//____________________
337///////////////////////////////////////////////////////
338// //
339// AliHBTFunction2D //
340// //
341// Base Calss for 2-dimensinal Functions //
342// //
343// Piotr.Skowronski@cern.ch //
344// http://alisoft.cern.ch/people/skowron/analyzer //
345// //
346///////////////////////////////////////////////////////
1b446896 347
1db320d4 348ClassImp( AliHBTFunction2D )
1b446896 349
26f1270c 350const Int_t AliHBTFunction2D::fgkDefaultNBinsX = 200;//default number of Bins in X axis in histograms
351const Float_t AliHBTFunction2D::fgkDefaultMinX = 0.0;//Default min value of X axis in histograms
352const Float_t AliHBTFunction2D::fgkDefaultMaxX = 1.5;//Default max value of X axis inhistograms
353
354const Int_t AliHBTFunction2D::fgkDefaultNBinsY = 200;//default number of Bins in histograms
355const Float_t AliHBTFunction2D::fgkDefaultMinY = -0.15;//Default min value of histograms
356const Float_t AliHBTFunction2D::fgkDefaultMaxY = 0.15;//Default max value of histograms
357
358const UInt_t AliHBTFunction2D::fgkDefaultNBinsToScaleX = 30;//Default number of X bins used for scaling to tale
359const UInt_t AliHBTFunction2D::fgkDefaultNBinsToScaleY = 30;//Default number of bins used for scaling to tale
360
361/******************************************************************/
362AliHBTFunction2D::AliHBTFunction2D():
363 fNumerator(0x0),
364 fDenominator(0x0),
365 fNBinsToScaleX(fgkDefaultNBinsToScaleX),
366 fNBinsToScaleY(fgkDefaultNBinsToScaleY)
367{//default constructor
368}
369/******************************************************************/
370AliHBTFunction2D::AliHBTFunction2D(const Char_t *name, const Char_t *title):
371 AliHBTFunction(name,title),
372 fNumerator(0x0),
373 fDenominator(0x0),
374 fNBinsToScaleX(fgkDefaultNBinsToScaleX),
375 fNBinsToScaleY(fgkDefaultNBinsToScaleY)
376{//constructor
377}
378/******************************************************************/
379
380AliHBTFunction2D::AliHBTFunction2D(Int_t nXbins, Double_t maxXval, Double_t minXval,
381 Int_t nYbins, Double_t maxYval, Double_t minYval):
382 fNumerator(0x0),
383 fDenominator(0x0),
384 fNBinsToScaleX(fgkDefaultNBinsToScaleX),
385 fNBinsToScaleY(fgkDefaultNBinsToScaleY)
1b446896 386{
26f1270c 387 BuildHistos(nXbins,maxXval,minXval,nYbins,maxYval,minYval);
388}
389/******************************************************************/
1b446896 390
26f1270c 391AliHBTFunction2D::AliHBTFunction2D(const Char_t *name, const Char_t *title,
392 Int_t nXbins, Double_t maxXval, Double_t minXval,
393 Int_t nYbins, Double_t maxYval, Double_t minYval):
394 AliHBTFunction(name,title),
395 fNumerator(0x0),
396 fDenominator(0x0),
397 fNBinsToScaleX(fgkDefaultNBinsToScaleX),
398 fNBinsToScaleY(fgkDefaultNBinsToScaleY)
399{
400 BuildHistos(nXbins,maxXval,minXval,nYbins,maxYval,minYval);
1b446896 401}
26f1270c 402/******************************************************************/
403
404AliHBTFunction2D::~AliHBTFunction2D()
1b446896 405{
406 delete fNumerator;
407 delete fDenominator;
408}
26f1270c 409/******************************************************************/
410
411void AliHBTFunction2D::BuildHistos()
1b446896 412{
26f1270c 413//Creates default histograms
414 BuildHistos(fgkDefaultNBinsX,fgkDefaultMaxX,fgkDefaultMinX,
415 fgkDefaultNBinsY,fgkDefaultMaxY,fgkDefaultMinY);
1b446896 416}
26f1270c 417/******************************************************************/
1b446896 418
26f1270c 419void AliHBTFunction2D::BuildHistos(Int_t nxbins, Float_t xmax, Float_t xmin,
420 Int_t nybins, Float_t ymax, Float_t ymin)
1b446896 421{
6e8d850a 422 //Builds numerator and denominator histograms (2d-case)
26f1270c 423 TString numstr = fName + " Numerator"; //title and name of the
424 //numerator histogram
425 TString denstr = fName + " Denominator";//title and name of the
426 //denominator histogram
427
428 fNumerator = new TH2D(numstr.Data(),numstr.Data(),
429 nxbins,xmin,xmax,nybins,ymin,ymax);
430
431 fDenominator = new TH2D(denstr.Data(),denstr.Data(),
432 nxbins,xmin,xmax,nybins,ymin,ymax);
433
434 fNumerator->Sumw2();
435 fDenominator->Sumw2();
436}
437/******************************************************************/
1b446896 438
26f1270c 439void AliHBTFunction2D::SetNumberOfBinsToScale(UInt_t xn, UInt_t yn)
440{
441//defines area used for scaling factor calculation
442 fNBinsToScaleX = xn;
443 fNBinsToScaleY = yn;
1b446896 444}
26f1270c 445/******************************************************************/
1b446896 446
26f1270c 447Double_t AliHBTFunction2D::Scale()
448{
6e8d850a 449 // Calculates the factor that should be used to scale
450 // quatience of fNumerator and fDenominator to 1 at
451 // given region
26f1270c 452 if (gDebug>0) Info("Scale","Enetered Scale()");
453 if(!fNumerator)
454 {
455 Error("Scale","No numerator");
456 return 0.0;
457 }
458 if(!fDenominator)
459 {
460 Error("Scale","No denominator");
461 return 0.0;
462 }
463
464 if( (fNBinsToScaleX < 1) || (fNBinsToScaleY < 1) )
465 {
466 return 0.0;
467 Error("Scale","Number of bins for scaling is smaller thnan 1");
468 }
469 UInt_t nbinsX = fNumerator->GetNbinsX();
470 if (fNBinsToScaleX > nbinsX)
471 {
472 Error("Scale","Number of X bins for scaling is bigger thnan number of bins in histograms");
473 return 0.0;
474 }
475
476 UInt_t nbinsY = fNumerator->GetNbinsX();
477 if (fNBinsToScaleY > nbinsY)
478 {
479 Error("Scale","Number of Y bins for scaling is bigger thnan number of bins in histograms");
480 return 0.0;
481 }
482
483 if (gDebug>0) Info("Scale","No errors detected");
484
485 Int_t offsetX = nbinsX - fNBinsToScaleX - 1; //bin that we start loop over bins in axis X
486 Int_t offsetY = nbinsY - fNBinsToScaleY - 1; //bin that we start loop over bins in axis X
487
488 Double_t ratio;
489 Double_t sum = 0;
2dc7203b 490 Int_t n = 0;
26f1270c 491
2c33acf3 492 for (UInt_t j = offsetY; j< nbinsY; j++)
493 for (UInt_t i = offsetX; i< nbinsX; i++)
26f1270c 494 {
495 if ( fNumerator->GetBinContent(i,j) > 0.0 )
496 {
497 ratio = fDenominator->GetBinContent(i,j)/fNumerator->GetBinContent(i,j);
498 sum += ratio;
2dc7203b 499 n++;
26f1270c 500 }
501 }
502
2dc7203b 503 if(gDebug > 0) Info("Scale","sum=%f fNBinsToScaleX=%d fNBinsToScaleY=%d n=%d",sum,fNBinsToScaleX,fNBinsToScaleY,n);
26f1270c 504
2dc7203b 505 if (n == 0) return 0.0;
506 Double_t ret = sum/((Double_t)n);
26f1270c 507
508 if(gDebug > 0) Info("Scale","returning %f",ret);
509 return ret;
510}
1b446896 511
512/******************************************************************/
513/******************************************************************/
514/******************************************************************/
515
26f1270c 516//____________________
517///////////////////////////////////////////////////////
518// //
519// AliHBTFunction3D //
520// //
521// Base Calss for 3-dimensinal Functions //
522// //
523// Piotr.Skowronski@cern.ch //
524// http://alisoft.cern.ch/people/skowron/analyzer //
525// //
526///////////////////////////////////////////////////////
1b446896 527
26f1270c 528ClassImp( AliHBTFunction3D)
1b446896 529
26f1270c 530const Int_t AliHBTFunction3D::fgkDefaultNBinsX = 200;//default number of Bins in X axis in histograms
531const Float_t AliHBTFunction3D::fgkDefaultMinX = 0.0;//Default min value of X axis in histograms
532const Float_t AliHBTFunction3D::fgkDefaultMaxX = 1.5;//Default max value of X axis inhistograms
1b446896 533
26f1270c 534const Int_t AliHBTFunction3D::fgkDefaultNBinsY = 200;//default number of Bins in histograms
535const Float_t AliHBTFunction3D::fgkDefaultMinY = -0.15;//Default min value of histograms
536const Float_t AliHBTFunction3D::fgkDefaultMaxY = 0.15;//Default max value of histograms
537
538const Int_t AliHBTFunction3D::fgkDefaultNBinsZ = 200;//default number of Bins in histograms
539const Float_t AliHBTFunction3D::fgkDefaultMinZ = -0.15;//Default min value of histograms
540const Float_t AliHBTFunction3D::fgkDefaultMaxZ = 0.15;//Default max value of histograms
541
542const UInt_t AliHBTFunction3D::fgkDefaultNBinsToScaleX = 30;//Default number of X bins used for scaling to tale
543const UInt_t AliHBTFunction3D::fgkDefaultNBinsToScaleY = 30;//Default number of bins used for scaling to tale
544const UInt_t AliHBTFunction3D::fgkDefaultNBinsToScaleZ = 30;//Default number of bins used for scaling to tale
545
2c33acf3 546AliHBTFunction3D::AliHBTFunction3D():
547 fNumerator(0x0),
548 fDenominator(0x0),
549 fNBinsToScaleX(fgkDefaultNBinsToScaleX),
550 fNBinsToScaleY(fgkDefaultNBinsToScaleY),
551 fNBinsToScaleZ(fgkDefaultNBinsToScaleZ)
552{
553 //constructor
554}
555/******************************************************************/
556
557AliHBTFunction3D::AliHBTFunction3D(const Char_t *name, const Char_t *title):
558 AliHBTFunction(name,title),
559 fNumerator(0x0),
560 fDenominator(0x0),
561 fNBinsToScaleX(fgkDefaultNBinsToScaleX),
562 fNBinsToScaleY(fgkDefaultNBinsToScaleY),
563 fNBinsToScaleZ(fgkDefaultNBinsToScaleZ)
564{
565 //constructor
566}
567/******************************************************************/
26f1270c 568
569AliHBTFunction3D::AliHBTFunction3D(Int_t nXbins, Double_t maxXval, Double_t minXval,
570 Int_t nYbins, Double_t maxYval, Double_t minYval,
571 Int_t nZbins, Double_t maxZval, Double_t minZval):
572 fNumerator(0x0),
573 fDenominator(0x0),
574 fNBinsToScaleX(fgkDefaultNBinsToScaleX),
575 fNBinsToScaleY(fgkDefaultNBinsToScaleY),
576 fNBinsToScaleZ(fgkDefaultNBinsToScaleZ)
577{
2c33acf3 578 //constructor
579 BuildHistos( nXbins,maxXval,minXval,nYbins,maxYval,minYval,nZbins,maxZval,minZval);
1b446896 580}
ba95ae3f 581/******************************************************************/
7836ee94 582
2c33acf3 583AliHBTFunction3D::AliHBTFunction3D(const Char_t *name, const Char_t *title,
584 Int_t nXbins, Double_t maxXval, Double_t minXval,
585 Int_t nYbins, Double_t maxYval, Double_t minYval,
586 Int_t nZbins, Double_t maxZval, Double_t minZval):
587 AliHBTFunction(name,title),
588 fNumerator(0x0),
589 fDenominator(0x0),
590 fNBinsToScaleX(fgkDefaultNBinsToScaleX),
591 fNBinsToScaleY(fgkDefaultNBinsToScaleY),
592 fNBinsToScaleZ(fgkDefaultNBinsToScaleZ)
593{
594 //constructor
595 BuildHistos( nXbins,maxXval,minXval,nYbins,maxYval,minYval,nZbins,maxZval,minZval);
596}
597/******************************************************************/
598
599
26f1270c 600AliHBTFunction3D::~AliHBTFunction3D()
7836ee94 601{
602 delete fNumerator;
603 delete fDenominator;
604}
ba95ae3f 605/******************************************************************/
7836ee94 606
26f1270c 607void AliHBTFunction3D::BuildHistos()
608{
609//Creates default histograms
610 BuildHistos(fgkDefaultNBinsX,fgkDefaultMaxX,fgkDefaultMinX,
611 fgkDefaultNBinsY,fgkDefaultMaxY,fgkDefaultMinY,
612 fgkDefaultNBinsZ,fgkDefaultMaxZ,fgkDefaultMinZ);
613}
ba95ae3f 614/******************************************************************/
ba95ae3f 615
26f1270c 616void AliHBTFunction3D::BuildHistos(Int_t nxbins, Float_t xmax, Float_t xmin,
617 Int_t nybins, Float_t ymax, Float_t ymin,
618 Int_t nzbins, Float_t zmax, Float_t zmin)
619{
6e8d850a 620 //Builds numerator and denominator histograms (3d-case)
ba95ae3f 621 TString numstr = fName + " Numerator"; //title and name of the
622 //numerator histogram
623 TString denstr = fName + " Denominator";//title and name of the
624 //denominator histogram
625
26f1270c 626 fNumerator = new TH3D(numstr.Data(),numstr.Data(),
627 nxbins,xmin,xmin,nybins,ymin,ymin,nzbins,zmin,zmin);
ba95ae3f 628
26f1270c 629 fDenominator = new TH3D(denstr.Data(),denstr.Data(),
630 nxbins,xmin,xmin,nybins,ymin,ymin,nzbins,zmin,zmin);
ba95ae3f 631
632 fNumerator->Sumw2();
633 fDenominator->Sumw2();
ba95ae3f 634}
ba95ae3f 635
4e871a8a 636/******************************************************************/
26f1270c 637
638Double_t AliHBTFunction3D::Scale()
4e871a8a 639{
6e8d850a 640 // Calculates the factor that should be used to scale
641 // quatience of fNumerator and fDenominator to 1 at
642 // given volume
266c51ca 643 if (gDebug>0) Info("Scale","Enetered Scale()");
4e871a8a 644 if(!fNumerator)
645 {
646 Error("Scale","No numerator");
647 return 0.0;
648 }
649 if(!fDenominator)
650 {
651 Error("Scale","No denominator");
652 return 0.0;
653 }
654
26f1270c 655 if( (fNBinsToScaleX < 1) || (fNBinsToScaleY < 1) || (fNBinsToScaleZ < 1))
4e871a8a 656 {
657 return 0.0;
658 Error("Scale","Number of bins for scaling is smaller thnan 1");
659 }
26f1270c 660 UInt_t nbinsX = fNumerator->GetNbinsX();
661 if (fNBinsToScaleX > nbinsX)
4e871a8a 662 {
26f1270c 663 Error("Scale","Number of X bins for scaling is bigger thnan number of bins in histograms");
664 return 0.0;
665 }
666
667 UInt_t nbinsY = fNumerator->GetNbinsX();
668 if (fNBinsToScaleY > nbinsY)
669 {
670 Error("Scale","Number of Y bins for scaling is bigger thnan number of bins in histograms");
671 return 0.0;
672 }
673
674 UInt_t nbinsZ = fNumerator->GetNbinsZ();
675 if (fNBinsToScaleZ > nbinsZ)
676 {
677 Error("Scale","Number of Z bins for scaling is bigger thnan number of bins in histograms");
4e871a8a 678 return 0.0;
679 }
26f1270c 680
266c51ca 681 if (gDebug>0) Info("Scale","No errors detected");
4e871a8a 682
26f1270c 683 Int_t offsetX = nbinsX - fNBinsToScaleX - 1; //bin that we start loop over bins in axis X
196e34f6 684 Int_t offsetY = nbinsY - fNBinsToScaleY - 1; //bin that we start loop over bins in axis Y
685 Int_t offsetZ = nbinsZ - fNBinsToScaleZ - 1; //bin that we start loop over bins in axis Z
26f1270c 686
4e871a8a 687 Double_t ratio;
688 Double_t sum = 0;
2dc7203b 689 Int_t n = 0;
4e871a8a 690
196e34f6 691 for (UInt_t k = offsetZ; k<nbinsZ; k++)
692 for (UInt_t j = offsetY; j<nbinsY; j++)
693 for (UInt_t i = offsetX; i<nbinsX; i++)
26f1270c 694 {
695 if ( fNumerator->GetBinContent(i,j,k) > 0.0 )
696 {
697 ratio = fDenominator->GetBinContent(i,j,k)/fNumerator->GetBinContent(i,j,k);
698 sum += ratio;
2dc7203b 699 n++;
26f1270c 700 }
701 }
4e871a8a 702
26f1270c 703 if(gDebug > 0)
2dc7203b 704 Info("Scale","sum=%f fNBinsToScaleX=%d fNBinsToScaleY=%d fNBinsToScaleZ=%d n=%d",
705 sum,fNBinsToScaleX,fNBinsToScaleY,fNBinsToScaleZ,n);
4e871a8a 706
2dc7203b 707 if (n == 0) return 0.0;
708 Double_t ret = sum/((Double_t)n);
4e871a8a 709
266c51ca 710 if(gDebug > 0) Info("Scale","returning %f",ret);
4e871a8a 711 return ret;
712}
2c33acf3 713/******************************************************************/
714
715void AliHBTFunction3D::SetNumberOfBinsToScale(UInt_t xn, UInt_t yn,UInt_t zn)
716{
717//sets up the volume to be used for scaling to tail
718 fNBinsToScaleX = xn;
719 fNBinsToScaleY = yn;
720 fNBinsToScaleZ = zn;
721}
ba95ae3f 722
1b446896 723/******************************************************************/
724/******************************************************************/
725/******************************************************************/
26f1270c 726/******************************************************************/
727/******************************************************************/
728/******************************************************************/
729/******************************************************************/
730/******************************************************************/
731/******************************************************************/
1b446896 732
26f1270c 733//____________________
734///////////////////////////////////////////////////////
735// //
736// AliHBTOnePairFctn1D //
737// //
738// Base Calss for 1-dimensinal Functions that need //
739// one pair to fill function //
740// //
741// Piotr.Skowronski@cern.ch //
742// http://alisoft.cern.ch/people/skowron/analyzer //
743// //
744///////////////////////////////////////////////////////
1b446896 745
26f1270c 746ClassImp( AliHBTOnePairFctn1D )
747/******************************************************************/
1b446896 748
26f1270c 749AliHBTOnePairFctn1D::AliHBTOnePairFctn1D(Int_t nbins, Float_t maxXval, Float_t minXval):
750 AliHBTFunction1D(nbins,maxXval,minXval)
1b446896 751{
26f1270c 752}
753/******************************************************************/
1b446896 754
26f1270c 755AliHBTOnePairFctn1D::AliHBTOnePairFctn1D(const Char_t *name, const Char_t *title):
756 AliHBTFunction1D(name,title)
757{
758}
759/******************************************************************/
760
761AliHBTOnePairFctn1D::AliHBTOnePairFctn1D(const Char_t *name, const Char_t *title,
762 Int_t nbins, Float_t maxXval, Float_t minXval):
763 AliHBTFunction1D(name,title,nbins,maxXval,minXval)
764{
765}
766/******************************************************************/
767
768void AliHBTOnePairFctn1D::ProcessSameEventParticles(AliHBTPair* pair)
769{
6e8d850a 770 //Fills the numerator using pair from the same event
26f1270c 771 pair = CheckPair(pair);
772 if(pair) fNumerator->Fill(GetValue(pair));
773}
774/******************************************************************/
775void AliHBTOnePairFctn1D::ProcessDiffEventParticles(AliHBTPair* pair)
776 {
6e8d850a 777 //Fills the denumerator using mixed pairs
26f1270c 778 pair = CheckPair(pair);
779 if(pair) fDenominator->Fill(GetValue(pair));
780 }
781
782/******************************************************************/
783/******************************************************************/
784/******************************************************************/
785
786//____________________
787///////////////////////////////////////////////////////
788// //
789// AliHBTOnePairFctn2D //
790// //
791// Base Calss for 2-dimensinal Functions that need //
792// one pair to fill function //
793// //
794// Piotr.Skowronski@cern.ch //
795// http://alisoft.cern.ch/people/skowron/analyzer //
796// //
797///////////////////////////////////////////////////////
798
799ClassImp( AliHBTOnePairFctn2D )
800/******************************************************************/
801
802AliHBTOnePairFctn2D::AliHBTOnePairFctn2D(const Char_t *name, const Char_t *title):
803 AliHBTFunction2D(name,title)
804{
805}
806/******************************************************************/
807
808AliHBTOnePairFctn2D::AliHBTOnePairFctn2D(Int_t nXbins, Double_t maxXval, Double_t minXval,
809 Int_t nYbins, Double_t maxYval, Double_t minYval):
810 AliHBTFunction2D(nXbins, maxXval, minXval, nYbins, maxYval, minYval)
811{
812}
813/******************************************************************/
814
815AliHBTOnePairFctn2D::AliHBTOnePairFctn2D(const Char_t *name, const Char_t *title,
816 Int_t nXbins, Double_t maxXval, Double_t minXval,
817 Int_t nYbins, Double_t maxYval, Double_t minYval):
818 AliHBTFunction2D(name,title, nXbins, maxXval, minXval, nYbins, maxYval, minYval)
819{
820}
821/******************************************************************/
822
823void AliHBTOnePairFctn2D::ProcessSameEventParticles(AliHBTPair* pair)
824{
6e8d850a 825 // Fills the numerator using pairs from the same event
26f1270c 826 pair = CheckPair(pair);
827 if(pair)
828 {
829 Double_t x,y;
830 GetValues(pair,x,y);
831 fNumerator->Fill(x,y);
832 }
833}
834/******************************************************************/
835
836void AliHBTOnePairFctn2D::ProcessDiffEventParticles(AliHBTPair* pair)
837{
6e8d850a 838 // Fills the denumerator using mixed pairs
26f1270c 839 pair = CheckPair(pair);
840 if(pair)
841 {
842 Double_t x,y;
843 GetValues(pair,x,y);
844 fDenominator->Fill(x,y);
845 }
846}
847/******************************************************************/
848/******************************************************************/
849/******************************************************************/
850/******************************************************************/
851//____________________
852///////////////////////////////////////////////////////
853// //
854// AliHBTOnePairFctn3D //
855// //
856// Base Calss for 3-dimensinal Functions that need //
857// one pair to fill function //
858// //
859// Piotr.Skowronski@cern.ch //
860// http://alisoft.cern.ch/people/skowron/analyzer //
861// //
862///////////////////////////////////////////////////////
863ClassImp( AliHBTOnePairFctn3D)
864
865/******************************************************************/
866
867AliHBTOnePairFctn3D::AliHBTOnePairFctn3D(const Char_t *name, const Char_t *title):
868 AliHBTFunction3D(name,title)
1b446896 869{
1b446896 870}
26f1270c 871/******************************************************************/
872
873AliHBTOnePairFctn3D::AliHBTOnePairFctn3D(Int_t nXbins, Double_t maxXval, Double_t minXval,
874 Int_t nYbins, Double_t maxYval, Double_t minYval,
875 Int_t nZbins, Double_t maxZval, Double_t minZval):
876 AliHBTFunction3D(nXbins, maxXval, minXval, nYbins, maxYval, minYval, nZbins, maxZval, minZval)
877{
878}
879/******************************************************************/
880
881AliHBTOnePairFctn3D::AliHBTOnePairFctn3D(const Char_t *name, const Char_t *title,
882 Int_t nXbins, Double_t maxXval, Double_t minXval,
883 Int_t nYbins, Double_t maxYval, Double_t minYval,
884 Int_t nZbins, Double_t maxZval, Double_t minZval):
885 AliHBTFunction3D(name,title,nXbins, maxXval, minXval, nYbins, maxYval, minYval, nZbins, maxZval, minZval)
886{
887}
888/******************************************************************/
889
890void AliHBTOnePairFctn3D::ProcessSameEventParticles(AliHBTPair* pair)
891{
892//Reacts on pair coming from same event (real pairs)
893//and fills numerator histogram
894 pair = CheckPair(pair);
895 if( pair )
896 {
897 Double_t x,y,z;
898 GetValues(pair,x,y,z);
899 fNumerator->Fill(x,y,z);
900 }
901}
902/******************************************************************/
903
904void AliHBTOnePairFctn3D::ProcessDiffEventParticles(AliHBTPair* pair)
905{
906//Reacts on pair coming from different events (mixed pairs)
907//and fills denominator histogram
908 pair = CheckPair(pair);
909 if( pair )
910 {
911 Double_t x,y,z;
912 GetValues(pair,x,y,z);
913 fDenominator->Fill(x,y,z);
914 }
915}
916
917/******************************************************************/
918/******************************************************************/
919/******************************************************************/
920
921//____________________
922///////////////////////////////////////////////////////
923// //
924// AliHBTTwoPairFctn1D //
925// //
926// Base Calss for 1-dimensinal Functions that need //
927// two pair (simulated and reconstructed) //
928// to fill function //
929// //
930// Piotr.Skowronski@cern.ch //
931// http://alisoft.cern.ch/people/skowron/analyzer //
932// //
933///////////////////////////////////////////////////////
934ClassImp(AliHBTTwoPairFctn1D)
935/******************************************************************/
936
937AliHBTTwoPairFctn1D::AliHBTTwoPairFctn1D(Int_t nbins, Float_t maxXval, Float_t minXval):
938 AliHBTFunction1D(nbins,maxXval,minXval)
939{
940}
941/******************************************************************/
942
943AliHBTTwoPairFctn1D::AliHBTTwoPairFctn1D(const Char_t *name, const Char_t *title):
944 AliHBTFunction1D(name,title)
945{
946}
947/******************************************************************/
948
949AliHBTTwoPairFctn1D::AliHBTTwoPairFctn1D(const Char_t *name, const Char_t *title,
950 Int_t nbins, Float_t maxXval, Float_t minXval):
951 AliHBTFunction1D(name,title,nbins,maxXval,minXval)
952{
953}
954/******************************************************************/
955
956void AliHBTTwoPairFctn1D::ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
957{
6e8d850a 958 // Fills the numerator using pairs from the same event
26f1270c 959 partpair = CheckPair(partpair);
960 if( partpair )
961 {
962 Double_t x = GetValue(trackpair,partpair);
963 fNumerator->Fill(x);
964 }
965}
966/******************************************************************/
967
968void AliHBTTwoPairFctn1D::ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
969{
6e8d850a 970 // Fills the denumerator usin mixed pairs
26f1270c 971 partpair = CheckPair(partpair);
972 if( partpair )
973 {
974 Double_t x = GetValue(trackpair,partpair);
975 fDenominator->Fill(x);
976 }
977}
978/******************************************************************/
979/******************************************************************/
980/******************************************************************/
981
982//____________________
983///////////////////////////////////////////////////////
984// //
985// AliHBTTwoPairFctn2D //
986// //
987// Base Calss for 2-dimensinal Functions that need //
988// two pair (simulated and reconstructed) //
989// to fill function //
990// //
991// Piotr.Skowronski@cern.ch //
992// http://alisoft.cern.ch/people/skowron/analyzer //
993// //
994///////////////////////////////////////////////////////
995
996ClassImp(AliHBTTwoPairFctn2D)
997
998/******************************************************************/
999
1000AliHBTTwoPairFctn2D::AliHBTTwoPairFctn2D(const Char_t *name, const Char_t *title):
1001 AliHBTFunction2D(name,title)
1002{
1003}
1004/******************************************************************/
1005
1006AliHBTTwoPairFctn2D::AliHBTTwoPairFctn2D(Int_t nXbins, Double_t maxXval, Double_t minXval,
1007 Int_t nYbins, Double_t maxYval, Double_t minYval):
1008 AliHBTFunction2D(nXbins, maxXval, minXval, nYbins, maxYval, minYval)
1009{
1010}
1011/******************************************************************/
1012
1013AliHBTTwoPairFctn2D::AliHBTTwoPairFctn2D(const Char_t *name, const Char_t *title,
1014 Int_t nXbins, Double_t maxXval, Double_t minXval,
1015 Int_t nYbins, Double_t maxYval, Double_t minYval):
1016 AliHBTFunction2D(name,title,nXbins, maxXval, minXval, nYbins, maxYval, minYval)
1017{
1018}
1019/******************************************************************/
1020
1021void AliHBTTwoPairFctn2D::ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
1b446896 1022{
2c33acf3 1023//processes pair of particles coming from a same events (real pair)
1024 partpair = CheckPair(partpair); //check cuts
266c51ca 1025 if( partpair )
1b446896 1026 {
1027 Double_t x,y;
1028 GetValues(trackpair,partpair,x,y);
19b27ae5 1029 fNumerator->Fill(x,y);
1b446896 1030 }
1031}
26f1270c 1032/******************************************************************/
1b446896 1033
26f1270c 1034void AliHBTTwoPairFctn2D::ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
1b446896 1035{
2c33acf3 1036//processes pair of particles coming from a different events (mixed pair)
1b446896 1037 partpair = CheckPair(partpair);
266c51ca 1038 if( partpair )
1b446896 1039 {
1040 Double_t x,y;
1041 GetValues(trackpair,partpair,x,y);
19b27ae5 1042 fDenominator->Fill(x,y);
1b446896 1043 }
1b446896 1044}
1045
ba95ae3f 1046/******************************************************************/
1047/******************************************************************/
1048/******************************************************************/
26f1270c 1049
1050//____________________
1051///////////////////////////////////////////////////////
1052// //
1053// AliHBTTwoPairFctn3D //
1054// //
1055// Base Calss for 3-dimensinal Functions that need //
1056// two pair (simulated and reconstructed) //
1057// to fill function //
1058// //
1059// Piotr.Skowronski@cern.ch //
1060// http://alisoft.cern.ch/people/skowron/analyzer //
1061// //
1062///////////////////////////////////////////////////////
1063
ba95ae3f 1064ClassImp(AliHBTTwoPairFctn3D)
1065
26f1270c 1066/******************************************************************/
1067
1068AliHBTTwoPairFctn3D::AliHBTTwoPairFctn3D(const Char_t *name, const Char_t *title):
1069 AliHBTFunction3D(name,title)
1070{
1071}
1072/******************************************************************/
1073
1074AliHBTTwoPairFctn3D::AliHBTTwoPairFctn3D(Int_t nXbins, Double_t maxXval, Double_t minXval,
1075 Int_t nYbins, Double_t maxYval, Double_t minYval,
1076 Int_t nZbins, Double_t maxZval, Double_t minZval):
1077 AliHBTFunction3D(nXbins, maxXval, minXval, nYbins, maxYval, minYval, nZbins, maxZval, minZval)
1078{
1079}
1080/******************************************************************/
1081
1082AliHBTTwoPairFctn3D::AliHBTTwoPairFctn3D(const Char_t *name, const Char_t *title,
1083 Int_t nXbins, Double_t maxXval, Double_t minXval,
1084 Int_t nYbins, Double_t maxYval, Double_t minYval,
1085 Int_t nZbins, Double_t maxZval, Double_t minZval):
1086 AliHBTFunction3D(name,title,nXbins, maxXval, minXval, nYbins, maxYval, minYval, nZbins, maxZval, minZval)
1087{
1088}
1089/******************************************************************/
1090
1091void AliHBTTwoPairFctn3D::ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
ba95ae3f 1092{
6e8d850a 1093 // Fills th numerator using pairs from the same event
ba95ae3f 1094 partpair = CheckPair(partpair);
266c51ca 1095 if( partpair )
ba95ae3f 1096 {
1097 Double_t x,y,z;
1098 GetValues(trackpair,partpair,x,y,z);
19b27ae5 1099 fNumerator->Fill(x,y,z);
ba95ae3f 1100 }
1101}
26f1270c 1102/******************************************************************/
ba95ae3f 1103
26f1270c 1104void AliHBTTwoPairFctn3D::ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
ba95ae3f 1105{
6e8d850a 1106 // Fills the denumerator using mixed pairs
ba95ae3f 1107 partpair = CheckPair(partpair);
266c51ca 1108 if( partpair )
ba95ae3f 1109 {
1110 Double_t x,y,z;
1111 GetValues(trackpair,partpair,x,y,z);
19b27ae5 1112 fDenominator->Fill(x,y,z);
ba95ae3f 1113 }
1114
1115}
1116
26f1270c 1117
1118/******************************************************************/
1119/******************************************************************/
1120/******************************************************************/
1121