Skip to content

Commit

Permalink
ALIROOT-5599 ALIROOT-5311 - adding missing protection divission by zerro
Browse files Browse the repository at this point in the history
  • Loading branch information
miranov25 authored and hristov committed Aug 28, 2014
1 parent 02797e0 commit 7706fb5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
27 changes: 23 additions & 4 deletions STAT/TStatToolkit.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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));
Expand All @@ -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));
Expand Down Expand Up @@ -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());
}
}
}
2 changes: 1 addition & 1 deletion STAT/TStatToolkit.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

};
Expand Down

0 comments on commit 7706fb5

Please sign in to comment.