]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Adding function to make a standad tgraph error as a result of the tree quesry
authormivanov <mivanov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 28 Mar 2013 11:07:18 +0000 (11:07 +0000)
committermivanov <mivanov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 28 Mar 2013 11:07:18 +0000 (11:07 +0000)
STAT/TStatToolkit.cxx
STAT/TStatToolkit.h

index b403172820c8a9694830ba374c8e6919f52e0f47..18b75e2ad48495b644d20df0fff9b4f196a43161 100644 (file)
@@ -1214,6 +1214,39 @@ TString  TStatToolkit::MakeFitString(const TString &input, const TVectorD &param
   return result;
 }
 
+TGraphErrors * TStatToolkit::MakeGraphErrors(TTree * tree, const char * expr, const char * cut,  Int_t mstyle, Int_t mcolor, Float_t msize, Float_t offset){
+  //
+  // Query a graph errors
+  // return TGraphErrors specified by expr and cut 
+  // Example  usage TStatToolkit::MakeGraphError(tree,"Y:X:ErrY","X>0", 25,2,0.4)
+  // tree   - tree with variable
+  // expr   - examp 
+  const Int_t entries =  tree->Draw(expr,cut,"goff");
+  if (entries<=0) {
+    TStatToolkit t;
+    t.Error("TStatToolkit::MakeGraphError",Form("Empty or Not valid expression (%s) or cut *%s)", expr,cut));
+    return 0;
+  }
+  if (  tree->GetV2()==0){
+    TStatToolkit t;
+    t.Error("TStatToolkit::MakeGraphError",Form("Not valid expression (%s) ", expr));
+    return 0;
+  }
+  TGraphErrors * graph=0;
+  if ( tree->GetV3()!=0){
+    graph = new TGraphErrors (entries, tree->GetV2(),tree->GetV1(),0,tree->GetV3());
+  }else{
+    graph = new TGraphErrors (entries, tree->GetV2(),tree->GetV1(),0,0);
+  }
+  graph->SetMarkerStyle(mstyle); 
+  graph->SetMarkerColor(mcolor);
+  graph->SetLineColor(mcolor);
+  if (msize>0) graph->SetMarkerSize(msize);
+  for(Int_t i=0;i<graph->GetN();i++) graph->GetX()[i]+=offset;
+  return graph;
+  
+}
+
 
 TGraph * TStatToolkit::MakeGraphSparse(TTree * tree, const char * expr, const char * cut, Int_t mstyle, Int_t mcolor, Float_t msize, Float_t offset){
   //
index 829915646213281c6a78c65d4afc02da8e710467..c0ca2a83afa52f25ee91663104c10e725882d62c 100644 (file)
@@ -22,6 +22,7 @@ class TGraph;
 class TGraph2D;
 class TCanvas;
 class TMultiGraph; 
+class TGraphErrors; 
 
 class TStatToolkit : public TObject
 {
@@ -49,6 +50,8 @@ class TStatToolkit : public TObject
   // Graph tools
   //
   static TGraph * MakeGraphSparse(TTree * tree, const char * expr="Entry", const char * cut="1",  Int_t mstyle=25, Int_t mcolor=1, Float_t msize=-1, Float_t offset=0.0);
+  static TGraphErrors * MakeGraphErrors(TTree * tree, const char * expr="Entry", const char * cut="1",  Int_t mstyle=25, Int_t mcolor=1, Float_t msize=-1, Float_t offset=0.0);
+
   //
   // Fitting function
   //