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 /******************************************************************/
31 ClassImp( AliHBTFunction )
33 AliHBTFunction::AliHBTFunction()
36 fPairCut = new AliHBTEmptyPairCut(); //dummy cut
38 /******************************************************************/
40 AliHBTFunction::~AliHBTFunction()
42 if (fPairCut) delete fPairCut;
44 /******************************************************************/
49 if (GetNumerator()) GetNumerator()->Write();
50 if (GetDenominator()) GetDenominator()->Write();
51 TH1* res = GetResult();
52 if (res) res->Write();
54 /******************************************************************/
57 GetRatio(Double_t normfactor)
59 if (gDebug>0) cout<<"Mormfactor is "<<normfactor<<" for "<<fName<<endl;
61 if (normfactor == 0.0)
63 Error("GetRatio","Scaling Factor is 0. Null poiner returned");
66 TString str = fName + " ratio";
67 TH1 *result = (TH1*)GetNumerator()->Clone(str.Data());
69 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::
101 Rename(const Char_t * name)
103 //renames the function and histograms
107 TString numstr = fName + " Numerator"; //title and name of the
108 //numerator histogram
109 TString denstr = fName + " Denominator";//title and name of the
110 //denominator histogram
112 GetNumerator()->SetName(numstr.Data());
113 GetNumerator()->SetTitle(numstr.Data());
115 GetDenominator()->SetName(denstr.Data());
116 GetDenominator()->SetTitle(denstr.Data());
120 void AliHBTFunction::
121 Rename(const Char_t * name, const Char_t * title)
123 //renames and retitle the function and histograms
128 TString numstrn = fName + " Numerator"; //name of the
129 //numerator histogram
131 TString numstrt = fTitle + " Numerator"; //title of the
132 //numerator histogram
134 TString denstrn = fName + " Denominator";//name of the
135 //denominator histogram
137 TString denstrt = fTitle + " Denominator";//title of the
138 //denominator histogram
141 GetNumerator()->SetName(numstrn.Data());
142 GetNumerator()->SetTitle(numstrt.Data());
144 GetDenominator()->SetName(denstrn.Data());
145 GetDenominator()->SetTitle(denstrt.Data());
150 /******************************************************************/
151 /******************************************************************/
152 /******************************************************************/
154 ClassImp( AliHBTTwoPartFctn )
156 /******************************************************************/
157 /******************************************************************/
158 /******************************************************************/
160 ClassImp( AliHBTFourPartFctn)
162 /******************************************************************/
163 /******************************************************************/
164 /******************************************************************/
166 ClassImp( AliHBTTwoPartFctn1D )
168 AliHBTTwoPartFctn1D::
169 AliHBTTwoPartFctn1D(Int_t nbins, Double_t maxXval, Double_t minXval)
171 //Constructor of Two Part One Dimentional Function
172 // nbins: number of bins in histograms - default 100
173 // maxXval and minXval: range of histgram(s) default 0 - 0.15 (GeV)
176 TString numstr = fName + " Numerator"; //title and name of the
177 //numerator histogram
178 TString denstr = fName + " Denominator";//title and name of the
179 //denominator histogram
181 fNumerator = new TH1D(numstr.Data(),numstr.Data(),nbins,minXval,maxXval);
182 fDenominator = new TH1D(denstr.Data(),denstr.Data(),nbins,minXval,maxXval);
185 fDenominator->Sumw2();
190 /******************************************************************/
191 AliHBTTwoPartFctn1D::~AliHBTTwoPartFctn1D()
196 /******************************************************************/
198 void AliHBTTwoPartFctn1D::ProcessSameEventParticles(AliHBTPair* pair)
200 //Fills the numerator
201 pair = CheckPair(pair);
202 if(pair) fNumerator->Fill(GetValue(pair));
204 /******************************************************************/
205 void AliHBTTwoPartFctn1D::ProcessDiffEventParticles(AliHBTPair* pair)
208 pair = CheckPair(pair);
209 if(pair) fDenominator->Fill(GetValue(pair));
212 /******************************************************************/
213 Double_t AliHBTTwoPartFctn1D::Scale()
215 if (gDebug>0) cout<<"Enetered Scale()"<<endl;
218 Error("Scale","No numerator");
223 Error("Scale","No denominator");
227 if(fNBinsToScale < 1)
230 Error("Scale","Number of bins for scaling is smaller thnan 1");
232 Int_t nbins = fNumerator->GetNbinsX();
233 if (fNBinsToScale > nbins)
235 Error("Scale","Number of bins for scaling is bigger thnan number of bins in histograms");
238 if (gDebug>0) cout<<"No errors detected"<<endl;
244 Int_t offset = nbins - fNBinsToScale - 1;
246 for ( i = offset; i< nbins; i++)
248 if ( fNumerator->GetBinContent(i) > 0.0 )
250 ratio = fDenominator->GetBinContent(i)/fNumerator->GetBinContent(i);
256 if(gDebug > 0) cout<<"sum="<<sum<<" fNBinsToScale="<<fNBinsToScale<<" N="<<N<<endl;
258 if (N == 0) return 0.0;
259 Double_t ret = sum/((Double_t)N);
261 if(gDebug > 0) cout<<"Scale() returning "<<ret<<endl;
265 /******************************************************************/
266 /******************************************************************/
267 /******************************************************************/
269 ClassImp( AliHBTTwoPartFctn2D )
271 AliHBTTwoPartFctn2D::
272 AliHBTTwoPartFctn2D(Int_t nXbins, Double_t maxXval, Double_t minXval ,
273 Int_t nYbins, Double_t maxYval, Double_t minYval)
276 TString numstr = fName + " Numerator"; //title and name of the
277 //numerator histogram
278 TString denstr = fName + " Denominator";//title and name of the
279 //denominator histogram
281 fNumerator = new TH2D(numstr.Data(),numstr.Data(),
282 nXbins,minXval,maxXval,
283 nYbins,minYval,maxYval);
285 fDenominator = new TH2D(denstr.Data(),denstr.Data(),
286 nXbins,minXval,maxXval,
287 nYbins,minYval,maxYval);
290 fDenominator->Sumw2();
293 AliHBTTwoPartFctn2D::~AliHBTTwoPartFctn2D()
298 void AliHBTTwoPartFctn2D::ProcessSameEventParticles(AliHBTPair* pair)
300 pair = CheckPair(pair);
305 fNumerator->Fill(y,x);
309 void AliHBTTwoPartFctn2D::ProcessDiffEventParticles(AliHBTPair* pair)
311 pair = CheckPair(pair);
316 fDenominator->Fill(y,x);
322 /******************************************************************/
323 /******************************************************************/
324 /******************************************************************/
326 ClassImp( AliHBTTwoPartFctn3D)
328 AliHBTTwoPartFctn3D::
329 AliHBTTwoPartFctn3D(Int_t nXbins, Double_t maxXval, Double_t minXval,
330 Int_t nYbins, Double_t maxYval, Double_t minYval,
331 Int_t nZbins, Double_t maxZval, Double_t minZval)
334 TString numstr = fName + " Numerator"; //title and name of the
335 //numerator histogram
336 TString denstr = fName + " Denominator";//title and name of the
337 //denominator histogram
339 fNumerator = new TH3D(numstr.Data(),numstr.Data(),
340 nXbins,minXval,maxXval,
341 nYbins,minYval,maxYval,
342 nZbins,minZval,maxZval);
344 fDenominator = new TH3D(denstr.Data(),denstr.Data(),
345 nXbins,minXval,maxXval,
346 nYbins,minYval,maxYval,
347 nZbins,minZval,maxZval);
350 fDenominator->Sumw2();
355 AliHBTTwoPartFctn3D::~AliHBTTwoPartFctn3D()
362 /******************************************************************/
363 /******************************************************************/
364 /******************************************************************/
365 ClassImp( AliHBTFourPartFctn2D)
368 AliHBTFourPartFctn2D::
369 AliHBTFourPartFctn2D(Int_t nXbins, Double_t maxXval, Double_t minXval ,
370 Int_t nYbins, Double_t maxYval, Double_t minYval)
373 TString numstr = fName + " Numerator"; //title and name of the
374 //numerator histogram
375 TString denstr = fName + " Denominator";//title and name of the
376 //denominator histogram
378 fNumerator = new TH2D(numstr.Data(),numstr.Data(),
379 nXbins,minXval,maxXval,
380 nYbins,minYval,maxYval);
382 fDenominator = new TH2D(denstr.Data(),denstr.Data(),
383 nXbins,minXval,maxXval,
384 nYbins,minYval,maxYval);
387 fDenominator->Sumw2();
390 AliHBTFourPartFctn2D::~AliHBTFourPartFctn2D()
395 void AliHBTFourPartFctn2D::
396 ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
398 partpair = CheckPair(partpair);
399 trackpair = CheckPair(trackpair);
400 if( partpair && trackpair)
403 GetValues(trackpair,partpair,x,y);
404 fNumerator->Fill(y,x);
408 void AliHBTFourPartFctn2D::
409 ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
411 partpair = CheckPair(partpair);
412 trackpair = CheckPair(trackpair);
413 if( partpair && trackpair)
416 GetValues(trackpair,partpair,x,y);
417 fDenominator->Fill(y,x);