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 #include <Riostream.h>
31 ClassImp( AliHBTFunction )
33 AliHBTFunction::AliHBTFunction()
35 fPairCut = new AliHBTEmptyPairCut(); //dummy cut
37 /******************************************************************/
38 AliHBTFunction::AliHBTFunction(const char* name,const char* title):TNamed(name,title)
40 fPairCut = new AliHBTEmptyPairCut(); //dummy cut
42 /******************************************************************/
44 AliHBTFunction::~AliHBTFunction()
46 if (fPairCut) delete fPairCut;
48 /******************************************************************/
53 if (GetNumerator()) GetNumerator()->Write();
54 if (GetDenominator()) GetDenominator()->Write();
55 TH1* res = GetResult();
56 if (res) res->Write();
58 /******************************************************************/
61 GetRatio(Double_t normfactor)
63 if (gDebug>0) cout<<"Mormfactor is "<<normfactor<<" for "<<fName<<endl;
65 if (normfactor == 0.0)
67 Error("GetRatio","Scaling Factor is 0. Null poiner returned");
70 TString str = fName + " ratio";
71 TH1 *result = (TH1*)GetNumerator()->Clone(str.Data());
73 result->SetTitle(str.Data());
76 result->Divide(GetNumerator(),GetDenominator(),normfactor);
81 /******************************************************************/
82 void AliHBTFunction::SetPairCut(AliHBTPairCut* cut)
84 //Sets new Pair Cut. Old one is deleted
85 //Note that it is created new object instead of simple pointer set
86 //I do not want to have pointer
87 //to object created somewhere else
88 //because in that case I could not believe that
89 //it would always exist (sb could delete it)
90 //so we have always own copy
94 Error("AliHBTFunction::SetPairCut","argument is NULL");
98 fPairCut = (AliHBTPairCut*)cut->Clone();
102 /******************************************************************/
104 void AliHBTFunction::
105 Rename(const Char_t * name)
107 //renames the function and histograms
111 TString numstr = fName + " Numerator"; //title and name of the
112 //numerator histogram
113 TString denstr = fName + " Denominator";//title and name of the
114 //denominator histogram
116 GetNumerator()->SetName(numstr.Data());
117 GetNumerator()->SetTitle(numstr.Data());
119 GetDenominator()->SetName(denstr.Data());
120 GetDenominator()->SetTitle(denstr.Data());
124 void AliHBTFunction::
125 Rename(const Char_t * name, const Char_t * title)
127 //renames and retitle the function and histograms
132 TString numstrn = fName + " Numerator"; //name of the
133 //numerator histogram
135 TString numstrt = fTitle + " Numerator"; //title of the
136 //numerator histogram
138 TString denstrn = fName + " Denominator";//name of the
139 //denominator histogram
141 TString denstrt = fTitle + " Denominator";//title of the
142 //denominator histogram
145 GetNumerator()->SetName(numstrn.Data());
146 GetNumerator()->SetTitle(numstrt.Data());
148 GetDenominator()->SetName(denstrn.Data());
149 GetDenominator()->SetTitle(denstrt.Data());
154 /******************************************************************/
155 /******************************************************************/
156 /******************************************************************/
158 ClassImp( AliHBTOnePairFctn )
160 /******************************************************************/
161 /******************************************************************/
162 /******************************************************************/
164 ClassImp( AliHBTTwoPairFctn)
166 /******************************************************************/
167 /******************************************************************/
168 /******************************************************************/
170 ClassImp( AliHBTOnePairFctn1D )
171 AliHBTOnePairFctn1D::AliHBTOnePairFctn1D():fNBinsToScale(30)
177 AliHBTOnePairFctn1D::
178 AliHBTOnePairFctn1D(Int_t nbins, Double_t maxXval, Double_t minXval)
180 //Constructor of Two Part One Dimentional Function
181 // nbins: number of bins in histograms - default 100
182 // maxXval and minXval: range of histgram(s) default 0 - 0.15 (GeV)
185 TString numstr = fName + " Numerator"; //title and name of the
186 //numerator histogram
187 TString denstr = fName + " Denominator";//title and name of the
188 //denominator histogram
190 fNumerator = new TH1D(numstr.Data(),numstr.Data(),nbins,minXval,maxXval);
191 fDenominator = new TH1D(denstr.Data(),denstr.Data(),nbins,minXval,maxXval);
194 fDenominator->Sumw2();
199 AliHBTOnePairFctn1D::
200 AliHBTOnePairFctn1D(const Char_t *name, const Char_t *title,
201 Int_t nbins, Double_t maxXval, Double_t minXval)
202 :AliHBTOnePairFctn(name,title)
204 TString numstr = fName + " Numerator"; //title and name of the
205 //numerator histogram
206 TString denstr = fName + " Denominator";//title and name of the
207 //denominator histogram
209 fNumerator = new TH1D(numstr.Data(),numstr.Data(),nbins,minXval,maxXval);
210 fDenominator = new TH1D(denstr.Data(),denstr.Data(),nbins,minXval,maxXval);
213 fDenominator->Sumw2();
217 /******************************************************************/
218 AliHBTOnePairFctn1D::~AliHBTOnePairFctn1D()
223 /******************************************************************/
225 void AliHBTOnePairFctn1D::ProcessSameEventParticles(AliHBTPair* pair)
227 //Fills the numerator
228 pair = CheckPair(pair);
229 if(pair) fNumerator->Fill(GetValue(pair));
231 /******************************************************************/
232 void AliHBTOnePairFctn1D::ProcessDiffEventParticles(AliHBTPair* pair)
235 pair = CheckPair(pair);
236 if(pair) fDenominator->Fill(GetValue(pair));
239 /******************************************************************/
240 Double_t AliHBTOnePairFctn1D::Scale()
242 if (gDebug>0) cout<<"Enetered Scale()"<<endl;
245 Error("Scale","No numerator");
250 Error("Scale","No denominator");
254 if(fNBinsToScale < 1)
257 Error("Scale","Number of bins for scaling is smaller thnan 1");
259 Int_t nbins = fNumerator->GetNbinsX();
260 if (fNBinsToScale > nbins)
262 Error("Scale","Number of bins for scaling is bigger thnan number of bins in histograms");
265 if (gDebug>0) cout<<"No errors detected"<<endl;
271 Int_t offset = nbins - fNBinsToScale - 1;
273 for ( i = offset; i< nbins; i++)
275 if ( fNumerator->GetBinContent(i) > 0.0 )
277 ratio = fDenominator->GetBinContent(i)/fNumerator->GetBinContent(i);
283 if(gDebug > 0) cout<<"sum="<<sum<<" fNBinsToScale="<<fNBinsToScale<<" N="<<N<<endl;
285 if (N == 0) return 0.0;
286 Double_t ret = sum/((Double_t)N);
288 if(gDebug > 0) cout<<"Scale() returning "<<ret<<endl;
292 /******************************************************************/
293 /******************************************************************/
294 /******************************************************************/
296 ClassImp( AliHBTOnePairFctn2D )
298 AliHBTOnePairFctn2D::
299 AliHBTOnePairFctn2D(Int_t nXbins, Double_t maxXval, Double_t minXval ,
300 Int_t nYbins, Double_t maxYval, Double_t minYval)
303 TString numstr = fName + " Numerator"; //title and name of the
304 //numerator histogram
305 TString denstr = fName + " Denominator";//title and name of the
306 //denominator histogram
308 fNumerator = new TH2D(numstr.Data(),numstr.Data(),
309 nXbins,minXval,maxXval,
310 nYbins,minYval,maxYval);
312 fDenominator = new TH2D(denstr.Data(),denstr.Data(),
313 nXbins,minXval,maxXval,
314 nYbins,minYval,maxYval);
317 fDenominator->Sumw2();
320 AliHBTOnePairFctn2D::~AliHBTOnePairFctn2D()
325 void AliHBTOnePairFctn2D::ProcessSameEventParticles(AliHBTPair* pair)
327 pair = CheckPair(pair);
332 fNumerator->Fill(x,y);
336 void AliHBTOnePairFctn2D::ProcessDiffEventParticles(AliHBTPair* pair)
338 pair = CheckPair(pair);
343 fDenominator->Fill(x,y);
349 /******************************************************************/
350 /******************************************************************/
351 /******************************************************************/
353 ClassImp( AliHBTOnePairFctn3D)
355 AliHBTOnePairFctn3D::
356 AliHBTOnePairFctn3D(Int_t nXbins, Double_t maxXval, Double_t minXval,
357 Int_t nYbins, Double_t maxYval, Double_t minYval,
358 Int_t nZbins, Double_t maxZval, Double_t minZval)
361 TString numstr = fName + " Numerator"; //title and name of the
362 //numerator histogram
363 TString denstr = fName + " Denominator";//title and name of the
364 //denominator histogram
366 fNumerator = new TH3D(numstr.Data(),numstr.Data(),
367 nXbins,minXval,maxXval,
368 nYbins,minYval,maxYval,
369 nZbins,minZval,maxZval);
371 fDenominator = new TH3D(denstr.Data(),denstr.Data(),
372 nXbins,minXval,maxXval,
373 nYbins,minYval,maxYval,
374 nZbins,minZval,maxZval);
377 fDenominator->Sumw2();
380 /******************************************************************/
382 AliHBTOnePairFctn3D::~AliHBTOnePairFctn3D()
387 /******************************************************************/
390 /******************************************************************/
391 /******************************************************************/
392 /******************************************************************/
393 ClassImp( AliHBTTwoPairFctn1D)
395 AliHBTTwoPairFctn1D::
396 AliHBTTwoPairFctn1D(Int_t nbins, Double_t maxval, Double_t minval)
398 TString numstr = fName + " Numerator"; //title and name of the
399 //numerator histogram
400 TString denstr = fName + " Denominator";//title and name of the
401 //denominator histogram
403 fNumerator = new TH1D(numstr.Data(),numstr.Data(),
404 nbins,minval,maxval);
406 fDenominator = new TH1D(denstr.Data(),denstr.Data(),
407 nbins,minval,maxval);
410 fDenominator->Sumw2();
414 AliHBTTwoPairFctn1D::
415 AliHBTTwoPairFctn1D(const Char_t* name, const Char_t* title,
416 Int_t nbins, Double_t maxval, Double_t minval)
417 :AliHBTTwoPairFctn(name,title)
419 TString numstr = fName + " Numerator"; //title and name of the
420 //numerator histogram
421 TString denstr = fName + " Denominator";//title and name of the
422 //denominator histogram
424 fNumerator = new TH1D(numstr.Data(),numstr.Data(),
425 nbins,minval,maxval);
427 fDenominator = new TH1D(denstr.Data(),denstr.Data(),
428 nbins,minval,maxval);
431 fDenominator->Sumw2();
436 /******************************************************************/
437 AliHBTTwoPairFctn1D::~AliHBTTwoPairFctn1D()
442 void AliHBTTwoPairFctn1D::
443 ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
445 partpair = CheckPair(partpair);
446 trackpair = CheckPair(trackpair);
447 if( partpair && trackpair)
449 Double_t x = GetValue(trackpair,partpair);
453 /******************************************************************/
455 void AliHBTTwoPairFctn1D::ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
457 partpair = CheckPair(partpair);
458 trackpair = CheckPair(trackpair);
459 if( partpair && trackpair)
461 Double_t x = GetValue(trackpair,partpair);
462 fDenominator->Fill(x);
466 /******************************************************************/
467 Double_t AliHBTTwoPairFctn1D::Scale()
469 if (gDebug>0) cout<<"Enetered Scale()"<<endl;
472 Error("Scale","No numerator");
477 Error("Scale","No denominator");
481 if(fNBinsToScale < 1)
484 Error("Scale","Number of bins for scaling is smaller thnan 1");
486 Int_t nbins = fNumerator->GetNbinsX();
487 if (fNBinsToScale > nbins)
489 Error("Scale","Number of bins for scaling is bigger thnan number of bins in histograms");
492 if (gDebug>0) cout<<"No errors detected"<<endl;
498 Int_t offset = nbins - fNBinsToScale - 1;
500 for ( i = offset; i< nbins; i++)
502 if ( fNumerator->GetBinContent(i) > 0.0 )
504 ratio = fDenominator->GetBinContent(i)/fNumerator->GetBinContent(i);
510 if(gDebug > 0) cout<<"sum="<<sum<<" fNBinsToScale="<<fNBinsToScale<<" N="<<N<<endl;
512 if (N == 0) return 0.0;
513 Double_t ret = sum/((Double_t)N);
515 if(gDebug > 0) cout<<"Scale() returning "<<ret<<endl;
519 /******************************************************************/
520 /******************************************************************/
521 /******************************************************************/
522 ClassImp( AliHBTTwoPairFctn2D)
525 AliHBTTwoPairFctn2D::
526 AliHBTTwoPairFctn2D(Int_t nXbins, Double_t maxXval, Double_t minXval ,
527 Int_t nYbins, Double_t maxYval, Double_t minYval)
530 TString numstr = fName + " Numerator"; //title and name of the
531 //numerator histogram
532 TString denstr = fName + " Denominator";//title and name of the
533 //denominator histogram
535 fNumerator = new TH2D(numstr.Data(),numstr.Data(),
536 nXbins,minXval,maxXval,
537 nYbins,minYval,maxYval);
539 fDenominator = new TH2D(denstr.Data(),denstr.Data(),
540 nXbins,minXval,maxXval,
541 nYbins,minYval,maxYval);
544 fDenominator->Sumw2();
547 AliHBTTwoPairFctn2D::~AliHBTTwoPairFctn2D()
552 void AliHBTTwoPairFctn2D::
553 ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
555 partpair = CheckPair(partpair);
556 trackpair = CheckPair(trackpair);
557 if( partpair && trackpair)
560 GetValues(trackpair,partpair,x,y);
561 fNumerator->Fill(x,y);
565 void AliHBTTwoPairFctn2D::
566 ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
568 partpair = CheckPair(partpair);
569 trackpair = CheckPair(trackpair);
570 if( partpair && trackpair)
573 GetValues(trackpair,partpair,x,y);
574 fDenominator->Fill(x,y);
579 /******************************************************************/
580 /******************************************************************/
581 /******************************************************************/
582 ClassImp(AliHBTTwoPairFctn3D)
584 void AliHBTTwoPairFctn3D::
585 ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
587 partpair = CheckPair(partpair);
588 trackpair = CheckPair(trackpair);
589 if( partpair && trackpair)
592 GetValues(trackpair,partpair,x,y,z);
593 fNumerator->Fill(x,y,z);
597 void AliHBTTwoPairFctn3D::
598 ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
600 partpair = CheckPair(partpair);
601 trackpair = CheckPair(trackpair);
602 if( partpair && trackpair)
605 GetValues(trackpair,partpair,x,y,z);
606 fDenominator->Fill(x,y,z);