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
42 if (GetNumerator()) GetNumerator()->Write();
43 if (GetDenominator()) GetDenominator()->Write();
44 TH1* res = GetResult();
45 if (res) res->Write();
47 /******************************************************************/
50 GetRatio(Double_t normfactor)
53 cout<<"Mormfactor is "<<normfactor<<" for "<<fName<<endl;
55 if (normfactor == 0.0)
57 Error("GetRatio","Scaling Factor is 0. Null poiner returned");
60 TString str = fName + " ratio";
61 TH1 *result = (TH1*)GetNumerator()->Clone(str.Data());
63 result->SetTitle(str.Data());
66 result->Divide(GetNumerator(),GetDenominator(),normfactor);
71 /******************************************************************/
72 void AliHBTFunction::SetPairCut(AliHBTPairCut* cut)
74 //Sets new Pair Cut. Old one is deleted
75 //Note that it is created new object instead of simple pointer set
76 //I do not want to have pointer
77 //to object created somewhere else
78 //because in that case I could not believe that
79 //it would always exist (sb could delete it)
80 //so we have always own copy
84 Error("AliHBTFunction::SetPairCut","argument is NULL");
88 fPairCut = (AliHBTPairCut*)cut->Clone();
92 /******************************************************************/
95 Rename(const Char_t * name)
97 //renames the function and histograms
101 TString numstr = fName + " Numerator"; //title and name of the
102 //numerator histogram
103 TString denstr = fName + " Denominator";//title and name of the
104 //denominator histogram
106 GetNumerator()->SetName(numstr.Data());
107 GetNumerator()->SetTitle(numstr.Data());
109 GetDenominator()->SetName(denstr.Data());
110 GetDenominator()->SetTitle(denstr.Data());
114 void AliHBTFunction::
115 Rename(const Char_t * name, const Char_t * title)
117 //renames and retitle the function and histograms
122 TString numstrn = fName + " Numerator"; //name of the
123 //numerator histogram
125 TString numstrt = fTitle + " Numerator"; //title of the
126 //numerator histogram
128 TString denstrn = fName + " Denominator";//name of the
129 //denominator histogram
131 TString denstrt = fTitle + " Denominator";//title of the
132 //denominator histogram
135 GetNumerator()->SetName(numstrn.Data());
136 GetNumerator()->SetTitle(numstrt.Data());
138 GetDenominator()->SetName(denstrn.Data());
139 GetDenominator()->SetTitle(denstrt.Data());
144 /******************************************************************/
145 /******************************************************************/
146 /******************************************************************/
148 ClassImp( AliHBTTwoPartFctn )
150 /******************************************************************/
151 /******************************************************************/
152 /******************************************************************/
154 ClassImp( AliHBTFourPartFctn)
156 /******************************************************************/
157 /******************************************************************/
158 /******************************************************************/
160 ClassImp( AliHBTTwoPartFctn1D )
162 AliHBTTwoPartFctn1D::
163 AliHBTTwoPartFctn1D(Int_t nbins, Double_t maxXval, Double_t minXval)
165 //Constructor of Two Part One Dimentional Function
166 // nbins: number of bins in histograms - default 100
167 // maxXval and minXval: range of histgram(s) default 0 - 0.15 (GeV)
170 TString numstr = fName + " Numerator"; //title and name of the
171 //numerator histogram
172 TString denstr = fName + " Denominator";//title and name of the
173 //denominator histogram
175 fNumerator = new TH1D(numstr.Data(),numstr.Data(),nbins,minXval,maxXval);
176 fDenominator = new TH1D(denstr.Data(),denstr.Data(),nbins,minXval,maxXval);
179 fDenominator->Sumw2();
184 /******************************************************************/
185 AliHBTTwoPartFctn1D::~AliHBTTwoPartFctn1D()
190 /******************************************************************/
192 void AliHBTTwoPartFctn1D::ProcessSameEventParticles(AliHBTPair* pair)
194 //Fills the numerator
195 pair = CheckPair(pair);
196 if(pair) fNumerator->Fill(GetValue(pair));
198 /******************************************************************/
199 void AliHBTTwoPartFctn1D::ProcessDiffEventParticles(AliHBTPair* pair)
202 pair = CheckPair(pair);
203 if(pair) fDenominator->Fill(GetValue(pair));
206 /******************************************************************/
207 Double_t AliHBTTwoPartFctn1D::Scale()
211 Error("Scale","No numerator");
216 Error("Scale","No denominator");
220 if(fNBinsToScale < 1)
223 Error("Scale","Number of bins for scaling is smaller thnan 1");
225 Int_t nbins = fNumerator->GetNbinsX();
226 if (fNBinsToScale > nbins)
228 Error("Scale","Number of bins for scaling is bigger thnan number of bins in histograms");
231 Double_t ratios[fNBinsToScale];
233 Int_t offset = nbins - fNBinsToScale - 1;
235 for ( i = offset; i< nbins; i++)
237 if ( fNumerator->GetBinContent(i) == 0.0 )
239 ratios[i - offset] = -1.0; //since we play with histograms negative is impossible
244 ratios[i - offset] = fDenominator->GetBinContent(i)/fNumerator->GetBinContent(i);
250 for (i = 0; i<fNBinsToScale; i++)
252 if (ratios[i] == -1.0) skipped++;
253 else sum += ratios[i];
255 cout<<"sum="<<sum<<" fNBinsToScale="<<fNBinsToScale<<" skipped="<<skipped<<endl;
257 return sum/(Double_t)(fNBinsToScale - skipped);
260 /******************************************************************/
261 /******************************************************************/
262 /******************************************************************/
264 ClassImp( AliHBTTwoPartFctn2D )
266 AliHBTTwoPartFctn2D::
267 AliHBTTwoPartFctn2D(Int_t nXbins, Double_t maxXval, Double_t minXval ,
268 Int_t nYbins, Double_t maxYval, Double_t minYval)
271 TString numstr = fName + " Numerator"; //title and name of the
272 //numerator histogram
273 TString denstr = fName + " Denominator";//title and name of the
274 //denominator histogram
276 fNumerator = new TH2D(numstr.Data(),numstr.Data(),
277 nXbins,minXval,maxXval,
278 nYbins,minYval,maxYval);
280 fDenominator = new TH2D(denstr.Data(),denstr.Data(),
281 nXbins,minXval,maxXval,
282 nYbins,minYval,maxYval);
285 fDenominator->Sumw2();
288 AliHBTTwoPartFctn2D::~AliHBTTwoPartFctn2D()
293 void AliHBTTwoPartFctn2D::ProcessSameEventParticles(AliHBTPair* pair)
295 pair = CheckPair(pair);
300 fNumerator->Fill(y,x);
304 void AliHBTTwoPartFctn2D::ProcessDiffEventParticles(AliHBTPair* pair)
306 pair = CheckPair(pair);
311 fDenominator->Fill(y,x);
317 /******************************************************************/
318 /******************************************************************/
319 /******************************************************************/
321 ClassImp( AliHBTTwoPartFctn3D)
323 AliHBTTwoPartFctn3D::
324 AliHBTTwoPartFctn3D(Int_t nXbins, Double_t maxXval, Double_t minXval,
325 Int_t nYbins, Double_t maxYval, Double_t minYval,
326 Int_t nZbins, Double_t maxZval, Double_t minZval)
329 TString numstr = fName + " Numerator"; //title and name of the
330 //numerator histogram
331 TString denstr = fName + " Denominator";//title and name of the
332 //denominator histogram
334 fNumerator = new TH3D(numstr.Data(),numstr.Data(),
335 nXbins,minXval,maxXval,
336 nYbins,minYval,maxYval,
337 nZbins,minZval,maxZval);
339 fDenominator = new TH3D(denstr.Data(),denstr.Data(),
340 nXbins,minXval,maxXval,
341 nYbins,minYval,maxYval,
342 nZbins,minZval,maxZval);
345 fDenominator->Sumw2();
350 AliHBTTwoPartFctn3D::~AliHBTTwoPartFctn3D()
357 /******************************************************************/
358 /******************************************************************/
359 /******************************************************************/
360 ClassImp( AliHBTFourPartFctn2D)
363 AliHBTFourPartFctn2D::
364 AliHBTFourPartFctn2D(Int_t nXbins, Double_t maxXval, Double_t minXval ,
365 Int_t nYbins, Double_t maxYval, Double_t minYval)
368 TString numstr = fName + " Numerator"; //title and name of the
369 //numerator histogram
370 TString denstr = fName + " Denominator";//title and name of the
371 //denominator histogram
373 fNumerator = new TH2D(numstr.Data(),numstr.Data(),
374 nXbins,minXval,maxXval,
375 nYbins,minYval,maxYval);
377 fDenominator = new TH2D(denstr.Data(),denstr.Data(),
378 nXbins,minXval,maxXval,
379 nYbins,minYval,maxYval);
382 fDenominator->Sumw2();
385 AliHBTFourPartFctn2D::~AliHBTFourPartFctn2D()
390 void AliHBTFourPartFctn2D::
391 ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
393 partpair = CheckPair(partpair);
394 trackpair = CheckPair(trackpair);
395 if( partpair && trackpair)
398 GetValues(trackpair,partpair,x,y);
399 fNumerator->Fill(y,x);
403 void AliHBTFourPartFctn2D::
404 ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
406 partpair = CheckPair(partpair);
407 trackpair = CheckPair(trackpair);
408 if( partpair && trackpair)
411 GetValues(trackpair,partpair,x,y);
412 fDenominator->Fill(y,x);