]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Now have consistant definition of slope and intersept in line fit and
authornilsen <nilsen@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 10 Oct 2006 18:39:26 +0000 (18:39 +0000)
committernilsen <nilsen@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 10 Oct 2006 18:39:26 +0000 (18:39 +0000)
fixed up coding convension violations.

ITS/AliITSstatistics2.cxx
ITS/AliITSstatistics2.h

index 705f21bc6ef8c6fc8f284c8966ae2410a25c61cc..ebdba4613fd96afd37fa0709ec4e0fe6bf0c6394 100644 (file)
 ClassImp(AliITSstatistics2)
 
 //
-AliITSstatistics2::AliITSstatistics2() : TObject(){
-//
-// default constructor
-//
-    fX  = 0;
-    fY  = 0;
-    fYx = 0;
-    fW  = 0;
-    fN  = 0;
-    fOrder = 0;
+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)
+    // 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)
+    // constructor to maximum moment/order order
+    // Inputs:
+    //   Int_t order   The maximum moment of distributions {for example x^n}
+    Int_t i;
 
-
-AliITSstatistics2::AliITSstatistics2(Int_t order) : TObject(){
-//
-// constructor to maximum moment/order order
-//
-    fOrder = order;
-    fX     = new Double_t[order];
-    fY     = new Double_t[order];
-    fYx    = new Double_t[order];
-    fW     = new Double_t[order];
-    for(Int_t i=0;i<order;i++) {fX[i] = 0.0;fY[i] = 0.0;
-                                fYx[i] = 0.0; fW[i] = 0.0;}
+    for(i=0;i<order;i++) {
+        fX[i]  = 0.0;
+        fY[i]  = 0.0;
+        fYx[i] = 0.0;
+        fW[i]  = 0.0;
+    } // end for i
     fN = 0;
     return;
 }
