1 #include "AliHBTFunction.h"
2 /******************************************************************/
4 Piotr Krzysztof Skowronski
5 Piotr.Skowronski@cern.ch
6 Base classes for HBT functions
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
27 /******************************************************************/
28 /******************************************************************/
30 ClassImp( AliHBTFunction )
32 AliHBTFunction::AliHBTFunction()
34 fPairCut = new AliHBTEmptyPairCut(); //dummy cut
36 /******************************************************************/
37 AliHBTFunction::AliHBTFunction(const char* name,const char* title):TNamed(name,title)
39 fPairCut = new AliHBTEmptyPairCut(); //dummy cut
41 /******************************************************************/
43 AliHBTFunction::~AliHBTFunction()
45 if (fPairCut) delete fPairCut;
47 /******************************************************************/
52 if (GetNumerator()) GetNumerator()->Write();
53 if (GetDenominator()) GetDenominator()->Write();
54 TH1* res = GetResult();
55 if (res) res->Write();
57 /******************************************************************/
59 TH1* AliHBTFunction::GetRatio(Double_t normfactor)
61 if (gDebug>0) Info("GetRatio","Norm. Factor is %f for %s",normfactor,GetName());
63 if (normfactor == 0.0)
65 Error("GetRatio","Scaling Factor is 0. Null poiner returned");
68 TString str = fName + " ratio";
69 TH1 *result = (TH1*)GetNumerator()->Clone(str.Data());
71 result->SetTitle(str.Data());
73 result->Divide(GetNumerator(),GetDenominator(),normfactor);
78 /******************************************************************/
79 void AliHBTFunction::SetPairCut(AliHBTPairCut* cut)
81 //Sets new Pair Cut. Old one is deleted
82 //Note that it is created new object instead of simple pointer set
83 //I do not want to have pointer
84 //to object created somewhere else
85 //because in that case I could not believe that
86 //it would always exist (sb could delete it)
87 //so we have always own copy
91 Error("AliHBTFunction::SetPairCut","argument is NULL");
95 fPairCut = (AliHBTPairCut*)cut->Clone();
99 /******************************************************************/
101 void AliHBTFunction::
102 Rename(const Char_t * name)
104 //renames the function and histograms
108 TString numstr = fName + " Numerator"; //title and name of the
109 //numerator histogram
110 TString denstr = fName + " Denominator";//title and name of the
111 //denominator histogram
113 GetNumerator()->SetName(numstr.Data());
114 GetNumerator()->SetTitle(numstr.Data());
116 GetDenominator()->SetName(denstr.Data());
117 GetDenominator()->SetTitle(denstr.Data());
121 void AliHBTFunction::
122 Rename(const Char_t * name, const Char_t * title)
124 //renames and retitle the function and histograms
129 TString numstrn = fName + " Numerator"; //name of the
130 //numerator histogram
132 TString numstrt = fTitle + " Numerator"; //title of the
133 //numerator histogram
135 TString denstrn = fName + " Denominator";//name of the
136 //denominator histogram
138 TString denstrt = fTitle + " Denominator";//title of the
139 //denominator histogram
142 GetNumerator()->SetName(numstrn.Data());
143 GetNumerator()->SetTitle(numstrt.Data());
145 GetDenominator()->SetName(denstrn.Data());
146 GetDenominator()->SetTitle(denstrt.Data());
151 /******************************************************************/
152 /******************************************************************/
153 /******************************************************************/
155 ClassImp( AliHBTOnePairFctn )
157 /******************************************************************/
158 /******************************************************************/
159 /******************************************************************/
161 ClassImp( AliHBTTwoPairFctn)
163 /******************************************************************/
164 /******************************************************************/
165 /******************************************************************/
167 ClassImp( AliHBTOnePairFctn1D )
168 AliHBTOnePairFctn1D::AliHBTOnePairFctn1D():fNBinsToScale(30)
174 AliHBTOnePairFctn1D::
175 AliHBTOnePairFctn1D(Int_t nbins, Double_t maxXval, Double_t minXval)
177 //Constructor of Two Part One Dimentional Function
178 // nbins: number of bins in histograms - default 100
179 // maxXval and minXval: range of histgram(s) default 0 - 0.15 (GeV)
182 TString numstr = fName + " Numerator"; //title and name of the
183 //numerator histogram
184 TString denstr = fName + " Denominator";//title and name of the
185 //denominator histogram
187 fNumerator = new TH1D(numstr.Data(),numstr.Data(),nbins,minXval,maxXval);
188 fDenominator = new TH1D(denstr.Data(),denstr.Data(),nbins,minXval,maxXval);
191 fDenominator->Sumw2();
196 AliHBTOnePairFctn1D::
197 AliHBTOnePairFctn1D(const Char_t *name, const Char_t *title,
198 Int_t nbins, Double_t maxXval, Double_t minXval)
199 :AliHBTOnePairFctn(name,title)
201 TString numstr = fName + " Numerator"; //title and name of the
202 //numerator histogram
203 TString denstr = fName + " Denominator";//title and name of the
204 //denominator histogram
206 fNumerator = new TH1D(numstr.Data(),numstr.Data(),nbins,minXval,maxXval);
207 fDenominator = new TH1D(denstr.Data(),denstr.Data(),nbins,minXval,maxXval);
210 fDenominator->Sumw2();
214 /******************************************************************/
215 AliHBTOnePairFctn1D::~AliHBTOnePairFctn1D()
220 /******************************************************************/
222 void AliHBTOnePairFctn1D::ProcessSameEventParticles(AliHBTPair* pair)
224 //Fills the numerator
225 pair = CheckPair(pair);
226 if(pair) fNumerator->Fill(GetValue(pair));
228 /******************************************************************/
229 void AliHBTOnePairFctn1D::ProcessDiffEventParticles(AliHBTPair* pair)
232 pair = CheckPair(pair);
233 if(pair) fDenominator->Fill(GetValue(pair));
236 /******************************************************************/
237 Double_t AliHBTOnePairFctn1D::Scale()
239 if (gDebug>0) Info("Scale","Enetered Scale()");
242 Error("Scale","No numerator");
247 Error("Scale","No denominator");
251 if(fNBinsToScale < 1)
254 Error("Scale","Number of bins for scaling is smaller thnan 1");
256 Int_t nbins = fNumerator->GetNbinsX();
257 if (fNBinsToScale > nbins)
259 Error("Scale","Number of bins for scaling is bigger thnan number of bins in histograms");
262 if (gDebug>0) Info("Scale","No errors detected");
268 Int_t offset = nbins - fNBinsToScale - 1;
270 for ( i = offset; i< nbins; i++)
272 if ( fNumerator->GetBinContent(i) > 0.0 )
274 ratio = fDenominator->GetBinContent(i)/fNumerator->GetBinContent(i);
280 if(gDebug > 0) Info("Scale","sum=%f fNBinsToScale=%d N=%d",sum,fNBinsToScale,N);
282 if (N == 0) return 0.0;
283 Double_t ret = sum/((Double_t)N);
285 if(gDebug > 0) Info("Scale","returning %f",ret);
289 /******************************************************************/
290 /******************************************************************/
291 /******************************************************************/
293 ClassImp( AliHBTOnePairFctn2D )
295 AliHBTOnePairFctn2D::
296 AliHBTOnePairFctn2D(Int_t nXbins, Double_t maxXval, Double_t minXval ,
297 Int_t nYbins, Double_t maxYval, Double_t minYval)
300 TString numstr = fName + " Numerator"; //title and name of the
301 //numerator histogram
302 TString denstr = fName + " Denominator";//title and name of the
303 //denominator histogram
305 fNumerator = new TH2D(numstr.Data(),numstr.Data(),
306 nXbins,minXval,maxXval,
307 nYbins,minYval,maxYval);
309 fDenominator = new TH2D(denstr.Data(),denstr.Data(),
310 nXbins,minXval,maxXval,
311 nYbins,minYval,maxYval);
314 fDenominator->Sumw2();
317 AliHBTOnePairFctn2D::~AliHBTOnePairFctn2D()
322 void AliHBTOnePairFctn2D::ProcessSameEventParticles(AliHBTPair* pair)
324 pair = CheckPair(pair);
329 fNumerator->Fill(x,y);
333 void AliHBTOnePairFctn2D::ProcessDiffEventParticles(AliHBTPair* pair)
335 pair = CheckPair(pair);
340 fDenominator->Fill(x,y);
346 /******************************************************************/
347 /******************************************************************/
348 /******************************************************************/
350 ClassImp( AliHBTOnePairFctn3D)
352 AliHBTOnePairFctn3D::
353 AliHBTOnePairFctn3D(Int_t nXbins, Double_t maxXval, Double_t minXval,
354 Int_t nYbins, Double_t maxYval, Double_t minYval,
355 Int_t nZbins, Double_t maxZval, Double_t minZval)
358 TString numstr = fName + " Numerator"; //title and name of the
359 //numerator histogram
360 TString denstr = fName + " Denominator";//title and name of the
361 //denominator histogram
363 fNumerator = new TH3D(numstr.Data(),numstr.Data(),
364 nXbins,minXval,maxXval,
365 nYbins,minYval,maxYval,
366 nZbins,minZval,maxZval);
368 fDenominator = new TH3D(denstr.Data(),denstr.Data(),
369 nXbins,minXval,maxXval,
370 nYbins,minYval,maxYval,
371 nZbins,minZval,maxZval);
374 fDenominator->Sumw2();
377 /******************************************************************/
379 AliHBTOnePairFctn3D::~AliHBTOnePairFctn3D()
384 /******************************************************************/
387 /******************************************************************/
388 /******************************************************************/
389 /******************************************************************/
390 ClassImp( AliHBTTwoPairFctn1D)
392 AliHBTTwoPairFctn1D::
393 AliHBTTwoPairFctn1D(Int_t nbins, Double_t maxval, Double_t minval)
395 TString numstr = fName + " Numerator"; //title and name of the
396 //numerator histogram
397 TString denstr = fName + " Denominator";//title and name of the
398 //denominator histogram
400 fNumerator = new TH1D(numstr.Data(),numstr.Data(),
401 nbins,minval,maxval);
403 fDenominator = new TH1D(denstr.Data(),denstr.Data(),
404 nbins,minval,maxval);
407 fDenominator->Sumw2();
411 AliHBTTwoPairFctn1D::
412 AliHBTTwoPairFctn1D(const Char_t* name, const Char_t* title,
413 Int_t nbins, Double_t maxval, Double_t minval)
414 :AliHBTTwoPairFctn(name,title)
416 TString numstr = fName + " Numerator"; //title and name of the
417 //numerator histogram
418 TString denstr = fName + " Denominator";//title and name of the
419 //denominator histogram
421 fNumerator = new TH1D(numstr.Data(),numstr.Data(),
422 nbins,minval,maxval);
424 fDenominator = new TH1D(denstr.Data(),denstr.Data(),
425 nbins,minval,maxval);
428 fDenominator->Sumw2();
433 /******************************************************************/
434 AliHBTTwoPairFctn1D::~AliHBTTwoPairFctn1D()
439 void AliHBTTwoPairFctn1D::ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
441 partpair = CheckPair(partpair);
444 Double_t x = GetValue(trackpair,partpair);
448 /******************************************************************/
450 void AliHBTTwoPairFctn1D::ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
452 partpair = CheckPair(partpair);
455 Double_t x = GetValue(trackpair,partpair);
456 fDenominator->Fill(x);
459 /******************************************************************/
460 Double_t AliHBTTwoPairFctn1D::Scale()
462 if (gDebug>0) Info("Scale","Enetered Scale()");
465 Error("Scale","No numerator");
470 Error("Scale","No denominator");
474 if(fNBinsToScale < 1)
477 Error("Scale","Number of bins for scaling is smaller thnan 1");
479 Int_t nbins = fNumerator->GetNbinsX();
480 if (fNBinsToScale > nbins)
482 Error("Scale","Number of bins for scaling is bigger thnan number of bins in histograms");
485 if (gDebug>0) Info("Scale","No errors detected");
491 Int_t offset = nbins - fNBinsToScale - 1;
493 for ( i = offset; i< nbins; i++)
495 if ( fNumerator->GetBinContent(i) > 0.0 )
497 ratio = fDenominator->GetBinContent(i)/fNumerator->GetBinContent(i);
503 if(gDebug > 0) Info("Scale","sum=%f fNBinsToScale=%d N=%d",sum,fNBinsToScale,N);
505 if (N == 0) return 0.0;
506 Double_t ret = sum/((Double_t)N);
508 if(gDebug > 0) Info("Scale","returning %f",ret);
512 /******************************************************************/
513 /******************************************************************/
514 /******************************************************************/
515 ClassImp( AliHBTTwoPairFctn2D)
518 AliHBTTwoPairFctn2D::
519 AliHBTTwoPairFctn2D(Int_t nXbins, Double_t maxXval, Double_t minXval ,
520 Int_t nYbins, Double_t maxYval, Double_t minYval)
523 TString numstr = fName + " Numerator"; //title and name of the
524 //numerator histogram
525 TString denstr = fName + " Denominator";//title and name of the
526 //denominator histogram
528 fNumerator = new TH2D(numstr.Data(),numstr.Data(),
529 nXbins,minXval,maxXval,
530 nYbins,minYval,maxYval);
532 fDenominator = new TH2D(denstr.Data(),denstr.Data(),
533 nXbins,minXval,maxXval,
534 nYbins,minYval,maxYval);
537 fDenominator->Sumw2();
540 AliHBTTwoPairFctn2D::~AliHBTTwoPairFctn2D()
545 void AliHBTTwoPairFctn2D::
546 ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
548 partpair = CheckPair(partpair);
552 GetValues(trackpair,partpair,x,y);
553 fNumerator->Fill(x,y);
557 void AliHBTTwoPairFctn2D::
558 ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
560 partpair = CheckPair(partpair);
564 GetValues(trackpair,partpair,x,y);
565 fDenominator->Fill(x,y);
570 /******************************************************************/
571 /******************************************************************/
572 /******************************************************************/
573 ClassImp(AliHBTTwoPairFctn3D)
575 void AliHBTTwoPairFctn3D::
576 ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
578 partpair = CheckPair(partpair);
582 GetValues(trackpair,partpair,x,y,z);
583 fNumerator->Fill(x,y,z);
587 void AliHBTTwoPairFctn3D::
588 ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
590 partpair = CheckPair(partpair);
594 GetValues(trackpair,partpair,x,y,z);
595 fDenominator->Fill(x,y,z);