]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
ALIROOT-5311 - adding missing protection divission by zerro
authormivanov <marian.ivanov@cern.ch>
Mon, 25 Aug 2014 12:52:14 +0000 (14:52 +0200)
committermivanov <marian.ivanov@cern.ch>
Mon, 25 Aug 2014 12:52:14 +0000 (14:52 +0200)
STAT/TStatToolkit.cxx
STAT/TStatToolkit.h

index 4a5fc4480fee4ad34e86aaa6da7e14010e90e28c..977f9487b580abd497017bafcfb5d95dacfcb600 100644 (file)
@@ -381,7 +381,7 @@ Bool_t TStatToolkit::LTMHisto(TH1 *his1D, TVectorD &params , Float_t fraction){
     // substract fractions of bin0 and bin1 to keep sum0=fration*sumCont
     //
     Double_t diff = sum0-fraction*sumCont;
-    Double_t mean = sum1/sum0;
+    Double_t mean = (sum0>0) ? sum1/sum0:0;
     //
     Double_t x0=his1D->GetBinCenter(ibin0);
     Double_t x1=his1D->GetBinCenter(ibin1);
@@ -970,7 +970,7 @@ TString* TStatToolkit::FitPlane(TTree *tree, const char* drawCommand, const char
    Int_t entries = tree->Draw(drawStr.Data(), cutStr.Data(), "goff",  stop-start, start);
    if (entries == -1) {
      delete formulaTokens;
-     return new TString("An ERROR has occured during fitting!");
+     return new TString(TString::Format("ERROR expr: %s\t%s\tEntries==0",drawStr.Data(),cutStr.Data()));
    }
    Double_t **values = new Double_t*[dim+1] ;
    for (Int_t i=0; i<dim+1; i++) values[i]=NULL; 
@@ -979,7 +979,7 @@ TString* TStatToolkit::FitPlane(TTree *tree, const char* drawCommand, const char
    if (entries == -1) {
      delete formulaTokens;
      delete []values;
-     return new TString("An ERROR has occured during fitting!");
+     return new TString(TString::Format("ERROR error part: %s\t%s\tEntries==0",ferr.Data(),cutStr.Data()));
    }
    Double_t *errors = new Double_t[entries];
    memcpy(errors,  tree->GetV1(), entries*sizeof(Double_t));
@@ -992,7 +992,7 @@ TString* TStatToolkit::FitPlane(TTree *tree, const char* drawCommand, const char
       if (entries != centries) {
        delete []errors;
        delete []values;
-       return new TString("An ERROR has occured during fitting!");
+       return new TString(TString::Format("ERROR: %s\t%s\tEntries==%d\tEntries2=%d\n",drawStr.Data(),cutStr.Data(),entries,centries));
       }
       values[i] = new Double_t[entries];
       memcpy(values[i],  tree->GetV1(), entries*sizeof(Double_t)); 
@@ -1833,3 +1833,22 @@ TH1* TStatToolkit::DrawHistogram(TTree * tree, const char* drawCommand, const ch
    }
    return hOut;
 }
+
+void TStatToolkit::CheckTreeAliases(TTree * tree, Int_t ncheck){
+  //
+  // Check consistency of tree aliases
+  //
+  Int_t nCheck=100;
+  TList * aliases = (TList*)tree->GetListOfAliases();
+  Int_t entries = aliases->GetEntries();
+  for (Int_t i=0; i<entries; i++){
+    TObject * object= aliases->At(i);
+    if (!object) continue;
+    Int_t ndraw=tree->Draw(aliases->At(i)->GetName(),"1","goff",nCheck);
+    if (ndraw==0){
+      ::Error("Alias:\tProblem",aliases->At(i)->GetName());
+    }else{
+      ::Info("Alias:\tOK",aliases->At(i)->GetName());
+    }
+  }
+}
index 0c798221e668b9ee421697dad6fe861810561fa6..2e4464a495e31f2d95ff1e25cc59fe4072abbc69 100644 (file)
@@ -86,7 +86,7 @@ class TStatToolkit : public TObject
   // TestFunctions:
   //
  static  void TestGausFit(Int_t nhistos=5000);
-
+ static  void CheckTreeAliases(TTree * tree, Int_t ncheck);
  ClassDef(TStatToolkit,0) // Various mathematical tools for physics analysis - which are not included in ROOT TMath
  
 };