]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HBTAN/AliHBTFunction.cxx
Repristinating a working loadlibs.C
[u/mrichter/AliRoot.git] / HBTAN / AliHBTFunction.cxx
CommitLineData
1b446896 1#include "AliHBTFunction.h"
2/******************************************************************/
3/*
4Piotr Krzysztof Skowronski
5Piotr.Skowronski@cern.ch
6Base classes for HBT functions
7
8 function
9 / \
10 / \
11 / \
12 / \
13 / \
14 / \
15 / \
27b3fe5d 16 one pair two pair
1b446896 17 / | \ / | \
18 / | \ / | \
19 1D 2D 3D 1D 2D 3D
20
21 four particle functions are intendent to be resolution functions:
22 it is mecessary to have simulated particle pair corresponding to given
23 recontructed track pair in order to calculate function simualted value
24 and recontructed value to be further histogrammed
25
26*/
27/******************************************************************/
28/******************************************************************/
29
30ClassImp( AliHBTFunction )
31
32AliHBTFunction::AliHBTFunction()
33{
ba95ae3f 34 fPairCut = new AliHBTEmptyPairCut(); //dummy cut
35}
36/******************************************************************/
37AliHBTFunction::AliHBTFunction(const char* name,const char* title):TNamed(name,title)
38{
39 fPairCut = new AliHBTEmptyPairCut(); //dummy cut
1b446896 40}
2674b9ff 41/******************************************************************/
42
43AliHBTFunction::~AliHBTFunction()
44 {
8928fd0d 45 delete fPairCut;
2674b9ff 46 }
47/******************************************************************/
1b446896 48
8928fd0d 49void AliHBTFunction::Write()
1b446896 50 {
51 if (GetNumerator()) GetNumerator()->Write();
52 if (GetDenominator()) GetDenominator()->Write();
53 TH1* res = GetResult();
976183fd 54 if (res) res->Write();
1b446896 55 }
56/******************************************************************/
57
266c51ca 58TH1* AliHBTFunction::GetRatio(Double_t normfactor)
1b446896 59 {
266c51ca 60 if (gDebug>0) Info("GetRatio","Norm. Factor is %f for %s",normfactor,GetName());
976183fd 61
62 if (normfactor == 0.0)
63 {
64 Error("GetRatio","Scaling Factor is 0. Null poiner returned");
65 return 0x0;
66 }
1b446896 67 TString str = fName + " ratio";
68 TH1 *result = (TH1*)GetNumerator()->Clone(str.Data());
69
70 result->SetTitle(str.Data());
1b446896 71
72 result->Divide(GetNumerator(),GetDenominator(),normfactor);
73
74 return result;
75
76 }
77/******************************************************************/
78void AliHBTFunction::SetPairCut(AliHBTPairCut* cut)
79{
80//Sets new Pair Cut. Old one is deleted
81//Note that it is created new object instead of simple pointer set
82//I do not want to have pointer
83//to object created somewhere else
84//because in that case I could not believe that
85//it would always exist (sb could delete it)
86//so we have always own copy
87
88 if(!cut)
89 {
90 Error("AliHBTFunction::SetPairCut","argument is NULL");
91 return;
92 }
93 delete fPairCut;
94 fPairCut = (AliHBTPairCut*)cut->Clone();
95
96}
97
98/******************************************************************/
99
8928fd0d 100void AliHBTFunction::Rename(const Char_t * name)
1b446896 101 {
102 //renames the function and histograms
103 SetName(name);
104 SetTitle(name);
105
106 TString numstr = fName + " Numerator"; //title and name of the
107 //numerator histogram
108 TString denstr = fName + " Denominator";//title and name of the
109 //denominator histogram
110
111 GetNumerator()->SetName(numstr.Data());
112 GetNumerator()->SetTitle(numstr.Data());
113
114 GetDenominator()->SetName(denstr.Data());
115 GetDenominator()->SetTitle(denstr.Data());
116
117 }
118
8928fd0d 119void AliHBTFunction::Rename(const Char_t * name, const Char_t * title)
1b446896 120 {
121 //renames and retitle the function and histograms
122
123 SetName(name);
124 SetTitle(title);
125
126 TString numstrn = fName + " Numerator"; //name of the
127 //numerator histogram
128
129 TString numstrt = fTitle + " Numerator"; //title of the
130 //numerator histogram
131
132 TString denstrn = fName + " Denominator";//name of the
133 //denominator histogram
134
135 TString denstrt = fTitle + " Denominator";//title of the
136 //denominator histogram
137
138
139 GetNumerator()->SetName(numstrn.Data());
140 GetNumerator()->SetTitle(numstrt.Data());
141
142 GetDenominator()->SetName(denstrn.Data());
143 GetDenominator()->SetTitle(denstrt.Data());
144
145
146 }
147
148/******************************************************************/
149/******************************************************************/
150/******************************************************************/
151
27b3fe5d 152ClassImp( AliHBTOnePairFctn )
1b446896 153
154/******************************************************************/
155/******************************************************************/
156/******************************************************************/
157
27b3fe5d 158ClassImp( AliHBTTwoPairFctn)
1b446896 159
160/******************************************************************/
161/******************************************************************/
162/******************************************************************/
163
27b3fe5d 164ClassImp( AliHBTOnePairFctn1D )
ba95ae3f 165AliHBTOnePairFctn1D::AliHBTOnePairFctn1D():fNBinsToScale(30)
166 {
167 fNumerator = 0x0;
168 fDenominator = 0x0;
169 }
1b446896 170
27b3fe5d 171AliHBTOnePairFctn1D::
172AliHBTOnePairFctn1D(Int_t nbins, Double_t maxXval, Double_t minXval)
1b446896 173 {
174 //Constructor of Two Part One Dimentional Function
175 // nbins: number of bins in histograms - default 100
176 // maxXval and minXval: range of histgram(s) default 0 - 0.15 (GeV)
177
178
179 TString numstr = fName + " Numerator"; //title and name of the
180 //numerator histogram
181 TString denstr = fName + " Denominator";//title and name of the
182 //denominator histogram
183
184 fNumerator = new TH1D(numstr.Data(),numstr.Data(),nbins,minXval,maxXval);
185 fDenominator = new TH1D(denstr.Data(),denstr.Data(),nbins,minXval,maxXval);
186
187 fNumerator->Sumw2();
188 fDenominator->Sumw2();
189
976183fd 190 fNBinsToScale = 30;
191
1b446896 192 }
ba95ae3f 193AliHBTOnePairFctn1D::
194AliHBTOnePairFctn1D(const Char_t *name, const Char_t *title,
195 Int_t nbins, Double_t maxXval, Double_t minXval)
196 :AliHBTOnePairFctn(name,title)
197{
198 TString numstr = fName + " Numerator"; //title and name of the
199 //numerator histogram
200 TString denstr = fName + " Denominator";//title and name of the
201 //denominator histogram
202
203 fNumerator = new TH1D(numstr.Data(),numstr.Data(),nbins,minXval,maxXval);
204 fDenominator = new TH1D(denstr.Data(),denstr.Data(),nbins,minXval,maxXval);
205
206 fNumerator->Sumw2();
207 fDenominator->Sumw2();
208
209 fNBinsToScale = 30;
210}
1b446896 211/******************************************************************/
27b3fe5d 212AliHBTOnePairFctn1D::~AliHBTOnePairFctn1D()
1b446896 213{
214 delete fNumerator;
215 delete fDenominator;
216}
976183fd 217/******************************************************************/
218
27b3fe5d 219void AliHBTOnePairFctn1D::ProcessSameEventParticles(AliHBTPair* pair)
976183fd 220{
221 //Fills the numerator
222 pair = CheckPair(pair);
223 if(pair) fNumerator->Fill(GetValue(pair));
224}
225/******************************************************************/
27b3fe5d 226void AliHBTOnePairFctn1D::ProcessDiffEventParticles(AliHBTPair* pair)
976183fd 227 {
228 //fills denumerator
229 pair = CheckPair(pair);
230 if(pair) fDenominator->Fill(GetValue(pair));
231
232 }
233/******************************************************************/
27b3fe5d 234Double_t AliHBTOnePairFctn1D::Scale()
976183fd 235{
266c51ca 236 if (gDebug>0) Info("Scale","Enetered Scale()");
976183fd 237 if(!fNumerator)
238 {
239 Error("Scale","No numerator");
240 return 0.0;
241 }
242 if(!fDenominator)
243 {
244 Error("Scale","No denominator");
245 return 0.0;
246 }
247
248 if(fNBinsToScale < 1)
249 {
250 return 0.0;
251 Error("Scale","Number of bins for scaling is smaller thnan 1");
252 }
253 Int_t nbins = fNumerator->GetNbinsX();
254 if (fNBinsToScale > nbins)
255 {
256 Error("Scale","Number of bins for scaling is bigger thnan number of bins in histograms");
257 return 0.0;
258 }
266c51ca 259 if (gDebug>0) Info("Scale","No errors detected");
976183fd 260
2674b9ff 261 Double_t ratio;
262 Double_t sum = 0;
263 Int_t N = 0;
264
976183fd 265 Int_t offset = nbins - fNBinsToScale - 1;
266 Int_t i;
267 for ( i = offset; i< nbins; i++)
268 {
2674b9ff 269 if ( fNumerator->GetBinContent(i) > 0.0 )
976183fd 270 {
2674b9ff 271 ratio = fDenominator->GetBinContent(i)/fNumerator->GetBinContent(i);
272 sum += ratio;
273 N++;
976183fd 274 }
275 }
2674b9ff 276
266c51ca 277 if(gDebug > 0) Info("Scale","sum=%f fNBinsToScale=%d N=%d",sum,fNBinsToScale,N);
2674b9ff 278
279 if (N == 0) return 0.0;
280 Double_t ret = sum/((Double_t)N);
976183fd 281
266c51ca 282 if(gDebug > 0) Info("Scale","returning %f",ret);
2674b9ff 283 return ret;
976183fd 284}
285
1b446896 286/******************************************************************/
287/******************************************************************/
288/******************************************************************/
289
27b3fe5d 290ClassImp( AliHBTOnePairFctn2D )
1b446896 291
27b3fe5d 292AliHBTOnePairFctn2D::
293AliHBTOnePairFctn2D(Int_t nXbins, Double_t maxXval, Double_t minXval ,
1b446896 294 Int_t nYbins, Double_t maxYval, Double_t minYval)
295
296{
297 TString numstr = fName + " Numerator"; //title and name of the
298 //numerator histogram
299 TString denstr = fName + " Denominator";//title and name of the
300 //denominator histogram
301
302 fNumerator = new TH2D(numstr.Data(),numstr.Data(),
303 nXbins,minXval,maxXval,
304 nYbins,minYval,maxYval);
305
306 fDenominator = new TH2D(denstr.Data(),denstr.Data(),
307 nXbins,minXval,maxXval,
308 nYbins,minYval,maxYval);
309
310 fNumerator->Sumw2();
311 fDenominator->Sumw2();
312
313}
27b3fe5d 314AliHBTOnePairFctn2D::~AliHBTOnePairFctn2D()
1b446896 315{
316 delete fNumerator;
317 delete fDenominator;
318}
27b3fe5d 319void AliHBTOnePairFctn2D::ProcessSameEventParticles(AliHBTPair* pair)
1b446896 320{
321 pair = CheckPair(pair);
322 if(pair)
323 {
324 Double_t x,y;
325 GetValues(pair,x,y);
19b27ae5 326 fNumerator->Fill(x,y);
1b446896 327 }
328}
329
27b3fe5d 330void AliHBTOnePairFctn2D::ProcessDiffEventParticles(AliHBTPair* pair)
1b446896 331{
332 pair = CheckPair(pair);
333 if(pair)
334 {
335 Double_t x,y;
336 GetValues(pair,x,y);
19b27ae5 337 fDenominator->Fill(x,y);
1b446896 338 }
339
340}
341
342
343/******************************************************************/
344/******************************************************************/
345/******************************************************************/
346
27b3fe5d 347ClassImp( AliHBTOnePairFctn3D)
1b446896 348
27b3fe5d 349AliHBTOnePairFctn3D::
350AliHBTOnePairFctn3D(Int_t nXbins, Double_t maxXval, Double_t minXval,
1b446896 351 Int_t nYbins, Double_t maxYval, Double_t minYval,
352 Int_t nZbins, Double_t maxZval, Double_t minZval)
353
354{
355 TString numstr = fName + " Numerator"; //title and name of the
356 //numerator histogram
357 TString denstr = fName + " Denominator";//title and name of the
358 //denominator histogram
359
360 fNumerator = new TH3D(numstr.Data(),numstr.Data(),
361 nXbins,minXval,maxXval,
362 nYbins,minYval,maxYval,
363 nZbins,minZval,maxZval);
364
365 fDenominator = new TH3D(denstr.Data(),denstr.Data(),
366 nXbins,minXval,maxXval,
367 nYbins,minYval,maxYval,
368 nZbins,minZval,maxZval);
369
370 fNumerator->Sumw2();
371 fDenominator->Sumw2();
372
373}
ba95ae3f 374/******************************************************************/
7836ee94 375
5a9432a9 376AliHBTOnePairFctn3D::~AliHBTOnePairFctn3D()
7836ee94 377{
378 delete fNumerator;
379 delete fDenominator;
380}
ba95ae3f 381/******************************************************************/
7836ee94 382
7836ee94 383
ba95ae3f 384/******************************************************************/
385/******************************************************************/
386/******************************************************************/
387ClassImp( AliHBTTwoPairFctn1D)
388
389AliHBTTwoPairFctn1D::
390AliHBTTwoPairFctn1D(Int_t nbins, Double_t maxval, Double_t minval)
391 {
392 TString numstr = fName + " Numerator"; //title and name of the
393 //numerator histogram
394 TString denstr = fName + " Denominator";//title and name of the
395 //denominator histogram
396
397 fNumerator = new TH1D(numstr.Data(),numstr.Data(),
398 nbins,minval,maxval);
399
400 fDenominator = new TH1D(denstr.Data(),denstr.Data(),
401 nbins,minval,maxval);
402
403 fNumerator->Sumw2();
404 fDenominator->Sumw2();
8e0e9b48 405 fNBinsToScale = 30;
ba95ae3f 406 }
407
408AliHBTTwoPairFctn1D::
409AliHBTTwoPairFctn1D(const Char_t* name, const Char_t* title,
410 Int_t nbins, Double_t maxval, Double_t minval)
411 :AliHBTTwoPairFctn(name,title)
412 {
413 TString numstr = fName + " Numerator"; //title and name of the
414 //numerator histogram
415 TString denstr = fName + " Denominator";//title and name of the
416 //denominator histogram
417
418 fNumerator = new TH1D(numstr.Data(),numstr.Data(),
419 nbins,minval,maxval);
420
421 fDenominator = new TH1D(denstr.Data(),denstr.Data(),
422 nbins,minval,maxval);
423
424 fNumerator->Sumw2();
425 fDenominator->Sumw2();
8e0e9b48 426 fNBinsToScale = 30;
ba95ae3f 427 }
428
429
430/******************************************************************/
431AliHBTTwoPairFctn1D::~AliHBTTwoPairFctn1D()
432{
433 delete fNumerator;
434 delete fDenominator;
435}
266c51ca 436void AliHBTTwoPairFctn1D::ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
ba95ae3f 437{
438 partpair = CheckPair(partpair);
266c51ca 439 if( partpair )
ba95ae3f 440 {
441 Double_t x = GetValue(trackpair,partpair);
442 fNumerator->Fill(x);
443 }
444}
445/******************************************************************/
446
4e871a8a 447void AliHBTTwoPairFctn1D::ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
ba95ae3f 448{
449 partpair = CheckPair(partpair);
266c51ca 450 if( partpair )
ba95ae3f 451 {
452 Double_t x = GetValue(trackpair,partpair);
453 fDenominator->Fill(x);
454 }
ba95ae3f 455}
4e871a8a 456/******************************************************************/
457Double_t AliHBTTwoPairFctn1D::Scale()
458{
266c51ca 459 if (gDebug>0) Info("Scale","Enetered Scale()");
4e871a8a 460 if(!fNumerator)
461 {
462 Error("Scale","No numerator");
463 return 0.0;
464 }
465 if(!fDenominator)
466 {
467 Error("Scale","No denominator");
468 return 0.0;
469 }
470
471 if(fNBinsToScale < 1)
472 {
473 return 0.0;
474 Error("Scale","Number of bins for scaling is smaller thnan 1");
475 }
476 Int_t nbins = fNumerator->GetNbinsX();
477 if (fNBinsToScale > nbins)
478 {
479 Error("Scale","Number of bins for scaling is bigger thnan number of bins in histograms");
480 return 0.0;
481 }
266c51ca 482 if (gDebug>0) Info("Scale","No errors detected");
4e871a8a 483
484 Double_t ratio;
485 Double_t sum = 0;
486 Int_t N = 0;
487
488 Int_t offset = nbins - fNBinsToScale - 1;
489 Int_t i;
490 for ( i = offset; i< nbins; i++)
491 {
492 if ( fNumerator->GetBinContent(i) > 0.0 )
493 {
494 ratio = fDenominator->GetBinContent(i)/fNumerator->GetBinContent(i);
495 sum += ratio;
496 N++;
497 }
498 }
499
266c51ca 500 if(gDebug > 0) Info("Scale","sum=%f fNBinsToScale=%d N=%d",sum,fNBinsToScale,N);
4e871a8a 501
502 if (N == 0) return 0.0;
503 Double_t ret = sum/((Double_t)N);
504
266c51ca 505 if(gDebug > 0) Info("Scale","returning %f",ret);
4e871a8a 506 return ret;
507}
ba95ae3f 508
1b446896 509/******************************************************************/
510/******************************************************************/
511/******************************************************************/
27b3fe5d 512ClassImp( AliHBTTwoPairFctn2D)
1b446896 513
514
27b3fe5d 515AliHBTTwoPairFctn2D::
516AliHBTTwoPairFctn2D(Int_t nXbins, Double_t maxXval, Double_t minXval ,
1b446896 517 Int_t nYbins, Double_t maxYval, Double_t minYval)
518
519{
520 TString numstr = fName + " Numerator"; //title and name of the
521 //numerator histogram
522 TString denstr = fName + " Denominator";//title and name of the
523 //denominator histogram
524
525 fNumerator = new TH2D(numstr.Data(),numstr.Data(),
526 nXbins,minXval,maxXval,
527 nYbins,minYval,maxYval);
528
529 fDenominator = new TH2D(denstr.Data(),denstr.Data(),
530 nXbins,minXval,maxXval,
531 nYbins,minYval,maxYval);
532
533 fNumerator->Sumw2();
534 fDenominator->Sumw2();
535
536}
27b3fe5d 537AliHBTTwoPairFctn2D::~AliHBTTwoPairFctn2D()
1b446896 538{
539 delete fNumerator;
540 delete fDenominator;
541}
27b3fe5d 542void AliHBTTwoPairFctn2D::
1b446896 543ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
544{
545 partpair = CheckPair(partpair);
266c51ca 546 if( partpair )
1b446896 547 {
548 Double_t x,y;
549 GetValues(trackpair,partpair,x,y);
19b27ae5 550 fNumerator->Fill(x,y);
1b446896 551 }
552}
553
27b3fe5d 554void AliHBTTwoPairFctn2D::
1b446896 555ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
556{
557 partpair = CheckPair(partpair);
266c51ca 558 if( partpair )
1b446896 559 {
560 Double_t x,y;
561 GetValues(trackpair,partpair,x,y);
19b27ae5 562 fDenominator->Fill(x,y);
1b446896 563 }
564
565}
566
ba95ae3f 567/******************************************************************/
568/******************************************************************/
569/******************************************************************/
570ClassImp(AliHBTTwoPairFctn3D)
571
572void AliHBTTwoPairFctn3D::
573ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
574{
575 partpair = CheckPair(partpair);
266c51ca 576 if( partpair )
ba95ae3f 577 {
578 Double_t x,y,z;
579 GetValues(trackpair,partpair,x,y,z);
19b27ae5 580 fNumerator->Fill(x,y,z);
ba95ae3f 581 }
582}
583
584void AliHBTTwoPairFctn3D::
585ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
586{
587 partpair = CheckPair(partpair);
266c51ca 588 if( partpair )
ba95ae3f 589 {
590 Double_t x,y,z;
591 GetValues(trackpair,partpair,x,y,z);
19b27ae5 592 fDenominator->Fill(x,y,z);
ba95ae3f 593 }
594
595}
596