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