GRAPH/TFndGraphs.h

00001 // @(#)fROOT/GRAPH:$Name:  $:$Id: TFndGraphs.h,v 1.4 2007/09/05 09:45:26 Diego_Faso Exp $
00002 // Author: Diego Faso <mailto:faso@to.infn.it> 2007/08/03
00003 
00004 #ifndef FROOT_TFndGraphs
00005 #define FROOT_TFndGraphs
00006 
00007 #include <Riostream.h>
00008 
00009 #include "TString.h"
00010 #include "TMultiGraph.h"
00011 #include "TGraphErrors.h"
00012 #include "TH1F.h"
00013 #include "TList.h"
00014 #include "TFile.h"
00015 
00016 #include "FIN_AN.h"
00017 using namespace FIN_AN;
00018 
00019 class TFndGraph: public TGraphErrors{
00020  public:
00021   /*   // ctors for compatibility with */
00022   /*   // the inheritance from TGraph */
00023   /*   //   Aug. 2006 (root-5.15/06) */
00024   TFndGraph();
00025   TFndGraph(Int_t n);
00026   TFndGraph(const TFndGraph &gr);
00027 
00028  private:
00029   Double_t fFndSum; // algebric sum of all Y-values
00030   Double_t fFndMinX; // min value (X axis)
00031   Double_t fFndMaxX; // max value (X axis)
00032   Double_t fFndMinY; // min value (Y axis)
00033   Double_t fFndMaxY; // max value (Y axis)
00034 
00035   Double_t fFndMinDrawX; // set minimum value for drawing X-axis
00036   Double_t fFndMaxDrawX; // set maximum value for drawing X-axis
00037   Double_t fFndMinDrawY; // set minimum value for drawing Y-axis
00038   Double_t fFndMaxDrawY; // set maximum value for drawing Y-axis
00039 
00040   void InitFnd(TString name="fnd_graph",TString title="fnd-graph");
00041 
00042  public:
00043   TFndGraph(const TString &name, const TString &title);
00044   
00045   void Reset(Bool_t keep_name_title=kTRUE); // back to original object
00046   Int_t LoadFromFile(TFile *file=0);
00047 
00048   Int_t EvalAxisRange();
00049   void SetTimeX(const Bool_t &time_x);
00050   void DrawDefaults(Bool_t time_x=kFALSE,Color_t col=-1,Width_t width=-1,Option_t *opt="ALP",Bool_t sort=kTRUE);
00051 
00052   Double_t GetSum()  { return fFndSum;  }  
00053   Double_t GetMinX() { return fFndMinX; }
00054   Double_t GetMaxX() { return fFndMaxX; }
00055   Double_t GetMinY() { return fFndMinY; }
00056   Double_t GetMaxY() { return fFndMaxY; }
00057 
00058   void SetMinDrawX(const Double_t &val) {fFndMinDrawX = val; }
00059   void SetMaxDrawX(const Double_t &val) {fFndMaxDrawX = val; }
00060   void SetMinDrawY(const Double_t &val) {fFndMinDrawY = val; }
00061   void SetMaxDrawY(const Double_t &val) {fFndMaxDrawY = val; }
00062   void UnSetMinDrawX() {fFndMinDrawX = - K_FinAn_double; }
00063   void UnSetMaxDrawX() {fFndMaxDrawX =   K_FinAn_double; }
00064   void UnSetMinDrawY() {fFndMinDrawY = - K_FinAn_double; }
00065   void UnSetMaxDrawY() {fFndMaxDrawY =   K_FinAn_double; }
00066 
00067   void UnZoom()  { UnZoomX(); UnZoomY(); }
00068   void UnZoomX() { if(GetXaxis())GetXaxis()->UnZoom(); }
00069   void UnZoomY() { if(GetYaxis())GetYaxis()->UnZoom(); }
00070 
00071   Double_t GetMinDrawX() { return fFndMinDrawX; }
00072   Double_t GetMaxDrawX() { return fFndMaxDrawX; }
00073   Double_t GetMinDrawY() { return fFndMinDrawY; }
00074   Double_t GetMaxDrawY() { return fFndMaxDrawY; }
00075 
00076 
00077   void AddPoint(const Double_t &x,const Double_t &y,Double_t err_x=0,Double_t err_y=0) {
00078     Int_t Pid = GetN();
00079     SetPoint(Pid,x,y); 
00080     fFndSum+=y;
00081     if(err_x || err_y) SetPointError(Pid,err_x,err_y);
00082     //    cout << "Point "  << GetN() << " added: " << x << " ; " << y << endl;
00083     
00084     if(fFndMinX > x) fFndMinX = x;
00085     if(fFndMaxX < x) fFndMaxX = x;
00086     if(fFndMinY > y) fFndMinY = y;
00087     if(fFndMaxY < y) fFndMaxY = y;
00088   }
00089   
00090   ClassDef(TFndGraph,1)
00091 };
00092     
00096 class TFndMultiGraph: public TMultiGraph{
00097 
00098  public:  
00099   TFndMultiGraph(TString name="FndMultiGraph",TString title="Fnd Multi-graph");
00100   ~TFndMultiGraph();
00101 
00102   void EvalAxisRange();
00103   void SetTimeX(const Bool_t &time_x);
00104   void AddFndGraph(TFndGraph *gr,Option_t *opt="P",Color_t col=-1,Width_t width=-1);
00105   void Reset(); // remove all graphs
00106   void DrawDefaults(Bool_t time_x=kFALSE);
00107 
00108   ClassDef(TFndMultiGraph,1)
00109 };
00110 
00111 #endif // FROOT_TFndGraphs

Generated on Tue Oct 16 15:40:46 2007 by  doxygen 1.5.2