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()
47 /******************************************************************/
49 void AliHBTFunction::Write()
51 if (GetNumerator()) GetNumerator()->Write();
52 if (GetDenominator()) GetDenominator()->Write();
53 TH1* res = GetResult();
54 if (res) res->Write();
56 /******************************************************************/
58 TH1* AliHBTFunction::GetRatio(Double_t normfactor)
60 if (gDebug>0) Info("GetRatio","Norm. Factor is %f for %s",normfactor,GetName());
62 if (normfactor == 0.0)
64 Error("GetRatio","Scaling Factor is 0. Null poiner returned");
67 TString str = fName + " ratio";
68 TH1 *result = (TH1*)GetNumerator()->Clone(str.Data());
70 result->SetTitle(str.Data());
72 result->Divide(GetNumerator(),GetDenominator(),normfactor);
77 /******************************************************************/
78 void AliHBTFunction::SetPairCut(AliHBTPairCut* cut)
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
90 Error("AliHBTFunction::SetPairCut","argument is NULL");
94 fPairCut = (AliHBTPairCut*)cut->Clone();
98 /******************************************************************/
100 void AliHBTFunction::Rename(const Char_t * name)
102 //renames the function and histograms
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
111 GetNumerator()->SetName(numstr.Data());
112 GetNumerator()->SetTitle(numstr.Data());
114 GetDenominator()->SetName(denstr.Data());
115 GetDenominator()->SetTitle(denstr.Data());
119 void AliHBTFunction::Rename(const Char_t * name, const Char_t * title)
121 //renames and retitle the function and histograms
126 TString numstrn = fName + " Numerator"; //name of the
127 //numerator histogram
129 TString numstrt = fTitle + " Numerator"; //title of the
130 //numerator histogram
132 TString denstrn = fName + " Denominator";//name of the
133 //denominator histogram
135 TString denstrt = fTitle + " Denominator";//title of the
136 //denominator histogram
139 GetNumerator()->SetName(numstrn.Data());
140 GetNumerator()->SetTitle(numstrt.Data());
142 GetDenominator()->SetName(denstrn.Data());
143 GetDenominator()->SetTitle(denstrt.Data());
148 /******************************************************************/
149 /******************************************************************/
150 /******************************************************************/
152 ClassImp( AliHBTOnePairFctn )
154 /******************************************************************/
155 /******************************************************************/
156 /******************************************************************/
158 ClassImp( AliHBTTwoPairFctn)
160 /******************************************************************/
161 /******************************************************************/
162 /******************************************************************/
164 ClassImp( AliHBTOnePairFctn1D )
165 AliHBTOnePairFctn1D::AliHBTOnePairFctn1D():fNBinsToScale(30)
171 AliHBTOnePairFctn1D::
172 AliHBTOnePairFctn1D(Int_t nbins, Double_t maxXval, Double_t minXval)
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)
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
184 fNumerator = new TH1D(numstr.Data(),numstr.Data(),nbins,minXval,maxXval);
185 fDenominator = new TH1D(denstr.Data(),denstr.Data(),nbins,minXval,maxXval);
188 fDenominator->Sumw2();
193 AliHBTOnePairFctn1D::
194 AliHBTOnePairFctn1D(const Char_t *name, const Char_t *title,
195 Int_t nbins, Double_t maxXval, Double_t minXval)
196 :AliHBTOnePairFctn(name,title)
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
203 fNumerator = new TH1D(numstr.Data(),numstr.Data(),nbins,minXval,maxXval);
204 fDenominator = new TH1D(denstr.Data(),denstr.Data(),nbins,minXval,maxXval);
207 fDenominator->Sumw2();
211 /******************************************************************/
212 AliHBTOnePairFctn1D::~AliHBTOnePairFctn1D()
217 /******************************************************************/
219 void AliHBTOnePairFctn1D::ProcessSameEventParticles(AliHBTPair* pair)
221 //Fills the numerator
222 pair = CheckPair(pair);
223 if(pair) fNumerator->Fill(GetValue(pair));
225 /******************************************************************/
226 void AliHBTOnePairFctn1D::ProcessDiffEventParticles(AliHBTPair* pair)
229 pair = CheckPair(pair);
230 if(pair) fDenominator->Fill(GetValue(pair));
233 /******************************************************************/
234 Double_t AliHBTOnePairFctn1D::Scale()
236 if (gDebug>0) Info("Scale","Enetered Scale()");
239 Error("Scale","No numerator");
244 Error("Scale","No denominator");
248 if(fNBinsToScale < 1)
251 Error("Scale","Number of bins for scaling is smaller thnan 1");
253 Int_t nbins = fNumerator->GetNbinsX();
254 if (fNBinsToScale > nbins)
256 Error("Scale","Number of bins for scaling is bigger thnan number of bins in histograms");
259 if (gDebug>0) Info("Scale","No errors detected");
265 Int_t offset = nbins - fNBinsToScale - 1;
267 for ( i = offset; i< nbins; i++)
269 if ( fNumerator->GetBinContent(i) > 0.0 )
271 ratio = fDenominator->GetBinContent(i)/fNumerator->GetBinContent(i);
277 if(gDebug > 0) Info("Scale","sum=%f fNBinsToScale=%d N=%d",sum,fNBinsToScale,N);
279 if (N == 0) return 0.0;
280 Double_t ret = sum/((Double_t)N);
282 if(gDebug > 0) Info("Scale","returning %f",ret);
286 /******************************************************************/
287 /******************************************************************/
288 /******************************************************************/
290 ClassImp( AliHBTOnePairFctn2D )
292 AliHBTOnePairFctn2D::
293 AliHBTOnePairFctn2D(Int_t nXbins, Double_t maxXval, Double_t minXval ,
294 Int_t nYbins, Double_t maxYval, Double_t minYval)
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
302 fNumerator = new TH2D(numstr.Data(),numstr.Data(),
303 nXbins,minXval,maxXval,
304 nYbins,minYval,maxYval);
306 fDenominator = new TH2D(denstr.Data(),denstr.Data(),
307 nXbins,minXval,maxXval,
308 nYbins,minYval,maxYval);
311 fDenominator->Sumw2();
314 AliHBTOnePairFctn2D::~AliHBTOnePairFctn2D()
319 void AliHBTOnePairFctn2D::ProcessSameEventParticles(AliHBTPair* pair)
321 pair = CheckPair(pair);
326 fNumerator->Fill(x,y);
330 void AliHBTOnePairFctn2D::ProcessDiffEventParticles(AliHBTPair* pair)
332 pair = CheckPair(pair);
337 fDenominator->Fill(x,y);
343 /******************************************************************/
344 /******************************************************************/
345 /******************************************************************/
347 ClassImp( AliHBTOnePairFctn3D)
349 AliHBTOnePairFctn3D::
350 AliHBTOnePairFctn3D(Int_t nXbins, Double_t maxXval, Double_t minXval,
351 Int_t nYbins, Double_t maxYval, Double_t minYval,
352 Int_t nZbins, Double_t maxZval, Double_t minZval)
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
360 fNumerator = new TH3D(numstr.Data(),numstr.Data(),
361 nXbins,minXval,maxXval,
362 nYbins,minYval,maxYval,
363 nZbins,minZval,maxZval);
365 fDenominator = new TH3D(denstr.Data(),denstr.Data(),
366 nXbins,minXval,maxXval,
367 nYbins,minYval,maxYval,
368 nZbins,minZval,maxZval);
371 fDenominator->Sumw2();
374 /******************************************************************/
376 AliHBTOnePairFctn3D::~AliHBTOnePairFctn3D()
381 /******************************************************************/
384 /******************************************************************/
385 /******************************************************************/
386 /******************************************************************/
387 ClassImp( AliHBTTwoPairFctn1D)
389 AliHBTTwoPairFctn1D::
390 AliHBTTwoPairFctn1D(Int_t nbins, Double_t maxval, Double_t minval)
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
397 fNumerator = new TH1D(numstr.Data(),numstr.Data(),
398 nbins,minval,maxval);
400 fDenominator = new TH1D(denstr.Data(),denstr.Data(),
401 nbins,minval,maxval);
404 fDenominator->Sumw2();
408 AliHBTTwoPairFctn1D::
409 AliHBTTwoPairFctn1D(const Char_t* name, const Char_t* title,
410 Int_t nbins, Double_t maxval, Double_t minval)
411 :AliHBTTwoPairFctn(name,title)
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
418 fNumerator = new TH1D(numstr.Data(),numstr.Data(),
419 nbins,minval,maxval);
421 fDenominator = new TH1D(denstr.Data(),denstr.Data(),
422 nbins,minval,maxval);
425 fDenominator->Sumw2();
430 /******************************************************************/
431 AliHBTTwoPairFctn1D::~AliHBTTwoPairFctn1D()
436 void AliHBTTwoPairFctn1D::ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
438 partpair = CheckPair(partpair);
441 Double_t x = GetValue(trackpair,partpair);
445 /******************************************************************/
447 void AliHBTTwoPairFctn1D::ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
449 partpair = CheckPair(partpair);
452 Double_t x = GetValue(trackpair,partpair);
453 fDenominator->Fill(x);
456 /******************************************************************/
457 Double_t AliHBTTwoPairFctn1D::Scale()
459 if (gDebug>0) Info("Scale","Enetered Scale()");
462 Error("Scale","No numerator");
467 Error("Scale","No denominator");
471 if(fNBinsToScale < 1)
474 Error("Scale","Number of bins for scaling is smaller thnan 1");
476 Int_t nbins = fNumerator->GetNbinsX();
477 if (fNBinsToScale > nbins)
479 Error("Scale","Number of bins for scaling is bigger thnan number of bins in histograms");
482 if (gDebug>0) Info("Scale","No errors detected");
488 Int_t offset = nbins - fNBinsToScale - 1;
490 for ( i = offset; i< nbins; i++)
492 if ( fNumerator->GetBinContent(i) > 0.0 )
494 ratio = fDenominator->GetBinContent(i)/fNumerator->GetBinContent(i);
500 if(gDebug > 0) Info("Scale","sum=%f fNBinsToScale=%d N=%d",sum,fNBinsToScale,N);
502 if (N == 0) return 0.0;
503 Double_t ret = sum/((Double_t)N);
505 if(gDebug > 0) Info("Scale","returning %f",ret);
509 /******************************************************************/
510 /******************************************************************/
511 /******************************************************************/
512 ClassImp( AliHBTTwoPairFctn2D)
515 AliHBTTwoPairFctn2D::
516 AliHBTTwoPairFctn2D(Int_t nXbins, Double_t maxXval, Double_t minXval ,
517 Int_t nYbins, Double_t maxYval, Double_t minYval)
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
525 fNumerator = new TH2D(numstr.Data(),numstr.Data(),
526 nXbins,minXval,maxXval,
527 nYbins,minYval,maxYval);
529 fDenominator = new TH2D(denstr.Data(),denstr.Data(),
530 nXbins,minXval,maxXval,
531 nYbins,minYval,maxYval);
534 fDenominator->Sumw2();
537 AliHBTTwoPairFctn2D::~AliHBTTwoPairFctn2D()
542 void AliHBTTwoPairFctn2D::
543 ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
545 partpair = CheckPair(partpair);
549 GetValues(trackpair,partpair,x,y);
550 fNumerator->Fill(x,y);
554 void AliHBTTwoPairFctn2D::
555 ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
557 partpair = CheckPair(partpair);
561 GetValues(trackpair,partpair,x,y);
562 fDenominator->Fill(x,y);
567 /******************************************************************/
568 /******************************************************************/
569 /******************************************************************/
570 ClassImp(AliHBTTwoPairFctn3D)
572 void AliHBTTwoPairFctn3D::
573 ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
575 partpair = CheckPair(partpair);
579 GetValues(trackpair,partpair,x,y,z);
580 fNumerator->Fill(x,y,z);
584 void AliHBTTwoPairFctn3D::
585 ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
587 partpair = CheckPair(partpair);
591 GetValues(trackpair,partpair,x,y,z);
592 fDenominator->Fill(x,y,z);