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