]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HBTAN/AliHBTFunction.cxx
Monitor function ProcessDiff ProcessSame substituted with Process, since previous...
[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
623 Int_t offsetY = nbinsY - fNBinsToScaleY - 1; //bin that we start loop over bins in axis X
624 Int_t offsetZ = nbinsZ - fNBinsToScaleZ - 1; //bin that we start loop over bins in axis X
625
4e871a8a 626 Double_t ratio;
627 Double_t sum = 0;
628 Int_t N = 0;
629
26f1270c 630 UInt_t i,j,k;
631 for ( j = offsetZ; j< nbinsZ; j++)
632 for ( j = offsetY; j< nbinsY; j++)
633 for ( i = offsetX; i< nbinsX; i++)
634 {
635 if ( fNumerator->GetBinContent(i,j,k) > 0.0 )
636 {
637 ratio = fDenominator->GetBinContent(i,j,k)/fNumerator->GetBinContent(i,j,k);
638 sum += ratio;
639 N++;
640 }
641 }
4e871a8a 642
26f1270c 643 if(gDebug > 0)
644 Info("Scale","sum=%f fNBinsToScaleX=%d fNBinsToScaleY=%d fNBinsToScaleZ=%d N=%d",
645 sum,fNBinsToScaleX,fNBinsToScaleY,fNBinsToScaleZ,N);
4e871a8a 646
647 if (N == 0) return 0.0;
648 Double_t ret = sum/((Double_t)N);
649
266c51ca 650 if(gDebug > 0) Info("Scale","returning %f",ret);
4e871a8a 651 return ret;
652}
ba95ae3f 653
1b446896 654/******************************************************************/
655/******************************************************************/
656/******************************************************************/
26f1270c 657/******************************************************************/
658/******************************************************************/
659/******************************************************************/
660/******************************************************************/
661/******************************************************************/
662/******************************************************************/
1b446896 663
26f1270c 664//____________________
665///////////////////////////////////////////////////////
666// //
667// AliHBTOnePairFctn1D //
668// //
669// Base Calss for 1-dimensinal Functions that need //
670// one pair to fill function //
671// //
672// Piotr.Skowronski@cern.ch //
673// http://alisoft.cern.ch/people/skowron/analyzer //
674// //
675///////////////////////////////////////////////////////
1b446896 676
26f1270c 677ClassImp( AliHBTOnePairFctn1D )
678/******************************************************************/
1b446896 679
26f1270c 680AliHBTOnePairFctn1D::AliHBTOnePairFctn1D(Int_t nbins, Float_t maxXval, Float_t minXval):
681 AliHBTFunction1D(nbins,maxXval,minXval)
1b446896 682{
26f1270c 683}
684/******************************************************************/
1b446896 685
26f1270c 686AliHBTOnePairFctn1D::AliHBTOnePairFctn1D(const Char_t *name, const Char_t *title):
687 AliHBTFunction1D(name,title)
688{
689}
690/******************************************************************/
691
692AliHBTOnePairFctn1D::AliHBTOnePairFctn1D(const Char_t *name, const Char_t *title,
693 Int_t nbins, Float_t maxXval, Float_t minXval):
694 AliHBTFunction1D(name,title,nbins,maxXval,minXval)
695{
696}
697/******************************************************************/
698
699void AliHBTOnePairFctn1D::ProcessSameEventParticles(AliHBTPair* pair)
700{
701 //Fills the numerator
702 pair = CheckPair(pair);
703 if(pair) fNumerator->Fill(GetValue(pair));
704}
705/******************************************************************/
706void AliHBTOnePairFctn1D::ProcessDiffEventParticles(AliHBTPair* pair)
707 {
708 //fills denumerator
709 pair = CheckPair(pair);
710 if(pair) fDenominator->Fill(GetValue(pair));
711 }
712
713/******************************************************************/
714/******************************************************************/
715/******************************************************************/
716
717//____________________
718///////////////////////////////////////////////////////
719// //
720// AliHBTOnePairFctn2D //
721// //
722// Base Calss for 2-dimensinal Functions that need //
723// one pair to fill function //
724// //
725// Piotr.Skowronski@cern.ch //
726// http://alisoft.cern.ch/people/skowron/analyzer //
727// //
728///////////////////////////////////////////////////////
729
730ClassImp( AliHBTOnePairFctn2D )
731/******************************************************************/
732
733AliHBTOnePairFctn2D::AliHBTOnePairFctn2D(const Char_t *name, const Char_t *title):
734 AliHBTFunction2D(name,title)
735{
736}
737/******************************************************************/
738
739AliHBTOnePairFctn2D::AliHBTOnePairFctn2D(Int_t nXbins, Double_t maxXval, Double_t minXval,
740 Int_t nYbins, Double_t maxYval, Double_t minYval):
741 AliHBTFunction2D(nXbins, maxXval, minXval, nYbins, maxYval, minYval)
742{
743}
744/******************************************************************/
745
746AliHBTOnePairFctn2D::AliHBTOnePairFctn2D(const Char_t *name, const Char_t *title,
747 Int_t nXbins, Double_t maxXval, Double_t minXval,
748 Int_t nYbins, Double_t maxYval, Double_t minYval):
749 AliHBTFunction2D(name,title, nXbins, maxXval, minXval, nYbins, maxYval, minYval)
750{
751}
752/******************************************************************/
753
754void AliHBTOnePairFctn2D::ProcessSameEventParticles(AliHBTPair* pair)
755{
756 pair = CheckPair(pair);
757 if(pair)
758 {
759 Double_t x,y;
760 GetValues(pair,x,y);
761 fNumerator->Fill(x,y);
762 }
763}
764/******************************************************************/
765
766void AliHBTOnePairFctn2D::ProcessDiffEventParticles(AliHBTPair* pair)
767{
768 pair = CheckPair(pair);
769 if(pair)
770 {
771 Double_t x,y;
772 GetValues(pair,x,y);
773 fDenominator->Fill(x,y);
774 }
775}
776/******************************************************************/
777/******************************************************************/
778/******************************************************************/
779/******************************************************************/
780//____________________
781///////////////////////////////////////////////////////
782// //
783// AliHBTOnePairFctn3D //
784// //
785// Base Calss for 3-dimensinal Functions that need //
786// one pair to fill function //
787// //
788// Piotr.Skowronski@cern.ch //
789// http://alisoft.cern.ch/people/skowron/analyzer //
790// //
791///////////////////////////////////////////////////////
792ClassImp( AliHBTOnePairFctn3D)
793
794/******************************************************************/
795
796AliHBTOnePairFctn3D::AliHBTOnePairFctn3D(const Char_t *name, const Char_t *title):
797 AliHBTFunction3D(name,title)
1b446896 798{
1b446896 799}
26f1270c 800/******************************************************************/
801
802AliHBTOnePairFctn3D::AliHBTOnePairFctn3D(Int_t nXbins, Double_t maxXval, Double_t minXval,
803 Int_t nYbins, Double_t maxYval, Double_t minYval,
804 Int_t nZbins, Double_t maxZval, Double_t minZval):
805 AliHBTFunction3D(nXbins, maxXval, minXval, nYbins, maxYval, minYval, nZbins, maxZval, minZval)
806{
807}
808/******************************************************************/
809
810AliHBTOnePairFctn3D::AliHBTOnePairFctn3D(const Char_t *name, const Char_t *title,
811 Int_t nXbins, Double_t maxXval, Double_t minXval,
812 Int_t nYbins, Double_t maxYval, Double_t minYval,
813 Int_t nZbins, Double_t maxZval, Double_t minZval):
814 AliHBTFunction3D(name,title,nXbins, maxXval, minXval, nYbins, maxYval, minYval, nZbins, maxZval, minZval)
815{
816}
817/******************************************************************/
818
819void AliHBTOnePairFctn3D::ProcessSameEventParticles(AliHBTPair* pair)
820{
821//Reacts on pair coming from same event (real pairs)
822//and fills numerator histogram
823 pair = CheckPair(pair);
824 if( pair )
825 {
826 Double_t x,y,z;
827 GetValues(pair,x,y,z);
828 fNumerator->Fill(x,y,z);
829 }
830}
831/******************************************************************/
832
833void AliHBTOnePairFctn3D::ProcessDiffEventParticles(AliHBTPair* pair)
834{
835//Reacts on pair coming from different events (mixed pairs)
836//and fills denominator histogram
837 pair = CheckPair(pair);
838 if( pair )
839 {
840 Double_t x,y,z;
841 GetValues(pair,x,y,z);
842 fDenominator->Fill(x,y,z);
843 }
844}
845
846/******************************************************************/
847/******************************************************************/
848/******************************************************************/
849
850//____________________
851///////////////////////////////////////////////////////
852// //
853// AliHBTTwoPairFctn1D //
854// //
855// Base Calss for 1-dimensinal Functions that need //
856// two pair (simulated and reconstructed) //
857// to fill function //
858// //
859// Piotr.Skowronski@cern.ch //
860// http://alisoft.cern.ch/people/skowron/analyzer //
861// //
862///////////////////////////////////////////////////////
863ClassImp(AliHBTTwoPairFctn1D)
864/******************************************************************/
865
866AliHBTTwoPairFctn1D::AliHBTTwoPairFctn1D(Int_t nbins, Float_t maxXval, Float_t minXval):
867 AliHBTFunction1D(nbins,maxXval,minXval)
868{
869}
870/******************************************************************/
871
872AliHBTTwoPairFctn1D::AliHBTTwoPairFctn1D(const Char_t *name, const Char_t *title):
873 AliHBTFunction1D(name,title)
874{
875}
876/******************************************************************/
877
878AliHBTTwoPairFctn1D::AliHBTTwoPairFctn1D(const Char_t *name, const Char_t *title,
879 Int_t nbins, Float_t maxXval, Float_t minXval):
880 AliHBTFunction1D(name,title,nbins,maxXval,minXval)
881{
882}
883/******************************************************************/
884
885void AliHBTTwoPairFctn1D::ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
886{
887 partpair = CheckPair(partpair);
888 if( partpair )
889 {
890 Double_t x = GetValue(trackpair,partpair);
891 fNumerator->Fill(x);
892 }
893}
894/******************************************************************/
895
896void AliHBTTwoPairFctn1D::ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
897{
898 partpair = CheckPair(partpair);
899 if( partpair )
900 {
901 Double_t x = GetValue(trackpair,partpair);
902 fDenominator->Fill(x);
903 }
904}
905/******************************************************************/
906/******************************************************************/
907/******************************************************************/
908
909//____________________
910///////////////////////////////////////////////////////
911// //
912// AliHBTTwoPairFctn2D //
913// //
914// Base Calss for 2-dimensinal Functions that need //
915// two pair (simulated and reconstructed) //
916// to fill function //
917// //
918// Piotr.Skowronski@cern.ch //
919// http://alisoft.cern.ch/people/skowron/analyzer //
920// //
921///////////////////////////////////////////////////////
922
923ClassImp(AliHBTTwoPairFctn2D)
924
925/******************************************************************/
926
927AliHBTTwoPairFctn2D::AliHBTTwoPairFctn2D(const Char_t *name, const Char_t *title):
928 AliHBTFunction2D(name,title)
929{
930}
931/******************************************************************/
932
933AliHBTTwoPairFctn2D::AliHBTTwoPairFctn2D(Int_t nXbins, Double_t maxXval, Double_t minXval,
934 Int_t nYbins, Double_t maxYval, Double_t minYval):
935 AliHBTFunction2D(nXbins, maxXval, minXval, nYbins, maxYval, minYval)
936{
937}
938/******************************************************************/
939
940AliHBTTwoPairFctn2D::AliHBTTwoPairFctn2D(const Char_t *name, const Char_t *title,
941 Int_t nXbins, Double_t maxXval, Double_t minXval,
942 Int_t nYbins, Double_t maxYval, Double_t minYval):
943 AliHBTFunction2D(name,title,nXbins, maxXval, minXval, nYbins, maxYval, minYval)
944{
945}
946/******************************************************************/
947
948void AliHBTTwoPairFctn2D::ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
1b446896 949{
950 partpair = CheckPair(partpair);
266c51ca 951 if( partpair )
1b446896 952 {
953 Double_t x,y;
954 GetValues(trackpair,partpair,x,y);
19b27ae5 955 fNumerator->Fill(x,y);
1b446896 956 }
957}
26f1270c 958/******************************************************************/
1b446896 959
26f1270c 960void AliHBTTwoPairFctn2D::ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
1b446896 961{
962 partpair = CheckPair(partpair);
266c51ca 963 if( partpair )
1b446896 964 {
965 Double_t x,y;
966 GetValues(trackpair,partpair,x,y);
19b27ae5 967 fDenominator->Fill(x,y);
1b446896 968 }
969
970}
971
ba95ae3f 972/******************************************************************/
973/******************************************************************/
974/******************************************************************/
26f1270c 975
976//____________________
977///////////////////////////////////////////////////////
978// //
979// AliHBTTwoPairFctn3D //
980// //
981// Base Calss for 3-dimensinal Functions that need //
982// two pair (simulated and reconstructed) //
983// to fill function //
984// //
985// Piotr.Skowronski@cern.ch //
986// http://alisoft.cern.ch/people/skowron/analyzer //
987// //
988///////////////////////////////////////////////////////
989
ba95ae3f 990ClassImp(AliHBTTwoPairFctn3D)
991
26f1270c 992/******************************************************************/
993
994AliHBTTwoPairFctn3D::AliHBTTwoPairFctn3D(const Char_t *name, const Char_t *title):
995 AliHBTFunction3D(name,title)
996{
997}
998/******************************************************************/
999
1000AliHBTTwoPairFctn3D::AliHBTTwoPairFctn3D(Int_t nXbins, Double_t maxXval, Double_t minXval,
1001 Int_t nYbins, Double_t maxYval, Double_t minYval,
1002 Int_t nZbins, Double_t maxZval, Double_t minZval):
1003 AliHBTFunction3D(nXbins, maxXval, minXval, nYbins, maxYval, minYval, nZbins, maxZval, minZval)
1004{
1005}
1006/******************************************************************/
1007
1008AliHBTTwoPairFctn3D::AliHBTTwoPairFctn3D(const Char_t *name, const Char_t *title,
1009 Int_t nXbins, Double_t maxXval, Double_t minXval,
1010 Int_t nYbins, Double_t maxYval, Double_t minYval,
1011 Int_t nZbins, Double_t maxZval, Double_t minZval):
1012 AliHBTFunction3D(name,title,nXbins, maxXval, minXval, nYbins, maxYval, minYval, nZbins, maxZval, minZval)
1013{
1014}
1015/******************************************************************/
1016
1017void AliHBTTwoPairFctn3D::ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
ba95ae3f 1018{
1019 partpair = CheckPair(partpair);
266c51ca 1020 if( partpair )
ba95ae3f 1021 {
1022 Double_t x,y,z;
1023 GetValues(trackpair,partpair,x,y,z);
19b27ae5 1024 fNumerator->Fill(x,y,z);
ba95ae3f 1025 }
1026}
26f1270c 1027/******************************************************************/
ba95ae3f 1028
26f1270c 1029void AliHBTTwoPairFctn3D::ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
ba95ae3f 1030{
1031 partpair = CheckPair(partpair);
266c51ca 1032 if( partpair )
ba95ae3f 1033 {
1034 Double_t x,y,z;
1035 GetValues(trackpair,partpair,x,y,z);
19b27ae5 1036 fDenominator->Fill(x,y,z);
ba95ae3f 1037 }
1038
1039}
1040
26f1270c 1041
1042/******************************************************************/
1043/******************************************************************/
1044/******************************************************************/
1045