-
+//______________________________________________________________________
 AliITSstatistics2::~AliITSstatistics2(){
-//
-// destructor
-//
+    // destructor
+    // Inputs:
+    //   none.
+    // Outputs:
+    //   none.
+    // Return:
+    //   none.
+
     if(fX!=0)  delete[] fX;
     if(fY!=0)  delete[] fY;
     if(fYx!=0) delete[] fYx;
@@ -58,74 +76,107 @@ AliITSstatistics2::~AliITSstatistics2(){
     fN  = 0;
     fOrder = 0;
 }
-
 //_______________________________________________________________
 AliITSstatistics2& AliITSstatistics2::operator=(AliITSstatistics2 &source){
-// operator =
-
-     if(this==&source) return *this;
-         if(source.fOrder!=0){
-              this->fOrder = source.fOrder;
-                        this->fN = source.fN;
-                        this->fX = new Double_t[this->fOrder];
-                        this->fW = new Double_t[this->fOrder];
-                        for(Int_t i=0;i<source.fOrder;i++){
-                             this->fX[i] = source.fX[i];
-                                       this->fW[i] = source.fW[i];
-                        } // end for i
-         }else{
-              this->fX = 0;
-                        this->fW = 0;
-                        this->fN = 0;
-                        this->fOrder = 0;
-         }// end if source.fOrder!=0
-         return *this;
+    // operator =
+    // Inputs:
+    //   AliITSstaticstics2 &source The source of this copy.
+    // Outputs:
+    //   none.
+    // Return:
+    //   A copy of the source class
+
+    if(this==&source) return *this;
+    TObject::operator=(source);
+    Reset(source.GetOrder());
+    fN = source.GetN();
+    fOrder=source.GetOrder();
+    for(Int_t i=0;i<source.fOrder;i++){
+        this->fX[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
+    return *this;
 }
 //_______________________________________________________________
-AliITSstatistics2::AliITSstatistics2(AliITSstatistics2 &source):
-    TObject(source){
-// Copy constructor
-
-     if(this==&source) return;
-         if(source.fOrder!=0){
-              this->fOrder = source.fOrder;
-                        this->fN = source.fN;
-                        this->fX = new Double_t[this->fOrder];
-                        this->fW = new Double_t[this->fOrder];
-                        for(Int_t i=0;i<source.fOrder;i++){
-                             this->fX[i] = source.fX[i];
-                                       this->fW[i] = source.fW[i];
-                        } // end for i
-         }else{
-              this->fX = 0;
-                        this->fW = 0;
-                        this->fN = 0;
-                        this->fOrder = 0;
-         }// end if source.fOrder!=0
+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)
+    // Copy constructor
+    // Inputs:
+    //   AliITSstatistics2 & source the source of this copy
+    // Outputs:
+    //   none.
+    // Return:
+    //   A copy of the source.
+
+    if(this==&source) return;
+    for(Int_t i=0;i<source.fOrder;i++){
+        this->fX[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
 }
+//______________________________________________________________________
+void AliITSstatistics2::Reset(Int_t order){
+    // Reset/zero all statistics variables statistics
+    // Inputs:
+    //   none.
+    // Outputs:
+    //   none.
+    // Return:
+    //   none.
+    Int_t i;
 
-void AliITSstatistics2::Reset(){
-//
-// Reset/zero statistics
-//
-    for(Int_t i=0;i<fOrder;i++) {fX[i] = 0.0;fY[i] = 0.0;
-                                fYx[i] = 0.0; fW[i] = 0.0;}
+    for(i=0;i<fOrder;i++) {
+        fX[i] = 0.0;
+        fY[i] = 0.0;
+        fYx[i] = 0.0;
+        fW[i] = 0.0;
+    } // end for i
     fN = 0;
+    if(order<0) return; // just zero
+    if(fX!=0)  delete[] fX;
+    if(fY!=0)  delete[] fY;
+    if(fYx!=0) delete[] fYx;
+    if(fW!=0)  delete[] fW;
+    fX  = 0;
+    fY  = 0;
+    fYx = 0;
+    fW  = 0;
+    fN  = 0;
+    fOrder = 0;
+    if(order==0) return;
+    fOrder = order;
+    fX =  new Double_t[fOrder];
+    fY =  new Double_t[fOrder];
+    fYx = new Double_t[fOrder];
+    fW =  new Double_t[fOrder];
     return;
 }
-
+//______________________________________________________________________
 void AliITSstatistics2::AddValue(Double_t y,Double_t x,Double_t w=1.0){
-//
-// add next x,y pair to statistics
-//
+    // add next x,y pair to statistics
+    // Inputs:
+    //   Double_t  y    y value of pair
+    //   Double_t  x    x value of pair
+    //   Double_t  w    weight of pair
+    // Outputs:
+    //   none.
+    // Return:
+    //   none.
     Double_t xs=1.0,ys=1.0,yxs=1.0,ws=1.0;
     Int_t i;
-
     const Double_t kBig=1.0e+38;
 
     if(y>kBig || x>kBig || w>kBig) return;
-
-
     fN++;
     for(i=0;i<fOrder;i++){
        xs  *= x;
@@ -138,50 +189,72 @@ void AliITSstatistics2::AddValue(Double_t y,Double_t x,Double_t w=1.0){
        fW[i]  += ws;
     } // end for i
 }
-
-Double_t AliITSstatistics2::GetXNth(Int_t order){
-//
-// This give the unbiased estimator for the RMS.
-//
-
+//______________________________________________________________________
+Double_t AliITSstatistics2::GetXNth(Int_t order)const{
+    // This give the unbiased estimator for the RMS.
+    // Inputs:
+    //   Int_t order   the order of x^n value to be returned
+    // Output:
+    //   none.
+    // Return:
+    //   The value sum{x^n}.
     Double_t s;
 
     if(fW[0]!=0.0&&order<=fOrder) s = fX[order-1]/fW[0];
     else {
        s = 0.0;
-       printf("AliITSstatistics2: error in GetNth: fOrder=%d fN=%d fW[0]=%f\n",
-              fOrder,fN,fW[0]);
+       Error("GetXNth","error fOrder=%d fN=%d fW[0]=%f\n",
+              fOrder,fN,fW[0]);
     } // end else
     return s;
 }
-Double_t AliITSstatistics2::GetYNth(Int_t order){
-//
-// This give the unbiased estimator for the RMS.
-//
+//______________________________________________________________________
+Double_t AliITSstatistics2::GetYNth(Int_t order)const{
+    // This give the unbiased estimator for the RMS.
+    // Inputs:
+    //   Int_t order   the order of y^n value to be returned
+    // Outputs:
+    //   none.
+    // Return:
+    //  The value sum{y^n}
     Double_t s;
 
     if(fW[0]!=0.0&&order<=fOrder) s = fY[order-1]/fW[0];
     else {
        s = 0.0;
-       printf("AliITSstatistics2: error in GetNth: fOrder=%d fN=%d fW[0]=%f\n",
-              fOrder,fN,fW[0]);
+       Error("GetYNth","fOrder=%d fN=%d fW[0]=%f\n",
+              fOrder,fN,fW[0]);
     } // end else
     return s;
 }
-Double_t AliITSstatistics2::GetYXNth(Int_t order){
-// This give the unbiased estimator for the RMS.
+//______________________________________________________________________
+Double_t AliITSstatistics2::GetYXNth(Int_t order)const{
+    // This give the unbiased estimator for the RMS.
+    // Inputs:
+    //   Int_t order   the order of (xy)^n value to be returned
+    // Outputs:
+    //   none.
+    // Return:
+    //  The value sum{(xy)^n}
     Double_t s;
 
     if(fW[0]!=0.0&&order<=fOrder) s = fYx[order-1]/fW[0];
     else {
        s = 0.0;
-       printf("AliITSstatistics2: error in GetNth: fOrder=%d fN=%d fW[0]=%f\n",
+       Error("GetYXNth","fOrder=%d fN=%d fW[0]=%f\n",
               fOrder,fN,fW[0]);
     } // end else
     return s;
 }
-Double_t AliITSstatistics2::GetRMSX(){
-// This give the unbiased estimator for the RMS.
+//______________________________________________________________________
+Double_t AliITSstatistics2::GetRMSX()const{
+    // This give the unbiased estimator for the RMS.
+    // Inputs:
+    //   none.
+    // Outputs:
+    //   none.
+    // Return:
+    //  The rms value
     Double_t x,x2,w,ww,s;
 
     x  = GetMeanX(); // first order
@@ -193,8 +266,15 @@ Double_t AliITSstatistics2::GetRMSX(){
     s = (x2-x*x)*w*w/(w*w-ww);
     return TMath::Sqrt(s);
 }
-Double_t AliITSstatistics2::GetRMSY(){
-// This give the unbiased estimator for the RMS.
+//______________________________________________________________________
+Double_t AliITSstatistics2::GetRMSY()const{
+    // This give the unbiased estimator for the RMS.
+    // Inputs:
+    //   none.
+    // Outputs:
+    //   none.
+    // Return:
+    //  The rms value
     Double_t x,x2,w,ww,s;
 
     x  = GetMeanY(); // first order
@@ -206,8 +286,15 @@ Double_t AliITSstatistics2::GetRMSY(){
     s = (x2-x*x)*w*w/(w*w-ww);
     return TMath::Sqrt(s);
 }
-Double_t AliITSstatistics2::GetRMSYX(){
-// This give the unbiased estimator for the RMS.
+//______________________________________________________________________
+Double_t AliITSstatistics2::GetRMSYX()const{
+    // This give the unbiased estimator for the RMS.
+    // Inputs:
+    //   none.
+    // Outputs:
+    //   none.
+    // Return:
+    //  The rms value
     Double_t x,x2,w,ww,s;
 
     x  = GetMeanYX(); // first order
@@ -219,8 +306,16 @@ Double_t AliITSstatistics2::GetRMSYX(){
     s = (x2-x*x)*w*w/(w*w-ww);
     return TMath::Sqrt(s);
 }
-Double_t AliITSstatistics2::GetErrorMeanY(){
-//This is the error in the mean or the square root of the variance of the mean.
+//______________________________________________________________________
+Double_t AliITSstatistics2::GetErrorMeanY()const{
+    //This is the error in the mean or the square root of the 
+    // variance of the mean.
+    // Inputs:
+    //   none.
+    // Outputs:
+    //   none.
+    // Return:
+    //  The error on the mean
     Double_t rms,w,ww,s;
 
     rms = GetRMSY();
@@ -229,8 +324,16 @@ Double_t AliITSstatistics2::GetErrorMeanY(){
     s   = rms*rms*ww/(w*w);
     return TMath::Sqrt(s);
 }
-Double_t AliITSstatistics2::GetErrorMeanX(){
-//This is the error in the mean or the square root of the variance of the mean.
+//______________________________________________________________________
+Double_t AliITSstatistics2::GetErrorMeanX()const{
+    //This is the error in the mean or the square root of the 
+    // variance of the mean.
+    // Inputs:
+    //   none.
+    // Outputs:
+    //   none.
+    // Return:
+    //  The error on the mean
     Double_t rms,w,ww,s;
 
     rms = GetRMSX();
@@ -239,8 +342,16 @@ Double_t AliITSstatistics2::GetErrorMeanX(){
     s   = rms*rms*ww/(w*w);
     return TMath::Sqrt(s);
 }
-Double_t AliITSstatistics2::GetErrorMeanYX(){
-//This is the error in the mean or the square root of the variance of the mean.
+//______________________________________________________________________
+Double_t AliITSstatistics2::GetErrorMeanYX()const{
+    //This is the error in the mean or the square root of the 
+    // variance of the mean.
+    // Inputs:
+    //   none.
+    // Outputs:
+    //   none.
+    // Return:
+    //  The error on the mean
     Double_t rms,w,ww,s;
 
     rms = GetRMSYX();
@@ -249,11 +360,17 @@ Double_t AliITSstatistics2::GetErrorMeanYX(){
     s   = rms*rms*ww/(w*w);
     return TMath::Sqrt(s);
 }
-
-
-Double_t AliITSstatistics2::GetErrorRMSY(){
-//This is the error in the mean or the square root of the variance of the mean.
-// at this moment this routine is only defined for weights=1.
+//______________________________________________________________________
+Double_t AliITSstatistics2::GetErrorRMSY()const{
+    // This is the error in the mean or the square root of the variance 
+    // of the mean. at this moment this routine is only defined for 
+    // weights=1.
+    // Inputs:
+    //   none.
+    // Outputs:
+    //   none.
+    // Return:
+    //  The error on the rms
     Double_t x,x2,x3,x4,w,ww,m2,m4,n,s;
 
     if(fW[0]!=(Double_t)fN||GetN()<4) return (-1.);
@@ -268,14 +385,22 @@ Double_t AliITSstatistics2::GetErrorRMSY(){
     n   = (Double_t) GetN();
     x3  = GetYNth(3);
     x4  = GetYNth(4);
-// This equation assumes that all of the weights are equal to 1.
+    // This equation assumes that all of the weights are equal to 1.
     m4  = (n/(n-1.))*(x4-3.*x*x3+6.*x*x*x2-2.*x*x*x*x);
     s   = (m4-(n-3.)*m2*m2/(n-1.))/n;
     return TMath::Sqrt(s);
 }
-Double_t AliITSstatistics2::GetErrorRMSX(){
-//This is the error in the mean or the square root of the variance of the mean.
-// at this moment this routine is only defined for weights=1.
+//______________________________________________________________________
+Double_t AliITSstatistics2::GetErrorRMSX()const{
+    // This is the error in the mean or the square root of the variance 
+    // of the mean. at this moment this routine is only defined for 
+    // weights=1.
+    // Inputs:
+    //   none.
+    // Outputs:
+    //   none.
+    // Return:
+    //  The error on the rms
     Double_t x,x2,x3,x4,w,ww,m2,m4,n,s;
 
     if(fW[0]!=(Double_t)fN||GetN()<4) return (-1.);
@@ -295,9 +420,17 @@ Double_t AliITSstatistics2::GetErrorRMSX(){
     s   = (m4-(n-3.)*m2*m2/(n-1.))/n;
     return TMath::Sqrt(s);
 }
-Double_t AliITSstatistics2::GetErrorRMSYX(){
-//This is the error in the mean or the square root of the variance of the mean.
-// at this moment this routine is only defined for weights=1.
+//______________________________________________________________________
+Double_t AliITSstatistics2::GetErrorRMSYX()const{
+    // This is the error in the mean or the square root of the variance 
+    // of the mean. at this moment this routine is only defined for 
+    // weights=1.
+    // Inputs:
+    //   none.
+    // Outputs:
+    //   none.
+    // Return:
+    //  The error on the rms
     Double_t x,x2,x3,x4,w,ww,m2,m4,n,s;
 
     if(fW[0]!=(Double_t)fN||GetN()<4) return (-1.);
@@ -312,34 +445,140 @@ Double_t AliITSstatistics2::GetErrorRMSYX(){
     n   = (Double_t) GetN();
     x3  = GetYXNth(3);
     x4  = GetYXNth(4);
-// This equation assumes that all of the weights are equal to 1.
+    // This equation assumes that all of the weights are equal to 1.
     m4  = (n/(n-1.))*(x4-3.*x*x3+6.*x*x*x2-2.*x*x*x*x);
     s   = (m4-(n-3.)*m2*m2/(n-1.))/n;
     return TMath::Sqrt(s);
 }
 //_______________________________________________________________________
-Double_t AliITSstatistics2::FitToLine(Double_t &a,Double_t &b){
-// fit to y = a+bx returns Chi squared or -1.0 if an error
+Double_t AliITSstatistics2::FitToLine(Double_t &a,Double_t &b)const{
+    // fit to y = ax+b returns Chi squared or -1.0 if an error
+    // Inputs:
+    //   none.
+    // Outputs:
+    //   Double_t  a   The slope parameter
+    //   Double_t  b   The intercept paramter
+    // Return:
+    //  The Chi^2 of the fit
     Double_t c,d,e,f,g,h;
 
     a = b = 0.0;
-    if(fOrder<2 || fN<3) return -1.0;
+    if(fOrder<2 || fN<3){
+        Error("FitToLine","Order=%d<2 or N=%d<3",fOrder,fN);
+        return -1.0;
+    } // end if
     c = GetWN(1);
     d = GetYN(1);
     e = GetXN(1);
     f = GetYXN(1);
     g = GetXN(2);
     h = c*g-e*e;
-    a = d*g-f*e;
-    b = c*f-d*e;
+    b = d*g-f*e;
+    a = c*f-d*e;
     if(h!=0.0){
        a = a/h;
        b = b/h;
     }else{
-       printf("AliITSstatistics2: Error in FitToLine vertical line\n");
+       Error("FitToLine","vertical line: fOrder=%d fN=%d "
+              "GetWN(1)=%g X GetXN(2)=%g - GetXN(1)=%g^2 = 0",fOrder,fN,c,g,e);
        return -1.0;
     } // end if h
-    h = GetYN(2)+a*a*c+b*b*g-2.0*a*d-2.0*b*f+2.0*a*b*e;
-    h /= (Double_t)fN - 2.0;
-    return h;
+    return GetChiSquared(a,b);
+}
+//_______________________________________________________________________
+Double_t AliITSstatistics2::GetChiSquared(Double_t a,Double_t b)const{
+    //  returns Chi^2 value of data to line y=ax+b with given a,b
+    // Inputs:
+    //   Double_t  a   The slope parameter
+    //   Double_t  b   The intercept paramter
+    // Outputs::
+    //   none.
+    // Return:
+    //  The Chi^2 of the fit
+    Double_t c2;
+
+    c2 = GetYN(2)+b*b*GetWN(1)+
+        a*a*GetXN(2)-2.0*b*GetYN(1)-2.0*a*GetYXN(1)+2.0*b*a*GetXN(1);
+    c2 /= (Double_t)fN - 2.0;
+    return c2;
+}
+//______________________________________________________________________
+void AliITSstatistics2::PrintAscii(ostream *os)const{
+    // Print out class data values in Ascii Form to output stream
+    // Inputs:
+    //   ostream *os   Output stream where Ascii data is to be writen
+    // Outputs:
+    //   none.
+    // Return:
+    //   none.
+    Int_t i;
+#if defined __GNUC__
+#if __GNUC__ > 2
+    ios::fmtflags fmt;
+#else
+    Int_t fmt;
+#endif
+#else
+#if defined __ICC || defined __ECC || defined __xlC__
+    ios::fmtflags fmt;
+#else
+    Int_t fmt;
+#endif
+#endif
+
+    *os << fN <<" "<< fOrder;
+    fmt = os->setf(ios::scientific); // set scientific floating point output
+    for(i=0;i<fOrder;i++) *os <<" "<< fX[i];
+    for(i=0;i<fOrder;i++) *os <<" "<< fYx[i];
+    for(i=0;i<fOrder;i++) *os <<" "<< fY[i];
+    for(i=0;i<fOrder;i++) *os <<" "<< fW[i];
+    os->flags(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<fOrder;i++) *is >> fX[i];
+    for(i=0;i<fOrder;i++) *is >> fYx[i];
+    for(i=0;i<fOrder;i++) *is >> fY[i];
+    for(i=0;i<fOrder;i++) *is >> fW[i];
+}
+//______________________________________________________________________
+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;
 }
index 2840b57913d0cfb3cd80e53cd45eea53793b55c7..6472683ea02d97bc843cf45ca3c9b636095d861e 100644 (file)
 
 class AliITSstatistics2 : public TObject {
 //
-
  public:
-    AliITSstatistics2();
-    AliITSstatistics2(Int_t order);
-        AliITSstatistics2(AliITSstatistics2 &source); // copy  constructor
-        AliITSstatistics2& operator=(AliITSstatistics2 &source); // operator=   
-    virtual ~AliITSstatistics2();
-    void Reset();
+    AliITSstatistics2(); // default constructor
+    AliITSstatistics2(Int_t order); // Standard constructor
+    AliITSstatistics2(AliITSstatistics2 &source); // copy  constructor
+    AliITSstatistics2& operator=(AliITSstatistics2 &source); // operator=
+    virtual ~AliITSstatistics2();// destructor
+    void Reset(Int_t order=-1); // Resets statictisc order=-1 do not change order.
     void AddValue(Double_t y,Double_t x,Double_t w);
-    Double_t GetXNth (Int_t order);
-    Double_t GetYNth (Int_t order);
-    Double_t GetYXNth(Int_t order);
-    Double_t GetMeanY()  {
-                              // return mean y
-                              return GetYNth(1);
-                                                                };
-    Double_t GetMeanX()  {
-                              // return mean x
-                              return GetXNth(1);
-                                                                };
-    Double_t GetMeanYX() {
-                              // return mean Y*X
-                              return GetYXNth(1);
-                                                                };
-    Int_t GetN(){
-                     // retrun the number of entries
-                     return fN;
-                                        };
-    Int_t GetOrder(){
-                         // return the maximum moment order
-                         return fOrder;
-                                                 };
-    Double_t GetXN (Int_t order){
-                                     // returns x^n
-                                     return fX[order-1];
-                                                                                 };
-    Double_t GetYN (Int_t order){
-                                     // returns y^n
-                                     return fY[order-1];
-                                                                                 };
-    Double_t GetYXN(Int_t order){
-                                     // returns (yx)^n
-                                     return fYx[order-1];
-                                                                                 };
-    Double_t GetWN (Int_t order){
-                                     // returns w^n (weight)
-                                     return fW[order-1];
-                                                                                 };
-    Double_t GetRMSY();
-    Double_t GetRMSX();
-    Double_t GetRMSYX();
-    Double_t GetErrorMeanY();
-    Double_t GetErrorMeanX();
-    Double_t GetErrorMeanYX();
-    Double_t GetErrorRMSY();
-    Double_t GetErrorRMSX();
-    Double_t GetErrorRMSYX();
-    Double_t FitToLine(Double_t &a,Double_t &b);
+    Double_t GetXNth (Int_t order)const;
+    Double_t GetYNth (Int_t order)const;
+    Double_t GetYXNth(Int_t order)const;
+    Double_t GetMeanY()const{// return mean y
+        return GetYNth(1);};
+    Double_t GetMeanX()const{// return mean x
+        return GetXNth(1);};
+    Double_t GetMeanYX()const{// return mean Y*X
+        return GetYXNth(1);};
+    Int_t GetN()const{// retrun the number of entries
+        return fN;};
+    Int_t GetOrder()const{// return the maximum moment order
+        return fOrder;};
+    Double_t GetXN (Int_t order)const{// returns x^n
+        return fX[order-1];};
+    Double_t GetYN (Int_t order)const{// returns y^n
+        return fY[order-1];};
+    Double_t GetYXN(Int_t order)const{// returns (yx)^n
+        return fYx[order-1];};
+    Double_t GetWN (Int_t order)const{// returns w^n (weight)
+        return fW[order-1];};
+    Double_t GetRMSY()const; // Returns Y rms value
+    Double_t GetRMSX()const; // Returns X rms value
+    Double_t GetRMSYX()const;// Return XY rms value
+    Double_t GetErrorMeanY()const; // returns error on y mean
+    Double_t GetErrorMeanX()const; // returns error on x mean
+    Double_t GetErrorMeanYX()const;// returns error on xy mean
+    Double_t GetErrorRMSY()const;  // returns error on y rms
+    Double_t GetErrorRMSX()const;  // returns error on x rms
+    Double_t GetErrorRMSYX()const; // returns error on xy rms
+    // returns Chi^2 value of data to line y=ax+b with given a,b
+    Double_t GetChiSquared(Double_t a,Double_t b)const; 
+    // Fits data to a line of the form y=ax+b and returns values
+    // for a and b.
+    Double_t FitToLine(Double_t &a,Double_t &b)const;
+    // Print class in ascii form to stream
+    virtual void PrintAscii(ostream *os)const;
+    // Read in class in ascii form from stream
+    virtual void ReadAscii(istream *is);
 
  private:
     Int_t  fN;       // number of enetries
@@ -79,7 +68,9 @@ class AliITSstatistics2 : public TObject {
     Double_t *fY;    //[fOrder] array of sums of y^n
     Double_t *fW;    //[fOrder] array of sums of w^n (weights)
 
-
     ClassDef(AliITSstatistics2,1)  //compute usueful statistics in 2D
 };
+// Input and output function for standard C++ input/output.
+ostream &operator<<(ostream &os,const AliITSstatistics2 &s);
+istream &operator>>(istream &is,AliITSstatistics2 &s);
 #endif