]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSstatistics.cxx
Changes to remove Effective C++ warnings
[u/mrichter/AliRoot.git] / ITS / AliITSstatistics.cxx
index e029abb7fb729394d32646f9c26f3e371bc195c6..90b4ef3e11d514b99a9aabe0e15dba32e3f2eb41 100644 (file)
 ClassImp(AliITSstatistics)
 
 //
-AliITSstatistics::AliITSstatistics() : TObject(){
+AliITSstatistics::AliITSstatistics() : TObject(),
+fN(0),
+fOrder(0),
+fX(0),
+fW(0){
 //
 // default contructor
 //
-    fx = 0;
-    fw = 0;
-    fN = 0;
-    fOrder = 0;
-    return;
 }
 
 
-AliITSstatistics::AliITSstatistics(Int_t order) : TObject(){
+AliITSstatistics::AliITSstatistics(Int_t order) : TObject(),
+fN(0),
+fOrder(order),
+fX(0),
+fW(0){
 //
 // contructor to a specific order in the moments
 //
-    fOrder = order;
-    fx = new Double_t[order];
-    fw = new Double_t[order];
-    Int_t i;
-    for(i=0;i<order;i++) {fx[i] = 0.0; fw[i] = 0.0;}
-    fN = 0;
+    fX = new Double_t[order];
+    fW = new Double_t[order];
+    for(Int_t i=0;i<order;i++) {fX[i] = 0.0; fW[i] = 0.0;}
     return;
 }
 
@@ -44,85 +44,91 @@ AliITSstatistics::~AliITSstatistics(){
 //
 // default destructor
 //
-    if(fx!=0) delete[] fx;
-    if(fw!=0) delete[] fw;
-    fx = 0;
-    fw = 0;
+    if(fX!=0) delete[] fX;
+    if(fW!=0) delete[] fW;
+    fX = 0;
+    fW = 0;
     fN = 0;
     fOrder = 0;
 }
 //_______________________________________________________________
-AliITSstatistics& AliITSstatistics::operator=(AliITSstatistics &source){
+AliITSstatistics& AliITSstatistics::operator=(const AliITSstatistics &source){
 // operator =
 
-     Int_t i;
      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(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;
+         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;
 }
 //_______________________________________________________________
-AliITSstatistics::AliITSstatistics(AliITSstatistics &source){
+AliITSstatistics::AliITSstatistics(const AliITSstatistics &source) : TObject(source),
+fN(0),
+fOrder(0),
+fX(0),
+fW(0){
 // Copy constructor
 
-  Int_t i;
-  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(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
+     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
 }
 //_______________________________________________________________
 void AliITSstatistics::Reset(){
 //
 // reset all values to zero
 //
-    Int_t i;
-    for(i=0;i<fOrder;i++) {fx[i] = 0.0; fw[i] = 0.0;}
+    for(Int_t i=0;i<fOrder;i++) {fX[i] = 0.0; fW[i] = 0.0;}
     fN = 0;
     return;
 }
 
-void AliITSstatistics::AddValue(Double_t x,Double_t w=1.0){
+//_______________________________________________________________
+void AliITSstatistics::AddValue(Double_t x,Double_t w){
 //
 // accumulate element x with weight w.
 //
+
+  //it was AddValue(Double_t x,Double_t w=1.0);
+
     Double_t y=1.0,z=1.0;
+
     Int_t i;
+    const Double_t kBig=1.0e+38;
 
+    if(y>kBig || x>kBig || w>kBig) return;
 
-    if(isinf(y)!=0||isinf(x)!=0||isinf(w)!=0) return;
-    if(isnan(y)!=0||isnan(x)!=0||isnan(w)!=0) return;
     fN++;
     for(i=0;i<fOrder;i++){
        y *= x;
        z *= w;
-       fx[i] += y*w;
-       fw[i] += z;
+       fX[i] += y*w;
+       fW[i] += z;
     } // end for i
 }
 
@@ -130,11 +136,11 @@ Double_t AliITSstatistics::GetNth(Int_t order){
 // This give the unbiased estimator for the RMS.
     Double_t s;
 
-    if(fw[0]!=0.0&&order<=fOrder) s = fx[order-1]/fw[0];
+    if(fW[0]!=0.0&&order<=fOrder) s = fX[order-1]/fW[0];
     else {
        s = 0.0;
-       printf("AliITSstatistics: error in GetNth: fOrder=%d fN=%d fw[0]=%f\n",
-              fOrder,fN,fw[0]);
+       printf("AliITSstatistics: error in GetNth: fOrder=%d fN=%d fW[0]=%f\n",
+              fOrder,fN,fW[0]);
     } // end else
     return s;
 }
@@ -145,8 +151,8 @@ Double_t AliITSstatistics::GetRMS(){
 
     x  = GetMean(); // first order
     x2 = GetNth(2); // second order
-    w  = fw[0];     // first order - 1.
-    ww = fw[1];     // second order - 1.
+    w  = fW[0];     // first order - 1.
+    ww = fW[1];     // second order - 1.
 
     if(w*w==ww) return (-1.0);
     s = (x2-x*x)*w*w/(w*w-ww);
@@ -158,8 +164,8 @@ Double_t AliITSstatistics::GetErrorMean(){
     Double_t rms,w,ww,s;
 
     rms = GetRMS();
-    w   = fw[0];
-    ww  = fw[1];
+    w   = fW[0];
+    ww  = fW[1];
     s   = rms*rms*ww/(w*w);
     return TMath::Sqrt(s);
 }
@@ -170,11 +176,11 @@ Double_t AliITSstatistics::GetErrorRMS(){
 // at this moment this routine is only defined for weights=1.
     Double_t x,x2,x3,x4,w,ww,m2,m4,n,s;
 
-    if(fw[0]!=(Double_t)fN||GetN()<4) return (-1.);
+    if(fW[0]!=(Double_t)fN||GetN()<4) return (-1.);
     x  = GetMean(); // first order
     x2 = GetNth(2); // second order
-    w  = fw[0];     // first order - 1.
-    ww = fw[1];     // second order - 1.
+    w  = fW[0];     // first order - 1.
+    ww = fW[1];     // second order - 1.
     if(w*w==ww) return (-1.0);
     s = (x2-x*x)*w*w/(w*w-ww);
 
@@ -187,23 +193,3 @@ Double_t AliITSstatistics::GetErrorRMS(){
     s   = (m4-(n-3.)*m2*m2/(n-1.))/n;
     return TMath::Sqrt(s);
 }
-//_______________________________________________________________________
-void AliITSstatistics::Streamer(TBuffer &R__b){
-   // Stream an object of class AliITSstatistics.
-
-   if (R__b.IsReading()) {
-      Version_t R__v = R__b.ReadVersion(); if (R__v) { }
-      TObject::Streamer(R__b);
-      R__b >> fN;
-      R__b >> fOrder;
-      R__b.ReadArray(fx);
-      R__b.ReadArray(fw);
-   } else {
-      R__b.WriteVersion(AliITSstatistics::IsA());
-      TObject::Streamer(R__b);
-      R__b << fN;
-      R__b << fOrder;
-      R__b.WriteArray(fx,fOrder);
-      R__b.WriteArray(fw,fOrder);
-   }
-}