Newer
Older
TestStandRepository / Software / TbNtupleMaker / Alibava / .svn / text-base / utils.h.svn-base
  1. #ifndef UTILS_H_
  2. #define UTILS_H_
  3.  
  4. #include <string>
  5. #include <vector>
  6. #include <TH1.h>
  7. #include <TH2.h>
  8. #include <TProfile.h>
  9. #include <TProfile2D.h>
  10. #include <TCanvas.h>
  11.  
  12. /**
  13. * Utils
  14. */
  15. inline bool isws(char c, char const * const wstr=" \t\n")
  16. {
  17. return (strchr(wstr, c) != NULL);
  18. }
  19.  
  20. inline std::string trim_right(const std::string &s)
  21. {
  22. std::string b=" \t\n";
  23. std::string str = s;
  24. return str.erase(str.find_last_not_of(b) +1);
  25. }
  26.  
  27. inline std::string trim_left(const std::string &s)
  28. {
  29. std::string b=" \t\n";
  30. std::string str = s;
  31. return str.erase( 0, str.find_first_not_of(b) );
  32. }
  33.  
  34. inline std::string trim_str(const std::string &s)
  35. {
  36. std::string str = s;
  37. return trim_left(trim_right(str) );
  38. }
  39.  
  40. TCanvas *create_canvas(const char *name, const char *title, int wx=-1, int wy=-1);
  41. TH1 *create_h1(const char *, const char *, int, double, double);
  42. TH2 *create_h2(const char *, const char *, int, double, double, int, double, double);
  43. TProfile *create_profile(const char *, const char *, int, double, double, double, double);
  44. TProfile2D *create_profile2d(const char *name, const char *tit, int nx, double x1, double x2, int ny, double y1, double y2);
  45.  
  46.  
  47.  
  48. #endif /*UTILS_H_*/