SusyNtuple
|
00001 #ifndef TGUIUTILS_H 00002 #define TGUIUTILS_H 00003 00009 #include "TObject.h" 00010 #include "TStyle.h" 00011 #include "TCanvas.h" 00012 #include "TH1F.h" 00013 #include "TProfile.h" 00014 #include "TH2F.h" 00015 #include "TH3F.h" 00016 #include "THStack.h" 00017 #include "TLegend.h" 00018 #include "TVirtualPad.h" 00019 00020 #include "TGraphErrors.h" 00021 #include "TGraphAsymmErrors.h" 00022 00023 00025 00029 class TGuiUtils : public TObject 00030 { 00031 public: 00032 TGuiUtils(); 00033 virtual ~TGuiUtils(){}; 00034 00035 public: 00036 static TGuiUtils *rootUtils; 00037 TStyle *atlasStyle; 00038 00039 void ATLASLabel(Double_t x,Double_t y,char* text=NULL,Color_t color=1); 00040 00041 void ATLASLabelOld(Double_t x,Double_t y,bool Preliminary=false,Color_t color=1); 00042 00043 void ATLASVersion(char* version=NULL,Double_t x=0.88,Double_t y=0.975,Color_t color=1); 00044 00045 00046 00047 TGraphErrors* myTGraphErrorsDivide(TGraphErrors* g1,TGraphErrors* g2); 00048 TGraphAsymmErrors* myTGraphErrorsDivide(TGraphAsymmErrors* g1,TGraphAsymmErrors* g2); 00049 TGraphAsymmErrors* myMakeBand(TGraphAsymmErrors* g0, TGraphAsymmErrors* g1,TGraphAsymmErrors* g2); 00050 00051 TGraphErrors* TH1ToTGraph(TH1 *h1); 00052 00053 TGraphAsymmErrors* TH1TOTGraphAsymErrors(TH1 *h1); 00054 00055 TGraphAsymmErrors* myRatioBand(TGraphAsymmErrors* _asymErrors); 00056 00057 void myAddtoBand(TGraphAsymmErrors* g1, TGraphAsymmErrors* g2); 00058 00059 00060 00061 void myText(Double_t x,Double_t y,Color_t color,const char *text, Double_t tsize=0.05); 00062 void myBoxText(Double_t x, Double_t y,Double_t boxsize,Int_t mcolor,const char *text); 00063 00064 void myMarkerText(Double_t x,Double_t y,Int_t color,Int_t mstyle,const char *text,Float_t msize=2.); 00065 00066 void myHatchBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2, 00067 Option_t* option="NDC", Color_t color=-1); 00068 00069 void myLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2, 00070 Color_t color=kRed); 00071 00072 //Method for plotting 00073 00074 TCanvas* myCanvas(const char* name, int w=500, int h=500, int nx=1, int ny=1); 00075 00076 TH1F* myTH1F(const char* name, const char* title, int nbin, float nlow, float nhigh, 00077 const char* titleX, const char* titleY); 00078 00079 TH1F* myTH1F(const char* name, const char* title, int nbin, const Double_t* nX, 00080 const char* titleX, const char* titleY); 00081 00082 TProfile* myTProfile(const char* name, const char* title, int nbinX, float nlowX, float nhighX, 00083 float nlowY, float nhighY, 00084 const char* titleX, const char* titleY); 00085 TH2F* myTH2F(const char* name, const char* title, 00086 int nbinX, float nlowX, float nhighX, 00087 int nbinY, float nlowY, float nhighY, 00088 const char* titleX, const char* titleY); 00089 TH2F* myTH2F(const char* name, const char* title, 00090 int nbinX, const Double_t* nX, 00091 int nbinY, float nlowY, float nhighY, 00092 const char* titleX, const char* titleY); 00093 TH2F* myTH2F(const char* name, const char* title, 00094 int nbinX, const Double_t* nX, 00095 int nbinY, const Double_t* nY, 00096 const char* titleX, const char* titleY); 00097 00098 TH3F* myTH3F(const char* name, const char* title, 00099 int nbinX, float nlowX, float nhighX, 00100 int nbinY, float nlowY, float nhighY, 00101 int nbinZ, float nlowZ, float nhighZ, 00102 const char* titleX, const char* titleY, const char* titleZ); 00103 00104 TH3F* myTH3F(const char* name, const char* title, 00105 int nbinX, const Double_t* nX, 00106 int nbinY, const Double_t* nY, 00107 int nbinZ, const Double_t* nz, 00108 const char* titleX, const char* titleY, const char* titleZ); 00109 00110 void myDraw1d(TH1* hist, TCanvas* c, int npad=1, Option_t* option="e", 00111 bool logy=false, Color_t color=-1, bool showStat=true, int markerStyle=20); 00112 void myDraw1d(TH1* hist, TVirtualPad* c, int npad=1, Option_t* option="e", 00113 bool logy=false, Color_t color=-1, bool showStat=true, int markerStyle=20); 00114 void myDraw2d(TH2* hist, TCanvas* c, int npad=1, Option_t* option="e", 00115 Color_t color=-1, bool showStat=false); 00116 void myDraw2d(TH2* hist, TVirtualPad* p, int npad=1, Option_t* option="e", 00117 Color_t color=-1, bool showStat=false); 00118 00119 TVirtualPad* myDrawRatio(TCanvas* _c,TPad* _pTop, TPad* _pBot, 00120 THStack* _hStack, TH1F* _stackH, TH1F* _h, TLegend* _l,bool logy=false); 00121 00122 void myDrawTHStack(TCanvas* _c, THStack* _hStack, TH1F* _stackH, 00123 TLegend* _l,bool logy=false); 00124 00125 void addToTHStack(THStack* _hStack, TH1F* _h, int icol, const char* opt, 00126 TLegend* _l, const char* _txt); 00127 00128 void getStackHisto(THStack* _hStack, TH1F* _stackH); 00129 00130 void moveUnderOverFlow(TH1* h, int opt=0); 00131 00132 double getMax(TH1* h1, TH1* h2); 00133 double getMin(TH1* h1, TH1* h2); 00134 double getMinBin(TH1* h); 00135 void legendSetting(TLegend* leg, float fontSize=0.02); 00136 00137 00138 double getHistMean(TH1* h); 00139 00141 void yAxis(TH1* h1, const char* _unit); 00142 00143 void normalize(TH1* h1, float val=1); 00144 00146 void templateHisto(); 00147 00148 00153 TGraphAsymmErrors* updateDataError(TH1* h, bool fillZero=false); 00154 00155 00156 00157 ClassDef(TGuiUtils,1); 00158 00159 00160 private: 00161 void createAtlasStyle(); 00162 00163 00164 }; 00165 00166 #endif // TGUIUTILS_H