/************************************************************************** * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * * * * Author: The ALICE Off-line Project. * * Contributors are mentioned in the code where appropriate. * * * * Permission to use, copy, modify and distribute this software and its * * documentation strictly for non-commercial purposes is hereby granted * * without fee, provided that the above copyright notice appears in all * * copies and that both the copyright notice and this permission notice * * appear in the supporting documentation. The authors make no claims * * about the suitability of this software for any purpose. It is * * provided "as is" without express or implied warranty. * **************************************************************************/ // $Id$ /////////////////////////////////////////////////////////////////////////// // Class AliSample // Perform statistics on various multi-dimensional data samples. // A data sample can be filled using the "Enter" and/or "Remove" functions, // whereas the "Reset" function resets the complete sample to 'empty'. // The info which can be extracted from a certain data sample are the // sum, mean, variance, sigma, covariance and correlation. // The "Data" function provides all statistics data for a certain sample. // The variables for which these stat. parameters have to be calculated // are indicated by the index of the variable which is passed as an // argument to the various member functions. // The index convention for a data point (x,y) is : x=1 y=2 // // Example : // --------- // For an AliSample s a data point (x,y) can be entered as s.Enter(x,y) and // the mean_x can be obtained as s.GetMean(1) whereas the mean_y is obtained // via s.GetMean(2). // The correlation between x and y is available via s.GetCor(1,2). // The x-statistics are obtained via s.Data(1), y-statistics via s.Data(2), // and the covariance and correlation between x and y via s.Data(1,2). // All statistics of a sample are obtained via s.Data(). // //--- Author: Nick van Eijndhoven 30-mar-1996 CERN Geneva //- Modified: NvE $Date$ UU-SAP Utrecht /////////////////////////////////////////////////////////////////////////// #include "AliSample.h" #include "Riostream.h" ClassImp(AliSample) // Class implementation to enable ROOT I/O AliSample::AliSample() { // Creation of an Aliample object and resetting the statistics values // The dimension is initialised to maximum fDim=fMaxdim; fNames[0]='X'; fNames[1]='Y'; fNames[2]='Z'; fN=0; Reset(); } /////////////////////////////////////////////////////////////////////////// AliSample::~AliSample() { // Default destructor } /////////////////////////////////////////////////////////////////////////// void AliSample::Reset() { // Resetting the statistics values for a certain Sample object // Dimension is NOT changed fN=0; for (Int_t i=0; i i) k=j; cout << " *AliSample::cov* Error : Dimension less than " << k << endl; return 0.; } else { return fCov[i-1][j-1]; } } /////////////////////////////////////////////////////////////////////////// Float_t AliSample::GetCor(Int_t i,Int_t j) const { // Provide the correlation between variables i and j if ((fDim < i) || (fDim < j)) { Int_t k=i; if (j > i) k=j; cout << " *AliSample::cor* Error : Dimension less than " << k << endl; return 0.; } else { return fCor[i-1][j-1]; } } /////////////////////////////////////////////////////////////////////////// void AliSample::Data() const { // Printing of statistics of all variables for (Int_t i=0; i