protection in case of invalid or empty selection (Marian)
authormivanov <mivanov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 22 Nov 2012 23:44:05 +0000 (23:44 +0000)
committermivanov <mivanov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 22 Nov 2012 23:44:05 +0000 (23:44 +0000)
STAT/TStatToolkit.cxx

index f5cf85b..8ea3c3c 100644 (file)
@@ -1192,6 +1192,11 @@ TGraph * TStatToolkit::MakeGraphSparse(TTree * tree, const char * expr, const ch
   // Make a sparse draw of the variables
   // Writen by Weilin.Yu
   const Int_t entries =  tree->Draw(expr,cut,"goff");
+  if (entries<=0) {
+    TStatToolkit t;
+    t.Error("TStatToolkit::MakeGraphSparse",Form("Empty or Not valid expression (%s) or cut *%s)", expr,cut));
+    return 0;
+  }
   //  TGraph * graph = (TGraph*)gPad->GetPrimitive("Graph"); // 2D
   TGraph * graph = 0;
   if (tree->GetV3()) graph = new TGraphErrors (entries, tree->GetV2(),tree->GetV1(),0,tree->GetV3());