/************************************************************************** * Copyright(c) 2007-2009, 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$ */ ////////////////////////////////////////////////////////////////////////// // Alice ITS class to help keep statistical information. Can also be // // used to fit data to lines and other 2 dimentional sytistical // // operations. // // // // version: 0.0.0 Draft. // // Date: April 18 1999 // // By: Bjorn S. Nilsen // // Updated: 1.0.0, Date: September 6 2007, By: Bjorn S. Nilsen // // // ////////////////////////////////////////////////////////////////////////// #include // ios::fmtflags fmt used in PrintAscii #include "Riostream.h" // IO functions. #include "TMath.h" // TMath::Sqrt() function used. #include "AliITSstatistics2.h" // Also defined TObject {base class} ClassImp(AliITSstatistics2) // AliITSstatistics2::AliITSstatistics2() : TObject(), // Base Class fN(-1), // number of enetries -1 => Uninitilized fOrder(0), // maximum moment of distributions (^n) fX(0), //[fOrder] array of sums of x^n fYx(0), //[fOrder] array of sums of (xy)^n fY(0), //[fOrder] array of sums of y^n fW(0) //[fOrder] array of sums of w^n (weights) //,fDig(5) // The number of significant digits to keep //,fOver(0) //! In case of numerical precistion problems { // default constructor // Inputs: // none. // Outputs: // none. // Return: // A default constructed AliITSstatistics class return; } //______________________________________________________________________ AliITSstatistics2::AliITSstatistics2(Int_t order) : TObject(), // Base Class fN(0), // number of enetries -1 => Uninitilized fOrder(order), // maximum moment of distributions (^n) fX(new Double_t[order]), //[fOrder] array of sums of x^n fYx(new Double_t[order]), //[fOrder] array of sums of (xy)^n fY(new Double_t[order]), //[fOrder] array of sums of y^n fW(new Double_t[order]) //[fOrder] array of sums of w^n (weights) //,fDig(5) // The number of significant digits to keep //,fOver(0) //! In case of numeerical precistion problems { // constructor to maximum moment/order order // Inputs: // Int_t order The maximum moment of distributions {for example x^n} Int_t i; for(i=0;ifX[i] = source.fX[i]; this->fYx[i] = source.fYx[i]; this->fY[i] = source.fY[i]; this->fW[i] = source.fW[i]; } // end for i // this->fDig = source.fDig; // if(fOver!=0) this->fOver = new AliITSstatistics2(*(source.fOver)); // else fOver=0; return *this; } //_______________________________________________________________ AliITSstatistics2::AliITSstatistics2(AliITSstatistics2 &source): TObject(source), // Base Class fN(source.GetN()), // number of enetries -1 => Uninitilized fOrder(source.GetOrder()),// maximum moment of distributions (^n) fX(new Double_t[source.GetOrder()]),//[fOrder] array of sums of x^n fYx(new Double_t[source.GetOrder()]),//[fOrder] array of sums of (xy)^n fY(new Double_t[source.GetOrder()]),//[fOrder] array of sums of y^n fW(new Double_t[source.GetOrder()]) //[fOrder] array of sums of w^n (weights) //,fDig(source.fDig) // The number of significant digits to keep //,fOver(0) //! In case of numerical precistion problems { // Copy constructor // Inputs: // AliITSstatistics2 & source the source of this copy // Outputs: // none. // Return: // A copy of the source. for(Int_t i=0;ifX[i] = source.fX[i]; this->fYx[i] = source.fYx[i]; this->fY[i] = source.fY[i]; this->fW[i] = source.fW[i]; } // end for i //if(fOver!=0) this->fOver = new AliITSstatistics2(*(source.fOver)); return; } //______________________________________________________________________ void AliITSstatistics2::Reset(Int_t order){ // Reset/zero all statistics variables statistics // Inputs: // none. // Outputs: // none. // Return: // none. Int_t i; for(i=0;ikBig || x>kBig || w>kBig) return; /* If problem with precision, then creat/fill fOver as a partical sum to be added to "this" later. if(????fDig){ if(fOver==0){ fOver = new AliITSstatistics2(fOrder); } // end if fOver==0 fOver->AddValue(y,x,w); return; } // end if(???) */ fN++; for(i=0;i 2 ios::fmtflags fmt; // Standard IO format object, required for output. #else Int_t fmt; #endif #else #if defined __ICC || defined __ECC || defined __xlC__ ios::fmtflags fmt; #else Int_t fmt; #endif #endif *os << fN <<" "<< GetOrder(); fmt = os->setf(ios::scientific); // set scientific floating point output for(i=0;iflags(fmt); // reset back to old Formating. return; } //______________________________________________________________________ void AliITSstatistics2::ReadAscii(istream *is){ // Read in class data values in Ascii Form to output stream // Inputs: // istream *is Input stream where Ascii data is to be read in from // Outputs: // none. // Return: // none. Int_t i; *is >> i >> fOrder; Reset(fOrder); fN = i; for(i=0;i> fX[i]; for(i=0;i> fYx[i]; for(i=0;i> fY[i]; for(i=0;i> fW[i]; //*is >> fDig; // if(fDig>0) *is >> fOver; // else fDig *= -1; } //______________________________________________________________________ ostream &operator<<(ostream &os,const AliITSstatistics2 &s){ // Standard output streaming function // Inputs: // ostream &os output steam // AliITSstatistics2 &s class to be streamed. // Output: // none. // Return: // ostream &os The stream pointer s.PrintAscii(&os); return os; } //______________________________________________________________________ istream &operator>>(istream &is,AliITSstatistics2 &s){ // Standard inputput streaming function // Inputs: // istream &is input steam // AliITSstatistics2 &s class to be streamed. // Output: // none. // Return: // ostream &os The stream pointer s.ReadAscii(&is); return is; }