You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

132 lines
4.3 KiB

10 months ago
9 months ago
10 months ago
8 months ago
10 months ago
  1. from ROOT import gROOT, TH1, TH1F, TH1D, TEfficiency
  2. from ROOT import TStyle
  3. def set_style(graph, color, marker, style):
  4. graph.SetLineColor(color)
  5. graph.SetMarkerColor(color)
  6. graph.SetMarkerSize(1.0)
  7. graph.SetMarkerStyle(marker)
  8. if type(graph) == TH1F or type(graph) == TH1 or type(graph) == TH1D:
  9. graph.SetFillColor(color)
  10. # graph.SetFillColorAlpha(color, 0.5)
  11. graph.SetFillStyle(style)
  12. graph.SetLineWidth(2)
  13. if style == 0:
  14. graph.SetFillColor(0)
  15. graph.SetStats(False)
  16. graph.GetYaxis().SetTitleOffset(1.0)
  17. if type(graph) != TEfficiency:
  18. graph.GetYaxis().SetTitleOffset(0.85)
  19. graph.GetYaxis().SetTitleSize(0.06)
  20. graph.GetYaxis().SetLabelSize(0.06)
  21. graph.GetXaxis().SetTitleSize(0.06)
  22. graph.GetXaxis().SetLabelSize(0.06)
  23. graph.GetXaxis().SetTitleFont(132)
  24. graph.GetXaxis().SetLabelFont(132)
  25. graph.GetYaxis().SetTitleFont(132)
  26. graph.GetYaxis().SetLabelFont(132)
  27. return graph
  28. def setLHCbStyle():
  29. global lhcbStyle
  30. lhcbFont = 132
  31. lhcbTSize = 0.05
  32. lhcbWidth = 2
  33. lhcbStyle = TStyle("lhcbStyle", "LHCb plots style")
  34. lhcbStyle.SetFillColor(1)
  35. lhcbStyle.SetFillStyle(1001) # solid 1001
  36. lhcbStyle.SetFrameFillColor(0)
  37. lhcbStyle.SetFrameBorderMode(0)
  38. lhcbStyle.SetPadBorderMode(0)
  39. lhcbStyle.SetPadColor(0)
  40. lhcbStyle.SetCanvasBorderMode(0)
  41. lhcbStyle.SetCanvasColor(0)
  42. lhcbStyle.SetStatColor(0)
  43. lhcbStyle.SetLegendBorderSize(0)
  44. lhcbStyle.SetLegendFont(132)
  45. # use large fonts
  46. lhcbStyle.SetTextFont(lhcbFont)
  47. lhcbStyle.SetTitleFont(lhcbFont)
  48. lhcbStyle.SetTextSize(lhcbTSize)
  49. lhcbStyle.SetLabelFont(lhcbFont, "x")
  50. lhcbStyle.SetLabelFont(lhcbFont, "y")
  51. lhcbStyle.SetLabelFont(lhcbFont, "z")
  52. lhcbStyle.SetLabelSize(lhcbTSize, "x")
  53. lhcbStyle.SetLabelSize(lhcbTSize, "y")
  54. lhcbStyle.SetLabelSize(lhcbTSize, "z")
  55. lhcbStyle.SetTitleFont(lhcbFont)
  56. lhcbStyle.SetTitleFont(lhcbFont, "x")
  57. lhcbStyle.SetTitleFont(lhcbFont, "y")
  58. lhcbStyle.SetTitleFont(lhcbFont, "z")
  59. lhcbStyle.SetTitleSize(1.2 * lhcbTSize, "x")
  60. lhcbStyle.SetTitleSize(1.2 * lhcbTSize, "y")
  61. lhcbStyle.SetTitleSize(1.2 * lhcbTSize, "z")
  62. # set the paper & margin sizes
  63. lhcbStyle.SetPaperSize(20, 26)
  64. lhcbStyle.SetPadTopMargin(0.05)
  65. lhcbStyle.SetPadRightMargin(0.05) # increase for colz plots
  66. lhcbStyle.SetPadBottomMargin(0.16)
  67. lhcbStyle.SetPadLeftMargin(0.14)
  68. # use medium bold lines and thick markers
  69. lhcbStyle.SetLineWidth(lhcbWidth)
  70. lhcbStyle.SetFrameLineWidth(lhcbWidth)
  71. lhcbStyle.SetHistLineWidth(lhcbWidth)
  72. lhcbStyle.SetFuncWidth(lhcbWidth)
  73. lhcbStyle.SetGridWidth(lhcbWidth)
  74. lhcbStyle.SetLineStyleString(2, "[12 12]")
  75. # postscript dashes
  76. lhcbStyle.SetMarkerStyle(20)
  77. lhcbStyle.SetMarkerSize(1.0)
  78. # label offsets
  79. lhcbStyle.SetLabelOffset(0.010, "X")
  80. lhcbStyle.SetLabelOffset(0.010, "Y")
  81. # by default, do not display histogram decorations:
  82. lhcbStyle.SetOptStat(0)
  83. # lhcbStyle.SetOptStat("emr") # show only nent -e , mean - m , rms -r
  84. # full opts at http:#root.cern.ch/root/html/TStyle.html#TStyle:SetOptStat
  85. lhcbStyle.SetStatFormat("6.3g") # specified as c printf options
  86. lhcbStyle.SetOptTitle(0)
  87. lhcbStyle.SetOptFit(0)
  88. # lhcbStyle.SetOptFit(1011) # order is probability, Chi2, errors, parameters
  89. # titles
  90. lhcbStyle.SetTitleOffset(0.95, "X")
  91. lhcbStyle.SetTitleOffset(0.85, "Y")
  92. lhcbStyle.SetTitleOffset(1.2, "Z")
  93. lhcbStyle.SetTitleFillColor(0)
  94. lhcbStyle.SetTitleStyle(0)
  95. lhcbStyle.SetTitleBorderSize(0)
  96. lhcbStyle.SetTitleFont(lhcbFont, "title")
  97. lhcbStyle.SetTitleX(0.0)
  98. lhcbStyle.SetTitleY(1.0)
  99. lhcbStyle.SetTitleW(1.0)
  100. lhcbStyle.SetTitleH(0.05)
  101. # look of the statistics box:
  102. lhcbStyle.SetStatBorderSize(0)
  103. lhcbStyle.SetStatFont(lhcbFont)
  104. lhcbStyle.SetStatFontSize(0.05)
  105. lhcbStyle.SetStatX(0.9)
  106. lhcbStyle.SetStatY(0.9)
  107. lhcbStyle.SetStatW(0.25)
  108. lhcbStyle.SetStatH(0.15)
  109. # put tick marks on top and RHS of plots
  110. lhcbStyle.SetPadTickX(1)
  111. lhcbStyle.SetPadTickY(1)
  112. # histogram divisions: only 5 in x to avoid label overlaps
  113. lhcbStyle.SetNdivisions(505, "x")
  114. lhcbStyle.SetNdivisions(510, "y")
  115. gROOT.SetStyle("lhcbStyle")
  116. return