Newer
Older
TestStandRepository / Software / TbNtupleMaker / Alibava / .svn / text-base / utils.cc.svn-base
  1. #include <TROOT.h>
  2. #include "utils.h"
  3.  
  4. TCanvas *create_canvas(const char *name, const char *title, int wx, int wy)
  5. {
  6. TCanvas *cnvs = (TCanvas *)gROOT->FindObject("name");
  7. if (cnvs)
  8. delete cnvs;
  9.  
  10. if (wx<0 ||wy<0)
  11. cnvs = new TCanvas(name, title);
  12. else
  13. cnvs = new TCanvas(name, title, wx, wy);
  14.  
  15. return cnvs;
  16. }
  17.  
  18. TH1 *create_h1(const char *name, const char *tit, int n, double x1, double x2)
  19. {
  20. TH1 *hst = (TH1 *)gROOT->FindObject(name);
  21. if (hst)
  22. delete hst;
  23. hst = new TH1D(name, tit, n, x1, x2);
  24. return hst;
  25. }
  26.  
  27. TH2 *create_h2(const char *name, const char *tit, int nx, double x1, double x2, int ny, double y1, double y2)
  28. {
  29. TH2 *hst = (TH2 *)gROOT->FindObject(name);
  30. if (hst)
  31. delete hst;
  32. hst = new TH2D(name, tit, nx, x1, x2, ny, y1, y2);
  33. return hst;
  34. }
  35.  
  36. TProfile *create_profile(const char *name, const char *tit, int n, double x1, double x2, double y1, double y2)
  37. {
  38. TProfile *hst = (TProfile *)gROOT->FindObject(name);
  39. if (hst)
  40. delete hst;
  41. hst = new TProfile(name, tit, n, x1, x2, y1, y2);
  42. return hst;
  43. }
  44.  
  45. TProfile2D *create_profile2d(const char *name, const char *tit, int nx, double x1, double x2, int ny, double y1, double y2)
  46. {
  47. TProfile2D *hst = (TProfile2D *)gROOT->FindObject(name);
  48. if (hst)
  49. delete hst;
  50.  
  51. hst = new TProfile2D(name, tit, nx, x1, x2, ny, y1, y2);
  52. return hst;
  53. }