1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
20 #include "AliSample.h"
22 AliSample::AliSample()
24 // Creation of an Aliample object and resetting the statistics values
25 // The dimension is initialised to maximum
33 ///////////////////////////////////////////////////////////////////////////
34 AliSample::~AliSample()
38 ///////////////////////////////////////////////////////////////////////////
39 void AliSample::Reset()
41 // Resetting the statistics values for a certain Sample object
42 // Dimension is NOT changed
44 for (Int_t i=0; i<fDim; i++)
50 for (Int_t j=0; j<fDim; j++)
58 ///////////////////////////////////////////////////////////////////////////
59 void AliSample::Enter(Float_t x)
61 // Entering a value into a 1-dim. sample
62 // In case of first entry the dimension is set to 1
72 cout << " *AliSample::enter* Error : Not a 1-dim sample." << endl;
82 ///////////////////////////////////////////////////////////////////////////
83 void AliSample::Remove(Float_t x)
85 // Removing a value from a 1-dim. sample
88 cout << " *AliSample::remove* Error : Not a 1-dim sample." << endl;
98 ///////////////////////////////////////////////////////////////////////////
99 void AliSample::Enter(Float_t x,Float_t y)
101 // Entering a pair (x,y) into a 2-dim. sample
102 // In case of first entry the dimension is set to 2
112 cout << " *AliSample::enter* Error : Not a 2-dim sample." << endl;
126 ///////////////////////////////////////////////////////////////////////////
127 void AliSample::Remove(Float_t x,Float_t y)
129 // Removing a pair (x,y) from a 2-dim. sample
132 cout << " *AliSample::remove* Error : Not a 2-dim sample." << endl;
146 ///////////////////////////////////////////////////////////////////////////
147 void AliSample::Enter(Float_t x,Float_t y,Float_t z)
149 // Entering a set (x,y,z) into a 3-dim. sample
150 // In case of first entry the dimension is set to 3
160 cout << " *AliSample::enter* Error : Not a 3-dim sample." << endl;
180 ///////////////////////////////////////////////////////////////////////////
181 void AliSample::Remove(Float_t x,Float_t y,Float_t z)
183 // Removing a set (x,y,z) from a 3-dim. sample
186 cout << " *AliSample::remove* Error : Not a 3-dim sample." << endl;
206 ///////////////////////////////////////////////////////////////////////////
207 void AliSample::Compute()
209 // Computation of the various statistical values
210 // after each entering or removing action on a certain sample
212 for (Int_t k=0; k<fDim; k++)
215 fVar[k]=(fSum2[k][k]/rn)-(fMean[k]*fMean[k]);
216 if (fVar[k] < 0.) fVar[k]=0.;
217 fSigma[k]=sqrt(fVar[k]);
219 for (Int_t i=0; i<fDim; i++)
221 for (Int_t j=0; j<fDim; j++)
223 fCov[i][j]=(fSum2[i][j]/rn)-(fMean[i]*fMean[j]);
224 Float_t sigij=fSigma[i]*fSigma[j];
225 if (sigij != 0.) fCor[i][j]=fCov[i][j]/sigij;
229 ///////////////////////////////////////////////////////////////////////////
230 Int_t AliSample::GetDimension()
232 // Provide the dimension of a certain sample
235 ///////////////////////////////////////////////////////////////////////////
236 Int_t AliSample::GetN()
238 // Provide the number of entries of a certain sample
241 ///////////////////////////////////////////////////////////////////////////
242 Float_t AliSample::GetSum(Int_t i)
244 // Provide the sum of a certain variable
247 cout << " *AliSample::sum* Error : Dimension less than " << i << endl;
255 ///////////////////////////////////////////////////////////////////////////
256 Float_t AliSample::GetMean(Int_t i)
258 // Provide the mean of a certain variable
261 cout << " *AliSample::mean* Error : Dimension less than " << i << endl;
269 ///////////////////////////////////////////////////////////////////////////
270 Float_t AliSample::GetVar(Int_t i)
272 // Provide the variance of a certain variable
275 cout << " *AliSample::var* Error : Dimension less than " << i << endl;
283 ///////////////////////////////////////////////////////////////////////////
284 Float_t AliSample::GetSigma(Int_t i)
286 // Provide the standard deviation of a certain variable
289 cout << " *AliSample::sigma* Error : Dimension less than " << i << endl;
297 ///////////////////////////////////////////////////////////////////////////
298 Float_t AliSample::GetCov(Int_t i,Int_t j)
300 // Provide the covariance between variables i and j
301 if ((fDim < i) || (fDim < j))
305 cout << " *AliSample::cov* Error : Dimension less than " << k << endl;
310 return fCov[i-1][j-1];
313 ///////////////////////////////////////////////////////////////////////////
314 Float_t AliSample::GetCor(Int_t i,Int_t j)
316 // Provide the correlation between variables i and j
317 if ((fDim < i) || (fDim < j))
321 cout << " *AliSample::cor* Error : Dimension less than " << k << endl;
326 return fCor[i-1][j-1];
329 ///////////////////////////////////////////////////////////////////////////
330 void AliSample::Info()
332 // Printing of statistics of all variables
333 for (Int_t i=0; i<fDim; i++)
335 cout << " " << fNames[i] << " : N = " << fN;
336 cout << " Sum = " << fSum[i] << " Mean = " << fMean[i];
337 cout << " Var = " << fVar[i] << " Sigma = " << fSigma[i] << endl;
340 ///////////////////////////////////////////////////////////////////////////
341 void AliSample::Info(Int_t i)
343 // Printing of statistics of ith variable
346 cout << " *AliSample::Info(i)* Error : Dimension less than " << i << endl;
350 cout << " " << fNames[i-1] << " : N = " << fN;
351 cout << " Sum = " << fSum[i-1] << " Mean = " << fMean[i-1];
352 cout << " Var = " << fVar[i-1] << " Sigma = " << fSigma[i-1] << endl;
355 ///////////////////////////////////////////////////////////////////////////
356 void AliSample::Info(Int_t i,Int_t j)
358 // Printing of covariance and correlation between variables i and j
359 if ((fDim < i) || (fDim < j))
363 cout << " *AliSample::Info(i,j)* Error : Dimension less than " << k << endl;
367 cout << " " << fNames[i-1] << "-" << fNames[j-1] << " correlation :";
368 cout << " Cov. = " << fCov[i-1][j-1] << " Cor. = " << fCor[i-1][j-1] << endl;
371 ///////////////////////////////////////////////////////////////////////////